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 code related to VarEvalFlags
details: https://anonhg.NetBSD.org/src/rev/c2c8450bf65f
branches: trunk
changeset: 1016125:c2c8450bf65f
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 08 19:53:11 2020 +0000
description:
make(1): clean up code related to VarEvalFlags
Mention VARE_WANTRES before VARE_UNDEFERR since the latter depends on
the former.
In ApplyModifier_Assign, VARE_KEEP_DOLLAR doesn't have to be removed
from eflags since ParseModifierPart does this already.
In EvalUndefined, testing for VARE_WANTRES is redundant if VARE_UNDEFERR
is already set.
diffstat:
usr.bin/make/arch.c | 12 ++++++------
usr.bin/make/cond.c | 6 +++---
usr.bin/make/parse.c | 12 ++++++------
usr.bin/make/suff.c | 8 ++++----
usr.bin/make/var.c | 11 +++--------
5 files changed, 22 insertions(+), 27 deletions(-)
diffs (203 lines):
diff -r 213e6a5aaed8 -r c2c8450bf65f usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sun Nov 08 19:24:19 2020 +0000
+++ b/usr.bin/make/arch.c Sun Nov 08 19:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.174 2020/11/08 09:15:19 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.175 2020/11/08 19:53:11 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.174 2020/11/08 09:15:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.175 2020/11/08 19:53:11 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -210,7 +210,7 @@
Boolean isError;
/* XXX: is expanded twice: once here and once below */
- (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES,
+ (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR,
&result, &result_freeIt);
/* TODO: handle errors */
isError = result == var_Error;
@@ -226,7 +226,7 @@
*cp++ = '\0';
if (expandLibName) {
- (void)Var_Subst(libName, ctxt, VARE_UNDEFERR|VARE_WANTRES, &libName);
+ (void)Var_Subst(libName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &libName);
/* TODO: handle errors */
libName_freeIt = libName;
}
@@ -254,7 +254,7 @@
Boolean isError;
const char *nested_p = cp;
- (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES,
+ (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR,
&result, &freeIt);
/* TODO: handle errors */
isError = result == var_Error;
@@ -307,7 +307,7 @@
char *sacrifice;
char *oldMemName = memName;
- (void)Var_Subst(memName, ctxt, VARE_UNDEFERR|VARE_WANTRES,
+ (void)Var_Subst(memName, ctxt, VARE_WANTRES | VARE_UNDEFERR,
&memName);
/* TODO: handle errors */
diff -r 213e6a5aaed8 -r c2c8450bf65f usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sun Nov 08 19:24:19 2020 +0000
+++ b/usr.bin/make/cond.c Sun Nov 08 19:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.186 2020/11/08 19:24:19 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.187 2020/11/08 19:53:11 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.186 2020/11/08 19:24:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.187 2020/11/08 19:53:11 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -443,7 +443,7 @@
continue;
case '$':
/* if we are in quotes, an undefined variable is ok */
- eflags = doEval && !qt ? VARE_UNDEFERR | VARE_WANTRES :
+ eflags = doEval && !qt ? VARE_WANTRES | VARE_UNDEFERR :
doEval ? VARE_WANTRES :
VARE_NONE;
diff -r 213e6a5aaed8 -r c2c8450bf65f usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Nov 08 19:24:19 2020 +0000
+++ b/usr.bin/make/parse.c Sun Nov 08 19:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.435 2020/11/08 16:58:33 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.436 2020/11/08 19:53:11 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.435 2020/11/08 16:58:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.436 2020/11/08 19:53:11 rillig Exp $");
/* types and constants */
@@ -1063,8 +1063,8 @@
const char *nested_val;
void *freeIt;
- (void)Var_Parse(&nested_p, VAR_CMDLINE, VARE_UNDEFERR|VARE_WANTRES,
- &nested_val, &freeIt);
+ (void)Var_Parse(&nested_p, VAR_CMDLINE,
+ VARE_WANTRES | VARE_UNDEFERR, &nested_val, &freeIt);
/* TODO: handle errors */
free(freeIt);
cp += nested_p - cp;
@@ -1944,7 +1944,7 @@
cmd = uvalue;
if (strchr(cmd, '$') != NULL) {
char *ecmd;
- (void)Var_Subst(cmd, VAR_CMDLINE, VARE_UNDEFERR | VARE_WANTRES, &ecmd);
+ (void)Var_Subst(cmd, VAR_CMDLINE, VARE_WANTRES | VARE_UNDEFERR, &ecmd);
/* TODO: handle errors */
cmd = cmd_freeIt = ecmd;
}
@@ -3032,7 +3032,7 @@
* Var_Parse does not print any parse errors in such a case.
* It simply returns the special empty string var_Error,
* which cannot be detected in the result of Var_Subst. */
- eflags = DEBUG(LINT) ? VARE_WANTRES : VARE_UNDEFERR | VARE_WANTRES;
+ eflags = DEBUG(LINT) ? VARE_WANTRES : VARE_WANTRES | VARE_UNDEFERR;
(void)Var_Subst(line, VAR_CMDLINE, eflags, &expanded_line);
/* TODO: handle errors */
diff -r 213e6a5aaed8 -r c2c8450bf65f usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sun Nov 08 19:24:19 2020 +0000
+++ b/usr.bin/make/suff.c Sun Nov 08 19:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.234 2020/11/08 00:28:52 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.235 2020/11/08 19:53:11 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.234 2020/11/08 00:28:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.235 2020/11/08 19:53:11 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -1132,7 +1132,7 @@
}
SUFF_DEBUG1("Expanding \"%s\"...", cgn->name);
- (void)Var_Subst(cgn->name, pgn, VARE_UNDEFERR|VARE_WANTRES, &cp);
+ (void)Var_Subst(cgn->name, pgn, VARE_WANTRES | VARE_UNDEFERR, &cp);
/* TODO: handle errors */
{
@@ -1183,7 +1183,7 @@
/* XXX: Why VARE_WANTRES when the result is not used? */
(void)Var_Parse(&nested_p, pgn,
- VARE_UNDEFERR|VARE_WANTRES,
+ VARE_WANTRES | VARE_UNDEFERR,
&junk, &freeIt);
/* TODO: handle errors */
if (junk == var_Error) {
diff -r 213e6a5aaed8 -r c2c8450bf65f usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Nov 08 19:24:19 2020 +0000
+++ b/usr.bin/make/var.c Sun Nov 08 19:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.681 2020/11/08 19:24:19 rillig Exp $ */
+/* $NetBSD: var.c,v 1.682 2020/11/08 19:53:11 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.681 2020/11/08 19:24:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.682 2020/11/08 19:53:11 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2977,9 +2977,6 @@
}
delim = st->startc == '(' ? ')' : '}';
- /* TODO: Add test for using the ::= modifier in a := assignment line.
- * Probably st->eflags should be passed down without VARE_KEEP_DOLLAR
- * here. */
res = ParseModifierPart(pp, delim, st->eflags, st, &val, NULL, NULL, NULL);
if (res != VPR_OK)
return AMR_CLEANUP;
@@ -3657,9 +3654,7 @@
return VPR_OK;
}
- if ((eflags & VARE_UNDEFERR) && (eflags & VARE_WANTRES) &&
- DEBUG(LINT))
- {
+ if ((eflags & VARE_UNDEFERR) && DEBUG(LINT)) {
Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined", varname);
free(varname);
*out_val = var_Error;
Home |
Main Index |
Thread Index |
Old Index