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 tests/make: demonstrate unintended u...



details:   https://anonhg.NetBSD.org/src/rev/bb44e1cdb29c
branches:  trunk
changeset: 1023681:bb44e1cdb29c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Sep 21 21:59:56 2021 +0000

description:
tests/make: demonstrate unintended unquoted string in conditions

diffstat:

 usr.bin/make/unit-tests/cond-token-plain.exp |   7 +++++++
 usr.bin/make/unit-tests/cond-token-plain.mk  |  18 +++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)

diffs (49 lines):

diff -r 7d3dc278c1ba -r bb44e1cdb29c usr.bin/make/unit-tests/cond-token-plain.exp
--- a/usr.bin/make/unit-tests/cond-token-plain.exp      Tue Sep 21 21:43:32 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.exp      Tue Sep 21 21:59:56 2021 +0000
@@ -49,6 +49,13 @@
 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
diff -r 7d3dc278c1ba -r bb44e1cdb29c usr.bin/make/unit-tests/cond-token-plain.mk
--- a/usr.bin/make/unit-tests/cond-token-plain.mk       Tue Sep 21 21:43:32 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.mk       Tue Sep 21 21:59:56 2021 +0000
@@ -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 @@
 .  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".
 



Home | Main Index | Thread Index | Old Index