make(1): indent dir.c using tabs instead of spaces
Except for Dir_Expand and Dir_UpdateMTime, which are nested too deeply to use tabs right now. They first have to be split into separate functions.
This commit is contained in:
parent
36ec30d3db
commit
a148714f6c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dir.c,v 1.211 2020/11/23 18:24:05 rillig Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.212 2020/11/23 20:21:34 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -134,7 +134,7 @@
|
||||
#include "job.h"
|
||||
|
||||
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
|
||||
MAKE_RCSID("$NetBSD: dir.c,v 1.211 2020/11/23 18:24:05 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: dir.c,v 1.212 2020/11/23 20:21:34 rillig Exp $");
|
||||
|
||||
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
|
||||
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
|
||||
@ -435,8 +435,8 @@ Dir_InitDot(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* We always need to have dot around, so we increment its reference count
|
||||
* to make sure it's not destroyed.
|
||||
* We always need to have dot around, so we increment its reference
|
||||
* count to make sure it's not destroyed.
|
||||
*/
|
||||
dot->refCount++;
|
||||
Dir_SetPATH(); /* initialize */
|
||||
@ -570,8 +570,11 @@ DirMatchFiles(const char *pattern, CachedDir *dir, StringList *expansions)
|
||||
Boolean isDot = dirName[0] == '.' && dirName[1] == '\0';
|
||||
HashIter hi;
|
||||
|
||||
/* XXX: Iterating over all hash entries is inefficient. If the pattern
|
||||
* is a plain string without any wildcards, a direct lookup is faster. */
|
||||
/*
|
||||
* XXX: Iterating over all hash entries is inefficient. If the
|
||||
* pattern is a plain string without any wildcards, a direct lookup
|
||||
* is faster.
|
||||
*/
|
||||
|
||||
HashIter_InitSet(&hi, &dir->files);
|
||||
while (HashIter_Next(&hi) != NULL) {
|
||||
@ -581,12 +584,13 @@ DirMatchFiles(const char *pattern, CachedDir *dir, StringList *expansions)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Follow the UNIX convention that dot files are only found if the
|
||||
* pattern begins with a dot. The pattern '.*' does not match '.' or
|
||||
* '..' since these are not included in the directory cache.
|
||||
* Follow the UNIX convention that dot files are only found
|
||||
* if the pattern begins with a dot. The pattern '.*' does
|
||||
* not match '.' or '..' since these are not included in the
|
||||
* directory cache.
|
||||
*
|
||||
* This means that the pattern '[a-z.]*' does not find '.file', which
|
||||
* is consistent with bash, NetBSD sh and csh.
|
||||
* This means that the pattern '[a-z.]*' does not find
|
||||
* '.file', which is consistent with bash, NetBSD sh and csh.
|
||||
*/
|
||||
if (base[0] == '.' && pattern[0] != '.')
|
||||
continue;
|
||||
@ -717,7 +721,8 @@ DirExpandCurly(const char *word, const char *brace, SearchPath *path,
|
||||
Lst_Append(expansions, file);
|
||||
}
|
||||
|
||||
piece = piece_end + 1; /* skip over the comma or closing brace */
|
||||
piece = piece_end +
|
||||
1; /* skip over the comma or closing brace */
|
||||
}
|
||||
}
|
||||
|
||||
@ -896,7 +901,8 @@ DirLookupAbs(CachedDir *dir, const char *name, const char *cp)
|
||||
* 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 (dnp = dir->name, np = name; *dnp != '\0' && *dnp == *np; dnp++, np++)
|
||||
for (dnp = dir->name, np = name;
|
||||
*dnp != '\0' && *dnp == *np; dnp++, np++)
|
||||
continue;
|
||||
if (*dnp != '\0' || np != cp - 1)
|
||||
return NULL;
|
||||
@ -999,16 +1005,16 @@ Dir_FindFile(const char *name, SearchPath *path)
|
||||
*/
|
||||
if (!hasSlash || (base - name == 2 && *name == '.')) {
|
||||
/*
|
||||
* We look through all the directories on the path seeking one which
|
||||
* contains the final component of the given name. If such a beast
|
||||
* is found, we concatenate the directory name and the final
|
||||
* component and return the resulting string. If we don't find any
|
||||
* such thing, we go on to phase two...
|
||||
* We look through all the directories on the path seeking one
|
||||
* which contains the final component of the given name. If
|
||||
* such a beast is found, we concatenate the directory name
|
||||
* and the final component and return the resulting string.
|
||||
* If we don't find any such thing, we go on to phase two.
|
||||
*
|
||||
* No matter what, we always look for the file in the current
|
||||
* directory before anywhere else (unless we found the magic
|
||||
* DOTLAST path, in which case we search it last) and we *do not*
|
||||
* add the ./ to it if it exists.
|
||||
* DOTLAST path, in which case we search it last) and we *do
|
||||
* not* add the ./ to it if it exists.
|
||||
* This is so there are no conflicts between what the user
|
||||
* specifies (fish.c) and what pmake finds (./fish.c).
|
||||
*/
|
||||
@ -1092,8 +1098,8 @@ Dir_FindFile(const char *name, SearchPath *path)
|
||||
|
||||
if (checkedDot) {
|
||||
/*
|
||||
* Already checked by the given name, since . was in the path,
|
||||
* so no point in proceeding...
|
||||
* Already checked by the given name, since . was in
|
||||
* the path, so no point in proceeding.
|
||||
*/
|
||||
DIR_DEBUG0(" Checked . already, returning NULL\n");
|
||||
return NULL;
|
||||
@ -1102,13 +1108,14 @@ Dir_FindFile(const char *name, SearchPath *path)
|
||||
} else { /* name[0] == '/' */
|
||||
|
||||
/*
|
||||
* For absolute names, compare directory path prefix against the
|
||||
* the directory path of each member on the search path for an exact
|
||||
* match. If we have an exact match on any member of the search path,
|
||||
* use the cached contents of that member to lookup the final file
|
||||
* component. If that lookup fails we can safely assume that the
|
||||
* file does not exist at all. This is signified by DirLookupAbs()
|
||||
* returning an empty string.
|
||||
* For absolute names, compare directory path prefix against
|
||||
* the the directory path of each member on the search path
|
||||
* for an exact match. If we have an exact match on any member
|
||||
* of the search path, use the cached contents of that member
|
||||
* to lookup the final file component. If that lookup fails we
|
||||
* can safely assume that the file does not exist at all.
|
||||
* This is signified by DirLookupAbs() returning an empty
|
||||
* string.
|
||||
*/
|
||||
DIR_DEBUG0(" Trying exact path matches...\n");
|
||||
|
||||
@ -1149,9 +1156,10 @@ Dir_FindFile(const char *name, SearchPath *path)
|
||||
* onto the search path in any case, just in case, then look for the
|
||||
* thing in the hash table. If we find it, grand. We return a new
|
||||
* copy of the name. Otherwise we sadly return a NULL pointer. Sigh.
|
||||
* Note that if the directory holding the file doesn't exist, this will
|
||||
* do an extra search of the final directory on the path. Unless something
|
||||
* weird happens, this search won't succeed and life will be groovy.
|
||||
* Note that if the directory holding the file doesn't exist, this
|
||||
* will do an extra search of the final directory on the path. Unless
|
||||
* something weird happens, this search won't succeed and life will
|
||||
* be groovy.
|
||||
*
|
||||
* Sigh. We cannot add the directory onto the search path because
|
||||
* of this amusing case:
|
||||
@ -1399,9 +1407,8 @@ Dir_AddDir(SearchPath *path, const char *name)
|
||||
* (0-inode slots just take up space), so we have to do
|
||||
* it ourselves.
|
||||
*/
|
||||
if (dp->d_fileno == 0) {
|
||||
if (dp->d_fileno == 0)
|
||||
continue;
|
||||
}
|
||||
#endif /* sun && d_ino */
|
||||
(void)HashSet_Add(&dir->files, dp->d_name);
|
||||
}
|
||||
@ -1532,15 +1539,16 @@ Dir_PrintDirectories(void)
|
||||
CachedDirListNode *ln;
|
||||
|
||||
debug_printf("#*** Directory Cache:\n");
|
||||
debug_printf("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
|
||||
debug_printf(
|
||||
"# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
|
||||
hits, misses, nearmisses, bigmisses,
|
||||
percentage(hits, hits + bigmisses + nearmisses));
|
||||
debug_printf("# %-20s referenced\thits\n", "directory");
|
||||
|
||||
for (ln = openDirs.list->first; ln != NULL; ln = ln->next) {
|
||||
CachedDir *dir = ln->datum;
|
||||
debug_printf("# %-20s %10d\t%4d\n", dir->name, dir->refCount,
|
||||
dir->hits);
|
||||
debug_printf("# %-20s %10d\t%4d\n",
|
||||
dir->name, dir->refCount, dir->hits);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user