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 struct ParseLinkSrcArgs



details:   https://anonhg.NetBSD.org/src/rev/5e3d25183ff1
branches:  trunk
changeset: 944967:5e3d25183ff1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 17 21:21:37 2020 +0000

description:
make(1): remove struct ParseLinkSrcArgs

Inlining Lst_ForEach removes the need for the void pointers and the
additional parameter struct.

diffstat:

 usr.bin/make/parse.c |  46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diffs (98 lines):

diff -r 4b6713db0632 -r 5e3d25183ff1 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Oct 17 20:57:08 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Oct 17 21:21:37 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.381 2020/10/17 20:57:08 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.382 2020/10/17 21:21:37 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.381 2020/10/17 20:57:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.382 2020/10/17 21:21:37 rillig Exp $");
 
 /* types and constants */
 
@@ -752,33 +752,22 @@
     return TRUE;
 }
 
-struct ParseLinkSrcArgs {
-    GNode *cgn;
-
-    /* The special target of the current dependency line. */
-    /* Example: for ".END: action", it is 'End'. */
-    ParseSpecial specType;
-};
-
 /* Add the child to the parent's children.
  *
- * Add the parent to the child's parents, but only if the target is not
- * special.  An example for such a special target is .END, which does not
- * need to be informed once the child target has been made. */
+ * Additionally, add the parent to the child's parents, but only if the
+ * target is not special.  An example for such a special target is .END,
+ * which does not need to be informed once the child target has been made. */
 static void
-ParseLinkSrc(void *pgnp, void *data)
+LinkSource(GNode *pgn, GNode *cgn, Boolean isSpecial)
 {
-    const struct ParseLinkSrcArgs *args = data;
-    GNode *pgn = pgnp;
-    GNode *cgn = args->cgn;
-
     if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts))
        pgn = LstNode_Datum(Lst_Last(pgn->cohorts));
 
     Lst_Append(pgn->children, cgn);
     pgn->unmade++;
 
-    if (args->specType == Not)
+    /* Special targets like .END don't need any children. */
+    if (!isSpecial)
        Lst_Append(cgn->parents, pgn);
 
     if (DEBUG(PARSE)) {
@@ -789,6 +778,15 @@
     }
 }
 
+/* Add the node to each target from the current dependency group. */
+static void
+LinkToTargets(GNode *gn, Boolean isSpecial)
+{
+    GNodeListNode *ln;
+    for (ln = targets->first; ln != NULL; ln = ln->next)
+       LinkSource(ln->datum, gn, isSpecial);
+}
+
 static Boolean
 TryApplyDependencyOperator(GNode *gn, GNodeType op)
 {
@@ -887,10 +885,7 @@
                if (doing_depend)
                    ParseMark(gn);
                gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
-               {
-                   struct ParseLinkSrcArgs args = { gn, specType };
-                   Lst_ForEach(targets, ParseLinkSrc, &args);
-               }
+               LinkToTargets(gn, specType != Not);
                return TRUE;
            }
        }
@@ -968,10 +963,7 @@
     if (tOp) {
        gn->type |= tOp;
     } else {
-       {
-           struct ParseLinkSrcArgs args = { gn, specType };
-           Lst_ForEach(targets, ParseLinkSrc, &args);
-       }
+       LinkToTargets(gn, specType != Not);
     }
 }
 



Home | Main Index | Thread Index | Old Index