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(1): clean up VarEvalFlags in the calls to ...
details: https://anonhg.NetBSD.org/src/rev/213e6a5aaed8
branches: trunk
changeset: 1016124:213e6a5aaed8
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 08 19:24:19 2020 +0000
description:
make(1): clean up VarEvalFlags in the calls to Var_Parse and Var_Subst
There are only 3 flags, and some combinations don't even make sense.
VARE_UNDEFERR only makes sense if combined with VARE_WANTRES. If the
latter is not set, the variable expressions are only parsed, without
asking whether they are defined or not. Therefore, VARE_UNDEFERR cannot
have any effect in that case.
VARE_KEEP_DOLLAR is actively ignored by ParseModifierPart. In cases
where VARE_WANTRES is not set, this means that VARE_NONE can be passed,
which is easier to grasp than any bitset operations. This also gets rid
of a few type casts from enum to unsigned int that were necessary to
pass WARNS=6.
diffstat:
usr.bin/make/cond.c | 7 ++++---
usr.bin/make/var.c | 26 ++++++++++++--------------
2 files changed, 16 insertions(+), 17 deletions(-)
diffs (112 lines):
diff -r 47aad14a268d -r 213e6a5aaed8 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sun Nov 08 18:27:14 2020 +0000
+++ b/usr.bin/make/cond.c Sun Nov 08 19:24:19 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.185 2020/11/07 20:39:56 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.186 2020/11/08 19:24:19 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.185 2020/11/07 20:39:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.186 2020/11/08 19:24:19 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -248,7 +248,8 @@
* though perhaps we should...
*/
void *nestedVal_freeIt;
- VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
+ VarEvalFlags eflags = doEval ? VARE_WANTRES | VARE_UNDEFERR
+ : VARE_NONE;
const char *nestedVal;
(void)Var_Parse(&p, VAR_CMDLINE, eflags, &nestedVal,
&nestedVal_freeIt);
diff -r 47aad14a268d -r 213e6a5aaed8 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Nov 08 18:27:14 2020 +0000
+++ b/usr.bin/make/var.c Sun Nov 08 19:24:19 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.680 2020/11/08 18:27:14 rillig Exp $ */
+/* $NetBSD: var.c,v 1.681 2020/11/08 19:24:19 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.680 2020/11/08 18:27:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.681 2020/11/08 19:24:19 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2068,13 +2068,12 @@
{
struct ModifyWord_LoopArgs args;
char prev_sep;
- VarEvalFlags eflags = st->eflags & ~(unsigned)VARE_WANTRES;
VarParseResult res;
args.ctx = st->ctxt;
(*pp)++; /* Skip the first '@' */
- res = ParseModifierPart(pp, '@', eflags, st,
+ res = ParseModifierPart(pp, '@', VARE_NONE, st,
&args.tvar, NULL, NULL, NULL);
if (res != VPR_OK)
return AMR_CLEANUP;
@@ -2086,12 +2085,12 @@
return AMR_CLEANUP;
}
- res = ParseModifierPart(pp, '@', eflags, st,
+ res = ParseModifierPart(pp, '@', VARE_NONE, st,
&args.str, NULL, NULL, NULL);
if (res != VPR_OK)
return AMR_CLEANUP;
- args.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
+ args.eflags = st->eflags & ~(unsigned)VARE_KEEP_DOLLAR;
prev_sep = st->sep;
st->sep = ' '; /* XXX: should be st->sep for consistency */
st->newVal = ModifyWords(st->val, ModifyWord_Loop, &args,
@@ -2110,11 +2109,10 @@
Buffer buf;
const char *p;
- VarEvalFlags eflags = st->eflags & ~(unsigned)VARE_WANTRES;
- if (st->eflags & VARE_WANTRES) {
+ VarEvalFlags eflags = VARE_NONE;
+ if (st->eflags & VARE_WANTRES)
if ((**pp == 'D') == !(st->exprFlags & VEF_UNDEF))
- eflags |= VARE_WANTRES;
- }
+ eflags = st->eflags;
Buf_Init(&buf);
p = *pp + 1;
@@ -2873,16 +2871,16 @@
VarParseResult res;
Boolean value = FALSE;
- VarEvalFlags then_eflags = st->eflags & ~(unsigned)VARE_WANTRES;
- VarEvalFlags else_eflags = st->eflags & ~(unsigned)VARE_WANTRES;
+ VarEvalFlags then_eflags = VARE_NONE;
+ VarEvalFlags else_eflags = VARE_NONE;
int cond_rc = COND_PARSE; /* anything other than COND_INVALID */
if (st->eflags & VARE_WANTRES) {
cond_rc = Cond_EvalCondition(st->v->name, &value);
if (cond_rc != COND_INVALID && value)
- then_eflags |= VARE_WANTRES;
+ then_eflags = st->eflags;
if (cond_rc != COND_INVALID && !value)
- else_eflags |= VARE_WANTRES;
+ else_eflags = st->eflags;
}
(*pp)++; /* skip past the '?' */
Home |
Main Index |
Thread Index |
Old Index