Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 10:00:20 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c dir.h suff.c

Log Message:
make(1): replace Dir_CopyDir with Dir_CopyDirSearchPath

Callback functions for the Lst functions do not belong in the public API
of a module.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/dir.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/dir.h
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.186 src/usr.bin/make/dir.c:1.187
--- src/usr.bin/make/dir.c:1.186	Sun Oct 25 09:51:52 2020
+++ src/usr.bin/make/dir.c	Sun Oct 25 10:00:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,7 +135,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1447,22 +1447,19 @@ Dir_AddDir(SearchPath *path, const char 
     return dir;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Dir_CopyDir --
- *	Callback function for duplicating a search path via Lst_Copy.
- *	Ups the reference count for the directory.
- *
- * Results:
- *	Returns the Path it was given.
- *-----------------------------------------------------------------------
- */
-void *
-Dir_CopyDir(void *p)
+/* Return a copy of dirSearchPath, incrementing the reference counts for
+ * the contained directories. */
+SearchPath *
+Dir_CopyDirSearchPath(void)
 {
-    CachedDir *dir = p;
-    dir->refCount++;
-    return dir;
+    SearchPath *path = Lst_New();
+    SearchPathNode *ln;
+    for (ln = dirSearchPath->first; ln != NULL; ln = ln->next) {
+	CachedDir *dir = ln->datum;
+	dir->refCount++;
+        Lst_Append(path, dir);
+    }
+    return path;
 }
 
 /*-

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.31 src/usr.bin/make/dir.h:1.32
--- src/usr.bin/make/dir.h:1.31	Mon Oct 19 23:43:55 2020
+++ src/usr.bin/make/dir.h	Sun Oct 25 10:00:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.31 2020/10/19 23:43:55 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.32 2020/10/25 10:00:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -109,7 +109,7 @@ void Dir_Concat(SearchPath *, SearchPath
 void Dir_PrintDirectories(void);
 void Dir_PrintPath(SearchPath *);
 void Dir_Destroy(void *);
-void *Dir_CopyDir(void *);
+SearchPath *Dir_CopyDirSearchPath(void);
 
 /* Stripped-down variant of struct stat. */
 struct make_stat {

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.222 src/usr.bin/make/suff.c:1.223
--- src/usr.bin/make/suff.c:1.222	Sat Oct 24 10:36:23 2020
+++ src/usr.bin/make/suff.c	Sun Oct 25 10:00:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.222 2020/10/24 10:36:23 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.222 2020/10/24 10:36:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -789,7 +789,7 @@ Suff_DoPaths(void)
 	    Dir_Concat(s->searchPath, dirSearchPath);
 	} else {
 	    Lst_Destroy(s->searchPath, Dir_Destroy);
-	    s->searchPath = Lst_Copy(dirSearchPath, Dir_CopyDir);
+	    s->searchPath = Dir_CopyDirSearchPath();
 	}
     }
 

Reply via email to