Module Name: src
Committed By: rillig
Date: Fri Oct 30 14:51:47 UTC 2020
Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-cmp-string.exp cond-cmp-string.mk
Log Message:
make(1): fix parse error in string literal in conditional
The string literal "${VAR} " had produced a "Malformed conditional", at
least since 2003. (That's the oldest make I have available for testing.)
Strange that nobody else noticed that in the last 17 years.
To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/make/cond.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-cmp-string.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-cmp-string.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/cond.c
diff -u src/usr.bin/make/cond.c:1.170 src/usr.bin/make/cond.c:1.171
--- src/usr.bin/make/cond.c:1.170 Fri Oct 30 07:19:30 2020
+++ src/usr.bin/make/cond.c Fri Oct 30 14:51:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.170 2020/10/30 07:19:30 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.171 2020/10/30 14:51:47 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.170 2020/10/30 07:19:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.171 2020/10/30 14:51:47 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -406,9 +406,9 @@ CondParser_String(CondParser *par, Boole
str = NULL;
*freeIt = NULL;
*quoted = qt = par->p[0] == '"' ? 1 : 0;
+ start = par->p;
if (qt)
par->p++;
- start = par->p;
while (par->p[0] && str == NULL) {
switch (par->p[0]) {
case '\\':
Index: src/usr.bin/make/unit-tests/cond-cmp-string.exp
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.6 src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.7
--- src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.6 Fri Oct 30 14:46:01 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.exp Fri Oct 30 14:51:47 2020
@@ -3,9 +3,6 @@ make: "cond-cmp-string.mk" line 37: Malf
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: "cond-cmp-string.mk" line 77: Malformed conditional (${:Uword!} != "${:Uword}!")
-make: "cond-cmp-string.mk" line 80: Malformed conditional (${:Uword<} != "${:Uword}<")
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/cond-cmp-string.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.9 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.10
--- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.9 Fri Oct 30 14:46:01 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.mk Fri Oct 30 14:51:47 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-string.mk,v 1.9 2020/10/30 14:46:01 rillig Exp $
+# $NetBSD: cond-cmp-string.mk,v 1.10 2020/10/30 14:51:47 rillig Exp $
#
# Tests for string comparisons in .if conditions.
@@ -57,12 +57,10 @@
. error
.endif
-# XXX: As of 2020-10-30, adding literal characters 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
+# Between 2003-01-01 (maybe even earlier) and 2020-10-30, adding one of the
+# characters " \t!=><" directly after a variable expression resulted in a
+# "Malformed conditional", even though the string was well-formed.
+.if ${:Uword } != "${:Uword} "
. error
.endif