Module Name: src Committed By: rillig Date: Fri Jul 5 18:59:33 UTC 2024
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk directive-for-escape.exp directive-for-escape.mk moderrs.exp moderrs.mk varmisc.exp varmisc.mk varmod-edge.exp varmod-edge.mk varmod-order.exp varmod-order.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on unclosed expressions during parse time In exchange, this adds location information. For unnamed expressions, the value is no longer printed. This will be added back in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.1130 -r1.1131 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-errors-lint.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.26 -r1.27 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.24 -r1.25 \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varparse-errors.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1130 src/usr.bin/make/var.c:1.1131 --- src/usr.bin/make/var.c:1.1130 Fri Jul 5 05:11:25 2024 +++ src/usr.bin/make/var.c Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1130 2024/07/05 05:11:25 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1130 2024/07/05 05:11:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3964,9 +3964,10 @@ ApplyModifiersIndirect(ModChain *ch, con if (*p == ':') p++; else if (*p == '\0' && ch->endc != '\0') { - Error("Unclosed expression after indirect modifier, " - "expecting '%c' for variable \"%s\"", - ch->endc, expr->name); + Parse_Error(PARSE_FATAL, + "Unclosed expression after indirect modifier, " + "expecting '%c'", + ch->endc); *pp = p; return AMIR_OUT; } @@ -4014,12 +4015,10 @@ ApplySingleModifier(const char **pp, Mod LogAfterApply(ch, p, mod); if (*p == '\0' && ch->endc != '\0') { - Error( + Parse_Error(PARSE_FATAL, "Unclosed expression, expecting '%c' for " - "modifier \"%.*s\" of variable \"%s\" with value \"%s\"", - ch->endc, - (int)(p - mod), mod, - ch->expr->name, Expr_Str(ch->expr)); + "modifier \"%.*s\"", + ch->endc, (int)(p - mod), mod); } else if (*p == ':') { p++; } else if (opts.strict && *p != '\0' && *p != ch->endc) { @@ -4072,9 +4071,8 @@ ApplyModifiers( p = *pp; if (*p == '\0' && endc != '\0') { - Error( - "Unclosed expression, expecting '%c' for \"%s\"", - ch.endc, expr->name); + Parse_Error(PARSE_FATAL, + "Unclosed expression, expecting '%c'", ch.endc); goto cleanup; } Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.8 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.7 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Fri Jul 5 18:59:33 2024 @@ -1,7 +1,7 @@ : undefined--eol make: in target "unclosed-expression": Unclosed variable "UNCLOSED" : unclosed-expression- -make: Unclosed expression, expecting '}' for "UNCLOSED" +make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' : unclosed-modifier- make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" : unknown-modifier--eol Index: src/usr.bin/make/unit-tests/cmd-errors-lint.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.7 src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.8 --- src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.7 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-lint.exp Fri Jul 5 18:59:33 2024 @@ -1,7 +1,7 @@ : undefined make: in target "unclosed-expression": Unclosed variable "UNCLOSED" : unclosed-expression -make: Unclosed expression, expecting '}' for "UNCLOSED" +make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' : unclosed-modifier make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" : unknown-modifier Index: src/usr.bin/make/unit-tests/cmd-errors.mk diff -u src/usr.bin/make/unit-tests/cmd-errors.mk:1.7 src/usr.bin/make/unit-tests/cmd-errors.mk:1.8 --- src/usr.bin/make/unit-tests/cmd-errors.mk:1.7 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/cmd-errors.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors.mk,v 1.7 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: cmd-errors.mk,v 1.8 2024/07/05 18:59:33 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in compat mode. @@ -18,7 +18,7 @@ unclosed-expression: : $@-${UNCLOSED unclosed-modifier: -# expect: make: Unclosed expression, expecting '}' for "UNCLOSED" +# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' # XXX: This command is executed even though it contains parse errors. # expect: : unclosed-modifier- : $@-${UNCLOSED: Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.6 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.7 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.6 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.6 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.7 2024/07/05 18:59:33 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. @@ -20,7 +20,7 @@ unclosed-expression: : $@-${UNCLOSED unclosed-modifier: -# expect: make: Unclosed expression, expecting '}' for "UNCLOSED" +# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' # XXX: This command is executed even though it contains parse errors. # expect: : unclosed-modifier- : $@-${UNCLOSED: Index: src/usr.bin/make/unit-tests/cmd-errors-lint.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.3 src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.4 --- src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.3 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-lint.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-lint.mk,v 1.3 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: cmd-errors-lint.mk,v 1.4 2024/07/05 18:59:33 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed. @@ -20,7 +20,7 @@ unclosed-expression: : $@ ${UNCLOSED unclosed-modifier: -# expect: make: Unclosed expression, expecting '}' for "UNCLOSED" +# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' # XXX: This command is executed even though it contains parse errors. # expect: : unclosed-modifier : $@ ${UNCLOSED: Index: src/usr.bin/make/unit-tests/cmd-errors.exp diff -u src/usr.bin/make/unit-tests/cmd-errors.exp:1.10 src/usr.bin/make/unit-tests/cmd-errors.exp:1.11 --- src/usr.bin/make/unit-tests/cmd-errors.exp:1.10 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/cmd-errors.exp Fri Jul 5 18:59:33 2024 @@ -1,7 +1,7 @@ : undefined--eol make: in target "unclosed-expression": Unclosed variable "UNCLOSED" : unclosed-expression- -make: Unclosed expression, expecting '}' for "UNCLOSED" +make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' : unclosed-modifier- make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" : unknown-modifier--eol Index: src/usr.bin/make/unit-tests/directive-for-escape.exp diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.26 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.27 --- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.26 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/directive-for-escape.exp Fri Jul 5 18:59:33 2024 @@ -1,16 +1,18 @@ For: end for 1 For: loop body with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: -# expect: make: Unclosed expression, expecting '}' for modifier "U!"" of variable "" with value "!"" +# expect+2: while evaluating "${:U!"": Unclosed expression, expecting '}' for modifier "U!"" # expect+1: !" . info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: Unclosed expression, expecting '}' for modifier "U!"" of variable "" with value "!"" +make: "directive-for-escape.mk" line 21: while evaluating "${:U!"": Unclosed expression, expecting '}' for modifier "U!"" + in .for loop from directive-for-escape.mk:18 with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ make: "directive-for-escape.mk" line 21: !" For: end for 1 For: loop body with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: -# expect: make: Unclosed expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\" +# expect+2: while evaluating "${:U!"\\\\": Unclosed expression, expecting '}' for modifier "U!"\\\\" # expect+1: !"\\ . info ${:U!"\\\\#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: Unclosed expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\" +make: "directive-for-escape.mk" line 33: while evaluating "${:U!"\\\\": Unclosed expression, expecting '}' for modifier "U!"\\\\" + in .for loop from directive-for-escape.mk:30 with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ make: "directive-for-escape.mk" line 33: !"\\ For: end for 1 For: loop body with i = $: Index: src/usr.bin/make/unit-tests/directive-for-escape.mk diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.24 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.25 --- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.24 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/directive-for-escape.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-escape.mk,v 1.24 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: directive-for-escape.mk,v 1.25 2024/07/05 18:59:33 rillig Exp $ # # Test escaping of special characters in the iteration values of a .for loop. # These values get expanded later using the :U variable modifier, and this @@ -16,7 +16,7 @@ ASCII= !"\#$$%&'()*+,-./0-9:;<=>?@A-Z[\] # the loop. Not only would it need the escaping for the variable modifier # ':U' but also the escaping for the line-end comment. .for chars in ${ASCII} -# expect: make: Unclosed expression, expecting '}' for modifier "U!"" of variable "" with value "!"" +# expect+2: while evaluating "${:U!"": Unclosed expression, expecting '}' for modifier "U!"" # expect+1: !" . info ${chars} .endfor @@ -28,7 +28,7 @@ ASCII= !"\#$$%&'()*+,-./0-9:;<=>?@A-Z[\] # at all. ASCII.2020-12-31= !"\\\#$$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ .for chars in ${ASCII.2020-12-31} -# expect: make: Unclosed expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\" +# expect+2: while evaluating "${:U!"\\\\": Unclosed expression, expecting '}' for modifier "U!"\\\\" # expect+1: !"\\ . info ${chars} .endfor Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.39 src/usr.bin/make/unit-tests/moderrs.exp:1.40 --- src/usr.bin/make/unit-tests/moderrs.exp:1.39 Thu Jul 4 18:53:37 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Fri Jul 5 18:59:33 2024 @@ -5,11 +5,11 @@ make: in target "mod-unknown-indirect": VAR:Z=before-inner}-after unclosed-direct: -make: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" +make: in target "unclosed-direct": while evaluating variable "VAR" with value "Thevariable": Unclosed expression, expecting '}' for modifier "S,V,v," VAR:S,V,v,=Thevariable unclosed-indirect: -make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" +make: in target "unclosed-indirect": while evaluating variable "VAR" with value "Thevariable": Unclosed expression after indirect modifier, expecting '}' VAR:S,V,v,=Thevariable make: in target "unfinished-indirect": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) @@ -22,7 +22,7 @@ make: in target "unfinished-loop": while 1 2 3 loop-close: -make: Unclosed expression, expecting '}' for modifier "@var@${var}}...@" of variable "UNDEF" with value "1}... 2}... 3}..." +make: in target "loop-close": while evaluating variable "UNDEF" with value "1}... 2}... 3}...": Unclosed expression, expecting '}' for modifier "@var@${var}}...@" 1}... 2}... 3}... 1}... 2}... 3}... @@ -49,7 +49,7 @@ make: in target "mod-subst-delimiter": w 4: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 5: -make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable" +make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "S,from,to," 6: TheVariable 7: TheVariable @@ -63,7 +63,7 @@ make: in target "mod-regex-delimiter": w 4: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 5: -make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable" +make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "C,from,to," 6: TheVariable 7: TheVariable @@ -102,13 +102,13 @@ make: in target "mod-remember-parse": wh make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3" -make: Unclosed expression, expecting '}' for modifier "3" of variable "FIB" with value "" +make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3" make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=" -make: Unclosed expression, expecting '}' for modifier "3=" of variable "FIB" with value "" +make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=" make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=x3" -make: Unclosed expression, expecting '}' for modifier "3=x3" of variable "FIB" with value "" +make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=x3" 1 1 2 x3 5 8 1x3 21 34 Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.36 src/usr.bin/make/unit-tests/moderrs.mk:1.37 --- src/usr.bin/make/unit-tests/moderrs.mk:1.36 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/moderrs.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: moderrs.mk,v 1.36 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.37 2024/07/05 18:59:33 rillig Exp $ # # various modifier error tests @@ -33,11 +33,11 @@ mod-unknown-indirect: print-footer @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' unclosed-direct: print-header print-footer -# expect: make: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" +# expect: make: in target "unclosed-direct": while evaluating variable "VAR" with value "Thevariable": Unclosed expression, expecting '}' for modifier "S,V,v," @echo VAR:S,V,v,=${VAR:S,V,v, unclosed-indirect: print-header print-footer -# expect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" +# expect: make: in target "unclosed-indirect": while evaluating variable "VAR" with value "Thevariable": Unclosed expression after indirect modifier, expecting '}' @echo VAR:${MOD_TERM},=${VAR:${MOD_S} unfinished-indirect: print-footer @@ -58,7 +58,7 @@ unfinished-loop: print-footer # This is also contrary to the SysV modifier, where only the actually # used delimiter (either braces or parentheses) must be balanced. loop-close: print-header print-footer -# expect: make: Unclosed expression, expecting '}' for modifier "@var@${var}}...@" of variable "UNDEF" with value "1}... 2}... 3}..." +# expect: make: in target "loop-close": while evaluating variable "UNDEF" with value "1}... 2}... 3}...": Unclosed expression, expecting '}' for modifier "@var@${var}}...@" @echo ${UNDEF:U1 2 3:@var@${var}}...@ @echo ${UNDEF:U1 2 3:@var@${var}}...@} @@ -111,7 +111,7 @@ mod-subst-delimiter: print-footer @echo 4: ${VAR:S,from, # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) @echo 5: ${VAR:S,from,to -# expect: make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable" +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "S,from,to," @echo 6: ${VAR:S,from,to, @echo 7: ${VAR:S,from,to,} @@ -126,7 +126,7 @@ mod-regex-delimiter: print-footer @echo 4: ${VAR:C,from, # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) @echo 5: ${VAR:C,from,to -# expect: make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable" +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "C,from,to," @echo 6: ${VAR:C,from,to, @echo 7: ${VAR:C,from,to,} @@ -168,13 +168,13 @@ mod-remember-parse: print-footer mod-sysv-parse: print-footer # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3" -# expect: make: Unclosed expression, expecting '}' for modifier "3" of variable "FIB" with value "" +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3" @echo ${FIB:3 # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=" -# expect: make: Unclosed expression, expecting '}' for modifier "3=" of variable "FIB" with value "" +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=" @echo ${FIB:3= # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=x3" -# expect: make: Unclosed expression, expecting '}' for modifier "3=x3" of variable "FIB" with value "" +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=x3" @echo ${FIB:3=x3 @echo ${FIB:3=x3} # ok Index: src/usr.bin/make/unit-tests/varmisc.exp diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.21 src/usr.bin/make/unit-tests/varmisc.exp:1.22 --- src/usr.bin/make/unit-tests/varmisc.exp:1.21 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmisc.exp Fri Jul 5 18:59:33 2024 @@ -51,7 +51,7 @@ make: in target "varerror-unclosed": Unc make: in target "varerror-unclosed": Unclosed variable "UNCLOSED" make: in target "varerror-unclosed": while evaluating variable "UNCLOSED" with value "": Unclosed variable "PATTERN" -make: Unclosed expression, expecting '}' for modifier "M${PATTERN" of variable "UNCLOSED" with value "" +make: in target "varerror-unclosed": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' for modifier "M${PATTERN" make: in target "varerror-unclosed": Unclosed variable "param" make: in target "varerror-unclosed": Unclosed variable "UNCLOSED." Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.21 src/usr.bin/make/unit-tests/varmod-edge.exp:1.22 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.21 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Fri Jul 5 18:59:33 2024 @@ -1,7 +1,8 @@ make: "varmod-edge.mk" line 186: ok M-paren make: "varmod-edge.mk" line 186: ok M-mixed make: "varmod-edge.mk" line 186: ok M-unescape -make: Unclosed expression, expecting '}' for modifier "U*)" of variable "" with value "*)" +make: "varmod-edge.mk" line 168: while evaluating variable "MOD.M-nest-mix" with value "${INP.M-nest-mix:M${:U*)}}": while evaluating variable "INP.M-nest-mix" with value "(parentheses)": while evaluating "${:U*)": Unclosed expression, expecting '}' for modifier "U*)" + in .for loop from varmod-edge.mk:164 with test = M-nest-mix make: "varmod-edge.mk" line 186: ok M-nest-mix make: "varmod-edge.mk" line 186: ok M-nest-brk make: "varmod-edge.mk" line 186: ok M-pat-err Index: src/usr.bin/make/unit-tests/varmisc.mk diff -u src/usr.bin/make/unit-tests/varmisc.mk:1.34 src/usr.bin/make/unit-tests/varmisc.mk:1.35 --- src/usr.bin/make/unit-tests/varmisc.mk:1.34 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varmisc.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmisc.mk,v 1.34 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: varmisc.mk,v 1.35 2024/07/05 18:59:33 rillig Exp $ # # Miscellaneous variable tests. @@ -196,7 +196,7 @@ varerror-unclosed: @echo $(UNCLOSED # expect: make: in target "varerror-unclosed": Unclosed variable "UNCLOSED" @echo ${UNCLOSED -# expect: make: Unclosed expression, expecting '}' for modifier "M${PATTERN" of variable "UNCLOSED" with value "" +# expect: make: in target "varerror-unclosed": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' for modifier "M${PATTERN" @echo ${UNCLOSED:M${PATTERN # expect: make: in target "varerror-unclosed": Unclosed variable "param" # expect: make: in target "varerror-unclosed": Unclosed variable "UNCLOSED." Index: src/usr.bin/make/unit-tests/varmod-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.23 src/usr.bin/make/unit-tests/varmod-edge.mk:1.24 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.23 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.23 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.24 2024/07/05 18:59:33 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -51,7 +51,7 @@ TESTS+= M-nest-mix INP.M-nest-mix= (parentheses) MOD.M-nest-mix= ${INP.M-nest-mix:M${:U*)}} EXP.M-nest-mix= (parentheses)} -# make: Unclosed expression, expecting '}' for modifier "U*)" of variable "" with value "*)" + # In contrast to parentheses and braces, the brackets are not counted # when the :M modifier is parsed since Makefile variables only take the @@ -169,7 +169,7 @@ EXP.colons= # empty # expect+17: ok M-paren # expect+16: ok M-mixed # expect+15: ok M-unescape -# expect: make: Unclosed expression, expecting '}' for modifier "U*)" of variable "" with value "*)" +# expect-4: while evaluating variable "MOD.M-nest-mix" with value "${INP.M-nest-mix:M${:U*)}}": while evaluating variable "INP.M-nest-mix" with value "(parentheses)": while evaluating "${:U*)": Unclosed expression, expecting '}' for modifier "U*)" # expect+13: ok M-nest-mix # expect+12: ok M-nest-brk # expect+11: ok M-pat-err Index: src/usr.bin/make/unit-tests/varmod-order.exp diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.12 src/usr.bin/make/unit-tests/varmod-order.exp:1.13 --- src/usr.bin/make/unit-tests/varmod-order.exp:1.12 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varmod-order.exp Fri Jul 5 18:59:33 2024 @@ -2,9 +2,9 @@ make: "varmod-order.mk" line 17: while e make: "varmod-order.mk" line 17: Undefined variable "${WORDS:OX" make: "varmod-order.mk" line 23: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OxXX" make: "varmod-order.mk" line 23: Undefined variable "${WORDS:Ox" -make: Unclosed expression, expecting '}' for modifier "O" of variable "WORDS" with value "eight five four nine one seven six ten three two" -make: Unclosed expression, expecting '}' for modifier "On" of variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10" -make: Unclosed expression, expecting '}' for modifier "Onr" of variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1" +make: "varmod-order.mk" line 27: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O" +make: "varmod-order.mk" line 29: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On" +make: "varmod-order.mk" line 31: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr" make: "varmod-order.mk" line 38: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn" make: "varmod-order.mk" line 38: Malformed conditional (${NUMBERS:Oxn}) make: "varmod-order.mk" line 48: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo" Index: src/usr.bin/make/unit-tests/varparse-errors.exp diff -u src/usr.bin/make/unit-tests/varparse-errors.exp:1.12 src/usr.bin/make/unit-tests/varparse-errors.exp:1.13 --- src/usr.bin/make/unit-tests/varparse-errors.exp:1.12 Thu Jul 4 18:53:37 2024 +++ src/usr.bin/make/unit-tests/varparse-errors.exp Fri Jul 5 18:59:33 2024 @@ -6,20 +6,20 @@ make: "varparse-errors.mk" line 75: whil make: "varparse-errors.mk" line 75: while evaluating "${:U:OX:U${IND}}": Bad modifier ":OX" make: "varparse-errors.mk" line 75: Undefined variable "${:U:OX" make: "varparse-errors.mk" line 75: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}": Bad modifier ":OX" -make: Unclosed expression, expecting '}' for modifier "Q" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "sh" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "tA" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "tsX" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "ts" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "ts\040" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "u" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "H" of variable "" with value "." -make: Unclosed expression, expecting '}' for modifier "[1]" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "hash" of variable "" with value "b2af338b" -make: Unclosed expression, expecting '}' for modifier "range" of variable "" with value "1" -make: Unclosed expression, expecting '}' for modifier "_" of variable "" with value "" -make: Unclosed expression, expecting '}' for modifier "gmtime" of variable "" with value "<timestamp>" -make: Unclosed expression, expecting '}' for modifier "localtime" of variable "" with value "<timestamp>" +make: "varparse-errors.mk" line 83: while evaluating "${:U:Q": Unclosed expression, expecting '}' for modifier "Q" +make: "varparse-errors.mk" line 85: while evaluating "${:U:sh": Unclosed expression, expecting '}' for modifier "sh" +make: "varparse-errors.mk" line 87: while evaluating "${:U:tA": Unclosed expression, expecting '}' for modifier "tA" +make: "varparse-errors.mk" line 89: while evaluating "${:U:tsX": Unclosed expression, expecting '}' for modifier "tsX" +make: "varparse-errors.mk" line 91: while evaluating "${:U:ts": Unclosed expression, expecting '}' for modifier "ts" +make: "varparse-errors.mk" line 93: while evaluating "${:U:ts\040": Unclosed expression, expecting '}' for modifier "ts\040" +make: "varparse-errors.mk" line 95: while evaluating "${:U:u": Unclosed expression, expecting '}' for modifier "u" +make: "varparse-errors.mk" line 97: while evaluating "${:U:H": Unclosed expression, expecting '}' for modifier "H" +make: "varparse-errors.mk" line 99: while evaluating "${:U:[1]": Unclosed expression, expecting '}' for modifier "[1]" +make: "varparse-errors.mk" line 101: while evaluating "${:U:hash": Unclosed expression, expecting '}' for modifier "hash" +make: "varparse-errors.mk" line 103: while evaluating "${:U:range": Unclosed expression, expecting '}' for modifier "range" +make: "varparse-errors.mk" line 105: while evaluating "${:U:_": Unclosed expression, expecting '}' for modifier "_" +make: "varparse-errors.mk" line 107: while evaluating "${:U:gmtime": Unclosed expression, expecting '}' for modifier "gmtime" +make: "varparse-errors.mk" line 109: while evaluating "${:U:localtime": Unclosed expression, expecting '}' for modifier "localtime" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-order.mk diff -u src/usr.bin/make/unit-tests/varmod-order.mk:1.13 src/usr.bin/make/unit-tests/varmod-order.mk:1.14 --- src/usr.bin/make/unit-tests/varmod-order.mk:1.13 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varmod-order.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-order.mk,v 1.13 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: varmod-order.mk,v 1.14 2024/07/05 18:59:33 rillig Exp $ # # Tests for the :O variable modifier and its variants, which either sort the # words of the value or shuffle them. @@ -23,11 +23,11 @@ _:= ${WORDS:OX} _:= ${WORDS:OxXX} # Missing closing brace, to cover the error handling code. -# expect: make: Unclosed expression, expecting '}' for modifier "O" of variable "WORDS" with value "eight five four nine one seven six ten three two" +# expect+1: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O" _:= ${WORDS:O -# expect: make: Unclosed expression, expecting '}' for modifier "On" of variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10" +# expect+1: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On" _:= ${NUMBERS:On -# expect: make: Unclosed expression, expecting '}' for modifier "Onr" of variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1" +# expect+1: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr" _:= ${NUMBERS:Onr # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be Index: src/usr.bin/make/unit-tests/varparse-errors.mk diff -u src/usr.bin/make/unit-tests/varparse-errors.mk:1.15 src/usr.bin/make/unit-tests/varparse-errors.mk:1.16 --- src/usr.bin/make/unit-tests/varparse-errors.mk:1.15 Fri Jul 5 17:41:50 2024 +++ src/usr.bin/make/unit-tests/varparse-errors.mk Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varparse-errors.mk,v 1.15 2024/07/05 17:41:50 rillig Exp $ +# $NetBSD: varparse-errors.mk,v 1.16 2024/07/05 18:59:33 rillig Exp $ # Tests for parsing and evaluating all kinds of expressions. # @@ -79,31 +79,31 @@ _:= ${:U:OX:U${IND}} ${:U:OX:U${IND}} # Before var.c 1.032 from 2022-08-24, make complained about 'Unknown modifier' # or 'Bad modifier' when in fact the modifier was entirely correct, it was # just not delimited by either ':' or '}' but instead by '\0'. -# expect: make: Unclosed expression, expecting '}' for modifier "Q" of variable "" with value "" +# expect+1: while evaluating "${:U:Q": Unclosed expression, expecting '}' for modifier "Q" UNCLOSED:= ${:U:Q -# expect: make: Unclosed expression, expecting '}' for modifier "sh" of variable "" with value "" +# expect+1: while evaluating "${:U:sh": Unclosed expression, expecting '}' for modifier "sh" UNCLOSED:= ${:U:sh -# expect: make: Unclosed expression, expecting '}' for modifier "tA" of variable "" with value "" +# expect+1: while evaluating "${:U:tA": Unclosed expression, expecting '}' for modifier "tA" UNCLOSED:= ${:U:tA -# expect: make: Unclosed expression, expecting '}' for modifier "tsX" of variable "" with value "" +# expect+1: while evaluating "${:U:tsX": Unclosed expression, expecting '}' for modifier "tsX" UNCLOSED:= ${:U:tsX -# expect: make: Unclosed expression, expecting '}' for modifier "ts" of variable "" with value "" +# expect+1: while evaluating "${:U:ts": Unclosed expression, expecting '}' for modifier "ts" UNCLOSED:= ${:U:ts -# expect: make: Unclosed expression, expecting '}' for modifier "ts\040" of variable "" with value "" +# expect+1: while evaluating "${:U:ts\040": Unclosed expression, expecting '}' for modifier "ts\040" UNCLOSED:= ${:U:ts\040 -# expect: make: Unclosed expression, expecting '}' for modifier "u" of variable "" with value "" +# expect+1: while evaluating "${:U:u": Unclosed expression, expecting '}' for modifier "u" UNCLOSED:= ${:U:u -# expect: make: Unclosed expression, expecting '}' for modifier "H" of variable "" with value "." +# expect+1: while evaluating "${:U:H": Unclosed expression, expecting '}' for modifier "H" UNCLOSED:= ${:U:H -# expect: make: Unclosed expression, expecting '}' for modifier "[1]" of variable "" with value "" +# expect+1: while evaluating "${:U:[1]": Unclosed expression, expecting '}' for modifier "[1]" UNCLOSED:= ${:U:[1] -# expect: make: Unclosed expression, expecting '}' for modifier "hash" of variable "" with value "b2af338b" +# expect+1: while evaluating "${:U:hash": Unclosed expression, expecting '}' for modifier "hash" UNCLOSED:= ${:U:hash -# expect: make: Unclosed expression, expecting '}' for modifier "range" of variable "" with value "1" +# expect+1: while evaluating "${:U:range": Unclosed expression, expecting '}' for modifier "range" UNCLOSED:= ${:U:range -# expect: make: Unclosed expression, expecting '}' for modifier "_" of variable "" with value "" +# expect+1: while evaluating "${:U:_": Unclosed expression, expecting '}' for modifier "_" UNCLOSED:= ${:U:_ -# expect: make: Unclosed expression, expecting '}' for modifier "gmtime" of variable "" with value "<timestamp>" +# expect+1: while evaluating "${:U:gmtime": Unclosed expression, expecting '}' for modifier "gmtime" UNCLOSED:= ${:U:gmtime -# expect: make: Unclosed expression, expecting '}' for modifier "localtime" of variable "" with value "<timestamp>" +# expect+1: while evaluating "${:U:localtime": Unclosed expression, expecting '}' for modifier "localtime" UNCLOSED:= ${:U:localtime