Module Name: src Committed By: rillig Date: Thu Jul 4 18:53:38 UTC 2024
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk varmod-assign.exp varmod-order.exp varmod-order.mk varmod-select-words.exp varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on the "Bad modifier" error message Previously, the "Bad modifier" error message did not affect make's exit status. As a side effect, this kind of error now gets more context information. To generate a diff of this commit: cvs rdiff -u -r1.1128 -r1.1129 src/usr.bin/make/var.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-order.mk \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-select-words.exp cvs rdiff -u -r1.14 -r1.15 \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod.exp \ 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.1128 src/usr.bin/make/var.c:1.1129 --- src/usr.bin/make/var.c:1.1128 Thu Jul 4 17:47:53 2024 +++ src/usr.bin/make/var.c Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1128 2024/07/04 17:47:53 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1129 2024/07/04 18:53:37 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.1128 2024/07/04 17:47:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1129 2024/07/04 18:53:37 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1965,11 +1965,9 @@ FormatTime(const char *fmt, time_t t, bo * and stores the result back in ch->expr->value via Expr_SetValueOwn or * Expr_SetValueRefer. * - * If evaluating fails, the fallback error message "Bad modifier" is printed - * using Error. This function has no side effects, it really just prints the - * error message, continuing as if nothing had happened. TODO: This should be - * fixed by adding proper error handling to Var_Subst, Var_Parse, - * ApplyModifiers and ModifyWords. + * If evaluating fails, the fallback error message "Bad modifier" is printed. + * TODO: Add proper error handling to Var_Subst, Var_Parse, ApplyModifiers and + * ModifyWords. * * Some modifiers such as :D and :U turn undefined expressions into defined * expressions using Expr_Define. @@ -4118,8 +4116,8 @@ ApplyModifiers( bad_modifier: /* Take a guess at where the modifier ends. */ - Error("Bad modifier \":%.*s\" for variable \"%s\"", - (int)strcspn(mod, ":)}"), mod, expr->name); + Parse_Error(PARSE_FATAL, "Bad modifier \":%.*s\"", + (int)strcspn(mod, ":)}"), mod); cleanup: /* Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.38 src/usr.bin/make/unit-tests/moderrs.exp:1.39 --- src/usr.bin/make/unit-tests/moderrs.exp:1.38 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Thu Jul 4 18:53:37 2024 @@ -31,7 +31,7 @@ make: in target "words": while evaluatin make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) 13= -make: Bad modifier ":[123451234512345123451234512345]" for variable "UNDEF" +make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Bad modifier ":[123451234512345123451234512345]" 12345=S,^ok,:S,^3ok,} make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing) @@ -70,21 +70,21 @@ make: Unclosed expression, expecting '}' mod-ts-parse: 112358132134 15152535558513521534 -make: Bad modifier ":ts\65oct" for variable "FIB" +make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" 65oct} -make: Bad modifier ":ts\65oct" for variable "" +make: in target "mod-ts-parse": while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """: Bad modifier ":ts\65oct" 65oct} -make: Bad modifier ":tsxy" for variable "FIB" +make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":tsxy" xy} mod-t-parse: -make: Bad modifier ":t" for variable "FIB" +make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" -make: Bad modifier ":txy" for variable "FIB" +make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":txy" y} -make: Bad modifier ":t" for variable "FIB" +make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" -make: Bad modifier ":t" for variable "FIB" +make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" M*} make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.34 src/usr.bin/make/unit-tests/moderrs.mk:1.35 --- src/usr.bin/make/unit-tests/moderrs.mk:1.34 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/moderrs.mk Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -# $NetBSD: moderrs.mk,v 1.34 2024/07/04 17:47:54 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.35 2024/07/04 18:53:37 rillig Exp $ # # various modifier error tests @@ -133,21 +133,21 @@ mod-regex-delimiter: print-footer mod-ts-parse: print-header print-footer @echo ${FIB:ts} @echo ${FIB:ts\65} # octal 065 == U+0035 == '5' -# expect: make: Bad modifier ":ts\65oct" for variable "FIB" +# expect: make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" @echo ${FIB:ts\65oct} # bad modifier -# expect: make: Bad modifier ":ts\65oct" for variable "" +# expect: make: in target "mod-ts-parse": while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """: Bad modifier ":ts\65oct" @echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is "" -# expect: make: Bad modifier ":tsxy" for variable "FIB" +# expect: make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":tsxy" @echo ${FIB:tsxy} # modifier too long mod-t-parse: print-header print-footer -# expect: make: Bad modifier ":t" for variable "FIB" +# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" @echo ${FIB:t -# expect: make: Bad modifier ":txy" for variable "FIB" +# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":txy" @echo ${FIB:txy} -# expect: make: Bad modifier ":t" for variable "FIB" +# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" @echo ${FIB:t} -# expect: make: Bad modifier ":t" for variable "FIB" +# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" @echo ${FIB:t:M*} mod-ifelse-parse: print-footer Index: src/usr.bin/make/unit-tests/varmod-assign.exp diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.24 src/usr.bin/make/unit-tests/varmod-assign.exp:1.25 --- src/usr.bin/make/unit-tests/varmod-assign.exp:1.24 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod-assign.exp Thu Jul 4 18:53:37 2024 @@ -37,9 +37,9 @@ Global: .MAKEOVERRIDES = FIRST LAST LAS Result of ${CMD_NEW_VAR::=new-value} is "" (eval, undefined) Global: .MAKEFLAGS = -r -k -d v -d 0 -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 -d v -d 0 -make: Bad modifier ":" for variable "" +make: in target "mod-assign-empty": while evaluating "${::=value}": Bad modifier ":" mod-assign-empty: value} -make: Bad modifier ":" for variable "" +make: in target "mod-assign-empty": while evaluating "${:Uvalue::=overwritten}": Bad modifier ":" mod-assign-empty: overwritten} mod-assign-empty: VAR=overwritten make: in target "mod-assign-parse": while evaluating variable "ASSIGN" with value "": Unknown modifier ":x" Index: src/usr.bin/make/unit-tests/varmod-order.exp diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.9 src/usr.bin/make/unit-tests/varmod-order.exp:1.10 --- src/usr.bin/make/unit-tests/varmod-order.exp:1.9 Sun Nov 19 22:06:15 2023 +++ src/usr.bin/make/unit-tests/varmod-order.exp Thu Jul 4 18:53:37 2024 @@ -1,26 +1,26 @@ -make: Bad modifier ":OX" for variable "WORDS" -make: "varmod-order.mk" line 16: Undefined variable "${WORDS:OX" -make: Bad modifier ":OxXX" for variable "WORDS" -make: "varmod-order.mk" line 21: Undefined variable "${WORDS:Ox" +make: "varmod-order.mk" line 17: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OX" +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: Bad modifier ":Oxn" for variable "NUMBERS" -make: "varmod-order.mk" line 33: Malformed conditional (${NUMBERS:Oxn}) -make: Bad modifier ":On_typo" for variable "NUMBERS" -make: "varmod-order.mk" line 44: Malformed conditional (${NUMBERS:On_typo}) -make: Bad modifier ":Onr_typo" for variable "NUMBERS" -make: "varmod-order.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo}) -make: Bad modifier ":Orn_typo" for variable "NUMBERS" -make: "varmod-order.mk" line 64: Malformed conditional (${NUMBERS:Orn_typo}) -make: Bad modifier ":Onn" for variable "NUMBERS" -make: "varmod-order.mk" line 76: Malformed conditional (${NUMBERS:Onn}) -make: Bad modifier ":Onrr" for variable "NUMBERS" -make: "varmod-order.mk" line 86: Malformed conditional (${NUMBERS:Onrr}) -make: Bad modifier ":Orrn" for variable "NUMBERS" -make: "varmod-order.mk" line 96: Malformed conditional (${NUMBERS:Orrn}) -make: Bad modifier ":On=Off" for variable "SWITCH" -make: "varmod-order.mk" line 111: Malformed conditional (${SWITCH:On=Off} != "Off") +make: "varmod-order.mk" line 35: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn" +make: "varmod-order.mk" line 35: Malformed conditional (${NUMBERS:Oxn}) +make: "varmod-order.mk" line 45: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo" +make: "varmod-order.mk" line 45: Malformed conditional (${NUMBERS:On_typo}) +make: "varmod-order.mk" line 55: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onr_typo" +make: "varmod-order.mk" line 55: Malformed conditional (${NUMBERS:Onr_typo}) +make: "varmod-order.mk" line 65: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orn_typo" +make: "varmod-order.mk" line 65: Malformed conditional (${NUMBERS:Orn_typo}) +make: "varmod-order.mk" line 77: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onn" +make: "varmod-order.mk" line 77: Malformed conditional (${NUMBERS:Onn}) +make: "varmod-order.mk" line 87: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onrr" +make: "varmod-order.mk" line 87: Malformed conditional (${NUMBERS:Onrr}) +make: "varmod-order.mk" line 97: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orrn" +make: "varmod-order.mk" line 97: Malformed conditional (${NUMBERS:Orrn}) +make: "varmod-order.mk" line 112: while evaluating variable "SWITCH" with value "On": Bad modifier ":On=Off" +make: "varmod-order.mk" line 112: Malformed conditional (${SWITCH:On=Off} != "Off") 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.11 src/usr.bin/make/unit-tests/varmod-order.mk:1.12 --- src/usr.bin/make/unit-tests/varmod-order.mk:1.11 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/varmod-order.mk Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-order.mk,v 1.11 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: varmod-order.mk,v 1.12 2024/07/04 18:53:37 rillig Exp $ # # Tests for the :O variable modifier and its variants, which either sort the # words of the value or shuffle them. @@ -11,13 +11,15 @@ NUMBERS= 8 5 4 9 1 7 6 10 3 2 # in Engli .endif # Unknown modifier "OX" -# FIXME: The error message is wrong. -# expect+1: Undefined variable "${WORDS:OX" +# FIXME: The error message "Undefined variable" is wrong. +# expect+2: Undefined variable "${WORDS:OX" +# expect+1: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OX" _:= ${WORDS:OX} # Unknown modifier "OxXX" -# FIXME: The error message is wrong. -# expect+1: Undefined variable "${WORDS:Ox" +# FIXME: The error message "Undefined variable" is wrong. +# expect+2: Undefined variable "${WORDS:Ox" +# expect+1: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OxXX" _:= ${WORDS:OxXX} # Missing closing brace, to cover the error handling code. @@ -28,7 +30,7 @@ _:= ${NUMBERS:Onr # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be # combined. # -# expect: make: Bad modifier ":Oxn" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn" # expect+1: Malformed conditional (${NUMBERS:Oxn}) .if ${NUMBERS:Oxn} . error @@ -37,9 +39,8 @@ _:= ${NUMBERS:Onr .endif # Extra characters after ':On' are detected and diagnosed. -# TODO: Add line number information to the "Bad modifier" diagnostic. # -# expect: make: Bad modifier ":On_typo" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo" # expect+1: Malformed conditional (${NUMBERS:On_typo}) .if ${NUMBERS:On_typo} . error @@ -49,7 +50,7 @@ _:= ${NUMBERS:Onr # Extra characters after ':Onr' are detected and diagnosed. # -# expect: make: Bad modifier ":Onr_typo" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onr_typo" # expect+1: Malformed conditional (${NUMBERS:Onr_typo}) .if ${NUMBERS:Onr_typo} . error @@ -59,7 +60,7 @@ _:= ${NUMBERS:Onr # Extra characters after ':Orn' are detected and diagnosed. # -# expect: make: Bad modifier ":Orn_typo" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orn_typo" # expect+1: Malformed conditional (${NUMBERS:Orn_typo}) .if ${NUMBERS:Orn_typo} . error @@ -71,7 +72,7 @@ _:= ${NUMBERS:Onr # criteria are fixed, not computed, therefore allowing this redundancy does # not make sense. # -# expect: make: Bad modifier ":Onn" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onn" # expect+1: Malformed conditional (${NUMBERS:Onn}) .if ${NUMBERS:Onn} . error @@ -81,7 +82,7 @@ _:= ${NUMBERS:Onr # Repeating the 'r' is not supported as well, for the same reasons as above. # -# expect: make: Bad modifier ":Onrr" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onrr" # expect+1: Malformed conditional (${NUMBERS:Onrr}) .if ${NUMBERS:Onrr} . error @@ -91,7 +92,7 @@ _:= ${NUMBERS:Onr # Repeating the 'r' is not supported as well, for the same reasons as above. # -# expect: make: Bad modifier ":Orrn" for variable "NUMBERS" +# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orrn" # expect+1: Malformed conditional (${NUMBERS:Orrn}) .if ${NUMBERS:Orrn} . error @@ -106,7 +107,7 @@ _:= ${NUMBERS:Onr # ':H' modifier but instead replaces a trailing 'H' with 'new' in each word. # There is no such fallback for the ':O' modifiers. SWITCH= On -# expect: make: Bad modifier ":On=Off" for variable "SWITCH" +# expect+2: while evaluating variable "SWITCH" with value "On": Bad modifier ":On=Off" # expect+1: Malformed conditional (${SWITCH:On=Off} != "Off") .if ${SWITCH:On=Off} != "Off" . error Index: src/usr.bin/make/unit-tests/varparse-errors.exp diff -u src/usr.bin/make/unit-tests/varparse-errors.exp:1.11 src/usr.bin/make/unit-tests/varparse-errors.exp:1.12 --- src/usr.bin/make/unit-tests/varparse-errors.exp:1.11 Sat Apr 20 10:18:56 2024 +++ src/usr.bin/make/unit-tests/varparse-errors.exp Thu Jul 4 18:53:37 2024 @@ -1,11 +1,11 @@ make: "varparse-errors.mk" line 38: while evaluating "${:U:Z}": Unknown modifier "Z" make: "varparse-errors.mk" line 47: while evaluating "${:U:Z}post": Unknown modifier "Z" -make: Bad modifier ":OX" for variable "" -make: "varparse-errors.mk" line 71: Undefined variable "${:U:OX" -make: Bad modifier ":OX" for variable "" -make: Bad modifier ":OX" for variable "" -make: "varparse-errors.mk" line 71: Undefined variable "${:U:OX" -make: Bad modifier ":OX" for variable "" +make: "varparse-errors.mk" line 75: while evaluating "${:U:OX:U${IND}} ${: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: "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 "" Index: src/usr.bin/make/unit-tests/varmod-select-words.exp diff -u src/usr.bin/make/unit-tests/varmod-select-words.exp:1.2 src/usr.bin/make/unit-tests/varmod-select-words.exp:1.3 --- src/usr.bin/make/unit-tests/varmod-select-words.exp:1.2 Sun Jan 23 16:09:38 2022 +++ src/usr.bin/make/unit-tests/varmod-select-words.exp Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -make: Bad modifier ":[]" for variable "LIST" +make: in target "mod-squarebrackets-0-star-at": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[]" LIST:[]="" is an error LIST:[0]="one two three four five six" LIST:[0x0]="one two three four five six" @@ -37,17 +37,17 @@ REALLYSPACE=" " REALLYSPACE:[1]="" == "" ? REALLYSPACE:[*]:[1]=" " == " " ? LIST:[1]="one" -make: Bad modifier ":[1.]" for variable "LIST" +make: in target "mod-squarebrackets-n": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1.]" LIST:[1.]="" is an error -make: Bad modifier ":[1]." for variable "LIST" +make: in target "mod-squarebrackets-n": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1]." LIST:[1].="}" is an error LIST:[2]="two" LIST:[6]="six" LIST:[7]="" LIST:[999]="" -make: Bad modifier ":[-]" for variable "LIST" +make: in target "mod-squarebrackets-n": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[-]" LIST:[-]="" is an error -make: Bad modifier ":[--]" for variable "LIST" +make: in target "mod-squarebrackets-n": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[--]" LIST:[--]="" is an error LIST:[-1]="six" LIST:[-2]="five" @@ -67,22 +67,22 @@ LIST:[*]:C/ /,/:[2]="" LIST:[*]:C/ /,/:[*]:[2]="" LIST:[*]:C/ /,/:[@]:[2]="three" LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18" -make: Bad modifier ":[1.]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1.]" LIST:[1.]="" is an error -make: Bad modifier ":[1..]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1..]" LIST:[1..]="" is an error -make: Bad modifier ":[1.. ]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1.. ]" LIST:[1.. ]="" is an error LIST:[1..1]="one" -make: Bad modifier ":[1..1.]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[1..1.]" LIST:[1..1.]="" is an error LIST:[1..2]="one two" LIST:[2..1]="two one" LIST:[3..-2]="three four five" LIST:[-4..4]="three four" -make: Bad modifier ":[0..1]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[0..1]" LIST:[0..1]="" is an error -make: Bad modifier ":[-1..0]" for variable "LIST" +make: in target "mod-squarebrackets-start-end": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[-1..0]" LIST:[-1..0]="" is an error LIST:[-1..1]="six five four three two one" LIST:[0..0]="one two three four five six" @@ -97,7 +97,7 @@ LIST:[${ONE}]="one" LIST:[${MINUSONE}]="six" LIST:[${STAR}]="one two three four five six" LIST:[${AT}]="one two three four five six" -make: Bad modifier ":[${EMPTY" for variable "LIST" +make: in target "mod-squarebrackets-nested": while evaluating variable "LIST" with value "one two three four five six": Bad modifier ":[${EMPTY" LIST:[${EMPTY}]="" is an error LIST:[${LONGLIST:[21]:S/2//}]="one" LIST:[${LIST:[#]}]="six" Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.14 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.15 --- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.14 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod-to-separator.exp Thu Jul 4 18:53:37 2024 @@ -6,24 +6,24 @@ make: "varmod-to-separator.mk" line 180: make: "varmod-to-separator.mk" line 180: Malformed conditional (${word:L:ts\x,}) make: "varmod-to-separator.mk" line 187: while evaluating variable "word" with value "word": Invalid character number at "112233445566778899}" make: "varmod-to-separator.mk" line 187: Malformed conditional (${word:L:ts\x112233445566778899}) -make: Bad modifier ":ts\-300" for variable "WORDS" -make: "varmod-to-separator.mk" line 192: Malformed conditional (${WORDS:[1..3]:ts\-300:tu}) -make: Bad modifier ":ts\8" for variable "1 2 3" -make: "varmod-to-separator.mk" line 201: Malformed conditional (${1 2 3:L:ts\8:tu}) -make: Bad modifier ":ts\100L" for variable "1 2 3" -make: "varmod-to-separator.mk" line 209: Malformed conditional (${1 2 3:L:ts\100L}) -make: Bad modifier ":ts\x40g" for variable "1 2 3" -make: "varmod-to-separator.mk" line 217: Malformed conditional (${1 2 3:L:ts\x40g}) -make: Bad modifier ":tx" for variable "WORDS" -make: "varmod-to-separator.mk" line 227: Malformed conditional (${WORDS:tx}) -make: Bad modifier ":ts\X" for variable "WORDS" -make: "varmod-to-separator.mk" line 236: Malformed conditional (${WORDS:ts\X}) -make: Bad modifier ":t\X" for variable "WORDS" -make: "varmod-to-separator.mk" line 245: Malformed conditional (${WORDS:t\X} != "anything") -make: Bad modifier ":ts\69" for variable "" -make: "varmod-to-separator.mk" line 262: Malformed conditional (${:Ua b:ts\69}) -make: "varmod-to-separator.mk" line 271: while evaluating "${:Ua b:ts\x1F60E}": Invalid character number at "1F60E}" -make: "varmod-to-separator.mk" line 271: Malformed conditional (${:Ua b:ts\x1F60E}) +make: "varmod-to-separator.mk" line 193: while evaluating variable "WORDS" with value "one two three": Bad modifier ":ts\-300" +make: "varmod-to-separator.mk" line 193: Malformed conditional (${WORDS:[1..3]:ts\-300:tu}) +make: "varmod-to-separator.mk" line 203: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\8" +make: "varmod-to-separator.mk" line 203: Malformed conditional (${1 2 3:L:ts\8:tu}) +make: "varmod-to-separator.mk" line 212: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\100L" +make: "varmod-to-separator.mk" line 212: Malformed conditional (${1 2 3:L:ts\100L}) +make: "varmod-to-separator.mk" line 221: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\x40g" +make: "varmod-to-separator.mk" line 221: Malformed conditional (${1 2 3:L:ts\x40g}) +make: "varmod-to-separator.mk" line 231: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":tx" +make: "varmod-to-separator.mk" line 231: Malformed conditional (${WORDS:tx}) +make: "varmod-to-separator.mk" line 240: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":ts\X" +make: "varmod-to-separator.mk" line 240: Malformed conditional (${WORDS:ts\X}) +make: "varmod-to-separator.mk" line 250: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":t\X" +make: "varmod-to-separator.mk" line 250: Malformed conditional (${WORDS:t\X} != "anything") +make: "varmod-to-separator.mk" line 267: while evaluating "${:Ua b:ts\69}": Bad modifier ":ts\69" +make: "varmod-to-separator.mk" line 267: Malformed conditional (${:Ua b:ts\69}) +make: "varmod-to-separator.mk" line 276: while evaluating "${:Ua b:ts\x1F60E}": Invalid character number at "1F60E}" +make: "varmod-to-separator.mk" line 276: Malformed conditional (${:Ua b:ts\x1F60E}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.16 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.17 --- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.16 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod-to-separator.mk Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-to-separator.mk,v 1.16 2024/07/04 17:47:54 rillig Exp $ +# $NetBSD: varmod-to-separator.mk,v 1.17 2024/07/04 18:53:37 rillig Exp $ # # Tests for the :ts variable modifier, which joins the words of the variable # using an arbitrary character as word separator. @@ -188,6 +188,7 @@ WORDS= one two three four five six .endif # Negative numbers are not allowed for the separator character. +# expect+2: while evaluating variable "WORDS" with value "one two three": Bad modifier ":ts\-300" # expect+1: Malformed conditional (${WORDS:[1..3]:ts\-300:tu}) .if ${WORDS:[1..3]:ts\-300:tu} . warning The separator \-300 is accepted even though it is negative. @@ -197,6 +198,7 @@ WORDS= one two three four five six # The character number is interpreted as octal number by default. # The digit '8' is not an octal digit though. +# expect+2: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\8" # expect+1: Malformed conditional (${1 2 3:L:ts\8:tu}) .if ${1 2 3:L:ts\8:tu} . warning The separator \8 is accepted even though it is not octal. @@ -205,6 +207,7 @@ WORDS= one two three four five six .endif # Trailing characters after the octal character number are rejected. +# expect+2: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\100L" # expect+1: Malformed conditional (${1 2 3:L:ts\100L}) .if ${1 2 3:L:ts\100L} . warning The separator \100L is accepted even though it contains an 'L'. @@ -213,6 +216,7 @@ WORDS= one two three four five six .endif # Trailing characters after the hexadecimal character number are rejected. +# expect+2: while evaluating variable "1 2 3" with value "1 2 3": Bad modifier ":ts\x40g" # expect+1: Malformed conditional (${1 2 3:L:ts\x40g}) .if ${1 2 3:L:ts\x40g} . warning The separator \x40g is accepted even though it contains a 'g'. @@ -222,7 +226,7 @@ WORDS= one two three four five six # In the :t modifier, the :t must be followed by any of A, l, s, u. -# expect: make: Bad modifier ":tx" for variable "WORDS" +# expect+2: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":tx" # expect+1: Malformed conditional (${WORDS:tx}) .if ${WORDS:tx} . error @@ -231,7 +235,7 @@ WORDS= one two three four five six .endif # The word separator can only be a single character. -# expect: make: Bad modifier ":ts\X" for variable "WORDS" +# expect+2: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":ts\X" # expect+1: Malformed conditional (${WORDS:ts\X}) .if ${WORDS:ts\X} . error @@ -241,6 +245,7 @@ WORDS= one two three four five six # After the backslash, only n, t, an octal number, or x and a hexadecimal # number are allowed. +# expect+2: while evaluating variable "WORDS" with value "one two three four five six": Bad modifier ":t\X" # expect+1: Malformed conditional (${WORDS:t\X} != "anything") .if ${WORDS:t\X} != "anything" . info This line is not reached. @@ -257,7 +262,7 @@ WORDS= one two three four five six # happens for non-octal digits. From 2003.07.23.18.06.46 to # 2016.02.27.16.20.06, the result was '1E2', since 2016.03.07.20.20.35 make no # longer accepts this escape and complains. -# expect: make: Bad modifier ":ts\69" for variable "" +# expect+2: while evaluating "${:Ua b:ts\69}": Bad modifier ":ts\69" # expect+1: Malformed conditional (${:Ua b:ts\69}) .if ${:Ua b:ts\69} . error Index: src/usr.bin/make/unit-tests/varmod.mk diff -u src/usr.bin/make/unit-tests/varmod.mk:1.16 src/usr.bin/make/unit-tests/varmod.mk:1.17 --- src/usr.bin/make/unit-tests/varmod.mk:1.16 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod.mk Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod.mk,v 1.16 2024/07/04 17:47:54 rillig Exp $ +# $NetBSD: varmod.mk,v 1.17 2024/07/04 18:53:37 rillig Exp $ # # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback. # @@ -121,9 +121,11 @@ VAR= STOP # Test the word selection modifier ':[n]' with a very large number that is # larger than ULONG_MAX for any supported platform. +# expect+2: while evaluating variable "word" with value "word": Bad modifier ":[99333000222000111000]" # expect+1: Malformed conditional (${word:L:[99333000222000111000]}) .if ${word:L:[99333000222000111000]} .endif +# expect+2: while evaluating variable "word" with value "word": Bad modifier ":[2147483648]" # expect+1: Malformed conditional (${word:L:[2147483648]}) .if ${word:L:[2147483648]} .endif @@ -174,7 +176,7 @@ ${:U }= <space> .if ${word:L:@w@$w$@} != "word" . error .endif -# expect: make: Bad modifier ":[$]" for variable "word" +# expect+2: while evaluating variable "word" with value "": Bad modifier ":[$]" # expect+1: Malformed conditional (${word:[$]}) .if ${word:[$]} . error Index: src/usr.bin/make/unit-tests/varmod.exp diff -u src/usr.bin/make/unit-tests/varmod.exp:1.13 src/usr.bin/make/unit-tests/varmod.exp:1.14 --- src/usr.bin/make/unit-tests/varmod.exp:1.13 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod.exp Thu Jul 4 18:53:37 2024 @@ -3,31 +3,31 @@ make: "varmod.mk" line 101: Invalid vari make: "varmod.mk" line 107: while evaluating "${:Uword:@word@${word}$@} != "word"": Dollar followed by nothing make: "varmod.mk" line 117: while evaluating variable "VAR" with value "VAR": Missing delimiter ':' after modifier "P" make: "varmod.mk" line 119: Missing argument for ".error" -make: Bad modifier ":[99333000222000111000]" for variable "word" -make: "varmod.mk" line 125: Malformed conditional (${word:L:[99333000222000111000]}) -make: Bad modifier ":[2147483648]" for variable "word" -make: "varmod.mk" line 128: Malformed conditional (${word:L:[2147483648]}) -make: "varmod.mk" line 135: while evaluating variable "word" with value "word": Invalid number "99333000222000111000}" for ':range' modifier -make: "varmod.mk" line 135: Malformed conditional (${word:L:range=99333000222000111000}) -make: "varmod.mk" line 143: while evaluating "${:${:Ugmtime=\\}}": Invalid time value "\" -make: "varmod.mk" line 143: Malformed conditional (${:${:Ugmtime=\\}}) -make: "varmod.mk" line 158: while evaluating variable "VAR" with value "value$": Dollar followed by nothing -make: "varmod.mk" line 164: while evaluating variable "VAR" with value "value$": Dollar followed by nothing -make: "varmod.mk" line 164: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing -make: "varmod.mk" line 174: while evaluating variable "word" with value "word": Dollar followed by nothing -make: Bad modifier ":[$]" for variable "word" -make: "varmod.mk" line 179: Malformed conditional (${word:[$]}) -make: "varmod.mk" line 196: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing -make: "varmod.mk" line 196: while evaluating variable "VAR" with value "value<space>appended": Invalid variable name '}', at "$} != "set"" -make: "varmod.mk" line 200: while evaluating "${:Ufallback$} != "fallback"": Invalid variable name '}', at "$} != "fallback"" -make: "varmod.mk" line 205: while evaluating variable "%y" with value "%y": Invalid time value "1000$" -make: "varmod.mk" line 205: Malformed conditional (${%y:L:gmtime=1000$}) -make: "varmod.mk" line 212: while evaluating variable "%y" with value "%y": Invalid time value "1000$" -make: "varmod.mk" line 212: Malformed conditional (${%y:L:localtime=1000$}) -make: "varmod.mk" line 218: while evaluating variable "word" with value "word": Dollar followed by nothing -make: "varmod.mk" line 222: while evaluating variable "word" with value "word": Dollar followed by nothing -make: "varmod.mk" line 227: while evaluating variable "." with value ".": Invalid argument 'fallback$' for modifier ':mtime' -make: "varmod.mk" line 227: Malformed conditional (${.:L:mtime=fallback$}) +make: "varmod.mk" line 126: while evaluating variable "word" with value "word": Bad modifier ":[99333000222000111000]" +make: "varmod.mk" line 126: Malformed conditional (${word:L:[99333000222000111000]}) +make: "varmod.mk" line 130: while evaluating variable "word" with value "word": Bad modifier ":[2147483648]" +make: "varmod.mk" line 130: Malformed conditional (${word:L:[2147483648]}) +make: "varmod.mk" line 137: while evaluating variable "word" with value "word": Invalid number "99333000222000111000}" for ':range' modifier +make: "varmod.mk" line 137: Malformed conditional (${word:L:range=99333000222000111000}) +make: "varmod.mk" line 145: while evaluating "${:${:Ugmtime=\\}}": Invalid time value "\" +make: "varmod.mk" line 145: Malformed conditional (${:${:Ugmtime=\\}}) +make: "varmod.mk" line 160: while evaluating variable "VAR" with value "value$": Dollar followed by nothing +make: "varmod.mk" line 166: while evaluating variable "VAR" with value "value$": Dollar followed by nothing +make: "varmod.mk" line 166: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing +make: "varmod.mk" line 176: while evaluating variable "word" with value "word": Dollar followed by nothing +make: "varmod.mk" line 181: while evaluating variable "word" with value "": Bad modifier ":[$]" +make: "varmod.mk" line 181: Malformed conditional (${word:[$]}) +make: "varmod.mk" line 198: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing +make: "varmod.mk" line 198: while evaluating variable "VAR" with value "value<space>appended": Invalid variable name '}', at "$} != "set"" +make: "varmod.mk" line 202: while evaluating "${:Ufallback$} != "fallback"": Invalid variable name '}', at "$} != "fallback"" +make: "varmod.mk" line 207: while evaluating variable "%y" with value "%y": Invalid time value "1000$" +make: "varmod.mk" line 207: Malformed conditional (${%y:L:gmtime=1000$}) +make: "varmod.mk" line 214: while evaluating variable "%y" with value "%y": Invalid time value "1000$" +make: "varmod.mk" line 214: Malformed conditional (${%y:L:localtime=1000$}) +make: "varmod.mk" line 220: while evaluating variable "word" with value "word": Dollar followed by nothing +make: "varmod.mk" line 224: while evaluating variable "word" with value "word": Dollar followed by nothing +make: "varmod.mk" line 229: while evaluating variable "." with value ".": Invalid argument 'fallback$' for modifier ':mtime' +make: "varmod.mk" line 229: Malformed conditional (${.:L:mtime=fallback$}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varparse-errors.mk diff -u src/usr.bin/make/unit-tests/varparse-errors.mk:1.13 src/usr.bin/make/unit-tests/varparse-errors.mk:1.14 --- src/usr.bin/make/unit-tests/varparse-errors.mk:1.13 Sun Jun 2 15:31:26 2024 +++ src/usr.bin/make/unit-tests/varparse-errors.mk Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varparse-errors.mk,v 1.13 2024/06/02 15:31:26 rillig Exp $ +# $NetBSD: varparse-errors.mk,v 1.14 2024/07/04 18:53:37 rillig Exp $ # Tests for parsing and evaluating all kinds of expressions. # @@ -66,8 +66,12 @@ VAR.${:U:Z}post= unknown modifier with t # #.MAKEFLAGS: -dv IND= ${:OX} +# expect+6: while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}": Bad modifier ":OX" +# expect+5: while evaluating "${:U:OX:U${IND}}": Bad modifier ":OX" +# expect+4: Undefined variable "${:U:OX" +# expect+3: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}": Bad modifier ":OX" # expect+2: Undefined variable "${:U:OX" -# expect+1: Undefined variable "${:U:OX" +# expect+1: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}": Bad modifier ":OX" _:= ${:U:OX:U${IND}} ${:U:OX:U${IND}} #.MAKEFLAGS: -d0