MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / push_onecapture

Function push_onecapture

deps/lua/src/lstrlib.c:466–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464
465
466static 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
485static int push_captures (MatchState *ms, const char *s, const char *e) {

Callers 3

push_capturesFunction · 0.85
add_sFunction · 0.85
add_valueFunction · 0.85

Calls 3

lua_pushlstringFunction · 0.85
luaL_errorFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected