|
@@ -313,6 +313,24 @@ int strtailcmp(const char *s1, const char *s2)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * strxfrchar - Locate and replace character in @s
|
|
|
+ * @s: The string to be searched/changed.
|
|
|
+ * @from: Source character to be replaced.
|
|
|
+ * @to: Destination character.
|
|
|
+ *
|
|
|
+ * Return pointer to the changed string.
|
|
|
+ */
|
|
|
+char *strxfrchar(char *s, char from, char to)
|
|
|
+{
|
|
|
+ char *p = s;
|
|
|
+
|
|
|
+ while ((p = strchr(p, from)) != NULL)
|
|
|
+ *p++ = to;
|
|
|
+
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* rtrim - Removes trailing whitespace from @s.
|
|
|
* @s: The string to be stripped.
|