MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_gsub

Function luaL_gsub

third-party/lua-5.2.4/src/lauxlib.c:902–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900
901
902LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
903 const char *r) {
904 const char *wild;
905 size_t l = strlen(p);
906 luaL_Buffer b;
907 luaL_buffinit(L, &b);
908 while ((wild = strstr(s, p)) != NULL) {
909 luaL_addlstring(&b, s, wild - s); /* push prefix */
910 luaL_addstring(&b, r); /* push replacement in place of pattern */
911 s = wild + l; /* continue after `p' */
912 }
913 luaL_addstring(&b, s); /* push last suffix */
914 luaL_pushresult(&b);
915 return lua_tostring(L, -1);
916}
917
918
919static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {

Callers 4

setprogdirFunction · 0.70
searchpathFunction · 0.70
loadfuncFunction · 0.70
setpathFunction · 0.70

Calls 4

luaL_buffinitFunction · 0.70
luaL_addlstringFunction · 0.70
luaL_addstringFunction · 0.70
luaL_pushresultFunction · 0.70

Tested by

no test coverage detected