X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=lib%2Fstring.c;h=13d1e84ddb80e983a325011fb8dd8b6ff9ce0600;hb=05a8256c586ab75bcd6b793737b2022a1a98cb1e;hp=bb3d4b6993c408321da2268b07b1eeefe57cd854;hpb=2cc5df6daeada938d1f90210b038f60c881a5102;p=karo-tx-linux.git diff --git a/lib/string.c b/lib/string.c index bb3d4b6993c4..13d1e84ddb80 100644 --- a/lib/string.c +++ b/lib/string.c @@ -849,3 +849,20 @@ void *memchr_inv(const void *start, int c, size_t bytes) return check_bytes8(start, value, bytes % 8); } EXPORT_SYMBOL(memchr_inv); + +/** + * 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; +} +EXPORT_SYMBOL(strreplace);