Module Name: src
Committed By: rillig
Date: Sat Jul 20 08:54:19 UTC 2024
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-order.exp varmod-order.mk
varparse-errors.exp varparse-errors.mk
Log Message:
make: remove wrong error message about an undefined variable
To generate a diff of this commit:
cvs rdiff -u -r1.1135 -r1.1136 src/usr.bin/make/var.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-order.mk \
src/usr.bin/make/unit-tests/varparse-errors.exp
cvs rdiff -u -r1.17 -r1.18 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.1135 src/usr.bin/make/var.c:1.1136
--- src/usr.bin/make/var.c:1.1135 Tue Jul 9 17:07:23 2024
+++ src/usr.bin/make/var.c Sat Jul 20 08:54:19 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -128,7 +128,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -4677,8 +4677,7 @@ VarSubstDollarDollar(const char **pp, Bu
}
static void
-VarSubstExpr(const char **pp, Buffer *buf, GNode *scope,
- VarEvalMode emode, bool *inout_errorReported)
+VarSubstExpr(const char **pp, Buffer *buf, GNode *scope, VarEvalMode emode)
{
const char *p = *pp;
const char *nested_p = p;
@@ -4686,28 +4685,8 @@ VarSubstExpr(const char **pp, Buffer *bu
/* TODO: handle errors */
if (val.str == var_Error || val.str == varUndefined) {
- if (!VarEvalMode_ShouldKeepUndef(emode)) {
- p = nested_p;
- } else if (val.str == var_Error) {
-
- /*
- * FIXME: The condition 'val.str == var_Error' doesn't
- * mean there was an undefined variable. It could
- * equally well be a parse error; see
- * unit-tests/varmod-order.mk.
- */
-
- /*
- * If variable is undefined, complain and skip the
- * variable. The complaint will stop us from doing
- * anything when the file is parsed.
- */
- if (!*inout_errorReported) {
- Parse_Error(PARSE_FATAL,
- "Undefined variable \"%.*s\"",
- (int)(nested_p - p), p);
- *inout_errorReported = true;
- }
+ if (!VarEvalMode_ShouldKeepUndef(emode)
+ || val.str == var_Error) {
p = nested_p;
} else {
/*
@@ -4761,20 +4740,13 @@ Var_Subst(const char *str, GNode *scope,
const char *p = str;
Buffer res;
- /*
- * Set true if an error has already been reported, to prevent a
- * plethora of messages when recursing
- */
- static bool errorReported;
-
Buf_Init(&res);
- errorReported = false;
while (*p != '\0') {
if (p[0] == '$' && p[1] == '$')
VarSubstDollarDollar(&p, &res, emode);
else if (p[0] == '$')
- VarSubstExpr(&p, &res, scope, emode, &errorReported);
+ VarSubstExpr(&p, &res, scope, emode);
else
VarSubstPlain(&p, &res);
}
Index: src/usr.bin/make/unit-tests/varmod-order.exp
diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.13 src/usr.bin/make/unit-tests/varmod-order.exp:1.14
--- src/usr.bin/make/unit-tests/varmod-order.exp:1.13 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/varmod-order.exp Sat Jul 20 08:54:19 2024
@@ -1,26 +1,24 @@
-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: "varmod-order.mk" line 27: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O"
-make: "varmod-order.mk" line 29: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On"
-make: "varmod-order.mk" line 31: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr"
-make: "varmod-order.mk" line 38: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn"
-make: "varmod-order.mk" line 38: Malformed conditional (${NUMBERS:Oxn})
-make: "varmod-order.mk" line 48: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo"
-make: "varmod-order.mk" line 48: Malformed conditional (${NUMBERS:On_typo})
-make: "varmod-order.mk" line 58: 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 58: Malformed conditional (${NUMBERS:Onr_typo})
-make: "varmod-order.mk" line 68: 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 68: Malformed conditional (${NUMBERS:Orn_typo})
-make: "varmod-order.mk" line 80: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onn"
-make: "varmod-order.mk" line 80: Malformed conditional (${NUMBERS:Onn})
-make: "varmod-order.mk" line 90: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onrr"
-make: "varmod-order.mk" line 90: Malformed conditional (${NUMBERS:Onrr})
-make: "varmod-order.mk" line 100: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orrn"
-make: "varmod-order.mk" line 100: Malformed conditional (${NUMBERS:Orrn})
-make: "varmod-order.mk" line 115: while evaluating variable "SWITCH" with value "On": Bad modifier ":On=Off"
-make: "varmod-order.mk" line 115: Malformed conditional (${SWITCH:On=Off} != "Off")
+make: "varmod-order.mk" line 14: 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: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OxXX"
+make: "varmod-order.mk" line 20: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O"
+make: "varmod-order.mk" line 22: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On"
+make: "varmod-order.mk" line 24: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr"
+make: "varmod-order.mk" line 31: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn"
+make: "varmod-order.mk" line 31: Malformed conditional (${NUMBERS:Oxn})
+make: "varmod-order.mk" line 41: 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 41: Malformed conditional (${NUMBERS:On_typo})
+make: "varmod-order.mk" line 51: 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 51: Malformed conditional (${NUMBERS:Onr_typo})
+make: "varmod-order.mk" line 61: 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 61: Malformed conditional (${NUMBERS:Orn_typo})
+make: "varmod-order.mk" line 73: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onn"
+make: "varmod-order.mk" line 73: Malformed conditional (${NUMBERS:Onn})
+make: "varmod-order.mk" line 83: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onrr"
+make: "varmod-order.mk" line 83: Malformed conditional (${NUMBERS:Onrr})
+make: "varmod-order.mk" line 93: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orrn"
+make: "varmod-order.mk" line 93: Malformed conditional (${NUMBERS:Orrn})
+make: "varmod-order.mk" line 108: while evaluating variable "SWITCH" with value "On": Bad modifier ":On=Off"
+make: "varmod-order.mk" line 108: Malformed conditional (${SWITCH:On=Off} != "Off")
make: Fatal errors encountered -- cannot continue
make: stopped making "all" 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.14 src/usr.bin/make/unit-tests/varmod-order.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-order.mk:1.14 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/varmod-order.mk Sat Jul 20 08:54:19 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-order.mk,v 1.14 2024/07/05 18:59:33 rillig Exp $
+# $NetBSD: varmod-order.mk,v 1.15 2024/07/20 08:54:19 rillig Exp $
#
# Tests for the :O variable modifier and its variants, which either sort the
# words of the value or shuffle them.
@@ -10,19 +10,12 @@ NUMBERS= 8 5 4 9 1 7 6 10 3 2 # in Engli
. error ${WORDS:O}
.endif
-# Unknown modifier "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 "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.
# expect+1: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O"
_:= ${WORDS:O
# expect+1: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On"
Index: src/usr.bin/make/unit-tests/varparse-errors.exp
diff -u src/usr.bin/make/unit-tests/varparse-errors.exp:1.14 src/usr.bin/make/unit-tests/varparse-errors.exp:1.15
--- src/usr.bin/make/unit-tests/varparse-errors.exp:1.14 Fri Jul 5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varparse-errors.exp Sat Jul 20 08:54:19 2024
@@ -1,25 +1,23 @@
make: "varparse-errors.mk" line 38: while evaluating "${:U:Z}" with value "": Unknown modifier "Z"
make: "varparse-errors.mk" line 47: while evaluating "${:U:Z}post" with value "": Unknown modifier "Z"
-make: "varparse-errors.mk" line 75: while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}" with value "": 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}" with value "": Bad modifier ":OX"
-make: "varparse-errors.mk" line 75: while evaluating "${:U:OX:U${IND}}" with value "": 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}" with value "": Bad modifier ":OX"
-make: "varparse-errors.mk" line 83: while evaluating "${:U:Q" with value "": Unclosed expression, expecting '}' for modifier "Q"
-make: "varparse-errors.mk" line 85: while evaluating "${:U:sh" with value "": Unclosed expression, expecting '}' for modifier "sh"
-make: "varparse-errors.mk" line 87: while evaluating "${:U:tA" with value "": Unclosed expression, expecting '}' for modifier "tA"
-make: "varparse-errors.mk" line 89: while evaluating "${:U:tsX" with value "": Unclosed expression, expecting '}' for modifier "tsX"
-make: "varparse-errors.mk" line 91: while evaluating "${:U:ts" with value "": Unclosed expression, expecting '}' for modifier "ts"
-make: "varparse-errors.mk" line 93: while evaluating "${:U:ts\040" with value "": Unclosed expression, expecting '}' for modifier "ts\040"
-make: "varparse-errors.mk" line 95: while evaluating "${:U:u" with value "": Unclosed expression, expecting '}' for modifier "u"
-make: "varparse-errors.mk" line 97: while evaluating "${:U:H" with value ".": Unclosed expression, expecting '}' for modifier "H"
-make: "varparse-errors.mk" line 99: while evaluating "${:U:[1]" with value "": Unclosed expression, expecting '}' for modifier "[1]"
-make: "varparse-errors.mk" line 101: while evaluating "${:U:hash" with value "b2af338b": Unclosed expression, expecting '}' for modifier "hash"
-make: "varparse-errors.mk" line 103: while evaluating "${:U:range" with value "1": Unclosed expression, expecting '}' for modifier "range"
-make: "varparse-errors.mk" line 105: while evaluating "${:U:_" with value "": Unclosed expression, expecting '}' for modifier "_"
-make: "varparse-errors.mk" line 107: while evaluating "${:U:gmtime" with value "<timestamp>": Unclosed expression, expecting '}' for modifier "gmtime"
-make: "varparse-errors.mk" line 109: while evaluating "${:U:localtime" with value "<timestamp>": Unclosed expression, expecting '}' for modifier "localtime"
+make: "varparse-errors.mk" line 73: while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
+make: "varparse-errors.mk" line 73: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}" with value "": Bad modifier ":OX"
+make: "varparse-errors.mk" line 73: while evaluating "${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
+make: "varparse-errors.mk" line 73: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}" with value "": Bad modifier ":OX"
+make: "varparse-errors.mk" line 81: while evaluating "${:U:Q" with value "": Unclosed expression, expecting '}' for modifier "Q"
+make: "varparse-errors.mk" line 83: while evaluating "${:U:sh" with value "": Unclosed expression, expecting '}' for modifier "sh"
+make: "varparse-errors.mk" line 85: while evaluating "${:U:tA" with value "": Unclosed expression, expecting '}' for modifier "tA"
+make: "varparse-errors.mk" line 87: while evaluating "${:U:tsX" with value "": Unclosed expression, expecting '}' for modifier "tsX"
+make: "varparse-errors.mk" line 89: while evaluating "${:U:ts" with value "": Unclosed expression, expecting '}' for modifier "ts"
+make: "varparse-errors.mk" line 91: while evaluating "${:U:ts\040" with value "": Unclosed expression, expecting '}' for modifier "ts\040"
+make: "varparse-errors.mk" line 93: while evaluating "${:U:u" with value "": Unclosed expression, expecting '}' for modifier "u"
+make: "varparse-errors.mk" line 95: while evaluating "${:U:H" with value ".": Unclosed expression, expecting '}' for modifier "H"
+make: "varparse-errors.mk" line 97: while evaluating "${:U:[1]" with value "": Unclosed expression, expecting '}' for modifier "[1]"
+make: "varparse-errors.mk" line 99: while evaluating "${:U:hash" with value "b2af338b": Unclosed expression, expecting '}' for modifier "hash"
+make: "varparse-errors.mk" line 101: while evaluating "${:U:range" with value "1": Unclosed expression, expecting '}' for modifier "range"
+make: "varparse-errors.mk" line 103: while evaluating "${:U:_" with value "": Unclosed expression, expecting '}' for modifier "_"
+make: "varparse-errors.mk" line 105: while evaluating "${:U:gmtime" with value "<timestamp>": Unclosed expression, expecting '}' for modifier "gmtime"
+make: "varparse-errors.mk" line 107: while evaluating "${:U:localtime" with value "<timestamp>": Unclosed expression, expecting '}' for modifier "localtime"
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/varparse-errors.mk
diff -u src/usr.bin/make/unit-tests/varparse-errors.mk:1.17 src/usr.bin/make/unit-tests/varparse-errors.mk:1.18
--- src/usr.bin/make/unit-tests/varparse-errors.mk:1.17 Fri Jul 5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varparse-errors.mk Sat Jul 20 08:54:19 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varparse-errors.mk,v 1.17 2024/07/05 19:47:22 rillig Exp $
+# $NetBSD: varparse-errors.mk,v 1.18 2024/07/20 08:54:19 rillig Exp $
# Tests for parsing and evaluating all kinds of expressions.
#
@@ -66,11 +66,9 @@ VAR.${:U:Z}post= unknown modifier with t
#
#.MAKEFLAGS: -dv
IND= ${:OX}
-# expect+6: while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
-# expect+5: while evaluating "${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
-# expect+4: Undefined variable "${:U:OX"
-# expect+3: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}" with value "": Bad modifier ":OX"
-# expect+2: Undefined variable "${:U:OX"
+# expect+4: while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
+# expect+3: while evaluating "${:U:OX:U${IND}}" with value "": Bad modifier ":OX"
+# expect+2: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}" with value "": Bad modifier ":OX"
# expect+1: while evaluating variable "IND" with value "${:OX}": while evaluating "${:OX}" with value "": Bad modifier ":OX"
_:= ${:U:OX:U${IND}} ${:U:OX:U${IND}}
#.MAKEFLAGS: -d0