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

Function gmatch

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

Source from the content-addressed store, hash-verified

855
856
857static int gmatch (lua_State *L) {
858 size_t ls, lp;
859 const char *s = luaL_checklstring(L, 1, &ls);
860 const char *p = luaL_checklstring(L, 2, &lp);
861 size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1;
862 GMatchState *gm;
863 lua_settop(L, 2); /* keep strings on closure to avoid being collected */
864 gm = (GMatchState *)lua_newuserdatauv(L, sizeof(GMatchState), 0);
865 if (init > ls) /* start after string's end? */
866 init = ls + 1; /* avoid overflows in 's + init' */
867 prepstate(&gm->ms, L, s, ls, p, lp);
868 gm->src = s + init; gm->p = p; gm->lastmatch = NULL;
869 lua_pushcclosure(L, gmatch_aux, 3);
870 return 1;
871}
872
873
874static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,

Callers

nothing calls this directly

Calls 7

luaL_checklstringFunction · 0.70
posrelatIFunction · 0.70
luaL_optintegerFunction · 0.70
lua_settopFunction · 0.70
lua_newuserdatauvFunction · 0.70
prepstateFunction · 0.70
lua_pushcclosureFunction · 0.70

Tested by

no test coverage detected