Module Name: src Committed By: rillig Date: Sat Jul 4 18:54:18 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk Log Message: make(1): add tests for dollar characters in modifiers To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/modmisc.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.12 src/usr.bin/make/unit-tests/modmisc.exp:1.13 --- src/usr.bin/make/unit-tests/modmisc.exp:1.12 Sat Jul 4 17:41:04 2020 +++ src/usr.bin/make/unit-tests/modmisc.exp Sat Jul 4 18:54:18 2020 @@ -32,4 +32,20 @@ make: Unclosed substitution for (, miss :x__ 3 x__ 3: :+one+ +two+ +three+: mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w: +mod-subst-dollar:$1: +mod-subst-dollar:$2: +mod-subst-dollar:$3: +mod-subst-dollar:$4: +mod-subst-dollar:$5: +mod-subst-dollar:$6: +mod-subst-dollar:$7: +mod-subst-dollar:$8: +mod-subst-dollar:U8: +mod-subst-dollar:$$$$: +mod-loop-dollar:1: +mod-loop-dollar:${word}: +mod-loop-dollar:$3$: +mod-loop-dollar:$${word}$: +mod-loop-dollar:$$5$$: +mod-loop-dollar:$$${word}$$: exit status 0 Index: src/usr.bin/make/unit-tests/modmisc.mk diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.11 src/usr.bin/make/unit-tests/modmisc.mk:1.12 --- src/usr.bin/make/unit-tests/modmisc.mk:1.11 Sat Jul 4 17:41:04 2020 +++ src/usr.bin/make/unit-tests/modmisc.mk Sat Jul 4 18:54:18 2020 @@ -1,4 +1,4 @@ -# $Id: modmisc.mk,v 1.11 2020/07/04 17:41:04 rillig Exp $ +# $Id: modmisc.mk,v 1.12 2020/07/04 18:54:18 rillig Exp $ # # miscellaneous modifier tests @@ -17,6 +17,7 @@ MOD_SEP=S,:, ,g all: modvar modvarloop modsysv mod-HTE emptyvar undefvar all: mod-S mod-C mod-at-varname mod-at-resolve +all: mod-subst-dollar mod-loop-dollar modsysv: @echo "The answer is ${libfoo.a:L:libfoo.a=42}" @@ -93,3 +94,34 @@ RES3= 3 mod-at-resolve: @echo $@:${RESOLVE:@v@w${v}w@:Q}: + +# No matter how many dollar characters there are, they all get merged +# into a single dollar by the :S modifier. +mod-subst-dollar: + @echo $@:${:U1:S,^,$,:Q}: + @echo $@:${:U2:S,^,$$,:Q}: + @echo $@:${:U3:S,^,$$$,:Q}: + @echo $@:${:U4:S,^,$$$$,:Q}: + @echo $@:${:U5:S,^,$$$$$,:Q}: + @echo $@:${:U6:S,^,$$$$$$,:Q}: + @echo $@:${:U7:S,^,$$$$$$$,:Q}: + @echo $@:${:U8:S,^,$$$$$$$$,:Q}: +# This generates no dollar at all: + @echo $@:${:UU8:S,^,${:U$$$$$$$$},:Q}: +# Here is an alternative way to generate dollar characters. +# It's unexpectedly complicated though. + @echo $@:${:U:range=5:ts\x24:C,[0-9],,g:Q}: + +# Demonstrate that it is possible to generate dollar characters using the +# :@ modifier. +# +# These are edge cases that could have resulted in a parse error as well +# since the $@ at the end could have been interpreted as a variable, which +# would mean a missing closing @ delimiter. +mod-loop-dollar: + @echo $@:${:U1:@word@${word}$@:Q}: + @echo $@:${:U2:@word@$${word}$$@:Q}: + @echo $@:${:U3:@word@$$${word}$$$@:Q}: + @echo $@:${:U4:@word@$$$${word}$$$$@:Q}: + @echo $@:${:U5:@word@$$$$${word}$$$$$@:Q}: + @echo $@:${:U6:@word@$$$$$${word}$$$$$$@:Q}: