From 7bd330de43fd5693e90be13dac7fbd9af3b6335d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 25 Jun 2019 21:23:18 -0300 Subject: tools lib: Adopt skip_spaces() from the kernel sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same implementation, will be used to replace ad-hoc equivalent code in tools/. Cc: Adrian Hunter Cc: André Goddard Rosa Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-dig691cg9ripvoiprpidthw7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/string.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/lib/string.c') 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 #include #include +#include #include /** @@ -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; +} -- cgit v1.2.3