include/strutils: add functions to replace and remove chars from string
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
7761bd3bb6
commit
3c4ff2dc9d
|
@ -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, ...)
|
||||
|
|
Loading…
Reference in New Issue