Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for out-of-bounds ...



details:   https://anonhg.NetBSD.org/src/rev/48debf7ba024
branches:  trunk
changeset: 977764:48debf7ba024
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 01 11:50:11 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/varmod-to-separator.exp |  10 ++++++----
 usr.bin/make/unit-tests/varmod-to-separator.mk  |  22 +++++++++++++++++++++-
 2 files changed, 27 insertions(+), 5 deletions(-)

diffs (60 lines):

diff -r e5e2423eab84 -r 48debf7ba024 usr.bin/make/unit-tests/varmod-to-separator.exp
--- a/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Nov 01 11:29:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Nov 01 11:50:11 2020 +0000
@@ -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
diff -r e5e2423eab84 -r 48debf7ba024 usr.bin/make/unit-tests/varmod-to-separator.mk
--- a/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Nov 01 11:29:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Nov 01 11:50:11 2020 +0000
@@ -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 @@
 .  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.



Home | Main Index | Thread Index | Old Index