Module Name:    othersrc
Committed By:   dholland
Date:           Mon Mar  4 08:47:09 UTC 2013

Modified Files:
        othersrc/usr.bin/dholland-make2: array.c array.h compat.c graph.h
            main.c make.c nonints.h parse.c suff.c targ.c

Log Message:
Use more arrays and fewer lists.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/dholland-make2/array.c \
    othersrc/usr.bin/dholland-make2/graph.h \
    othersrc/usr.bin/dholland-make2/parse.c
cvs rdiff -u -r1.4 -r1.5 othersrc/usr.bin/dholland-make2/array.h
cvs rdiff -u -r1.3 -r1.4 othersrc/usr.bin/dholland-make2/compat.c \
    othersrc/usr.bin/dholland-make2/main.c \
    othersrc/usr.bin/dholland-make2/make.c \
    othersrc/usr.bin/dholland-make2/suff.c \
    othersrc/usr.bin/dholland-make2/targ.c
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/usr.bin/dholland-make2/nonints.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/dholland-make2/array.c
diff -u othersrc/usr.bin/dholland-make2/array.c:1.2 othersrc/usr.bin/dholland-make2/array.c:1.3
--- othersrc/usr.bin/dholland-make2/array.c:1.2	Mon Mar  4 07:27:54 2013
+++ othersrc/usr.bin/dholland-make2/array.c	Mon Mar  4 08:47:08 2013
@@ -31,6 +31,9 @@
 #include <string.h>
 #include "portable.h"
 
+/* XXX this should go away */
+#include "lst.h"
+
 #define ARRAYINLINE
 #include "array.h"
 
@@ -159,3 +162,36 @@ array_removeval(struct array *a, void *v
 		array_remove(a, ix);
 	}
 }
