|
@@ -331,6 +331,24 @@ char *strxfrchar(char *s, char from, char to)
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * ltrim - Removes leading whitespace from @s.
|
|
|
+ * @s: The string to be stripped.
|
|
|
+ *
|
|
|
+ * Return pointer to the first non-whitespace character in @s.
|
|
|
+ */
|
|
|
+char *ltrim(char *s)
|
|
|
+{
|
|
|
+ int len = strlen(s);
|
|
|
+
|
|
|
+ while (len && isspace(*s)) {
|
|
|
+ len--;
|
|
|
+ s++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* rtrim - Removes trailing whitespace from @s.
|
|
|
* @s: The string to be stripped.
|