diff --git a/src/dorem.c b/src/dorem.c index 82a27052..846c9254 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -13,7 +13,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: dorem.c,v 1.14 2005-11-20 01:26:59 dfs Exp $"; +static char const RCSID[] = "$Id: dorem.c,v 1.15 2007-06-29 01:52:36 dfs Exp $"; #include #include @@ -151,6 +151,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim) tim->delta = NO_DELTA; tim->rep = NO_REP; tim->duration = NO_TIME; + LastTriggerTime = NO_TIME; while(1) { /* Read space-delimited string */ diff --git a/src/funcs.c b/src/funcs.c index a0b982ea..052ce31b 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -12,7 +12,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: funcs.c,v 1.13 2007-06-29 01:17:39 dfs Exp $"; +static char const RCSID[] = "$Id: funcs.c,v 1.14 2007-06-29 01:52:36 dfs Exp $"; #include @@ -1084,8 +1084,13 @@ static int FDefined(void) /***************************************************************/ static int FTrigdate(void) { - RetVal.type = DATE_TYPE; - RetVal.v.val = LastTriggerDate; + if (LastTrigValid) { + RetVal.type = DATE_TYPE; + RetVal.v.val = LastTriggerDate; + } else { + RetVal.type = INT_TYPE; + RetVal.v.val = 0; + } return OK; } @@ -1098,15 +1103,28 @@ static int FTrigvalid(void) static int FTrigtime(void) { - RetVal.type = TIME_TYPE; - RetVal.v.val = LastTriggerTime; + if (LastTriggerTime != NO_TIME) { + RetVal.type = TIME_TYPE; + RetVal.v.val = LastTriggerTime; + } else { + RetVal.type = INT_TYPE; + RetVal.v.val = 0; + } return OK; } static int FTrigdatetime(void) { - RetVal.type = DATETIME_TYPE; - RetVal.v.val = LastTriggerDate * MINUTES_PER_DAY + LastTriggerTime; + if (!LastTrigValid) { + RetVal.type = INT_TYPE; + RetVal.v.val = 0; + } else if (LastTriggerTime != NO_TIME) { + RetVal.type = DATETIME_TYPE; + RetVal.v.val = LastTriggerDate * MINUTES_PER_DAY + LastTriggerTime; + } else { + RetVal.type = DATE_TYPE; + RetVal.v.val = LastTriggerDate; + } return OK; } diff --git a/src/trigger.c b/src/trigger.c index fe30555e..a8fe1508 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -11,7 +11,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: trigger.c,v 1.6 2005-09-30 03:29:32 dfs Exp $"; +static char const RCSID[] = "$Id: trigger.c,v 1.7 2007-06-29 01:52:36 dfs Exp $"; #include @@ -357,6 +357,7 @@ int ComputeTrigger(int today, Trigger *trig, int *err) result; LastTrigValid = 0; + /* Assume everything works */ *err = OK;