diff options
author | Eric Andersen | 2001-04-04 22:49:01 +0000 |
---|---|---|
committer | Eric Andersen | 2001-04-04 22:49:01 +0000 |
commit | 3c0364f3911ec9f43e1c8c96ec2c8e30b1b52c47 (patch) | |
tree | 7ad1918c2c76df8f723195e20e9e95d21ef7c4e8 /libbb/trim.c | |
parent | 4fd382ea29c6492f4776aa29b8b298d3c4a98d01 (diff) | |
download | busybox-3c0364f3911ec9f43e1c8c96ec2c8e30b1b52c47.zip busybox-3c0364f3911ec9f43e1c8c96ec2c8e30b1b52c47.tar.gz |
Patch from Larry Doolittle to eliminate needless thrashing
about when trimming long strings with lots of trailing white
space.
Diffstat (limited to 'libbb/trim.c')
-rw-r--r-- | libbb/trim.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libbb/trim.c b/libbb/trim.c index be97d49..78cf235 100644 --- 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); |