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): remove void pointers from addErrorCMD



details:   https://anonhg.NetBSD.org/src/rev/6243b673dc07
branches:  trunk
changeset: 941500:6243b673dc07
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 23 06:27:39 2020 +0000

description:
make(1): remove void pointers from addErrorCMD

diffstat:

 usr.bin/make/main.c |  44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diffs (79 lines):

diff -r 013397906bd2 -r 6243b673dc07 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Oct 23 06:18:23 2020 +0000
+++ b/usr.bin/make/main.c       Fri Oct 23 06:27:39 2020 +0000
@@ -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 @@
     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 @@
     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 @@
 
     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 */



Home | Main Index | Thread Index | Old Index