MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gmatch

Function gmatch

extlibs/lua/src/lstrlib.c:851–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected