Module Name: src Committed By: rillig Date: Thu Dec 31 13:23:43 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: directive-for-escape.exp directive-for-escape.mk Log Message: make(1): add tests for extreme edge cases of .for loop expansion To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-for-escape.exp \ 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.1 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.2 --- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.1 Thu Dec 31 03:05:12 2020 +++ src/usr.bin/make/unit-tests/directive-for-escape.exp Thu Dec 31 13:23:43 2020 @@ -38,6 +38,14 @@ For: end for 1 For: loop body: . info ${:U\$} make: "directive-for-escape.mk" line 60: $ +For: end for 1 +For: loop body: +. info ${NUMBERS} ${:Ureplaced} +make: "directive-for-escape.mk" line 68: one two three replaced +For: end for 1 +For: loop body: +. info ${:Ureplaced} +make: "directive-for-escape.mk" line 78: replaced make: no target to make. make: stopped in unit-tests Index: src/usr.bin/make/unit-tests/directive-for-escape.mk diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.1 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.2 --- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.1 Thu Dec 31 03:05:12 2020 +++ src/usr.bin/make/unit-tests/directive-for-escape.mk Thu Dec 31 13:23:43 2020 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-escape.mk,v 1.1 2020/12/31 03:05:12 rillig Exp $ +# $NetBSD: directive-for-escape.mk,v 1.2 2020/12/31 13:23:43 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 @@ -59,3 +59,21 @@ VALUES= $${UNDEF:U\$$\$$ {{}} end} .for i in ${:U\$} . info ${i} .endfor + +# As of 2020-12-31, the name of the iteration variable can even contain +# colons, which then affects variable expressions having this exact modifier. +# This is clearly an unintended side effect of the implementation. +NUMBERS= one two three +.for NUMBERS:M*e in replaced +. info ${NUMBERS} ${NUMBERS:M*e} +.endfor + +# As of 2020-12-31, the name of the iteration variable can contain braces, +# which gets even more surprising than colons, since it allows to replace +# sequences of variable expressions. There is no practical use case for +# this, though. +BASENAME= one +EXT= .c +.for BASENAME}${EXT in replaced +. info ${BASENAME}${EXT} +.endfor