| 756 | |
| 757 | |
| 758 | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, |
| 759 | const char *r) { |
| 760 | const char *wild; |
| 761 | size_t l = strlen(p); |
| 762 | luaL_Buffer b; |
| 763 | luaL_buffinit(L, &b); |
| 764 | while ((wild = strstr(s, p)) != NULL) { |
| 765 | luaL_addlstring(&b, s, wild - s); /* push prefix */ |
| 766 | luaL_addstring(&b, r); /* push replacement in place of pattern */ |
| 767 | s = wild + l; /* continue after `p' */ |
| 768 | } |
| 769 | luaL_addstring(&b, s); /* push last suffix */ |
| 770 | luaL_pushresult(&b); |
| 771 | return lua_tostring(L, -1); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { |
nothing calls this directly
no test coverage detected