Module Name:    src
Committed By:   sjg
Date:           Tue Jan 31 06:54:24 UTC 2017

Modified Files:
        src/usr.bin/make: dir.c main.c

Log Message:
Partially initialize Dir before MainParseArgs can be called.

The rest can be done once curdir is finalized.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/dir.c
cvs rdiff -u -r1.254 -r1.255 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.68 src/usr.bin/make/dir.c:1.69
--- src/usr.bin/make/dir.c:1.68	Tue Jun  7 00:40:00 2016
+++ src/usr.bin/make/dir.c	Tue Jan 31 06:54:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $	*/
+/*	$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg 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.68 2016/06/07 00:40:00 sjg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg 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.68 2016/06/07 00:40:00 sjg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -346,11 +346,13 @@ cached_lstat(const char *pathname, void 
 void
 Dir_Init(const char *cdname)
 {
-    dirSearchPath = Lst_Init(FALSE);
-    openDirectories = Lst_Init(FALSE);
-    Hash_InitTable(&mtimes, 0);
-    Hash_InitTable(&lmtimes, 0);
-
+    if (!cdname) {
+	dirSearchPath = Lst_Init(FALSE);
+	openDirectories = Lst_Init(FALSE);
+	Hash_InitTable(&mtimes, 0);
+	Hash_InitTable(&lmtimes, 0);
+	return;
+    }
     Dir_InitCur(cdname);
 
     dotLast = bmake_malloc(sizeof(Path));

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.254 src/usr.bin/make/main.c:1.255
--- src/usr.bin/make/main.c:1.254	Sat Dec 10 23:12:39 2016
+++ src/usr.bin/make/main.c	Tue Jan 31 06:54:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.254 2016/12/10 23:12:39 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.255 2017/01/31 06:54:23 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.254 2016/12/10 23:12:39 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.255 2017/01/31 06:54:23 sjg 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.254 2016/12/10 23:12:39 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.255 2017/01/31 06:54:23 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1038,6 +1038,8 @@ main(int argc, char **argv)
 #ifdef USE_META
 	meta_init();
 #endif
+	Dir_Init(NULL);		/* Dir_* safe to call from MainParseArgs */
+
 	/*
 	 * First snag any flags out of the MAKE environment variable.
 	 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
@@ -1279,7 +1281,8 @@ main(int argc, char **argv)
 	    fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
 		jp_0, jp_1, maxJobs, maxJobTokens, compatMake);
 
-	Main_ExportMAKEFLAGS(TRUE);	/* initial export */
+	if (!printVars)
+	    Main_ExportMAKEFLAGS(TRUE);	/* initial export */
 	
 
 	/*

Reply via email to