Sun Jul 26 12:18:12 2020 UTC ()
make(1): demonstrate bug in the :S modifier with the 1 modifier

The bug has been introduced in var.c r1.268 on 2020-07-19.


(rillig)
diff -r1.23 -r1.24 src/usr.bin/make/unit-tests/modmisc.mk

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

--- src/usr.bin/make/unit-tests/modmisc.mk 2020/07/26 11:39:55 1.23
+++ src/usr.bin/make/unit-tests/modmisc.mk 2020/07/26 12:18:11 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $Id: modmisc.mk,v 1.23 2020/07/26 11:39:55 rillig Exp $ 1# $Id: modmisc.mk,v 1.24 2020/07/26 12:18:11 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/,
@@ -62,26 +62,47 @@ emptyvar: @@ -62,26 +62,47 @@ emptyvar:
62 @echo S:${:S,^$,empty,} 62 @echo S:${:S,^$,empty,}
63 @echo C:${:C,^$,empty,} 63 @echo C:${:C,^$,empty,}
64 @echo @:${:@var@${var}@} 64 @echo @:${:@var@${var}@}
65 65
66# The :U modifier turns even the "" variable into something that has a value. 66# The :U modifier turns even the "" variable into something that has a value.
67# The resulting variable is empty, but is still considered to contain a 67# The resulting variable is empty, but is still considered to contain a
68# single empty word. This word can be accessed by the :S and :C modifiers, 68# single empty word. This word can be accessed by the :S and :C modifiers,
69# but not by the :@ modifier since it explicitly skips empty words. 69# but not by the :@ modifier since it explicitly skips empty words.
70undefvar: 70undefvar:
71 @echo S:${:U:S,^$,empty,} 71 @echo S:${:U:S,^$,empty,}
72 @echo C:${:U:C,^$,empty,} 72 @echo C:${:U:C,^$,empty,}
73 @echo @:${:U:@var@empty@} 73 @echo @:${:U:@var@empty@}
74 74
 75WORDS= sequences of letters
 76# FIXME: The "*" in "letters" must not be substituted because of the 1.
 77.if ${WORDS:S,e,*,1} != "s*quences of l*tters"
 78.warning ${WORDS:S,e,*,1}
 79.endif
 80.if ${WORDS:S,e,*,} != "s*quences of l*tters"
 81.error oops
 82.endif
 83.if ${WORDS:S,e,*,g} != "s*qu*nc*s of l*tt*rs"
 84.error oops
 85.endif
 86.if ${WORDS:S,^sequ,occurr,} != "occurrences of letters"
 87.error oops
 88.endif
 89.if ${WORDS:S,^of,with,} != "sequences with letters"
 90.error oops
 91.endif
 92.if ${WORDS:S,^office,does not match,} != ${WORDS}
 93.error oops
 94.endif
 95
75mod-subst: 96mod-subst:
76 @echo $@: 97 @echo $@:
77 @echo :${:Ua b b c:S,a b,,:Q}: 98 @echo :${:Ua b b c:S,a b,,:Q}:
78 @echo :${:Ua b b c:S,a b,,1:Q}: 99 @echo :${:Ua b b c:S,a b,,1:Q}:
79 @echo :${:Ua b b c:S,a b,,W:Q}: 100 @echo :${:Ua b b c:S,a b,,W:Q}:
80 @echo :${:Ua b b c:S,b,,g:Q}: 101 @echo :${:Ua b b c:S,b,,g:Q}:
81 @echo :${:U1 2 3 1 2 3:S,1 2,___,Wg:S,_,x,:Q}: 102 @echo :${:U1 2 3 1 2 3:S,1 2,___,Wg:S,_,x,:Q}:
82 @echo ${:U12345:S,,sep,g:Q} 103 @echo ${:U12345:S,,sep,g:Q}
83 104
84mod-regex: 105mod-regex:
85 @echo $@: 106 @echo $@:
86 @echo :${:Ua b b c:C,a b,,:Q}: 107 @echo :${:Ua b b c:C,a b,,:Q}:
87 @echo :${:Ua b b c:C,a b,,1:Q}: 108 @echo :${:Ua b b c:C,a b,,1:Q}: