1 # $NetBSD: varmod-sysv.mk,v 1.3 2020/08/23 14:52:06 rillig Exp $
3 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
4 # "from" with "to". It can also use '%' as a wildcard.
6 # This modifier is applied when the other modifiers don't match exactly.
8 all: words ampersand anchor-dollar mismatch
10 # The :Q looks like a modifier but isn't.
11 # It is part of the replacement string.
13 @echo a${a b c d e:L:%a=x:Q}b
15 # Before 2020-07-19, an ampersand could be used in the replacement part
16 # of a SysV substitution modifier. This was probably a copy-and-paste
17 # mistake since the SysV modifier code looked a lot like the code for the
18 # :S and :C modifiers. The ampersand is not mentioned in the manual page.
20 @echo ${:U${a.bcd.e:L:a.%=%}:Q}
21 @echo ${:U${a.bcd.e:L:a.%=&}:Q}
23 # Before 2020-07-20, when a SysV modifier was parsed, a single dollar
24 # before the '=' was interpreted as an anchor, which doesn't make sense
25 # since the anchor was discarded immediately.
27 @echo $@: ${:U${value:L:e$=x}:Q}
28 @echo $@: ${:U${value:L:e=x}:Q}
30 # Words that don't match are copied unmodified.
31 # The % placeholder can be anywhere in the string.
33 @echo $@: ${:Ufile.c file.h:%.c=%.cpp}
34 @echo $@: ${:Ufile.c other.c:file.%=renamed.%}
36 # Trying to cover all possible variants of the SysV modifier.
50 EXPR.7= ${LIST:o%%e=X} # Only the first '%' is the wildcard.
51 EXP.7= one two # None of the words contains a literal '%'.
54 EXPR.9= ${LIST:%nes=%xxx} # lhs is longer than the word "one"
57 .for i in ${:U:range=9}
58 .if ${EXPR.$i} != ${EXP.$i}
59 .warning test case $i expected "${EXP.$i}", got "${EXPR.$i}