| 534 | |
| 535 | |
| 536 | static void push_onecapture (MatchState *ms, int i, const char *s, |
| 537 | const char *e) { |
| 538 | if (i >= ms->level) { |
| 539 | if (i == 0) /* ms->level == 0, too */ |
| 540 | lua_pushlstring(ms->L, s, e - s); /* add whole match */ |
| 541 | else |
| 542 | luaL_error(ms->L, "invalid capture index"); |
| 543 | } |
| 544 | else { |
| 545 | ptrdiff_t l = ms->capture[i].len; |
| 546 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
| 547 | if (l == CAP_POSITION) |
| 548 | lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); |
| 549 | else |
| 550 | lua_pushlstring(ms->L, ms->capture[i].init, l); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | |
| 555 | static int push_captures (MatchState *ms, const char *s, const char *e) { |
no test coverage detected