Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/libbb/trim.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/libbb/trim.c
r1765 r2725 6 6 * If you wrote this, please acknowledge your work. 7 7 * 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 9 */ 10 10 11 11 #include "libbb.h" 12 12 13 void trim(char *s)13 void FAST_FUNC trim(char *s) 14 14 { 15 15 size_t len = strlen(s); 16 size_t lws;17 16 18 17 /* trim trailing whitespace */ 19 while (len && isspace(s[len-1])) --len; 18 while (len && isspace(s[len-1])) 19 --len; 20 20 21 21 /* trim leading whitespace */ 22 22 if (len) { 23 lws = strspn(s, " \n\r\t\v"); 24 memmove(s, s + lws, len -= lws); 23 char *nws = skip_whitespace(s); 24 if ((nws - s) != 0) { 25 len -= (nws - s); 26 memmove(s, nws, len); 27 } 25 28 } 26 29 s[len] = '\0';
Note:
See TracChangeset
for help on using the changeset viewer.