Module Name: src
Committed By: rillig
Date: Tue Sep 21 21:59:56 UTC 2021
Modified Files:
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk
Log Message:
tests/make: demonstrate unintended unquoted string in conditions
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-plain.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/cond-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.10 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.11
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.10 Mon Jun 21 21:10:01 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp Tue Sep 21 21:59:56 2021
@@ -49,6 +49,13 @@ make: "cond-token-plain.mk" line 168: No
CondParser_Eval: "unquoted\"quoted" != unquoted"quoted
lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = !=
CondParser_Eval: $$$$$$$$ != ""
+CondParser_Eval: left == right
+make: "cond-token-plain.mk" line 191: Malformed conditional (left == right)
+CondParser_Eval: ${0:?:} || left == right
+CondParser_Eval: 0
+lhs = "left", rhs = "right", op = ==
+CondParser_Eval: left == right || ${0:?:}
+make: "cond-token-plain.mk" line 201: Malformed conditional (left == right || ${0:?:})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.11
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10 Thu Jan 21 14:08:09 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk Tue Sep 21 21:59:56 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.10 2021/01/21 14:08:09 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.11 2021/09/21 21:59:56 rillig Exp $
#
# Tests for plain tokens (that is, string literals without quotes)
# in .if conditions.
@@ -185,6 +185,22 @@ ${:U\\\\}= backslash
. error
.endif
+# In a condition in an .if directive, the left-hand side must not be an
+# unquoted string literal.
+# expect+1: Malformed conditional (left == right)
+.if left == right
+.endif
+# Before cond.c 1.276 from 2021-09-21, a variable expression containing the
+# modifier ':?:' allowed unquoted string literals for the rest of the
+# condition. This was an unintended implementation mistake.
+.if ${0:?:} || left == right
+.endif
+# This affected only the comparisons after the expression, so the following
+# was still a syntax error.
+# expect+1: Malformed conditional (left == right || ${0:?:})
+.if left == right || ${0:?:}
+.endif
+
# See cond-token-string.mk for similar tests where the condition is enclosed
# in "quotes".