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