MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaL_gsub

Function luaL_gsub

Source/Misc/lua/src/lua.c:10552–10566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10550
10551
10552LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
10553const char *r) {
10554const char *wild;
10555size_t l = strlen(p);
10556luaL_Buffer b;
10557luaL_buffinit(L, &b);
10558while ((wild = strstr(s, p)) != NULL) {
10559luaL_addlstring(&b, s, wild - s); /* push prefix */
10560luaL_addstring(&b, r); /* push replacement in place of pattern */
10561s = wild + l; /* continue after `p' */
10562}
10563luaL_addstring(&b, s); /* push last suffix */
10564luaL_pushresult(&b);
10565return lua_tostring(L, -1);
10566}
10567
10568
10569LUALIB_API const char *luaL_findtable (lua_State *L, int idx,

Callers 4

setprogdirFunction · 0.85
findfileFunction · 0.85
mkfuncnameFunction · 0.85
setpathFunction · 0.85

Calls 4

luaL_buffinitFunction · 0.85
luaL_addlstringFunction · 0.85
luaL_addstringFunction · 0.85
luaL_pushresultFunction · 0.85

Tested by

no test coverage detected