Module Name:    src
Committed By:   rillig
Date:           Fri Oct 30 20:36:33 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: var-op-append.exp var-op-append.mk

Log Message:
make(1): demonstrate double expansion when appending to a variable


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-op-append.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-op-append.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/unit-tests/var-op-append.exp
diff -u src/usr.bin/make/unit-tests/var-op-append.exp:1.1 src/usr.bin/make/unit-tests/var-op-append.exp:1.2
--- src/usr.bin/make/unit-tests/var-op-append.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/var-op-append.exp	Fri Oct 30 20:36:33 2020
@@ -1 +1,7 @@
+Var_Parse: ${:U\$\$\$\$\$\$\$\$} with VARE_WANTRES
+Applying ${:U...} to "" (VARE_WANTRES, none, VEF_UNDEF)
+Result of ${:U\$\$\$\$\$\$\$\$} is "$$$$$$$$" (VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
+Global:VAR.$$$$ = dollars
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/var-op-append.mk
diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.6 src/usr.bin/make/unit-tests/var-op-append.mk:1.7
--- src/usr.bin/make/unit-tests/var-op-append.mk:1.6	Sat Oct 24 08:50:17 2020
+++ src/usr.bin/make/unit-tests/var-op-append.mk	Fri Oct 30 20:36:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-append.mk,v 1.6 2020/10/24 08:50:17 rillig Exp $
+# $NetBSD: var-op-append.mk,v 1.7 2020/10/30 20:36:33 rillig Exp $
 #
 # Tests for the += variable assignment operator, which appends to a variable,
 # creating it if necessary.
@@ -32,5 +32,17 @@ C++=	value
 .  error
 .endif
 
+# Try out how often the variable name is expanded when appending to a
+# nonexistent variable.
+# As of 2020-10-30, that's two times.
+# XXX: That's one time too often.
+# See Var_Append, the call to Var_Set.
+.MAKEFLAGS: -dv
+VAR.${:U\$\$\$\$\$\$\$\$}+=	dollars
+.MAKEFLAGS: -d0
+.if ${VAR.${:U\$\$\$\$}} != "dollars"
+.  error
+.endif
+
 all:
 	@:;

Reply via email to