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): demonstrate double expansio...



details:   https://anonhg.NetBSD.org/src/rev/e3c847a0ea0f
branches:  trunk
changeset: 956441:e3c847a0ea0f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 30 20:36:33 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/var-op-append.exp |   6 ++++++
 usr.bin/make/unit-tests/var-op-append.mk  |  14 +++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r ce5eba3a7ce2 -r e3c847a0ea0f usr.bin/make/unit-tests/var-op-append.exp
--- a/usr.bin/make/unit-tests/var-op-append.exp Fri Oct 30 20:30:44 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-append.exp Fri Oct 30 20:36:33 2020 +0000
@@ -1,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
diff -r ce5eba3a7ce2 -r e3c847a0ea0f usr.bin/make/unit-tests/var-op-append.mk
--- a/usr.bin/make/unit-tests/var-op-append.mk  Fri Oct 30 20:30:44 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-append.mk  Fri Oct 30 20:36:33 2020 +0000
@@ -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 @@
 .  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:
        @:;



Home | Main Index | Thread Index | Old Index