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/223e07748ffb
branches:  trunk
changeset: 977635:223e07748ffb
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 5138400c3d12 -r 223e07748ffb 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 5138400c3d12 -r 223e07748ffb 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