Reorganize Suff_EndTransform to be called only for nodes for

which it is needed (transforms).
This commit is contained in:
Hartmut Brandt 2005-03-10 14:54:47 +00:00
parent d7011881e7
commit 6dfe1d848e
3 changed files with 41 additions and 45 deletions

View File

@ -2367,12 +2367,16 @@ ParseReadLine(void)
static void
ParseFinishLine(void)
{
const LstNode *ln;
if (inLine) {
Lst_ForEach(&targets, Suff_EndTransform, NULL);
Lst_Destroy(&targets, ParseHasCommands);
inLine = FALSE;
}
if (inLine) {
LST_FOREACH(ln, &targets) {
if (((const GNode *)Lst_Datum(ln))->type & OP_TRANSFORM)
Suff_EndTransform(Lst_Datum(ln));
}
Lst_Destroy(&targets, ParseHasCommands);
inLine = FALSE;
}
}

View File

@ -653,11 +653,8 @@ Suff_AddTransform(char *line)
* Suff_EndTransform --
* Handle the finish of a transformation definition, removing the
* transformation from the graph if it has neither commands nor
* sources. This is a callback procedure for the Parse module via
* Lst_ForEach
*
* Results:
* === 0
* sources. This is called from the Parse module at the end of
* a dependency block.
*
* Side Effects:
* If the node has no commands or children, the children and parents
@ -665,45 +662,40 @@ Suff_AddTransform(char *line)
*
*-----------------------------------------------------------------------
*/
int
Suff_EndTransform(void *gnp, void *dummy __unused)
void
Suff_EndTransform(const GNode *gn)
{
GNode *gn = (GNode *)gnp;
Suff *s, *t;
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(&gn->commands) &&
Lst_IsEmpty(&gn->children)) {
Suff *s, *t;
/*
* SuffParseTransform() may fail for special rules which are not
* actual transformation rules (e.g., .DEFAULT).
*/
if (!SuffParseTransform(gn->name, &s, &t))
return (0);
DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n",
s->name, t->name));
/*
* Remove the source from the target's children list. We check
* for a NULL return to handle a beanhead saying something like
* .c.o .c.o:
*
* We'll be called twice when the next target is seen, but .c
* and .o are only linked once...
*/
SuffRemove(&t->children, s);
/*
* Remove the target from the source's parents list
*/
SuffRemove(&s->parents, t);
} else if (gn->type & OP_TRANSFORM) {
if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) {
DEBUGF(SUFF, ("transformation %s complete\n", gn->name));
return;
}
return (0);
/*
* SuffParseTransform() may fail for special rules which are not
* actual transformation rules (e.g., .DEFAULT).
*/
if (!SuffParseTransform(gn->name, &s, &t))
return;
DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n",
s->name, t->name));
/*
* Remove the source from the target's children list. We check
* for a NULL return to handle a beanhead saying something like
* .c.o .c.o:
*
* We'll be called twice when the next target is seen, but .c
* and .o are only linked once...
*/
SuffRemove(&t->children, s);
/*
* Remove the target from the source's parents list
*/
SuffRemove(&s->parents, t);
}
/*-

View File

@ -46,7 +46,7 @@ struct GNode;
void Suff_ClearSuffixes(void);
Boolean Suff_IsTransform(char *);
struct GNode *Suff_AddTransform(char *);
int Suff_EndTransform(void *, void *);
void Suff_EndTransform(const struct GNode *);
void Suff_AddSuffix(char *);
Lst *Suff_GetPath(char *);
void Suff_DoPaths(void);