Module Name:    src
Committed By:   rillig
Date:           Thu Sep 24 07:11:29 UTC 2020

Modified Files:
        src/usr.bin/make: compat.c dir.c job.c lst.c lst.h main.c make.c meta.c
            parse.c suff.c targ.c

Log Message:
make(1): rename Lst_ForEach to Lst_ForEachUntil

Since the callback function returns a terminating condition, this is not
really a foreach loop.

Many of the calls to Lst_ForEachUntil don't make use of the terminating
condition, and several don't modify the list structurally, which means
they don't need this complicated implementation.

In a follow-up commit, Lst_ForEach will be added back with a much
simpler implementation that iterates over the list naively, without a
terminating condition and without taking the iteration state from
Lst_Open/Lst_Next/Lst_Close into account.  The migration to this simpler
implementation will be done step by step since each callback function
needs to be examined closely.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/compat.c
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/make/dir.c
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/job.c
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/make/lst.c
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/lst.h
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/main.c
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/make/make.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/meta.c
cvs rdiff -u -r1.323 -r1.324 src/usr.bin/make/parse.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/make/suff.c
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/make/targ.c

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/compat.c
diff -u src/usr.bin/make/compat.c:1.149 src/usr.bin/make/compat.c:1.150
--- src/usr.bin/make/compat.c:1.149	Wed Sep 23 03:06:38 2020
+++ src/usr.bin/make/compat.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.149 2020/09/23 03:06:38 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.150 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -99,7 +99,7 @@
 #include    "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.149 2020/09/23 03:06:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.150 2020/09/24 07:11:29 rillig Exp $");
 
 static GNode	    *curTarg = NULL;
 static void CompatInterrupt(int);
@@ -512,7 +512,7 @@ Compat_Make(GNode *gn, GNode *pgn)
 	gn->made = BEINGMADE;
 	if ((gn->type & OP_MADE) == 0)
 	    Suff_FindDeps(gn);
-	Lst_ForEach(gn->children, CompatMake, gn);
+	Lst_ForEachUntil(gn->children, CompatMake, gn);
 	if ((gn->flags & REMAKE) == 0) {
 	    gn->made = ABORTED;
 	    pgn->flags &= ~(unsigned)REMAKE;
@@ -582,7 +582,7 @@ Compat_Make(GNode *gn, GNode *pgn)
 		    meta_job_start(NULL, gn);
 		}
 #endif
-		Lst_ForEach(gn->commands, CompatRunCommand, gn);
+		Lst_ForEachUntil(gn->commands, CompatRunCommand, gn);
 		curTarg = NULL;
 	    } else {
 		Job_Touch(gn, (gn->type & OP_SILENT) != 0);
@@ -652,7 +652,7 @@ Compat_Make(GNode *gn, GNode *pgn)
     }
 
 cohorts:
-    Lst_ForEach(gn->cohorts, CompatMake, pgn);
+    Lst_ForEachUntil(gn->cohorts, CompatMake, pgn);
     return 0;
 }
 

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.144 src/usr.bin/make/dir.c:1.145
--- src/usr.bin/make/dir.c:1.144	Tue Sep 22 04:05:41 2020
+++ src/usr.bin/make/dir.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.144 2020/09/22 04:05:41 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.145 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.144 2020/09/22 04:05:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.145 2020/09/24 07:11:29 rillig Exp $");
 
 #define DIR_DEBUG0(fmt) \
     if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -759,7 +759,7 @@ DirExpandInt(const char *word, SearchPat
 }
 
 /* Print a word in the list of expansions.
- * Callback for Dir_Expand when DEBUG(DIR), via Lst_ForEach. */
+ * Callback for Dir_Expand when DEBUG(DIR), via Lst_ForEachUntil. */
 static int
 DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED)
 {
@@ -879,7 +879,7 @@ Dir_Expand(const char *word, SearchPath 
 	}
     }
     if (DEBUG(DIR)) {
-	Lst_ForEach(expansions, DirPrintWord, NULL);
+	Lst_ForEachUntil(expansions, DirPrintWord, NULL);
 	fprintf(debug_file, "\n");
     }
 }
@@ -1489,7 +1489,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
  * Dir_AddDir --
  *	Add the given name to the end of the given path. The order of
  *	the arguments is backwards so ParseDoDependency can do a
