MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / get_onecapture

Function get_onecapture

third-party/lua-5.5.0/src/lstrlib.c:704–722  ·  view source on GitHub ↗

** get information about the i-th capture. If there are no captures ** and 'i==0', return information about the whole match, which ** is the range 's'..'e'. If the capture is a string, return ** its length and put its address in '*cap'. If it is an integer ** (a position), push it on the stack and return CAP_POSITION. */

Source from the content-addressed store, hash-verified

702** (a position), push it on the stack and return CAP_POSITION.
703*/
704static ptrdiff_t get_onecapture (MatchState *ms, int i, const char *s,
705 const char *e, const char **cap) {
706 if (i >= ms->level) {
707 if (l_unlikely(i != 0))
708 luaL_error(ms->L, "invalid capture index %%%d", i + 1);
709 *cap = s;
710 return (e - s);
711 }
712 else {
713 ptrdiff_t capl = ms->capture[i].len;
714 *cap = ms->capture[i].init;
715 if (l_unlikely(capl == CAP_UNFINISHED))
716 luaL_error(ms->L, "unfinished capture");
717 else if (capl == CAP_POSITION)
718 lua_pushinteger(ms->L,
719 ct_diff2S(ms->capture[i].init - ms->src_init) + 1);
720 return capl;
721 }
722}
723
724
725/*

Callers 2

push_onecaptureFunction · 0.70
add_sFunction · 0.70

Calls 2

luaL_errorFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected