summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r--usr.bin/make/dir.c88
1 files changed, 62 insertions, 26 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index a3093ad..6ed3c19 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -49,6 +49,8 @@ static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
* The interface for this module is:
* Dir_Init Initialize the module.
*
+ * Dir_End Cleanup the module.
+ *
* Dir_HasWildcards Returns TRUE if the name given it needs to
* be wildcard-expanded.
*
@@ -184,12 +186,12 @@ static Hash_Table mtimes; /* Results of doing a last-resort stat in
* should be ok, but... */
-static int DirFindName __P((Path *, char *));
+static int DirFindName __P((ClientData, ClientData));
static int DirMatchFiles __P((char *, Path *, Lst));
static void DirExpandCurly __P((char *, char *, Lst, Lst));
static void DirExpandInt __P((char *, Lst, Lst));
-static int DirPrintWord __P((char *));
-static int DirPrintDir __P((Path *));
+static int DirPrintWord __P((ClientData, ClientData));
+static int DirPrintDir __P((ClientData, ClientData));
/*-
*-----------------------------------------------------------------------
@@ -228,6 +230,30 @@ Dir_Init ()
/*-
*-----------------------------------------------------------------------
+ * Dir_End --
+ * cleanup things for this module
+ *
+ * Results:
+ * none
+ *
+ * Side Effects:
+ * none
+ *-----------------------------------------------------------------------
+ */
+void
+Dir_End()
+{
+ dot->refCount -= 1;
+ Dir_Destroy((ClientData) dot);
+ Dir_ClearPath(dirSearchPath);
+ Lst_Destroy(dirSearchPath, NOFREE);
+ Dir_ClearPath(openDirectories);
+ Lst_Destroy(openDirectories, NOFREE);
+ Hash_DeleteTable(&mtimes);
+}
+
+/*-
+ *-----------------------------------------------------------------------
* DirFindName --
* See if the Path structure describes the same directory as the
* given one by comparing their names. Called from Dir_AddDir via
@@ -242,10 +268,10 @@ Dir_Init ()
*/
static int
DirFindName (p, dname)
- Path *p; /* Current name */
- char *dname; /* Desired name */
+ ClientData p; /* Current name */
+ ClientData dname; /* Desired name */
{
- return (strcmp (p->name, dname));
+ return (strcmp (((Path *)p)->name, (char *) dname));
}
/*-
@@ -490,12 +516,13 @@ DirExpandInt(word, path, expansions)
*-----------------------------------------------------------------------
*/
static int
-DirPrintWord(word)
- char *word;
+DirPrintWord(word, dummy)
+ ClientData word;
+ ClientData dummy;
{
- printf("%s ", word);
+ printf("%s ", (char *) word);
- return(0);
+ return(dummy ? 0 : 0);
}
/*-
@@ -606,7 +633,7 @@ Dir_Expand (word, path, expansions)
}
}
if (DEBUG(DIR)) {
- Lst_ForEach(expansions, DirPrintWord, NULL);
+ Lst_ForEach(expansions, DirPrintWord, (ClientData) 0);
fputc('\n', stdout);
}
}
@@ -712,7 +739,7 @@ Dir_FindFile (name, path)
*/
p1 = p->name + strlen (p->name) - 1;
p2 = cp - 2;
- while (p2 >= name && *p1 == *p2) {
+ while (p2 >= name && p1 >= p->name && *p1 == *p2) {
p1 -= 1; p2 -= 1;
}
if (p2 >= name || (p1 >= p->name && *p1 != '/')) {
@@ -824,7 +851,7 @@ Dir_FindFile (name, path)
}
entry = Hash_CreateEntry(&mtimes, (char *) file,
(Boolean *)NULL);
- Hash_SetValue(entry, stb.st_mtime);
+ Hash_SetValue(entry, (long)stb.st_mtime);
nearmisses += 1;
return (file);
} else {
@@ -902,7 +929,7 @@ Dir_FindFile (name, path)
printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
name);
}
- Hash_SetValue(entry, stb.st_mtime);
+ Hash_SetValue(entry, (long)stb.st_mtime);
return (strdup (name));
} else {
if (DEBUG(DIR)) {
@@ -946,7 +973,7 @@ Dir_MTime (gn)
}
if (fullName == (char *)NULL) {
- fullName = gn->name;
+ fullName = strdup(gn->name);
}
entry = Hash_FindEntry(&mtimes, fullName);
@@ -958,12 +985,14 @@ Dir_MTime (gn)
*/
if (DEBUG(DIR)) {
printf("Using cached time %s for %s\n",
- Targ_FmtTime((time_t) Hash_GetValue(entry)), fullName);
+ Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
}
- stb.st_mtime = (time_t)Hash_GetValue(entry);
+ stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
Hash_DeleteEntry(&mtimes, entry);
} else if (stat (fullName, &stb) < 0) {
if (gn->type & OP_MEMBER) {
+ if (fullName != gn->path)
+ free(fullName);
return Arch_MemMTime (gn);
} else {
stb.st_mtime = 0;
@@ -1039,7 +1068,7 @@ Dir_AddDir (path, name)
if (dp->d_fileno == 0) {
continue;
}
-#endif sun
+#endif /* sun */
(void)Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
}
(void) closedir (d);
@@ -1068,9 +1097,9 @@ Dir_AddDir (path, name)
*/
ClientData
Dir_CopyDir(p)
- Path *p; /* Directory descriptor to copy */
+ ClientData p;
{
- p->refCount += 1;
+ ((Path *) p)->refCount += 1;
return ((ClientData)p);
}
@@ -1132,9 +1161,10 @@ Dir_MakeFlags (flag, path)
*-----------------------------------------------------------------------
*/
void
-Dir_Destroy (p)
- Path *p; /* The directory descriptor to nuke */
+Dir_Destroy (pp)
+ ClientData pp; /* The directory descriptor to nuke */
{
+ Path *p = (Path *) pp;
p->refCount -= 1;
if (p->refCount == 0) {
@@ -1170,7 +1200,7 @@ Dir_ClearPath(path)
Path *p;
while (!Lst_IsEmpty(path)) {
p = (Path *)Lst_DeQueue(path);
- Dir_Destroy(p);
+ Dir_Destroy((ClientData) p);
}
}
@@ -1228,7 +1258,13 @@ Dir_PrintDirectories()
}
}
-static int DirPrintDir (p) Path *p; { printf ("%s ", p->name); return (0); }
+static int DirPrintDir (p, dummy)
+ ClientData p;
+ ClientData dummy;
+{
+ printf ("%s ", ((Path *) p)->name);
+ return (dummy ? 0 : 0);
+}
void
Dir_PrintPath (path)
OpenPOWER on IntegriCloud