| 14141 | |
| 14142 | |
| 14143 | static void push_onecapture (MatchState *ms, int i, const char *s, |
| 14144 | const char *e) { |
| 14145 | if (i >= ms->level) { |
| 14146 | if (i == 0) /* ms->level == 0, too */ |
| 14147 | lua_pushlstring(ms->L, s, e - s); /* add whole match */ |
| 14148 | else |
| 14149 | luaL_error(ms->L, "invalid capture index"); |
| 14150 | } |
| 14151 | else { |
| 14152 | ptrdiff_t l = ms->capture[i].len; |
| 14153 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
| 14154 | if (l == CAP_POSITION) |
| 14155 | lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); |
| 14156 | else |
| 14157 | lua_pushlstring(ms->L, ms->capture[i].init, l); |
| 14158 | } |
| 14159 | } |
| 14160 | |
| 14161 | |
| 14162 | static int push_captures (MatchState *ms, const char *s, const char *e) { |
no test coverage detected