| 464 | |
| 465 | |
| 466 | static void push_onecapture (MatchState *ms, int i, const char *s, |
| 467 | const char *e) { |
| 468 | if (i >= ms->level) { |
| 469 | if (i == 0) /* ms->level == 0, too */ |
| 470 | lua_pushlstring(ms->L, s, e - s); /* add whole match */ |
| 471 | else |
| 472 | luaL_error(ms->L, "invalid capture index"); |
| 473 | } |
| 474 | else { |
| 475 | ptrdiff_t l = ms->capture[i].len; |
| 476 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
| 477 | if (l == CAP_POSITION) |
| 478 | lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); |
| 479 | else |
| 480 | lua_pushlstring(ms->L, ms->capture[i].init, l); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | |
| 485 | static int push_captures (MatchState *ms, const char *s, const char *e) { |
no test coverage detected