aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/crond.c80
1 files changed, 21 insertions, 59 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 3c73c7337..fa7b3da08 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -287,56 +287,19 @@ static void startlogger(void)
287} 287}
288 288
289 289
290static const char *const DowAry[] = { 290static const char DowAry[] ALIGN1 =
291 "sun", 291 "sun""mon""tue""wed""thu""fri""sat"
292 "mon", 292 /* "Sun""Mon""Tue""Wed""Thu""Fri""Sat" */
293 "tue", 293;
294 "wed", 294
295 "thu", 295static const char MonAry[] ALIGN1 =
296 "fri", 296 "jan""feb""mar""apr""may""jun""jul""aug""sep""oct""nov""dec"
297 "sat", 297 /* "Jan""Feb""Mar""Apr""May""Jun""Jul""Aug""Sep""Oct""Nov""Dec" */
298 298;
299 "Sun",
300 "Mon",
301 "Tue",
302 "Wed",
303 "Thu",
304 "Fri",
305 "Sat",
306 NULL
307};
308
309static const char *const MonAry[] = {
310 "jan",
311 "feb",
312 "mar",
313 "apr",
314 "may",
315 "jun",
316 "jul",
317 "aug",
318 "sep",
319 "oct",
320 "nov",
321 "dec",
322
323 "Jan",
324 "Feb",
325 "Mar",
326 "Apr",
327 "May",
328 "Jun",
329 "Jul",
330 "Aug",
331 "Sep",
332 "Oct",
333 "Nov",
334 "Dec",
335 NULL
336};
337 299
338static char *ParseField(char *user, char *ary, int modvalue, int off, 300static char *ParseField(char *user, char *ary, int modvalue, int off,
339 const char *const *names, char *ptr) 301 const char *names, char *ptr)
302/* 'names' is a pointer to a set of 3-char abbreviations */
340{ 303{
341 char *base = ptr; 304 char *base = ptr;
342 int n1 = -1; 305 int n1 = -1;
@@ -366,20 +329,19 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
366 } else if (names) { 329 } else if (names) {
367 int i; 330 int i;
368 331
369 for (i = 0; names[i]; ++i) { 332 for (i = 0; names[i]; i += 3) {
370 if (strncmp(ptr, names[i], strlen(names[i])) == 0) { 333 /* was using strncmp before... */
334 if (strncasecmp(ptr, &names[i], 3) == 0) {
335 ptr += 3;
336 if (n1 < 0) {
337 n1 = i / 3;
338 } else {
339 n2 = i / 3;
340 }
341 skip = 1;
371 break; 342 break;
372 } 343 }
373 } 344 }
374 if (names[i]) {
375 ptr += strlen(names[i]);
376 if (n1 < 0) {
377 n1 = i;
378 } else {
379 n2 = i;
380 }
381 skip = 1;
382 }
383 } 345 }
384 346
385 /* handle optional range '-' */ 347 /* handle optional range '-' */