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): indent dir.c using tabs instead of spaces
details: https://anonhg.NetBSD.org/src/rev/32e33238669e
branches: trunk
changeset: 978524:32e33238669e
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Nov 23 20:21:34 2020 +0000
description:
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.
diffstat:
usr.bin/make/dir.c | 1408 ++++++++++++++++++++++++++-------------------------
1 files changed, 708 insertions(+), 700 deletions(-)
diffs (truncated from 1773 to 300 lines):
diff -r cc203a6276e4 -r 32e33238669e usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Mon Nov 23 20:05:31 2020 +0000
+++ b/usr.bin/make/dir.c Mon Nov 23 20:21:34 2020 +0000
@@ -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)
@@ -212,63 +212,63 @@
typedef ListNode SearchPathNode;
-SearchPath *dirSearchPath; /* main search path */
+SearchPath *dirSearchPath; /* main search path */
/* A list of cached directories, with fast lookup by directory name. */
typedef struct OpenDirs {
- CachedDirList *list;
- HashTable /* of CachedDirListNode */ table;
+ CachedDirList *list;
+ HashTable /* of CachedDirListNode */ table;
} OpenDirs;
static void
OpenDirs_Init(OpenDirs *odirs)
{
- odirs->list = Lst_New();
- HashTable_Init(&odirs->table);
+ odirs->list = Lst_New();
+ HashTable_Init(&odirs->table);
}
#ifdef CLEANUP
static void
OpenDirs_Done(OpenDirs *odirs)
{
- CachedDirListNode *ln = odirs->list->first;
- while (ln != NULL) {
- CachedDirListNode *next = ln->next;
- CachedDir *dir = ln->datum;
- Dir_Destroy(dir); /* removes the dir from odirs->list */
- ln = next;
- }
- Lst_Free(odirs->list);
- HashTable_Done(&odirs->table);
+ CachedDirListNode *ln = odirs->list->first;
+ while (ln != NULL) {
+ CachedDirListNode *next = ln->next;
+ CachedDir *dir = ln->datum;
+ Dir_Destroy(dir); /* removes the dir from odirs->list */
+ ln = next;
+ }
+ Lst_Free(odirs->list);
+ HashTable_Done(&odirs->table);
}
#endif
static CachedDir *
OpenDirs_Find(OpenDirs *odirs, const char *name)
{
- CachedDirListNode *ln = HashTable_FindValue(&odirs->table, name);
- return ln != NULL ? ln->datum : NULL;
+ CachedDirListNode *ln = HashTable_FindValue(&odirs->table, name);
+ return ln != NULL ? ln->datum : NULL;
}
static void
OpenDirs_Add(OpenDirs *odirs, CachedDir *cdir)
{
- if (HashTable_FindEntry(&odirs->table, cdir->name) != NULL)
- return;
- Lst_Append(odirs->list, cdir);
- HashTable_Set(&odirs->table, cdir->name, odirs->list->last);
+ if (HashTable_FindEntry(&odirs->table, cdir->name) != NULL)
+ return;
+ Lst_Append(odirs->list, cdir);
+ HashTable_Set(&odirs->table, cdir->name, odirs->list->last);
}
static void
OpenDirs_Remove(OpenDirs *odirs, const char *name)
{
- HashEntry *he = HashTable_FindEntry(&odirs->table, name);
- CachedDirListNode *ln;
- if (he == NULL)
- return;
- ln = HashEntry_Get(he);
- HashTable_DeleteEntry(&odirs->table, he);
- Lst_Remove(odirs->list, ln);
+ HashEntry *he = HashTable_FindEntry(&odirs->table, name);
+ CachedDirListNode *ln;
+ if (he == NULL)
+ return;
+ ln = HashEntry_Get(he);
+ HashTable_DeleteEntry(&odirs->table, he);
+ Lst_Remove(odirs->list, ln);
}
static OpenDirs openDirs; /* all cached directories */
@@ -299,9 +299,9 @@
static HashTable lmtimes; /* same as mtimes but for lstat */
typedef enum CachedStatsFlags {
- CST_NONE = 0,
- CST_LSTAT = 1 << 0, /* call lstat(2) instead of stat(2) */
- CST_UPDATE = 1 << 1 /* ignore existing cached entry */
+ CST_NONE = 0,
+ CST_LSTAT = 1 << 0, /* call lstat(2) instead of stat(2) */
+ CST_UPDATE = 1 << 1 /* ignore existing cached entry */
} CachedStatsFlags;
/* Returns 0 and the result of stat(2) or lstat(2) in *out_cst,
@@ -310,76 +310,76 @@
cached_stats(const char *pathname, struct cached_stat *out_cst,
CachedStatsFlags flags)
{
- HashTable *tbl = flags & CST_LSTAT ? &lmtimes : &mtimes;
- struct stat sys_st;
- struct cached_stat *cst;
- int rc;
+ HashTable *tbl = flags & CST_LSTAT ? &lmtimes : &mtimes;
+ struct stat sys_st;
+ struct cached_stat *cst;
+ int rc;
- if (pathname == NULL || pathname[0] == '\0')
- return -1; /* This can happen in meta mode. */
+ if (pathname == NULL || pathname[0] == '\0')
+ return -1; /* This can happen in meta mode. */
- cst = HashTable_FindValue(tbl, pathname);
- if (cst != NULL && !(flags & CST_UPDATE)) {
- *out_cst = *cst;
- DIR_DEBUG2("Using cached time %s for %s\n",
- Targ_FmtTime(cst->cst_mtime), pathname);
- return 0;
- }
+ cst = HashTable_FindValue(tbl, pathname);
+ if (cst != NULL && !(flags & CST_UPDATE)) {
+ *out_cst = *cst;
+ DIR_DEBUG2("Using cached time %s for %s\n",
+ Targ_FmtTime(cst->cst_mtime), pathname);
+ return 0;
+ }
- rc = (flags & CST_LSTAT ? lstat : stat)(pathname, &sys_st);
- if (rc == -1)
- return -1; /* don't cache negative lookups */
+ rc = (flags & CST_LSTAT ? lstat : stat)(pathname, &sys_st);
+ if (rc == -1)
+ return -1; /* don't cache negative lookups */
- if (sys_st.st_mtime == 0)
- sys_st.st_mtime = 1; /* avoid confusion with missing file */
+ if (sys_st.st_mtime == 0)
+ sys_st.st_mtime = 1; /* avoid confusion with missing file */
- if (cst == NULL) {
- cst = bmake_malloc(sizeof *cst);
- HashTable_Set(tbl, pathname, cst);
- }
+ if (cst == NULL) {
+ cst = bmake_malloc(sizeof *cst);
+ HashTable_Set(tbl, pathname, cst);
+ }
- cst->cst_mtime = sys_st.st_mtime;
- cst->cst_mode = sys_st.st_mode;
+ cst->cst_mtime = sys_st.st_mtime;
+ cst->cst_mode = sys_st.st_mode;
- *out_cst = *cst;
- DIR_DEBUG2(" Caching %s for %s\n",
- Targ_FmtTime(sys_st.st_mtime), pathname);
+ *out_cst = *cst;
+ DIR_DEBUG2(" Caching %s for %s\n",
+ Targ_FmtTime(sys_st.st_mtime), pathname);
- return 0;
+ return 0;
}
int
cached_stat(const char *pathname, struct cached_stat *cst)
{
- return cached_stats(pathname, cst, CST_NONE);
+ return cached_stats(pathname, cst, CST_NONE);
}
int
cached_lstat(const char *pathname, struct cached_stat *cst)
{
- return cached_stats(pathname, cst, CST_LSTAT);
+ return cached_stats(pathname, cst, CST_LSTAT);
}
/* Initialize the directories module. */
void
Dir_Init(void)
{
- dirSearchPath = Lst_New();
- OpenDirs_Init(&openDirs);
- HashTable_Init(&mtimes);
- HashTable_Init(&lmtimes);
+ dirSearchPath = Lst_New();
+ OpenDirs_Init(&openDirs);
+ HashTable_Init(&mtimes);
+ HashTable_Init(&lmtimes);
}
void
Dir_InitDir(const char *cdname)
{
- Dir_InitCur(cdname);
+ Dir_InitCur(cdname);
- dotLast = bmake_malloc(sizeof *dotLast);
- dotLast->refCount = 1;
- dotLast->hits = 0;
- dotLast->name = bmake_strdup(".DOTLAST");
- HashSet_Init(&dotLast->files);
+ dotLast = bmake_malloc(sizeof *dotLast);
+ dotLast->refCount = 1;
+ dotLast->hits = 0;
+ dotLast->name = bmake_strdup(".DOTLAST");
+ HashSet_Init(&dotLast->files);
}
/*
@@ -388,33 +388,33 @@
void
Dir_InitCur(const char *cdname)
{
- CachedDir *dir;
+ CachedDir *dir;
- if (cdname == NULL)
- return;
+ if (cdname == NULL)
+ return;
- /*
- * Our build directory is not the same as our source directory.
- * Keep this one around too.
- */
- dir = Dir_AddDir(NULL, cdname);
- if (dir == NULL)
- return;
+ /*
+ * Our build directory is not the same as our source directory.
+ * Keep this one around too.
+ */
+ dir = Dir_AddDir(NULL, cdname);
+ if (dir == NULL)
+ return;
- /* XXX: Reference counting is wrong here.
- * If this function is called repeatedly with the same directory name,
- * its reference count increases each time even though the number of
- * actual references stays the same. */
+ /* XXX: Reference counting is wrong here.
+ * If this function is called repeatedly with the same directory name,
+ * its reference count increases each time even though the number of
+ * actual references stays the same. */
- dir->refCount++;
- if (cur != NULL && cur != dir) {
- /*
- * We've been here before, clean up.
- */
- cur->refCount--;
- Dir_Destroy(cur);
- }
- cur = dir;
+ dir->refCount++;
+ if (cur != NULL && cur != dir) {
+ /*
+ * We've been here before, clean up.
+ */
+ cur->refCount--;
+ Dir_Destroy(cur);
+ }
+ cur = dir;
}
/* (Re)initialize "dot" (current/object directory) path hash.
@@ -422,24 +422,24 @@
void
Dir_InitDot(void)
{
Home |
Main Index |
Thread Index |
Old Index