Module Name:    othersrc
Committed By:   dholland
Date:           Tue Mar  5 03:32:08 UTC 2013

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

Log Message:
more arrays; fewer lists.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 othersrc/usr.bin/dholland-make2/arch.c \
    othersrc/usr.bin/dholland-make2/compat.c \
    othersrc/usr.bin/dholland-make2/main.c \
    othersrc/usr.bin/dholland-make2/parse.c
cvs rdiff -u -r1.3 -r1.4 othersrc/usr.bin/dholland-make2/cond.c \
    othersrc/usr.bin/dholland-make2/nonints.h
cvs rdiff -u -r1.4 -r1.5 othersrc/usr.bin/dholland-make2/dir.c \
    othersrc/usr.bin/dholland-make2/graph.h
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/dholland-make2/dir.h
cvs rdiff -u -r1.6 -r1.7 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.8 -r1.9 othersrc/usr.bin/dholland-make2/make.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/arch.c
diff -u othersrc/usr.bin/dholland-make2/arch.c:1.5 othersrc/usr.bin/dholland-make2/arch.c:1.6
--- othersrc/usr.bin/dholland-make2/arch.c:1.5	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/arch.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.5 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: arch.c,v 1.6 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -137,7 +137,7 @@
 #include    "dir.h"
 #include    "config.h"
 
-MAKE_RCSID("$NetBSD: arch.c,v 1.5 2013/03/05 01:44:34 dholland Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.6 2013/03/05 03:32:08 dholland Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -228,7 +228,7 @@ ArchFree(Arch *a)
  *-----------------------------------------------------------------------
  */
 ReturnStatus
-Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
+Arch_ParseArchive(char **linePtr, GList *nodeList, GNode *ctxt)
 {
     char	    *cp;	    /* Pointer into line */
     GNode	    *gn;     	    /* New node */
@@ -352,7 +352,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 	    /*
 	     * Now form an archive spec and recurse to deal with nested
 	     * variables and multi-word variable values.... The results
-	     * are just placed at the end of the nodeLst we're returning.
+	     * are just placed at the end of the node list we're returning.
 	     */
 	    sz = strlen(memName)+strlen(libName)+3;
 	    buf = sacrifice = bmake_malloc(sz);
@@ -372,9 +372,9 @@ Arch_ParseArchive(char **linePtr, Lst no
 		    return(FAILURE);
 		} else {
 		    gn->type |= OP_ARCHV;
-		    (void)Lst_AtEnd(nodeLst, gn);
+		    glist_add(nodeList, gn, NULL);
 		}
-	    } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
+	    } else if (Arch_ParseArchive(&sacrifice, nodeList, ctxt)!=SUCCESS) {
 		/*
 		 * Error in nested call -- free buffer and return FAILURE
 		 * ourselves.
@@ -387,14 +387,17 @@ Arch_ParseArchive(char **linePtr, Lst no
 	     */
 	    free(buf);
 	} else if (Dir_HasWildcards(memName)) {
-	    Lst	  members = Lst_Init(FALSE);
-	    char  *member;
+	    struct stringarray members;
+	    char *member;
+	    unsigned i;
 	    size_t sz = MAXPATHLEN, nsz;
 	    nameBuf = bmake_malloc(sz);
 
-	    Dir_Expand(memName, &dirSearchPath, members);
-	    while (!Lst_IsEmpty(members)) {
-		member = (char *)Lst_DeQueue(members);
+	    stringarray_init(&members);
+
+	    Dir_Expand(memName, &dirSearchPath, &members);
+	    for (i=0; i<stringarray_num(&members); i++) {
+		member = stringarray_get(&members, i);
 		nsz = strlen(libName) + strlen(member) + 3;
 		if (sz > nsz)
 		    nameBuf = bmake_realloc(nameBuf, sz = nsz * 2);
@@ -414,10 +417,11 @@ Arch_ParseArchive(char **linePtr, Lst no
 		     * end of the provided list.
 		     */
 		    gn->type |= OP_ARCHV;
-		    (void)Lst_AtEnd(nodeLst, gn);
+		    glist_add(nodeList, gn, NULL);
 		}
 	    }
-	    Lst_Destroy(members, NULL);
+	    stringarray_setsize(&members, 0);
+	    stringarray_cleanup(&members);
 	    free(nameBuf);
 	} else {
 	    size_t	sz = strlen(libName) + strlen(memName) + 3;
@@ -436,7 +440,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 		 * provided list.
 		 */
 		gn->type |= OP_ARCHV;
-		(void)Lst_AtEnd(nodeLst, gn);
+		glist_add(nodeList, gn, NULL);
 	    }
 	}
 	if (doSubst) {
Index: othersrc/usr.bin/dholland-make2/compat.c
diff -u othersrc/usr.bin/dholland-make2/compat.c:1.5 othersrc/usr.bin/dholland-make2/compat.c:1.6
--- othersrc/usr.bin/dholland-make2/compat.c:1.5	Mon Mar  4 23:03:41 2013
+++ othersrc/usr.bin/dholland-make2/compat.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.5 2013/03/04 23:03:41 dholland Exp $	*/
+/*	$NetBSD: compat.c,v 1.6 2013/03/05 03:32: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.5 2013/03/04 23:03:41 dholland Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.6 2013/03/05 03:32:08 dholland Exp $");
 
 /*
  * The following array is used to make a fast determination of which
@@ -685,7 +685,7 @@ cohorts:
  *-----------------------------------------------------------------------
  */
 void
-Compat_Run(Lst targs)
+Compat_Run(GList *targs)
 {
     GNode   	  *gn = NULL;/* Current root target */
     int	    	  errors;   /* Number of targets not remade due to errors */
@@ -739,8 +739,10 @@ Compat_Run(Lst targs)
      *	    	  	    could not be made due to errors.
      */
     errors = 0;
-    while (!Lst_IsEmpty (targs)) {
-	gn = (GNode *)Lst_DeQueue(targs);
+    /* XXX this should be an ordinary iteration */
+    while (glist_num(targs) > 0) {
+	gn = glist_get(targs, 0);
+	glist_remove(targs, 0);
 	Compat_Make(gn, gn);
 
 	if (gn->made == UPTODATE) {
Index: othersrc/usr.bin/dholland-make2/main.c
diff -u othersrc/usr.bin/dholland-make2/main.c:1.5 othersrc/usr.bin/dholland-make2/main.c:1.6
--- othersrc/usr.bin/dholland-make2/main.c:1.5	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/main.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.5 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.6 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -128,14 +128,14 @@
 
 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.5 2013/03/05 01:44:34 dholland Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.6 2013/03/05 03:32:08 dholland Exp $");
 
 
 #ifndef	DEFMAXLOCAL
 #define	DEFMAXLOCAL DEFMAXJOBS
 #endif	/* DEFMAXLOCAL */
 
-Lst			create;		/* Targets to be made */
+struct stringarray	create;		/* Targets to be made */
 time_t			now;		/* Time at start of make */
 GNode			*DEFAULT;	/* .DEFAULT node */
 Boolean			allPrecious;	/* .PRECIOUS given on line by itself */
@@ -564,7 +564,7 @@ rearg:	
 				Punt("illegal (null) argument.");
 			if (*argv[1] == '-' && !dashDash)
 				goto rearg;
-			(void)Lst_AtEnd(create, bmake_strdup(argv[1]));
+			stringarray_add(&create, bmake_strdup(argv[1]), NULL);
 		}
 
 	return;
@@ -755,7 +755,7 @@ MakeMode(const char *mode)
 int
 main(int argc, char **argv)
 {
-	Lst targs;	/* target nodes to create -- passed to Make_Init */
+	GList *targs;	/* target nodes to create -- passed to Make_Init */
 	Boolean outOfDate = FALSE; 	/* FALSE if all targets up to date */
 	struct stat sb, sa;
 	char *p1, *path, *pwd;
@@ -763,7 +763,7 @@ main(int argc, char **argv)
     	const char *machine = getenv("MACHINE");
 	const char *machine_arch = getenv("MACHINE_ARCH");
 	char *syspath = getenv("MAKESYSPATH");
-	Lst sysMkPath;			/* Path of sys.mk */
+	struct stringarray sysMkPath;			/* Path of sys.mk */
 	char *cp = NULL, *start;
 					/* avoid faults on read-only strings */
 	static char defsyspath[] = _PATH_DEFSYSPATH;
@@ -864,7 +864,7 @@ main(int argc, char **argv)
 		VAR_GLOBAL, 0);
 	Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL, 0);
 
-	create = Lst_Init(FALSE);
+	stringarray_init(&create);
 	makefiles = Lst_Init(FALSE);
 	printVars = FALSE;
 	debugVflag = FALSE;
@@ -1049,14 +1049,14 @@ main(int argc, char **argv)
 	 * created. If none specified, make the variable empty -- the parser
 	 * will fill the thing in with the default or .MAIN target.
 	 */
-	if (!Lst_IsEmpty(create)) {
-		LstNode ln;
-
-		for (ln = Lst_First(create); ln != NULL;
-		    ln = Lst_Succ(ln)) {
-			char *name = (char *)Lst_Datum(ln);
-
-			Var_Append(".TARGETS", name, VAR_GLOBAL);
+	if (stringarray_num(&create) > 0) {
+		char *name;
+		unsigned i, num;
+
+		num = stringarray_num(&create);
+		for (i=0; i<num; i++) {
+		    name = stringarray_get(&create, i);
+		    Var_Append(".TARGETS", name, VAR_GLOBAL);
 		}
 	} else
 		Var_Set(".TARGETS", "", VAR_GLOBAL, 0);
@@ -1097,19 +1097,32 @@ main(int argc, char **argv)
 	 * makefile and Makefile, in that order, if it wasn't.
 	 */
 	if (!noBuiltins) {
-		LstNode ln;
+		unsigned i, num;
+		char *f;
 
-		sysMkPath = Lst_Init(FALSE);
+		stringarray_init(&sysMkPath);
 		Dir_Expand(_PATH_DEFSYSMK,
 			   patharray_num(&sysIncPath) == 0 ? &defIncPath : &sysIncPath,
-			   sysMkPath);
-		if (Lst_IsEmpty(sysMkPath))
+			   &sysMkPath);
+		if (stringarray_num(&sysMkPath) == 0) {
 			Fatal("%s: no system rules (%s).", progname,
 			    _PATH_DEFSYSMK);
-		ln = Lst_Find(sysMkPath, NULL, ReadMakefile);
-		if (ln == NULL)
+		}
+
+		num = stringarray_num(&sysMkPath);
+		for (i=0; i<num; i++) {
+		    f = stringarray_get(&sysMkPath, i);
+		    if (ReadMakefile(f, NULL) == 0) {
+			/* success; stop trying */
+			break;
+		    }
+		}
+		if (i == num) {
+			/* none succeeded */
+			/* XXX: should warn on any that exist but won't read */
 			Fatal("%s: cannot open %s.", progname,
-			    (char *)Lst_Datum(ln));
+			    stringarray_get(&sysMkPath, 0));
+		}
 	}
 
 	if (!Lst_IsEmpty(makefiles)) {
@@ -1237,16 +1250,10 @@ main(int argc, char **argv)
 		 * we consult the parsing module to find the main target(s)
 		 * to create.
 		 */
-		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);
+		if (stringarray_num(&create) == 0) {
+			targs = Parse_MainName();
 		} else {
-			targs = Targ_FindList(create, TARG_CREATE);
+			targs = Targ_FindList(&create, TARG_CREATE);
 		}
 
 		if (!compatMake) {
@@ -1274,10 +1281,21 @@ main(int argc, char **argv)
 	}
 
 #ifdef CLEANUP
-	Lst_Destroy(targs, NULL);
+	glist_setsize(targs, 0);
+	/*
+	 * targs[] was malloc'd and returned by Parse_MainName and/or
+	 * Targ_FindList, so needs to be _destroy'd.
+	 */
+	glist_destroy(targs);
+
 	Lst_Destroy(variables, NULL);
 	Lst_Destroy(makefiles, NULL);
-	Lst_Destroy(create, (FreeProc *)free);
+	num = stringarray_num(&create);
+	for (i=0; i<num; i++) {
+	    free(stringarray_get(&create, i));
+	}
+	stringarray_setsize(&create, 0);
+	stringarray_cleanup(&create);
 #endif
 
 	/* print the graph now it's been processed if the user requested it */
Index: othersrc/usr.bin/dholland-make2/parse.c
diff -u othersrc/usr.bin/dholland-make2/parse.c:1.5 othersrc/usr.bin/dholland-make2/parse.c:1.6
--- othersrc/usr.bin/dholland-make2/parse.c:1.5	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/parse.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.5 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: parse.c,v 1.6 2013/03/05 03:32: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.5 2013/03/05 01:44:34 dholland Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.6 2013/03/05 03:32:08 dholland Exp $");
 
 ////////////////////////////////////////////////////////////
 // types and constants
@@ -228,7 +228,7 @@ static GNode *mainNode;
 // eval state
 
 /* targets we're working on */
-static Lst targets;
+static GList targets;
 
 #ifdef CLEANUP
 /* command lines for targets */
@@ -341,12 +341,8 @@ static void ParseErrorInternal(const cha
 static void ParseVErrorInternal(FILE *, const char *, size_t, int, const char *, va_list)
     MAKE_ATTR_PRINTFLIKE(5, 0);
 static int ParseFindKeyword(const char *);
-static int ParseLinkSrc(void *, void *);
-static int ParseDoOp(void *, void *);
 static void ParseDoSrc(int, const char *);
-static int ParseFindMain(void *, void *);
 static void ParseDoDependency(char *);
-static int ParseAddCmd(void *, void *);
 static void ParseHasCommands(void *);
 static void ParseDoInclude(char *);
 static void ParseSetParseFile(const char *);
@@ -813,7 +809,7 @@ ParseMessage(char *line)
  *	cgpn		The child node
  *
  * Results:
- *	Always = 0
+ *	none
  *
  * Side Effects:
  *	New elements are added to the parents list of cgn and the
@@ -821,12 +817,9 @@ ParseMessage(char *line)
  *	to reflect the additional child.
  *---------------------------------------------------------------------
  */
-static int
-ParseLinkSrc(void *pgnp, void *cgnp)
+static void
+ParseLinkSrc(GNode *pgn, GNode *cgn)
 {
-    GNode          *pgn = (GNode *)pgnp;
-    GNode          *cgn = (GNode *)cgnp;
-
     if ((pgn->type & OP_DOUBLEDEP) && glist_num(&pgn->cohorts) > 0) {
 	pgn = glist_get(&pgn->cohorts, glist_num(&pgn->cohorts) - 1);
     }
@@ -839,7 +832,6 @@ ParseLinkSrc(void *pgnp, void *cgnp)
 	Targ_PrintNode(pgn, 0);
 	Targ_PrintNode(cgn, 0);
     }
-    return (0);
 }
 
 /*-
@@ -855,18 +847,16 @@ ParseLinkSrc(void *pgnp, void *cgnp)
  *	opp		The operator to apply
  *
  * Results:
- *	Always 0
+ *	none
  *
  * Side Effects:
  *	The type field of the node is altered to reflect any new bits in
  *	the op.
  *---------------------------------------------------------------------
  */
-static int
-ParseDoOp(void *gnp, void *opp)
+static void
+ParseDoOp(GNode *gn, int op)
 {
-    GNode          *gn = (GNode *)gnp;
-    int             op = *(int *)opp;
     /*
      * If the dependency mask of the operator and the node don't match and
      * the node has actually had an operator applied to it before, and
@@ -876,7 +866,7 @@ ParseDoOp(void *gnp, void *opp)
 	!OP_NOP(gn->type) && !OP_NOP(op))
     {
 	Parse_Error(PARSE_FATAL, "Inconsistent operator for %s", gn->name);
-	return (1);
+	return;
     }
 
     if ((op == OP_DOUBLEDEP) && ((gn->type & OP_OPMASK) == OP_DOUBLEDEP)) {
@@ -917,8 +907,6 @@ ParseDoOp(void *gnp, void *opp)
 	 */
 	gn->type |= op;
     }
-
-    return (0);
 }
 
 /*-
@@ -948,13 +936,16 @@ ParseDoSrc(int tOp, const char *src)
     GNode	*gn = NULL;
     static int wait_number = 0;
     char wait_src[16];
+    unsigned i;
 
     if (*src == '.' && isupper ((unsigned char)src[1])) {
 	int keywd = ParseFindKeyword(src);
 	if (keywd != -1) {
 	    int op = parseKeywords[keywd].op;
 	    if (op != 0) {
-		Lst_ForEach(targets, ParseDoOp, &op);
+		for (i=0; i<glist_num(&targets); i++) {
+		    ParseDoOp(glist_get(&targets, i), op);
+		}
 		return;
 	    }
 	    if (parseKeywords[keywd].spec == Wait) {
@@ -970,7 +961,9 @@ ParseDoSrc(int tOp, const char *src)
 		snprintf(wait_src, sizeof wait_src, ".WAIT_%u", ++wait_number);
 		gn = Targ_FindNode(wait_src, TARG_NOHASH);
 		gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
-		Lst_ForEach(targets, ParseLinkSrc, gn);
+		for (i=0; i<glist_num(&targets); i++) {
+		    ParseLinkSrc(glist_get(&targets, i), gn);
+		}
 		return;
 	    }
 	}
@@ -981,12 +974,12 @@ ParseDoSrc(int tOp, const char *src)
 	/*
 	 * If we have noted the existence of a .MAIN, it means we need
 	 * to add the sources of said target to the list of things
-	 * to create. The string 'src' is likely to be free, so we
+	 * to create. The string 'src' is likely to be freed, so we
 	 * must make a new copy of it. Note that this will only be
 	 * invoked if the user didn't specify a target on the command
 	 * line. This is to allow #ifmake's to succeed, or something...
 	 */
-	(void)Lst_AtEnd(create, bmake_strdup(src));
+	stringarray_add(&create, bmake_strdup(src), NULL);
 	/*
 	 * Add the name to the .TARGETS variable as well, so the user can
 	 * employ that, if desired.
@@ -1034,7 +1027,9 @@ ParseDoSrc(int tOp, const char *src)
 	if (tOp) {
 	    gn->type |= tOp;
 	} else {
-	    Lst_ForEach(targets, ParseLinkSrc, gn);
+	    for (i=0; i<glist_num(&targets); i++) {
+		ParseLinkSrc(glist_get(&targets, i), gn);
+	    }
 	}
 	break;
     }
@@ -1059,15 +1054,14 @@ ParseDoSrc(int tOp, const char *src)
  *-----------------------------------------------------------------------
  */
 static int
-ParseFindMain(void *gnp, void *dummy)
+ParseFindMain(GNode *gn)
 {
-    GNode   	  *gn = (GNode *)gnp;
     if ((gn->type & OP_NOTARGET) == 0) {
 	mainNode = gn;
 	Targ_SetMain(gn);
-	return (dummy ? 1 : 1);
+	return 1;
     } else {
-	return (dummy ? 0 : 0);
+	return 0;
     }
 }
 
@@ -1118,11 +1112,12 @@ ParseDoDependency(char *line)
     /* List of search paths to alter when parsing a list of .PATH targets */
     struct patharrayarray paths;
     int	    	    tOp;    	/* operator from special target */
-    Lst	    	    sources;	/* list of archive source names after
+    GList	    sources;	/* list of archive source names after
 				 * expansion */
-    Lst 	    curTargs;	/* list of target names to be found and added
-				 * to the targets list */
+    /* list of target names to be found and added to the targets list */
+    struct stringarray curTargs;
     char	   *lstart = line;
+    unsigned i;
 
     if (DEBUG(PARSE))
 	fprintf(debug_file, "ParseDoDependency(%s)\n", line);
@@ -1131,7 +1126,7 @@ ParseDoDependency(char *line)
     specType = Not;
     patharrayarray_init(&paths);
 
-    curTargs = Lst_Init(FALSE);
+    stringarray_init(&curTargs);
 
     do {
 	for (cp = line; *cp && (ParseIsEscaped(lstart, cp) ||
@@ -1168,7 +1163,7 @@ ParseDoDependency(char *line)
 	     * went well and FAILURE if there was an error in the
 	     * specification. On error, line should remain untouched.
 	     */
-	    if (Arch_ParseArchive(&line, targets, VAR_CMD) != SUCCESS) {
+	    if (Arch_ParseArchive(&line, &targets, VAR_CMD) != SUCCESS) {
 		Parse_Error(PARSE_FATAL,
 			     "Error in archive specification: \"%s\"", line);
 		goto out;
@@ -1250,7 +1245,7 @@ ParseDoDependency(char *line)
 			patharrayarray_add(&paths, &dirSearchPath, NULL);
 			break;
 		    case Main:
-			if (!Lst_IsEmpty(create)) {
+			if (stringarray_num(&create) > 0) {
 			    specType = Not;
 			}
 			break;
@@ -1260,12 +1255,12 @@ ParseDoDependency(char *line)
 		    case Interrupt:
 			gn = Targ_FindNode(line, TARG_CREATE);
 			gn->type |= OP_NOTMAIN|OP_SPECIAL;
-			(void)Lst_AtEnd(targets, gn);
+			glist_add(&targets, gn, NULL);
 			break;
 		    case Default:
 			gn = Targ_NewGN(".DEFAULT");
 			gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
-			(void)Lst_AtEnd(targets, gn);
+			glist_add(&targets, gn, NULL);
 			DEFAULT = gn;
 			break;
 		    case NotParallel:
@@ -1319,18 +1314,18 @@ ParseDoDependency(char *line)
 		struct patharray emptyPath;
 
 		patharray_init(&emptyPath);
-		Dir_Expand(line, &emptyPath, curTargs);
+		Dir_Expand(line, &emptyPath, &curTargs);
 		patharray_cleanup(&emptyPath);
 	    } else {
 		/*
 		 * No wildcards, but we want to avoid code duplication,
 		 * so create a list with the word on it.
 		 */
-		(void)Lst_AtEnd(curTargs, line);
+		stringarray_add(&curTargs, line, NULL);
 	    }
 
-	    while(!Lst_IsEmpty(curTargs)) {
-		char	*targName = (char *)Lst_DeQueue(curTargs);
+	    for (i=0; i<stringarray_num(&curTargs); i++) {
+		char *targName = stringarray_get(&curTargs, i);
 
 		if (!Suff_IsTransform (targName)) {
 		    gn = Targ_FindNode(targName, TARG_CREATE);
@@ -1338,8 +1333,9 @@ ParseDoDependency(char *line)
 		    gn = Suff_AddTransform(targName);
 		}
 
-		(void)Lst_AtEnd(targets, gn);
+		glist_add(&targets, gn, NULL);
 	    }
+	    stringarray_setsize(&curTargs, 0);
 	} else if (specType == ExPath && *line != '.' && *line != '\0') {
 	    Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
 	}
@@ -1374,11 +1370,11 @@ ParseDoDependency(char *line)
 
     /*
      * Don't need the list of target names anymore...
+     * (but there shouldn't be anything in it here)
      */
-    Lst_Destroy(curTargs, NULL);
-    curTargs = NULL;
+    assert(stringarray_num(&curTargs) == 0);
 
-    if (!Lst_IsEmpty(targets)) {
+    if (glist_num(&targets) > 0) {
 	switch(specType) {
 	    default:
 		Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored");
@@ -1421,7 +1417,9 @@ ParseDoDependency(char *line)
 
     cp++;			/* Advance beyond operator */
 
-    Lst_ForEach(targets, ParseDoOp, &op);
+    for (i=0; i<glist_num(&targets); i++) {
+	ParseDoOp(glist_get(&targets, i), op);
+    }
 
     /*
      * Get to the first source
@@ -1594,18 +1592,20 @@ ParseDoDependency(char *line)
 	    }
 
 	    if (*cp == LPAREN) {
-		sources = Lst_Init(FALSE);
-		if (Arch_ParseArchive(&line, sources, VAR_CMD) != SUCCESS) {
+		glist_init(&sources);
+		if (Arch_ParseArchive(&line, &sources, VAR_CMD) != SUCCESS) {
 		    Parse_Error(PARSE_FATAL,
 				 "Error in source archive spec \"%s\"", line);
+		    glist_cleanup(&sources);
 		    goto out;
 		}
 
-		while (!Lst_IsEmpty (sources)) {
-		    gn = (GNode *)Lst_DeQueue(sources);
+		for (i=0; i<glist_num(&sources); i++) {
+		    gn = glist_get(&sources, i);
 		    ParseDoSrc(tOp, gn->name);
 		}
-		Lst_Destroy(sources, NULL);
+		glist_setsize(&sources, 0);
+		glist_cleanup(&sources);
 		cp = line;
 	    } else {
 		if (*cp) {
@@ -1629,12 +1629,15 @@ ParseDoDependency(char *line)
 	 * the first dependency line that is actually a real target
 	 * (i.e. isn't a .USE or .EXEC rule) to be made.
 	 */
-	Lst_ForEach(targets, ParseFindMain, NULL);
+	for (i=0; i<glist_num(&targets); i++) {
+	    if (ParseFindMain(glist_get(&targets, i))) {
+		break;
+	    }
+	}
     }
 
 out:
-    if (curTargs)
-	    Lst_Destroy(curTargs, NULL);
+    stringarray_cleanup(&curTargs);
 }
 
 /*-
@@ -1906,9 +1909,8 @@ Parse_DoVar(char *line, GNode *ctxt)
  *	A new element is added to the commands list of the node.
  */
 static int
-ParseAddCmd(void *gnp, void *cmd)
+ParseAddCmd(GNode *gn, char *cmd)
 {
-    GNode *gn = (GNode *)gnp;
 
     /* Add to last (ie current) cohort for :: targets */
     if ((gn->type & OP_DOUBLEDEP) && glist_num(&gn->cohorts) > 0) {
@@ -2726,10 +2728,18 @@ ParseReadLine(void)
 static void
 ParseFinishLine(void)
 {
+    unsigned i;
+
     if (inLine) {
-	Lst_ForEach(targets, Suff_EndTransform, NULL);
-	Lst_Destroy(targets, ParseHasCommands);
-	targets = NULL;
+	for (i=0; i<glist_num(&targets); i++) {
+	    if (Suff_EndTransform(glist_get(&targets, i), NULL)) {
+		break;
+	    }
+	}
+	for (i=0; i<glist_num(&targets); i++) {
+	    ParseHasCommands(glist_get(&targets, i));
+	}
+	glist_setsize(&targets, 0);
 	inLine = FALSE;
     }
 }
@@ -2761,6 +2771,7 @@ Parse_File(const char *name, int fd)
     char	  *cp;		/* pointer into the line */
     char          *line;	/* the line we're working on */
     struct loadedfile *lf;
+    unsigned i;
 
     lf = loadfile(name, fd);
 
@@ -2841,9 +2852,11 @@ Parse_File(const char *name, int fd)
 		     * in a dependency spec, add the command to the list of
 		     * commands of all targets in the dependency spec
 		     */
-		    if (targets) {
+		    if (glist_num(&targets) > 0) {
 			cp = bmake_strdup(cp);
-			Lst_ForEach(targets, ParseAddCmd, cp);
+			for (i=0; i<glist_num(&targets); i++) {
+			    ParseAddCmd(glist_get(&targets, i), cp);
+			}
 #ifdef CLEANUP
 			Lst_AtEnd(targCmds, cp);
 #endif
@@ -2952,12 +2965,9 @@ Parse_File(const char *name, int fd)
 	    line = Var_Subst(NULL, line, VAR_CMD, TRUE);
 
 	    /*
-	     * Need a non-circular list for the target nodes
+	     * Clear the list of target nodes
 	     */
-	    if (targets)
-		Lst_Destroy(targets, NULL);
-
-	    targets = Lst_Init(FALSE);
+	    glist_setsize(&targets, 0);
 	    inLine = TRUE;
 
 	    ParseDoDependency(line);
@@ -3003,6 +3013,7 @@ Parse_Init(void)
     patharray_init(&sysIncPath);
     patharray_init(&defIncPath);
     includes = Lst_Init(FALSE);
+    glist_init(&targets);
 #ifdef CLEANUP
     targCmds = Lst_Init(FALSE);
 #endif
@@ -3013,8 +3024,8 @@ Parse_End(void)
 {
 #ifdef CLEANUP
     Lst_Destroy(targCmds, (FreeProc *)free);
-    if (targets)
-	Lst_Destroy(targets, NULL);
+    glist_setsize(&targets, 0);
+    glist_cleanup(&targets);
     Dir_ClearPath(&defIncPath);
     Dir_ClearPath(&sysIncPath);
     Dir_ClearPath(&parseIncPath);
@@ -3041,15 +3052,17 @@ Parse_End(void)
  *
  *-----------------------------------------------------------------------
  */
-void
-Parse_MainName(GList *mainList)
+GList *
+Parse_MainName(void)
 {
     unsigned i;
+    GList *mainList;
 
     if (mainNode == NULL) {
 	Punt("no target to make.");
     	/*NOTREACHED*/
     }
+    mainList = glist_create();
     glist_add(mainList, mainNode, NULL);
     if (mainNode->type & OP_DOUBLEDEP) {
 	for (i=0; i<glist_num(&mainNode->cohorts); i++) {
@@ -3057,6 +3070,7 @@ Parse_MainName(GList *mainList)
 	}
     }
     Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
+    return mainList;
 }
 
 /*-

Index: othersrc/usr.bin/dholland-make2/cond.c
diff -u othersrc/usr.bin/dholland-make2/cond.c:1.3 othersrc/usr.bin/dholland-make2/cond.c:1.4
--- othersrc/usr.bin/dholland-make2/cond.c:1.3	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/cond.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.3 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: cond.c,v 1.4 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -90,7 +90,7 @@
 #include    "dir.h"
 #include    "buf.h"
 
-MAKE_RCSID("$NetBSD: cond.c,v 1.3 2013/03/05 01:44:34 dholland Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.4 2013/03/05 03:32:08 dholland Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -140,7 +140,6 @@ typedef enum {
 static void CondPushBack(Token);
 static int CondGetArg(char **, char **, const char *);
 static Boolean CondDoDefined(int, const char *);
-static int CondStrMatch(const void *, const void *);
 static Boolean CondDoMake(int, const char *);
 static Boolean CondDoExists(int, const char *);
 static Boolean CondDoTarget(int, const char *);
@@ -337,26 +336,6 @@ CondDoDefined(int argLen MAKE_ATTR_UNUSE
 
 /*-
  *-----------------------------------------------------------------------
- * CondStrMatch --
- *	Front-end for Str_Match so it returns 0 on match and non-zero
- *	on mismatch. Callback function for CondDoMake via Lst_Find
- *
- * Results:
- *	0 if string matches pattern
- *
- * Side Effects:
- *	None
- *
- *-----------------------------------------------------------------------
- */
-static int
-CondStrMatch(const void *string, const void *pattern)
-{
-    return(!Str_Match(string, pattern));
-}
-
-/*-
- *-----------------------------------------------------------------------
  * CondDoMake --
  *	Handle the 'make' function for conditionals.
  *
@@ -371,7 +350,15 @@ CondStrMatch(const void *string, const v
 static Boolean
 CondDoMake(int argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    return Lst_Find(create, arg, CondStrMatch) != NULL;
+	unsigned i, num;
+
+	num = stringarray_num(&create);
+	for (i=0; i<num; i++) {
+	    if (Str_Match(stringarray_get(&create, i), arg)) {
+		return TRUE;
+	    }
+	}
+	return FALSE;
 }
 
 /*-
Index: othersrc/usr.bin/dholland-make2/nonints.h
diff -u othersrc/usr.bin/dholland-make2/nonints.h:1.3 othersrc/usr.bin/dholland-make2/nonints.h:1.4
--- othersrc/usr.bin/dholland-make2/nonints.h:1.3	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/nonints.h	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.3 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: nonints.h,v 1.4 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -73,7 +73,7 @@
  */
 
 /* arch.c */
-ReturnStatus Arch_ParseArchive(char **, Lst, GNode *);
+ReturnStatus Arch_ParseArchive(char **, GList *, GNode *);
 void Arch_Touch(GNode *);
 void Arch_TouchLib(GNode *);
 time_t Arch_MTime(GNode *);
@@ -86,7 +86,7 @@ int Arch_IsLib(GNode *);
 
 /* compat.c */
 int CompatRunCommand(void *, void *);
-void Compat_Run(Lst);
+void Compat_Run(GList *);
 int Compat_Make(void *, void *);
 
 /* cond.c */
@@ -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 *);
-void Parse_MainName(GList *);
+GList *Parse_MainName(void);
 
 /* str.c */
 char *str_concat(const char *, const char *, int);
@@ -160,16 +160,16 @@ void Suff_PrintAll(void);
 /* targ.c */
 void Targ_Init(void);
 void Targ_End(void);
-Lst Targ_List(void);
+GList *Targ_List(void);
 GNode *Targ_NewGN(const char *);
 GNode *Targ_FindNode(const char *, int);
-Lst Targ_FindList(Lst, int);
+GList *Targ_FindList(struct stringarray *, int);
 Boolean Targ_Ignore(GNode *);
 Boolean Targ_Silent(GNode *);
 Boolean Targ_Precious(GNode *);
 void Targ_SetMain(GNode *);
 int Targ_PrintCmd(void *, void *);
-int Targ_PrintNode(void *, void *);
+void Targ_PrintNode(GNode *, int *);
 char *Targ_FmtTime(time_t);
 void Targ_PrintType(int);
 void Targ_PrintGraph(int);

Index: othersrc/usr.bin/dholland-make2/dir.c
diff -u othersrc/usr.bin/dholland-make2/dir.c:1.4 othersrc/usr.bin/dholland-make2/dir.c:1.5
--- othersrc/usr.bin/dholland-make2/dir.c:1.4	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/dir.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.4 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: dir.c,v 1.5 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
  *	Dir_HasWildcards    Returns TRUE if the name given it needs to
  *	    	  	    be wildcard-expanded.
  *
- *	Dir_Expand	    Given a pattern and a path, return a Lst of names
+ *	Dir_Expand	    Given a pattern and a path, return a list of names
  *	    	  	    which match the pattern on the search path.
  *
  *	Dir_FindFile	    Searches for a file on a given search path.
@@ -137,10 +137,10 @@
 #include "hash.h"
 #include "dir.h"
 
-__RCSID("$NetBSD: dir.c,v 1.4 2013/03/05 01:44:34 dholland Exp $");
+__RCSID("$NetBSD: dir.c,v 1.5 2013/03/05 03:32:08 dholland Exp $");
 
 /*
- *	A search path consists of a Lst of Path structures. A Path structure
+ *	A search path consists of a list of Path structures. A Path structure
  *	has in it the name of the directory and a hash table of all the files
  *	in the directory. This is used to cut down on the number of system
  *	calls necessary to find implicit dependents and their like. Since
@@ -149,7 +149,7 @@ __RCSID("$NetBSD: dir.c,v 1.4 2013/03/05
  *	hampers the style of some makefiles, they must be changed.
  *
  *	A list of all previously-read directories is kept in the
- *	openDirectories Lst. This list is checked first before a directory
+ *	openDirectories list. This list is checked first before a directory
  *	is opened.
  *
  *	The need for the caching of whole directories is brought about by
@@ -237,8 +237,6 @@ static Hash_Table mtimes;   /* Results o
 			     * should be ok, but... */
 
 
-static int DirMatchFiles(const char *, Path *, Lst);
-static int DirPrintWord(void *, void *);
 static char *DirLookup(Path *, const char *, const char *, Boolean);
 static char *DirLookupSubdir(Path *, const char *);
 static char *DirFindDot(Boolean, const char *, const char *);
@@ -525,15 +523,15 @@ Dir_HasWildcards(char *name)
  *	expansion	Place to store the results
  *
  * Results:
- *	Always returns 0
+ *	none
  *
  * Side Effects:
  *	File names are added to the expansions lst. The directory will be
  *	fully hashed when this is done.
  *-----------------------------------------------------------------------
  */
-static int
-DirMatchFiles(const char *pattern, Path *p, Lst expansions)
+static void
+DirMatchFiles(const char *pattern, Path *p, struct stringarray *expansions)
 {
     Hash_Search	  search;   	/* Index into the directory's table */
     Hash_Entry	  *entry;   	/* Current entry in the table */
@@ -555,13 +553,13 @@ DirMatchFiles(const char *pattern, Path 
 	    ((entry->name[0] != '.') ||
 	     (pattern[0] == '.')))
 	{
-	    (void)Lst_AtEnd(expansions,
-			    (isDot ? bmake_strdup(entry->name) :
-			     str_concat(p->name, entry->name,
-					STR_ADDSLASH)));
+	    char *val;
+
+	    val = isDot ? bmake_strdup(entry->name) :
+		    str_concat(p->name, entry->name, STR_ADDSLASH);
+	    stringarray_add(expansions, val, NULL);
 	}
     }
-    return (0);
 }
 
 /*-
@@ -588,7 +586,7 @@ DirMatchFiles(const char *pattern, Path 
  */
 static void
 DirExpandCurly(const char *word, const char *brace,
-	       const struct patharray *path, Lst expansions)
+	       const struct patharray *path, struct stringarray *expansions)
 {
     const char   *end;	    	/* Character after the closing brace */
     const char   *cp;	    	/* Current position in brace clause */
@@ -669,7 +667,7 @@ DirExpandCurly(const char *word, const c
 	     * Hit the end w/o finding any wildcards, so stick the expansion
 	     * on the end of the list.
 	     */
-	    (void)Lst_AtEnd(expansions, file);
+	    stringarray_add(expansions, file, NULL);
 	} else {
 	next:
 	    free(file);
@@ -700,7 +698,8 @@ DirExpandCurly(const char *word, const c
  *-----------------------------------------------------------------------
  */
 static void
-DirExpandInt(const char *word, const struct patharray *path, Lst expansions)
+DirExpandInt(const char *word, const struct patharray *path,
+	     struct stringarray *expansions)
 {
     Path	  *p;	    	/* Directory in the node */
     unsigned i;
@@ -713,28 +712,6 @@ DirExpandInt(const char *word, const str
 
 /*-
  *-----------------------------------------------------------------------
- * DirPrintWord --
- *	Print a word in the list of expansions. Callback for Dir_Expand
- *	when DEBUG(DIR), via Lst_ForEach.
- *
- * Results:
- *	=== 0
- *
- * Side Effects:
- *	The passed word is printed, followed by a space.
- *
- *-----------------------------------------------------------------------
- */
-static int
-DirPrintWord(void *word, void *dummy)
-{
-    fprintf(debug_file, "%s ", (char *)word);
-
-    return(dummy ? 0 : 0);
-}
-
-/*-
- *-----------------------------------------------------------------------
  * Dir_Expand  --
  *	Expand the given word into a list of words by globbing it looking
  *	in the directories on the given search path.
@@ -754,9 +731,11 @@ DirPrintWord(void *word, void *dummy)
  *-----------------------------------------------------------------------
  */
 void
-Dir_Expand(const char *word, const struct patharray *path, Lst expansions)
+Dir_Expand(const char *word, const struct patharray *path,
+	   struct stringarray *expansions)
 {
     const char    	  *cp;
+    unsigned i;
 
     if (DEBUG(DIR)) {
 	fprintf(debug_file, "Expanding \"%s\"... ", word);
@@ -853,7 +832,9 @@ Dir_Expand(const char *word, const struc
 	}
     }
     if (DEBUG(DIR)) {
-	Lst_ForEach(expansions, DirPrintWord, NULL);
+	for (i=0; i<stringarray_num(expansions); i++) {
+	    fprintf(debug_file, "%s ", stringarray_get(expansions, i));
+	}
 	fprintf(debug_file, "\n");
     }
 }
@@ -1047,7 +1028,7 @@ DirFindDot(Boolean hasSlash MAKE_ATTR_UN
  *
  * Input:
  *	name		the file to find
- *	path		the Lst of directories to search
+ *	path		the list of directories to search
  *
  * Results:
  *	The path to the file or NULL. This path is guaranteed to be in a
Index: othersrc/usr.bin/dholland-make2/graph.h
diff -u othersrc/usr.bin/dholland-make2/graph.h:1.4 othersrc/usr.bin/dholland-make2/graph.h:1.5
--- othersrc/usr.bin/dholland-make2/graph.h:1.4	Mon Mar  4 23:03:41 2013
+++ othersrc/usr.bin/dholland-make2/graph.h	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: graph.h,v 1.4 2013/03/04 23:03:41 dholland Exp $	*/
+/*	$NetBSD: graph.h,v 1.5 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -128,9 +128,9 @@ enum enum_made {
  *	17) a list of nodes that must be made (if they're made) after
  *	    this node is, but that do not depend on this node, in the
  *	    normal sense.
- *	18) a Lst of ``local'' variables that are specific to this target
+ *	18) a list of ``local'' variables that are specific to this target
  *	   and this target only (qv. var.c [$@ $< $?, etc.])
- *	19) a Lst of strings that are commands to be given to a shell
+ *	19) a list of strings that are commands to be given to a shell
  *	   to create this target.
  */
 struct GNode {

Index: othersrc/usr.bin/dholland-make2/dir.h
diff -u othersrc/usr.bin/dholland-make2/dir.h:1.2 othersrc/usr.bin/dholland-make2/dir.h:1.3
--- othersrc/usr.bin/dholland-make2/dir.h:1.2	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/dir.h	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.2 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: dir.h,v 1.3 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -101,7 +101,7 @@ void Dir_InitDot(void);
 void Dir_End(void);
 void Dir_SetPATH(void);
 Boolean Dir_HasWildcards(char *);
-void Dir_Expand(const char *, const struct patharray *, Lst);
+void Dir_Expand(const char *, const struct patharray *, struct stringarray *);
 char *Dir_FindFile(const char *, const struct patharray *);
 int Dir_FindHereOrAbove(char *, char *, char *, int);
 int Dir_MTime(GNode *, Boolean);

Index: othersrc/usr.bin/dholland-make2/make.c
diff -u othersrc/usr.bin/dholland-make2/make.c:1.6 othersrc/usr.bin/dholland-make2/make.c:1.7
--- othersrc/usr.bin/dholland-make2/make.c:1.6	Mon Mar  4 23:31:57 2013
+++ othersrc/usr.bin/dholland-make2/make.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.6 2013/03/04 23:31:57 dholland Exp $	*/
+/*	$NetBSD: make.c,v 1.7 2013/03/05 03:32: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.6 2013/03/04 23:31:57 dholland Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.7 2013/03/05 03:32:08 dholland Exp $");
 
 static unsigned int checked = 1;/* Sequence # to detect recursion */
 static Lst     	toBeMade;	/* The current fringe of the graph. These
@@ -132,6 +132,14 @@ static int DoMakeCheckOrder(GList *);
 static int MakeBuildChild(GNode *, LstNode);
 static void MakeBuildParent(GNode *, LstNode);
 
+/* XXX: non-typesafe wrapper for list code; remove when possible */
+static int
+doTarg_PrintNode(void *a, void *b)
+{
+    Targ_PrintNode(a, b);
+    return 0;
+}
+
 MAKE_ATTR_DEAD static void
 make_abort(GNode *gn, int line)
 {
@@ -139,7 +147,7 @@ make_abort(GNode *gn, int line)
 
     fprintf(debug_file, "make_abort from line %d\n", line);
     Targ_PrintNode(gn, &two);
-    Lst_ForEach(toBeMade, Targ_PrintNode, &two);
+    Lst_ForEach(toBeMade, doTarg_PrintNode, &two);
     Targ_PrintGraph(3);
     abort();
 }
@@ -1285,13 +1293,6 @@ MakePrintStatus(GNode *gn, int *errors)
     return 0;
 }
 
-/* non-typesafe thunk for list library; remove when possible (XXX) */
-static int
-doMakePrintStatus(void *gnp, void *errors)
-{
-    return MakePrintStatus(gnp, errors);
-}
-
 
 
 /*-
@@ -1306,14 +1307,16 @@ doMakePrintStatus(void *gnp, void *error
  *-----------------------------------------------------------------------
  */
 void
-Make_ExpandUse(Lst targs)
+Make_ExpandUse(GList *targs)
 {
     GNode  *gn;		/* a temporary pointer */
     GList examine;	/* List of targets to examine */
     unsigned i;
 
     glist_init(&examine);
-    Lst_IntoArray(targs, &examine.arr); /* XXX not typesafe */
+    for (i=0; i<glist_num(targs); i++) {
+	glist_add(&examine, glist_get(targs, i), NULL);
+    }
 
     /*
      * Make an initial downward pass over the graph, marking nodes to be made
@@ -1415,16 +1418,12 @@ Make_ExpandUse(Lst targs)
  *-----------------------------------------------------------------------
  */
 
-static int
-link_parent(void *cnp, void *pnp)
+static void
+link_parent(GNode *cn, GNode *pn)
 {
-    GNode *cn = cnp;
-    GNode *pn = pnp;
-
     glist_add(&pn->children, cn, NULL);
     glist_add(&cn->parents, pn, NULL);
     pn->unmade++;
-    return 0;
 }
 
 static int
@@ -1448,7 +1447,7 @@ add_wait_dep(GNode *cn, GNode *wn)
 }
 
 static void
-Make_ProcessWait(Lst targs)
+Make_ProcessWait(GList *targs)
 {
     GNode  *pgn;	/* 'parent' node we are examining */
     GNode  *cgn;	/* Each child in turn */
@@ -1465,9 +1464,17 @@ Make_ProcessWait(Lst targs)
     pgn->flags = REMAKE;
     pgn->type = OP_PHONY | OP_DEPENDS;
     /* Get it displayed in the diag dumps */
-    Lst_AtFront(Targ_List(), pgn);
+    {
+	    GList *alltargs;
 
-    Lst_ForEach(targs, link_parent, pgn);
+	    alltargs = Targ_List();
+	    glist_insert(alltargs, 0);
+	    glist_set(alltargs, 0, pgn);
+    }
+
+    for (i=0; i<glist_num(targs); i++) {
+	link_parent(glist_get(targs, i), pgn);
+    }
 
     /* Start building with the 'dummy' .MAIN' node */
     MakeBuildChild(pgn, NULL);
@@ -1496,8 +1503,6 @@ Make_ProcessWait(Lst targs)
 	     * 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));
@@ -1550,9 +1555,10 @@ Make_ProcessWait(Lst targs)
  *-----------------------------------------------------------------------
  */
 Boolean
-Make_Run(Lst targs)
+Make_Run(GList *targs)
 {
     int	    	    errors; 	/* Number of errors the Job module reports */
+    unsigned i, num;
 
     /* Start trying to make the current targets... */
     toBeMade = Lst_Init(FALSE);
@@ -1606,7 +1612,12 @@ Make_Run(Lst targs)
     if (DEBUG(MAKE))
 	 fprintf(debug_file, "done: errors %d\n", errors);
     if (errors == 0) {
-	Lst_ForEach(targs, doMakePrintStatus, &errors);
+	num = glist_num(targs);
+	for (i=0; i<num; i++) {
+	    if (MakePrintStatus(glist_get(targs, i), &errors)) {
+		break;
+	    }
+	}
 	if (DEBUG(MAKE)) {
 	    fprintf(debug_file, "done: errors %d\n", errors);
 	    if (errors)
Index: othersrc/usr.bin/dholland-make2/suff.c
diff -u othersrc/usr.bin/dholland-make2/suff.c:1.6 othersrc/usr.bin/dholland-make2/suff.c:1.7
--- othersrc/usr.bin/dholland-make2/suff.c:1.6	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/suff.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.6 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: suff.c,v 1.7 2013/03/05 03:32: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.6 2013/03/05 01:44:34 dholland Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.7 2013/03/05 03:32:08 dholland Exp $");
 
 static Lst       sufflist;	/* Lst of suffixes */
 #ifdef CLEANUP
@@ -217,7 +217,6 @@ static void SuffInsert(Lst, Suff *);
 static void SuffRemove(Lst, Suff *);
 static Boolean SuffParseTransform(char *, Suff **, Suff **);
 static int SuffRebuildGraph(void *, void *);
-static int SuffScanTargets(void *, void *);
 static int SuffAddSrc(void *, void *);
 static int SuffRemoveSrc(Lst);
 static void SuffAddLevel(Lst, Src *);
@@ -894,10 +893,8 @@ SuffRebuildGraph(void *transformp, void 
  *-----------------------------------------------------------------------
  */
 static int
-SuffScanTargets(void *targetp, void *gsp)
+SuffScanTargets(GNode *target, GNodeSuff *gs)
 {
-    GNode   	*target = (GNode *)targetp;
-    GNodeSuff	*gs = (GNodeSuff *)gsp;
     Suff	*s, *t;
     char 	*ptr;
 
@@ -960,6 +957,8 @@ Suff_AddSuffix(char *str, GNode **gn)
     Suff          *s;	    /* new suffix descriptor */
     LstNode 	  ln;
     GNodeSuff	  gs;
+    GList *alltargets;
+    unsigned i, num;
 
     ln = Lst_Find(sufflist, str, SuffSuffHasNameP);
     if (ln == NULL) {
@@ -985,7 +984,14 @@ Suff_AddSuffix(char *str, GNode **gn)
 	gs.gn = gn;
 	gs.s  = s;
 	gs.r  = FALSE;
-	Lst_ForEach(Targ_List(), SuffScanTargets, &gs);
+	alltargets = Targ_List();
+	num = glist_num(alltargets);
+	for (i=0; i<num; i++) {
+	    if (SuffScanTargets(glist_get(alltargets, i), &gs)) {
+		/* XXX: is this really right? */
+		break;
+	    }
+	}
 	/*
 	 * Look for any existing transformations from or to this suffix.
 	 * XXX: Only do this after a Suff_ClearSuffixes?
@@ -1545,6 +1551,7 @@ SuffExpandChildren(GNode *cgn, unsigned 
 {
     GNode	*gn;	    /* New source 8) */
     char	*cp;	    /* Expanded value */
+    unsigned i, num;
 
     assert(glist_get(&pgn->children, cindex) == cgn);
 
@@ -1572,7 +1579,9 @@ SuffExpandChildren(GNode *cgn, unsigned 
     cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
 
     if (cp != NULL) {
-	Lst	    members = Lst_Init(FALSE);
+	GList members;
+
+	glist_init(&members);
 
 	if (cgn->type & OP_ARCHV) {
 	    /*
@@ -1582,7 +1591,7 @@ SuffExpandChildren(GNode *cgn, unsigned 
 	     */
 	    char	*sacrifice = cp;
 
-	    (void)Arch_ParseArchive(&sacrifice, members, pgn);
+	    (void)Arch_ParseArchive(&sacrifice, &members, pgn);
 	} else {
 	    /*
 	     * Break the result into a vector of strings whose nodes
@@ -1604,7 +1613,7 @@ SuffExpandChildren(GNode *cgn, unsigned 
 		     */
 		    *cp++ = '\0';
 		    gn = Targ_FindNode(start, TARG_CREATE);
-		    (void)Lst_AtEnd(members, gn);
+		    glist_add(&members, gn, NULL);
 		    while (*cp == ' ' || *cp == '\t') {
 			cp++;
 		    }
@@ -1642,7 +1651,7 @@ SuffExpandChildren(GNode *cgn, unsigned 
 		 * Stuff left over -- add it to the list too
 		 */
 		gn = Targ_FindNode(start, TARG_CREATE);
-		(void)Lst_AtEnd(members, gn);
+		glist_add(&members, gn, NULL);
 	    }
 	    /*
 	     * Point cp back at the beginning again so the variable value
@@ -1654,8 +1663,9 @@ SuffExpandChildren(GNode *cgn, unsigned 
 	/*
 	 * Add all elements of the members list to the parent node.
 	 */
-	while(!Lst_IsEmpty(members)) {
-	    gn = (GNode *)Lst_DeQueue(members);
+	num = glist_num(&members);
+	for (i=0; i<num; i++) {
+	    gn = glist_get(&members, i);
 
 	    if (DEBUG(SUFF)) {
 		fprintf(debug_file, "%s...", gn->name);
@@ -1673,7 +1683,8 @@ SuffExpandChildren(GNode *cgn, unsigned 
 	    cindex = SuffExpandWildcards(gn, cindex - 1, pgn);
 	    assert(glist_get(&pgn->children, cindex) == cgn);
 	}
-	Lst_Destroy(members, NULL);
+	glist_setsize(&members, 0);
+	glist_cleanup(&members);
 
 	/*
 	 * Free the result
@@ -1706,7 +1717,8 @@ SuffExpandWildcards(GNode *cgn, unsigned
 {
     GNode	*gn;	    /* New source 8) */
     char	*cp;	    /* Expanded value */
-    Lst 	explist;    /* List of expansions */
+    struct stringarray explist;    /* Expansions */
+    unsigned i;
 
     assert(glist_get(&pgn->children, cindex) == cgn);
 
@@ -1716,14 +1728,14 @@ SuffExpandWildcards(GNode *cgn, unsigned
     /*
      * Expand the word along the chosen path
      */
-    explist = Lst_Init(FALSE);
-    Dir_Expand(cgn->name, Suff_FindPath(cgn), explist);
+    stringarray_init(&explist);
+    Dir_Expand(cgn->name, Suff_FindPath(cgn), &explist);
 
-    while (!Lst_IsEmpty(explist)) {
+    for (i=0; i<stringarray_num(&explist); i++) {
 	/*
 	 * Fetch next expansion off the list and find its GNode
 	 */
-	cp = (char *)Lst_DeQueue(explist);
+	cp = stringarray_get(&explist, i);
 
 	if (DEBUG(SUFF)) {
 	    fprintf(debug_file, "%s...", cp);
@@ -1742,7 +1754,7 @@ SuffExpandWildcards(GNode *cgn, unsigned
     /*
      * Nuke what's left of the list
      */
-    Lst_Destroy(explist, NULL);
+    stringarray_cleanup(&explist);
 
     if (DEBUG(SUFF)) {
 	fprintf(debug_file, "\n");
Index: othersrc/usr.bin/dholland-make2/targ.c
diff -u othersrc/usr.bin/dholland-make2/targ.c:1.6 othersrc/usr.bin/dholland-make2/targ.c:1.7
--- othersrc/usr.bin/dholland-make2/targ.c:1.6	Mon Mar  4 23:31:57 2013
+++ othersrc/usr.bin/dholland-make2/targ.c	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.6 2013/03/04 23:31:57 dholland Exp $	*/
+/*	$NetBSD: targ.c,v 1.7 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -127,23 +127,21 @@
 #include	  "hash.h"
 #include	  "dir.h"
 
-MAKE_RCSID("$NetBSD: targ.c,v 1.6 2013/03/04 23:31:57 dholland Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.7 2013/03/05 03:32:08 dholland Exp $");
 
-static Lst        allTargets;	/* the list of all targets found so far */
+static GList      allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
-static Lst	  allGNs;	/* List of all the GNodes */
+static GList	  allGNs;	/* List of all the GNodes */
 #endif
 static Hash_Table targets;	/* a hash table of same */
 
 #define HTSIZE	191		/* initial size of hash table */
 
-static int TargPrintOnlySrc(void *, void *);
 static void TargPrintName(GNode *);
 #ifdef CLEANUP
-static void TargFreeGN(void *);
+static void TargFreeGN(GNode *);
 #endif
 static void TargPropagateCohort(GNode *, GNode *);
-static int TargPropagateNode(void *, void *);
 
 /*-
  *-----------------------------------------------------------------------
@@ -160,8 +158,11 @@ static int TargPropagateNode(void *, voi
 void
 Targ_Init(void)
 {
-    allTargets = Lst_Init(FALSE);
-    Hash_InitTable(&targets, HTSIZE);
+	glist_init(&allTargets);
+#ifdef CLEANUP
+	glist_init(&allGNs);
+#endif
+	Hash_InitTable(&targets, HTSIZE);
 }
 
 /*-
@@ -180,10 +181,17 @@ void
 Targ_End(void)
 {
 #ifdef CLEANUP
-    Lst_Destroy(allTargets, NULL);
-    if (allGNs)
-	Lst_Destroy(allGNs, TargFreeGN);
-    Hash_DeleteTable(&targets);
+	unsigned i, num;
+
+	glist_setsize(&allTargets, 0);
+	glist_cleanup(&allTargets);
+
+	num = glist_num(&allGNs);
+	for (i=0; i<num; i++) {
+		TargFreeGN(glist_get(&allGNs, i));
+	}
+
+	Hash_DeleteTable(&targets);
 #endif
 }
 
@@ -199,10 +207,10 @@ Targ_End(void)
  *	None
  *-----------------------------------------------------------------------
  */
-Lst
+GList *
 Targ_List(void)
 {
-    return allTargets;
+	return &allTargets;
 }
 
 /*-
@@ -257,9 +265,7 @@ Targ_NewGN(const char *name)
     gn->fname = 	NULL;
 
 #ifdef CLEANUP
-    if (allGNs == NULL)
-	allGNs = Lst_Init(FALSE);
-    Lst_AtEnd(allGNs, gn);
+    glist_add(&allGNs, gn, NULL);
 #endif
 
     return (gn);
@@ -279,11 +285,8 @@ Targ_NewGN(const char *name)
  *-----------------------------------------------------------------------
  */
 static void
-TargFreeGN(void *gnp)
+TargFreeGN(GNode *gn)
 {
-    GNode *gn = (GNode *)gnp;
-
-
     free(gn->name);
     if (gn->uname)
 	free(gn->uname);
@@ -354,7 +357,7 @@ Targ_FindNode(const char *name, int flag
     if (!(flags & TARG_NOHASH))
 	Hash_SetValue(he, gn);
     Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
-    (void)Lst_AtEnd(allTargets, gn);
+    glist_add(&allTargets, gn, NULL);
     if (doing_depend)
 	gn->flags |= FROM_DEPEND;
     return gn;
@@ -379,34 +382,26 @@ Targ_FindNode(const char *name, int flag
  *	an error message will be printed for each name which can't be found.
  * -----------------------------------------------------------------------
  */
-Lst
-Targ_FindList(Lst names, int flags)
+GList *
+Targ_FindList(struct stringarray *names, int flags)
 {
-    Lst            nodes;	/* result list */
-    LstNode	   ln;		/* name list element */
-    GNode	   *gn;		/* node in tLn */
+    GList          *nodes;	/* result list */
+    GNode	   *gn;
     char    	   *name;
+    unsigned i, num;
 
-    nodes = Lst_Init(FALSE);
+    nodes = glist_create();
 
-    if (Lst_Open(names) == FAILURE) {
-	return (nodes);
-    }
-    while ((ln = Lst_Next(names)) != NULL) {
-	name = (char *)Lst_Datum(ln);
+    num = stringarray_num(names);
+    for (i=0; i<num; i++) {
+	name = stringarray_get(names, i);
 	gn = Targ_FindNode(name, flags);
 	if (gn != NULL) {
-	    /*
-	     * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
-	     * are added to the list in the order in which they were
-	     * encountered in the makefile.
-	     */
-	    (void)Lst_AtEnd(nodes, gn);
+	    glist_add(nodes, gn, NULL);
 	} else if (flags == TARG_NOCREATE) {
 	    Error("\"%s\" -- target unknown.", name);
 	}
     }
-    Lst_Close(names);
     return (nodes);
 }
 
@@ -618,16 +613,15 @@ made_name(enum enum_made made)
  *	print the contents of a node
  *-----------------------------------------------------------------------
  */
-int
-Targ_PrintNode(void *gnp, void *passp)
+void
+Targ_PrintNode(GNode *gn, int *passp)
 {
-    GNode         *gn = (GNode *)gnp;
-    int	    	  pass = passp ? *(int *)passp : 0;
+    int pass = passp ? *passp : 0;
 
     fprintf(debug_file, "# %s%s, flags %x, type %x, made %d\n",
 	    gn->name, gn->cohort_num, gn->flags, gn->type, gn->made);
     if (gn->flags == 0)
-	return 0;
+	return;
 
     if (!OP_NOP(gn->type)) {
 	fprintf(debug_file, "#\n");
@@ -721,7 +715,6 @@ Targ_PrintNode(void *gnp, void *passp)
 	    }
 	}
     }
-    return (0);
 }
 
 /*-
@@ -730,26 +723,23 @@ Targ_PrintNode(void *gnp, void *passp)
  *	Print only those targets that are just a source.
  *
  * Results:
- *	0.
+ *	none
  *
  * Side Effects:
  *	The name of each file is printed preceded by #\t
  *
  *-----------------------------------------------------------------------
  */
-static int
-TargPrintOnlySrc(void *gnp, void *dummy MAKE_ATTR_UNUSED)
+static void
+TargPrintOnlySrc(GNode *gn)
 {
-    GNode   	  *gn = (GNode *)gnp;
     if (!OP_NOP(gn->type))
-	return 0;
+	return;
 
     fprintf(debug_file, "#\t%s [%s] ",
 	    gn->name, gn->path ? gn->path : gn->name);
     Targ_PrintType(gn->type);
     fprintf(debug_file, "\n");
-
-    return 0;
 }
 
 /*-
@@ -771,11 +761,18 @@ TargPrintOnlySrc(void *gnp, void *dummy 
 void
 Targ_PrintGraph(int pass)
 {
+    unsigned i, num;
+
     fprintf(debug_file, "#*** Input graph:\n");
-    Lst_ForEach(allTargets, Targ_PrintNode, &pass);
+    num = glist_num(&allTargets);
+    for (i=0; i<num; i++) {
+	Targ_PrintNode(glist_get(&allTargets, i), &pass);
+    }
     fprintf(debug_file, "\n\n");
     fprintf(debug_file, "#\n#   Files that are only sources:\n");
-    Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
+    for (i=0; i<num; i++) {
+	TargPrintOnlySrc(glist_get(&allTargets, i));
+    }
     fprintf(debug_file, "#*** Global Variables:\n");
     Var_Dump(VAR_GLOBAL);
     fprintf(debug_file, "#*** Command-line Variables:\n");
@@ -796,7 +793,7 @@ Targ_PrintGraph(int pass)
  *	gnp		The node that we are processing.
  *
  * Results:
- *	Always returns 0, for the benefit of Lst_ForEach().
+ *	none
  *
  * Side Effects:
  *	Information is propagated from this node to cohort or child
@@ -810,18 +807,16 @@ Targ_PrintGraph(int pass)
  *	predecessor.
  *-----------------------------------------------------------------------
  */
-static int
-TargPropagateNode(void *gnp, void *junk MAKE_ATTR_UNUSED)
+static void
+TargPropagateNode(GNode *gn)
 {
-    GNode	  *gn = (GNode *)gnp;
     unsigned i;
 
     if (gn->type & OP_DOUBLEDEP) {
 	for (i=0; i<glist_num(&gn->cohorts); i++) {
-	    TargPropagateCohort(glist_get(&gn->cohorts, i), gnp);
+	    TargPropagateCohort(glist_get(&gn->cohorts, i), gn);
 	}
     }
-    return (0);
 }
 
 /*-
@@ -865,5 +860,10 @@ TargPropagateCohort(GNode *cgn, GNode *p
 void
 Targ_Propagate(void)
 {
-    Lst_ForEach(allTargets, TargPropagateNode, NULL);
+	unsigned i, num;
+
+	num = glist_num(&allTargets);
+	for (i=0; i<num; i++) {
+		TargPropagateNode(glist_get(&allTargets, i));
+	}
 }

Index: othersrc/usr.bin/dholland-make2/make.h
diff -u othersrc/usr.bin/dholland-make2/make.h:1.8 othersrc/usr.bin/dholland-make2/make.h:1.9
--- othersrc/usr.bin/dholland-make2/make.h:1.8	Tue Mar  5 01:44:34 2013
+++ othersrc/usr.bin/dholland-make2/make.h	Tue Mar  5 03:32:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.8 2013/03/05 01:44:34 dholland Exp $	*/
+/*	$NetBSD: make.h,v 1.9 2013/03/05 03:32:08 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -158,9 +158,12 @@
 /*
  * Global Variables
  */
-extern Lst  	create;	    	/* The list of target names specified on the
-				 * command line. used to resolve #if
-				 * make(...) statements */
+
+/*
+ * The list of target names specified on the command line. Used to
+ * resolve #if make(...) statements.
+ */
+extern struct stringarray create;
 
 /* The list of directories to search when looking for targets */
 extern struct patharray dirSearchPath;
@@ -269,12 +272,12 @@ extern int debug;
 
 void Make_TimeStamp(GNode *, GNode *);
 Boolean Make_OODate(GNode *);
-void Make_ExpandUse(Lst);
+void Make_ExpandUse(GList *);
 time_t Make_Recheck(GNode *);
 void Make_HandleUse(GNode *, GNode *);
 void Make_Update(GNode *);
 void Make_DoAllVar(GNode *);
-Boolean Make_Run(Lst);
+Boolean Make_Run(GList *);
 char * Check_Cwd_Cmd(const char *);
 void Check_Cwd(const char **);
 void PrintOnError(GNode *, const char *);

Reply via email to