Mon Jul 20 16:12:02 2020 UTC ()
make(1): add test for :tu modifier with spaces


(rillig)
diff -r1.20 -r1.21 src/usr.bin/make/unit-tests/modmisc.exp
diff -r1.16 -r1.17 src/usr.bin/make/unit-tests/modmisc.mk

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

--- src/usr.bin/make/unit-tests/modmisc.exp 2020/07/20 14:50:41 1.20
+++ src/usr.bin/make/unit-tests/modmisc.exp 2020/07/20 16:12:02 1.21
@@ -68,14 +68,15 @@ make: No subexpression \2 @@ -68,14 +68,15 @@ make: No subexpression \2
68make: No subexpression \2 68make: No subexpression \2
69make: No subexpression \2 69make: No subexpression \2
70mod-C-limits:22-missing:1 6 70mod-C-limits:22-missing:1 6
71mod-C-limits:22-ok:1 33 556 71mod-C-limits:22-ok:1 33 556
72mod-C-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest 72mod-C-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
73mod-assign: first=1. 73mod-assign: first=1.
74mod-assign: last=3. 74mod-assign: last=3.
75mod-assign: appended=1 2 3. 75mod-assign: appended=1 2 3.
761 761
772 772
783 783
79mod-assign: ran:3. 79mod-assign: ran:3.
80mod-assign: global: 1, 3, 1 2 3, 3. 80mod-assign: global: 1, 3, 1 2 3, 3.
 81mod-tu-space: A B
81exit status 0 82exit status 0

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

--- src/usr.bin/make/unit-tests/modmisc.mk 2020/07/19 20:49:44 1.16
+++ src/usr.bin/make/unit-tests/modmisc.mk 2020/07/20 16:12:02 1.17
@@ -1,35 +1,36 @@ @@ -1,35 +1,36 @@
1# $Id: modmisc.mk,v 1.16 2020/07/19 20:49:44 rillig Exp $ 1# $Id: modmisc.mk,v 1.17 2020/07/20 16:12:02 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 mod-at-dollar 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
21all: mod-C-limits 21all: mod-C-limits
22all: mod-assign 22all: mod-assign
 23all: mod-tu-space
23 24
24modsysv: 25modsysv:
25 @echo "The answer is ${libfoo.a:L:libfoo.a=42}" 26 @echo "The answer is ${libfoo.a:L:libfoo.a=42}"
26 27
27modvar: 28modvar:
28 @echo "path='${path}'" 29 @echo "path='${path}'"
29 @echo "path='${path:${MOD_NODOT}}'" 30 @echo "path='${path:${MOD_NODOT}}'"
30 @echo "path='${path:S,home,homes,:${MOD_NODOT}}'" 31 @echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
31 @echo "path=${path:${MOD_NODOTX}:ts:}" 32 @echo "path=${path:${MOD_NODOTX}:ts:}"
32 @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}" 33 @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}"
33 34
34.for d in ${path:${MOD_SEP}:N.} /usr/xbin 35.for d in ${path:${MOD_SEP}:N.} /usr/xbin
35path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/ 36path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/
@@ -146,13 +147,19 @@ mod-C-limits: @@ -146,13 +147,19 @@ mod-C-limits:
146 # The :C modifier only handles single-digit capturing groups, 147 # The :C modifier only handles single-digit capturing groups,
147 # which is more than enough for daily use. 148 # which is more than enough for daily use.
148 @echo $@:capture:${:UabcdefghijABCDEFGHIJrest:C,(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.),\9\8\7\6\5\4\3\2\1\0\10\11\12,} 149 @echo $@:capture:${:UabcdefghijABCDEFGHIJrest:C,(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.),\9\8\7\6\5\4\3\2\1\0\10\11\12,}
149 150
150# Just a bit of basic code coverage for the obscure ::= assignment modifiers. 151# Just a bit of basic code coverage for the obscure ::= assignment modifiers.
151mod-assign: 152mod-assign:
152 @echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}. 153 @echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}.
153 @echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}. 154 @echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}.
154 @echo $@: ${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}. 155 @echo $@: ${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}.
155 @echo $@: ${echo.1 echo.2 echo.3:L:@i@${RAN::!=${i:C,.*,&; & 1>\&2,:S,., ,g}}@} ran:${RAN}. 156 @echo $@: ${echo.1 echo.2 echo.3:L:@i@${RAN::!=${i:C,.*,&; & 1>\&2,:S,., ,g}}@} ran:${RAN}.
156 # The assignments happen in the global scope and thus are 157 # The assignments happen in the global scope and thus are
157 # preserved even after the shell command has been run. 158 # preserved even after the shell command has been run.
158 @echo $@: global: ${FIRST:Q}, ${LAST:Q}, ${APPENDED:Q}, ${RAN:Q}. 159 @echo $@: global: ${FIRST:Q}, ${LAST:Q}, ${APPENDED:Q}, ${RAN:Q}.
 160
 161mod-tu-space:
 162 # The :tu and :tl modifiers operate on the variable value
 163 # as a single string, not as a list of words. Therefore,
 164 # the adjacent spaces are preserved.
 165 @echo $@: ${a b:L:tu:Q}