Redo the hashtable for "." if .OBJDIR changes.

This commit is contained in:
tv 2001-11-12 21:58:17 +00:00
parent 36d6a03ffd
commit e4b456f8b8
3 changed files with 49 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.27 2001/11/11 21:36:06 tv Exp $ */
/* $NetBSD: dir.c,v 1.28 2001/11/12 21:58:17 tv Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: dir.c,v 1.27 2001/11/11 21:36:06 tv Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.28 2001/11/12 21:58:17 tv 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.27 2001/11/11 21:36:06 tv Exp $");
__RCSID("$NetBSD: dir.c,v 1.28 2001/11/12 21:58:17 tv Exp $");
#endif
#endif /* not lint */
#endif
@ -231,24 +231,6 @@ Dir_Init (cdname)
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?
*/
dot = Dir_AddDir (NULL, ".");
if (dot == NULL) {
Error("Cannot open `.' (%s)", strerror(errno));
exit(1);
}
/*
* We always need to have dot around, so we increment its reference count
* to make sure it's not destroyed.
*/
dot->refCount += 1;
if (cdname != NULL) {
/*
* Our build directory is not the same as our source directory.
@ -265,6 +247,43 @@ Dir_Init (cdname)
Hash_InitTable (&dotLast->files, -1);
}
/*-
*-----------------------------------------------------------------------
* Dir_InitDot --
* (re)initialize "dot" (current/object directory) path hash
*
* Results:
* none
*
* Side Effects:
* some directories may be opened.
*-----------------------------------------------------------------------
*/
void
Dir_InitDot()
{
if (dot != NULL) {
LstNode ln;
/* Remove old entry from openDirectories, but do not destroy. */
ln = Lst_Member (openDirectories, (ClientData)dot);
(void) Lst_Remove (openDirectories, ln);
}
dot = Dir_AddDir (NULL, ".");
if (dot == NULL) {
Error("Cannot open `.' (%s)", strerror(errno));
exit(1);
}
/*
* We always need to have dot around, so we increment its reference count
* to make sure it's not destroyed.
*/
dot->refCount += 1;
}
/*-
*-----------------------------------------------------------------------
* Dir_End --

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.h,v 1.5 1997/05/08 21:24:42 gwr Exp $ */
/* $NetBSD: dir.h,v 1.6 2001/11/12 21:58:18 tv Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -55,6 +55,7 @@ typedef struct Path {
} Path;
void Dir_Init __P((const char *));
void Dir_InitDot __P((void));
void Dir_End __P((void));
Boolean Dir_HasWildcards __P((char *));
void Dir_Expand __P((char *, Lst, Lst));

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.78 2001/11/12 01:33:48 tv Exp $ */
/* $NetBSD: main.c,v 1.79 2001/11/12 21:58:18 tv Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,7 +39,7 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: main.c,v 1.78 2001/11/12 01:33:48 tv Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.79 2001/11/12 21:58:18 tv Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.78 2001/11/12 01:33:48 tv Exp $");
__RCSID("$NetBSD: main.c,v 1.79 2001/11/12 21:58:18 tv Exp $");
#endif
#endif /* not lint */
#endif
@ -482,6 +482,7 @@ Main_SetObjdir(path)
strncpy(objdir, path, MAXPATHLEN);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
setenv("PWD", objdir, 1);
Dir_InitDot();
rc = TRUE;
}
}
@ -636,7 +637,9 @@ main(argc, argv)
* finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none
* of these paths exist, just use .CURDIR.
*/
Dir_Init(curdir);
(void) Main_SetObjdir(curdir);
if ((path = getenv("MAKEOBJDIRPREFIX")) != NULL) {
(void) snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir);
(void) Main_SetObjdir(mdpath);
@ -683,20 +686,13 @@ main(argc, argv)
* command line
*/
/*
* Initialize directory structures so -I flags can be processed
* correctly.
*/
Dir_Init(curdir);
Parse_Init(); /* Need to initialize the paths of #include
* directories */
/*
* Initialize various variables.
* MAKE also gets this name, for compatibility
* .MAKEFLAGS gets set to the empty string just in case.
* MFLAGS also gets initialized empty, for compatibility.
*/
Parse_Init();
Var_Set("MAKE", argv[0], VAR_GLOBAL, 0);
Var_Set(".MAKE", argv[0], VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);