From d2f5458ff92c45a552f4f23c44de1ec922a815e2 Mon Sep 17 00:00:00 2001 From: thib Date: Mon, 13 Nov 2000 15:48:23 +0000 Subject: [PATCH] code clearer in goto_non_matching --- database.c | 92 ++++++++++++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 55 deletions(-) diff --git a/database.c b/database.c index d082582..f47dd68 100644 --- a/database.c +++ b/database.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: database.c,v 1.37 2000-11-03 13:23:20 thib Exp $ */ + /* $Id: database.c,v 1.38 2000-11-13 15:48:23 thib Exp $ */ #include "fcron.h" @@ -514,67 +514,49 @@ goto_non_matching(CL *line, struct tm *ftime) /* to prevent from invinite loop with unvalid lines : */ short int year_limit = MAXYEAR_SCHEDULE_TIME; - /* check if we are in an interval of execution */ - if( ! ( bit_test(line->cl_mins, ftime->tm_min) && - bit_test(line->cl_hrs, ftime->tm_hour) && - ( - (is_dayand(line->cl_option) && - bit_test(line->cl_days, ftime->tm_mday) && - bit_test(line->cl_dow, ftime->tm_wday)) - || - (is_dayor(line->cl_option) && ( - bit_test(line->cl_days, ftime->tm_mday) || - bit_test(line->cl_dow, ftime->tm_wday))) - ) && - bit_test(line->cl_mons, ftime->tm_mon) - ) ) - return; - - start: - for(i=ftime->tm_min; bit_test(line->cl_mins, i) && (i<60); i++); - ftime->tm_min = i; - if (i == 60) { - ftime->tm_min = 0; - if (++ftime->tm_hour == 24) { - ftime->tm_hour = 0; - set_wday(ftime); - if(++ftime->tm_mday == - get_nb_mdays((ftime->tm_year+1900),ftime->tm_mon)) { - ftime->tm_mday = 0; - if(++ftime->tm_mon == 12) { - ftime->tm_mon = 0; - ftime->tm_year++; - if (--year_limit <= 0) { - error("Can't found a non matching date for %s " - "in the next %d years. Maybe this line is " - "corrupted : consider reinstalling the fcrontab", - line->cl_shell, MAXYEAR_SCHEDULE_TIME); - return; + /* check if we are in an interval of execution */ + while ( ( bit_test(line->cl_mins, ftime->tm_min) && + bit_test(line->cl_hrs, ftime->tm_hour) && + ( + (is_dayand(line->cl_option) && + bit_test(line->cl_days, ftime->tm_mday) && + bit_test(line->cl_dow, ftime->tm_wday)) + || + (is_dayor(line->cl_option) && ( + bit_test(line->cl_days, ftime->tm_mday) || + bit_test(line->cl_dow, ftime->tm_wday))) + ) && + bit_test(line->cl_mons, ftime->tm_mon) + ) ) { + + for(i=ftime->tm_min; bit_test(line->cl_mins, i) && (i<60); i++); + ftime->tm_min = i; + if (i == 60) { + ftime->tm_min = 0; + if (++ftime->tm_hour == 24) { + ftime->tm_hour = 0; + set_wday(ftime); + if(++ftime->tm_mday == + get_nb_mdays((ftime->tm_year+1900),ftime->tm_mon)) { + ftime->tm_mday = 0; + if(++ftime->tm_mon == 12) { + ftime->tm_mon = 0; + ftime->tm_year++; + if (--year_limit <= 0) { + error("Can't found a non matching date for %s in " + "the next %d years. Maybe this line is " + "corrupted : consider reinstalling the " + "fcrontab", line->cl_shell, + MAXYEAR_SCHEDULE_TIME); + return; + } } } } } - - if( ! ( bit_test(line->cl_mins, ftime->tm_min) && - bit_test(line->cl_hrs, ftime->tm_hour) && - ( - (is_dayand(line->cl_option) && - bit_test(line->cl_days, ftime->tm_mday) && - bit_test(line->cl_dow, ftime->tm_wday)) - || - (is_dayor(line->cl_option) && ( - bit_test(line->cl_days, ftime->tm_mday) || - bit_test(line->cl_dow, ftime->tm_wday))) - ) && - bit_test(line->cl_mons, ftime->tm_mon) - ) ) - goto exit_fct; - - goto start; } - exit_fct: debug(" '%s' first non matching %d/%d/%d wday:%d %02d:%02d", line->cl_shell, (ftime->tm_mon + 1), ftime->tm_mday, (ftime->tm_year + 1900), ftime->tm_wday, -- 2.40.0