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: remove recursion from CondParser_And
details: https://anonhg.NetBSD.org/src/rev/e1942e031780
branches: trunk
changeset: 1027551:e1942e031780
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Dec 10 23:33:05 2021 +0000
description:
make: remove recursion from CondParser_And
No functional change intended. Before cond.c 1.286 from today, there
would have been the functional change that in malformed conditions, the
extra expression would not be evaluated. Now that CondParser_Token is
always called with doEval == false, there is no change in behavior to be
expected.
diffstat:
usr.bin/make/cond.c | 31 +++++++++++++------------------
1 files changed, 13 insertions(+), 18 deletions(-)
diffs (63 lines):
diff -r df6087284d18 -r e1942e031780 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Fri Dec 10 23:19:59 2021 +0000
+++ b/usr.bin/make/cond.c Fri Dec 10 23:33:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.287 2021/12/10 23:19:59 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.288 2021/12/10 23:33:05 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,13 +95,12 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.287 2021/12/10 23:19:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.288 2021/12/10 23:33:05 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
* Or -> And ('||' And)*
- * And -> Term
- * And -> And '&&' Term
+ * And -> Term ('&&' Term)*
* Term -> Function '(' Argument ')'
* Term -> Leaf Operator Leaf
* Term -> Leaf
@@ -974,27 +973,23 @@
}
/*
- * And -> Term
- * And -> And '&&' Term
+ * And -> Term ('&&' Term)*
*/
static CondResult
CondParser_And(CondParser *par, bool doEval)
{
- CondResult res;
+ CondResult res, rhs;
Token op;
- res = CondParser_Term(par, doEval);
- if (res == CR_ERROR)
- return CR_ERROR;
-
- op = CondParser_Token(par, false);
- if (op == TOK_AND) {
- if (res == CR_TRUE)
- return CondParser_And(par, doEval);
- if (CondParser_And(par, false) == CR_ERROR)
+ res = CR_TRUE;
+ do {
+ if ((rhs = CondParser_Term(par, doEval)) == CR_ERROR)
return CR_ERROR;
- return res;
- }
+ if (rhs == CR_FALSE) {
+ res = CR_FALSE;
+ doEval = false;
+ }
+ } while ((op = CondParser_Token(par, false)) == TOK_AND);
CondParser_PushBack(par, op);
return res;
Home |
Main Index |
Thread Index |
Old Index