MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / luaL_gsub

Function luaL_gsub

other_src/lua/src/lauxlib.cpp:365–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363
364
365LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
366 const char *r) {
367 const char *wild;
368 size_t l = strlen(p);
369 luaL_Buffer b;
370 luaL_buffinit(L, &b);
371 while ((wild = strstr(s, p)) != NULL) {
372 luaL_addlstring(&b, s, wild - s); /* push prefix */
373 luaL_addstring(&b, r); /* push replacement in place of pattern */
374 s = wild + l; /* continue after `p' */
375 }
376 luaL_addstring(&b, s); /* push last suffix */
377 luaL_pushresult(&b);
378 return lua_tostring(L, -1);
379}
380
381
382LUALIB_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 4

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

Tested by

no test coverage detected