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): inline Lst_ForEachUntil in Compat_Make



details:   https://anonhg.NetBSD.org/src/rev/c6c5d3a5a522
branches:  trunk
changeset: 1014603:c6c5d3a5a522
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 27 11:43:46 2020 +0000

description:
make(1): inline Lst_ForEachUntil in Compat_Make

This avoids the extra local function and a few conversions to void
pointers, to gain additional type safety.

The code in Compat_RunCommand does not modify gn->commands structurally,
therefore it does not need the extra complexity of Lst_ForEachUntil.  It
does have access to a list node to exactly this list.  This list node is
only used to set the command to NULL after processing it, not for
removing the node from the list.

diffstat:

 usr.bin/make/compat.c |  19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r fe0e786a5e76 -r c6c5d3a5a522 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sun Sep 27 11:39:02 2020 +0000
+++ b/usr.bin/make/compat.c     Sun Sep 27 11:43:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.154 2020/09/27 11:39:02 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.155 2020/09/27 11:43:46 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.154 2020/09/27 11:39:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.155 2020/09/27 11:43:46 rillig Exp $");
 
 static GNode       *curTarg = NULL;
 static void CompatInterrupt(int);
@@ -466,10 +466,15 @@
     return status;
 }
 
-static int
-CompatRunCommand(void *cmd, void *gn)
+static void
+RunCommands(GNode *gn)
 {
-    return Compat_RunCommand(cmd, gn);
+    StringListNode *ln;
+    for (ln = gn->commands->first; ln != NULL; ln = ln->next) {
+       const char *cmd = ln->datum;
+       if (Compat_RunCommand(cmd, gn) != 0)
+           break;
+    }
 }
 
 static void
@@ -578,7 +583,7 @@
                    meta_job_start(NULL, gn);
                }
 #endif
-               Lst_ForEachUntil(gn->commands, CompatRunCommand, gn);
+               RunCommands(gn);
                curTarg = NULL;
            } else {
                Job_Touch(gn, (gn->type & OP_SILENT) != 0);
@@ -730,7 +735,7 @@
      * If the user has defined a .END target, run its commands.
      */
     if (errors == 0) {
-        GNode *endNode = Targ_GetEndNode();
+       GNode *endNode = Targ_GetEndNode();
        Compat_Make(endNode, endNode);
        /* XXX: Did you mean endNode->made instead of gn->made? */
        if (gn->made == ERROR) {



Home | Main Index | Thread Index | Old Index