]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - lib/string.c
string: factorize skip_spaces and export it to be generally available
[mv-sheeva.git] / lib / string.c
index e96421ab9a9a0a1a8ddd4496e32789acdc4b0749..3a912a4e9a632a3cf63d1da2f4da6dd502e82ff5 100644 (file)
@@ -337,6 +337,20 @@ char *strnchr(const char *s, size_t count, int c)
 EXPORT_SYMBOL(strnchr);
 #endif
 
+/**
+ * skip_spaces - Removes leading whitespace from @s.
+ * @s: The string to be stripped.
+ *
+ * Returns a pointer to the first non-whitespace character in @s.
+ */
+char *skip_spaces(const char *str)
+{
+       while (isspace(*str))
+               ++str;
+       return (char *)str;
+}
+EXPORT_SYMBOL(skip_spaces);
+
 /**
  * strstrip - Removes leading and trailing whitespace from @s.
  * @s: The string to be stripped.
@@ -360,10 +374,7 @@ char *strstrip(char *s)
                end--;
        *(end + 1) = '\0';
 
-       while (*s && isspace(*s))
-               s++;
-
-       return s;
+       return skip_spaces(s);
 }
 EXPORT_SYMBOL(strstrip);