aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/trim.c6
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 @@
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);