Sun Jul 19 15:16:22 2020 UTC ()
make(1): add test for stray dollar signs in :@ modifier


(rillig)
diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/modmisc.exp
diff -r1.12 -r1.13 src/usr.bin/make/unit-tests/modmisc.mk

cvs diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/modmisc.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/modmisc.exp 2020/07/04 22:17:09 1.14
+++ src/usr.bin/make/unit-tests/modmisc.exp 2020/07/19 15:16:22 1.15
@@ -22,26 +22,29 @@ C:empty @@ -22,26 +22,29 @@ C:empty
22: b c: 22: b c:
23:a c: 23:a c:
24:x__ 3 x__ 3: 24:x__ 3 x__ 3:
25:a b b c: 25:a b b c:
26:a b b c: 26:a b b c:
27: b c: 27: b c:
28make: RE substitution error: (details omitted) 28make: RE substitution error: (details omitted)
29make: Unclosed substitution for (, missing) 29make: Unclosed substitution for (, missing)
30:C,word,____,:Q}: 30:C,word,____,:Q}:
31:a c: 31:a c:
32:x__ 3 x__ 3: 32:x__ 3 x__ 3:
33:+one+ +two+ +three+: 33:+one+ +two+ +three+:
34mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w: 34mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
 35mod-at-dollar:(1) (2) (3).
 36mod-at-dollar:(1) (2) (3).
 37mod-at-dollar:() () ().
35mod-subst-dollar:$1: 38mod-subst-dollar:$1:
36mod-subst-dollar:$2: 39mod-subst-dollar:$2:
37mod-subst-dollar:$3: 40mod-subst-dollar:$3:
38mod-subst-dollar:$4: 41mod-subst-dollar:$4:
39mod-subst-dollar:$5: 42mod-subst-dollar:$5:
40mod-subst-dollar:$6: 43mod-subst-dollar:$6:
41mod-subst-dollar:$7: 44mod-subst-dollar:$7:
42mod-subst-dollar:$8: 45mod-subst-dollar:$8:
43mod-subst-dollar:U8: 46mod-subst-dollar:U8:
44mod-subst-dollar:$$$$: 47mod-subst-dollar:$$$$:
45mod-loop-dollar:1: 48mod-loop-dollar:1:
46mod-loop-dollar:${word}: 49mod-loop-dollar:${word}:
47mod-loop-dollar:$3$: 50mod-loop-dollar:$3$:

