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 (expand / 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
@@ -7,14 +7,16 @@ In the Sun @@ -7,14 +7,16 @@ In 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 (expand / 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,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
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:
@@ -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.
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.%}