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): demonstrate parse error in ...



details:   https://anonhg.NetBSD.org/src/rev/399661bd1b60
branches:  trunk
changeset: 945423:399661bd1b60
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 30 08:13:17 2020 +0000

description:
make(1): demonstrate parse error in string interpolation in condition

diffstat:

 usr.bin/make/unit-tests/cond-cmp-string.exp |   1 +
 usr.bin/make/unit-tests/cond-cmp-string.mk  |  21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diffs (43 lines):

diff -r 99cbd6a9ab99 -r 399661bd1b60 usr.bin/make/unit-tests/cond-cmp-string.exp
--- a/usr.bin/make/unit-tests/cond-cmp-string.exp       Fri Oct 30 07:47:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.exp       Fri Oct 30 08:13:17 2020 +0000
@@ -3,6 +3,7 @@
 make: "cond-cmp-string.mk" line 42: warning: String comparison operator must be either == or !=
 make: "cond-cmp-string.mk" line 42: Malformed conditional (!("value" = "value"))
 make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" === "value"))
+make: "cond-cmp-string.mk" line 63: Malformed conditional (${:Uword} != "${:Uword} ")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 99cbd6a9ab99 -r 399661bd1b60 usr.bin/make/unit-tests/cond-cmp-string.mk
--- a/usr.bin/make/unit-tests/cond-cmp-string.mk        Fri Oct 30 07:47:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.mk        Fri Oct 30 08:13:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-string.mk,v 1.6 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-cmp-string.mk,v 1.7 2020/10/30 08:13:17 rillig Exp $
 #
 # Tests for string comparisons in .if conditions.
 
@@ -52,3 +52,22 @@
 .  error
 .endif
 
+# A variable expression can be enclosed in double quotes.
+.if ${:Uword} != "${:Uword}"
+.  error
+.endif
+
+# XXX: As of 2020-10-30, adding a space to the string results in a parse
+# error.  This is a bug and should have been caught much earlier.
+# I wonder since when it exists.
+.if ${:Uword} != "${:Uword} "
+.  error
+.else
+.  error
+.endif
+
+# Adding a space at the beginning of the quoted variable expression works
+# though.
+.if ${:U word } != " ${:Uword} "
+.  error
+.endif



Home | Main Index | Thread Index | Old Index