Patch from Larry Doolittle to eliminate needless thrashing

about when trimming long strings with lots of trailing white
space.
This commit is contained in:
Eric Andersen 2001-04-04 22:49:01 +00:00
parent 4fd382ea29
commit 3c0364f391

View File

@ -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);