MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / gmatch_aux

Function gmatch_aux

deps/lua/src/lstrlib.c:548–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546
547
548static int gmatch_aux (lua_State *L) {
549 MatchState ms;
550 size_t ls;
551 const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
552 const char *p = lua_tostring(L, lua_upvalueindex(2));
553 const char *src;
554 ms.L = L;
555 ms.src_init = s;
556 ms.src_end = s+ls;
557 for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
558 src <= ms.src_end;
559 src++) {
560 const char *e;
561 ms.level = 0;
562 if ((e = match(&ms, src, p)) != NULL) {
563 lua_Integer newstart = e-s;
564 if (e == src) newstart++; /* empty match? go at least one position */
565 lua_pushinteger(L, newstart);
566 lua_replace(L, lua_upvalueindex(3));
567 return push_captures(&ms, src, e);
568 }
569 }
570 return 0; /* not found */
571}
572
573
574static int gmatch (lua_State *L) {

Callers

nothing calls this directly

Calls 6

lua_tolstringFunction · 0.85
lua_tointegerFunction · 0.85
matchFunction · 0.85
lua_pushintegerFunction · 0.85
lua_replaceFunction · 0.85
push_capturesFunction · 0.85

Tested by

no test coverage detected