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 redundant parameter for evaluating...
details: https://anonhg.NetBSD.org/src/rev/22df258dea9f
branches: trunk
changeset: 1029271:22df258dea9f
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Dec 29 04:50:56 2021 +0000
description:
make: remove redundant parameter for evaluating conditions
No functional change.
diffstat:
usr.bin/make/cond.c | 25 ++++++++++++-------------
usr.bin/make/nonints.h | 4 ++--
usr.bin/make/var.c | 17 ++++++++---------
3 files changed, 22 insertions(+), 24 deletions(-)
diffs (171 lines):
diff -r 7e1019d7e74b -r 22df258dea9f usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Wed Dec 29 04:41:38 2021 +0000
+++ b/usr.bin/make/cond.c Wed Dec 29 04:50:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -982,7 +982,7 @@
}
static CondEvalResult
-CondParser_Eval(CondParser *par, bool *out_value)
+CondParser_Eval(CondParser *par)
{
CondResult res;
@@ -995,8 +995,7 @@
if (CondParser_Token(par, false) != TOK_EOF)
return COND_INVALID;
- *out_value = res == CR_TRUE;
- return COND_PARSE;
+ return res;
}
/*
@@ -1011,7 +1010,7 @@
* *out_value is set to the boolean value of the condition
*/
static CondEvalResult
-CondEvalExpression(const char *cond, bool *out_value, bool plain,
+CondEvalExpression(const char *cond, bool plain,
bool (*evalBare)(const char *), bool negate,
bool eprint, bool leftUnquotedOK)
{
@@ -1028,7 +1027,7 @@
par.curr = TOK_NONE;
par.printedError = false;
- rval = CondParser_Eval(&par, out_value);
+ rval = CondParser_Eval(&par);
if (rval == COND_INVALID && eprint && !par.printedError)
Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
@@ -1041,9 +1040,9 @@
* ${"${VAR}" == value:?yes:no}.
*/
CondEvalResult
-Cond_EvalCondition(const char *cond, bool *out_value)
+Cond_EvalCondition(const char *cond)
{
- return CondEvalExpression(cond, out_value, true,
+ return CondEvalExpression(cond, true,
FuncDefined, false, false, true);
}
@@ -1150,7 +1149,7 @@
bool (*evalBare)(const char *);
bool negate;
bool isElif;
- bool value;
+ CondResult res;
IfState state;
const char *p = line;
@@ -1275,8 +1274,8 @@
}
/* And evaluate the conditional expression */
- if (CondEvalExpression(p, &value, plain, evalBare, negate,
- true, false) == COND_INVALID) {
+ res = CondEvalExpression(p, plain, evalBare, negate, true, false);
+ if (res == COND_INVALID) {
/*
* Syntax error in conditional, error message already output.
*/
@@ -1286,7 +1285,7 @@
return COND_SKIP;
}
- if (!value) {
+ if (res == COND_SKIP) {
cond_states[cond_depth] = IFS_INITIAL;
return COND_SKIP;
}
diff -r 7e1019d7e74b -r 22df258dea9f usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Wed Dec 29 04:41:38 2021 +0000
+++ b/usr.bin/make/nonints.h Wed Dec 29 04:50:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.223 2021/12/28 01:11:36 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.224 2021/12/29 04:50:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -91,7 +91,7 @@
void Compat_Make(GNode *, GNode *);
/* cond.c */
-CondEvalResult Cond_EvalCondition(const char *, bool *) MAKE_ATTR_USE;
+CondEvalResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
CondEvalResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
void Cond_restore_depth(unsigned int);
unsigned int Cond_save_depth(void) MAKE_ATTR_USE;
diff -r 7e1019d7e74b -r 22df258dea9f usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Dec 29 04:41:38 2021 +0000
+++ b/usr.bin/make/var.c Wed Dec 29 04:50:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.989 2021/12/15 13:03:33 rillig Exp $ */
+/* $NetBSD: var.c,v 1.990 2021/12/29 04:50:56 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.989 2021/12/15 13:03:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.990 2021/12/29 04:50:56 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -3451,16 +3451,15 @@
LazyBuf thenBuf;
LazyBuf elseBuf;
- bool value = false;
VarEvalMode then_emode = VARE_PARSE_ONLY;
VarEvalMode else_emode = VARE_PARSE_ONLY;
- CondEvalResult cond_rc = COND_PARSE; /* just not COND_INVALID */
+ CondEvalResult cond_rc = CR_TRUE; /* just not CR_ERROR */
if (Expr_ShouldEval(expr)) {
- cond_rc = Cond_EvalCondition(expr->name, &value);
- if (cond_rc != COND_INVALID && value)
+ cond_rc = Cond_EvalCondition(expr->name);
+ if (cond_rc == CR_TRUE)
then_emode = expr->emode;
- if (cond_rc != COND_INVALID && !value)
+ if (cond_rc == CR_FALSE)
else_emode = expr->emode;
}
@@ -3477,7 +3476,7 @@
(*pp)--; /* Go back to the ch->endc. */
- if (cond_rc == COND_INVALID) {
+ if (cond_rc == CR_ERROR) {
Substring thenExpr = LazyBuf_Get(&thenBuf);
Substring elseExpr = LazyBuf_Get(&elseBuf);
Error("Bad conditional expression '%s' in '%s?%.*s:%.*s'",
@@ -3492,7 +3491,7 @@
if (!Expr_ShouldEval(expr)) {
LazyBuf_Done(&thenBuf);
LazyBuf_Done(&elseBuf);
- } else if (value) {
+ } else if (cond_rc == CR_TRUE) {
Expr_SetValue(expr, LazyBuf_DoneGet(&thenBuf));
LazyBuf_Done(&elseBuf);
} else {
Home |
Main Index |
Thread Index |
Old Index