13 |
void FAST_FUNC trim(char *s) |
void FAST_FUNC trim(char *s) |
14 |
{ |
{ |
15 |
size_t len = strlen(s); |
size_t len = strlen(s); |
|
size_t lws; |
|
16 |
|
|
17 |
/* trim trailing whitespace */ |
/* trim trailing whitespace */ |
18 |
while (len && isspace(s[len-1])) |
while (len && isspace(s[len-1])) |
20 |
|
|
21 |
/* trim leading whitespace */ |
/* trim leading whitespace */ |
22 |
if (len) { |
if (len) { |
23 |
lws = strspn(s, " \n\r\t\v"); |
char *nws = skip_whitespace(s); |
24 |
if (lws) { |
if ((nws - s) != 0) { |
25 |
len -= lws; |
len -= (nws - s); |
26 |
memmove(s, s + lws, len); |
memmove(s, nws, len); |
27 |
} |
} |
28 |
} |
} |
29 |
s[len] = '\0'; |
s[len] = '\0'; |