Lines Matching +full:one +full:- +full:to +full:- +full:one

1 # $NetBSD: varmod-sysv.mk,v 1.22 2025/01/11 20:54:46 rillig Exp $
3 # Tests for the variable modifier ':from=to', which replaces the suffix
4 # "from" with "to". It can also use '%' as a wildcard.
10 # A typical use case for the modifier ':from=to' is conversion of filename
16 # The modifier applies to each word on its own.
17 .if ${one.c two.c three.c:L:.c=.o} != "one.o two.o three.o"
26 # The modifier ':from=to' is therefore often combined with the modifier ':M'.
31 # Another use case for the modifier ':from=to' is to append a suffix to each
38 # The modifier ':from=to' can also be used to surround each word by strings.
39 # It might be tempting to use this for enclosing a string in quotes for the
41 .if ${one two three:L:%=(%)} != "(one) (two) (three)"
45 # When the modifier ':from=to' is parsed, it lasts until the closing brace
52 # In the modifier ':from=to', both parts can contain expressions.
53 .if ${one two:L:${:Uone}=${:U1}} != "1 two"
57 # In the modifier ':from=to', the "from" part is expanded exactly once.
62 # In the modifier ':from=to', the "to" part is expanded exactly twice.
63 # XXX: The right-hand side should be expanded only once.
64 # XXX: It's hard to get the escaping correct here, and to read that.
78 # single empty word, or no word at all. The modifier ':from=to' treats it as
87 # single empty word (before 2020-05-06), or no word at all (since 2020-05-06).
94 # Before 2020-07-19, an ampersand could be used in the replacement part
98 # This was probably a copy-and-paste mistake since the code for the SysV
104 # Before 2020-07-19, the result of the expression was "a.bcd.e".
109 # Before 2020-07-20, when a SysV modifier was parsed, a single dollar
116 # Before 2020-07-20, the modifier ':e$=x' was parsed as having a left-hand
117 # side 'e' and a right-hand side 'x'. The dollar was parsed (but not
119 # to ':e=x', which doesn't match the string "value$". Therefore the whole
120 # expression evaluated to "value$".
133 # The % placeholder can be anywhere in the string, it doesn't have to be at
139 # It's also possible to modify each word by replacing the prefix and adding
141 .if ${one two:L:o%=a%w} != "anew two"
146 .if ${one two:L:=X} != "oneX twoX"
151 .if ${one two:L:o=X} != "one twX"
156 .if ${one two:L:o=} != "one tw"
161 # a wildcard when it appears on the left-hand side.
162 .if ${one two:L:o=%} != "one tw%"
167 # wildcard even though the right-hand side does not contain another percent.
168 .if ${one two:L:%o=X} != "one X"
173 # wildcard even though the right-hand side does not contain another percent.
174 .if ${one two:L:o%=X} != "X two"
180 .if ${one two oe oxen:L:o%e=X} != "X two X oxen"
185 .if ${one two o%e other%e:L:o%%e=X} != "one two X X"
191 .if ${one two:L:%=%%} != "one% two%"
195 # In the word "one", only a prefix of the pattern suffix "nes" matches,
197 .if ${one two:L:%nes=%xxx} != "one two"
201 # The modifier ':from=to' can be used to replace both the prefix and a suffix
205 .if ${prefix-middle-suffix:L:prefix-%-suffix=p-%-s} != "p-middle-s"
210 # to an empty string. The '=' in it should be irrelevant during parsing.
211 # XXX: As of 2024-06-30, this expression generates an "Unfinished modifier"
215 .if ${word216:L:from${:D=}to}
222 # parses the modifier as "from${:D=}to", ending at the '}'. Next, the two
226 .if "${:Ufromto\}...:from${:D=}to}...=replaced}" != "replaced"
230 # As of 2020-10-06, the right-hand side of the SysV modifier is expanded
234 # XXX: This is unexpected. Add more test case to demonstrate the effects
235 # of removing one of the expansions.
244 !=1>&2 printf '%-24s %-24s %-24s\n' 'word' 'modifier' 'result'
246 . for to in '' NS % %NS NPre% NPre%NS
247 . for word in '' suffix prefix pre-middle-suffix
248 . for mod in ${from:N''}=${to:N''}
249 !=1>&2 printf '%-24s %-24s "%s"\n' ''${word:Q} ''${mod:Q} ''${word:N'':${mod}:Q}
256 # The error case of an unfinished ':from=to' modifier after the '=' requires