diff options
Diffstat (limited to 'tools/lib/string.c')
-rw-r--r-- | tools/lib/string.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/lib/string.c b/tools/lib/string.c index 80472e6b3829..f2ae1b87c719 100644 --- a/tools/lib/string.c +++ b/tools/lib/string.c @@ -145,3 +145,19 @@ char *strim(char *s) return skip_spaces(s); } + +/** + * strreplace - Replace all occurrences of character in string. + * @s: The string to operate on. + * @old: The character being replaced. + * @new: The character @old is replaced with. + * + * Returns pointer to the nul byte at the end of @s. + */ +char *strreplace(char *s, char old, char new) +{ + for (; *s; ++s) + if (*s == old) + *s = new; + return s; +} |