Module Name: src Committed By: rillig Date: Sun Jun 30 15:21:24 UTC 2024
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk opt-debug-file.exp opt-debug-file.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-subst-regex.exp varmod-sysv.exp varmod-sysv.mk Log Message: make: error out on some more syntax errors Previously, these errors only produced a message on stderr. They only affected make's exit status when they were evaluated at parse time, but not when evaluating the commands for a specific target right before executing them. The affected syntax errors are: * invalid regular expressions in the ':C' modifier * out-of-range references to regex groups in the ':C' modifier * unfinished modifiers To generate a diff of this commit: cvs rdiff -u -r1.1124 -r1.1125 src/usr.bin/make/var.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-file.exp \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-file.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-sysv.exp 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.1124 src/usr.bin/make/var.c:1.1125 --- src/usr.bin/make/var.c:1.1124 Sun Jun 30 13:01:01 2024 +++ src/usr.bin/make/var.c Sun Jun 30 15:21:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1124 2024/06/30 13:01:01 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 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.1124 2024/06/30 13:01:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1567,7 +1567,7 @@ RegexError(int reerr, const regex_t *pat size_t errlen = regerror(reerr, pat, NULL, 0); char *errbuf = bmake_malloc(errlen); regerror(reerr, pat, errbuf, errlen); - Error("%s: %s", str, errbuf); + Parse_Error(PARSE_FATAL, "%s: %s", str, errbuf); free(errbuf); } @@ -1579,7 +1579,7 @@ RegexReplaceBackref(char ref, SepBuf *bu unsigned int n = (unsigned)ref - '0'; if (n >= nsub) - Error("No subexpression \\%u", n); + Parse_Error(PARSE_FATAL, "No subexpression \\%u", n); else if (m[n].rm_so == -1) { if (opts.strict) Error("No match for subexpression \\%u", n); @@ -2230,8 +2230,8 @@ ParseModifierPart( *pp = p; if (*p != end1 && *p != end2) { - Error("Unfinished modifier for \"%s\" ('%c' missing)", - ch->expr->name, end2); + Parse_Error(PARSE_FATAL, + "Unfinished modifier ('%c' missing)", end2); LazyBuf_Done(part); return false; } @@ -2933,7 +2933,8 @@ ApplyModifier_Subst(const char **pp, Mod char delim = (*pp)[1]; if (delim == '\0') { - Error("Missing delimiter for modifier ':S'"); + Parse_Error(PARSE_FATAL, + "Missing delimiter for modifier ':S'"); (*pp)++; return AMR_CLEANUP; } @@ -2982,7 +2983,8 @@ ApplyModifier_Regex(const char **pp, Mod char delim = (*pp)[1]; if (delim == '\0') { - Error("Missing delimiter for :C modifier"); + Parse_Error(PARSE_FATAL, + "Missing delimiter for modifier ':C'"); (*pp)++; return AMR_CLEANUP; } Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.36 src/usr.bin/make/unit-tests/moderrs.exp:1.37 --- src/usr.bin/make/unit-tests/moderrs.exp:1.36 Sun Jun 30 14:23:18 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Sun Jun 30 15:21:24 2024 @@ -1,8 +1,6 @@ -mod-unknown-direct: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before--after -mod-unknown-indirect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before-inner}-after @@ -14,14 +12,12 @@ unclosed-indirect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" VAR:S,V,v,=Thevariable -unfinished-indirect: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing) VAR:S,V,v= -unfinished-loop: -make: Unfinished modifier for "UNDEF" ('@' missing) +make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing) -make: Unfinished modifier for "UNDEF" ('@' missing) +make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing) 1 2 3 @@ -30,46 +26,42 @@ make: Unclosed expression, expecting '}' 1}... 2}... 3}... 1}... 2}... 3}... -words: -make: Unfinished modifier for "UNDEF" (']' missing) +make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing) -make: Unfinished modifier for "UNDEF" (']' missing) +make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing) 13= make: Bad modifier ":[123451234512345123451234512345]" for variable "UNDEF" 12345=S,^ok,:S,^3ok,} -exclam: -make: Unfinished modifier for "VARNAME" ('!' missing) +make: in target "exclam": while evaluating variable "VARNAME": Unfinished modifier ('!' missing) -make: Unfinished modifier for "!" ('!' missing) +make: in target "exclam": while evaluating variable "!": Unfinished modifier ('!' missing) -mod-subst-delimiter: -make: Missing delimiter for modifier ':S' +make: in target "mod-subst-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':S' 1: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 2: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 3: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 4: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 5: make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable" 6: TheVariable 7: TheVariable -mod-regex-delimiter: -make: Missing delimiter for :C modifier +make: in target "mod-regex-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':C' 1: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 2: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 3: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 4: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) 5: make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable" 6: TheVariable @@ -95,23 +87,20 @@ make: Bad modifier ":t" for variable "FI make: Bad modifier ":t" for variable "FIB" M*} -mod-ifelse-parse: -make: Unfinished modifier for "FIB" (':' missing) +make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) -make: Unfinished modifier for "FIB" (':' missing) +make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) -make: Unfinished modifier for "FIB" ('}' missing) +make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) -make: Unfinished modifier for "FIB" ('}' missing) +make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) then -mod-remember-parse: 1 1 2 3 5 8 13 21 34 make: in target "mod-remember-parse": while evaluating variable "FIB": Unknown modifier "__" -mod-sysv-parse: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3" make: Unclosed expression, expecting '}' for modifier "3" of variable "FIB" with value "" Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.32 src/usr.bin/make/unit-tests/moderrs.mk:1.33 --- src/usr.bin/make/unit-tests/moderrs.mk:1.32 Sun Jun 30 14:23:18 2024 +++ src/usr.bin/make/unit-tests/moderrs.mk Sun Jun 30 15:21:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: moderrs.mk,v 1.32 2024/06/30 14:23:18 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.33 2024/06/30 15:21:24 rillig Exp $ # # various modifier error tests @@ -24,11 +24,11 @@ all: mod-ifelse-parse all: mod-remember-parse all: mod-sysv-parse -mod-unknown-direct: print-header print-footer +mod-unknown-direct: print-footer # expect: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z" @echo 'VAR:Z=before-${VAR:Z}-after' -mod-unknown-indirect: print-header print-footer +mod-unknown-indirect: print-footer # expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z" @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' @@ -40,14 +40,14 @@ unclosed-indirect: print-header print-fo # expect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" @echo VAR:${MOD_TERM},=${VAR:${MOD_S} -unfinished-indirect: print-header print-footer -# expect: make: Unfinished modifier for "VAR" (',' missing) +unfinished-indirect: print-footer +# expect: make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing) -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" -unfinished-loop: print-header print-footer -# expect: make: Unfinished modifier for "UNDEF" ('@' missing) +unfinished-loop: print-footer +# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing) @echo ${UNDEF:U1 2 3:@var} -# expect: make: Unfinished modifier for "UNDEF" ('@' missing) +# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing) @echo ${UNDEF:U1 2 3:@var@...} @echo ${UNDEF:U1 2 3:@var@${var}@} @@ -58,13 +58,14 @@ unfinished-loop: print-header print-foot # 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}..." @echo ${UNDEF:U1 2 3:@var@${var}}...@ @echo ${UNDEF:U1 2 3:@var@${var}}...@} -words: print-header print-footer -# expect: make: Unfinished modifier for "UNDEF" (']' missing) +words: print-footer +# expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing) @echo ${UNDEF:U1 2 3:[} -# expect: make: Unfinished modifier for "UNDEF" (']' missing) +# expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing) @echo ${UNDEF:U1 2 3:[#} # out of bounds => empty @@ -89,61 +90,88 @@ words: print-header print-footer # That variable is undefined, resulting in an empty string. @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,} -exclam: print-header print-footer -# expect: make: Unfinished modifier for "VARNAME" ('!' missing) +exclam: print-footer +# expect: make: in target "exclam": while evaluating variable "VARNAME": Unfinished modifier ('!' missing) @echo ${VARNAME:!echo} # When the final exclamation mark is missing, there is no # fallback to the SysV substitution modifier. # If there were a fallback, the output would be "exclam", # and the above would have produced an "Unknown modifier '!'". -# expect: make: Unfinished modifier for "!" ('!' missing) +# expect: make: in target "exclam": while evaluating variable "!": Unfinished modifier ('!' missing) @echo ${!:L:!=exclam} -mod-subst-delimiter: print-header print-footer +mod-subst-delimiter: print-footer +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':S' @echo 1: ${VAR:S +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 2: ${VAR:S, +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 3: ${VAR:S,from +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 4: ${VAR:S,from, +# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": 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" @echo 6: ${VAR:S,from,to, @echo 7: ${VAR:S,from,to,} -mod-regex-delimiter: print-header print-footer +mod-regex-delimiter: print-footer +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':C' @echo 1: ${VAR:C +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 2: ${VAR:C, +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 3: ${VAR:C,from +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing) @echo 4: ${VAR:C,from, +# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": 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" @echo 6: ${VAR:C,from,to, @echo 7: ${VAR:C,from,to,} 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" @echo ${FIB:ts\65oct} # bad modifier +# expect: make: Bad modifier ":ts\65oct" for variable "" @echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is "" +# expect: make: Bad modifier ":tsxy" for variable "FIB" @echo ${FIB:tsxy} # modifier too long mod-t-parse: print-header print-footer +# expect: make: Bad modifier ":t" for variable "FIB" @echo ${FIB:t +# expect: make: Bad modifier ":txy" for variable "FIB" @echo ${FIB:txy} +# expect: make: Bad modifier ":t" for variable "FIB" @echo ${FIB:t} +# expect: make: Bad modifier ":t" for variable "FIB" @echo ${FIB:t:M*} -mod-ifelse-parse: print-header print-footer +mod-ifelse-parse: print-footer +# expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) @echo ${FIB:? +# expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) @echo ${FIB:?then +# expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) @echo ${FIB:?then: +# expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) @echo ${FIB:?then:else @echo ${FIB:?then:else} -mod-remember-parse: print-header print-footer +mod-remember-parse: print-footer @echo ${FIB:_} # ok +# expect: make: in target "mod-remember-parse": while evaluating variable "FIB": Unknown modifier "__" @echo ${FIB:__} # modifier name too long -mod-sysv-parse: print-header print-footer +mod-sysv-parse: print-footer +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3" @echo ${FIB:3 +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3=" @echo ${FIB:3= +# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3=x3" @echo ${FIB:3=x3 @echo ${FIB:3=x3} # ok Index: src/usr.bin/make/unit-tests/opt-debug-file.exp diff -u src/usr.bin/make/unit-tests/opt-debug-file.exp:1.7 src/usr.bin/make/unit-tests/opt-debug-file.exp:1.8 --- src/usr.bin/make/unit-tests/opt-debug-file.exp:1.7 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/opt-debug-file.exp Sun Jun 30 15:21:24 2024 @@ -3,10 +3,10 @@ make: "opt-debug-file.mk" line 47: This make: "opt-debug-file.mk" line 50: This goes to stderr, and in addition to the debug log. CondParser_Eval: ${:!cat opt-debug-file.debuglog!:Maddition:[#]} != 1 Comparing 1.000000 != 1.000000 -make: Missing delimiter for modifier ':S' -make: Missing delimiter for modifier ':S' -make: Missing delimiter for modifier ':S' -CondParser_Eval: ${:!cat opt-debug-file.debuglog!:Mdelimiter:[#]} != 1 +make: Unterminated quoted string [make 'This goes to stdout only, once.] +make: Unterminated quoted string [make 'This goes to stderr only, once.] +make: Unterminated quoted string [make 'This goes to stderr, and in addition to the debug log.] +CondParser_Eval: ${:!cat opt-debug-file.debuglog!:MUnterminated:[#]} != 1 Comparing 1.000000 != 1.000000 Cannot open debug file "/nonexistent-6f21c672-a22d-4ef7/opt-debug-file.debuglog" exit status 2 Index: src/usr.bin/make/unit-tests/varmod-subst-regex.exp diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.7 src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.8 --- src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.7 Sat Apr 20 10:18:55 2024 +++ src/usr.bin/make/unit-tests/varmod-subst-regex.exp Sun Jun 30 15:21:24 2024 @@ -1,24 +1,24 @@ -make: Regex compilation error: (details omitted) +make: in target "mod-regex-compile-error": while evaluating "${:Uword1 word2:C,****,____,g:C,word,____,:Q}.": Regex compilation error: (details omitted) mod-regex-compile-error: C,word,____,:Q}. -make: No subexpression \1 -make: No subexpression \1 -make: No subexpression \1 -make: No subexpression \1 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\1\1,:Q}": No subexpression \1 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\1\1,:Q}": No subexpression \1 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\1\1,:Q}": No subexpression \1 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\1\1,:Q}": No subexpression \1 mod-regex-limits:11-missing:1 6 mod-regex-limits:11-ok:1 22 446 -make: No subexpression \2 -make: No subexpression \2 -make: No subexpression \2 -make: No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,..,\2\2,:Q}": No subexpression \2 mod-regex-limits:22-missing:1 6 -make: No subexpression \2 -make: No subexpression \2 -make: No subexpression \2 -make: No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}": No subexpression \2 +make: in target "mod-regex-limits": while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}": No subexpression \2 mod-regex-limits:22-missing:1 6 mod-regex-limits:22-ok:1 33 556 mod-regex-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest -make: Regex compilation error: (details omitted) +make: in target "mod-regex-errors": while evaluating variable "UNDEF": Regex compilation error: (details omitted) mod-regex-errors: make: in target "mod-regex-errors": while evaluating variable "word": while evaluating "${:U:Z}y,W}": Unknown modifier "Z" mod-regex-errors: xy Index: src/usr.bin/make/unit-tests/opt-debug-file.mk diff -u src/usr.bin/make/unit-tests/opt-debug-file.mk:1.10 src/usr.bin/make/unit-tests/opt-debug-file.mk:1.11 --- src/usr.bin/make/unit-tests/opt-debug-file.mk:1.10 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/opt-debug-file.mk Sun Jun 30 15:21:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: opt-debug-file.mk,v 1.10 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: opt-debug-file.mk,v 1.11 2024/06/30 15:21:24 rillig Exp $ # # Tests for the -dF command line option, which redirects the debug log # to a file instead of writing it to stderr. @@ -54,15 +54,18 @@ DEBUG_OUTPUT:= ${:!cat opt-debug-file.de .endif -# See ApplyModifier_Subst, which calls Error. +# See Main_ParseArgLine, which calls Error. .MAKEFLAGS: -dFstdout -: This goes to stderr only, once. ${:U:S +# expect: make: Unterminated quoted string [make 'This goes to stdout only, once.] +.MAKEFLAGS: 'This goes to stdout only, once. .MAKEFLAGS: -dFstderr -: This goes to stderr only, once. ${:U:S +# expect: make: Unterminated quoted string [make 'This goes to stderr only, once.] +.MAKEFLAGS: 'This goes to stderr only, once. .MAKEFLAGS: -dFopt-debug-file.debuglog -: This goes to stderr, and in addition to the debug log. ${:U:S +# expect: make: Unterminated quoted string [make 'This goes to stderr, and in addition to the debug log.] +.MAKEFLAGS: 'This goes to stderr, and in addition to the debug log. .MAKEFLAGS: -dFstderr -d0c -.if ${:!cat opt-debug-file.debuglog!:Mdelimiter:[#]} != 1 +.if ${:!cat opt-debug-file.debuglog!:MUnterminated:[#]} != 1 . error .endif Index: src/usr.bin/make/unit-tests/varmod-assign.exp diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.22 src/usr.bin/make/unit-tests/varmod-assign.exp:1.23 --- src/usr.bin/make/unit-tests/varmod-assign.exp:1.22 Sun Jun 30 11:44:14 2024 +++ src/usr.bin/make/unit-tests/varmod-assign.exp Sun Jun 30 15:21:24 2024 @@ -45,7 +45,7 @@ mod-assign-empty: VAR=overwritten make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unknown modifier ":x" sysv:y -make: Unfinished modifier for "ASSIGN" ('}' missing) +make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unfinished modifier ('}' missing) ok=word make: warning: in target "mod-assign-shell-error": while evaluating variable "SH_ERR": Command " echo word; (exit 13) " exited with status 13 Index: src/usr.bin/make/unit-tests/varmod-assign.mk diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.21 src/usr.bin/make/unit-tests/varmod-assign.mk:1.22 --- src/usr.bin/make/unit-tests/varmod-assign.mk:1.21 Sun Jun 30 11:37:21 2024 +++ src/usr.bin/make/unit-tests/varmod-assign.mk Sun Jun 30 15:21:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-assign.mk,v 1.21 2024/06/30 11:37:21 rillig Exp $ +# $NetBSD: varmod-assign.mk,v 1.22 2024/06/30 15:21:24 rillig Exp $ # # Tests for the obscure ::= variable modifiers, which perform variable # assignments during evaluation, just like the = operator in C. @@ -95,6 +95,7 @@ mod-assign-parse: # When parsing an assignment operator fails because the operator is # incomplete, make falls back to the SysV modifier. +# expect: make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unfinished modifier ('}' missing) @echo ${SYSV::=sysv\:x}${SYSV::x=:y} @echo ${ASSIGN::=value # missing closing brace Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.17 src/usr.bin/make/unit-tests/varmod-edge.exp:1.18 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.17 Sat Apr 20 10:18:55 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Sun Jun 30 15:21:24 2024 @@ -1,27 +1,27 @@ -make: "varmod-edge.mk" line 184: ok M-paren -make: "varmod-edge.mk" line 184: ok M-mixed -make: "varmod-edge.mk" line 184: ok M-unescape +make: "varmod-edge.mk" line 185: ok M-paren +make: "varmod-edge.mk" line 185: ok M-mixed +make: "varmod-edge.mk" line 185: ok M-unescape make: Unclosed expression, expecting '}' for modifier "U*)" of variable "" with value "*)" -make: "varmod-edge.mk" line 184: ok M-nest-mix -make: "varmod-edge.mk" line 184: ok M-nest-brk -make: "varmod-edge.mk" line 184: ok M-pat-err -make: "varmod-edge.mk" line 184: ok M-bsbs -make: "varmod-edge.mk" line 184: ok M-bs1-par -make: "varmod-edge.mk" line 184: ok M-bs2-par -make: "varmod-edge.mk" line 184: ok M-128 -make: "varmod-edge.mk" line 184: ok eq-ext -make: "varmod-edge.mk" line 184: ok eq-q -make: "varmod-edge.mk" line 184: ok eq-bs -make: Unfinished modifier for "INP.eq-esc" ('=' missing) -make: "varmod-edge.mk" line 184: ok eq-esc -make: "varmod-edge.mk" line 184: ok colon -make: "varmod-edge.mk" line 167: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" -make: "varmod-edge.mk" line 167: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" -make: "varmod-edge.mk" line 184: ok colons -make: "varmod-edge.mk" line 195: while evaluating "${:Z}": Unknown modifier "Z" -make: "varmod-edge.mk" line 195: Malformed conditional (${:Z}) -make: Unfinished modifier for "" (',' missing) -make: "varmod-edge.mk" line 209: Malformed conditional (${:S,}) +make: "varmod-edge.mk" line 185: ok M-nest-mix +make: "varmod-edge.mk" line 185: ok M-nest-brk +make: "varmod-edge.mk" line 185: ok M-pat-err +make: "varmod-edge.mk" line 185: ok M-bsbs +make: "varmod-edge.mk" line 185: ok M-bs1-par +make: "varmod-edge.mk" line 185: ok M-bs2-par +make: "varmod-edge.mk" line 185: ok M-128 +make: "varmod-edge.mk" line 185: ok eq-ext +make: "varmod-edge.mk" line 185: ok eq-q +make: "varmod-edge.mk" line 185: ok eq-bs +make: "varmod-edge.mk" line 168: while evaluating variable "MOD.eq-esc": while evaluating variable "INP.eq-esc": Unfinished modifier ('=' missing) +make: "varmod-edge.mk" line 185: ok eq-esc +make: "varmod-edge.mk" line 185: ok colon +make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" +make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" +make: "varmod-edge.mk" line 185: ok colons +make: "varmod-edge.mk" line 196: while evaluating "${:Z}": Unknown modifier "Z" +make: "varmod-edge.mk" line 196: Malformed conditional (${:Z}) +make: "varmod-edge.mk" line 210: while evaluating "${:S,}": Unfinished modifier (',' missing) +make: "varmod-edge.mk" line 210: Malformed conditional (${:S,}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-sysv.mk diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.17 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.18 --- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.17 Sat Jun 1 18:44:05 2024 +++ src/usr.bin/make/unit-tests/varmod-sysv.mk Sun Jun 30 15:21:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-sysv.mk,v 1.17 2024/06/01 18:44:05 rillig Exp $ +# $NetBSD: varmod-sysv.mk,v 1.18 2024/06/30 15:21:24 rillig Exp $ # # Tests for the variable modifier ':from=to', which replaces the suffix # "from" with "to". It can also use '%' as a wildcard. @@ -208,11 +208,12 @@ # This is not a SysV modifier since the nested expression expands # to an empty string. The '=' in it should be irrelevant during parsing. -# XXX: As of 2020-12-05, this expression generates an "Unfinished modifier" +# XXX: As of 2024-06-30, this expression generates an "Unfinished modifier" # error, while the correct error message would be "Unknown modifier" since # there is no modifier named "fromto". -# expect+1: Malformed conditional (${word214:L:from${:D=}to}) -.if ${word214:L:from${:D=}to} +# expect+2: while evaluating variable "word216": Unfinished modifier ('=' missing) +# expect+1: Malformed conditional (${word216:L:from${:D=}to}) +.if ${word216:L:from${:D=}to} . error .endif @@ -255,6 +256,7 @@ INDIRECT= 1:${VALUE} 2:$${VALUE} 4:$$$${ # The error case of an unfinished ':from=to' modifier after the '=' requires # an expression that is missing the closing '}'. +# expect+2: while evaluating variable "error": Unfinished modifier ('}' missing) # expect+1: Malformed conditional (${error:L:from=$(})) .if ${error:L:from=$(}) .endif Index: src/usr.bin/make/unit-tests/varmod-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.20 src/usr.bin/make/unit-tests/varmod-edge.mk:1.21 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.20 Sat Apr 20 10:18:55 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Sun Jun 30 15:21:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.20 2024/04/20 10:18:55 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.21 2024/06/30 15:21:24 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -162,6 +162,7 @@ MOD.colons= ${INP.colons::::} EXP.colons= # empty .for test in ${TESTS} +# expect+3: while evaluating variable "MOD.eq-esc": while evaluating variable "INP.eq-esc": Unfinished modifier ('=' missing) # expect+2: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" # expect+1: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":" . if ${MOD.${test}} == ${EXP.${test}} @@ -204,7 +205,7 @@ EXP.colons= # empty # variable name with quotes, leading to the rather confusing "Unfinished # modifier for (',' missing)", having two spaces in a row. # -# XXX: The error message should report the filename:lineno. +# expect+2: while evaluating "${:S,}": Unfinished modifier (',' missing) # expect+1: Malformed conditional (${:S,}) .if ${:S,} . error Index: src/usr.bin/make/unit-tests/varmod-sysv.exp diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.11 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.12 --- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.11 Sat Jun 1 18:44:05 2024 +++ src/usr.bin/make/unit-tests/varmod-sysv.exp Sun Jun 30 15:21:24 2024 @@ -1,5 +1,5 @@ -make: Unfinished modifier for "word214" ('=' missing) -make: "varmod-sysv.mk" line 215: Malformed conditional (${word214:L:from${:D=}to}) +make: "varmod-sysv.mk" line 216: while evaluating variable "word216": Unfinished modifier ('=' missing) +make: "varmod-sysv.mk" line 216: Malformed conditional (${word216:L:from${:D=}to}) word modifier result '' = "" suffix = "suffix" @@ -145,8 +145,8 @@ pre-middle-suffix pre%ffix=NPre% suffix pre%ffix=NPre%NS "suffix" prefix pre%ffix=NPre%NS "prefix" pre-middle-suffix pre%ffix=NPre%NS "NPre-middle-suNS" -make: Unfinished modifier for "error" ('}' missing) -make: "varmod-sysv.mk" line 259: Malformed conditional (${error:L:from=$(})) +make: "varmod-sysv.mk" line 261: while evaluating variable "error": Unfinished modifier ('}' missing) +make: "varmod-sysv.mk" line 261: Malformed conditional (${error:L:from=$(})) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1