MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaL_gsub

Function luaL_gsub

libraries/AP_Scripting/lua/src/lauxlib.c:996–1010  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

994
995
996LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
997 const char *r) {
998 const char *wild;
999 size_t l = strlen(p);
1000 luaL_Buffer b;
1001 luaL_buffinit(L, &b);
1002 while ((wild = strstr(s, p)) != NULL) {
1003 luaL_addlstring(&b, s, wild - s); /* push prefix */
1004 luaL_addstring(&b, r); /* push replacement in place of pattern */
1005 s = wild + l; /* continue after 'p' */
1006 }
1007 luaL_addstring(&b, s); /* push last suffix */
1008 luaL_pushresult(&b);
1009 return lua_tostring(L, -1);
1010}
1011
1012
1013// static 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 5

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

Tested by

no test coverage detected