Skip to content

Commit 28cf5ce

Browse files
committed
feature: added the FFI API for 'str_replace_char()'.
1 parent f87d1f1 commit 28cf5ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ngx_http_lua_string.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,20 @@ ngx_http_lua_ffi_escape_uri(const u_char *src, size_t len, u_char *dst)
762762
ngx_http_lua_escape_uri(dst, (u_char *) src, len, NGX_ESCAPE_URI_COMPONENT);
763763
}
764764

765+
766+
void
767+
ngx_http_lua_ffi_str_replace_char(u_char *buf, size_t len, const u_char find,
768+
const u_char replace)
769+
{
770+
while (len) {
771+
if (*buf == find) {
772+
*buf = replace;
773+
}
774+
775+
buf++;
776+
len--;
777+
}
778+
}
765779
#endif
766780

767781
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

0 commit comments

Comments
 (0)