cvs diff -r1.12 -r1.13 src/usr.bin/make/unit-tests/modmisc.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/modmisc.mk 2020/07/04 18:54:18 1.12
+++ src/usr.bin/make/unit-tests/modmisc.mk 2020/07/19 15:16:22 1.13
@@ -1,32 +1,32 @@ @@ -1,32 +1,32 @@
1# $Id: modmisc.mk,v 1.12 2020/07/04 18:54:18 rillig Exp $ 1# $Id: modmisc.mk,v 1.13 2020/07/19 15:16:22 rillig Exp $
2# 2#
3# miscellaneous modifier tests 3# miscellaneous modifier tests
4 4
5# do not put any dirs in this list which exist on some 5# do not put any dirs in this list which exist on some
6# but not all target systems - an exists() check is below. 6# but not all target systems - an exists() check is below.
7path=:/bin:/tmp::/:.:/no/such/dir:. 7path=:/bin:/tmp::/:.:/no/such/dir:.
8# strip cwd from path. 8# strip cwd from path.
9MOD_NODOT=S/:/ /g:N.:ts: 9MOD_NODOT=S/:/ /g:N.:ts:
10# and decorate, note that $'s need to be doubled. Also note that  10# and decorate, note that $'s need to be doubled. Also note that
11# the modifier_variable can be used with other modifiers. 11# the modifier_variable can be used with other modifiers.
12MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@ 12MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@
13# another mod - pretend it is more interesting 13# another mod - pretend it is more interesting
14MOD_HOMES=S,/home/,/homes/, 14MOD_HOMES=S,/home/,/homes/,
15MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@ 15MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
16MOD_SEP=S,:, ,g 16MOD_SEP=S,:, ,g
17 17
18all: modvar modvarloop modsysv mod-HTE emptyvar undefvar 18all: modvar modvarloop modsysv mod-HTE emptyvar undefvar
19all: mod-S mod-C mod-at-varname mod-at-resolve 19all: mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar
20all: mod-subst-dollar mod-loop-dollar 20all: mod-subst-dollar mod-loop-dollar
21 21
22modsysv: 22modsysv:
23 @echo "The answer is ${libfoo.a:L:libfoo.a=42}" 23 @echo "The answer is ${libfoo.a:L:libfoo.a=42}"
24 24
25modvar: 25modvar:
26 @echo "path='${path}'" 26 @echo "path='${path}'"
27 @echo "path='${path:${MOD_NODOT}}'" 27 @echo "path='${path:${MOD_NODOT}}'"
28 @echo "path='${path:S,home,homes,:${MOD_NODOT}}'" 28 @echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
29 @echo "path=${path:${MOD_NODOTX}:ts:}" 29 @echo "path=${path:${MOD_NODOTX}:ts:}"
30 @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}" 30 @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}"
31 31
32.for d in ${path:${MOD_SEP}:N.} /usr/xbin 32.for d in ${path:${MOD_SEP}:N.} /usr/xbin
@@ -85,26 +85,34 @@ mod-at-varname: @@ -85,26 +85,34 @@ mod-at-varname:
85# The :@ modifier resolves the variables a little more often than expected. 85# The :@ modifier resolves the variables a little more often than expected.
86# In particular, it resolves _all_ variables from the context, and not only 86# In particular, it resolves _all_ variables from the context, and not only
87# the loop variable (in this case v). 87# the loop variable (in this case v).
88# 88#
89# The d means direct reference, the i means indirect reference. 89# The d means direct reference, the i means indirect reference.
90RESOLVE= ${RES1} $${RES1} 90RESOLVE= ${RES1} $${RES1}
91RES1= 1d${RES2} 1i$${RES2} 91RES1= 1d${RES2} 1i$${RES2}
92RES2= 2d${RES3} 2i$${RES3} 92RES2= 2d${RES3} 2i$${RES3}
93RES3= 3 93RES3= 3
94 94
95mod-at-resolve: 95mod-at-resolve:
96 @echo $@:${RESOLVE:@v@w${v}w@:Q}: 96 @echo $@:${RESOLVE:@v@w${v}w@:Q}:
97 97
 98# As of 2020-07-19, the variable name of the :@ modifier may end with one
 99# or two dollar signs, which are silently ignored. There's no point in
 100# allowing a dollar sign in that position.
 101mod-at-dollar:
 102 @echo $@:${1 2 3:L:@v$@($v)@:Q}.
 103 @echo $@:${1 2 3:L:@v$$@($v)@:Q}.
 104 @echo $@:${1 2 3:L:@v$$$@($v)@:Q}.
 105
98# No matter how many dollar characters there are, they all get merged 106# No matter how many dollar characters there are, they all get merged
99# into a single dollar by the :S modifier. 107# into a single dollar by the :S modifier.
100mod-subst-dollar: 108mod-subst-dollar:
101 @echo $@:${:U1:S,^,$,:Q}: 109 @echo $@:${:U1:S,^,$,:Q}:
102 @echo $@:${:U2:S,^,$$,:Q}: 110 @echo $@:${:U2:S,^,$$,:Q}:
103 @echo $@:${:U3:S,^,$$$,:Q}: 111 @echo $@:${:U3:S,^,$$$,:Q}:
104 @echo $@:${:U4:S,^,$$$$,:Q}: 112 @echo $@:${:U4:S,^,$$$$,:Q}:
105 @echo $@:${:U5:S,^,$$$$$,:Q}: 113 @echo $@:${:U5:S,^,$$$$$,:Q}:
106 @echo $@:${:U6:S,^,$$$$$$,:Q}: 114 @echo $@:${:U6:S,^,$$$$$$,:Q}:
107 @echo $@:${:U7:S,^,$$$$$$$,:Q}: 115 @echo $@:${:U7:S,^,$$$$$$$,:Q}:
108 @echo $@:${:U8:S,^,$$$$$$$$,:Q}: 116 @echo $@:${:U8:S,^,$$$$$$$$,:Q}:
109# This generates no dollar at all: 117# This generates no dollar at all:
110 @echo $@:${:UU8:S,^,${:U$$$$$$$$},:Q}: 118 @echo $@:${:UU8:S,^,${:U$$$$$$$$},:Q}: