Sun Jul 26 11:19:04 2020 UTC ()
make(1): add test for prefix mismatch in SysV substitution


(rillig)
diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/sysv.exp
diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/sysv.mk

cvs diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/Attic/sysv.exp (switch to unified diff)

--- src/usr.bin/make/unit-tests/Attic/sysv.exp 2020/07/20 16:32:14 1.8
+++ src/usr.bin/make/unit-tests/Attic/sysv.exp 2020/07/26 11:19:04 1.9
@@ -1,20 +1,22 @@ @@ -1,20 +1,22 @@
1FOOBAR = 1FOOBAR =
2FOOBAR = foobar fubar 2FOOBAR = foobar fubar
3fun 3fun
4fun 4fun
5fun 5fun
6In the Sun 6In the Sun
7acme 7acme
8aam.d 8aam.d
9sam.c 9sam.c
10a%.c 10a%.c
11asam.c.c 11asam.c.c
12asam.c 12asam.c
13a.c.c 13a.c.c
14 14
15ax:Q b c d eb 15ax:Q b c d eb
16bcd.e 16bcd.e
17& 17&
18anchor-dollar: value 18anchor-dollar: value
19anchor-dollar: valux 19anchor-dollar: valux
 20mismatch: file.cpp file.h
 21mismatch: renamed.c other.c
20exit status 0 22exit status 0

cvs diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/Attic/sysv.mk (switch to unified diff)

--- src/usr.bin/make/unit-tests/Attic/sysv.mk 2020/07/20 16:27:55 1.8
+++ src/usr.bin/make/unit-tests/Attic/sysv.mk 2020/07/26 11:19:04 1.9
@@ -1,63 +1,70 @@ @@ -1,63 +1,70 @@
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
3all: foo fun sam bla words ampersand anchor-dollar 3all: foo fun sam bla words ampersand anchor-dollar
 4all: mismatch
4 5
5FOO ?= 6FOO ?=
6FOOBAR = ${FOO:=bar} 7FOOBAR = ${FOO:=bar}
7 8
8_this := ${.PARSEDIR}/${.PARSEFILE} 9_this := ${.PARSEDIR}/${.PARSEFILE}
9 10
10B = /b 11B = /b
11S = / 12S = /
12FUN = ${B}${S}fun 13FUN = ${B}${S}fun
13SUN = the Sun 14SUN = the Sun
14 15
15# we expect nothing when FOO is empty 16# we expect nothing when FOO is empty
16foo: 17foo:
17 @echo FOOBAR = ${FOOBAR} 18 @echo FOOBAR = ${FOOBAR}
18.if empty(FOO) 19.if empty(FOO)
19 @FOO="foo fu" ${.MAKE} -f ${_this} foo 20 @FOO="foo fu" ${.MAKE} -f ${_this} foo
20.endif 21.endif
21 22
22fun: 23fun:
23 @echo ${FUN:T} 24 @echo ${FUN:T}
24 @echo ${FUN:${B}${S}fun=fun} 25 @echo ${FUN:${B}${S}fun=fun}
25 @echo ${FUN:${B}${S}%=%} 26 @echo ${FUN:${B}${S}%=%}
26 @echo ${In:L:%=% ${SUN}} 27 @echo ${In:L:%=% ${SUN}}
27 28
28 29
29SAM=sam.c 30SAM=sam.c
30 31
31sam: 32sam:
32 @echo ${SAM:s%.c=acme} 33 @echo ${SAM:s%.c=acme}
33 @echo ${SAM:s%.c=a%.d} 34 @echo ${SAM:s%.c=a%.d}
34 @echo ${SAM:s.c=a%.d} 35 @echo ${SAM:s.c=a%.d}
35 @echo ${SAM:sam.c=a%.c} 36 @echo ${SAM:sam.c=a%.c}
36 @echo ${SAM:%=a%.c} 37 @echo ${SAM:%=a%.c}
37 @echo ${SAM:%.c=a%.c} 38 @echo ${SAM:%.c=a%.c}
38 @echo ${SAM:sam%=a%.c} 39 @echo ${SAM:sam%=a%.c}
39 40
40BLA= 41BLA=
41 42
42bla: 43bla:
43 @echo $(BLA:%=foo/%x) 44 @echo $(BLA:%=foo/%x)
44 45
45# The :Q looks like a modifier but isn't. 46# The :Q looks like a modifier but isn't.
46# It is part of the replacement string. 47# It is part of the replacement string.
47words: 48words:
48 @echo a${a b c d e:L:%a=x:Q}b 49 @echo a${a b c d e:L:%a=x:Q}b
49 50
50# Before 2020-07-19, an ampersand could be used in the replacement part 51# Before 2020-07-19, an ampersand could be used in the replacement part
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.
54ampersand: 55ampersand:
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.
61anchor-dollar: 62anchor-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.
 68mismatch:
 69 @echo $@: ${:Ufile.c file.h:%.c=%.cpp}
 70 @echo $@: ${:Ufile.c other.c:file.%=renamed.%}