Module Name:    src
Committed By:   rillig
Date:           Sun Nov  8 11:05:58 UTC 2020

Modified Files:
        src/usr.bin/make: make.c
        src/usr.bin/make/unit-tests: depsrc-optional.exp

Log Message:
make(1): inline MakeAddChild into ExamineLater

This gets rid of a few void pointers and unspecific variable names like
"l" for the list that should have rather been called "examine" all the
time.

Add quotes around placeholders in debug messages.  Especially for targets
like "all" the message had been syntactically misleading.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/make/make.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc-optional.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.199 src/usr.bin/make/make.c:1.200
--- src/usr.bin/make/make.c:1.199	Sun Nov  8 10:50:50 2020
+++ src/usr.bin/make/make.c	Sun Nov  8 11:05:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.199 2020/11/08 10:50:50 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.200 2020/11/08 11:05:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -108,7 +108,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.199 2020/11/08 10:50:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.200 2020/11/08 11:05:58 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -341,21 +341,6 @@ GNode_IsOODate(GNode *gn)
     return oodate;
 }
 
-/* Add the node to the list if it needs to be examined. */
-static int
-MakeAddChild(void *gnp, void *lp)
-{
-    GNode *gn = gnp;
-    GNodeList *l = lp;
-
-    if (!(gn->flags & REMAKE) && !(gn->type & (OP_USE|OP_USEBEFORE))) {
-	DEBUG2(MAKE, "MakeAddChild: need to examine %s%s\n",
-	       gn->name, gn->cohort_num);
-	Lst_Enqueue(l, gn);
-    }
-    return 0;
-}
-
 static void
 PretendAllChildrenAreMade(GNode *pgn)
 {
@@ -1101,6 +1086,25 @@ MakePrintStatusList(GNodeList *gnodes, i
 	    break;
 }
 
+static void
+ExamineLater(GNodeList *examine, GNodeList *toBeExamined)
+{
+    ListNode *ln;
+
+    for (ln = toBeExamined->first; ln != NULL; ln = ln->next) {
+	GNode *gn = ln->datum;
+
+	if (gn->flags & REMAKE)
+	    continue;
+	if (gn->type & (OP_USE | OP_USEBEFORE))
+	    continue;
+
+	DEBUG2(MAKE, "ExamineLater: need to examine \"%s%s\"\n",
+	       gn->name, gn->cohort_num);
+	Lst_Enqueue(examine, gn);
+    }
+}
+
 /* Expand .USE nodes and create a new targets list.
  *
  * Input:
@@ -1177,7 +1181,7 @@ Make_ExpandUse(GNodeList *targs)
 	}
 
 	if (gn->unmade != 0)
-	    Lst_ForEachUntil(gn->children, MakeAddChild, examine);
+	    ExamineLater(examine, gn->children);
     }
 
     Lst_Free(examine);

Index: src/usr.bin/make/unit-tests/depsrc-optional.exp
diff -u src/usr.bin/make/unit-tests/depsrc-optional.exp:1.4 src/usr.bin/make/unit-tests/depsrc-optional.exp:1.5
--- src/usr.bin/make/unit-tests/depsrc-optional.exp:1.4	Sun Nov  8 10:33:47 2020
+++ src/usr.bin/make/unit-tests/depsrc-optional.exp	Sun Nov  8 11:05:58 2020
@@ -1,8 +1,8 @@
 Make_ExpandUse: examine all
-MakeAddChild: need to examine important
+ExamineLater: need to examine "important"
 Make_ExpandUse: examine important
-MakeAddChild: need to examine optional
-MakeAddChild: need to examine optional-cohort
+ExamineLater: need to examine "optional"
+ExamineLater: need to examine "optional-cohort"
 Make_ExpandUse: examine optional
 Make_ExpandUse: examine optional-cohort
 Examining optional...non-existent...up-to-date.

Reply via email to