Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: improve error message for unknown modifier



details:   https://anonhg.NetBSD.org/src/rev/7bd64e4c140e
branches:  trunk
changeset: 980975:7bd64e4c140e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Feb 23 15:19:41 2021 +0000

description:
make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character.  Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is.  The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.

diffstat:

 usr.bin/make/unit-tests/cmd-errors-jobs.exp      |   2 +-
 usr.bin/make/unit-tests/cmd-errors-lint.exp      |   2 +-
 usr.bin/make/unit-tests/cmd-errors.exp           |   2 +-
 usr.bin/make/unit-tests/cond-token-string.exp    |   2 +-
 usr.bin/make/unit-tests/deptgt.exp               |   2 +-
 usr.bin/make/unit-tests/directive-for-errors.exp |   2 +-
 usr.bin/make/unit-tests/directive-for.exp        |   2 +-
 usr.bin/make/unit-tests/directive-undef.exp      |   2 +-
 usr.bin/make/unit-tests/moderrs.exp              |  12 ++++++------
 usr.bin/make/unit-tests/opt-debug-lint.exp       |   2 +-
 usr.bin/make/unit-tests/vardebug.exp             |   2 +-
 usr.bin/make/unit-tests/varmod-assign.exp        |   2 +-
 usr.bin/make/unit-tests/varmod-edge.exp          |   6 +++---
 usr.bin/make/unit-tests/varmod-hash.exp          |   6 +++---
 usr.bin/make/unit-tests/varmod-indirect.exp      |   8 ++++----
 usr.bin/make/unit-tests/varmod-range.exp         |   8 ++++----
 usr.bin/make/unit-tests/varmod-subst-regex.exp   |   2 +-
 usr.bin/make/unit-tests/varmod-subst.exp         |   2 +-
 usr.bin/make/unit-tests/varparse-errors.exp      |   4 ++--
 usr.bin/make/var.c                               |   7 ++++---
 20 files changed, 39 insertions(+), 38 deletions(-)

diffs (truncated from 317 to 300 lines):

diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/cmd-errors-jobs.exp
--- a/usr.bin/make/unit-tests/cmd-errors-jobs.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/cmd-errors-jobs.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -3,7 +3,7 @@
 : unclosed-variable 
 make: Unclosed variable expression (expecting '}') for "UNCLOSED"
 : unclosed-modifier 
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 : unknown-modifier  eol
 : end eol
 exit status 0
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/cmd-errors-lint.exp
--- a/usr.bin/make/unit-tests/cmd-errors-lint.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/cmd-errors-lint.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -3,7 +3,7 @@
 : unclosed-variable 
 make: Unclosed variable expression (expecting '}') for "UNCLOSED"
 : unclosed-modifier 
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 : unknown-modifier 
 : end
 exit status 2
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/cmd-errors.exp
--- a/usr.bin/make/unit-tests/cmd-errors.exp    Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/cmd-errors.exp    Tue Feb 23 15:19:41 2021 +0000
@@ -3,7 +3,7 @@
 : unclosed-variable 
 make: Unclosed variable expression (expecting '}') for "UNCLOSED"
 : unclosed-modifier 
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 : unknown-modifier  eol
 : end eol
 exit status 0
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/cond-token-string.exp
--- a/usr.bin/make/unit-tests/cond-token-string.exp     Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-string.exp     Tue Feb 23 15:19:41 2021 +0000
@@ -1,4 +1,4 @@
-make: "cond-token-string.mk" line 13: Unknown modifier 'Z'
+make: "cond-token-string.mk" line 13: Unknown modifier "Z"
 make: "cond-token-string.mk" line 13: Malformed conditional ("" != "${:Uvalue:Z}")
 make: "cond-token-string.mk" line 22: xvalue is not defined.
 make: "cond-token-string.mk" line 28: Malformed conditional (x${:Uvalue} == "")
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/deptgt.exp
--- a/usr.bin/make/unit-tests/deptgt.exp        Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt.exp        Tue Feb 23 15:19:41 2021 +0000
@@ -8,7 +8,7 @@
 ParseReadLine (37): '  : command for empty targets list'
 ParseReadLine (38): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
