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): describe expansion of neste...



details:   https://anonhg.NetBSD.org/src/rev/8b569e3da8da
branches:  trunk
changeset: 958922:8b569e3da8da
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 24 19:48:11 2021 +0000

description:
make(1): describe expansion of nested variables in .for values

These edge cases are not documented anywhere, and their behavior is
non-intuitive.  For now, just describe them, don't try to fix them.
There may be people out there relying on exactly this behavior.

diffstat:

 usr.bin/make/unit-tests/directive-for-escape.exp |  36 +++++++++++++----------
 usr.bin/make/unit-tests/directive-for-escape.mk  |  24 ++++++++++++---
 2 files changed, 39 insertions(+), 21 deletions(-)

diffs (109 lines):

diff -r c8ad67015aa0 -r 8b569e3da8da usr.bin/make/unit-tests/directive-for-escape.exp
--- a/usr.bin/make/unit-tests/directive-for-escape.exp  Sun Jan 24 19:38:49 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.exp  Sun Jan 24 19:48:11 2021 +0000
@@ -27,25 +27,29 @@
 For: end for 1
 For: loop body:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 52: ${UNDEF:U\$
+make: "directive-for-escape.mk" line 55: ${UNDEF:U\$
 For: loop body:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 52: {{}}
+make: "directive-for-escape.mk" line 55: {{}}
 For: loop body:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 52: end}
+make: "directive-for-escape.mk" line 55: end}
+For: end for 1
+For: loop body:
+.  info ${:Ubegin<${UNDEF:Ufallback:N{{{}}}}>end}
+make: "directive-for-escape.mk" line 66: begin<fallback>end
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 60: $
+make: "directive-for-escape.mk" line 74: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 68: one two three replaced
+make: "directive-for-escape.mk" line 82: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 78: replaced
+make: "directive-for-escape.mk" line 92: replaced
 For: end for 1
 For: loop body:
 .  info .        $$i: ${:Uinner}
@@ -58,14 +62,14 @@
 .  info .     $${i2}: ${i2}
 .  info .     $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 86: .        $i: inner
-make: "directive-for-escape.mk" line 87: .      ${i}: inner
-make: "directive-for-escape.mk" line 88: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 89: .      $(i): inner
-make: "directive-for-escape.mk" line 90: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 91: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 92: .    ${i\}}: inner}
-make: "directive-for-escape.mk" line 93: .     ${i2}: two
-make: "directive-for-escape.mk" line 94: .     ${i,}: comma
-make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 100: .        $i: inner
+make: "directive-for-escape.mk" line 101: .      ${i}: inner
+make: "directive-for-escape.mk" line 102: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 103: .      $(i): inner
+make: "directive-for-escape.mk" line 104: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 105: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 106: .    ${i\}}: inner}
+make: "directive-for-escape.mk" line 107: .     ${i2}: two
+make: "directive-for-escape.mk" line 108: .     ${i,}: comma
+make: "directive-for-escape.mk" line 109: .  adjacent: innerinnerinnerinner
 exit status 0
diff -r c8ad67015aa0 -r 8b569e3da8da usr.bin/make/unit-tests/directive-for-escape.mk
--- a/usr.bin/make/unit-tests/directive-for-escape.mk   Sun Jan 24 19:38:49 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.mk   Sun Jan 24 19:48:11 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.4 2021/01/24 19:30:18 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.5 2021/01/24 19:48:11 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -41,17 +41,31 @@
 .  info $i
 .endfor
 
-# Cover the code for nested '{}' in for_var_len.
+# Try to cover the code for nested '{}' in for_var_len, without success.
 #
-# The value of VALUES is not a variable expression.  Instead, it is meant to
-# represent dollar, lbrace, "UNDEF:U", backslash, dollar, backslash, dollar,
-# space, nested braces, space, "end}".
+# The value of VALUES is not meant to be a variable expression.  Instead, it
+# is meant to represent dollar, lbrace, "UNDEF:U", backslash, dollar,
+# backslash, dollar, space, nested braces, space, "end}".
+#
+# The .for loop splits ${VALUES} into 3 words, at the space characters, since
+# these are not escaped.
 VALUES=                $${UNDEF:U\$$\$$ {{}} end}
 # XXX: Where does the '\$$\$$' get converted into a single '\$'?
 .for i in ${VALUES}
 .  info $i
 .endfor
 
+# Second try to cover the code for nested '{}' in for_var_len.
+#
+# XXX: It is wrong that for_var_len requires the braces to be balanced.
+# Each variable modifier has its own inconsistent way of parsing nested
+# variable expressions, braces and parentheses.  The only sensible thing
+# to do is therefore to let Var_Parse do all the parsing work.
+VALUES=                begin<$${UNDEF:Ufallback:N{{{}}}}>end
+.for i in ${VALUES}
+.  info $i
+.endfor
+
 # A single trailing dollar doesn't happen in practice.
 # The dollar sign is correctly passed through to the body of the .for loop.
 # There, it is expanded by the .info directive, but even there a trailing



Home | Main Index | Thread Index | Old Index