]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/modts.mk
Update to bmake-20201101
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / modts.mk
1 # $NetBSD: modts.mk,v 1.7 2020/10/24 08:50:17 rillig Exp $
2
3 LIST=   one two three
4 LIST+=  four five six
5
6 FU_mod-ts=      a / b / cool
7
8 AAA=    a a a
9 B.aaa=  Baaa
10
11 all:   mod-ts mod-ts-space
12
13 # Use print or printf iff they are builtin.
14 # XXX note that this causes problems, when make decides
15 # there is no need to use a shell, so avoid where possible.
16 .if ${(type print) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
17 PRINT=  print -r --
18 .elif ${(type printf) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
19 PRINT=  printf '%s\n'
20 .else
21 PRINT=  echo
22 .endif
23
24 mod-ts:
25         @${PRINT} 'LIST:tx="${LIST:tx}"'
26         @${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"'
27         @${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
28         @${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
29         @${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
30
31 mod-ts-space:
32         # After the :ts modifier, the whole string is interpreted as a single
33         # word since all spaces have been replaced with x.
34         @${PRINT} ':ts :S => '${aa bb aa bb aa bb:L:tsx:S,b,B,:Q}
35
36         # The :ts modifier also applies to word separators that are added
37         # afterwards.
38         @${PRINT} ':ts :S space    => '${a ababa c:L:tsx:S,b, ,g:Q}
39         @${PRINT} ':ts :S space :M => '${a ababa c:L:tsx:S,b, ,g:M*:Q}
40
41         # Not all modifiers behave this way though.  Some of them always use
42         # a space as word separator instead of the :ts separator.
43         # This seems like an oversight during implementation.
44         @${PRINT} ':ts :S       => '${a ababa c:L:tsx:S,b, ,g:Q}
45         @${PRINT} ':ts :S :@    => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}
46
47         # A final :M* modifier applies the :ts separator again, though.
48         @${PRINT} ':ts :S :@ :M => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:M*:Q}