summaryrefslogtreecommitdiff
path: root/miscutils/crond.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-08-19 18:49:21 +0000
committerDenis Vlasenko2007-08-19 18:49:21 +0000
commitf9000c51dbf7bb9544a305ae06e91bba7e17e26a (patch)
tree08f77640ef47306a46bdbc51aac951a3444dee4b /miscutils/crond.c
parentd37f22225b4d10b84bbc4f6cee2e26d9f9b80fac (diff)
downloadbusybox-f9000c51dbf7bb9544a305ae06e91bba7e17e26a.zip
busybox-f9000c51dbf7bb9544a305ae06e91bba7e17e26a.tar.gz
crond: code shrink
Diffstat (limited to 'miscutils/crond.c')
-rw-r--r--miscutils/crond.c80
1 files changed, 21 insertions, 59 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 3c73c73..fa7b3da 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -287,56 +287,19 @@ static void startlogger(void)
}
-static const char *const DowAry[] = {
- "sun",
- "mon",
- "tue",
- "wed",
- "thu",
- "fri",
- "sat",
-
- "Sun",
- "Mon",
- "Tue",
- "Wed",
- "Thu",
- "Fri",
- "Sat",
- NULL
-};
-
-static const char *const MonAry[] = {
- "jan",
- "feb",
- "mar",
- "apr",
- "may",
- "jun",
- "jul",
- "aug",
- "sep",
- "oct",
- "nov",
- "dec",
-
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
- NULL
-};
+static const char DowAry[] ALIGN1 =
+ "sun""mon""tue""wed""thu""fri""sat"
+ /* "Sun""Mon""Tue""Wed""Thu""Fri""Sat" */
+;
+
+static const char MonAry[] ALIGN1 =
+ "jan""feb""mar""apr""may""jun""jul""aug""sep""oct""nov""dec"
+ /* "Jan""Feb""Mar""Apr""May""Jun""Jul""Aug""Sep""Oct""Nov""Dec" */
+;
static char *ParseField(char *user, char *ary, int modvalue, int off,
- const char *const *names, char *ptr)
+ const char *names, char *ptr)
+/* 'names' is a pointer to a set of 3-char abbreviations */
{
char *base = ptr;
int n1 = -1;
@@ -366,20 +329,19 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
} else if (names) {
int i;
- for (i = 0; names[i]; ++i) {
- if (strncmp(ptr, names[i], strlen(names[i])) == 0) {
+ for (i = 0; names[i]; i += 3) {
+ /* was using strncmp before... */
+ if (strncasecmp(ptr, &names[i], 3) == 0) {
+ ptr += 3;
+ if (n1 < 0) {
+ n1 = i / 3;
+ } else {
+ n2 = i / 3;
+ }
+ skip = 1;
break;
}
}
- if (names[i]) {
- ptr += strlen(names[i]);
- if (n1 < 0) {
- n1 = i;
- } else {
- n2 = i;
- }
- skip = 1;
- }
}
/* handle optional range '-' */