| 1001 | |
| 1002 | |
| 1003 | LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, |
| 1004 | const char *p, const char *r) { |
| 1005 | const char *wild; |
| 1006 | size_t l = strlen(p); |
| 1007 | while ((wild = strstr(s, p)) != NULL) { |
| 1008 | luaL_addlstring(b, s, wild - s); /* push prefix */ |
| 1009 | luaL_addstring(b, r); /* push replacement in place of pattern */ |
| 1010 | s = wild + l; /* continue after 'p' */ |
| 1011 | } |
| 1012 | luaL_addstring(b, s); /* push last suffix */ |
| 1013 | } |
| 1014 | |
| 1015 | |
| 1016 | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, |
no test coverage detected