diff options
-rw-r--r-- | usr.bin/make/suff.c | 108 |
1 files changed, 38 insertions, 70 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index ed95bce..f26111f 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -157,15 +157,6 @@ typedef struct Src { #endif } Src; -/* - * A structure for passing more than one argument to the Lst-library-invoked - * function... - */ -typedef struct { - Lst *l; - Src *s; -} LstSrc; - /* The NULL suffix for this run */ static Suff *suffNull; @@ -977,87 +968,64 @@ SuffSrcCreate(char *file, char *prefix, Suff *suff, Src *parent, GNode *node) /*- *----------------------------------------------------------------------- - * SuffAddSrc -- + * SuffAddLevel -- + * Add all the children of targ as Src structures to the given list: * Add a suffix as a Src structure to the given list with its parent * being the given Src structure. If the suffix is the null suffix, * the prefix is used unaltered as the file name in the Src structure. * * Results: - * always returns 0 + * None * * Side Effects: - * A Src structure is created and tacked onto the end of the list + * Lots of structures are created and added to the list *----------------------------------------------------------------------- */ -static int -SuffAddSrc(void *sp, void *lsp) +static void +SuffAddLevel(Lst *l, Src *targ) { - Suff *s = sp; - LstSrc *ls = lsp; - Src *s2; /* new Src structure */ - Src *targ; /* Target structure */ + LstNode *ln; + Suff *suff; + Src *s2; #ifdef DEBUG_SRC - const LstNode *ln; + const LstNode *ln1; #endif - targ = ls->s; + LST_FOREACH(ln, &targ->suff->children) { + suff = Lst_Datum(ln); - if ((s->flags & SUFF_NULL) && (*s->name != '\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 that... - */ - s2 = SuffSrcCreate(estrdup(targ->pref), targ->pref, - s, targ, NULL); - s->refCount++; + if ((suff->flags & SUFF_NULL) && *suff->name != '\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 that... + */ + s2 = SuffSrcCreate(estrdup(targ->pref), targ->pref, + suff, targ, NULL); + suff->refCount++; + targ->children += 1; + Lst_AtEnd(l, s2); +#ifdef DEBUG_SRC + Lst_AtEnd(&targ->cp, s2); + printf("1 add %p %p to %p:", targ, s2, l); + LST_FOREACH(ln1, l) + printf("%p ", (const void *)Lst_Datum(ln1)); + printf("\n"); +#endif + } + s2 = SuffSrcCreate(str_concat(targ->pref, suff->name, 0), + targ->pref, suff, targ, NULL); + suff->refCount++; targ->children += 1; - Lst_AtEnd(ls->l, s2); + Lst_AtEnd(l, s2); #ifdef DEBUG_SRC Lst_AtEnd(&targ->cp, s2); - printf("1 add %p %p to %p:", targ, s2, ls->l); - LST_FOREACH(ln, ls->l) - printf("%p ", (const void *)Lst_Datum(ln)); + printf("2 add %p %p to %p:", targ, s2, l); + LST_FOREACH(ln1, l) + printf("%p ", (const void *)Lst_Datum(ln1)); printf("\n"); #endif } - s2 = SuffSrcCreate(str_concat(targ->pref, s->name, 0), targ->pref, - s, targ, NULL); - s->refCount++; - targ->children += 1; - Lst_AtEnd(ls->l, s2); -#ifdef DEBUG_SRC - Lst_AtEnd(&targ->cp, s2); - printf("2 add %p %p to %p:", targ, s2, ls->l); - LST_FOREACH(ln, ls->l) - printf("%p ", (const void *)Lst_Datum(ln)); - printf("\n"); -#endif - - return (0); -} - -/*- - *----------------------------------------------------------------------- - * SuffAddLevel -- - * Add all the children of targ as Src structures to the given list - * - * Results: - * None - * - * Side Effects: - * Lots of structures are created and added to the list - *----------------------------------------------------------------------- - */ -static void -SuffAddLevel(Lst *l, Src *targ) -{ - LstSrc ls; - - ls.s = targ; - ls.l = l; - - Lst_ForEach(&targ->suff->children, SuffAddSrc, &ls); } /*- |