Module Name: src
Committed By: rillig
Date: Sat Aug 22 00:48:02 UTC 2020
Modified Files:
src/usr.bin/make: dir.c dir.h main.c
Log Message:
make(1): split Dir_Init into two functions
There's just no point in having a function consisting of a big
if-then-else.
To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/dir.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/dir.h
cvs rdiff -u -r1.305 -r1.306 src/usr.bin/make/main.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.96 src/usr.bin/make/dir.c:1.97
--- src/usr.bin/make/dir.c:1.96 Fri Aug 21 04:42:02 2020
+++ src/usr.bin/make/dir.c Sat Aug 22 00:48:02 2020
@@ -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 @@ cached_lstat(const char *pathname, void
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)
+{
+ dirSearchPath = Lst_Init();
+ openDirectories = Lst_Init();
+ Hash_InitTable(&mtimes, 0);
+ Hash_InitTable(&lmtimes, 0);
+}
+
+void
+Dir_InitDir(const char *cdname)
{
- if (!cdname) {
- dirSearchPath = Lst_Init();
- openDirectories = Lst_Init();
- Hash_InitTable(&mtimes, 0);
- Hash_InitTable(&lmtimes, 0);
- return;
- }
Dir_InitCur(cdname);
dotLast = bmake_malloc(sizeof(Path));
@@ -383,7 +378,7 @@ Dir_Init(const char *cdname)
}
/*
- * 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)
Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.18 src/usr.bin/make/dir.h:1.19
--- src/usr.bin/make/dir.h:1.18 Wed May 31 22:02:06 2017
+++ src/usr.bin/make/dir.h Sat Aug 22 00:48:02 2020
@@ -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 @@ typedef struct Path {
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);
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.305 src/usr.bin/make/main.c:1.306
--- src/usr.bin/make/main.c:1.305 Fri Aug 21 02:20:47 2020
+++ src/usr.bin/make/main.c Sat Aug 22 00:48:02 2020
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#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 @@ main(int argc, char **argv)
#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 @@ main(int argc, char **argv)
* 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) &&