According to bug #63, crond is unhappy with crontab lines that don't end in a
authorRob Landley <rob@landley.net>
Thu, 1 Sep 2005 10:23:57 +0000 (10:23 -0000)
committerRob Landley <rob@landley.net>
Thu, 1 Sep 2005 10:23:57 +0000 (10:23 -0000)
newline, or lines that have trailing spaces.

libbb/trim.c
miscutils/crond.c

index 38aa282..0dca667 100644 (file)
 
 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 */
index 085cf6e..53c255f 100644 (file)
@@ -589,10 +589,8 @@ static void SynchronizeFile(const char *fileName)
                                        CronLine line;
                                        char *ptr;
 
-                                       if (buf[0]) {
-                                               buf[strlen(buf) - 1] = 0;
-                                       }
-                                       if (buf[0] == 0 || buf[0] == '#' || buf[0] == ' ' || buf[0] == '\t') {
+                                       trim(buf);
+                                       if (buf[0] == 0 || buf[0] == '#') {
                                                continue;
                                        }
                                        if (--maxEntries == 0) {