svn commit: trunk/busybox: libbb miscutils

landley at busybox.net landley at busybox.net
Thu Sep 1 10:23:59 UTC 2005


Author: landley
Date: 2005-09-01 03:23:57 -0700 (Thu, 01 Sep 2005)
New Revision: 11310

Log:
According to bug #63, crond is unhappy with crontab lines that don't end in a
newline, or lines that have trailing spaces.


Modified:
   trunk/busybox/libbb/trim.c
   trunk/busybox/miscutils/crond.c


Changeset:
Modified: trunk/busybox/libbb/trim.c
===================================================================
--- trunk/busybox/libbb/trim.c	2005-09-01 09:38:32 UTC (rev 11309)
+++ trunk/busybox/libbb/trim.c	2005-09-01 10:23:57 UTC (rev 11310)
@@ -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 */

Modified: trunk/busybox/miscutils/crond.c
===================================================================
--- trunk/busybox/miscutils/crond.c	2005-09-01 09:38:32 UTC (rev 11309)
+++ trunk/busybox/miscutils/crond.c	2005-09-01 10:23:57 UTC (rev 11310)
@@ -589,10 +589,8 @@
 					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) {




More information about the busybox-cvs mailing list