Commit 6e6d9fa6 authored by Michael Holzheu's avatar Michael Holzheu Committed by Linus Torvalds

[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: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarMichael Holzheu <holzheu@de.ibm.com>
Acked-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Acked-by Joern Engel <joern@wh.fh-wedel.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5fa3839a
......@@ -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';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment