Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make/unit-tests make(1): document test for parsing o...



details:   https://anonhg.NetBSD.org/src/rev/819a3659c27e
branches:  trunk
changeset: 945650:819a3659c27e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 02 22:59:48 2020 +0000

description:
make(1): document test for parsing of variable assignments

diffstat:

 usr.bin/make/unit-tests/varname.exp |   8 +++-----
 usr.bin/make/unit-tests/varname.mk  |  12 ++++++++++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (45 lines):

diff -r b158aad06fbc -r 819a3659c27e usr.bin/make/unit-tests/varname.exp
--- a/usr.bin/make/unit-tests/varname.exp       Mon Nov 02 22:58:51 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.exp       Mon Nov 02 22:59:48 2020 +0000
@@ -14,11 +14,9 @@
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
 Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Global:.ALLTARGETS =  VAR(((=) VAR\(\(\(=
-make: "varname.mk" line 31: Need an operator
-Var_Parse: ${:UVAR\(\(\(}=     try3 with VARE_UNDEFERR|VARE_WANTRES
-Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
-Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
-make: "varname.mk" line 32: Need an operator
+make: "varname.mk" line 35: Need an operator
+Var_Parse: ${VARNAME} with VARE_WANTRES
+Global:VAR((( = try3
 Global:.MAKEFLAGS =  -r -k -d v -d
 Global:.MAKEFLAGS =  -r -k -d v -d 0
 make: Fatal errors encountered -- cannot continue
diff -r b158aad06fbc -r 819a3659c27e usr.bin/make/unit-tests/varname.mk
--- a/usr.bin/make/unit-tests/varname.mk        Mon Nov 02 22:58:51 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.mk        Mon Nov 02 22:59:48 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varname.mk,v 1.7 2020/11/02 22:44:29 rillig Exp $
+# $NetBSD: varname.mk,v 1.8 2020/11/02 22:59:48 rillig Exp $
 #
 # Tests for special variables, such as .MAKE or .PARSEDIR.
 # And for variable names in general.
@@ -28,8 +28,16 @@
 # balanced.  At the end of the line, there are still 3 levels open, which
 # means the variable name is not finished.
 ${:UVAR(((}=   try1
+# On the left-hand side of a variable assignments, the backslash is not parsed
+# as an escape character, therefore the parentheses still count to the nesting
+# level, which at the end of the line is still 3.  Therefore this is not a
+# variable assignment as well.
 ${:UVAR\(\(\(}=        try2
-${:UVAR\(\(\(}=        try3
+# To assign to a variable with an arbitrary name, the variable name has to
+# come from an external source, not the text that is parsed in the assignment
+# itself.  This is exactly the reason why further above, the indirect
+# ${VARNAME} works, while all other attempts fail.
+${VARNAME}=    try3
 
 .MAKEFLAGS: -d0
 



Home | Main Index | Thread Index | Old Index