MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / push_onecapture

Function push_onecapture

src/Chain/libraries/glua/lstrlib.cpp:563–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561
562
563static 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
582static 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