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): merge functions for suffix handling
details: https://anonhg.NetBSD.org/src/rev/9c010d554e61
branches: trunk
changeset: 946273:9c010d554e61
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 22 10:11:23 2020 +0000
description:
make(1): merge functions for suffix handling
The names of the functions AddSources and AddLevel were not as precise
and guiding as possible. Merging them into a single function makes the
code indented a little more, but on the other hand provides a function
with an easy to grasp purpose.
diffstat:
usr.bin/make/suff.c | 53 ++++++++++++++++++++++-------------------------------
1 files changed, 22 insertions(+), 31 deletions(-)
diffs (98 lines):
diff -r b3fb91945f46 -r 9c010d554e61 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sun Nov 22 09:56:01 2020 +0000
+++ b/usr.bin/make/suff.c Sun Nov 22 10:11:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.285 2020/11/22 09:56:01 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.286 2020/11/22 10:11:23 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.285 2020/11/22 09:56:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.286 2020/11/22 10:11:23 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -906,32 +906,26 @@
#endif
}
-/*
- * Add a new candidate to the list, formed from the candidate's prefix and
- * the suffix.
- */
-/* XXX: reorder parameters */
+/* Add all candidates to the list that can be formed by applying a suffix to
+ * the candidate. */
static void
-AddSources(Suffix *suff, CandidateList *list, Candidate *targ)
+CandidateList_AddCandidatesFor(CandidateList *list, Candidate *cand)
{
- if ((suff->flags & SUFF_NULL) && suff->name[0] != '\0') {
- /*
- * If the suffix has been marked as the NULL suffix, also create a
- * candidate for a file with no suffix attached.
- */
- CandidateList_Add(list, bmake_strdup(targ->pref), targ, suff, "1");
- }
- CandidateList_Add(list, str_concat2(targ->pref, suff->name), targ, suff, "2");
-}
+ SuffixListNode *ln;
+ for (ln = cand->suff->children->first; ln != NULL; ln = ln->next) {
+ Suffix *suff = ln->datum;
-/* Add all the children of targ to the list. */
-static void
-AddLevel(CandidateList *srcs, Candidate *targ)
-{
- CandidateListNode *ln;
- for (ln = targ->suff->children->first; ln != NULL; ln = ln->next) {
- Suffix *childSuff = ln->datum;
- AddSources(childSuff, srcs, targ);
+ if ((suff->flags & SUFF_NULL) && suff->name[0] != '\0') {
+ /*
+ * If the suffix has been marked as the NULL suffix, also
+ * create a candidate for a file with no suffix attached.
+ */
+ CandidateList_Add(list, bmake_strdup(cand->pref),
+ cand, suff, "1");
+ }
+
+ CandidateList_Add(list, str_concat2(cand->pref, suff->name),
+ cand, suff, "2");
}
}
@@ -1023,7 +1017,7 @@
SUFF_DEBUG0("not there\n");
- AddLevel(srcs, src);
+ CandidateList_AddCandidatesFor(srcs, src);
Lst_Append(slst, src);
}
@@ -1559,10 +1553,7 @@
pref = bmake_strldup(name, (size_t)(nameLen - suff->nameLen));
targ = Candidate_New(bmake_strdup(gn->name), pref, suff, NULL, gn);
- /*
- * Add nodes from which the target can be made
- */
- AddLevel(srcs, targ);
+ CandidateList_AddCandidatesFor(srcs, targ);
/*
* Record the target so we can nuke it
@@ -1592,7 +1583,7 @@
* don't do this anymore.
*/
if (Lst_IsEmpty(gn->commands))
- AddLevel(srcs, targ);
+ CandidateList_AddCandidatesFor(srcs, targ);
else {
SUFF_DEBUG0("not ");
}
Home |
Main Index |
Thread Index |
Old Index