Commit 6e6d9fa6f95e382bb2d5725dda18b9e811418e79

Authored by Michael Holzheu
Committed by Linus Torvalds
1 parent 5fa3839a64

[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 <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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -320,7 +320,7 @@
320 320 return s;
321 321  
322 322 end = s + size - 1;
323   - while (end != s && isspace(*end))
  323 + while (end >= s && isspace(*end))
324 324 end--;
325 325 *(end + 1) = '\0';
326 326