From: Michael Holzheu Date: Sat, 28 Oct 2006 17:38:47 +0000 (-0700) Subject: [PATCH] strstrip remove last blank fix X-Git-Tag: v3.12-rc1~32144^2~7^2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e6d9fa6f95e382bb2d5725dda18b9e811418e79;p=kernel%2Fkernel-generic.git [PATCH] strstrip remove last blank fix strstrip() does not remove the last blank from strings which only consist of blanks. Example: char string[] = " "; strstrip(string); results in " ", but should produce an empty string! The following patch solves this problem: Acked-by: Martin Schwidefsky Signed-off-by: Michael Holzheu Acked-by: Pekka Enberg Acked-by Joern Engel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/string.c b/lib/string.c index 6307726..a485d75 100644 --- a/lib/string.c +++ b/lib/string.c @@ -320,7 +320,7 @@ char *strstrip(char *s) return s; end = s + size - 1; - while (end != s && isspace(*end)) + while (end >= s && isspace(*end)) end--; *(end + 1) = '\0';