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