MCPcopy Create free account
hub / github.com/DFHack/dfhack / push_onecapture

Function push_onecapture

depends/lua/src/lstrlib.c:550–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548
549
550static 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
569static 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