aboutsummaryrefslogtreecommitdiffstats
path: root/lib/string.c
diff options
context:
space:
mode:
authorMichael Holzheu <holzheu@linux.vnet.ibm.com>2011-10-31 20:12:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-31 20:30:56 -0400
commit66f6958e69d8055277356d3cc2e7a1d734db1755 (patch)
tree9de78bc91f0640edad882ad1b21280a7da03e349 /lib/string.c
parente3816c5407c800e4fb055d08f668286db6b7113f (diff)
lib/string.c: fix strim() semantics for strings that have only blanks
Commit 84c95c9acf0 ("string: on strstrip(), first remove leading spaces before running over str") improved the performance of the strim() function. Unfortunately this changed the semantics of strim() and broke my code. Before the patch it was possible to use strim() without using the return value for removing trailing spaces from strings that had either only blanks or only trailing blanks. Now this does not work any longer for strings that *only* have blanks. Before patch: " " -> "" (empty string) After patch: " " -> " " (no change) I think we should remove your patch to restore the old behavior. The description (lib/string.c): * Note that the first trailing whitespace is replaced with a %NUL-terminator => The first trailing whitespace of a string that only has whitespace characters is the first whitespace The patch restores the old strim() semantics. Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Cc: Andre Goddard Rosa <andre.goddard@gmail.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/string.c b/lib/string.c
index 11df54325fb8..dc4a86341f91 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -360,7 +360,6 @@ char *strim(char *s)
360 size_t size; 360 size_t size;
361 char *end; 361 char *end;
362 362
363 s = skip_spaces(s);
364 size = strlen(s); 363 size = strlen(s);
365 if (!size) 364 if (!size)
366 return s; 365 return s;
@@ -370,7 +369,7 @@ char *strim(char *s)
370 end--; 369 end--;
371 *(end + 1) = '\0'; 370 *(end + 1) = '\0';
372 371
373 return s; 372 return skip_spaces(s);
374} 373}
375EXPORT_SYMBOL(strim); 374EXPORT_SYMBOL(strim);
376 375