Skip to content

Commit

Permalink
[PATCH] strstrip remove last blank fix
Browse files Browse the repository at this point in the history
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 <schwidefsky@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by Joern Engel <joern@wh.fh-wedel.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Michael Holzheu authored and Linus Torvalds committed Oct 28, 2006
1 parent 5fa3839 commit 6e6d9fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 6e6d9fa

Please sign in to comment.