aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/include/linux/string.h4
-rw-r--r--tools/lib/string.c14
2 files changed, 17 insertions, 1 deletions
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index 6c3e2cc274c5..cee239350a6b 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -29,4 +29,6 @@ static inline bool strstarts(const char *str, const char *prefix)
29 return strncmp(str, prefix, strlen(prefix)) == 0; 29 return strncmp(str, prefix, strlen(prefix)) == 0;
30} 30}
31 31
32#endif /* _LINUX_STRING_H_ */ 32extern char * __must_check skip_spaces(const char *);
33
34#endif /* _TOOLS_LINUX_STRING_H_ */
diff --git a/tools/lib/string.c b/tools/lib/string.c
index 93b3d4b6feac..50d400822bb3 100644
--- a/tools/lib/string.c
+++ b/tools/lib/string.c
@@ -17,6 +17,7 @@
17#include <string.h> 17#include <string.h>
18#include <errno.h> 18#include <errno.h>
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/ctype.h>
20#include <linux/compiler.h> 21#include <linux/compiler.h>
21 22
22/** 23/**
@@ -106,3 +107,16 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
106 } 107 }
107 return ret; 108 return ret;
108} 109}
110
111/**
112 * skip_spaces - Removes leading whitespace from @str.
113 * @str: The string to be stripped.
114 *
115 * Returns a pointer to the first non-whitespace character in @str.
116 */
117char *skip_spaces(const char *str)
118{
119 while (isspace(*str))
120 ++str;
121 return (char *)str;
122}