+
+////////////////////////////////////////////////////////////
+// tools for interfacing with lst.lib
+
+static int
+Lst_AddToArray(void *p, void *arrv)
+{
+	struct array *arr = arrv;
+
+	array_add(arr, p, NULL);
+	return 0;
+}
+
+void
+Lst_IntoArray(Lst list, struct array *arr)
+{
+	Lst_ForEach(list, Lst_AddToArray, arr);
+}
+
+Lst
+LstFromArray(struct array *arr)
+{
+	Lst ret;
+	unsigned i;
+	void *p;
+
+	ret = Lst_Init(FALSE);
+	for (i=0; i<array_num(arr); i++) {
+		p = array_get(arr, i);
+		Lst_AtEnd(ret, p);
+	}
+	return ret;
+}
Index: othersrc/usr.bin/dholland-make2/graph.h
diff -u othersrc/usr.bin/dholland-make2/graph.h:1.2 othersrc/usr.bin/dholland-make2/graph.h:1.3
--- othersrc/usr.bin/dholland-make2/graph.h:1.2	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/graph.h	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: graph.h,v 1.2 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: graph.h,v 1.3 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -158,7 +158,7 @@ struct GNode {
 
     GList     	    iParents;  	/* Links to parents for which this is an
 				 * implied source, if any */
-    Lst	    	    cohorts;  	/* Other nodes for the :: operator */
+    GList           cohorts;  	/* Other nodes for the :: operator */
     Lst             parents;   	/* Nodes that depend on this one */
     Lst             children;  	/* Nodes on which this one depends */
     Lst             order_pred;	/* .ORDER nodes we need made */
Index: othersrc/usr.bin/dholland-make2/parse.c
diff -u othersrc/usr.bin/dholland-make2/parse.c:1.2 othersrc/usr.bin/dholland-make2/parse.c:1.3
--- othersrc/usr.bin/dholland-make2/parse.c:1.2	Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/parse.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.2 2013/02/25 03:39:28 dholland Exp $	*/
+/*	$NetBSD: parse.c,v 1.3 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -138,7 +138,7 @@
 #include "buf.h"
 #include "pathnames.h"
 
-MAKE_RCSID("$NetBSD: parse.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.3 2013/03/04 08:47:08 dholland Exp $");
 
 ////////////////////////////////////////////////////////////
 // types and constants
@@ -829,8 +829,9 @@ ParseLinkSrc(void *pgnp, void *cgnp)
     GNode          *pgn = (GNode *)pgnp;
     GNode          *cgn = (GNode *)cgnp;
 
-    if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts))
-	pgn = (GNode *)Lst_Datum(Lst_Last(pgn->cohorts));
+    if ((pgn->type & OP_DOUBLEDEP) && glist_num(&pgn->cohorts) > 0) {
+	pgn = glist_get(&pgn->cohorts, glist_num(&pgn->cohorts) - 1);
+    }
     (void)Lst_AtEnd(pgn->children, cgn);
     if (specType == Not)
 	    (void)Lst_AtEnd(cgn->parents, pgn);
@@ -906,7 +907,7 @@ ParseDoOp(void *gnp, void *opp)
 	 * traversals will no longer see this node anyway. -mycroft)
 	 */
 	cohort->type = op | OP_INVISIBLE;
-	(void)Lst_AtEnd(gn->cohorts, cohort);
+	glist_add(&gn->cohorts, cohort, NULL);
 	cohort->centurion = gn;
 	gn->unmade_cohorts += 1;
 	snprintf(cohort->cohort_num, sizeof cohort->cohort_num, "#%d",
@@ -1941,8 +1942,9 @@ ParseAddCmd(void *gnp, void *cmd)
     GNode *gn = (GNode *)gnp;
 
     /* Add to last (ie current) cohort for :: targets */
-    if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts))
-	gn = (GNode *)Lst_Datum(Lst_Last(gn->cohorts));
+    if ((gn->type & OP_DOUBLEDEP) && glist_num(&gn->cohorts) > 0) {
+	gn = glist_get(&gn->cohorts, glist_num(&gn->cohorts) - 1);
+    }
 
     /* if target already supplied, ignore commands */
     if (!(gn->type & OP_HAS_COMMANDS)) {
@@ -3055,35 +3057,34 @@ Parse_End(void)
 /*-
  *-----------------------------------------------------------------------
  * Parse_MainName --
- *	Return a Lst of the main target to create for main()'s sake. If
- *	no such target exists, we Punt with an obnoxious error message.
+ *	Fill a GList with the the main target to create for main()'s
+ *	sake. If no such target exists, we Punt with an obnoxious
+ *	error message.
  *
  * Results:
- *	A Lst of the single node to create.
+ *	The argument GList is filled in.
  *
  * Side Effects:
  *	None.
  *
  *-----------------------------------------------------------------------
  */
-Lst
-Parse_MainName(void)
+void
+Parse_MainName(GList *mainList)
 {
-    Lst           mainList;	/* result list */
-
-    mainList = Lst_Init(FALSE);
+    unsigned i;
 
     if (mainNode == NULL) {
 	Punt("no target to make.");
     	/*NOTREACHED*/
-    } else if (mainNode->type & OP_DOUBLEDEP) {
-	(void)Lst_AtEnd(mainList, mainNode);
-	Lst_Concat(mainList, mainNode->cohorts, LST_CONCNEW);
     }
-    else
-	(void)Lst_AtEnd(mainList, mainNode);
+    glist_add(mainList, mainNode, NULL);
+    if (mainNode->type & OP_DOUBLEDEP) {
+	for (i=0; i<glist_num(&mainNode->cohorts); i++) {
+	    glist_add(mainList, glist_get(&mainNode->cohorts, i), NULL);
+	}
+    }
     Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
-    return (mainList);
 }
 
 /*-

Index: othersrc/usr.bin/dholland-make2/array.h
diff -u othersrc/usr.bin/dholland-make2/array.h:1.4 othersrc/usr.bin/dholland-make2/array.h:1.5
--- othersrc/usr.bin/dholland-make2/array.h:1.4	Mon Mar  4 07:27:54 2013
+++ othersrc/usr.bin/dholland-make2/array.h	Mon Mar  4 08:47:08 2013
@@ -290,4 +290,12 @@ array_add(struct array *a, void *val, un
 DECLARRAY_BYTYPE(stringarray, char, ARRAYINLINE);
 DEFARRAY_BYTYPE(stringarray, char, ARRAYINLINE);
 
+////////////////////////////////////////////////////////////
+// tools for interacting with lst.lib
+// (these are not typesafe and should go away)
+
+void Lst_IntoArray(Lst list, struct array *arr);
+Lst LstFromArray(struct array *arr);
+
+
 #endif /* ARRAY_H */

Index: othersrc/usr.bin/dholland-make2/compat.c
diff -u othersrc/usr.bin/dholland-make2/compat.c:1.3 othersrc/usr.bin/dholland-make2/compat.c:1.4
--- othersrc/usr.bin/dholland-make2/compat.c:1.3	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/compat.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.3 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: compat.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -101,7 +101,7 @@
 #include    "job.h"
 #include    "pathnames.h"
 
-MAKE_RCSID("$NetBSD: compat.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.4 2013/03/04 08:47:08 dholland Exp $");
 
 /*
  * The following array is used to make a fast determination of which
@@ -652,7 +652,13 @@ Compat_Make(void *gnp, void *pgnp)
     }
 
 cohorts:
-    Lst_ForEach(gn->cohorts, Compat_Make, pgnp);
+    {
+	unsigned i;
+
+	for (i=0; i<glist_num(&gn->cohorts); i++) {
+		Compat_Make(glist_get(&gn->cohorts, i), pgnp);
+	}
+    }
     return (0);
 }
 
Index: othersrc/usr.bin/dholland-make2/main.c
diff -u othersrc/usr.bin/dholland-make2/main.c:1.3 othersrc/usr.bin/dholland-make2/main.c:1.4
--- othersrc/usr.bin/dholland-make2/main.c:1.3	Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/main.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.3 2013/02/25 03:39:28 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -128,7 +128,7 @@
 
 MAKE_COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
-MAKE_RCSID("$NetBSD: main.c,v 1.3 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.4 2013/03/04 08:47:08 dholland Exp $");
 
 
 #ifndef	DEFMAXLOCAL
@@ -1237,10 +1237,17 @@ main(int argc, char **argv)
 		 * we consult the parsing module to find the main target(s)
 		 * to create.
 		 */
-		if (Lst_IsEmpty(create))
-			targs = Parse_MainName();
-		else
+		if (Lst_IsEmpty(create)) {
+			GList tmp;
+
+			glist_init(&tmp);
+			Parse_MainName(&tmp);
+			targs = LstFromArray(&tmp.arr); /* XXX not typesafe */
+			glist_setsize(&tmp, 0);
+			glist_cleanup(&tmp);
+		} else {
 			targs = Targ_FindList(create, TARG_CREATE);
+		}
 
 		if (!compatMake) {
 			/*
Index: othersrc/usr.bin/dholland-make2/make.c
diff -u othersrc/usr.bin/dholland-make2/make.c:1.3 othersrc/usr.bin/dholland-make2/make.c:1.4
--- othersrc/usr.bin/dholland-make2/make.c:1.3	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/make.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.3 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: make.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include    "dir.h"
 #include    "job.h"
 
-MAKE_RCSID("$NetBSD: make.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.4 2013/03/04 08:47:08 dholland Exp $");
 
 static unsigned int checked = 1;/* Sequence # to detect recursion */
 static Lst     	toBeMade;	/* The current fringe of the graph. These
@@ -120,7 +120,7 @@ static Lst     	toBeMade;	/* The current
 				 * Make_Update and subtracted from by
 				 * MakeStartJobs */
 
-static int MakeAddChild(void *, void *);
+static int MakeAddChild2(void *, void *);
 static int MakeFindChild(void *, void *);
 static int MakeUnmark(void *, void *);
 static int MakeAddAllSrc(void *, void *);
@@ -349,6 +349,8 @@ Make_OODate(GNode *gn)
  * MakeAddChild  --
  *	Function used by Make_Run to add a child to the list l.
  *	It will only add the child if its make field is FALSE.
+ * MakeAddChild2  --
+ *      Same but lp is a GList, not a Lst.
  *
  * Input:
  *	gnp		the node to add
@@ -361,6 +363,7 @@ Make_OODate(GNode *gn)
  *	The given list is extended
  *-----------------------------------------------------------------------
  */
+#if 0
 static int
 MakeAddChild(void *gnp, void *lp)
 {
@@ -375,6 +378,23 @@ MakeAddChild(void *gnp, void *lp)
     }
     return (0);
 }
+#endif
+
+/* array variant */
+static int
+MakeAddChild2(void *gnp, void *lp)
+{
+    GNode          *gn = (GNode *)gnp;
+    GList          *l = lp;
+
+    if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) {
+	if (DEBUG(MAKE))
+	    fprintf(debug_file, "MakeAddChild: need to examine %s%s\n",
+		gn->name, gn->cohort_num);
+	glist_add(l, gn, NULL);
+    }
+    return (0);
+}
 
 /*-
  *-----------------------------------------------------------------------
@@ -1039,8 +1059,15 @@ MakeBuildChild(void *v_cn, void *toBeMad
     else
 	Lst_InsertBefore(toBeMade, toBeMade_next, cn);
 
-    if (cn->unmade_cohorts != 0)
-	Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next);
+    if (cn->unmade_cohorts != 0) {
+	unsigned i;
+
+	for (i=0; i<glist_num(&cn->cohorts); i++) {
+	    if (MakeBuildChild(glist_get(&cn->cohorts, i), toBeMade_next)) {
+		break;
+	    }
+	}
+    }
 
     /*
      * If this node is a .WAIT node with unmade chlidren
@@ -1279,9 +1306,10 @@ void
 Make_ExpandUse(Lst targs)
 {
     GNode  *gn;		/* a temporary pointer */
