projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4fd382e
)
Patch from Larry Doolittle to eliminate needless thrashing
author
Eric Andersen
<andersen@codepoet.org>
Wed, 4 Apr 2001 22:49:01 +0000
(22:49 -0000)
committer
Eric Andersen
<andersen@codepoet.org>
Wed, 4 Apr 2001 22:49:01 +0000
(22:49 -0000)
about when trimming long strings with lots of trailing white
space.
libbb/trim.c
patch
|
blob
|
history
diff --git
a/libbb/trim.c
b/libbb/trim.c
index be97d4924192f4758d3b2884547a12ed91e16d43..78cf235dd006cae01c326006d69e2d79e24f3e18 100644
(file)
--- a/
libbb/trim.c
+++ b/
libbb/trim.c
@@
-33,11
+33,11
@@
void trim(char *s)
{
- int len;
+ int len
=strlen(s)
;
/* trim trailing whitespace */
- while (
(len=strlen(s)) >= 1
&& isspace(s[len-1]))
- s[
len-1
]='\0';
+ while (
len > 0
&& isspace(s[len-1]))
+ s[
--len
]='\0';
/* trim leading whitespace */
memmove(s, &s[strspn(s, " \n\r\t\v")], len);