make(1): add test for out-of-bounds separator in variable modifier :ts

This commit is contained in:
rillig 2020-11-01 11:50:11 +00:00
parent 64c690aaaf
commit 13ce664461
2 changed files with 27 additions and 5 deletions

View File

@ -1,9 +1,11 @@
make: "varmod-to-separator.mk" line 106: warning: The separator \400 is accepted even though it is out of bounds.
make: "varmod-to-separator.mk" line 118: warning: The separator \x100 is accepted even though it is out of bounds.
make: Bad modifier `:tx' for WORDS
make: "varmod-to-separator.mk" line 104: Malformed conditional (${WORDS:tx} != "anything")
make: "varmod-to-separator.mk" line 108: Parsing continues here.
make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:tx} != "anything")
make: "varmod-to-separator.mk" line 128: Parsing continues here.
make: Bad modifier `:t\X' for WORDS
make: "varmod-to-separator.mk" line 112: Malformed conditional (${WORDS:t\X} != "anything")
make: "varmod-to-separator.mk" line 115: Parsing continues here.
make: "varmod-to-separator.mk" line 132: Malformed conditional (${WORDS:t\X} != "anything")
make: "varmod-to-separator.mk" line 135: Parsing continues here.
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1

View File

@ -1,4 +1,4 @@
# $NetBSD: varmod-to-separator.mk,v 1.3 2020/08/31 19:58:21 rillig Exp $
# $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $
#
# Tests for the :ts variable modifier, which joins the words of the variable
# using an arbitrary character as word separator.
@ -95,11 +95,31 @@ WORDS= one two three four five six
. warning The separator \012 is not interpreted in octal ASCII.
.endif
# The octal number can have as many digits as it wants.
.if ${WORDS:[1..2]:ts\000000000000000000000000012:tu} != "ONE${.newline}TWO"
. warning The separator \012 cannot have many leading zeroes.
.endif
# The value of the separator character must not be outside the value space
# for an unsigned character though.
.if ${WORDS:[1..3]:ts\400:tu}
. warning The separator \400 is accepted even though it is out of bounds.
.else
. warning The separator \400 is accepted even though it is out of bounds.
.endif
# The separator can be given as hexadecimal number.
.if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE"
. warning The separator \xa is not interpreted in hexadecimal ASCII.
.endif
# The hexadecimal number must be in the range of an unsigned char.
.if ${WORDS:[1..3]:ts\x100:tu}
. warning The separator \x100 is accepted even though it is out of bounds.
.else
. warning The separator \x100 is accepted even though it is out of bounds.
.endif
# In the :t modifier, the :t must be followed by any of A, l, s, u.
.if ${WORDS:tx} != "anything"
. info This line is not reached because of the malformed condition.