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): split Dir_Init into two functions
details: https://anonhg.NetBSD.org/src/rev/3097373e9e47
branches: trunk
changeset: 937576:3097373e9e47
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 22 00:48:02 2020 +0000
description:
make(1): split Dir_Init into two functions
There's just no point in having a function consisting of a big
if-then-else.
diffstat:
usr.bin/make/dir.c | 35 +++++++++++++++--------------------
usr.bin/make/dir.h | 5 +++--
usr.bin/make/main.c | 10 +++++-----
3 files changed, 23 insertions(+), 27 deletions(-)
diffs (139 lines):
diff -r d41ba3855236 -r 3097373e9e47 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sat Aug 22 00:13:16 2020 +0000
+++ b/usr.bin/make/dir.c Sat Aug 22 00:48:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.97 2020/08/22 00:48:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.97 2020/08/22 00:48:02 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.97 2020/08/22 00:48:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -351,28 +351,23 @@
return cached_stats(&lmtimes, pathname, st, CST_LSTAT);
}
-/*-
- *-----------------------------------------------------------------------
- * Dir_Init --
- * initialize things for this module
- *
- * Results:
- * none
+/* Initialize things for this module.
*
* Side Effects:
* some directories may be opened.
- *-----------------------------------------------------------------------
*/
void
-Dir_Init(const char *cdname)
+Dir_Init(void)
{
- if (!cdname) {
- dirSearchPath = Lst_Init();
- openDirectories = Lst_Init();
- Hash_InitTable(&mtimes, 0);
- Hash_InitTable(&lmtimes, 0);
- return;
- }
+ dirSearchPath = Lst_Init();
+ openDirectories = Lst_Init();
+ Hash_InitTable(&mtimes, 0);
+ Hash_InitTable(&lmtimes, 0);
+}
+
+void
+Dir_InitDir(const char *cdname)
+{
Dir_InitCur(cdname);
dotLast = bmake_malloc(sizeof(Path));
@@ -383,7 +378,7 @@
}
/*
- * Called by Dir_Init() and whenever .CURDIR is assigned to.
+ * Called by Dir_InitDir and whenever .CURDIR is assigned to.
*/
void
Dir_InitCur(const char *cdname)
diff -r d41ba3855236 -r 3097373e9e47 usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Sat Aug 22 00:13:16 2020 +0000
+++ b/usr.bin/make/dir.h Sat Aug 22 00:48:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.18 2017/05/31 22:02:06 maya Exp $ */
+/* $NetBSD: dir.h,v 1.19 2020/08/22 00:48:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -86,7 +86,8 @@
Hash_Table files; /* Hash table of files in directory */
} Path;
-void Dir_Init(const char *);
+void Dir_Init(void);
+void Dir_InitDir(const char *);
void Dir_InitCur(const char *);
void Dir_InitDot(void);
void Dir_End(void);
diff -r d41ba3855236 -r 3097373e9e47 usr.bin/make/main.c
--- a/usr.bin/make/main.c Sat Aug 22 00:13:16 2020 +0000
+++ b/usr.bin/make/main.c Sat Aug 22 00:48:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.305 2020/08/21 02:20:47 rillig Exp $ */
+/* $NetBSD: main.c,v 1.306 2020/08/22 00:48:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.305 2020/08/21 02:20:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.306 2020/08/22 00:48:02 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.305 2020/08/21 02:20:47 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.306 2020/08/22 00:48:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1168,7 +1168,7 @@
#ifdef USE_META
meta_init();
#endif
- Dir_Init(NULL); /* Dir_* safe to call from MainParseArgs */
+ Dir_Init();
/*
* First snag any flags out of the MAKE environment variable.
@@ -1249,7 +1249,7 @@
* and * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none
* of these paths exist, just use .CURDIR.
*/
- Dir_Init(curdir);
+ Dir_InitDir(curdir);
(void)Main_SetObjdir("%s", curdir);
if (!Main_SetVarObjdir("MAKEOBJDIRPREFIX", curdir) &&
Home |
Main Index |
Thread Index |
Old Index