Module Name:    src
Committed By:   rillig
Date:           Fri Oct 23 06:27:39 UTC 2020

Modified Files:
        src/usr.bin/make: main.c

Log Message:
make(1): remove void pointers from addErrorCMD


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.384 src/usr.bin/make/main.c:1.385
--- src/usr.bin/make/main.c:1.384	Thu Oct 22 07:12:13 2020
+++ src/usr.bin/make/main.c	Fri Oct 23 06:27:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.384 2020/10/22 07:12:13 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.385 2020/10/23 06:27:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.384 2020/10/22 07:12:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.385 2020/10/23 06:27:39 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -2024,16 +2024,6 @@ cached_realpath(const char *pathname, ch
     return rp ? resolved : NULL;
 }
 
-
-static int
-addErrorCMD(void *cmdp, void *gnp)
-{
-    if (cmdp == NULL)
-	return 1;			/* stop */
-    Var_Append(".ERROR_CMD", cmdp, VAR_GLOBAL);
-    return 0;
-}
-
 /*
  * Return true if we should die without noise.
  * For example our failing child was a sub-make
@@ -2055,6 +2045,26 @@ dieQuietly(GNode *gn, int bf)
     return quietly;
 }
 
+static void
+SetErrorVars(GNode *gn)
+{
+    StringListNode *ln;
+
+    /*
+     * We can print this even if there is no .ERROR target.
+     */
+    Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
+    Var_Delete(".ERROR_CMD", VAR_GLOBAL);
+
+    for (ln = gn->commands->first; ln != NULL; ln = ln->next) {
+	const char *cmd = ln->datum;
+
+	if (cmd == NULL)
+	    break;
+	Var_Append(".ERROR_CMD", cmd, VAR_GLOBAL);
+    }
+}
+
 void
 PrintOnError(GNode *gn, const char *s)
 {
@@ -2078,14 +2088,8 @@ PrintOnError(GNode *gn, const char *s)
 
     if (en)
 	return;				/* we've been here! */
-    if (gn) {
-	/*
-	 * We can print this even if there is no .ERROR target.
-	 */
-	Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
-	Var_Delete(".ERROR_CMD", VAR_GLOBAL);
-	Lst_ForEachUntil(gn->commands, addErrorCMD, gn);
-    }
+    if (gn)
+        SetErrorVars(gn);
     expr = "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}";
     (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);
     /* TODO: handle errors */

Reply via email to