MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gmatch_aux

Function gmatch_aux

freebsd/contrib/openzfs/module/lua/lstrlib.c:650–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648
649
650static int gmatch_aux (lua_State *L) {
651 MatchState ms;
652 size_t ls, lp;
653 const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
654 const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp);
655 const char *src;
656 ms.L = L;
657 ms.matchdepth = MAXCCALLS;
658 ms.src_init = s;
659 ms.src_end = s+ls;
660 ms.p_end = p + lp;
661 for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
662 src <= ms.src_end;
663 src++) {
664 const char *e;
665 ms.level = 0;
666 lua_assert(ms.matchdepth == MAXCCALLS);
667 if ((e = match(&ms, src, p)) != NULL) {
668 lua_Integer newstart = e-s;
669 if (e == src) newstart++; /* empty match? go at least one position */
670 lua_pushinteger(L, newstart);
671 lua_replace(L, lua_upvalueindex(3));
672 return push_captures(&ms, src, e);
673 }
674 }
675 return 0; /* not found */
676}
677
678
679static int str_gmatch (lua_State *L) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected