strstrip remove last blank fix
Subsystems (2)
PATCH 1/1 strstrip remove last blank fix
Hi Pekka,
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:
Signed-off-by Michael Holzheu <[email protected]>
---
lib/string.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
lib/string.c +1 -1
@@ -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' ;
Quoted 2 lines · Michael Holzheu
strstrip()does not remove the last blank from strings which only consist of blanks.
[snip]
Quoted 12 lines
Signed-off-by Michael Holzheu <[email protected]>---
lib/string.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)diff -Naurp
linux-2.6.18/lib/string.clinux-2.6.18-strstrip-fix/lib/string.c
lib/string.c char *strstrip(char *s) · line 325
Quoted 7 lines
lib/string.c +1
-1@@ -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' ;
Looks good, thanks! Andrew, can you please pick up this patch?
Acked-by Pekka Enberg <[email protected]>
Quoted 2 lines · Pekka J Enberg
Acked-by Pekka Enberg <[email protected]>
Acked-by Joern Engel <[email protected]>
Jörn
Signature · 2 lines
Data expands to fill the space available for storage. -- Parkinson's Law