Diagnose bad YYYY-MM-DD constants in REM command.

This commit is contained in:
Dianne Skoll
2024-09-10 14:09:52 -04:00
parent ef6b9c3783
commit c645db5ede
3 changed files with 19 additions and 4 deletions

View File

@@ -233,6 +233,7 @@ void FindNumericToken(char const *s, Token *t)
int mult = 1, hour, min;
char const *s_orig = s;
int ampm = 0;
int r;
t->type = T_Illegal;
t->val = 0;
@@ -243,7 +244,8 @@ void FindNumericToken(char const *s, Token *t)
if (*s == '-' || *s == '/') {
char const *p = s_orig;
int dse, tim;
if (ParseLiteralDate(&p, &dse, &tim) == OK) {
r = ParseLiteralDate(&p, &dse, &tim);
if (r == OK) {
if (*p) return;
if (tim == NO_TIME) {
t->type = T_Date;
@@ -252,7 +254,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);
}
return;
}

View File

@@ -5699,8 +5699,17 @@ set zxk dooby(1)
Entering UserFN dooby(1)
Leaving UserFN dooby(1) => 1
REM 1 Jan 1873 MSG hehah
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

View File

@@ -1119,7 +1119,9 @@ set zxk dooby()
set zxk dooby(1, 2)
set zxk dooby(1)
REM 1 Jan 1873 MSG hehah
REM 1 Jan 1873 MSG This should fail
REM 1873-12-11 MSG Also bad.
# Don't want Remind to queue reminders
EXIT