-    Lst    examine; 	/* List of targets to examine */
+    GList examine;	/* List of targets to examine */
 
-    examine = Lst_Duplicate(targs, NULL);
+    glist_init(&examine);
+    Lst_IntoArray(targs, &examine.arr); /* XXX not typesafe */
 
     /*
      * Make an initial downward pass over the graph, marking nodes to be made
@@ -1291,8 +1319,9 @@ Make_ExpandUse(Lst targs)
      * be looked at in a minute, otherwise we add its children to our queue
      * and go on about our business.
      */
-    while (!Lst_IsEmpty (examine)) {
-	gn = (GNode *)Lst_DeQueue(examine);
+    while (glist_num(&examine) > 0) {
+	gn = glist_get(&examine, 0);
+	glist_remove(&examine, 0);
     
 	if (gn->flags & REMAKE)
 	    /* We've looked at this one already */
@@ -1302,12 +1331,22 @@ Make_ExpandUse(Lst targs)
 	    fprintf(debug_file, "Make_ExpandUse: examine %s%s\n",
 		    gn->name, gn->cohort_num);
 
-	if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts)) {
-	    /* Append all the 'cohorts' to the list of things to examine */
-	    Lst new;
-	    new = Lst_Duplicate(gn->cohorts, NULL);
-	    Lst_Concat(new, examine, LST_CONCLINK);
-	    examine = new;
+	if ((gn->type & OP_DOUBLEDEP) && glist_num(&gn->cohorts) > 0) {
+	    /*
+	     * Prepend all the 'cohorts' to the list of things to examine.
+	     * The old code here was equivalent to:
+	     *    examine = concat(gn->cohorts, examine)
+	     * but described this for some reason as "appending".
+	     *
+	     * XXX: this is a silly way of doing things when examine is
+	     * an array.
+	     */
+	    unsigned i;
+
+	    for (i=glist_num(&gn->cohorts); i-- > 0; ) {
+		glist_insert(&examine, 0);
+		glist_set(&examine, 0, glist_get(&gn->cohorts, i));
+	    }
 	}
 
 	/*
@@ -1346,10 +1385,11 @@ Make_ExpandUse(Lst targs)
 	}
 
 	if (gn->unmade != 0)
-	    Lst_ForEach(gn->children, MakeAddChild, examine);
+	    Lst_ForEach(gn->children, MakeAddChild2, &examine);
     }
 
-    Lst_Destroy(examine, NULL);
+    glist_setsize(&examine, 0);
+    glist_cleanup(&examine);
 }
 
 /*-
@@ -1404,7 +1444,7 @@ Make_ProcessWait(Lst targs)
     GNode  *pgn;	/* 'parent' node we are examining */
     GNode  *cgn;	/* Each child in turn */
     LstNode owln;	/* Previous .WAIT node */
-    Lst    examine; 	/* List of targets to examine */
+    GList   examine; 	/* List of targets to examine */
     LstNode ln;
 
     /*
@@ -1424,11 +1464,12 @@ Make_ProcessWait(Lst targs)
     /* Start building with the 'dummy' .MAIN' node */
     MakeBuildChild(pgn, NULL);
 
-    examine = Lst_Init(FALSE);
-    Lst_AtEnd(examine, pgn);
+    glist_init(&examine);
+    glist_add(&examine, pgn, NULL);
 
-    while (!Lst_IsEmpty (examine)) {
-	pgn = Lst_DeQueue(examine);
+    while (glist_num(&examine) > 0) {
+	pgn = glist_get(&examine, 0);
+	glist_remove(&examine, 0);
    
 	/* We only want to process each child-list once */
 	if (pgn->flags & DONE_WAIT)
@@ -1437,12 +1478,22 @@ Make_ProcessWait(Lst targs)
 	if (DEBUG(MAKE))
 	    fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name);
 
-	if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts)) {
-	    /* Append all the 'cohorts' to the list of things to examine */
-	    Lst new;
-	    new = Lst_Duplicate(pgn->cohorts, NULL);
-	    Lst_Concat(new, examine, LST_CONCLINK);
-	    examine = new;
+	if ((pgn->type & OP_DOUBLEDEP) && glist_num(&pgn->cohorts) > 0) {
+	    /*
+	     * Prepend all the 'cohorts' to the list of things to examine.
+	     * The old code here was equivalent to:
+	     *    examine = concat(gn->cohorts, examine)
+	     * but described this for some reason as "appending".
+	     *
+	     * XXX: this is a silly way of doing things when examine is
+	     * an array.
+	     */
+	    unsigned i;
+
+	    for (i=glist_num(&pgn->cohorts); i-- > 0; ) {
+		glist_insert(&examine, 0);
+		glist_set(&examine, 0, glist_get(&pgn->cohorts, i));
+	    }
 	}
 
 	owln = Lst_First(pgn->children);
@@ -1454,13 +1505,14 @@ Make_ProcessWait(Lst targs)
 		Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn);
 		owln = ln;
 	    } else {
-		Lst_AtEnd(examine, cgn);
+		glist_add(&examine, cgn, NULL);
 	    }
 	}
 	Lst_Close(pgn->children);
     }
 