-make: "deptgt.mk" line 46: Unknown modifier 'Z'
+make: "deptgt.mk" line 46: Unknown modifier "Z"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/directive-for-errors.exp
--- a/usr.bin/make/unit-tests/directive-for-errors.exp  Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-errors.exp  Tue Feb 23 15:19:41 2021 +0000
@@ -13,7 +13,7 @@
 make: "directive-for-errors.mk" line 64: missing `in' in for
 make: "directive-for-errors.mk" line 66: warning: Should not be reached.
 make: "directive-for-errors.mk" line 67: for-less endfor
-make: "directive-for-errors.mk" line 73: Unknown modifier 'Z'
+make: "directive-for-errors.mk" line 73: Unknown modifier "Z"
 make: "directive-for-errors.mk" line 74: warning: Should not be reached.
 make: "directive-for-errors.mk" line 74: warning: Should not be reached.
 make: "directive-for-errors.mk" line 74: warning: Should not be reached.
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/directive-for.exp
--- a/usr.bin/make/unit-tests/directive-for.exp Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for.exp Tue Feb 23 15:19:41 2021 +0000
@@ -16,7 +16,7 @@
 make: "directive-for.mk" line 140: }{ }{ }{
 make: "directive-for.mk" line 148: outer value value
 make: "directive-for.mk" line 148: outer "quoted" \"quoted\"
-make: "directive-for.mk" line 154: Unknown modifier 'Z'
+make: "directive-for.mk" line 154: Unknown modifier "Z"
 make: "directive-for.mk" line 155: XXX: Not reached word1
 make: "directive-for.mk" line 155: XXX: Not reached word3
 make: Fatal errors encountered -- cannot continue
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/directive-undef.exp
--- a/usr.bin/make/unit-tests/directive-undef.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-undef.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -1,5 +1,5 @@
 make: "directive-undef.mk" line 29: The .undef directive requires an argument
-make: "directive-undef.mk" line 86: Unknown modifier 'Z'
+make: "directive-undef.mk" line 86: Unknown modifier "Z"
 make: "directive-undef.mk" line 103: warning: UT_EXPORTED is still listed in .MAKE.EXPORTED even though spaceit is not exported anymore.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -1,11 +1,11 @@
 mod-unknown-direct:
 want: Unknown modifier 'Z'
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 VAR:Z=before--after
 
 mod-unknown-indirect:
 want: Unknown modifier 'Z'
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 VAR:Z=before-inner}-after
 
 unclosed-direct:
@@ -126,17 +126,17 @@
 
 mod-remember-parse:
 1 1 2 3 5 8 13 21 34
-make: Unknown modifier '_'
+make: Unknown modifier "__"
 
 
 mod-sysv-parse:
-make: Unknown modifier '3'
+make: Unknown modifier "3"
 make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3
 
-make: Unknown modifier '3'
+make: Unknown modifier "3="
 make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3
 
-make: Unknown modifier '3'
+make: Unknown modifier "3=x3"
 make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3
 
 1 1 2 x3 5 8 1x3 21 34
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/opt-debug-lint.exp
--- a/usr.bin/make/unit-tests/opt-debug-lint.exp        Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-lint.exp        Tue Feb 23 15:19:41 2021 +0000
@@ -2,7 +2,7 @@
 make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L"
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P"
-make: "opt-debug-lint.mk" line 69: Unknown modifier '$'
+make: "opt-debug-lint.mk" line 69: Unknown modifier "${"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Tue Feb 23 15:19:41 2021 +0000
@@ -71,7 +71,7 @@
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, undefined)
 Result of ${:Uvariable} is "variable" (VARE_UNDEFERR|VARE_WANTRES, none, defined)
 Applying ${:u...} to "variable" (VARE_UNDEFERR|VARE_WANTRES, none, defined)
-make: "vardebug.mk" line 44: Unknown modifier 'u'
+make: "vardebug.mk" line 44: Unknown modifier "unknown"
 Result of ${:unknown} is error (VARE_UNDEFERR|VARE_WANTRES, none, defined)
 make: "vardebug.mk" line 44: Malformed conditional (${:Uvariable:unknown})
 Var_Parse: ${UNDEFINED} with VARE_UNDEFERR|VARE_WANTRES
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-assign.exp
--- a/usr.bin/make/unit-tests/varmod-assign.exp Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.exp Tue Feb 23 15:19:41 2021 +0000
@@ -15,7 +15,7 @@
 make: Bad modifier `:' for 
 mod-assign-empty: overwritten}
 mod-assign-empty: VAR=overwritten
-make: Unknown modifier ':'
+make: Unknown modifier ":x"
 
 sysv:y
 make: Unfinished modifier for "ASSIGN" ('}' missing)
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-edge.exp
--- a/usr.bin/make/unit-tests/varmod-edge.exp   Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.exp   Tue Feb 23 15:19:41 2021 +0000
@@ -15,10 +15,10 @@
 make: Unfinished modifier for "INP.eq-esc" ('=' missing)
 make: "varmod-edge.mk" line 166: ok eq-esc
 make: "varmod-edge.mk" line 166: ok colon
-make: "varmod-edge.mk" line 165: Unknown modifier ':'
-make: "varmod-edge.mk" line 165: Unknown modifier ':'
+make: "varmod-edge.mk" line 165: Unknown modifier ":"
+make: "varmod-edge.mk" line 165: Unknown modifier ":"
 make: "varmod-edge.mk" line 166: ok colons
-make: "varmod-edge.mk" line 175: Unknown modifier 'Z'
+make: "varmod-edge.mk" line 175: Unknown modifier "Z"
 make: "varmod-edge.mk" line 175: Malformed conditional (${:Z})
 make: Unfinished modifier for "" (',' missing)
 make: "varmod-edge.mk" line 188: Malformed conditional (${:S,})
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-hash.exp
--- a/usr.bin/make/unit-tests/varmod-hash.exp   Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-hash.exp   Tue Feb 23 15:19:41 2021 +0000
@@ -1,9 +1,9 @@
-make: Unknown modifier 'h'
+make: Unknown modifier "has"
 
 26bb0f5f
 12345
