Module Name:    src
Committed By:   rillig
Date:           Mon Apr 19 22:22:27 UTC 2021

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: cond-late.exp cond1.exp varmod-ifelse.exp
            varmod-ifelse.mk

Log Message:
make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected.  But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case.  I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.


To generate a diff of this commit:
cvs rdiff -u -r1.929 -r1.930 src/usr.bin/make/var.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-late.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond1.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-ifelse.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/var.c
diff -u src/usr.bin/make/var.c:1.929 src/usr.bin/make/var.c:1.930
--- src/usr.bin/make/var.c:1.929	Wed Apr 14 16:59:34 2021
+++ src/usr.bin/make/var.c	Mon Apr 19 22:22:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.929 2021/04/14 16:59:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.930 2021/04/19 22:22:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.929 2021/04/14 16:59:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.930 2021/04/19 22:22:27 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3384,7 +3384,7 @@ ApplyModifier_IfElse(const char **pp, Mo
 	(*pp)--;		/* Go back to the ch->endc. */
 
 	if (cond_rc == COND_INVALID) {
-		Error("Bad conditional expression `%s' in %s?%s:%s",
+		Error("Bad conditional expression '%s' in '%s?%s:%s'",
 		    expr->name, expr->name, then_expr.str, else_expr.str);
 		return AMR_CLEANUP;
 	}

Index: src/usr.bin/make/unit-tests/cond-late.exp
diff -u src/usr.bin/make/unit-tests/cond-late.exp:1.3 src/usr.bin/make/unit-tests/cond-late.exp:1.4
--- src/usr.bin/make/unit-tests/cond-late.exp:1.3	Sat Jul 25 20:37:46 2020
+++ src/usr.bin/make/unit-tests/cond-late.exp	Mon Apr 19 22:22:27 2021
@@ -1,4 +1,4 @@
-make: Bad conditional expression ` != "no"' in  != "no"?:
+make: Bad conditional expression ' != "no"' in ' != "no"?:'
 yes
 no
 exit status 0

Index: src/usr.bin/make/unit-tests/cond1.exp
diff -u src/usr.bin/make/unit-tests/cond1.exp:1.4 src/usr.bin/make/unit-tests/cond1.exp:1.5
--- src/usr.bin/make/unit-tests/cond1.exp:1.4	Thu Jan 21 23:32:28 2021
+++ src/usr.bin/make/unit-tests/cond1.exp	Mon Apr 19 22:22:27 2021
@@ -17,7 +17,7 @@ Passed:
 5 is  prime
 
 make: String comparison operator must be either == or !=
-make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
+make: Bad conditional expression '"0" > 0' in '"0" > 0?OK:No'
 
 OK
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.6 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.6	Mon Apr 19 22:05:29 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Mon Apr 19 22:22:27 2021
@@ -1,21 +1,21 @@
-make: Bad conditional expression `variable expression == "literal"' in variable expression == "literal"?bad:bad
+make: Bad conditional expression 'variable expression == "literal"' in 'variable expression == "literal"?bad:bad'
 make: "varmod-ifelse.mk" line 27: Malformed conditional (${${:Uvariable expression} == "literal":?bad:bad})
-make: Bad conditional expression ` == ""' in  == ""?bad-assign:bad-assign
-make: Bad conditional expression ` == ""' in  == ""?bad-cond:bad-cond
+make: Bad conditional expression ' == ""' in ' == ""?bad-assign:bad-assign'
+make: Bad conditional expression ' == ""' in ' == ""?bad-cond:bad-cond'
 make: "varmod-ifelse.mk" line 44: Malformed conditional (${${UNDEF} == "":?bad-cond:bad-cond})
-make: Bad conditional expression `1 == == 2' in 1 == == 2?yes:no
+make: Bad conditional expression '1 == == 2' in '1 == == 2?yes:no'
 make: "varmod-ifelse.mk" line 66: Malformed conditional (${1 == == 2:?yes:no} != "")
 CondParser_Eval: "${1 == == 2:?yes:no}" != ""
 CondParser_Eval: 1 == == 2
 lhs = 1.000000, rhs = 0.000000, op = ==
-make: Bad conditional expression `1 == == 2' in 1 == == 2?yes:no
+make: Bad conditional expression '1 == == 2' in '1 == == 2?yes:no'
 lhs = "", rhs = "", op = !=
 make: "varmod-ifelse.mk" line 92: warning: Oops, the parse error should have been propagated.
 CondParser_Eval: ${ ${:U\$}{VAR} == value :?ok:bad} != "ok"
 CondParser_Eval: ${VAR} == value 
 lhs = "value", rhs = "value", op = ==
 lhs = "ok", rhs = "ok", op = !=
-make: Bad conditional expression `string == "literal" && no >= 10' in string == "literal" && no >= 10?yes:no
+make: Bad conditional expression 'string == "literal" && no >= 10' in 'string == "literal" && no >= 10?yes:no'
 make: "varmod-ifelse.mk" line 127: .
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.12 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.13
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.12	Mon Apr 19 22:05:29 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Mon Apr 19 22:22:27 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.12 2021/04/19 22:05:29 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.13 2021/04/19 22:22:27 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -125,4 +125,3 @@ VAR=	value
 STRING=		string
 NUMBER=		no
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
-# XXX: In the diagnostic, the second placeholder is missing the quotes.

Reply via email to