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): move test for recursive var...



details:   https://anonhg.NetBSD.org/src/rev/61cd627adccf
branches:  trunk
changeset: 957424:61cd627adccf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 28 14:08:37 2020 +0000

description:
make(1): move test for recursive variable to cond-func-empty

Previously, the documentation of that test was much too short to explain
all the effects that happened in the bug situation from 2020-06-28 until
2020-07-02.

diffstat:

 usr.bin/make/unit-tests/cond-func-empty.mk |  27 ++++++++++++++++++++++++++-
 usr.bin/make/unit-tests/varmisc.mk         |  12 +-----------
 2 files changed, 27 insertions(+), 12 deletions(-)

diffs (66 lines):

diff -r b25d048d04fc -r 61cd627adccf usr.bin/make/unit-tests/cond-func-empty.mk
--- a/usr.bin/make/unit-tests/cond-func-empty.mk        Sat Nov 28 14:02:30 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func-empty.mk        Sat Nov 28 14:08:37 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-empty.mk,v 1.10 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.11 2020/11/28 14:08:37 rillig Exp $
 #
 # Tests for the empty() function in .if conditions, which tests a variable
 # expression for emptiness.
@@ -155,5 +155,30 @@
 .  error
 .endif
 
+# Between 2020-06-28 and var.c 1.226 from 2020-07-02, this paragraph generated
+# a wrong error message "Variable VARNAME is recursive".
+#
+# The bug was that the !empty() condition was evaluated, even though this was
+# not necessary since the defined() condition already evaluated to false.
+#
+# When evaluating the !empty condition, the variable name was parsed as
+# "VARNAME${:U2}", but without expanding any nested variable expression, in
+# this case the ${:U2}.  Therefore, the variable name came out as simply
+# "VARNAME".  Since this variable name should have been discarded quickly after
+# parsing it, this unrealistic variable name should have done no harm.
+#
+# The variable expression was expanded though, and this was wrong.  The
+# expansion was done without the VARE_WANTRES flag (called VARF_WANTRES back
+# then) though.  This had the effect that the ${:U1} from the value of VARNAME
+# expanded to an empty string.  This in turn created the seemingly recursive
+# definition VARNAME=${VARNAME}, and that definition was never meant to be
+# expanded.
+#
+# This was fixed by expanding nested variable expressions in the variable name
+# only if the flag VARE_WANTRES is given.
+VARNAME=       ${VARNAME${:U1}}
+.if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
+.endif
+
 all:
        @:;
diff -r b25d048d04fc -r 61cd627adccf usr.bin/make/unit-tests/varmisc.mk
--- a/usr.bin/make/unit-tests/varmisc.mk        Sat Nov 28 14:02:30 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.mk        Sat Nov 28 14:08:37 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmisc.mk,v 1.28 2020/11/07 00:07:02 rillig Exp $
+# $NetBSD: varmisc.mk,v 1.29 2020/11/28 14:08:37 rillig Exp $
 #
 # Miscellaneous variable tests.
 
@@ -77,16 +77,6 @@
 manok:
        @echo MAN=${MAN}
 
-# This is an expanded variant of the above .for loop.
-# Between 2020-06-28 and 2020-07-02 this paragraph generated a wrong
-# error message "Variable VARNAME is recursive".
-# When evaluating the !empty expression, the ${:U1} was not expanded and
-# thus resulted in the seeming definition VARNAME=${VARNAME}, which is
-# obviously recursive.
-VARNAME=       ${VARNAME${:U1}}
-.if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
-.endif
-
 # begin .MAKE.SAVE_DOLLARS; see Var_SetWithFlags and ParseBoolean.
 SD_VALUES=     0 1 2 False True false true Yes No yes no On Off ON OFF on off
 SD_4_DOLLARS=  $$$$



Home | Main Index | Thread Index | Old Index