Patch from Larry Doolittle to eliminate needless thrashing
about when trimming long strings with lots of trailing white space.
This commit is contained in:
parent
4fd382ea29
commit
3c0364f391
@ -33,11 +33,11 @@
|
|||||||
|
|
||||||
void trim(char *s)
|
void trim(char *s)
|
||||||
{
|
{
|
||||||
int len;
|
int len=strlen(s);
|
||||||
|
|
||||||
/* trim trailing whitespace */
|
/* trim trailing whitespace */
|
||||||
while ( (len=strlen(s)) >= 1 && isspace(s[len-1]))
|
while ( len > 0 && isspace(s[len-1]))
|
||||||
s[len-1]='\0';
|
s[--len]='\0';
|
||||||
|
|
||||||
/* trim leading whitespace */
|
/* trim leading whitespace */
|
||||||
memmove(s, &s[strspn(s, " \n\r\t\v")], len);
|
memmove(s, &s[strspn(s, " \n\r\t\v")], len);
|
||||||
|
Loading…
Reference in New Issue
Block a user