diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-26 03:23:18 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-26 03:23:18 +0300 |
commit | 7bd330de43fd5693e90be13dac7fbd9af3b6335d (patch) | |
tree | 0e3a3029bbb61d14730f84ae08a0be89d6dd2477 /tools/lib/string.c | |
parent | bd9860bf050f77c4e260a9ae10a5587009ad6e07 (diff) | |
download | linux-7bd330de43fd5693e90be13dac7fbd9af3b6335d.tar.xz |
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 @@ #include <string.h> #include <errno.h> #include <linux/string.h> +#include <linux/ctype.h> #include <linux/compiler.h> /** @@ -106,3 +107,16 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size) } return ret; } + +/** + * 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; +} |