diff options
-rw-r--r-- | include/strutils.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/strutils.h b/include/strutils.h index 65d5259db..5584ac5ec 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -248,6 +248,22 @@ static inline size_t ltrim_whitespace(unsigned char *str) return len; } +static inline void strrep(char *s, int find, int replace) +{ + while (s && *s && (s = strchr(s, find)) != NULL) + *s++ = replace; +} + +static inline void strrem(char *s, int rem) +{ + char *p; + + for (p = s; s && *s; s++) { + if (*s != rem) + *p++ = *s; + } +} + extern char *strnappend(const char *s, const char *suffix, size_t b); extern char *strappend(const char *s, const char *suffix); extern char *strfappend(const char *s, const char *format, ...) |