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 suff.c with tabs instead of spaces
details: https://anonhg.NetBSD.org/src/rev/0ef038d12ab2
branches: trunk
changeset: 946642:0ef038d12ab2
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 05 16:59:47 2020 +0000
description:
make(1): indent suff.c with tabs instead of spaces
ExpandChildren is way too deeply nested.
diffstat:
usr.bin/make/suff.c | 2522 ++++++++++++++++++++++++++------------------------
1 files changed, 1291 insertions(+), 1231 deletions(-)
diffs (truncated from 3191 to 300 lines):
diff -r ea700738bcfc -r 0ef038d12ab2 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sat Dec 05 16:23:08 2020 +0000
+++ b/usr.bin/make/suff.c Sat Dec 05 16:59:47 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.323 2020/11/29 01:40:26 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.324 2020/12/05 16:59:47 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.323 2020/11/29 01:40:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.324 2020/12/05 16:59:47 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -126,25 +126,54 @@
typedef List CandidateList;
typedef ListNode CandidateListNode;
-static SuffixList sufflist = LST_INIT; /* List of suffixes */
+/* The defined suffixes, such as '.c', '.o', '.l'. */
+static SuffixList sufflist = LST_INIT;
#ifdef CLEANUP
-static SuffixList suffClean = LST_INIT; /* List of suffixes to be cleaned */
+/* The suffixes to be cleaned up at the end. */
+static SuffixList suffClean = LST_INIT;
#endif
-/* List of transformation rules, such as ".c.o" */
+/*
+ * The transformation rules, such as '.c.o' to transform '.c' into '.o',
+ * or simply '.c' to transform 'file.c' into 'file'.
+ */
static GNodeList transforms = LST_INIT;
-static int sNum = 0; /* Counter for assigning suffix numbers */
+/*
+ * Counter for assigning suffix numbers.
+ * TODO: What are these suffix numbers used for?
+ */
+static int sNum = 0;
typedef enum SuffixFlags {
- SUFF_INCLUDE = 0x01, /* One which is #include'd */
- SUFF_LIBRARY = 0x02, /* One which contains a library */
- SUFF_NULL = 0x04 /* The empty suffix */
- /* XXX: Why is SUFF_NULL needed? Wouldn't nameLen == 0 mean the same? */
+
+ /*
+ * This suffix marks include files. Their search path ends up in the
+ * undocumented special variable '.INCLUDES'.
+ */
+ SUFF_INCLUDE = 1 << 0,
+
+ /*
+ * This suffix marks library files. Their search path ends up in the
+ * undocumented special variable '.LIBS'.
+ */
+ SUFF_LIBRARY = 1 << 1,
+
+ /*
+ * The empty suffix.
+ *
+ * XXX: What is the difference between the empty suffix and the null
+ * suffix?
+ *
+ * XXX: Why is SUFF_NULL needed at all? Wouldn't nameLen == 0 mean
+ * the same?
+ */
+ SUFF_NULL = 1 << 2
+
} SuffixFlags;
ENUM_FLAGS_RTTI_3(SuffixFlags,
- SUFF_INCLUDE, SUFF_LIBRARY, SUFF_NULL);
+ SUFF_INCLUDE, SUFF_LIBRARY, SUFF_NULL);
typedef List SuffixListList;
@@ -153,28 +182,29 @@
* such as ".c.o:".
*/
typedef struct Suffix {
- /* The suffix itself, such as ".c" */
- char *name;
- /* Length of the name, to avoid strlen calls */
- size_t nameLen;
- /* Type of suffix */
- SuffixFlags flags;
- /* The path along which files of this suffix may be found */
- SearchPath *searchPath;
- /* The suffix number; TODO: document the purpose of this number */
- int sNum;
- /* Reference count of list membership and several other places */
- int refCount;
- /* Suffixes we have a transformation to */
- SuffixList parents;
- /* Suffixes we have a transformation from */
- SuffixList children;
+ /* The suffix itself, such as ".c" */
+ char *name;
+ /* Length of the name, to avoid strlen calls */
+ size_t nameLen;
+ /* Type of suffix */
+ SuffixFlags flags;
+ /* The path along which files of this suffix may be found */
+ SearchPath *searchPath;
+ /* The suffix number; TODO: document the purpose of this number */
+ int sNum;
+ /* Reference count of list membership and several other places */
+ int refCount;
+ /* Suffixes we have a transformation to */
+ SuffixList parents;
+ /* Suffixes we have a transformation from */
+ SuffixList children;
- /* Lists in which this suffix is referenced.
- * XXX: These lists are used nowhere, they are just appended to, for no
- * apparent reason. They do have the side effect of increasing refCount
- * though. */
- SuffixListList ref;
+ /* Lists in which this suffix is referenced.
+ *
+ * XXX: These lists are used nowhere, they are just appended to, for
+ * no apparent reason. They do have the side effect of increasing
+ * refCount though. */
+ SuffixListList ref;
} Suffix;
/*
@@ -187,36 +217,36 @@
* node is finally chosen to be made.
*/
typedef struct Candidate {
- /* The file or node to look for. */
- char *file;
- /* The prefix from which file was formed.
- * Its memory is shared among all candidates. */
- char *prefix;
- /* The suffix on the file. */
- Suffix *suff;
+ /* The file or node to look for. */
+ char *file;
+ /* The prefix from which file was formed.
+ * Its memory is shared among all candidates. */
+ char *prefix;
+ /* The suffix on the file. */
+ Suffix *suff;
- /* The candidate that can be made from this,
- * or NULL for the top-level candidate. */
- struct Candidate *parent;
- /* The node describing the file. */
- GNode *node;
+ /* The candidate that can be made from this,
+ * or NULL for the top-level candidate. */
+ struct Candidate *parent;
+ /* The node describing the file. */
+ GNode *node;
- /* Count of existing children, only used for memory management, so we
- * don't free this candidate too early or too late. */
- int numChildren;
+ /* Count of existing children, only used for memory management, so we
+ * don't free this candidate too early or too late. */
+ int numChildren;
#ifdef DEBUG_SRC
- CandidateList childrenList;
+ CandidateList childrenList;
#endif
} Candidate;
typedef struct CandidateSearcher {
- CandidateList list;
+ CandidateList list;
- /*
- * TODO: Add HashSet for seen entries, to avoid endless loops such as
- * in suff-transform-endless.mk.
- */
+ /*
+ * TODO: Add HashSet for seen entries, to avoid endless loops such as
+ * in suff-transform-endless.mk.
+ */
} CandidateSearcher;
@@ -231,27 +261,27 @@
static Suffix *
Suffix_Ref(Suffix *suff)
{
- suff->refCount++;
- return suff;
+ suff->refCount++;
+ return suff;
}
/* Change the value of a Suffix variable, adjusting the reference counts. */
static void
Suffix_Reassign(Suffix **var, Suffix *suff)
{
- if (*var != NULL)
- (*var)->refCount--;
- *var = suff;
- suff->refCount++;
+ if (*var != NULL)
+ (*var)->refCount--;
+ *var = suff;
+ suff->refCount++;
}
/* Set a Suffix variable to NULL, adjusting the reference count. */
static void
Suffix_Unassign(Suffix **var)
{
- if (*var != NULL)
- (*var)->refCount--;
- *var = NULL;
+ if (*var != NULL)
+ (*var)->refCount--;
+ *var = NULL;
}
/*
@@ -261,12 +291,12 @@
static const char *
StrTrimPrefix(const char *pref, const char *str)
{
- while (*str && *pref == *str) {
- pref++;
- str++;
- }
+ while (*str && *pref == *str) {
+ pref++;
+ str++;
+ }
- return *pref != '\0' ? NULL : str;
+ return *pref != '\0' ? NULL : str;
}
/*
@@ -276,18 +306,18 @@
static const char *
StrTrimSuffix(const char *str, size_t strLen, const char *suff, size_t suffLen)
{
- const char *suffInStr;
- size_t i;
+ const char *suffInStr;
+ size_t i;
- if (strLen < suffLen)
- return NULL;
+ if (strLen < suffLen)
+ return NULL;
- suffInStr = str + strLen - suffLen;
- for (i = 0; i < suffLen; i++)
- if (suff[i] != suffInStr[i])
- return NULL;
+ suffInStr = str + strLen - suffLen;
+ for (i = 0; i < suffLen; i++)
+ if (suff[i] != suffInStr[i])
+ return NULL;
- return suffInStr;
+ return suffInStr;
}
/*
@@ -297,54 +327,57 @@
static const char *
Suffix_TrimSuffix(const Suffix *suff, size_t nameLen, const char *nameEnd)
{
- return StrTrimSuffix(nameEnd - nameLen, nameLen, suff->name, suff->nameLen);
+ return StrTrimSuffix(nameEnd - nameLen, nameLen,
+ suff->name, suff->nameLen);
}
static Boolean
Suffix_IsSuffix(const Suffix *suff, size_t nameLen, const char *nameEnd)
{
- return Suffix_TrimSuffix(suff, nameLen, nameEnd) != NULL;
+ return Suffix_TrimSuffix(suff, nameLen, nameEnd) != NULL;
}
static Suffix *
FindSuffixByNameLen(const char *name, size_t nameLen)
{
- SuffixListNode *ln;
+ SuffixListNode *ln;
- for (ln = sufflist.first; ln != NULL; ln = ln->next) {
- Suffix *suff = ln->datum;
- if (suff->nameLen == nameLen && memcmp(suff->name, name, nameLen) == 0)
- return suff;
Home |
Main Index |
Thread Index |
Old Index