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): eliminate the global variable specType
details: https://anonhg.NetBSD.org/src/rev/f66840752b95
branches: trunk
changeset: 938783:f66840752b95
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Sep 14 16:59:41 2020 +0000
description:
make(1): eliminate the global variable specType
This variable didn't have an intended lifetype of "whole application",
therefore it is better implemented as a local variable that is passed
around the few functions that really need it. It's the same pattern as
in the ModifyWord functions in var.c, only this time without a typedef.
diffstat:
usr.bin/make/parse.c | 50 +++++++++++++++++++++++++++++---------------------
1 files changed, 29 insertions(+), 21 deletions(-)
diffs (137 lines):
diff -r 48eb8df9cc58 -r f66840752b95 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Mon Sep 14 16:40:06 2020 +0000
+++ b/usr.bin/make/parse.c Mon Sep 14 16:59:41 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.314 2020/09/14 16:40:06 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.315 2020/09/14 16:59:41 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.314 2020/09/14 16:40:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.315 2020/09/14 16:59:41 rillig Exp $");
/* types and constants */
@@ -223,14 +223,6 @@
#endif
/*
- * specType contains the SPECial TYPE of the current target. It is
- * Not if the target is unspecial. If it *is* special, however, the children
- * are linked as children of the parent but not vice versa. This variable is
- * set in ParseDoDependency
- */
-static ParseSpecial specType;
-
-/*
* Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
* seen, then set to each successive source on the line.
*/
@@ -751,6 +743,11 @@
return TRUE;
}
+struct ParseLinkSrcArgs {
+ GNode *cgn;
+ ParseSpecial specType;
+};
+
/*-
*---------------------------------------------------------------------
* ParseLinkSrc --
@@ -772,15 +769,16 @@
*---------------------------------------------------------------------
*/
static int
-ParseLinkSrc(void *pgnp, void *cgnp)
+ParseLinkSrc(void *pgnp, void *data)
{
+ const struct ParseLinkSrcArgs *args = data;
GNode *pgn = (GNode *)pgnp;
- GNode *cgn = (GNode *)cgnp;
+ GNode *cgn = args->cgn;
if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts))
pgn = LstNode_Datum(Lst_Last(pgn->cohorts));
Lst_Append(pgn->children, cgn);
- if (specType == Not)
+ if (args->specType == Not)
Lst_Append(cgn->parents, pgn);
pgn->unmade += 1;
if (DEBUG(PARSE)) {
@@ -895,7 +893,7 @@
*---------------------------------------------------------------------
*/
static void
-ParseDoSrc(int tOp, const char *src)
+ParseDoSrc(int tOp, const char *src, ParseSpecial specType)
{
GNode *gn = NULL;
static int wait_number = 0;
@@ -925,8 +923,10 @@
if (doing_depend)
ParseMark(gn);
gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
- if (targets != NULL)
- Lst_ForEach(targets, ParseLinkSrc, gn);
+ if (targets != NULL) {
+ struct ParseLinkSrcArgs args = { gn, specType };
+ Lst_ForEach(targets, ParseLinkSrc, &args);
+ }
return;
}
}
@@ -994,8 +994,10 @@
if (tOp) {
gn->type |= tOp;
} else {
- if (targets != NULL)
- Lst_ForEach(targets, ParseLinkSrc, gn);
+ if (targets != NULL) {
+ struct ParseLinkSrcArgs args = { gn, specType };
+ Lst_ForEach(targets, ParseLinkSrc, &args);
+ }
}
break;
}
@@ -1175,11 +1177,17 @@
* to the targets list */
char *lstart = line;
+ /*
+ * specType contains the SPECial TYPE of the current target. It is Not
+ * if the target is unspecial. If it *is* special, however, the children
+ * are linked as children of the parent but not vice versa.
+ */
+ ParseSpecial specType = Not;
+
if (DEBUG(PARSE))
fprintf(debug_file, "ParseDoDependency(%s)\n", line);
tOp = 0;
- specType = Not;
paths = NULL;
curTargs = Lst_Init();
@@ -1661,7 +1669,7 @@
while (!Lst_IsEmpty(sources)) {
GNode *gn = Lst_Dequeue(sources);
- ParseDoSrc(tOp, gn->name);
+ ParseDoSrc(tOp, gn->name, specType);
}
Lst_Free(sources);
cp = line;
@@ -1671,7 +1679,7 @@
cp += 1;
}
- ParseDoSrc(tOp, line);
+ ParseDoSrc(tOp, line, specType);
}
while (*cp && ch_isspace(*cp)) {
cp++;
Home |
Main Index |
Thread Index |
Old Index