[PATCH 1/3] string: add skip_spaces support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Wed Jan 26 11:46:02 EST 2011
need by parse_args for the command line parsing
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
include/linux/string.h | 1 +
lib/string.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 62d743e..b4b48fb 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -59,6 +59,7 @@ extern char * _strchr(const char *,int);
#ifndef __HAVE_ARCH_STRRCHR
extern char * _strrchr(const char *,int);
#endif
+extern char * skip_spaces(const char *);
#ifndef __HAVE_ARCH_STRSTR
extern char * _strstr(const char *,const char *);
#endif
diff --git a/lib/string.c b/lib/string.c
index 77435aa..5ffb861 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -214,6 +214,20 @@ char * _strrchr(const char * s, int c)
#endif
EXPORT_SYMBOL(_strrchr);
+/**
+ * skip_spaces - Removes leading whitespace from @str.
+ * @str: The string to be stripped.
+ *
+ * Returns a pointer to the first non-whitespace character in @str.
+ */
+char *skip_spaces(const char *str)
+{
+ while (isspace(*str))
+ ++str;
+ return (char *)str;
+}
+EXPORT_SYMBOL(skip_spaces);
+
#ifndef __HAVE_ARCH_STRLEN
/**
* strlen - Find the length of a string
--
1.7.2.3
More information about the barebox
mailing list