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

Function luaL_gsub

freebsd/contrib/openzfs/module/lua/lauxlib.c:758–772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756
757
758LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
759 const char *r) {
760 const char *wild;
761 size_t l = strlen(p);
762 luaL_Buffer b;
763 luaL_buffinit(L, &b);
764 while ((wild = strstr(s, p)) != NULL) {
765 luaL_addlstring(&b, s, wild - s); /* push prefix */
766 luaL_addstring(&b, r); /* push replacement in place of pattern */
767 s = wild + l; /* continue after `p' */
768 }
769 luaL_addstring(&b, s); /* push last suffix */
770 luaL_pushresult(&b);
771 return lua_tostring(L, -1);
772}
773
774
775LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) {

Callers

nothing calls this directly

Calls 5

strstrFunction · 0.85
luaL_buffinitFunction · 0.70
luaL_addlstringFunction · 0.70
luaL_addstringFunction · 0.70
luaL_pushresultFunction · 0.70

Tested by

no test coverage detected