From ea8519ec8a9e6807e16ca3a138d22201d35b273b Mon Sep 17 00:00:00 2001 From: andersen Date: Wed, 4 Apr 2001 22:49:01 +0000 Subject: 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 --- libbb/trim.c | 6 +++--- 1 file 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 @@ 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); -- cgit v1.2.3-55-g6feb