More error checking of bad date specs.

This commit is contained in:
Dianne Skoll
2024-09-10 14:27:46 -04:00
parent c645db5ede
commit 56e62b1b4d
5 changed files with 39 additions and 10 deletions
+27 -3
View File
@@ -437,10 +437,24 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
break;
case T_Date:
if (trig->d != NO_DAY) {
DBufFree(&buf);
return E_DAY_TWICE;
}
if (trig->m != NO_MON) {
DBufFree(&buf);
return E_MON_TWICE;
}
if (trig->y != NO_YR) {
DBufFree(&buf);
return E_YR_TWICE;
}
if (tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
DBufFree(&buf);
if (trig->d != NO_DAY) return E_DAY_TWICE;
if (trig->m != NO_MON) return E_MON_TWICE;
if (trig->y != NO_YR) return E_YR_TWICE;
FromDSE(tok.val, &y, &m, &d);
trig->y = y;
trig->m = m;
@@ -893,6 +907,11 @@ static int ParseUntil(ParsePtr s, Trigger *t, int type)
break;
case T_Date:
if (tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
DBufFree(&buf);
if (y != NO_YR) {
Eprint("%s: %s", which, ErrMsg[E_YR_TWICE]);
@@ -985,6 +1004,11 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
break;
case T_Date:
if (tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
DBufFree(&buf);
if (y != NO_YR) {
Eprint("%s: %s", word, ErrMsg[E_YR_TWICE]);