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: revert previous commit to CondParser_Or



details:   https://anonhg.NetBSD.org/src/rev/b0047d1f90fe
branches:  trunk
changeset: 1027185:b0047d1f90fe
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 09 23:02:46 2021 +0000

description:
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"))

diffstat:

 usr.bin/make/cond.c |  25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r 095d5bf8a6a3 -r b0047d1f90fe usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Thu Dec 09 22:25:58 2021 +0000
+++ b/usr.bin/make/cond.c       Thu Dec 09 23:02:46 2021 +0000
@@ -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 @@
 }
 
 /*
- * 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);



Home | Main Index | Thread Index | Old Index