-    Lst_Destroy(examine, NULL);
+    glist_setsize(&examine, 0);
+    glist_cleanup(&examine);
 }
 
 /*-
Index: othersrc/usr.bin/dholland-make2/suff.c
diff -u othersrc/usr.bin/dholland-make2/suff.c:1.3 othersrc/usr.bin/dholland-make2/suff.c:1.4
--- othersrc/usr.bin/dholland-make2/suff.c:1.3	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/suff.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.3 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: suff.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include	  "hash.h"
 #include	  "dir.h"
 
-MAKE_RCSID("$NetBSD: suff.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.4 2013/03/04 08:47:08 dholland Exp $");
 
 static Lst       sufflist;	/* Lst of suffixes */
 #ifdef CLEANUP
@@ -746,8 +746,9 @@ Suff_EndTransform(void *gnp, void *dummy
 {
     GNode *gn = (GNode *)gnp;
 
-    if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts))
-	gn = (GNode *)Lst_Datum(Lst_Last(gn->cohorts));
+    if ((gn->type & OP_DOUBLEDEP) && glist_num(&gn->cohorts) > 0) {
+	gn = glist_get(&gn->cohorts, glist_num(&gn->cohorts) - 1);
+    }
     if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
 	Lst_IsEmpty(gn->children))
     {
Index: othersrc/usr.bin/dholland-make2/targ.c
diff -u othersrc/usr.bin/dholland-make2/targ.c:1.3 othersrc/usr.bin/dholland-make2/targ.c:1.4
--- othersrc/usr.bin/dholland-make2/targ.c:1.3	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/targ.c	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.3 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: targ.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -127,7 +127,7 @@
 #include	  "hash.h"
 #include	  "dir.h"
 
-MAKE_RCSID("$NetBSD: targ.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.4 2013/03/04 08:47:08 dholland Exp $");
 
 static Lst        allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -245,7 +245,7 @@ Targ_NewGN(const char *name)
     gn->mtime =		0;
     gn->cmgn =		NULL;
     glist_init(&gn->iParents);
-    gn->cohorts =   	Lst_Init(FALSE);
+    glist_init(&gn->cohorts);
     gn->parents =   	Lst_Init(FALSE);
     gn->children =  	Lst_Init(FALSE);
     gn->order_pred =  	Lst_Init(FALSE);
@@ -293,7 +293,8 @@ TargFreeGN(void *gnp)
 
     glist_setsize(&gn->iParents, 0);
     glist_cleanup(&gn->iParents);
-    Lst_Destroy(gn->cohorts, NULL);
+    glist_setsize(&gn->cohorts, 0);
+    glist_cleanup(&gn->cohorts);
     Lst_Destroy(gn->parents, NULL);
     Lst_Destroy(gn->children, NULL);
     Lst_Destroy(gn->order_succ, NULL);
@@ -695,7 +696,11 @@ Targ_PrintNode(void *gnp, void *passp)
 	Lst_ForEach(gn->commands, Targ_PrintCmd, NULL);
 	fprintf(debug_file, "\n\n");
 	if (gn->type & OP_DOUBLEDEP) {
-	    Lst_ForEach(gn->cohorts, Targ_PrintNode, &pass);
+	    unsigned i;
+
+	    for (i=0; i<glist_num(&gn->cohorts); i++) {
+		Targ_PrintNode(glist_get(&gn->cohorts, i), &pass);
+	    }
 	}
     }
     return (0);
