Only check the trigger portion of a REM for expressions in purge mode, not body.

This commit is contained in:
Dianne Skoll
2025-10-12 13:38:47 -04:00
parent 81a186607b
commit 2723875a18
4 changed files with 36 additions and 4 deletions

View File

@@ -546,7 +546,7 @@ int DoRem(ParsePtr p)
}
if (PurgeMode) {
if (trig.expired || (!trig.is_todo && dse < DSEToday)) {
if (p->expr_happened) {
if (trig.expr_happened) {
if (trig.nonconst_expr) {
if (!Hush) {
PurgeEchoLine("%s\n", "#!P: Next line may have expired, but contains non-constant expression");
@@ -834,6 +834,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
trig->infos = NULL;
trig->tz = NULL;
trig->nonconst_expr = 0;
trig->expr_happened = 0;
int parsing = 1;
while(parsing) {
@@ -1206,6 +1207,9 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
if (s->nonconst_expr) {
trig->nonconst_expr = 1;
}
if (s->expr_happened) {
trig->expr_happened = 1;
}
if (trig->need_wkday && trig->wd == NO_WD) {
Eprint("Weekday name(s) required");
return E_PARSE_ERR;

View File

@@ -143,11 +143,13 @@ typedef struct {
int eventstart; /* Original event start (datetime) */
int eventstart_orig; /* Original event start in TZ (datetime) */
int eventduration; /* Original event duration (minutes) */
int maybe_uncomputable; /* Suppress "can't compute trigger" warnings */
int addomit; /* Add trigger date to global OMITs */
int noqueue; /* Don't queue even if timed */
int nonconst_expr; /* Non-constant expression encountered */
int max_overdue; /* Stop warning if TODO is too far overdue */
unsigned char addomit; /* Add trigger date to global OMITs */
unsigned char maybe_uncomputable; /* Suppress "can't compute trigger" warnings */
unsigned char nonconst_expr; /* Non-constant expression encountered */
unsigned char expr_happened;
char sched[VAR_NAME_LEN+1]; /* Scheduling function */
char warn[VAR_NAME_LEN+1]; /* Warning function */
char omitfunc[VAR_NAME_LEN+1]; /* OMITFUNC function */

View File

@@ -926,6 +926,19 @@ REM 2025 Oct [a] MSG Nonconst IS set [today()]
REM 2025 Oct [a] MSG Nonconst IS set
EOF
$REMIND -j - 2025-12-31 <<'EOF' >> $OUT 2>&1
# Nonconst-expr in trigger
set $ParseUntriggered 1
set a (today()+1)-today()
REM 2025-10-01 MSG Nonconst NOT set [today()]
REM 2025 Oct [a] MSG Nonconst IS set [today()]
REM 2025 Oct [a] MSG Nonconst IS set
REM 2025 Oct [1] MSG Expr but not nonconst [today()]
REM 2025-10-01 MSG No expr seen [1+2]
EOF
# Purge mode
cmp -s $OUT $CMP
if [ "$?" = "0" ]; then
echo "Remind: Acceptance tests ${GRN}PASSED${NRM}"

View File

@@ -39931,3 +39931,16 @@ No reminders.
{"date":"2025-10-01","filename":"-stdin-","lineno":4,"nonconst_expr":1,"d":1,"m":10,"y":2025,"is_todo":0,"trigbase":"2025-10-1 ","priority":5000,"body":"Nonconst IS set 2025-10-01"},
{"date":"2025-10-01","filename":"-stdin-","lineno":5,"nonconst_expr":1,"d":1,"m":10,"y":2025,"is_todo":0,"trigbase":"2025-10-1 ","priority":5000,"body":"Nonconst IS set"}
]
# Nonconst-expr in trigger
set $ParseUntriggered 1
set a (today()+1)-today()
#!P: Expired: REM 2025-10-01 MSG Nonconst NOT set [today()]
#!P: Next line may have expired, but contains non-constant expression
#!P: or a relative SCANFROM clause
REM 2025 Oct [a] MSG Nonconst IS set [today()]
#!P: Next line may have expired, but contains non-constant expression
#!P: or a relative SCANFROM clause
REM 2025 Oct [a] MSG Nonconst IS set
#!P: Next line has expired, but contains expression... please verify
#!P: Expired: REM 2025 Oct [1] MSG Expr but not nonconst [today()]
#!P: Expired: REM 2025-10-01 MSG No expr seen [1+2]