MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaL_gsub

Function luaL_gsub

lua/lauxlib.c:388–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386
387
388LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
389 const char *r) {
390 const char *wild;
391 size_t l = strlen(p);
392 luaL_Buffer b;
393 luaL_buffinit(L, &b);
394 while ((wild = strstr(s, p)) != NULL) {
395 luaL_addlstring(&b, s, wild - s); /* push prefix */
396 luaL_addstring(&b, r); /* push replacement in place of pattern */
397 s = wild + l; /* continue after `p' */
398 }
399 luaL_addstring(&b, s); /* push last suffix */
400 luaL_pushresult(&b);
401 return lua_tostring(L, -1);
402}
403
404
405LUALIB_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