1 # $NetBSD: varmod-match.mk,v 1.6 2020/11/15 18:33:41 rillig Exp $
3 # Tests for the :M variable modifier, which filters words that match the
6 # See ApplyModifier_Match and ModifyWord_Match for the implementation.
10 NUMBERS= One Two Three Four five six seven
12 # Only keep words that start with an uppercase letter.
13 .if ${NUMBERS:M[A-Z]*} != "One Two Three Four"
17 # Only keep words that start with a character other than an uppercase letter.
18 .if ${NUMBERS:M[^A-Z]*} != "five six seven"
22 # Only keep words that don't start with s and at the same time end with
25 # This test case ensures that the negation from the first character class
26 # does not propagate to the second character class.
27 .if ${NUMBERS:M[^s]*[ex]} != "One Three five"
31 # Before 2020-06-13, this expression took quite a long time in Str_Match,
32 # calling itself 601080390 times for 16 asterisks.
33 .if ${:U****************:M****************b}
36 # To match a dollar sign in a word, double it.
38 # This is different from the :S and :C variable modifiers, where a '$'
39 # has to be escaped as '\$'.
40 .if ${:Ua \$ sign:M*$$*} != "\$"
44 # In the :M modifier, '\$' does not escape a dollar. Instead it is
45 # interpreted as a backslash followed by whatever expression the
48 # This differs from the :S, :C and several other variable modifiers.
50 .if ${:Ua \$ sign any-asterisk:M*\$*} != "any-asterisk"
54 # TODO: ${VAR:M(((}}}}
55 # TODO: ${VAR:M{{{)))}
56 # TODO: ${VAR:M${UNBALANCED}}
57 # TODO: ${VAR:M${:U(((\}\}\}}}