From a333d4f752453ccdb71c1bb03b9a0fd25df15e24 Mon Sep 17 00:00:00 2001 From: Thomas Moestl Date: Thu, 8 Mar 2001 00:55:08 +0000 Subject: [PATCH] Fix two bugs in null suffix handling. Both occured only after the suffix list was cleared. Rules with null suffixes would not be rebuilt when the suffixes were added again. Adding null suffix rules would fail when a rule for the same source was declared before the suffix list was cleared. PR: 23328, 24102 Reviewed by: will Approved by: rwatson --- usr.bin/make/suff.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 81d4216190a..8ade95edb48 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -460,8 +460,16 @@ Suff_ClearSuffixes () { Lst_Concat (suffClean, sufflist, LST_CONCLINK); sufflist = Lst_Init(FALSE); - sNum = 0; + sNum = 1; suffNull = emptySuff; + /* + * Clear suffNull's children list (the other suffixes are built new, but + * suffNull is used as is). + * NOFREE is used because all suffixes are are on the suffClean list. + * suffNull should not have parents. + */ + Lst_Destroy(suffNull->children, NOFREE); + suffNull->children = Lst_Init(FALSE); } /*- @@ -714,20 +722,25 @@ SuffRebuildGraph(transformp, sp) Suff *s = (Suff *) sp; char *cp; LstNode ln; - Suff *s2; + Suff *s2 = NULL; /* * First see if it is a transformation from this suffix. */ cp = SuffStrIsPrefix(s->name, transform->name); if (cp != (char *)NULL) { - ln = Lst_Find(sufflist, (void *)cp, SuffSuffHasNameP); - if (ln != NULL) { + if (cp[0] == '\0') /* null rule */ + s2 = suffNull; + else { + ln = Lst_Find(sufflist, (void *)cp, SuffSuffHasNameP); + if (ln != NULL) + s2 = (Suff *)Lst_Datum(ln); + } + if (s2 != NULL) { /* * Found target. Link in and return, since it can't be anything * else. */ - s2 = (Suff *)Lst_Datum(ln); SuffInsert(s2->children, s); SuffInsert(s->parents, s2); return(0); @@ -2359,7 +2372,7 @@ static int SuffPrintName(s, dummy) void * s; void * dummy; { - printf ("%s ", ((Suff *) s)->name); + printf ("`%s' ", ((Suff *) s)->name); return (dummy ? 0 : 0); }