MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / gmatch

Function gmatch

lib/lua/src/lstrlib.c:854–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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