mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Holzheu <holzheu@de.ibm.com>
To: penberg@cs.helsinki.fi
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org,
	joern@wohnheim.fh-wedel.de, schwidefsky@de.ibm.com,
	ioe-lkml@rameria.de, minyard@acm.org
Subject: [PATCH] strstrip remove last blank fix
Date: Thu, 26 Oct 2006 13:07:03 +0200	[thread overview]
Message-ID: <20061026130703.6f8cc0bd.holzheu@de.ibm.com> (raw)

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';
 


             reply	other threads:[~2006-10-26 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26 11:07 Michael Holzheu [this message]
2006-10-26 11:20 ` Pekka J Enberg
2006-10-26 12:44   ` Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061026130703.6f8cc0bd.holzheu@de.ibm.com \
    --to=holzheu@de.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ioe-lkml@rameria.de \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®