From 71ae45f48a484426097a134801c9976fd36f5110 Mon Sep 17 00:00:00 2001 From: markw Date: Fri, 9 Mar 2001 00:55:34 +0000 Subject: Fix to trim to make it trim properly. git-svn-id: svn://busybox.net/trunk/busybox@2017 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- utility.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utility.c b/utility.c index b4893a0e1..092cfdb10 100644 --- a/utility.c +++ b/utility.c @@ -1831,13 +1831,13 @@ void chomp(char *s) #if defined(BB_SH) void trim(char *s) { + /* trim trailing whitespace */ + while (isspace(s[strlen(s)-1])) + s[strlen(s)-1]='\0'; + /* trim leading whitespace */ memmove(s, &s[strspn(s, " \n\r\t\v")], strlen(s)); - /* trim trailing whitespace */ - while (*s && (!isspace (*s))) - s++; - *s='\0'; } #endif -- cgit v1.2.3-55-g6feb