Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): replace Dir_CopyDir with Dir_CopyDirSe...
details: https://anonhg.NetBSD.org/src/rev/844206eb7e26
branches: trunk
changeset: 956264:844206eb7e26
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 25 10:00:20 2020 +0000
description:
make(1): replace Dir_CopyDir with Dir_CopyDirSearchPath
Callback functions for the Lst functions do not belong in the public API
of a module.
diffstat:
usr.bin/make/dir.c | 31 ++++++++++++++-----------------
usr.bin/make/dir.h | 4 ++--
usr.bin/make/suff.c | 6 +++---
3 files changed, 19 insertions(+), 22 deletions(-)
diffs (98 lines):
diff -r 5c7292d73f05 -r 844206eb7e26 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Oct 25 09:51:52 2020 +0000
+++ b/usr.bin/make/dir.c Sun Oct 25 10:00:20 2020 +0000
@@ -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 @@
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;
}
/*-
diff -r 5c7292d73f05 -r 844206eb7e26 usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Sun Oct 25 09:51:52 2020 +0000
+++ b/usr.bin/make/dir.h Sun Oct 25 10:00:20 2020 +0000
@@ -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_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 {
diff -r 5c7292d73f05 -r 844206eb7e26 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sun Oct 25 09:51:52 2020 +0000
+++ b/usr.bin/make/suff.c Sun Oct 25 10:00:20 2020 +0000
@@ -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 @@
Dir_Concat(s->searchPath, dirSearchPath);
} else {
Lst_Destroy(s->searchPath, Dir_Destroy);
- s->searchPath = Lst_Copy(dirSearchPath, Dir_CopyDir);
+ s->searchPath = Dir_CopyDirSearchPath();
}
}
Home |
Main Index |
Thread Index |
Old Index