Module Name:    src
Committed By:   rillig
Date:           Sun Nov  1 11:50:11 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: varmod-to-separator.exp
            varmod-to-separator.mk

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


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-to-separator.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-to-separator.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.2 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.2	Mon Aug 31 19:58:21 2020
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp	Sun Nov  1 11:50:11 2020
@@ -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

Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.3 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.3	Mon Aug 31 19:58:21 2020
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk	Sun Nov  1 11:50:11 2020
@@ -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.

Reply via email to