Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): rename type Path to CachedDir
details: https://anonhg.NetBSD.org/src/rev/1d851fa676a0
branches: trunk
changeset: 938963:1d851fa676a0
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Sep 22 02:26:22 2020 +0000
description:
make(1): rename type Path to CachedDir
The word "path" is commonly used either as an abbreviation for pathname
(a string consisting of several directory or file names) or as an
abbreviation for search path (a list of directory names used for
searching files), but not for a single directory.
diffstat:
usr.bin/make/dir.c | 214 +++++++++++++++++++++++++-------------------------
usr.bin/make/dir.h | 8 +-
usr.bin/make/parse.c | 8 +-
3 files changed, 116 insertions(+), 114 deletions(-)
diffs (truncated from 646 to 300 lines):
diff -r a224f533e890 -r 1d851fa676a0 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Tue Sep 22 01:52:16 2020 +0000
+++ b/usr.bin/make/dir.c Tue Sep 22 02:26:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.142 2020/09/13 15:15:51 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.143 2020/09/22 02:26:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -78,9 +78,9 @@
* The interface for this module is:
* Dir_Init Initialize the module.
*
- * Dir_InitCur Set the cur Path.
+ * Dir_InitCur Set the cur CachedDir.
*
- * Dir_InitDot Set the dot Path.
+ * Dir_InitDot Set the dot CachedDir.
*
* Dir_End Cleanup the module.
*
@@ -134,7 +134,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.142 2020/09/13 15:15:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.143 2020/09/22 02:26:22 rillig Exp $");
#define DIR_DEBUG0(fmt) \
if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -147,7 +147,7 @@
/*
- * A search path consists of a Lst of Path structures. A Path structure
+ * A search path consists of a list of CachedDir structures. A CachedDir
* has in it the name of the directory and a hash table of all the files
* in the directory. This is used to cut down on the number of system
* calls necessary to find implicit dependents and their like. Since
@@ -179,7 +179,7 @@
* that UNIX OS's have taken to allowing more than 20 or 32
* file descriptors for a process, this doesn't seem acceptable
* to me.
- * 3) record the mtime of the directory in the Path structure and
+ * 3) record the mtime of the directory in the CachedDir structure and
* verify the directory hasn't changed since the contents were
* hashed. This will catch the creation or deletion of files,
* but not the updating of files. However, since it is the
@@ -229,9 +229,9 @@
static int nearmisses; /* Found under search path */
static int bigmisses; /* Sought by itself */
-static Path *dot; /* contents of current directory */
-static Path *cur; /* contents of current directory, if not dot */
-static Path *dotLast; /* a fake path entry indicating we need to
+static CachedDir *dot; /* contents of current directory */
+static CachedDir *cur; /* contents of current directory, if not dot */
+static CachedDir *dotLast; /* a fake path entry indicating we need to
* look for . last */
/* Results of doing a last-resort stat in Dir_FindFile -- if we have to go to
@@ -248,10 +248,10 @@
static void DirExpandInt(const char *, Lst, Lst);
static int DirPrintWord(void *, void *);
static int DirPrintDir(void *, void *);
-static char *DirLookup(Path *, const char *, const char *, Boolean);
-static char *DirLookupSubdir(Path *, const char *);
+static char *DirLookup(CachedDir *, const char *, const char *, Boolean);
+static char *DirLookupSubdir(CachedDir *, const char *);
static char *DirFindDot(Boolean, const char *, const char *);
-static char *DirLookupAbs(Path *, const char *, const char *);
+static char *DirLookupAbs(CachedDir *, const char *, const char *);
/*
@@ -355,7 +355,7 @@
{
Dir_InitCur(cdname);
- dotLast = bmake_malloc(sizeof(Path));
+ dotLast = bmake_malloc(sizeof(CachedDir));
dotLast->refCount = 1;
dotLast->hits = 0;
dotLast->name = bmake_strdup(".DOTLAST");
@@ -368,23 +368,23 @@
void
Dir_InitCur(const char *cdname)
{
- Path *p;
+ CachedDir *dir;
if (cdname != NULL) {
/*
* Our build directory is not the same as our source directory.
* Keep this one around too.
*/
- if ((p = Dir_AddDir(NULL, cdname))) {
- p->refCount += 1;
- if (cur && cur != p) {
+ if ((dir = Dir_AddDir(NULL, cdname))) {
+ dir->refCount += 1;
+ if (cur && cur != dir) {
/*
* We've been here before, cleanup.
*/
cur->refCount -= 1;
Dir_Destroy(cur);
}
- cur = p;
+ cur = dir;
}
}
}
@@ -447,15 +447,14 @@
Dir_SetPATH(void)
{
LstNode ln; /* a list element */
- Path *p;
Boolean hasLastDot = FALSE; /* true if we should search dot last */
Var_Delete(".PATH", VAR_GLOBAL);
Lst_Open(dirSearchPath);
if ((ln = Lst_First(dirSearchPath)) != NULL) {
- p = LstNode_Datum(ln);
- if (p == dotLast) {
+ CachedDir *dir = LstNode_Datum(ln);
+ if (dir == dotLast) {
hasLastDot = TRUE;
Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
}
@@ -469,12 +468,12 @@
}
while ((ln = Lst_Next(dirSearchPath)) != NULL) {
- p = LstNode_Datum(ln);
- if (p == dotLast)
+ CachedDir *dir = LstNode_Datum(ln);
+ if (dir == dotLast)
continue;
- if (p == dot && hasLastDot)
+ if (dir == dot && hasLastDot)
continue;
- Var_Append(".PATH", p->name, VAR_GLOBAL);
+ Var_Append(".PATH", dir->name, VAR_GLOBAL);
}
if (hasLastDot) {
@@ -486,13 +485,14 @@
Lst_Close(dirSearchPath);
}
-/* See if the Path structure describes the same directory as the
+/* See if the CachedDir structure describes the same directory as the
* given one by comparing their names. Called from Dir_AddDir via
* Lst_Find when searching the list of open directories. */
static Boolean
DirFindName(const void *p, const void *desiredName)
{
- return strcmp(((const Path *)p)->name, desiredName) == 0;
+ const CachedDir *dir = p;
+ return strcmp(dir->name, desiredName) == 0;
}
/* See if the given name has any wildcard characters in it. Be careful not to
@@ -545,7 +545,7 @@
/*-
*-----------------------------------------------------------------------
* DirMatchFiles --
- * Given a pattern and a Path structure, see if any files
+ * Given a pattern and a CachedDir structure, see if any files
* match the pattern and add their names to the 'expansions' list if
* any do. This is incomplete -- it doesn't take care of patterns like
* src / *src / *.c properly (just *.c on any of the directories), but it
@@ -553,7 +553,7 @@
*
* Input:
* pattern Pattern to look for
- * p Directory to search
+ * dir Directory to search
* expansion Place to store the results
*
* Side Effects:
@@ -562,15 +562,15 @@
*-----------------------------------------------------------------------
*/
static void
-DirMatchFiles(const char *pattern, Path *p, Lst expansions)
+DirMatchFiles(const char *pattern, CachedDir *dir, Lst expansions)
{
Hash_Search search; /* Index into the directory's table */
Hash_Entry *entry; /* Current entry in the table */
Boolean isDot; /* TRUE if the directory being searched is . */
- isDot = (p->name[0] == '.' && p->name[1] == '\0');
+ isDot = (dir->name[0] == '.' && dir->name[1] == '\0');
- for (entry = Hash_EnumFirst(&p->files, &search);
+ for (entry = Hash_EnumFirst(&dir->files, &search);
entry != NULL;
entry = Hash_EnumNext(&search))
{
@@ -586,7 +586,7 @@
{
Lst_Append(expansions,
(isDot ? bmake_strdup(entry->name) :
- str_concat3(p->name, "/", entry->name)));
+ str_concat3(dir->name, "/", entry->name)));
}
}
}
@@ -728,7 +728,7 @@
*
* Input:
* word Word to expand
- * path Path on which to look
+ * path Directory in which to look
* expansions Place to store the result
*
* Results:
@@ -746,8 +746,8 @@
Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
- Path *p = LstNode_Datum(ln);
- DirMatchFiles(word, p, expansions);
+ CachedDir *dir = LstNode_Datum(ln);
+ DirMatchFiles(word, dir, expansions);
}
Lst_Close(path);
}
@@ -892,19 +892,19 @@
*-----------------------------------------------------------------------
*/
static char *
-DirLookup(Path *p, const char *name MAKE_ATTR_UNUSED, const char *cp,
+DirLookup(CachedDir *dir, const char *name MAKE_ATTR_UNUSED, const char *cp,
Boolean hasSlash MAKE_ATTR_UNUSED)
{
char *file; /* the current filename to check */
- DIR_DEBUG1(" %s ...\n", p->name);
+ DIR_DEBUG1(" %s ...\n", dir->name);
- if (Hash_FindEntry(&p->files, cp) == NULL)
+ if (Hash_FindEntry(&dir->files, cp) == NULL)
return NULL;
- file = str_concat3(p->name, "/", cp);
+ file = str_concat3(dir->name, "/", cp);
DIR_DEBUG1(" returning %s\n", file);
- p->hits += 1;
+ dir->hits += 1;
hits += 1;
return file;
}
@@ -925,13 +925,13 @@
*-----------------------------------------------------------------------
*/
static char *
-DirLookupSubdir(Path *p, const char *name)
+DirLookupSubdir(CachedDir *dir, const char *name)
{
struct make_stat mst;
char *file; /* the current filename to check */
- if (p != dot) {
- file = str_concat3(p->name, "/", name);
+ if (dir != dot) {
+ file = str_concat3(dir->name, "/", name);
} else {
/*
* Checking in dot -- DON'T put a leading ./ on the thing.
@@ -965,12 +965,12 @@
*-----------------------------------------------------------------------
*/
static char *
-DirLookupAbs(Path *p, const char *name, const char *cp)
+DirLookupAbs(CachedDir *dir, const char *name, const char *cp)
{
- char *p1; /* pointer into p->name */
+ char *p1; /* pointer into dir->name */
const char *p2; /* pointer into name */
- DIR_DEBUG1(" %s ...\n", p->name);
+ DIR_DEBUG1(" %s ...\n", dir->name);
/*
* If the file has a leading path component and that component
@@ -978,20 +978,20 @@
* directory, we can attempt another cache lookup. And if we don't
* have a hit, we can safely assume the file does not exist at all.
*/
- for (p1 = p->name, p2 = name; *p1 && *p1 == *p2; p1++, p2++) {
+ for (p1 = dir->name, p2 = name; *p1 && *p1 == *p2; p1++, p2++) {
continue;
}
if (*p1 != '\0' || p2 != cp - 1) {
return NULL;
}
Home |
Main Index |
Thread Index |
Old Index