diff options
-rw-r--r-- | include/linux/ctype.h | 1 | ||||
-rw-r--r-- | include/linux/string.h | 1 | ||||
-rw-r--r-- | lib/string.c | 19 |
3 files changed, 17 insertions, 4 deletions
diff --git a/include/linux/ctype.h b/include/linux/ctype.h index 6dec944a370b..a3d6ee0044f9 100644 --- a/include/linux/ctype.h +++ b/include/linux/ctype.h | |||
@@ -27,6 +27,7 @@ extern const unsigned char _ctype[]; | |||
27 | #define islower(c) ((__ismask(c)&(_L)) != 0) | 27 | #define islower(c) ((__ismask(c)&(_L)) != 0) |
28 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) | 28 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) |
29 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) | 29 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) |
30 | /* Note: isspace() must return false for %NUL-terminator */ | ||
30 | #define isspace(c) ((__ismask(c)&(_S)) != 0) | 31 | #define isspace(c) ((__ismask(c)&(_S)) != 0) |
31 | #define isupper(c) ((__ismask(c)&(_U)) != 0) | 32 | #define isupper(c) ((__ismask(c)&(_U)) != 0) |
32 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) | 33 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) |
diff --git a/include/linux/string.h b/include/linux/string.h index b8508868d5ad..168dad11ae03 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -62,6 +62,7 @@ extern char * strnchr(const char *, size_t, int); | |||
62 | #ifndef __HAVE_ARCH_STRRCHR | 62 | #ifndef __HAVE_ARCH_STRRCHR |
63 | extern char * strrchr(const char *,int); | 63 | extern char * strrchr(const char *,int); |
64 | #endif | 64 | #endif |
65 | extern char * __must_check skip_spaces(const char *); | ||
65 | extern char * __must_check strstrip(char *); | 66 | extern char * __must_check strstrip(char *); |
66 | #ifndef __HAVE_ARCH_STRSTR | 67 | #ifndef __HAVE_ARCH_STRSTR |
67 | extern char * strstr(const char *,const char *); | 68 | extern char * strstr(const char *,const char *); |
diff --git a/lib/string.c b/lib/string.c index e96421ab9a9a..3a912a4e9a63 100644 --- a/lib/string.c +++ b/lib/string.c | |||
@@ -338,6 +338,20 @@ EXPORT_SYMBOL(strnchr); | |||
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * skip_spaces - Removes leading whitespace from @s. | ||
342 | * @s: The string to be stripped. | ||
343 | * | ||
344 | * Returns a pointer to the first non-whitespace character in @s. | ||
345 | */ | ||
346 | char *skip_spaces(const char *str) | ||
347 | { | ||
348 | while (isspace(*str)) | ||
349 | ++str; | ||
350 | return (char *)str; | ||
351 | } | ||
352 | EXPORT_SYMBOL(skip_spaces); | ||
353 | |||
354 | /** | ||
341 | * strstrip - Removes leading and trailing whitespace from @s. | 355 | * strstrip - Removes leading and trailing whitespace from @s. |
342 | * @s: The string to be stripped. | 356 | * @s: The string to be stripped. |
343 | * | 357 | * |
@@ -360,10 +374,7 @@ char *strstrip(char *s) | |||
360 | end--; | 374 | end--; |
361 | *(end + 1) = '\0'; | 375 | *(end + 1) = '\0'; |
362 | 376 | ||
363 | while (*s && isspace(*s)) | 377 | return skip_spaces(s); |
364 | s++; | ||
365 | |||
366 | return s; | ||
367 | } | 378 | } |
368 | EXPORT_SYMBOL(strstrip); | 379 | EXPORT_SYMBOL(strstrip); |
369 | 380 | ||