diff --git a/src/dosubst.c b/src/dosubst.c index 0f15cc88..0691c1ea 100644 --- a/src/dosubst.c +++ b/src/dosubst.c @@ -79,6 +79,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int origLen = DBufLen(dbuf); int altmode; int r; + int origtime; Value v; UserFunc *func; @@ -87,6 +88,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, if (tt) { tim = tt->ttime; } + origtime = tim; if (tim == NO_TIME) tim = curtime; tdiff = tim - curtime; adiff = ABS(tdiff); @@ -405,6 +407,12 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, Eprint("%s", GetErr(r)); } } + if (origtime == NO_TIME) { + if ((c >= '0' && c <= '9') || (c == '!')) { + Wprint(tr("`%%%c' substitution sequence should not be used without an AT clause"), c); + } + } + switch(UPPER(c)) { case 'A': if (altmode == '*' || !strcmp(tr("on"), "")) { diff --git a/tests/test-rem b/tests/test-rem index 953c8580..fefde67e 100644 --- a/tests/test-rem +++ b/tests/test-rem @@ -690,6 +690,11 @@ set a "\x0P" set a "\x00P" EOF +# Test diagnostics when using a timed substitution without an AT clause +../src/remind - 1 Feb 2024 1:00 <> ../tests/test.out 2>&1 +REM MSG %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %! hahaha +EOF + # Test translate table dumping ../src/remind - 1 Feb 2024 <> ../tests/test.out 2>&1 TRANSLATE "\x03" "BREAK" diff --git a/tests/test.cmp b/tests/test.cmp index 8c024e24..8b0e00e2 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -24548,6 +24548,7 @@ TRANSLATE "Warning: Useless use of UNTIL with fully-specified date and no *rep" TRANSLATE "Warning: Variable name `%.*s...' truncated to `%.*s'" "" TRANSLATE "You have OMITted everything! The space-time continuum is at risk." "" TRANSLATE "\\x00 is not a valid escape sequence" "" +TRANSLATE "`%%%c' substitution sequence should not be used without an AT clause" "" TRANSLATE "did you mean" "" TRANSLATE "here" "" TRANSLATE "psmoon() is deprecated; use SPECIAL MOON instead." "" @@ -24691,6 +24692,21 @@ a "xPOO" -stdin-(24): \x00 is not a valid escape sequence -stdin-(25): \x00 is not a valid escape sequence -stdin-(26): \x00 is not a valid escape sequence +-stdin-(1): `%0' substitution sequence should not be used without an AT clause +-stdin-(1): `%1' substitution sequence should not be used without an AT clause +-stdin-(1): `%2' substitution sequence should not be used without an AT clause +-stdin-(1): `%3' substitution sequence should not be used without an AT clause +-stdin-(1): `%4' substitution sequence should not be used without an AT clause +-stdin-(1): `%5' substitution sequence should not be used without an AT clause +-stdin-(1): `%6' substitution sequence should not be used without an AT clause +-stdin-(1): `%7' substitution sequence should not be used without an AT clause +-stdin-(1): `%8' substitution sequence should not be used without an AT clause +-stdin-(1): `%9' substitution sequence should not be used without an AT clause +-stdin-(1): `%!' substitution sequence should not be used without an AT clause +Reminders for Thursday, 1st February, 2024: + +s now at 1:00am at 01:00 0 0 from now 0 0 s is hahaha + # Translation table TRANSLATE "LANGID" "en" TRANSLATE "\x03" "BREAK"