diff options
author | harti <harti@FreeBSD.org> | 2005-03-14 08:29:58 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-03-14 08:29:58 +0000 |
commit | dffc7fe63f1548c4020403c09673174369621036 (patch) | |
tree | ff8700291996038ee45c9152ddfd0f5be3245ebe | |
parent | eaf9deaeb70e433131a0320ac0ce9e5f7a8c9df7 (diff) | |
download | FreeBSD-src-dffc7fe63f1548c4020403c09673174369621036.zip FreeBSD-src-dffc7fe63f1548c4020403c09673174369621036.tar.gz |
Convert a couple of other uses of Lst_ForEach to LST_FOREACH and
simplify code.
-rw-r--r-- | usr.bin/make/suff.c | 88 |
1 files changed, 40 insertions, 48 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 408f44e..8da48eb 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -173,9 +173,6 @@ static Suff *suffNull; static Suff *emptySuff; static void SuffFindDeps(GNode *, Lst *); -#ifdef DEBUG_SRC -static int PrintAddr(void *, void *); -#endif /* DEBUG_SRC */ /*************** Lst Predicates ****************/ @@ -689,27 +686,22 @@ Suff_EndTransform(const GNode *gn) /*- *----------------------------------------------------------------------- * SuffRebuildGraph -- - * Called from Suff_AddSuffix via Lst_ForEach to search through the + * Called from Suff_AddSuffix via LST_FOREACH to search through the * list of existing transformation rules and rebuild the transformation * graph when it has been destroyed by Suff_ClearSuffixes. If the * given rule is a transformation involving this suffix and another, * existing suffix, the proper relationship is established between * the two. * - * Results: - * Always 0. - * * Side Effects: * The appropriate links will be made between this suffix and * others if transformation rules exist for it. * *----------------------------------------------------------------------- */ -static int -SuffRebuildGraph(void *transformp, void *sp) +static void +SuffRebuildGraph(const GNode *transform, Suff *s) { - GNode *transform = transformp; - Suff *s = sp; char *cp; LstNode *ln; Suff *s2 = NULL; @@ -733,7 +725,7 @@ SuffRebuildGraph(void *transformp, void *sp) */ SuffInsert(&s2->children, s); SuffInsert(&s->parents, s2); - return (0); + return; } } @@ -760,7 +752,6 @@ SuffRebuildGraph(void *transformp, void *sp) SuffInsert(&s2->parents, s); } } - return (0); } /*- @@ -784,27 +775,32 @@ Suff_AddSuffix(char *str) LstNode *ln; ln = Lst_Find(&sufflist, str, SuffSuffHasNameP); - if (ln == NULL) { - s = emalloc(sizeof(Suff)); + if (ln != NULL) + /* + * Already known + */ + return; - s->name = estrdup(str); - s->nameLen = strlen(s->name); - Lst_Init(&s->searchPath); - Lst_Init(&s->children); - Lst_Init(&s->parents); - Lst_Init(&s->ref); - s->sNum = sNum++; - s->flags = 0; - s->refCount = 0; + s = emalloc(sizeof(Suff)); - Lst_AtEnd(&sufflist, s); + s->name = estrdup(str); + s->nameLen = strlen(s->name); + Lst_Init(&s->searchPath); + Lst_Init(&s->children); + Lst_Init(&s->parents); + Lst_Init(&s->ref); + s->sNum = sNum++; + s->flags = 0; + s->refCount = 0; - /* - * Look for any existing transformations from or to this suffix. - * XXX: Only do this after a Suff_ClearSuffixes? - */ - Lst_ForEach(&transforms, SuffRebuildGraph, s); - } + Lst_AtEnd(&sufflist, s); + + /* + * Look for any existing transformations from or to this suffix. + * XXX: Only do this after a Suff_ClearSuffixes? + */ + LST_FOREACH(ln, &transforms) + SuffRebuildGraph(Lst_Datum(ln), s); } /*- @@ -977,6 +973,9 @@ SuffAddSrc(void *sp, void *lsp) LstSrc *ls = lsp; Src *s2; /* new Src structure */ Src *targ; /* Target structure */ +#ifdef DEBUG_SRC + const LstNode *ln; +#endif targ = ls->s; @@ -1000,7 +999,8 @@ SuffAddSrc(void *sp, void *lsp) Lst_Init(&s2->cp); Lst_AtEnd(&targ->cp, s2); printf("1 add %p %p to %p:", targ, s2, ls->l); - Lst_ForEach(ls->l, PrintAddr, (void *)NULL); + LST_FOREACH(ln, ls->l) + printf("%p ", (const void *)Lst_Datum(ln)); printf("\n"); #endif } @@ -1018,7 +1018,8 @@ SuffAddSrc(void *sp, void *lsp) Lst_Init(&s2->cp); Lst_AtEnd(&targ->cp, s2); printf("2 add %p %p to %p:", targ, s2, ls->l); - Lst_ForEach(ls->l, PrintAddr, (void *)NULL); + LST_FOREACH(ln, ls->l) + printf("%p ", (const void *)Lst_Datum(ln)); printf("\n"); #endif @@ -1070,7 +1071,8 @@ SuffRemoveSrc(Lst *l) #ifdef DEBUG_SRC printf("cleaning %lx: ", (unsigned long) l); - Lst_ForEach(l, PrintAddr, (void *)NULL); + LST_FOREACH(ln, l) + printf("%p ", (const void *)Lst_Datum(ln)); printf("\n"); #endif @@ -1101,8 +1103,11 @@ SuffRemoveSrc(Lst *l) } #ifdef DEBUG_SRC else { + const LstNode *tln; + printf("keep: [l=%p] p=%p %d: ", l, s, s->children); - Lst_ForEach(&s->cp, PrintAddr, (void *)NULL); + LST_FOREACH(tln, &s->cp) + printf("%p ", (const void *)Lst_Datum(tln)); printf("\n"); } #endif @@ -2338,16 +2343,3 @@ Suff_PrintAll(void) printf("\n"); } } - -#ifdef DEBUG_SRC -/* - * Printaddr -- - * Print the address of a node. - */ -static int -PrintAddr(void *a, void *b __unused) -{ - printf("%p ", a); - return (0); -} -#endif /* DEBUG_SRC */ |