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