Module Name: src
Committed By: rillig
Date: Sun Oct 18 15:53:47 UTC 2020
Modified Files:
src/usr.bin/make: suff.c
Log Message:
make(1): inline struct LstSrc into SuffAddSrc
The variable names are still confusing. There was no useful
documentation on the struct, and the code in SuffAddSrc is highly
redundant. Maybe the next few refactorings will shed light on this part
of the code.
To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/suff.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.183 src/usr.bin/make/suff.c:1.184
--- src/usr.bin/make/suff.c:1.183 Sun Oct 18 15:40:54 2020
+++ src/usr.bin/make/suff.c Sun Oct 18 15:53:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.183 2020/10/18 15:40:54 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.184 2020/10/18 15:53:47 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.183 2020/10/18 15:40:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.184 2020/10/18 15:53:47 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -195,15 +195,6 @@ typedef struct Src {
#endif
} Src;
-/*
- * A structure for passing more than one argument to the Lst-library-invoked
- * function...
- */
-typedef struct LstSrc {
- SrcList *l;
- Src *s;
-} LstSrc;
-
/* XXX: Name doesn't match content */
typedef struct GNodeSuff {
GNode **gnp;
@@ -898,18 +889,16 @@ PrintAddr(void *a, void *b MAKE_ATTR_UNU
* the prefix is used unaltered as the file name in the Src structure.
*
* Input:
- * sp suffix for which to create a Src structure
- * lsp list and parent for the new Src
+ * suff suffix for which to create a Src structure
+ * srcList list for the new Src
+ * targ parent for the new Src
*/
static void
-SuffAddSrc(Suff *s, LstSrc *ls)
+SuffAddSrc(Suff *suff, SrcList *srcList, Src *targ)
{
Src *s2; /* new Src structure */
- Src *targ; /* Target structure */
- targ = ls->s;
-
- if ((s->flags & SUFF_NULL) && s->name[0] != '\0') {
+ if ((suff->flags & SUFF_NULL) && suff->name[0] != '\0') {
/*
* If the suffix has been marked as the NULL suffix, also create a Src
* structure for a file with no suffix attached. Two birds, and all
@@ -920,34 +909,34 @@ SuffAddSrc(Suff *s, LstSrc *ls)
s2->pref = targ->pref;
s2->parent = targ;
s2->node = NULL;
- s2->suff = s;
- s->refCount++;
+ s2->suff = suff;
+ suff->refCount++;
s2->children = 0;
targ->children++;
- Lst_Append(ls->l, s2);
+ Lst_Append(srcList, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_New();
Lst_Append(targ->cp, s2);
- debug_printf("1 add %p %p to %p:", targ, s2, ls->l);
- Lst_ForEach(ls->l, PrintAddr, NULL);
+ debug_printf("1 add %p %p to %p:", targ, s2, srcList);
+ Lst_ForEach(srcList, PrintAddr, NULL);
debug_printf("\n");
#endif
}
s2 = bmake_malloc(sizeof(Src));
- s2->file = str_concat2(targ->pref, s->name);
+ s2->file = str_concat2(targ->pref, suff->name);
s2->pref = targ->pref;
s2->parent = targ;
s2->node = NULL;
- s2->suff = s;
- s->refCount++;
+ s2->suff = suff;
+ suff->refCount++;
s2->children = 0;
targ->children++;
- Lst_Append(ls->l, s2);
+ Lst_Append(srcList, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_New();
Lst_Append(targ->cp, s2);
- debug_printf("2 add %p %p to %p:", targ, s2, ls->l);
- Lst_ForEach(ls->l, PrintAddr, NULL);
+ debug_printf("2 add %p %p to %p:", targ, s2, srcList);
+ Lst_ForEach(srcList, PrintAddr, NULL);
debug_printf("\n");
#endif
}
@@ -964,8 +953,7 @@ SuffAddLevel(SrcList *l, Src *targ)
SrcListNode *ln;
for (ln = targ->suff->children->first; ln != NULL; ln = ln->next) {
Suff *childSuff = ln->datum;
- LstSrc ls = { l, targ };
- SuffAddSrc(childSuff, &ls);
+ SuffAddSrc(childSuff, l, targ);
}
}