@@ -791,9 +796,13 @@ static int
 TargPropagateNode(void *gnp, void *junk MAKE_ATTR_UNUSED)
 {
     GNode	  *gn = (GNode *)gnp;
+    unsigned i;
 
-    if (gn->type & OP_DOUBLEDEP)
-	Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
+    if (gn->type & OP_DOUBLEDEP) {
+	for (i=0; i<glist_num(&gn->cohorts); i++) {
+	    TargPropagateCohort(glist_get(&gn->cohorts, i), gnp);
+	}
+    }
     return (0);
 }
 

Index: othersrc/usr.bin/dholland-make2/nonints.h
diff -u othersrc/usr.bin/dholland-make2/nonints.h:1.1.1.1 othersrc/usr.bin/dholland-make2/nonints.h:1.2
--- othersrc/usr.bin/dholland-make2/nonints.h:1.1.1.1	Mon Feb 25 01:33:04 2013
+++ othersrc/usr.bin/dholland-make2/nonints.h	Mon Mar  4 08:47:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.1.1.1 2013/02/25 01:33:04 dholland Exp $	*/
+/*	$NetBSD: nonints.h,v 1.2 2013/03/04 08:47:08 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@ void Parse_File(const char *, int);
 void Parse_Init(void);
 void Parse_End(void);
 void Parse_SetInput(const char *, int, int, char *(*)(void *, size_t *), void *);
-Lst Parse_MainName(void);
+void Parse_MainName(GList *);
 
 /* str.c */
 char *str_concat(const char *, const char *, int);

Reply via email to