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

Function luaL_gsub

app/redis-6.2.6/deps/lua/src/lauxlib.c:340–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338
339
340LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
341 const char *r) {
342 const char *wild;
343 size_t l = strlen(p);
344 luaL_Buffer b;
345 luaL_buffinit(L, &b);
346 while ((wild = strstr(s, p)) != NULL) {
347 luaL_addlstring(&b, s, wild - s); /* push prefix */
348 luaL_addstring(&b, r); /* push replacement in place of pattern */
349 s = wild + l; /* continue after `p' */
350 }
351 luaL_addstring(&b, s); /* push last suffix */
352 luaL_pushresult(&b);
353 return lua_tostring(L, -1);
354}
355
356
357LUALIB_API const char *luaL_findtable (lua_State *L, int idx,

Callers 4

setprogdirFunction · 0.70
findfileFunction · 0.70
mkfuncnameFunction · 0.70
setpathFunction · 0.70

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