| 1024 | |
| 1025 | |
| 1026 | LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, |
| 1027 | const char *p, const char *r) { |
| 1028 | const char *wild; |
| 1029 | size_t l = strlen(p); |
| 1030 | while ((wild = strstr(s, p)) != NULL) { |
| 1031 | luaL_addlstring(b, s, ct_diff2sz(wild - s)); /* push prefix */ |
| 1032 | luaL_addstring(b, r); /* push replacement in place of pattern */ |
| 1033 | s = wild + l; /* continue after 'p' */ |
| 1034 | } |
| 1035 | luaL_addstring(b, s); /* push last suffix */ |
| 1036 | } |
| 1037 | |
| 1038 | |
| 1039 | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, |
no test coverage detected