Module Name: src Committed By: rillig Date: Thu Jun 24 23:22:17 UTC 2021
Modified Files: src/usr.bin/make/unit-tests: directive-for-escape.exp directive-for-escape.mk Log Message: tests/make: test .for loop over a variable named '$' It's an impractical edge case, nevertheless it's accepted by make. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.8 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9 --- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.8 Tue Feb 23 15:56:30 2021 +++ src/usr.bin/make/unit-tests/directive-for-escape.exp Thu Jun 24 23:22:17 2021 @@ -72,4 +72,11 @@ make: "directive-for-escape.mk" line 107 make: "directive-for-escape.mk" line 108: . ${i2}: two make: "directive-for-escape.mk" line 109: . ${i,}: comma make: "directive-for-escape.mk" line 110: . adjacent: innerinnerinnerinner +For: end for 1 +For: loop body: +. info eight $$$$$$$$ and no cents. +. info eight ${:Udollar}${:Udollar}${:Udollar}${:Udollar} and no cents. +make: "directive-for-escape.mk" line 118: eight $$$$ and no cents. +make: "directive-for-escape.mk" line 119: eight dollardollardollardollar and no cents. +make: "directive-for-escape.mk" line 128: eight and no cents. exit status 0 Index: src/usr.bin/make/unit-tests/directive-for-escape.mk diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.7 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8 --- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.7 Mon Feb 15 07:58:19 2021 +++ src/usr.bin/make/unit-tests/directive-for-escape.mk Thu Jun 24 23:22:17 2021 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-escape.mk,v 1.7 2021/02/15 07:58:19 rillig Exp $ +# $NetBSD: directive-for-escape.mk,v 1.8 2021/06/24 23:22:17 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 @@ -110,4 +110,21 @@ i,= comma . info . adjacent: $i${i}${i:M*}$i .endfor +# The variable name can be a single '$' since there is no check on valid +# variable names. ForLoop_SubstVarShort skips "stupid" variable names though, +# but ForLoop_SubstVarLong naively parses the body of the loop, substituting +# each '${$}' with an actual 'dollar'. +.for $ in dollar +. info eight $$$$$$$$ and no cents. +. info eight ${$}${$}${$}${$} and no cents. +.endfor +# Outside a .for loop, '${$}' is interpreted differently. The outer '$' starts +# a variable expression. The inner '$' is followed by a '}' and is thus a +# silent syntax error, the '$' is skipped. The variable name is thus '', and +# since since there is never a variable named '', the whole expression '${$}' +# evaluates to an empty string. +closing-brace= } # guard against an +${closing-brace}= <closing-brace> # alternative interpretation +.info eight ${$}${$}${$}${$} and no cents. + all: