Sun Nov 1 11:50:11 2020 UTC ()
make(1): add test for out-of-bounds separator in variable modifier :ts


(rillig)
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-to-separator.exp
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-to-separator.mk

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-to-separator.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-to-separator.exp 2020/08/31 19:58:21 1.2
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp 2020/11/01 11:50:11 1.3
@@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
 1make: "varmod-to-separator.mk" line 106: warning: The separator \400 is accepted even though it is out of bounds.
 2make: "varmod-to-separator.mk" line 118: warning: The separator \x100 is accepted even though it is out of bounds.
1make: Bad modifier `:tx' for WORDS 3make: Bad modifier `:tx' for WORDS
2make: "varmod-to-separator.mk" line 104: Malformed conditional (${WORDS:tx} != "anything") 4make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:tx} != "anything")
3make: "varmod-to-separator.mk" line 108: Parsing continues here. 5make: "varmod-to-separator.mk" line 128: Parsing continues here.
4make: Bad modifier `:t\X' for WORDS 6make: Bad modifier `:t\X' for WORDS
5make: "varmod-to-separator.mk" line 112: Malformed conditional (${WORDS:t\X} != "anything") 7make: "varmod-to-separator.mk" line 132: Malformed conditional (${WORDS:t\X} != "anything")
6make: "varmod-to-separator.mk" line 115: Parsing continues here. 8make: "varmod-to-separator.mk" line 135: Parsing continues here.
7make: Fatal errors encountered -- cannot continue 9make: Fatal errors encountered -- cannot continue
8make: stopped in unit-tests 10make: stopped in unit-tests
9exit status 1 11exit status 1

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-to-separator.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-to-separator.mk 2020/08/31 19:58:21 1.3
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk 2020/11/01 11:50:11 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-to-separator.mk,v 1.3 2020/08/31 19:58:21 rillig Exp $ 1# $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $
2# 2#
3# Tests for the :ts variable modifier, which joins the words of the variable 3# Tests for the :ts variable modifier, which joins the words of the variable
4# using an arbitrary character as word separator. 4# using an arbitrary character as word separator.
5 5
6WORDS= one two three four five six 6WORDS= one two three four five six
7 7
8# The words are separated by a single space, just as usual. 8# The words are separated by a single space, just as usual.
9.if ${WORDS:ts } != "one two three four five six" 9.if ${WORDS:ts } != "one two three four five six"
10. warning Space as separator does not work. 10. warning Space as separator does not work.
11.endif 11.endif
12 12
13# The separator can be an arbitrary character, for example a comma. 13# The separator can be an arbitrary character, for example a comma.
14.if ${WORDS:ts,} != "one,two,three,four,five,six" 14.if ${WORDS:ts,} != "one,two,three,four,five,six"
@@ -85,31 +85,51 @@ WORDS= one two three four five six @@ -85,31 +85,51 @@ WORDS= one two three four five six
85. warning The separator \n does not produce a newline. 85. warning The separator \n does not produce a newline.
86.endif 86.endif
87 87
88# The separator can be \t, which is a tab. 88# The separator can be \t, which is a tab.
89.if ${WORDS:[1..3]:ts\t} != "one two three" 89.if ${WORDS:[1..3]:ts\t} != "one two three"
90. warning The separator \t does not produce a tab. 90. warning The separator \t does not produce a tab.
91.endif 91.endif
92 92
93# The separator can be given as octal number. 93# The separator can be given as octal number.
94.if ${WORDS:[1..3]:ts\012:tu} != "ONE${.newline}TWO${.newline}THREE" 94.if ${WORDS:[1..3]:ts\012:tu} != "ONE${.newline}TWO${.newline}THREE"
95. warning The separator \012 is not interpreted in octal ASCII. 95. warning The separator \012 is not interpreted in octal ASCII.
96.endif 96.endif
97 97
 98# The octal number can have as many digits as it wants.
 99.if ${WORDS:[1..2]:ts\000000000000000000000000012:tu} != "ONE${.newline}TWO"
 100. warning The separator \012 cannot have many leading zeroes.
 101.endif
 102
 103# The value of the separator character must not be outside the value space
 104# for an unsigned character though.
 105.if ${WORDS:[1..3]:ts\400:tu}
 106. warning The separator \400 is accepted even though it is out of bounds.
 107.else
 108. warning The separator \400 is accepted even though it is out of bounds.
 109.endif
 110
98# The separator can be given as hexadecimal number. 111# The separator can be given as hexadecimal number.
99.if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE" 112.if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE"
100. warning The separator \xa is not interpreted in hexadecimal ASCII. 113. warning The separator \xa is not interpreted in hexadecimal ASCII.
101.endif 114.endif
102 115
 116# The hexadecimal number must be in the range of an unsigned char.
 117.if ${WORDS:[1..3]:ts\x100:tu}
 118. warning The separator \x100 is accepted even though it is out of bounds.
 119.else
 120. warning The separator \x100 is accepted even though it is out of bounds.
 121.endif
 122
103# In the :t modifier, the :t must be followed by any of A, l, s, u. 123# In the :t modifier, the :t must be followed by any of A, l, s, u.
104.if ${WORDS:tx} != "anything" 124.if ${WORDS:tx} != "anything"
105. info This line is not reached because of the malformed condition. 125. info This line is not reached because of the malformed condition.
106. info If this line were reached, it would be visible in the -dcpv log. 126. info If this line were reached, it would be visible in the -dcpv log.
107.endif 127.endif
108.info Parsing continues here. 128.info Parsing continues here.
109 129
110# After the backslash, only n, t, an octal number, or x and a hexadecimal 130# After the backslash, only n, t, an octal number, or x and a hexadecimal
111# number are allowed. 131# number are allowed.
112.if ${WORDS:t\X} != "anything" 132.if ${WORDS:t\X} != "anything"
113. info This line is not reached. 133. info This line is not reached.
114.endif 134.endif
115.info Parsing continues here. 135.info Parsing continues here.