MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaL_gsub

Function luaL_gsub

depends/lua/src/lauxlib.c:991–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989
990
991LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
992 const char *r) {
993 const char *wild;
994 size_t l = strlen(p);
995 luaL_Buffer b;
996 luaL_buffinit(L, &b);
997 while ((wild = strstr(s, p)) != NULL) {
998 luaL_addlstring(&b, s, wild - s); /* push prefix */
999 luaL_addstring(&b, r); /* push replacement in place of pattern */
1000 s = wild + l; /* continue after 'p' */
1001 }
1002 luaL_addstring(&b, s); /* push last suffix */
1003 luaL_pushresult(&b);
1004 return lua_tostring(L, -1);
1005}
1006
1007
1008static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {

Callers 4

setprogdirFunction · 0.85
setpathFunction · 0.85
searchpathFunction · 0.85
loadfuncFunction · 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