提交 6e6d9fa6 编写于 作者: M Michael Holzheu 提交者: 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: NMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: NMichael Holzheu <holzheu@de.ibm.com>
Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
Acked-by Joern Engel <joern@wh.fh-wedel.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册