Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): fix parse error in string literal in c...



details:   https://anonhg.NetBSD.org/src/rev/9e228b2231dc
branches:  trunk
changeset: 977643:9e228b2231dc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 30 14:51:47 2020 +0000

description:
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.

diffstat:

 usr.bin/make/cond.c                         |   6 +++---
 usr.bin/make/unit-tests/cond-cmp-string.exp |   3 ---
 usr.bin/make/unit-tests/cond-cmp-string.mk  |  12 +++++-------
 3 files changed, 8 insertions(+), 13 deletions(-)

diffs (68 lines):

diff -r 615472a08ca5 -r 9e228b2231dc usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Oct 30 14:46:01 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Oct 30 14:51:47 2020 +0000
@@ -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 @@
     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 '\\':
diff -r 615472a08ca5 -r 9e228b2231dc usr.bin/make/unit-tests/cond-cmp-string.exp
--- a/usr.bin/make/unit-tests/cond-cmp-string.exp       Fri Oct 30 14:46:01 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.exp       Fri Oct 30 14:51:47 2020 +0000
@@ -3,9 +3,6 @@
 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
diff -r 615472a08ca5 -r 9e228b2231dc usr.bin/make/unit-tests/cond-cmp-string.mk
--- a/usr.bin/make/unit-tests/cond-cmp-string.mk        Fri Oct 30 14:46:01 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.mk        Fri Oct 30 14:51:47 2020 +0000
@@ -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
 



Home | Main Index | Thread Index | Old Index