Module Name:    src
Committed By:   rillig
Date:           Sat Oct 17 21:21:38 UTC 2020

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

Log Message:
make(1): remove struct ParseLinkSrcArgs

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


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.381 src/usr.bin/make/parse.c:1.382
--- src/usr.bin/make/parse.c:1.381	Sat Oct 17 20:57:08 2020
+++ src/usr.bin/make/parse.c	Sat Oct 17 21:21:37 2020
@@ -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 @@ ParseMessage(const char *directive)
     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. */
-static void
-ParseLinkSrc(void *pgnp, void *data)
-{
-    const struct ParseLinkSrcArgs *args = data;
-    GNode *pgn = pgnp;
-    GNode *cgn = args->cgn;
-
+ * 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
+LinkSource(GNode *pgn, GNode *cgn, Boolean isSpecial)
+{
     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 @@ ParseLinkSrc(void *pgnp, void *data)
     }
 }
 
+/* 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 @@ ParseDoSrcKeyword(const char *src, Parse
 		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 @@ ParseDoSrcOther(const char *src, GNodeTy
     if (tOp) {
 	gn->type |= tOp;
     } else {
-	{
-	    struct ParseLinkSrcArgs args = { gn, specType };
-	    Lst_ForEach(targets, ParseLinkSrc, &args);
-	}
+	LinkToTargets(gn, specType != Not);
     }
 }
 

Reply via email to