Module Name:    src
Committed By:   rillig
Date:           Thu Dec  9 23:02:46 UTC 2021

Modified Files:
        src/usr.bin/make: cond.c

Log Message:
make: revert previous commit to CondParser_Or

Even though the unit tests for make cover a lot of cases, they don't
cover all cases.  After the previous commit, the NetBSD build failed
with:

bsd.sys.mk line 247: \
    Malformed conditional (!defined(NOPIE) && \
    (!defined(LDSTATIC) || ${LDSTATIC} != "-static"))


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/cond.c

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.283 src/usr.bin/make/cond.c:1.284
--- src/usr.bin/make/cond.c:1.283	Thu Dec  9 22:25:58 2021
+++ src/usr.bin/make/cond.c	Thu Dec  9 23:02:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.283 2021/12/09 22:25:58 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.284 2021/12/09 23:02:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,11 +95,12 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.283 2021/12/09 22:25:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.284 2021/12/09 23:02:46 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
- *	Or -> And ('||' And)*
+ *	Or -> And
+ *	Or -> Or '||' And
  *	And -> Term
  *	And -> And '&&' Term
  *	Term -> Function '(' Argument ')'
@@ -1001,22 +1002,26 @@ CondParser_And(CondParser *par, bool doE
 }
 
 /*
- * Or -> And ('||' And)*
+ * Or -> And
+ * Or -> Or '||' And
  */
 static CondResult
 CondParser_Or(CondParser *par, bool doEval)
 {
-	CondResult res, r;
+	CondResult res;
 	Token op;
 
-	if ((res = CondParser_And(par, doEval)) == CR_ERROR)
+	res = CondParser_And(par, doEval);
+	if (res == CR_ERROR)
 		return CR_ERROR;
 
-	while ((op = CondParser_Token(par, res == CR_FALSE)) == TOK_OR) {
-		if ((r = CondParser_And(par, res == CR_FALSE)) == CR_ERROR)
+	op = CondParser_Token(par, doEval);
+	if (op == TOK_OR) {
+		if (res == CR_FALSE)
+			return CondParser_Or(par, doEval);
+		if (CondParser_Or(par, false) == CR_ERROR)
 			return CR_ERROR;
-		if (r == CR_TRUE)
-			res = CR_TRUE;
+		return res;
 	}
 
 	CondParser_PushBack(par, op);

Reply via email to