| @@ -1,16 +1,17 @@ | | | @@ -1,16 +1,17 @@ |
1 | # $Id: sysv.mk,v 1.8 2020/07/20 16:27:55 rillig Exp $ | | 1 | # $Id: sysv.mk,v 1.9 2020/07/26 11:19:04 rillig Exp $ |
2 | | | 2 | |
3 | all: foo fun sam bla words ampersand anchor-dollar | | 3 | all: foo fun sam bla words ampersand anchor-dollar |
| | | 4 | all: mismatch |
4 | | | 5 | |
5 | FOO ?= | | 6 | FOO ?= |
6 | FOOBAR = ${FOO:=bar} | | 7 | FOOBAR = ${FOO:=bar} |
7 | | | 8 | |
8 | _this := ${.PARSEDIR}/${.PARSEFILE} | | 9 | _this := ${.PARSEDIR}/${.PARSEFILE} |
9 | | | 10 | |
10 | B = /b | | 11 | B = /b |
11 | S = / | | 12 | S = / |
12 | FUN = ${B}${S}fun | | 13 | FUN = ${B}${S}fun |
13 | SUN = the Sun | | 14 | SUN = the Sun |
14 | | | 15 | |
15 | # we expect nothing when FOO is empty | | 16 | # we expect nothing when FOO is empty |
16 | foo: | | 17 | foo: |
| @@ -51,13 +52,19 @@ words: | | | @@ -51,13 +52,19 @@ words: |
51 | # of a SysV substitution modifier. This was probably a copy-and-paste | | 52 | # of a SysV substitution modifier. This was probably a copy-and-paste |
52 | # mistake since the SysV modifier code looked a lot like the code for the | | 53 | # mistake since the SysV modifier code looked a lot like the code for the |
53 | # :S and :C modifiers. The ampersand is not mentioned in the manual page. | | 54 | # :S and :C modifiers. The ampersand is not mentioned in the manual page. |
54 | ampersand: | | 55 | ampersand: |
55 | @echo ${:U${a.bcd.e:L:a.%=%}:Q} | | 56 | @echo ${:U${a.bcd.e:L:a.%=%}:Q} |
56 | @echo ${:U${a.bcd.e:L:a.%=&}:Q} | | 57 | @echo ${:U${a.bcd.e:L:a.%=&}:Q} |
57 | | | 58 | |
58 | # Before 2020-07-20, when a SysV modifier was parsed, a single dollar | | 59 | # Before 2020-07-20, when a SysV modifier was parsed, a single dollar |
59 | # before the '=' was interpreted as an anchor, which doesn't make sense | | 60 | # before the '=' was interpreted as an anchor, which doesn't make sense |
60 | # since the anchor was discarded immediately. | | 61 | # since the anchor was discarded immediately. |
61 | anchor-dollar: | | 62 | anchor-dollar: |
62 | @echo $@: ${:U${value:L:e$=x}:Q} | | 63 | @echo $@: ${:U${value:L:e$=x}:Q} |
63 | @echo $@: ${:U${value:L:e=x}:Q} | | 64 | @echo $@: ${:U${value:L:e=x}:Q} |
| | | 65 | |
| | | 66 | # Words that don't match are copied unmodified. |
| | | 67 | # The % placeholder can be anywhere in the string. |
| | | 68 | mismatch: |
| | | 69 | @echo $@: ${:Ufile.c file.h:%.c=%.cpp} |
| | | 70 | @echo $@: ${:Ufile.c other.c:file.%=renamed.%} |