diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-25 20:23:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-25 20:23:18 -0400 |
commit | 7bd330de43fd5693e90be13dac7fbd9af3b6335d (patch) | |
tree | 0e3a3029bbb61d14730f84ae08a0be89d6dd2477 /tools/lib/string.c | |
parent | bd9860bf050f77c4e260a9ae10a5587009ad6e07 (diff) |
tools lib: Adopt skip_spaces() from the kernel sources
Same implementation, will be used to replace ad-hoc equivalent code in
tools/.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-dig691cg9ripvoiprpidthw7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/string.c')
-rw-r--r-- | tools/lib/string.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 | */ | ||
117 | char *skip_spaces(const char *str) | ||
118 | { | ||
119 | while (isspace(*str)) | ||
120 | ++str; | ||
121 | return (char *)str; | ||
122 | } | ||