| 561 | |
| 562 | |
| 563 | static void push_onecapture(MatchState *ms, int i, const char *s, |
| 564 | const char *e) { |
| 565 | if (i >= ms->level) { |
| 566 | if (i == 0) /* ms->level == 0, too */ |
| 567 | lua_pushlstring(ms->L, s, e - s); /* add whole match */ |
| 568 | else |
| 569 | luaL_error(ms->L, "invalid capture index %%%d", i + 1); |
| 570 | } |
| 571 | else { |
| 572 | ptrdiff_t l = ms->capture[i].len; |
| 573 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
| 574 | if (l == CAP_POSITION) |
| 575 | lua_pushinteger(ms->L, (ms->capture[i].init - ms->src_init) + 1); |
| 576 | else |
| 577 | lua_pushlstring(ms->L, ms->capture[i].init, l); |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | |
| 582 | static int push_captures(MatchState *ms, const char *s, const char *e) { |
no test coverage detected