* [PATCH] strstrip remove last blank fix
@ 2006-10-26 11:07 Michael Holzheu
2006-10-26 11:20 ` Pekka J Enberg
0 siblings, 1 reply; 3+ messages in thread
From: Michael Holzheu @ 2006-10-26 11:07 UTC (permalink / raw)
To: penberg; +Cc: linux-kernel, akpm, joern, schwidefsky, ioe-lkml, minyard
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:
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
---
lib/string.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff -Naurp linux-2.6.18/lib/string.c linux-2.6.18-strstrip-fix/lib/string.c
--- linux-2.6.18/lib/string.c 2006-06-19 14:03:20.000000000 +0200
+++ linux-2.6.18-strstrip-fix/lib/string.c 2006-10-25 18:36:08.000000000 +0200
@@ -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';
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] strstrip remove last blank fix
2006-10-26 11:07 [PATCH] strstrip remove last blank fix Michael Holzheu
@ 2006-10-26 11:20 ` Pekka J Enberg
2006-10-26 12:44 ` Jörn Engel
0 siblings, 1 reply; 3+ messages in thread
From: Pekka J Enberg @ 2006-10-26 11:20 UTC (permalink / raw)
To: Michael Holzheu; +Cc: linux-kernel, akpm, joern, schwidefsky, ioe-lkml, minyard
On Thu, 26 Oct 2006, Michael Holzheu wrote:
> strstrip() does not remove the last blank from strings which only consist
> of blanks.
[snip]
> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
>
> ---
>
> lib/string.c | 2 +-
> 1 files changed, 1 insertion(+), 1 deletion(-)
>
> diff -Naurp linux-2.6.18/lib/string.c linux-2.6.18-strstrip-fix/lib/string.c
> --- linux-2.6.18/lib/string.c 2006-06-19 14:03:20.000000000 +0200
> +++ linux-2.6.18-strstrip-fix/lib/string.c 2006-10-25 18:36:08.000000000 +0200
> @@ -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 <penberg@cs.helsinki.fi>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] strstrip remove last blank fix
2006-10-26 11:20 ` Pekka J Enberg
@ 2006-10-26 12:44 ` Jörn Engel
0 siblings, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2006-10-26 12:44 UTC (permalink / raw)
To: Pekka J Enberg
Cc: Michael Holzheu, linux-kernel, akpm, schwidefsky, ioe-lkml, minyard
On Thu, 26 October 2006 14:20:56 +0300, Pekka J Enberg wrote:
>
> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by Joern Engel <joern@wh.fh-wedel.de>
Jörn
--
Data expands to fill the space available for storage.
-- Parkinson's Law
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-26 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-26 11:07 [PATCH] strstrip remove last blank fix Michael Holzheu
2006-10-26 11:20 ` Pekka J Enberg
2006-10-26 12:44 ` Jörn Engel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®