Commit 93292988 authored by Nicolas Michon's avatar Nicolas Michon

Add bctbx_replace utility function

parent 8c92e63c
......@@ -369,7 +369,8 @@ BCTBX_PUBLIC char *bctbx_strdup_printf(const char *fmt,...);
BCTBX_PUBLIC char *bctbx_strdup_vprintf(const char *fmt, va_list ap);
BCTBX_PUBLIC char *bctbx_strcat_printf(char *dst, const char *fmt,...);
BCTBX_PUBLIC char *bctbx_strcat_vprintf(char *dst, const char *fmt, va_list ap);
BCTBX_PUBLIC char *bctbx_concat (const char *str, ...) ;
BCTBX_PUBLIC char *bctbx_concat(const char *str, ...);
BCTBX_PUBLIC char *bctbx_replace(char *str, char c, char n);
/**
* Portable version of the dirname function from libgen.h
......
......@@ -1472,6 +1472,18 @@ void bctbx_sockaddr_ipv4_to_ipv6(const struct sockaddr *v4, struct sockaddr *res
}
}
char *bctbx_replace(char *str, char c, char n) {
char *s = str;
while (*s) {
if (*s == c) {
*s = n;
}
++s;
}
return str;
}
char * bctbx_concat(const char *str, ...) {
va_list ap;
size_t allocated = 100;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment