Module Name:    othersrc
Committed By:   dholland
Date:           Tue Mar  5 01:44:35 UTC 2013

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

Log Message:
Use arrays instead of lists for path searching.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/usr.bin/dholland-make2/arch.c \
    othersrc/usr.bin/dholland-make2/main.c \
    othersrc/usr.bin/dholland-make2/parse.c
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/dholland-make2/cond.c \
    othersrc/usr.bin/dholland-make2/nonints.h
cvs rdiff -u -r1.3 -r1.4 othersrc/usr.bin/dholland-make2/dir.c
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/usr.bin/dholland-make2/dir.h
cvs rdiff -u -r1.7 -r1.8 othersrc/usr.bin/dholland-make2/make.h
cvs rdiff -u -r1.5 -r1.6 othersrc/usr.bin/dholland-make2/suff.c

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.4 othersrc/usr.bin/dholland-make2/arch.c:1.5
--- othersrc/usr.bin/dholland-make2/arch.c:1.4	Mon Mar  4 23:52:07 2013
+++ othersrc/usr.bin/dholland-make2/arch.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.4 2013/03/04 23:52:07 dholland Exp $	*/
+/*	$NetBSD: arch.c,v 1.5 2013/03/05 01:44:34 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.4 2013/03/04 23:52:07 dholland Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.5 2013/03/05 01:44:34 dholland Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -392,7 +392,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 	    size_t sz = MAXPATHLEN, nsz;
 	    nameBuf = bmake_malloc(sz);
 
-	    Dir_Expand(memName, dirSearchPath, members);
+	    Dir_Expand(memName, &dirSearchPath, members);
 	    while (!Lst_IsEmpty(members)) {
 		member = (char *)Lst_DeQueue(members);
 		nsz = strlen(libName) + strlen(member) + 3;
@@ -1172,7 +1172,7 @@ Arch_MemMTime(GNode *gn)
  *-----------------------------------------------------------------------
  */
 void
-Arch_FindLib(GNode *gn, Lst path)
+Arch_FindLib(GNode *gn, const struct patharray *path)
 {
     char	    *libName;   /* file name for archive */
     size_t	     sz = strlen(gn->name) + 6 - 2;
Index: othersrc/usr.bin/dholland-make2/main.c
diff -u othersrc/usr.bin/dholland-make2/main.c:1.4 othersrc/usr.bin/dholland-make2/main.c:1.5
--- othersrc/usr.bin/dholland-make2/main.c:1.4	Mon Mar  4 08:47:08 2013
+++ othersrc/usr.bin/dholland-make2/main.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.4 2013/03/04 08:47:08 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.5 2013/03/05 01:44:34 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.4 2013/03/04 08:47:08 dholland Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.5 2013/03/05 01:44:34 dholland Exp $");
 
 
 #ifndef	DEFMAXLOCAL
@@ -510,9 +510,9 @@ rearg:	
 				if (!Dir_FindHereOrAbove(curdir, argvalue+4,
 				    found_path, sizeof(found_path)))
 					break;		/* nothing doing */
-				(void)Dir_AddDir(sysIncPath, found_path);
+				(void)Dir_AddDir(&sysIncPath, found_path);
 			} else {
-				(void)Dir_AddDir(sysIncPath, argvalue);
+				(void)Dir_AddDir(&sysIncPath, argvalue);
 			}
 			Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
@@ -1080,11 +1080,11 @@ main(int argc, char **argv)
 		}
 		/* look for magic parent directory search string */
 		if (strncmp(".../", start, 4) != 0) {
-			(void)Dir_AddDir(defIncPath, start);
+			(void)Dir_AddDir(&defIncPath, start);
 		} else {
 			if (Dir_FindHereOrAbove(curdir, start+4, 
 			    found_path, sizeof(found_path))) {
-				(void)Dir_AddDir(defIncPath, found_path);
+				(void)Dir_AddDir(&defIncPath, found_path);
 			}
 		}
 	}
@@ -1101,7 +1101,7 @@ main(int argc, char **argv)
 
 		sysMkPath = Lst_Init(FALSE);
 		Dir_Expand(_PATH_DEFSYSMK,
-			   Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath,
+			   patharray_num(&sysIncPath) == 0 ? &defIncPath : &sysIncPath,
 			   sysMkPath);
 		if (Lst_IsEmpty(sysMkPath))
 			Fatal("%s: no system rules (%s).", progname,
@@ -1178,7 +1178,7 @@ main(int argc, char **argv)
 			savec = *cp;
 			*cp = '\0';
 			/* Add directory to search path */
-			(void)Dir_AddDir(dirSearchPath, path);
+			(void)Dir_AddDir(&dirSearchPath, path);
 			*cp = savec;
 			path = cp + 1;
 		} while (savec == ':');
@@ -1349,10 +1349,10 @@ ReadMakefile(const void *p, const void *
 				goto found;
 		}
 		/* look in -I and system include directories. */
-		name = Dir_FindFile(fname, parseIncPath);
+		name = Dir_FindFile(fname, &parseIncPath);
 		if (!name)
 			name = Dir_FindFile(fname,
-				Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath);
+				patharray_num(&sysIncPath) == 0 ? &defIncPath : &sysIncPath);
 		if (!name || (fd = open(name, O_RDONLY)) == -1) {
 			if (name)
 				free(name);
Index: othersrc/usr.bin/dholland-make2/parse.c
diff -u othersrc/usr.bin/dholland-make2/parse.c:1.4 othersrc/usr.bin/dholland-make2/parse.c:1.5
--- othersrc/usr.bin/dholland-make2/parse.c:1.4	Mon Mar  4 23:03:42 2013
+++ othersrc/usr.bin/dholland-make2/parse.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.4 2013/03/04 23:03:42 dholland Exp $	*/
+/*	$NetBSD: parse.c,v 1.5 2013/03/05 01:44:34 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.4 2013/03/04 23:03:42 dholland Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.5 2013/03/05 01:44:34 dholland Exp $");
 
 ////////////////////////////////////////////////////////////
 // types and constants
@@ -269,9 +269,9 @@ static IFile *curFile;
 static Lst includes;
 
 /* include paths (lists of directories) */
-Lst parseIncPath;	/* dirs for "..." includes */
-Lst sysIncPath;		/* dirs for <...> includes */
-Lst defIncPath;		/* default for sysIncPath */
+struct patharray parseIncPath;	/* dirs for "..." includes */
+struct patharray sysIncPath;	/* dirs for <...> includes */
+struct patharray defIncPath;	/* default for sysIncPath */
 
 ////////////////////////////////////////////////////////////
 // parser tables
@@ -345,8 +345,6 @@ static int ParseLinkSrc(void *, void *);
 static int ParseDoOp(void *, void *);
 static void ParseDoSrc(int, const char *);
 static int ParseFindMain(void *, void *);
-static int ParseAddDir(void *, void *);
-static int ParseClearPath(void *, void *);
 static void ParseDoDependency(char *);
 static int ParseAddCmd(void *, void *);
 static void ParseHasCommands(void *);
@@ -1074,46 +1072,6 @@ ParseFindMain(void *gnp, void *dummy)
 }
 
 /*-
- *-----------------------------------------------------------------------
- * ParseAddDir --
- *	Front-end for Dir_AddDir to make sure Lst_ForEach keeps going
- *
- * Results:
- *	=== 0
- *
- * Side Effects:
- *	See Dir_AddDir.
- *
- *-----------------------------------------------------------------------
- */
-static int
-ParseAddDir(void *path, void *name)
-{
-    (void)Dir_AddDir((Lst) path, (char *)name);
-    return(0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * ParseClearPath --
- *	Front-end for Dir_ClearPath to make sure Lst_ForEach keeps going
- *
- * Results:
- *	=== 0
- *
- * Side Effects:
- *	See Dir_ClearPath
- *
- *-----------------------------------------------------------------------
- */
-static int
-ParseClearPath(void *path, void *dummy)
-{
-    Dir_ClearPath((Lst) path);
-    return(dummy ? 0 : 0);
-}
-
-/*-
  *---------------------------------------------------------------------
  * ParseDoDependency  --
  *	Parse the dependency line in line.
@@ -1157,8 +1115,8 @@ ParseDoDependency(char *line)
     GNode 	   *gn = NULL;	/* a general purpose temporary node */
     int             op;		/* the operator on the line */
     char            savec;	/* a place to save a character */
-    Lst    	    paths;   	/* List of search paths to alter when parsing
-				 * a list of .PATH targets */
+    /* 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
 				 * expansion */
@@ -1171,7 +1129,7 @@ ParseDoDependency(char *line)
     tOp = 0;
 
     specType = Not;
-    paths = NULL;
+    patharrayarray_init(&paths);
 
     curTargs = Lst_Init(FALSE);
 
@@ -1289,10 +1247,7 @@ ParseDoDependency(char *line)
 		 */
 		switch (specType) {
 		    case ExPath:
-			if (paths == NULL) {
-			    paths = Lst_Init(FALSE);
-			}
-			(void)Lst_AtEnd(paths, dirSearchPath);
+			patharrayarray_add(&paths, &dirSearchPath, NULL);
 			break;
 		    case Main:
 			if (!Lst_IsEmpty(create)) {
@@ -1331,7 +1286,7 @@ ParseDoDependency(char *line)
 		 * Call on the suffix module to give us a path to
 		 * modify.
 		 */
-		Lst 	path;
+		struct patharray *path;
 
 		specType = ExPath;
 		path = Suff_GetPath(&line[5]);
@@ -1341,10 +1296,7 @@ ParseDoDependency(char *line)
 				 &line[5]);
 		    goto out;
 		} else {
-		    if (paths == NULL) {
-			paths = Lst_Init(FALSE);
-		    }
-		    (void)Lst_AtEnd(paths, path);
+		    patharrayarray_add(&paths, path, NULL);
 		}
 	    }
 	}
@@ -1360,12 +1312,15 @@ ParseDoDependency(char *line)
 		 * so create an empty path for the thing. Note we need to
 		 * use Dir_Destroy in the destruction of the path as the
 		 * Dir module could have added a directory to the path...
+		 *
+		 * Note dholland 20130304: this is now not supposed to
+		 * happen, so we can just zap it.
 		 */
-		Lst	    emptyPath = Lst_Init(FALSE);
-
-		Dir_Expand(line, emptyPath, curTargs);
+		struct patharray emptyPath;
 
-		Lst_Destroy(emptyPath, Dir_Destroy);
+		patharray_init(&emptyPath);
+		Dir_Expand(line, &emptyPath, curTargs);
+		patharray_cleanup(&emptyPath);
 	    } else {
 		/*
 		 * No wildcards, but we want to avoid code duplication,
@@ -1500,7 +1455,14 @@ ParseDoDependency(char *line)
 		beSilent = TRUE;
 		break;
 	    case ExPath:
-		Lst_ForEach(paths, ParseClearPath, NULL);
+		{
+		    unsigned i, num;
+
+		    num = patharrayarray_num(&paths);
+		    for (i=0; i<num; i++) {
+			Dir_ClearPath(patharrayarray_get(&paths, i));
+		    }
+		}
 		Dir_SetPATH();
 		break;
 #ifdef POSIX
@@ -1574,7 +1536,14 @@ ParseDoDependency(char *line)
 		    Suff_AddSuffix(line, &mainNode);
 		    break;
 		case ExPath:
-		    Lst_ForEach(paths, ParseAddDir, line);
+		    {
+			unsigned i, num;
+
+			num = patharrayarray_num(&paths);
+			for (i=0; i<num; i++) {
+			    Dir_AddDir(patharrayarray_get(&paths, i), line);
+			}
+		    }
 		    break;
 		case Includes:
 		    Suff_AddInclude(line);
@@ -1600,9 +1569,9 @@ ParseDoDependency(char *line)
 	    }
 	    line = cp;
 	}
-	if (paths) {
-	    Lst_Destroy(paths, NULL);
-	}
+	/* XXX is this the right place for this cleanup? */
+	patharrayarray_setsize(&paths, 0);
+	patharrayarray_cleanup(&paths);
 	if (specType == ExPath)
 	    Dir_SetPATH();
     } else {
@@ -2018,7 +1987,7 @@ ParseHasCommands(void *gnp)
 void
 Parse_AddIncludeDir(char *dir)
 {
-    (void)Dir_AddDir(parseIncPath, dir);
+    (void)Dir_AddDir(&parseIncPath, dir);
 }
 
 /*-
@@ -2078,9 +2047,9 @@ Parse_include_file(char *file, Boolean i
 		*prefEnd = '\0';
 	    }
 	    newName = str_concat(incdir, file + i, STR_ADDSLASH);
-	    fullname = Dir_FindFile(newName, parseIncPath);
+	    fullname = Dir_FindFile(newName, &parseIncPath);
 	    if (fullname == NULL)
-		fullname = Dir_FindFile(newName, dirSearchPath);
+		fullname = Dir_FindFile(newName, &dirSearchPath);
 	    free(newName);
 	}
 	free(incdir);
@@ -2093,7 +2062,7 @@ Parse_include_file(char *file, Boolean i
 	     * If we have a suffix specific path we should use that.
 	     */
 	    char *suff;
-	    Lst	suffPath = NULL;
+	    struct patharray *suffPath;
 
 	    if ((suff = strrchr(file, '.'))) {
 		suffPath = Suff_GetPath(suff);
@@ -2102,9 +2071,9 @@ Parse_include_file(char *file, Boolean i
 		}
 	    }
 	    if (fullname == NULL) {
-		fullname = Dir_FindFile(file, parseIncPath);
+		fullname = Dir_FindFile(file, &parseIncPath);
 		if (fullname == NULL) {
-		    fullname = Dir_FindFile(file, dirSearchPath);
+		    fullname = Dir_FindFile(file, &dirSearchPath);
 		}
 	    }
 	}
@@ -2116,7 +2085,7 @@ Parse_include_file(char *file, Boolean i
 	 * Look for it on the system path
 	 */
 	fullname = Dir_FindFile(file,
-		    Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath);
+		    patharray_num(&sysIncPath) == 0 ? &defIncPath : &sysIncPath);
     }
 
     if (fullname == NULL) {
@@ -3030,9 +2999,9 @@ void
 Parse_Init(void)
 {
     mainNode = NULL;
-    parseIncPath = Lst_Init(FALSE);
-    sysIncPath = Lst_Init(FALSE);
-    defIncPath = Lst_Init(FALSE);
+    patharray_init(&parseIncPath);
+    patharray_init(&sysIncPath);
+    patharray_init(&defIncPath);
     includes = Lst_Init(FALSE);
 #ifdef CLEANUP
     targCmds = Lst_Init(FALSE);
@@ -3046,9 +3015,12 @@ Parse_End(void)
     Lst_Destroy(targCmds, (FreeProc *)free);
     if (targets)
 	Lst_Destroy(targets, NULL);
-    Lst_Destroy(defIncPath, Dir_Destroy);
-    Lst_Destroy(sysIncPath, Dir_Destroy);
-    Lst_Destroy(parseIncPath, Dir_Destroy);
+    Dir_ClearPath(&defIncPath);
+    Dir_ClearPath(&sysIncPath);
+    Dir_ClearPath(&parseIncPath);
+    patharray_cleaup(&defIncPath);
+    patharray_cleaup(&sysIncPath);
+    patharray_cleaup(&parseIncPath);
     Lst_Destroy(includes, NULL);	/* Should be empty now */
 #endif
 }

Index: othersrc/usr.bin/dholland-make2/cond.c
diff -u othersrc/usr.bin/dholland-make2/cond.c:1.2 othersrc/usr.bin/dholland-make2/cond.c:1.3
--- othersrc/usr.bin/dholland-make2/cond.c:1.2	Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/cond.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.2 2013/02/25 03:39:28 dholland Exp $	*/
+/*	$NetBSD: cond.c,v 1.3 2013/03/05 01:44:34 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.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.3 2013/03/05 01:44:34 dholland Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -393,7 +393,7 @@ CondDoExists(int argLen MAKE_ATTR_UNUSED
     Boolean result;
     char    *path;
 
-    path = Dir_FindFile(arg, dirSearchPath);
+    path = Dir_FindFile(arg, &dirSearchPath);
     if (DEBUG(COND)) {
 	fprintf(debug_file, "exists(%s) result is \"%s\"\n",
 	       arg, path ? path : "");
Index: othersrc/usr.bin/dholland-make2/nonints.h
diff -u othersrc/usr.bin/dholland-make2/nonints.h:1.2 othersrc/usr.bin/dholland-make2/nonints.h:1.3
--- othersrc/usr.bin/dholland-make2/nonints.h:1.2	Mon Mar  4 08:47:08 2013
+++ othersrc/usr.bin/dholland-make2/nonints.h	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.2 2013/03/04 08:47:08 dholland Exp $	*/
+/*	$NetBSD: nonints.h,v 1.3 2013/03/05 01:44:34 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -78,7 +78,7 @@ void Arch_Touch(GNode *);
 void Arch_TouchLib(GNode *);
 time_t Arch_MTime(GNode *);
 time_t Arch_MemMTime(GNode *);
-void Arch_FindLib(GNode *, Lst);
+void Arch_FindLib(GNode *, const struct patharray *);
 Boolean Arch_LibOODate(GNode *);
 void Arch_Init(void);
 void Arch_End(void);
@@ -146,12 +146,12 @@ Boolean Suff_IsTransform(char *);
 GNode *Suff_AddTransform(char *);
 int Suff_EndTransform(void *, void *);
 void Suff_AddSuffix(char *, GNode **);
-Lst Suff_GetPath(char *);
+struct patharray *Suff_GetPath(char *);
 void Suff_DoPaths(void);
 void Suff_AddInclude(char *);
 void Suff_AddLib(char *);
 void Suff_FindDeps(GNode *);
-Lst Suff_FindPath(GNode *);
+const struct patharray *Suff_FindPath(GNode *);
 void Suff_SetNull(char *);
 void Suff_Init(void);
 void Suff_End(void);

Index: othersrc/usr.bin/dholland-make2/dir.c
diff -u othersrc/usr.bin/dholland-make2/dir.c:1.3 othersrc/usr.bin/dholland-make2/dir.c:1.4
--- othersrc/usr.bin/dholland-make2/dir.c:1.3	Mon Mar  4 07:28:45 2013
+++ othersrc/usr.bin/dholland-make2/dir.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.3 2013/03/04 07:28:45 dholland Exp $	*/
+/*	$NetBSD: dir.c,v 1.4 2013/03/05 01:44:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -137,7 +137,7 @@
 #include "hash.h"
 #include "dir.h"
 
-__RCSID("$NetBSD: dir.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
+__RCSID("$NetBSD: dir.c,v 1.4 2013/03/05 01:44:34 dholland Exp $");
 
 /*
  *	A search path consists of a Lst of Path structures. A Path structure
@@ -209,7 +209,7 @@ __RCSID("$NetBSD: dir.c,v 1.3 2013/03/04
  *	in a cache for when Dir_MTime was actually called.
  */
 
-Lst          dirSearchPath;	/* main search path */
+struct patharray dirSearchPath;	/* main search path */
 
 static Lst   openDirectories;	/* the list of all open directories */
 
@@ -237,12 +237,8 @@ static Hash_Table mtimes;   /* Results o
 			     * should be ok, but... */
 
 
-static int DirFindName(const void *, const void *);
 static int DirMatchFiles(const char *, Path *, Lst);
-static void DirExpandCurly(const char *, const char *, Lst, Lst);
-static void DirExpandInt(const char *, Lst, Lst);
 static int DirPrintWord(void *, void *);
-static int DirPrintDir(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 *);
@@ -263,7 +259,7 @@ static char *DirLookupAbs(Path *, const 
 void
 Dir_Init(const char *cdname)
 {
-    dirSearchPath = Lst_Init(FALSE);
+    patharray_init(&dirSearchPath);
     openDirectories = Lst_Init(FALSE);
     Hash_InitTable(&mtimes, 0);
 
@@ -381,15 +377,15 @@ Dir_End(void)
 void
 Dir_SetPATH(void)
 {
-    LstNode       ln;		/* a list element */
     Path *p;
     Boolean	  hasLastDot = FALSE;	/* true we should search dot last */
+    unsigned i;
 
     Var_Delete(".PATH", VAR_GLOBAL);
     
-    if (Lst_Open(dirSearchPath) == SUCCESS) {
-	if ((ln = Lst_First(dirSearchPath)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
+    {
+	if (patharray_num(&dirSearchPath) > 0) {
+	    p = patharray_get(&dirSearchPath, 0);
 	    if (p == dotLast) {
 		hasLastDot = TRUE;
 		Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
@@ -403,8 +399,8 @@ Dir_SetPATH(void)
 		Var_Append(".PATH", cur->name, VAR_GLOBAL);
 	}
 
-	while ((ln = Lst_Next(dirSearchPath)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
+	for (i=1; i<patharray_num(&dirSearchPath); i++) {
+	    p = patharray_get(&dirSearchPath, i);
 	    if (p == dotLast)
 		continue;
 	    if (p == dot && hasLastDot)
@@ -418,7 +414,6 @@ Dir_SetPATH(void)
 	    if (cur)
 		Var_Append(".PATH", cur->name, VAR_GLOBAL);
 	}
-	Lst_Close(dirSearchPath);
     }
 }
 
@@ -446,6 +441,22 @@ DirFindName(const void *p, const void *d
     return (strcmp(((const Path *)p)->name, dname));
 }
 
+static Path *
+DirFind(const struct patharray *path, const char *name)
+{
+	unsigned i, num;
+	Path *p;
+
+	num = patharray_num(path);
+	for (i=0; i<num; i++) {
+		p = patharray_get(path, i);
+		if (!strcmp(p->name, name)) {
+			return p;
+		}
+	}
+	return NULL;
+}
+
 /*-
  *-----------------------------------------------------------------------
  * Dir_HasWildcards  --
@@ -576,7 +587,8 @@ DirMatchFiles(const char *pattern, Path 
  *-----------------------------------------------------------------------
  */
 static void
-DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
+DirExpandCurly(const char *word, const char *brace,
+	       const struct patharray *path, Lst expansions)
 {
     const char   *end;	    	/* Character after the closing brace */
     const char   *cp;	    	/* Current position in brace clause */
@@ -688,17 +700,14 @@ DirExpandCurly(const char *word, const c
  *-----------------------------------------------------------------------
  */
 static void
-DirExpandInt(const char *word, Lst path, Lst expansions)
+DirExpandInt(const char *word, const struct patharray *path, Lst expansions)
 {
-    LstNode 	  ln;	    	/* Current node */
     Path	  *p;	    	/* Directory in the node */
+    unsigned i;
 
-    if (Lst_Open(path) == SUCCESS) {
-	while ((ln = Lst_Next(path)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
-	    DirMatchFiles(word, p, expansions);
-	}
-	Lst_Close(path);
+    for (i=0; i<patharray_num(path); i++) {
+	p = patharray_get(path, i);
+	DirMatchFiles(word, p, expansions);
     }
 }
 
@@ -745,7 +754,7 @@ DirPrintWord(void *word, void *dummy)
  *-----------------------------------------------------------------------
  */
 void
-Dir_Expand(const char *word, Lst path, Lst expansions)
+Dir_Expand(const char *word, const struct patharray *path, Lst expansions)
 {
     const char    	  *cp;
 
@@ -801,13 +810,23 @@ Dir_Expand(const char *word, Lst path, L
 		     * Probably not important.
 		     */
 		    if (dirpath != NULL) {
-			char *dp = &dirpath[strlen(dirpath) - 1];
+			struct patharray path2;
+			char *dp;
+
+			dp = &dirpath[strlen(dirpath) - 1];
 			if (*dp == '/')
 			    *dp = '\0';
-			path = Lst_Init(FALSE);
-			(void)Dir_AddDir(path, dirpath);
-			DirExpandInt(cp+1, path, expansions);
-			Lst_Destroy(path, NULL);
+			patharray_init(&path2);
+			(void)Dir_AddDir(&path2, dirpath);
+			DirExpandInt(cp+1, &path2, expansions);
+			patharray_setsize(&path2, 0);
+			patharray_cleanup(&path2);
+			/*
+			 * The previous code in here left this
+			 * pointing to free memory; let's null it out
+			 * instead to be safe.
+			 */
+			path = NULL;
 		    }
 		} else {
 		    /*
@@ -1044,9 +1063,8 @@ DirFindDot(Boolean hasSlash MAKE_ATTR_UN
  *-----------------------------------------------------------------------
  */
 char *
-Dir_FindFile(const char *name, Lst path)
+Dir_FindFile(const char *name, const struct patharray *path)
 {
-    LstNode       ln;			/* a list element */
     char	  *file;		/* the current filename to check */
     Path	  *p;			/* current path member */
     const char	  *cp;			/* Terminal name of file */
@@ -1055,6 +1073,7 @@ Dir_FindFile(const char *name, Lst path)
     struct stat	  stb;			/* Buffer for stat, if necessary */
     Hash_Entry	  *entry;		/* Entry for mtimes table */
     const char   *trailing_dot = ".";
+    unsigned i;
 
     /*
      * Find the final component of the name and note whether it has a
@@ -1073,6 +1092,7 @@ Dir_FindFile(const char *name, Lst path)
 	fprintf(debug_file, "Searching for %s ...", name);
     }
 
+#if 0 /* apparently no real situation corresponds to this case */
     if (Lst_Open(path) == FAILURE) {
 	if (DEBUG(DIR)) {
 	    fprintf(debug_file, "couldn't open path, file not found\n");
@@ -1080,9 +1100,10 @@ Dir_FindFile(const char *name, Lst path)
 	misses += 1;
 	return NULL;
     }
+#endif
 
-    if ((ln = Lst_First(path)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+    if (patharray_num(path) > 0) {
+	p = patharray_get(path, 0);
 	if (p == dotLast) {
 	    hasLastDot = TRUE;
             if (DEBUG(DIR))
@@ -1115,27 +1136,23 @@ Dir_FindFile(const char *name, Lst path)
 	     */
 	    if (!hasLastDot &&
 			(file = DirFindDot(hasSlash, name, cp)) != NULL) {
-		    Lst_Close(path);
 		    return file;
 	    }
 
-	    while ((ln = Lst_Next(path)) != NULL) {
-		p = (Path *)Lst_Datum(ln);
+	    for (i=1; i<patharray_num(path); i++) {
+		p = patharray_get(path, i);
 		if (p == dotLast)
 		    continue;
 		if ((file = DirLookup(p, name, cp, hasSlash)) != NULL) {
-		    Lst_Close(path);
 		    return file;
 		}
 	    }
 
 	    if (hasLastDot &&
 			(file = DirFindDot(hasSlash, name, cp)) != NULL) {
-		    Lst_Close(path);
 		    return file;
 	    }
     }
-    Lst_Close(path);
 
     /*
      * We didn't find the file on any directory in the search path.
@@ -1181,9 +1198,8 @@ Dir_FindFile(const char *name, Lst path)
 			return file;
 	}
 
-	(void)Lst_Open(path);
-	while ((ln = Lst_Next(path)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
+	for (i=0; i<patharray_num(path); i++) {
+	    p = patharray_get(path, i);
 	    if (p == dotLast)
 		continue;
 	    if (p == dot) {
@@ -1192,11 +1208,9 @@ Dir_FindFile(const char *name, Lst path)
 		checkedDot = TRUE;
 	    }
 	    if ((file = DirLookupSubdir(p, name)) != NULL) {
-		Lst_Close(path);
 		return file;
 	    }
 	}
-	Lst_Close(path);
 
 	if (hasLastDot) {
 		if (dot && !checkedDot) {
@@ -1237,20 +1251,17 @@ Dir_FindFile(const char *name, Lst path)
 	if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
 	    return *file?file:NULL;
 
-	(void)Lst_Open(path);
-	while ((ln = Lst_Next(path)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
+	for (i=0; i<patharray_num(path); i++) {
+	    p = patharray_get(path, i);
 	    if (p == dotLast)
 		continue;
 	    if ((file = DirLookupAbs(p, name, cp)) != NULL) {
-		Lst_Close(path);
-		return *file?file:NULL;
+		return *file ? file : NULL;
 	    }
 	}
-	Lst_Close(path);
 
 	if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
-	    return *file?file:NULL;
+	    return *file ? file : NULL;
     }
 
     /*
@@ -1271,7 +1282,7 @@ Dir_FindFile(const char *name, Lst path)
      * b/c we added it here. This is not good...
      */
 #ifdef notdef
-    if (cp == traling_dot) {
+    if (cp == trailing_dot) {
 	cp = strrchr(name, '/');
 	cp += 1;
     }
@@ -1280,11 +1291,10 @@ Dir_FindFile(const char *name, Lst path)
     cp[-1] = '/';
 
     bigmisses += 1;
-    ln = Lst_Last(path);
-    if (ln == NULL) {
+    if (patharray_num(path) == 0) {
 	return NULL;
     } else {
-	p = (Path *)Lst_Datum(ln);
+	p = patharray_get(path, patharray_num(path) - 1);
     }
 
     if (Hash_FindEntry(&p->files, cp) != NULL) {
@@ -1533,30 +1543,33 @@ Dir_MTime(GNode *gn, Boolean recheck)
  *-----------------------------------------------------------------------
  */
 Path *
-Dir_AddDir(Lst path, const char *name)
+Dir_AddDir(struct patharray *path, const char *name)
 {
     LstNode       ln = NULL; /* node in case Path structure is found */
-    Path	  *p = NULL;  /* pointer to new Path structure */
+    Path	  *p;        /* pointer to new Path structure */
     DIR     	  *d;	      /* for reading directory */
     struct dirent *dp;	      /* entry in directory */
 
     if (strcmp(name, ".DOTLAST") == 0) {
-	ln = Lst_Find(path, name, DirFindName);
-	if (ln != NULL)
-	    return (Path *)Lst_Datum(ln);
+	p = DirFind(path, name);
+	if (p != NULL)
+	    return p;
 	else {
 	    dotLast->refCount += 1;
-	    (void)Lst_AtFront(path, dotLast);
+	    patharray_insert(path, 0);
+	    patharray_set(path, 0, dotLast);
 	}
     }
 
+    p = NULL;
+
     if (path)
 	ln = Lst_Find(openDirectories, name, DirFindName);
     if (ln != NULL) {
 	p = (Path *)Lst_Datum(ln);
-	if (path && Lst_Member(path, p) == NULL) {
+	if (path && !patharray_contains(path, p)) {
 	    p->refCount += 1;
-	    (void)Lst_AtEnd(path, p);
+	    patharray_add(path, p, NULL);
 	}
     } else {
 	if (DEBUG(DIR)) {
@@ -1586,7 +1599,7 @@ Dir_AddDir(Lst path, const char *name)
 	    (void)closedir(d);
 	    (void)Lst_AtEnd(openDirectories, p);
 	    if (path != NULL)
-		(void)Lst_AtEnd(path, p);
+		patharray_add(path, p, NULL);
 	}
 	if (DEBUG(DIR)) {
 	    fprintf(debug_file, "done\n");
@@ -1609,11 +1622,10 @@ Dir_AddDir(Lst path, const char *name)
  *
  *-----------------------------------------------------------------------
  */
-void *
-Dir_CopyDir(void *p)
+Path *
+Dir_CopyDir(Path *p)
 {
-    ((Path *)p)->refCount += 1;
-
+    p->refCount += 1;
     return (p);
 }
 
@@ -1639,24 +1651,22 @@ Dir_CopyDir(void *p)
  *-----------------------------------------------------------------------
  */
 char *
-Dir_MakeFlags(const char *flag, Lst path)
+Dir_MakeFlags(const char *flag, const struct patharray *path)
 {
     char	  *str;	  /* the string which will be returned */
     char	  *s1, *s2;/* the current directory preceded by 'flag' */
-    LstNode	  ln;	  /* the node of the current directory */
     Path	  *p;	  /* the structure describing the current directory */
+    unsigned i, num;
 
     str = bmake_strdup("");
 
-    if (Lst_Open(path) == SUCCESS) {
-	while ((ln = Lst_Next(path)) != NULL) {
-	    p = (Path *)Lst_Datum(ln);
-	    s2 = str_concat(flag, p->name, 0);
-	    str = str_concat(s1 = str, s2, STR_ADDSPACE);
-	    free(s1);
-	    free(s2);
-	}
-	Lst_Close(path);
+    num = patharray_num(path);
+    for (i=0; i<num; i++) {
+	p = patharray_get(path, i);
+	s2 = str_concat(flag, p->name, 0);
+	str = str_concat(s1 = str, s2, STR_ADDSPACE);
+	free(s1);
+	free(s2);
     }
 
     return (str);
@@ -1681,9 +1691,8 @@ Dir_MakeFlags(const char *flag, Lst path
  *-----------------------------------------------------------------------
  */
 void
-Dir_Destroy(void *pp)
+Dir_Destroy(Path *p)
 {
-    Path    	  *p = (Path *)pp;
     p->refCount -= 1;
 
     if (p->refCount == 0) {
@@ -1702,7 +1711,7 @@ Dir_Destroy(void *pp)
  *-----------------------------------------------------------------------
  * Dir_ClearPath --
  *	Clear out all elements of the given search path. This is different
- *	from destroying the list, notice.
+ *	from destroying the array.
  *
  * Input:
  *	path		Path to clear
@@ -1711,18 +1720,20 @@ Dir_Destroy(void *pp)
  *	None.
  *
  * Side Effects:
- *	The path is set to the empty list.
+ *	The path is set to empty.
  *
  *-----------------------------------------------------------------------
  */
 void
-Dir_ClearPath(Lst path)
+Dir_ClearPath(struct patharray *path)
 {
-    Path    *p;
-    while (!Lst_IsEmpty(path)) {
-	p = (Path *)Lst_DeQueue(path);
-	Dir_Destroy(p);
-    }
+	unsigned num, i;
+
+	num = patharray_num(path);
+	for (i=0; i<num; i++) {
+		Dir_Destroy(patharray_get(path, i));
+	}
+	patharray_setsize(path, 0);
 }
 
 
@@ -1745,16 +1756,17 @@ Dir_ClearPath(Lst path)
  *-----------------------------------------------------------------------
  */
 void
-Dir_Concat(Lst path1, Lst path2)
+Dir_Concat(struct patharray *path1, const struct patharray *path2)
 {
-    LstNode ln;
-    Path    *p;
+    unsigned i, num;
+    Path *p;
 
-    for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) {
-	p = (Path *)Lst_Datum(ln);
-	if (Lst_Member(path1, p) == NULL) {
+    num = patharray_num(path2);
+    for (i=0; i<num; i++) {
+	p = patharray_get(path2, i);
+	if (!patharray_contains(path1, p)) {
 	    p->refCount += 1;
-	    (void)Lst_AtEnd(path1, p);
+	    patharray_add(path1, p, NULL);
 	}
     }
 }
@@ -1781,15 +1793,15 @@ Dir_PrintDirectories(void)
     }
 }
 
-static int
-DirPrintDir(void *p, void *dummy)
-{
-    fprintf(debug_file, "%s ", ((Path *)p)->name);
-    return (dummy ? 0 : 0);
-}
-
 void
-Dir_PrintPath(Lst path)
+Dir_PrintPath(const struct patharray *path)
 {
-    Lst_ForEach(path, DirPrintDir, NULL);
+	unsigned i, num;
+	Path *p;
+
+	num = patharray_num(path);
+	for (i=0; i<num; i++) {
+		p = patharray_get(path, i);
+		fprintf(debug_file, "%s ", p->name);
+	}
 }

Index: othersrc/usr.bin/dholland-make2/dir.h
diff -u othersrc/usr.bin/dholland-make2/dir.h:1.1.1.1 othersrc/usr.bin/dholland-make2/dir.h:1.2
--- othersrc/usr.bin/dholland-make2/dir.h:1.1.1.1	Mon Feb 25 01:32:53 2013
+++ othersrc/usr.bin/dholland-make2/dir.h	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.1.1.1 2013/02/25 01:32:53 dholland Exp $	*/
+/*	$NetBSD: dir.h,v 1.2 2013/03/05 01:44:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -78,6 +78,8 @@
 #ifndef	_DIR
 #define	_DIR
 
+#include "array.h"
+
 typedef struct Path {
     char         *name;	    	/* Name of directory */
     int	    	  refCount; 	/* Number of paths with this directory */
@@ -86,23 +88,30 @@ typedef struct Path {
     Hash_Table    files;    	/* Hash table of files in directory */
 } Path;
 
+/* struct patharray -> array of Path */
+DECLARRAY_BYTYPE(patharray, struct Path, MAKE_INLINE);
+DEFARRAY_BYTYPE(patharray, struct Path, MAKE_INLINE);
+/* struct patharrayarray -> array of patharray (used in parse.c) */
+DECLARRAY(patharray, MAKE_INLINE);
+DEFARRAY(patharray, MAKE_INLINE);
+
 void Dir_Init(const char *);
 void Dir_InitCur(const char *);
 void Dir_InitDot(void);
 void Dir_End(void);
 void Dir_SetPATH(void);
 Boolean Dir_HasWildcards(char *);
-void Dir_Expand(const char *, Lst, Lst);
-char *Dir_FindFile(const char *, Lst);
+void Dir_Expand(const char *, const struct patharray *, Lst);
+char *Dir_FindFile(const char *, const struct patharray *);
 int Dir_FindHereOrAbove(char *, char *, char *, int);
 int Dir_MTime(GNode *, Boolean);
-Path *Dir_AddDir(Lst, const char *);
-char *Dir_MakeFlags(const char *, Lst);
-void Dir_ClearPath(Lst);
-void Dir_Concat(Lst, Lst);
+Path *Dir_AddDir(struct patharray *, const char *);
+char *Dir_MakeFlags(const char *, const struct patharray *);
+void Dir_ClearPath(struct patharray *);
+void Dir_Concat(struct patharray *, const struct patharray *);
 void Dir_PrintDirectories(void);
-void Dir_PrintPath(Lst);
-void Dir_Destroy(void *);
-void * Dir_CopyDir(void *);
+void Dir_PrintPath(const struct patharray *);
+void Dir_Destroy(Path *);
+Path *Dir_CopyDir(Path *);
 
 #endif /* _DIR */

Index: othersrc/usr.bin/dholland-make2/make.h
diff -u othersrc/usr.bin/dholland-make2/make.h:1.7 othersrc/usr.bin/dholland-make2/make.h:1.8
--- othersrc/usr.bin/dholland-make2/make.h:1.7	Mon Mar  4 23:31:57 2013
+++ othersrc/usr.bin/dholland-make2/make.h	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.7 2013/03/04 23:31:57 dholland Exp $	*/
+/*	$NetBSD: make.h,v 1.8 2013/03/05 01:44:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -161,8 +161,9 @@
 extern Lst  	create;	    	/* The list of target names specified on the
 				 * command line. used to resolve #if
 				 * make(...) statements */
-extern Lst     	dirSearchPath; 	/* The list of directories to search when
-				 * looking for targets */
+
+/* The list of directories to search when looking for targets */
+extern struct patharray dirSearchPath;
 
 extern Boolean	compatMake;	/* True if we are make compatible */
 extern Boolean	ignoreErrors;  	/* True if should ignore all errors */
@@ -206,9 +207,9 @@ extern time_t 	now;	    	/* The time at 
 
 extern Boolean	oldVars;    	/* Do old-style variable substitution */
 
-extern Lst	parseIncPath;	/* The general include path, for "". */
-extern Lst	sysIncPath;	/* The system include path, for <>. */
-extern Lst	defIncPath;	/* The default include path. */
+extern struct patharray parseIncPath;	/* The general include path, for "". */
+extern struct patharray	sysIncPath;	/* The system include path, for <>. */
+extern struct patharray	defIncPath;	/* The default include path. */
 
 extern char	curdir[];	/* Startup directory */
 extern char	*progname;	/* The program name */

Index: othersrc/usr.bin/dholland-make2/suff.c
diff -u othersrc/usr.bin/dholland-make2/suff.c:1.5 othersrc/usr.bin/dholland-make2/suff.c:1.6
--- othersrc/usr.bin/dholland-make2/suff.c:1.5	Mon Mar  4 23:03:42 2013
+++ othersrc/usr.bin/dholland-make2/suff.c	Tue Mar  5 01:44:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.5 2013/03/04 23:03:42 dholland Exp $	*/
+/*	$NetBSD: suff.c,v 1.6 2013/03/05 01:44:34 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.5 2013/03/04 23:03:42 dholland Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.6 2013/03/05 01:44:34 dholland Exp $");
 
 static Lst       sufflist;	/* Lst of suffixes */
 #ifdef CLEANUP
@@ -152,7 +152,7 @@ typedef struct _Suff {
 #define SUFF_INCLUDE	  0x01	    /* One which is #include'd */
 #define SUFF_LIBRARY	  0x02	    /* One which contains a library */
 #define SUFF_NULL 	  0x04	    /* The empty suffix */
-    Lst    	 searchPath;	/* The path along which files of this suffix
+    struct patharray searchPath;/* The path along which files of this suffix
 				 * may be found */
     int          sNum;	      	/* The suffix number */
     int		 refCount;	/* Reference count of list membership */
@@ -419,6 +419,7 @@ static void
 SuffFree(void *sp)
 {
     Suff           *s = (Suff *)sp;
+    unsigned i;
 
     if (s == suffNull)
 	suffNull = NULL;
@@ -436,7 +437,11 @@ SuffFree(void *sp)
     Lst_Destroy(s->ref, NULL);
     Lst_Destroy(s->children, NULL);
     Lst_Destroy(s->parents, NULL);
-    Lst_Destroy(s->searchPath, Dir_Destroy);
+    for (i=0; i<patharray_num(&s->searchPath); i++) {
+	Dir_Destroy(patharray_get(&s->searchPath, i));
+    }
+    patharray_setsize(&s->searchPath, 0);
+    patharray_cleanup(&s->searchPath);
 
     free(s->name);
     free(s);
@@ -962,7 +967,7 @@ Suff_AddSuffix(char *str, GNode **gn)
 
 	s->name =   	bmake_strdup(str);
 	s->nameLen = 	strlen(s->name);
-	s->searchPath = Lst_Init(FALSE);
+	patharray_init(&s->searchPath);
 	s->children = 	Lst_Init(FALSE);
 	s->parents = 	Lst_Init(FALSE);
 	s->ref = 	Lst_Init(FALSE);
@@ -1002,7 +1007,7 @@ Suff_AddSuffix(char *str, GNode **gn)
  *	None
  *-----------------------------------------------------------------------
  */
-Lst
+struct patharray *
 Suff_GetPath(char *sname)
 {
     LstNode   	  ln;
@@ -1013,7 +1018,7 @@ Suff_GetPath(char *sname)
 	return NULL;
     } else {
 	s = (Suff *)Lst_Datum(ln);
-	return (s->searchPath);
+	return &s->searchPath;
     }
 }
 
@@ -1035,49 +1040,64 @@ Suff_GetPath(char *sname)
  *	".LIBS" and the flag is -L.
  *-----------------------------------------------------------------------
  */
+
 void
 Suff_DoPaths(void)
 {
     Suff	   	*s;
     LstNode  		ln;
     char		*ptr;
-    Lst	    	    	inIncludes; /* Cumulative .INCLUDES path */
-    Lst	    	    	inLibs;	    /* Cumulative .LIBS path */
+    struct patharray   	inIncludes; /* Cumulative .INCLUDES path */
+    struct patharray   	inLibs;	    /* Cumulative .LIBS path */
+    unsigned i, num;
 
     if (Lst_Open(sufflist) == FAILURE) {
 	return;
     }
 
-    inIncludes = Lst_Init(FALSE);
-    inLibs = Lst_Init(FALSE);
+    patharray_init(&inIncludes);
+    patharray_init(&inLibs);
 
     while ((ln = Lst_Next(sufflist)) != NULL) {
 	s = (Suff *)Lst_Datum(ln);
-	if (!Lst_IsEmpty (s->searchPath)) {
+	if (patharray_num(&s->searchPath) > 0) {
 #ifdef INCLUDES
 	    if (s->flags & SUFF_INCLUDE) {
-		Dir_Concat(inIncludes, s->searchPath);
+		Dir_Concat(&inIncludes, &s->searchPath);
 	    }
 #endif /* INCLUDES */
 #ifdef LIBRARIES
 	    if (s->flags & SUFF_LIBRARY) {
-		Dir_Concat(inLibs, s->searchPath);
+		Dir_Concat(&inLibs, &s->searchPath);
 	    }
 #endif /* LIBRARIES */
-	    Dir_Concat(s->searchPath, dirSearchPath);
 	} else {
-	    Lst_Destroy(s->searchPath, Dir_Destroy);
-	    s->searchPath = Lst_Duplicate(dirSearchPath, Dir_CopyDir);
+	    num = patharray_num(&s->searchPath);
 	}
+	Dir_Concat(&s->searchPath, &dirSearchPath);
     }
 
-    Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL, 0);
+    ptr = Dir_MakeFlags("-I", &inIncludes);
+    Var_Set(".INCLUDES", ptr, VAR_GLOBAL, 0);
     free(ptr);
-    Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL, 0);
+
+    ptr = Dir_MakeFlags("-L", &inLibs);
+    Var_Set(".LIBS", ptr, VAR_GLOBAL, 0);
     free(ptr);
 
-    Lst_Destroy(inIncludes, Dir_Destroy);
-    Lst_Destroy(inLibs, Dir_Destroy);
+    num = patharray_num(&inIncludes);
+    for (i=0; i<num; i++) {
+	Dir_Destroy(patharray_get(&inIncludes, i));
+    }
+    patharray_setsize(&inIncludes, 0);
+    patharray_cleanup(&inIncludes);
+
+    num = patharray_num(&inLibs);
+    for (i=0; i<num; i++) {
+	Dir_Destroy(patharray_get(&inLibs, i));
+    }
+    patharray_setsize(&inLibs, 0);
+    patharray_cleanup(&inLibs);
 
     Lst_Close(sufflist);
 }
@@ -1357,7 +1377,7 @@ SuffFindThem(Lst srcs, Lst slst)
 	    break;
 	}
 
-	if ((ptr = Dir_FindFile(s->file, s->suff->searchPath)) != NULL) {
+	if ((ptr = Dir_FindFile(s->file, &s->suff->searchPath)) != NULL) {
 	    rs = s;
 #ifdef DEBUG_SRC
 	    fprintf(debug_file, "remove %x from %x\n", s, srcs);
@@ -1765,7 +1785,7 @@ SuffExpandWildcards(GNode *cgn, unsigned
  *
  *-----------------------------------------------------------------------
  */
-Lst
+const struct patharray *
 Suff_FindPath(GNode* gn)
 {
     Suff *suff = gn->suffix;
@@ -1789,12 +1809,12 @@ Suff_FindPath(GNode* gn)
 	if (DEBUG(SUFF)) {
 	    fprintf(debug_file, "suffix is \"%s\"...", suff->name);
 	}
-	return suff->searchPath;
+	return &suff->searchPath;
     } else {
 	/*
 	 * Use default search path
 	 */
-	return dirSearchPath;
+	return &dirSearchPath;
     }
 }
 
@@ -2243,8 +2263,8 @@ sfnd_abort:
 	if ((gn->type & (OP_PHONY|OP_NOPATH)) == 0) {
 	    free(gn->path);
 	    gn->path = Dir_FindFile(gn->name,
-				    (targ == NULL ? dirSearchPath :
-				     targ->suff->searchPath));
+				    (targ == NULL ? &dirSearchPath :
+				     &targ->suff->searchPath));
 	    if (gn->path != NULL) {
 		char *ptr;
 		Var_Set(TARGET, gn->path, gn, 0);
@@ -2491,7 +2511,7 @@ SuffFindDeps(GNode *gn, Lst slst)
 	if (ln != NULL) {
 	    gn->suffix = s = (Suff *)Lst_Datum(ln);
 	    gn->suffix->refCount++;
-	    Arch_FindLib(gn, s->searchPath);
+	    Arch_FindLib(gn, &s->searchPath);
 	} else {
 	    gn->suffix = NULL;
 	    Var_Set(TARGET, gn->name, gn, 0);
@@ -2582,8 +2602,8 @@ Suff_Init(void)
 
     suffNull->name =   	    bmake_strdup("");
     suffNull->nameLen =     0;
-    suffNull->searchPath =  Lst_Init(FALSE);
-    Dir_Concat(suffNull->searchPath, dirSearchPath);
+    patharray_init(&suffNull->searchPath);
+    Dir_Concat(&suffNull->searchPath, &dirSearchPath);
     suffNull->children =    Lst_Init(FALSE);
     suffNull->parents =	    Lst_Init(FALSE);
     suffNull->ref =	    Lst_Init(FALSE);
@@ -2666,7 +2686,7 @@ SuffPrintSuff(void *sp, void *dummy)
     Lst_ForEach(s->children, SuffPrintName, NULL);
     fputc('\n', debug_file);
     fprintf(debug_file, "#\tSearch Path: ");
-    Dir_PrintPath(s->searchPath);
+    Dir_PrintPath(&s->searchPath);
     fputc('\n', debug_file);
     return (dummy ? 0 : 0);
 }

Reply via email to