| 545 | |
| 546 | |
| 547 | static void push_onecapture (MatchState *ms, int i, const char *s, |
| 548 | const char *e) { |
| 549 | if (i >= ms->level) { |
| 550 | if (i == 0) /* ms->level == 0, too */ |
| 551 | lua_pushlstring(ms->L, s, e - s); /* add whole match */ |
| 552 | else |
| 553 | luaL_error(ms->L, "invalid capture index"); |
| 554 | } |
| 555 | else { |
| 556 | ptrdiff_t l = ms->capture[i].len; |
| 557 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
| 558 | if (l == CAP_POSITION) |
| 559 | lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); |
| 560 | else |
| 561 | lua_pushlstring(ms->L, ms->capture[i].init, l); |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | |
| 566 | static int push_captures (MatchState *ms, const char *s, const char *e) { |
no test coverage detected