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 38aa28231b4e4609a0e7081150445cf25abbb8d0..0dca6678edf758985ae62e1a496e3ddfba39cca5 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 085cf6e9de81acc81efe3e19d18f55528474bf64..53c255fef872412cad4356ca88cb4233a0282f1c 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) {