mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
More error checking of bad date specs.
This commit is contained in:
30
src/dorem.c
30
src/dorem.c
@@ -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]);
|
||||
|
||||
@@ -692,6 +692,10 @@ void InitRemind(int argc, char const *argv[])
|
||||
break;
|
||||
|
||||
case T_Date:
|
||||
if (tok.val < 0) {
|
||||
fprintf(stderr, "%s: `%s'\n", ErrMsg[-tok.val], arg);
|
||||
Usage();
|
||||
}
|
||||
if (m != NO_MON || d != NO_DAY || y != NO_YR || dse != NO_DATE) Usage();
|
||||
dse = tok.val;
|
||||
break;
|
||||
|
||||
@@ -350,6 +350,11 @@ int DoOmit(ParsePtr p)
|
||||
return OK;
|
||||
|
||||
case T_Date:
|
||||
if (tok.val < 0) {
|
||||
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
|
||||
DBufFree(&buf);
|
||||
return -tok.val;
|
||||
}
|
||||
DBufFree(&buf);
|
||||
if (y[seen_through] != NO_YR) return E_YR_TWICE;
|
||||
if (m[seen_through] != NO_MON) return E_MON_TWICE;
|
||||
|
||||
@@ -255,7 +255,9 @@ void FindNumericToken(char const *s, Token *t)
|
||||
t->type = T_DateTime;
|
||||
t->val = MINUTES_PER_DAY * dse + tim;
|
||||
} else {
|
||||
Wprint("%s: `%s'", ErrMsg[r], s_orig);
|
||||
t->type = T_Date;
|
||||
/* Store error message negated as val! */
|
||||
t->val = -r;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5703,12 +5703,6 @@ REM 1 Jan 1873 MSG This should fail
|
||||
../tests/test.rem(1122): Number `1873' is not recognized as a year or a day number
|
||||
REM 1873-12-11 MSG Also bad.
|
||||
../tests/test.rem(1123): Bad date specification: `1873-12-11'
|
||||
../tests/test.rem(1123): Missing REM type; assuming MSG
|
||||
../tests/test.rem(1123): Trig = Saturday, 16 February, 1991
|
||||
../tests/test.rem(1123): Function `subst_ampm' defined at ../tests/test.rem:931 should take 1 argument, but actually takes 7
|
||||
../tests/test.rem(1123): Function `subst_ampm' defined at ../tests/test.rem:931 should take 1 argument, but actually takes 7
|
||||
1873-12-11 MSG Also bad.
|
||||
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
Reference in New Issue
Block a user