diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-04 22:49:01 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-04 22:49:01 +0000 |
commit | ea8519ec8a9e6807e16ca3a138d22201d35b273b (patch) | |
tree | 7ad1918c2c76df8f723195e20e9e95d21ef7c4e8 | |
parent | c932d11a914833d393b9aed0f8d938cfbf687f74 (diff) | |
download | busybox-w32-ea8519ec8a9e6807e16ca3a138d22201d35b273b.tar.gz busybox-w32-ea8519ec8a9e6807e16ca3a138d22201d35b273b.tar.bz2 busybox-w32-ea8519ec8a9e6807e16ca3a138d22201d35b273b.zip |
Patch from Larry Doolittle to eliminate needless thrashing
about when trimming long strings with lots of trailing white
space.
git-svn-id: svn://busybox.net/trunk/busybox@2247 69ca8d6d-28ef-0310-b511-8ec308f3f277
-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 be97d4924..78cf235dd 100644 --- a/libbb/trim.c +++ b/libbb/trim.c | |||
@@ -33,11 +33,11 @@ | |||
33 | 33 | ||
34 | void trim(char *s) | 34 | void trim(char *s) |
35 | { | 35 | { |
36 | int len; | 36 | int len=strlen(s); |
37 | 37 | ||
38 | /* trim trailing whitespace */ | 38 | /* trim trailing whitespace */ |
39 | while ( (len=strlen(s)) >= 1 && isspace(s[len-1])) | 39 | while ( len > 0 && isspace(s[len-1])) |
40 | s[len-1]='\0'; | 40 | s[--len]='\0'; |
41 | 41 | ||
42 | /* trim leading whitespace */ | 42 | /* trim leading whitespace */ |
43 | memmove(s, &s[strspn(s, " \n\r\t\v")], len); | 43 | memmove(s, &s[strspn(s, " \n\r\t\v")], len); |