- *	Lst_ForEach of its list of paths...
+ *	Lst_ForEachUntil of its list of paths...
  *
  * Input:
  *	path		the path to which the directory should be
@@ -1763,5 +1763,5 @@ DirPrintDir(void *p, void *dummy MAKE_AT
 void
 Dir_PrintPath(SearchPath *path)
 {
-    Lst_ForEach(path, DirPrintDir, NULL);
+    Lst_ForEachUntil(path, DirPrintDir, NULL);
 }

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.236 src/usr.bin/make/job.c:1.237
--- src/usr.bin/make/job.c:1.236	Wed Sep 23 07:30:12 2020
+++ src/usr.bin/make/job.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.236 2020/09/23 07:30:12 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.237 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -140,7 +140,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.236 2020/09/23 07:30:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.237 2020/09/24 07:11:29 rillig Exp $");
 
 # define STATIC static
 
@@ -648,7 +648,7 @@ JobFindPid(int pid, int status, Boolean 
  *	made and return non-zero to signal that the end of the commands
  *	was reached. These commands are later attached to the postCommands
  *	node and executed by Job_End when all things are done.
- *	This function is called from JobStart via Lst_ForEach.
+ *	This function is called from JobStart via Lst_ForEachUntil.
  *
  * Input:
  *	cmdp		command string to print
@@ -1605,7 +1605,7 @@ JobStart(GNode *gn, int flags)
 	 * We can do all the commands at once. hooray for sanity
 	 */
 	numCommands = 0;
-	Lst_ForEach(gn->commands, JobPrintCommand, job);
+	Lst_ForEachUntil(gn->commands, JobPrintCommand, job);
 
 	/*
 	 * If we didn't print out any commands to the shell script,
@@ -1632,7 +1632,7 @@ JobStart(GNode *gn, int flags)
 	 * doesn't do any harm in this case and may do some good.
 	 */
 	if (cmdsOK) {
-	    Lst_ForEach(gn->commands, JobPrintCommand, job);
+	    Lst_ForEachUntil(gn->commands, JobPrintCommand, job);
 	}
 	/*
 	 * Don't execute the shell, thank you.

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.66 src/usr.bin/make/lst.c:1.67
--- src/usr.bin/make/lst.c:1.66	Thu Sep 24 06:45:59 2020
+++ src/usr.bin/make/lst.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.66 2020/09/24 06:45:59 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.67 2020/09/24 07:11:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -36,7 +36,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.66 2020/09/24 06:45:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.67 2020/09/24 07:11:29 rillig Exp $");
 
 struct ListNode {
     struct ListNode *prev;	/* previous element in list */
@@ -415,13 +415,13 @@ Lst_FindDatum(List *list, const void *da
     return NULL;
 }
 
-static int Lst_ForEachFrom(List *, ListNode *, LstActionProc, void *);
+static int Lst_ForEachFrom(List *, ListNode *, LstActionUntilProc, void *);
 
 /* Apply the given function to each element of the given list. The function
  * should return 0 if traversal should continue and non-zero if it should
  * abort. */
 int
-Lst_ForEach(List *list, LstActionProc proc, void *procData)
+Lst_ForEachUntil(List *list, LstActionUntilProc proc, void *procData)
 {
     if (LstIsEmpty(list))
 	return 0;		/* XXX: Document what this value means. */
@@ -433,7 +433,7 @@ Lst_ForEach(List *list, LstActionProc pr
  * and non-zero if it should abort. */
 int
 Lst_ForEachFrom(List *list, ListNode *node,
-		 LstActionProc proc, void *procData)
+		 LstActionUntilProc proc, void *procData)
 {
     ListNode *tln = node;
     ListNode *next;

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.63 src/usr.bin/make/lst.h:1.64
--- src/usr.bin/make/lst.h:1.63	Thu Sep 24 06:45:59 2020
+++ src/usr.bin/make/lst.h	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.63 2020/09/24 06:45:59 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.64 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,8 +94,8 @@ typedef void *LstCopyProc(void *);
 typedef void LstFreeProc(void *);
 /* Return TRUE if the datum matches the args, for Lst_Find. */
 typedef Boolean LstFindProc(const void *datum, const void *args);
-/* An action for Lst_ForEach. */
-typedef int LstActionProc(void *datum, void *args);
+/* An action for Lst_ForEachUntil. */
+typedef int LstActionUntilProc(void *datum, void *args);
 
 /* Create or destroy a list */
 
@@ -154,7 +154,7 @@ void LstNode_SetNull(ListNode *);
 
 /* Apply a function to each datum of the list, until the callback function
  * returns non-zero. */
-int Lst_ForEach(List *, LstActionProc, void *);
+int Lst_ForEachUntil(List *, LstActionUntilProc, void *);
 
 /* Iterating over a list while keeping track of the current node and possible
  * concurrent modifications */

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.341 src/usr.bin/make/main.c:1.342
--- src/usr.bin/make/main.c:1.341	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/main.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.341 2020/09/22 20:19:46 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.342 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.341 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.342 2020/09/24 07:11:29 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -2015,7 +2015,7 @@ PrintOnError(GNode *gn, const char *s)
 	 */
 	Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
 	Var_Delete(".ERROR_CMD", VAR_GLOBAL);
-	Lst_ForEach(gn->commands, addErrorCMD, gn);
+	Lst_ForEachUntil(gn->commands, addErrorCMD, gn);
     }
     expr = "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}";
     (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.139 src/usr.bin/make/make.c:1.140
--- src/usr.bin/make/make.c:1.139	Thu Sep 24 06:45:59 2020
+++ src/usr.bin/make/make.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.139 2020/09/24 06:45:59 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.140 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include    "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.139 2020/09/24 06:45:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.140 2020/09/24 07:11:29 rillig Exp $");
 
 static unsigned int checked = 1;/* Sequence # to detect recursion */
 static GNodeList *toBeMade;	/* The current fringe of the graph. These
@@ -179,7 +179,7 @@ GNode_FprintDetails(FILE *f, const char 
  *-----------------------------------------------------------------------
  * Make_TimeStamp --
  *	Set the cmgn field of a parent node based on the mtime stamp in its
- *	child. Called from MakeOODate via Lst_ForEach.
+ *	child. Called from MakeOODate via Lst_ForEachUntil.
  *
  * Input:
  *	pgn		the current parent
@@ -369,7 +369,7 @@ Make_OODate(GNode *gn)
      * thinking they're out-of-date.
      */
     if (!oodate) {
-	Lst_ForEach(gn->parents, MakeTimeStamp, gn);
+	Lst_ForEachUntil(gn->parents, MakeTimeStamp, gn);
     }
 
     return oodate;
@@ -507,7 +507,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
 /*-
  *-----------------------------------------------------------------------
  * MakeHandleUse --
- *	Callback function for Lst_ForEach, used by Make_Run on the downward
+ *	Callback function for Lst_ForEachUntil, used by Make_Run on the downward
  *	pass to handle .USE nodes. Should be called before the children
  *	are enqueued to be looked at by MakeAddChild.
  *	This function calls Make_HandleUse to copy the .USE node's commands,
@@ -723,7 +723,7 @@ Make_Update(GNode *cgn)
     parents = centurion->parents;
 
     /* If this was a .ORDER node, schedule the RHS */
-    Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
+    Lst_ForEachUntil(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
 
     /* Now mark all the parents as having one less unmade child */
     Lst_Open(parents);
@@ -805,7 +805,7 @@ Make_Update(GNode *cgn)
 	    continue;
 	}
 	assert(pgn->order_pred != NULL);
-	if (Lst_ForEach(pgn->order_pred, MakeCheckOrder, 0)) {
+	if (Lst_ForEachUntil(pgn->order_pred, MakeCheckOrder, 0)) {
 	    /* A .ORDER rule stops us building this */
 	    continue;
 	}
@@ -846,7 +846,7 @@ Make_Update(GNode *cgn)
  *-----------------------------------------------------------------------
  * MakeAddAllSrc --
  *	Add a child's name to the ALLSRC and OODATE variables of the given
- *	node. Called from Make_DoAllVar via Lst_ForEach. A child is added only
+ *	node. Called from Make_DoAllVar via Lst_ForEachUntil. A child is added only
  *	if it has not been given the .EXEC, .USE or .INVISIBLE attributes.
  *	.EXEC and .USE children are very rarely going to be files, so...
  *	If the child is a .JOIN node, its ALLSRC is propagated to the parent.
@@ -964,8 +964,8 @@ Make_DoAllVar(GNode *gn)
     if (gn->flags & DONE_ALLSRC)
 	return;
 
-    Lst_ForEach(gn->children, MakeUnmark, gn);
-    Lst_ForEach(gn->children, MakeAddAllSrc, gn);
+    Lst_ForEachUntil(gn->children, MakeUnmark, gn);
+    Lst_ForEachUntil(gn->children, MakeAddAllSrc, gn);
 
     if (!Var_Exists (OODATE, gn)) {
 	Var_Set(OODATE, "", gn);
@@ -1025,7 +1025,7 @@ MakeBuildChild(void *v_cn, void *toBeMad
 
     /* If this node is on the RHS of a .ORDER, check LHSs. */
     assert(cn->order_pred);
-    if (Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) {
+    if (Lst_ForEachUntil(cn->order_pred, MakeCheckOrder, 0)) {
 	/* Can't build this (or anything else in this child list) yet */
 	cn->made = DEFERRED;
 	return 0;			/* but keep looking */
@@ -1042,7 +1042,7 @@ MakeBuildChild(void *v_cn, void *toBeMad
 	Lst_InsertBefore(toBeMade, toBeMade_next, cn);
 
     if (cn->unmade_cohorts != 0)
-	Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next);
+	Lst_ForEachUntil(cn->cohorts, MakeBuildChild, toBeMade_next);
 
     /*
      * If this node is a .WAIT node with unmade chlidren
@@ -1108,7 +1108,7 @@ MakeStartJobs(void)
 	     * just before the current first element.
 	     */
 	    gn->made = DEFERRED;
-	    Lst_ForEach(gn->children, MakeBuildChild, Lst_First(toBeMade));
+	    Lst_ForEachUntil(gn->children, MakeBuildChild, Lst_First(toBeMade));
 	    /* and drop this node on the floor */
 	    if (DEBUG(MAKE))
 		fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num);
@@ -1155,7 +1155,7 @@ MakeStartJobs(void)
  * MakePrintStatus --
  *	Print the status of a top-level node, viz. it being up-to-date
  *	already or not created due to an error in a lower level.
- *	Callback function for Make_Run via Lst_ForEach.
+ *	Callback function for Make_Run via Lst_ForEachUntil.
  *
  * Input:
  *	gnp		Node to examine
@@ -1224,7 +1224,7 @@ MakePrintStatus(void *gnp, void *v_error
 		GNode_FprintDetails(debug_file, " (", gn, ")!\n");
 	    }
 	    /* Most likely problem is actually caused by .ORDER */
-	    Lst_ForEach(gn->order_pred, MakePrintStatusOrder, gn);
+	    Lst_ForEachUntil(gn->order_pred, MakePrintStatusOrder, gn);
 	    break;
 	default:
 	    /* Errors - already counted */
@@ -1248,7 +1248,7 @@ MakePrintStatus(void *gnp, void *v_error
     if (!(gn->flags & CYCLE)) {
 	/* Fist time we've seen this node, check all children */
 	gn->flags |= CYCLE;
-	Lst_ForEach(gn->children, MakePrintStatus, errors);
+	Lst_ForEachUntil(gn->children, MakePrintStatus, errors);
 	/* Mark that this node needn't be processed again */
 	gn->flags |= DONECYCLE;
 	return 0;
@@ -1262,7 +1262,7 @@ MakePrintStatus(void *gnp, void *v_error
 	return 1;
 
     /* Reporting for our children will give the rest of the loop */
-    Lst_ForEach(gn->children, MakePrintStatus, errors);
+    Lst_ForEachUntil(gn->children, MakePrintStatus, errors);
     return 0;
 }
 
@@ -1329,21 +1329,21 @@ Make_ExpandUse(GNodeList *targs)
 
 	(void)Dir_MTime(gn, 0);
 	Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
-	Lst_ForEach(gn->children, MakeUnmark, gn);
-	Lst_ForEach(gn->children, MakeHandleUse, gn);
+	Lst_ForEachUntil(gn->children, MakeUnmark, gn);
+	Lst_ForEachUntil(gn->children, MakeHandleUse, gn);
 
 	if ((gn->type & OP_MADE) == 0)
 	    Suff_FindDeps(gn);
 	else {
 	    /* Pretend we made all this node's children */
-	    Lst_ForEach(gn->children, MakeFindChild, gn);
+	    Lst_ForEachUntil(gn->children, MakeFindChild, gn);
 	    if (gn->unmade != 0)
 		    printf("Warning: %s%s still has %d unmade children\n",
 			    gn->name, gn->cohort_num, gn->unmade);
 	}
 
 	if (gn->unmade != 0)
-	    Lst_ForEach(gn->children, MakeAddChild, examine);
+	    Lst_ForEachUntil(gn->children, MakeAddChild, examine);
     }
 
     Lst_Free(examine);
@@ -1412,7 +1412,7 @@ Make_ProcessWait(GNodeList *targs)
     /* Get it displayed in the diag dumps */
     Lst_Prepend(Targ_List(), pgn);
 
-    Lst_ForEach(targs, link_parent, pgn);
+    Lst_ForEachUntil(targs, link_parent, pgn);
 
     /* Start building with the 'dummy' .MAIN' node */
     MakeBuildChild(pgn, NULL);
@@ -1531,7 +1531,7 @@ Make_Run(GNodeList *targs)
     if (DEBUG(MAKE))
 	 fprintf(debug_file, "done: errors %d\n", errors);
     if (errors == 0) {
-	Lst_ForEach(targs, MakePrintStatus, &errors);
+	Lst_ForEachUntil(targs, MakePrintStatus, &errors);
 	if (DEBUG(MAKE)) {
 	    fprintf(debug_file, "done: errors %d\n", errors);
 	    if (errors)

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.117 src/usr.bin/make/meta.c:1.118
--- src/usr.bin/make/meta.c:1.117	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/meta.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.117 2020/09/22 20:19:46 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.118 2020/09/24 07:11:29 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -428,7 +428,7 @@ meta_needed(GNode *gn, const char *dname
     }
     if ((gn->type & (OP_META|OP_SUBMAKE)) == OP_SUBMAKE) {
 	/* OP_SUBMAKE is a bit too aggressive */
-	if (Lst_ForEach(gn->commands, is_submake, gn)) {
+	if (Lst_ForEachUntil(gn->commands, is_submake, gn)) {
 	    if (DEBUG(META))
 		fprintf(debug_file, "Skipping meta for %s: .SUBMAKE\n",
 			gn->name);
@@ -522,7 +522,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 
     mf.gn = gn;
 
-    Lst_ForEach(gn->commands, printCMD, &mf);
+    Lst_ForEachUntil(gn->commands, printCMD, &mf);
 
     fprintf(mf.fp, "CWD %s\n", getcwd(buf, sizeof(buf)));
     fprintf(mf.fp, "TARGET %s\n", tname);
@@ -948,7 +948,7 @@ fgetLine(char **bufp, size_t *szp, int o
     return 0;
 }
 
-/* Lst_ForEach wants 1 to stop search */
+/* Lst_ForEachUntil wants 1 to stop search */
 static int
 prefix_match(void *p, void *q)
 {
@@ -989,7 +989,7 @@ meta_ignore(GNode *gn, const char *p)
 
     if (*p == '/') {
 	cached_realpath(p, fname); /* clean it up */
-	if (Lst_ForEach(metaIgnorePaths, prefix_match, fname)) {
+	if (Lst_ForEachUntil(metaIgnorePaths, prefix_match, fname)) {
 #ifdef DEBUG_META_MODE
 	    if (DEBUG(META))
 		fprintf(debug_file, "meta_oodate: ignoring path: %s\n",
@@ -1389,7 +1389,7 @@ meta_oodate(GNode *gn, Boolean oodate)
 		    if (strncmp(p, cwd, cwdlen) == 0)
 			break;
 
-		    if (!Lst_ForEach(metaBailiwick, prefix_match, p))
+		    if (!Lst_ForEachUntil(metaBailiwick, prefix_match, p))
 			break;
 
 		    /* tmpdir might be within */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.323 src/usr.bin/make/parse.c:1.324
--- src/usr.bin/make/parse.c:1.323	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/parse.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.323 2020/09/22 20:19:46 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 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.323 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 rillig Exp $");
 
 /* types and constants */
 
@@ -826,7 +826,7 @@ ParseLinkSrc(void *pgnp, void *data)
  *---------------------------------------------------------------------
  * ParseDoOp  --
  *	Apply the parsed operator to the given target node. Used in a
- *	Lst_ForEach call by ParseDoDependency once all targets have
+ *	Lst_ForEachUntil call by ParseDoDependency once all targets have
  *	been found and their operator parsed. If the previous and new
  *	operators are incompatible, a major error is taken.
  *
@@ -937,7 +937,7 @@ ParseDoSrc(int tOp, const char *src, Par
 	    int op = parseKeywords[keywd].op;
 	    if (op != 0) {
 		if (targets != NULL)
-		    Lst_ForEach(targets, ParseDoOp, &op);
+		    Lst_ForEachUntil(targets, ParseDoOp, &op);
 		return;
 	    }
 	    if (parseKeywords[keywd].spec == Wait) {
@@ -957,7 +957,7 @@ ParseDoSrc(int tOp, const char *src, Par
 		gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
 		if (targets != NULL) {
 		    struct ParseLinkSrcArgs args = { gn, specType };
-		    Lst_ForEach(targets, ParseLinkSrc, &args);
+		    Lst_ForEachUntil(targets, ParseLinkSrc, &args);
 		}
 		return;
 	    }
@@ -1028,7 +1028,7 @@ ParseDoSrc(int tOp, const char *src, Par
 	} else {
 	    if (targets != NULL) {
 	        struct ParseLinkSrcArgs args = { gn, specType };
-		Lst_ForEach(targets, ParseLinkSrc, &args);
+		Lst_ForEachUntil(targets, ParseLinkSrc, &args);
 	    }
 	}
 	break;
@@ -1069,7 +1069,7 @@ ParseFindMain(void *gnp, void *dummy MAK
 /*-
  *-----------------------------------------------------------------------
  * ParseAddDir --
- *	Front-end for Dir_AddDir to make sure Lst_ForEach keeps going
+ *	Front-end for Dir_AddDir to make sure Lst_ForEachUntil keeps going
  *
  * Results:
  *	=== 0
@@ -1089,7 +1089,7 @@ ParseAddDir(void *path, void *name)
 /*-
  *-----------------------------------------------------------------------
  * ParseClearPath --
- *	Front-end for Dir_ClearPath to make sure Lst_ForEach keeps going
+ *	Front-end for Dir_ClearPath to make sure Lst_ForEachUntil keeps going
  *
  * Results:
  *	=== 0
@@ -1526,7 +1526,7 @@ ParseDoDependency(char *line)
      * used isn't consistent across all references.
      */
     if (targets != NULL)
-	Lst_ForEach(targets, ParseDoOp, &op);
+	Lst_ForEachUntil(targets, ParseDoOp, &op);
 
     /*
      * Onward to the sources.
@@ -1564,7 +1564,7 @@ ParseDoDependency(char *line)
 		break;
 	    case ExPath:
 		if (paths != NULL)
-		    Lst_ForEach(paths, ParseClearPath, NULL);
+		    Lst_ForEachUntil(paths, ParseClearPath, NULL);
 		Dir_SetPATH();
 		break;
 #ifdef POSIX
@@ -1640,7 +1640,7 @@ ParseDoDependency(char *line)
 		    break;
 		case ExPath:
 		    if (paths != NULL)
-			Lst_ForEach(paths, ParseAddDir, line);
+			Lst_ForEachUntil(paths, ParseAddDir, line);
 		    break;
 		case Includes:
 		    Suff_AddInclude(line);
@@ -1728,7 +1728,7 @@ ParseDoDependency(char *line)
 	 * the first dependency line that is actually a real target
 	 * (i.e. isn't a .USE or .EXEC rule) to be made.
 	 */
-	Lst_ForEach(targets, ParseFindMain, NULL);
+	Lst_ForEachUntil(targets, ParseFindMain, NULL);
     }
 
 out:
@@ -2045,7 +2045,7 @@ ParseMaybeSubMake(const char *cmd)
 
 /*-
  * ParseAddCmd  --
- *	Lst_ForEach function to add a command line to all targets
+ *	Lst_ForEachUntil function to add a command line to all targets
  *
  * Input:
  *	gnp		the node to which the command is to be added
@@ -2879,7 +2879,7 @@ ParseFinishLine(void)
 {
     if (inLine) {
 	if (targets != NULL) {
-	    Lst_ForEach(targets, SuffEndTransform, NULL);
+	    Lst_ForEachUntil(targets, SuffEndTransform, NULL);
 	    Lst_Destroy(targets, ParseHasCommands);
 	}
 	targets = NULL;
@@ -2979,7 +2979,7 @@ Parse_File(const char *name, int fd)
 		     */
 		    if (targets) {
 			cp = bmake_strdup(cp);
-			Lst_ForEach(targets, ParseAddCmd, cp);
+			Lst_ForEachUntil(targets, ParseAddCmd, cp);
 #ifdef CLEANUP
 			Lst_Append(targCmds, cp);
 #endif

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.158 src/usr.bin/make/suff.c:1.159
--- src/usr.bin/make/suff.c:1.158	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/suff.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.158 2020/09/22 20:19:46 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.159 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.158 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.159 2020/09/24 07:11:29 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
     if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -608,7 +608,7 @@ Suff_AddTransform(char *line)
 
 /* Handle the finish of a transformation definition, removing the
  * transformation from the graph if it has neither commands nor sources.
- * This is a callback procedure for the Parse module via Lst_ForEach.
+ * This is a callback procedure for the Parse module via Lst_ForEachUntil.
  *
  * If the node has no commands or children, the children and parents lists
  * of the affected suffixes are altered.
@@ -661,7 +661,7 @@ Suff_EndTransform(GNode *gn)
     }
 }
 
-/* Called from Suff_AddSuffix via Lst_ForEach to search through the list of
+/* Called from Suff_AddSuffix via Lst_ForEachUntil to search through the list of
  * existing transformation rules and rebuild the transformation graph when
  * it has been destroyed by Suff_ClearSuffixes. If the given rule is a
  * transformation involving this suffix and another, existing suffix, the
@@ -675,7 +675,7 @@ Suff_EndTransform(GNode *gn)
  *	sp		Suffix to rebuild
  *
  * Results:
- *	0, so that Lst_ForEach continues
+ *	0, so that Lst_ForEachUntil continues
  */
 static int
 SuffRebuildGraph(void *transformp, void *sp)
@@ -734,7 +734,7 @@ SuffRebuildGraph(void *transformp, void 
     return 0;
 }
 
-/* Called from Suff_AddSuffix via Lst_ForEach to search through the list of
+/* Called from Suff_AddSuffix via Lst_ForEachUntil to search through the list of
  * existing targets and find if any of the existing targets can be turned
  * into a transformation rule.
  *
@@ -818,12 +818,12 @@ Suff_AddSuffix(const char *name, GNode *
 	gs.gnp = gnp;
 	gs.s  = s;
 	gs.r  = FALSE;
-	Lst_ForEach(Targ_List(), SuffScanTargets, &gs);
+	Lst_ForEachUntil(Targ_List(), SuffScanTargets, &gs);
 	/*
 	 * Look for any existing transformations from or to this suffix.
 	 * XXX: Only do this after a Suff_ClearSuffixes?
 	 */
-	Lst_ForEach(transforms, SuffRebuildGraph, s);
+	Lst_ForEachUntil(transforms, SuffRebuildGraph, s);
     }
 }
 
@@ -952,7 +952,7 @@ PrintAddr(void *a, void *b MAKE_ATTR_UNU
  *	lsp		list and parent for the new Src
  *
  * Results:
- *	0, so that Lst_ForEach continues
+ *	0, so that Lst_ForEachUntil continues
  */
 static int
 SuffAddSrc(void *sp, void *lsp)
@@ -984,7 +984,7 @@ SuffAddSrc(void *sp, void *lsp)
 	s2->cp = Lst_Init();
 	Lst_Append(targ->cp, s2);
 	fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
-	Lst_ForEach(ls->l, PrintAddr, NULL);
+	Lst_ForEachUntil(ls->l, PrintAddr, NULL);
 	fprintf(debug_file, "\n");
 #endif
     }
@@ -1002,7 +1002,7 @@ SuffAddSrc(void *sp, void *lsp)
     s2->cp = Lst_Init();
     Lst_Append(targ->cp, s2);
     fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
-    Lst_ForEach(ls->l, PrintAddr, NULL);
+    Lst_ForEachUntil(ls->l, PrintAddr, NULL);
     fprintf(debug_file, "\n");
 #endif
 
@@ -1023,7 +1023,7 @@ SuffAddLevel(SrcList *l, Src *targ)
     ls.s = targ;
     ls.l = l;
 
-    Lst_ForEach(targ->suff->children, SuffAddSrc, &ls);
+    Lst_ForEachUntil(targ->suff->children, SuffAddSrc, &ls);
 }
 
 /* Free the first Src in the list that doesn't have a reference count.
@@ -1038,7 +1038,7 @@ SuffRemoveSrc(SrcList *l)
 
 #ifdef DEBUG_SRC
     fprintf(debug_file, "cleaning %lx: ", (unsigned long) l);
-    Lst_ForEach(l, PrintAddr, NULL);
+    Lst_ForEachUntil(l, PrintAddr, NULL);
     fprintf(debug_file, "\n");
 #endif
 
@@ -1068,7 +1068,7 @@ SuffRemoveSrc(SrcList *l)
 #ifdef DEBUG_SRC
 	else {
 	    fprintf(debug_file, "keep: [l=%p] p=%p %d: ", l, s, s->children);
-	    Lst_ForEach(s->cp, PrintAddr, NULL);
+	    Lst_ForEachUntil(s->cp, PrintAddr, NULL);
 	    fprintf(debug_file, "\n");
 	}
 #endif
@@ -2225,10 +2225,10 @@ SuffPrintSuff(void *sp, void *dummy MAKE
     }
     fputc('\n', debug_file);
     fprintf(debug_file, "#\tTo: ");
-    Lst_ForEach(s->parents, SuffPrintName, NULL);
+    Lst_ForEachUntil(s->parents, SuffPrintName, NULL);
     fputc('\n', debug_file);
     fprintf(debug_file, "#\tFrom: ");
-    Lst_ForEach(s->children, SuffPrintName, NULL);
+    Lst_ForEachUntil(s->children, SuffPrintName, NULL);
     fputc('\n', debug_file);
     fprintf(debug_file, "#\tSearch Path: ");
     Dir_PrintPath(s->searchPath);
@@ -2253,8 +2253,8 @@ void
 Suff_PrintAll(void)
 {
     fprintf(debug_file, "#*** Suffixes:\n");
-    Lst_ForEach(sufflist, SuffPrintSuff, NULL);
+    Lst_ForEachUntil(sufflist, SuffPrintSuff, NULL);
 
     fprintf(debug_file, "#*** Transformations:\n");
-    Lst_ForEach(transforms, SuffPrintTrans, NULL);
+    Lst_ForEachUntil(transforms, SuffPrintTrans, NULL);
 }

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.91 src/usr.bin/make/targ.c:1.92
--- src/usr.bin/make/targ.c:1.91	Thu Sep 24 06:45:59 2020
+++ src/usr.bin/make/targ.c	Thu Sep 24 07:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.91 2020/09/24 06:45:59 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.92 2020/09/24 07:11:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
 #include	  "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.91 2020/09/24 06:45:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.92 2020/09/24 07:11:29 rillig Exp $");
 
 static GNodeList *allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -395,7 +395,7 @@ TargPrintCmd(void *cmd, void *dummy MAKE
 void
 Targ_PrintCmds(GNode *gn)
 {
-    Lst_ForEach(gn->commands, TargPrintCmd, NULL);
+    Lst_ForEachUntil(gn->commands, TargPrintCmd, NULL);
 }
 
 /* Format a modification time in some reasonable way and return it.
@@ -521,7 +521,7 @@ PrintNode(void *gnp, void *passp)
 	Targ_PrintCmds(gn);
 	fprintf(debug_file, "\n\n");
 	if (gn->type & OP_DOUBLEDEP) {
-	    Lst_ForEach(gn->cohorts, PrintNode, passp);
+	    Lst_ForEachUntil(gn->cohorts, PrintNode, passp);
 	}
     }
     return 0;
@@ -537,7 +537,7 @@ Targ_PrintNode(GNode *gn, int pass)
 void
 Targ_PrintNodes(GNodeList *gnodes, int pass)
 {
-    Lst_ForEach(gnodes, PrintNode, &pass);
+    Lst_ForEachUntil(gnodes, PrintNode, &pass);
 }
 
 /* Print only those targets that are just a source.
@@ -566,10 +566,10 @@ void
 Targ_PrintGraph(int pass)
 {
     fprintf(debug_file, "#*** Input graph:\n");
-    Lst_ForEach(allTargets, PrintNode, &pass);
+    Lst_ForEachUntil(allTargets, PrintNode, &pass);
     fprintf(debug_file, "\n\n");
     fprintf(debug_file, "#\n#   Files that are only sources:\n");
-    Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
+    Lst_ForEachUntil(allTargets, TargPrintOnlySrc, NULL);
     fprintf(debug_file, "#*** Global Variables:\n");
     Var_Dump(VAR_GLOBAL);
     fprintf(debug_file, "#*** Command-line Variables:\n");

Reply via email to