summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/dir.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-09-14 12:31:33 +0000
committerru <ru@FreeBSD.org>2003-09-14 12:31:33 +0000
commit7ad89d9544793f73cd7d3d7d7f44562f89a49bcd (patch)
tree1cea0f2344264c01652889b9f3cbc0119cb30b33 /usr.bin/make/dir.c
parent50888524cab7543731fcbf46443bd1644d900523 (diff)
downloadFreeBSD-src-7ad89d9544793f73cd7d3d7d7f44562f89a49bcd.zip
FreeBSD-src-7ad89d9544793f73cd7d3d7d7f44562f89a49bcd.tar.gz
- Cut out the code that caches the "." directory out of Dir_Init()
into a separate function, Dir_InitDot(). - Postpone the current and object directories detection (and caching of the "." directory) until after all command line arguments are parsed. This makes the -C option DTRT. PR: bin/47149
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r--usr.bin/make/dir.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 49a3cf9..57d1687 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -205,7 +205,7 @@ static int DirPrintDir(void *, void *);
* none
*
* Side Effects:
- * some directories may be opened.
+ * none
*-----------------------------------------------------------------------
*/
void
@@ -214,15 +214,25 @@ Dir_Init (void)
dirSearchPath = Lst_Init (FALSE);
openDirectories = Lst_Init (FALSE);
Hash_InitTable(&mtimes, 0);
+}
- /*
- * Since the Path structure is placed on both openDirectories and
- * the path we give Dir_AddDir (which in this case is openDirectories),
- * we need to remove "." from openDirectories and what better time to
- * do it than when we have to fetch the thing anyway?
- */
+/*-
+ *-----------------------------------------------------------------------
+ * Dir_InitDot --
+ * initialize the "." directory
+ *
+ * Results:
+ * none
+ *
+ * Side Effects:
+ * some directories may be opened.
+ *-----------------------------------------------------------------------
+ */
+void
+Dir_InitDot (void)
+{
Dir_AddDir (openDirectories, ".");
- dot = (Path *) Lst_DeQueue (openDirectories);
+ dot = (Path *)Lst_Datum(Lst_Last(openDirectories));
if (dot == (Path *) NULL)
err(1, "cannot open current directory");
@@ -1031,7 +1041,8 @@ Dir_AddDir (Lst path, char *name)
}
(void) closedir (d);
(void)Lst_AtEnd (openDirectories, (void *)p);
- (void)Lst_AtEnd (path, (void *)p);
+ if (path != openDirectories)
+ (void)Lst_AtEnd (path, (void *)p);
}
DEBUGF(DIR, ("done\n"));
}
OpenPOWER on IntegriCloud