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(1): error out on unknown variable modifier...



details:   https://anonhg.NetBSD.org/src/rev/6c30535acdd2
branches:  trunk
changeset: 958036:6c30535acdd2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 20 19:47:34 2020 +0000

description:
make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such.  This "error message"
also did not influence the exit status in the default mode but only in
-dL mode.  The error message also didn't include any line number
information and was thus rude.

diffstat:

 usr.bin/make/unit-tests/cond-token-string.exp |  2 +-
 usr.bin/make/unit-tests/opt-debug-lint.exp    |  2 +-
 usr.bin/make/unit-tests/vardebug.exp          |  2 +-
 usr.bin/make/unit-tests/varmod-edge.exp       |  9 +++++----
 usr.bin/make/unit-tests/varmod-indirect.exp   |  6 ++++--
 usr.bin/make/unit-tests/varmod-range.exp      |  8 ++++----
 usr.bin/make/unit-tests/varparse-errors.exp   |  8 +++++---
 usr.bin/make/unit-tests/varparse-errors.mk    |  6 +++++-
 usr.bin/make/var.c                            |  6 +++---
 9 files changed, 29 insertions(+), 20 deletions(-)

diffs (146 lines):

diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/cond-token-string.exp
--- a/usr.bin/make/unit-tests/cond-token-string.exp     Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-token-string.exp     Sun Dec 20 19:47:34 2020 +0000
@@ -1,4 +1,4 @@
-make: Unknown modifier 'Z'
+make: "cond-token-string.mk" line 9: Unknown modifier 'Z'
 make: "cond-token-string.mk" line 9: Malformed conditional ("" != "${:Uvalue:Z}")
 make: "cond-token-string.mk" line 18: xvalue is not defined.
 make: "cond-token-string.mk" line 24: Malformed conditional (x${:Uvalue} == "")
diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/opt-debug-lint.exp
--- a/usr.bin/make/unit-tests/opt-debug-lint.exp        Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-lint.exp        Sun Dec 20 19:47:34 2020 +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: 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 e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Sun Dec 20 19:47:34 2020 +0000
@@ -71,7 +71,7 @@
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
 Result of ${:Uvariable} is "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Applying ${:u...} to "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
-make: Unknown modifier 'u'
+make: "vardebug.mk" line 44: Unknown modifier 'u'
 Result of ${:unknown} is error (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 make: "vardebug.mk" line 44: Malformed conditional (${:Uvariable:unknown})
 Var_Parse: ${UNDEFINED} with VARE_UNDEFERR|VARE_WANTRES
diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/varmod-edge.exp
--- a/usr.bin/make/unit-tests/varmod-edge.exp   Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.exp   Sun Dec 20 19:47:34 2020 +0000
@@ -15,8 +15,9 @@
 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: Unknown modifier ':'
-make: 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
-ok
-exit status 0
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/varmod-indirect.exp
--- a/usr.bin/make/unit-tests/varmod-indirect.exp       Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-indirect.exp       Sun Dec 20 19:47:34 2020 +0000
@@ -1,2 +1,4 @@
-make: Unknown modifier '$'
-exit status 0
+make: "varmod-indirect.mk" line 13: Unknown modifier '$'
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/varmod-range.exp
--- a/usr.bin/make/unit-tests/varmod-range.exp  Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.exp  Sun Dec 20 19:47:34 2020 +0000
@@ -1,13 +1,13 @@
 make: "varmod-range.mk" line 53: Invalid number: x}Rest" != "Rest"
 
 make: "varmod-range.mk" line 53: Malformed conditional ("${:U:range=x}Rest" != "Rest")
-make: Unknown modifier 'x'
+make: "varmod-range.mk" line 62: Unknown modifier 'x'
 make: "varmod-range.mk" line 62: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
-make: Unknown modifier 'r'
+make: "varmod-range.mk" line 78: Unknown modifier 'r'
 make: "varmod-range.mk" line 78: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
-make: Unknown modifier 'r'
+make: "varmod-range.mk" line 85: Unknown modifier 'r'
 make: "varmod-range.mk" line 85: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
-make: Unknown modifier 'r'
+make: "varmod-range.mk" line 92: Unknown modifier 'r'
 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 e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/varparse-errors.exp
--- a/usr.bin/make/unit-tests/varparse-errors.exp       Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.exp       Sun Dec 20 19:47:34 2020 +0000
@@ -1,3 +1,5 @@
-make: Unknown modifier 'Z'
-make: Unknown modifier 'Z'
-exit status 0
+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 e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/unit-tests/varparse-errors.mk
--- a/usr.bin/make/unit-tests/varparse-errors.mk        Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.mk        Sun Dec 20 19:47:34 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varparse-errors.mk,v 1.2 2020/12/01 20:15:23 rillig Exp $
+# $NetBSD: varparse-errors.mk,v 1.3 2020/12/20 19:47:34 rillig Exp $
 
 # Tests for parsing and evaluating all kinds of variable expressions.
 #
@@ -33,12 +33,16 @@
 .endif
 
 # As of 2020-12-01, errors in the variable name are silently ignored.
+# Since var.c 1.754 from 2020-12-20, unknown modifiers at parse time result
+# in an error message and a non-zero exit status.
 VAR.${:U:Z}=   unknown modifier in the variable name
 .if ${VAR.} != "unknown modifier in the variable name"
 .  error
 .endif
 
 # As of 2020-12-01, errors in the variable name are silently ignored.
+# Since var.c 1.754 from 2020-12-20, unknown modifiers at parse time result
+# in an error message and a non-zero exit status.
 VAR.${:U:Z}post=       unknown modifier with text in the variable name
 .if ${VAR.post} != "unknown modifier with text in the variable name"
 .  error
diff -r e78cfb9f3d41 -r 6c30535acdd2 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Dec 20 19:37:23 2020 +0000
+++ b/usr.bin/make/var.c        Sun Dec 20 19:47:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.753 2020/12/20 19:10:53 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.754 2020/12/20 19:47:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.753 2020/12/20 19:10:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.754 2020/12/20 19:47:34 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -3511,7 +3511,7 @@
 #endif
 
        if (res == AMR_UNKNOWN) {
-               Error("Unknown modifier '%c'", *mod);
+               Parse_Error(PARSE_FATAL, "Unknown modifier '%c'", *mod);
                /*
                 * Guess the end of the current modifier.
                 * XXX: Skipping the rest of the modifier hides



Home | Main Index | Thread Index | Old Index