-make: Unknown modifier 'h'
+make: Unknown modifier "hasX"
 
-make: Unknown modifier 'h'
+make: Unknown modifier "hashed"
 
 exit status 0
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-indirect.exp
--- a/usr.bin/make/unit-tests/varmod-indirect.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-indirect.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -1,5 +1,5 @@
-make: "varmod-indirect.mk" line 19: Unknown modifier '$'
-make: "varmod-indirect.mk" line 52: Unknown modifier '$'
+make: "varmod-indirect.mk" line 19: Unknown modifier "${"
+make: "varmod-indirect.mk" line 52: Unknown modifier "${"
 make: "varmod-indirect.mk" line 55: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
 make: "varmod-indirect.mk" line 140: before
 make: "varmod-indirect.mk" line 140: after
@@ -7,7 +7,7 @@
 make: "varmod-indirect.mk" line 146: after
 make: "varmod-indirect.mk" line 152: before
 make: "varmod-indirect.mk" line 152: after
-make: "varmod-indirect.mk" line 156: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 156: Unknown modifier "Z"
 make: "varmod-indirect.mk" line 157: before
 make: "varmod-indirect.mk" line 157: after
 ParseReadLine (166): '_:=      before ${UNDEF} after'
@@ -46,7 +46,7 @@
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, defined)
 Indirect modifier "Z" from "${:UZ}"
 Applying ${UNDEF:Z} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, undefined)
-make: "varmod-indirect.mk" line 184: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 184: Unknown modifier "Z"
 Result of ${UNDEF:Z} is error (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, undefined)
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, undefined)
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-range.exp
--- a/usr.bin/make/unit-tests/varmod-range.exp  Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.exp  Tue Feb 23 15:19:41 2021 +0000
@@ -1,12 +1,12 @@
 make: "varmod-range.mk" line 53: Invalid number "x}Rest" != "Rest"" for ':range' modifier
 make: "varmod-range.mk" line 53: Malformed conditional ("${:U:range=x}Rest" != "Rest")
-make: "varmod-range.mk" line 62: Unknown modifier 'x'
+make: "varmod-range.mk" line 62: Unknown modifier "x0"
 make: "varmod-range.mk" line 62: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
-make: "varmod-range.mk" line 78: Unknown modifier 'r'
+make: "varmod-range.mk" line 78: Unknown modifier "rang"
 make: "varmod-range.mk" line 78: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
-make: "varmod-range.mk" line 85: Unknown modifier 'r'
+make: "varmod-range.mk" line 85: Unknown modifier "rango"
 make: "varmod-range.mk" line 85: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
-make: "varmod-range.mk" line 92: Unknown modifier 'r'
+make: "varmod-range.mk" line 92: Unknown modifier "ranger"
 make: "varmod-range.mk" line 92: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-subst-regex.exp
--- a/usr.bin/make/unit-tests/varmod-subst-regex.exp    Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-subst-regex.exp    Tue Feb 23 15:19:41 2021 +0000
@@ -20,6 +20,6 @@
 mod-regex-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
 make: Regex compilation error: (details omitted)
 mod-regex-errors:
-make: Unknown modifier 'Z'
+make: Unknown modifier "Z"
 mod-regex-errors: xy
 exit status 0
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varmod-subst.exp
--- a/usr.bin/make/unit-tests/varmod-subst.exp  Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-subst.exp  Tue Feb 23 15:19:41 2021 +0000
@@ -45,7 +45,7 @@
 1 two 3 tilde
 mod-subst-chain:
 A B c.
-make: Unknown modifier 'i'
+make: Unknown modifier "i"
 .
 mod-subst-dollar:$1:
 mod-subst-dollar:$2:
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/unit-tests/varparse-errors.exp
--- a/usr.bin/make/unit-tests/varparse-errors.exp       Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.exp       Tue Feb 23 15:19:41 2021 +0000
@@ -1,5 +1,5 @@
-make: "varparse-errors.mk" line 38: Unknown modifier 'Z'
-make: "varparse-errors.mk" line 46: Unknown modifier 'Z'
+make: "varparse-errors.mk" line 38: Unknown modifier "Z"
+make: "varparse-errors.mk" line 46: Unknown modifier "Z"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 8a9f956aa5a6 -r 7bd64e4c140e usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Feb 23 15:16:43 2021 +0000
+++ b/usr.bin/make/var.c        Tue Feb 23 15:19:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.850 2021/02/23 15:07:58 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.851 2021/02/23 15:19:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.850 2021/02/23 15:07:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.851 2021/02/23 15:19:41 rillig Exp $");
 
 typedef enum VarFlags {
        VFL_NONE        = 0,



Home | Main Index | Thread Index | Old Index