diff options
Diffstat (limited to 'contrib/bmake/unit-tests/directive-for-escape.mk')
-rw-r--r-- | contrib/bmake/unit-tests/directive-for-escape.mk | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/contrib/bmake/unit-tests/directive-for-escape.mk b/contrib/bmake/unit-tests/directive-for-escape.mk index 0bd2af68625a..d61f05cc53cc 100644 --- a/contrib/bmake/unit-tests/directive-for-escape.mk +++ b/contrib/bmake/unit-tests/directive-for-escape.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-escape.mk,v 1.3 2020/12/31 14:26:37 rillig Exp $ +# $NetBSD: directive-for-escape.mk,v 1.6 2021/01/25 19:05:39 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 @@ VALUES= $$ $${V} $${V:=-with-modifier} $$(V) $$(V:=-with-modifier) . 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 @@ -89,8 +103,10 @@ i,= comma . info . $$(i): $(i) . info . $$(i:M*): $(i:M*) . info . $${i$${:U}}: ${i${:U}} -. info . $${i\}}: ${i\}} # XXX: unclear why SubstVarLong needs this +. info . $${i\}}: ${i\}} # XXX: unclear why ForLoop_SubstVarLong needs this . info . $${i2}: ${i2} . info . $${i,}: ${i,} . info . adjacent: $i${i}${i:M*}$i .endfor + +all: |