aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-09-01 10:23:57 +0000
committerRob Landley <rob@landley.net>2005-09-01 10:23:57 +0000
commit828548ab56ed2dca36daf0dfdbb0644119ecbe2c (patch)
treeef98f8bb5478276a0a5cb15d127ae79fba8f1dea /libbb
parent344ea471ef63d54436f296c140e7f86c67237545 (diff)
downloadbusybox-828548ab56ed2dca36daf0dfdbb0644119ecbe2c.tar.gz
According to bug #63, crond is unhappy with crontab lines that don't end in a
newline, or lines that have trailing spaces.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/trim.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libbb/trim.c b/libbb/trim.c
index 38aa28231..0dca6678e 100644
--- a/libbb/trim.c
+++ b/libbb/trim.c
@@ -29,14 +29,18 @@
void trim(char *s)
{
- int len = strlen(s);
+ size_t len = strlen(s);
+ size_t lws;
/* trim trailing whitespace */
- while ( len > 0 && isspace(s[len-1]))
- s[--len]='\0';
+ while (len && isspace(s[len-1])) --len;
/* trim leading whitespace */
- memmove(s, &s[strspn(s, " \n\r\t\v")], len);
+ if(len) {
+ lws = strspn(s, " \n\r\t\v");
+ memmove(s, s + lws, len -= lws);
+ }
+ s[len] = 0;
}
/* END CODE */