version 1.76, 2007/11/17 16:39:45 |
version 1.77, 2007/11/24 15:41:01 |
|
|
static void SuffAddLevel(Lst, Src *); |
static void SuffAddLevel(Lst, Src *); |
static Src *SuffFindThem(Lst, Lst); |
static Src *SuffFindThem(Lst, Lst); |
static Src *SuffFindCmds(Src *, Lst); |
static Src *SuffFindCmds(Src *, Lst); |
static void SuffExpandChildren(void *, void *); |
static void SuffExpandChildren(LstNode, GNode *); |
static void SuffExpandVarChildren(LstNode, GNode *, GNode *); |
static void SuffExpandVarChildren(LstNode, GNode *, GNode *); |
static void SuffExpandWildChildren(LstNode, GNode *, GNode *); |
static void SuffExpandWildChildren(LstNode, GNode *, GNode *); |
static bool SuffApplyTransform(GNode *, GNode *, Suff *, Suff *); |
static bool SuffApplyTransform(GNode *, GNode *, Suff *, Suff *); |
|
|
Lst_Append(&pgn->children, after, gn); |
Lst_Append(&pgn->children, after, gn); |
after = Lst_Adv(after); |
after = Lst_Adv(after); |
Lst_AtEnd(&gn->parents, pgn); |
Lst_AtEnd(&gn->parents, pgn); |
pgn->unmade++; |
if (!has_been_built(gn)) |
|
pgn->unmade++; |
} |
} |
} |
} |
/* Free the result. */ |
/* Free the result. */ |
|
|
Lst_Append(&pgn->children, after, gn); |
Lst_Append(&pgn->children, after, gn); |
after = Lst_Adv(after); |
after = Lst_Adv(after); |
Lst_AtEnd(&gn->parents, pgn); |
Lst_AtEnd(&gn->parents, pgn); |
pgn->unmade++; |
if (!has_been_built(gn)) |
|
pgn->unmade++; |
} |
} |
} |
} |
|
|
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
SuffExpandChildren( |
SuffExpandChildren(LstNode ln, /* LstNode of child, so we can replace it */ |
void *cgnp, /* Child to examine */ |
GNode *pgn) |
void *pgnp) /* Parent node being processed */ |
|
{ |
{ |
GNode *cgn = (GNode *)cgnp; |
GNode *cgn = (GNode *)Lst_Datum(ln); |
GNode *pgn = (GNode *)pgnp; |
|
LstNode ln; |
|
/* New nodes effectively take the place of the child, so we place them |
|
* after the child. */ |
|
ln = Lst_Member(&pgn->children, cgn); |
|
|
|
/* First do variable expansion -- this takes precedence over wildcard |
/* First do variable expansion -- this takes precedence over wildcard |
* expansion. If the result contains wildcards, they'll be gotten to |
* expansion. If the result contains wildcards, they'll be gotten to |
|
|
Lst_Remove(&pgn->children, ln); |
Lst_Remove(&pgn->children, ln); |
} |
} |
|
|
|
void |
|
expand_children_from(GNode *parent, LstNode from) |
|
{ |
|
LstNode np, ln; |
|
|
|
for (ln = from; ln != NULL; ln = np) { |
|
np = Lst_Adv(ln); |
|
SuffExpandChildren(ln, parent); |
|
} |
|
} |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* SuffApplyTransform -- |
* SuffApplyTransform -- |
|
|
Suff *s) /* Source suffix */ |
Suff *s) /* Source suffix */ |
{ |
{ |
LstNode ln; /* General node */ |
LstNode ln; /* General node */ |
LstNode np; /* Next node for loop */ |
|
char *tname; /* Name of transformation rule */ |
char *tname; /* Name of transformation rule */ |
GNode *gn; /* Node for same */ |
GNode *gn; /* Node for same */ |
|
|
|
|
/* Not already linked, so form the proper links between the |
/* Not already linked, so form the proper links between the |
* target and source. */ |
* target and source. */ |
Lst_AtEnd(&sGn->parents, tGn); |
Lst_AtEnd(&sGn->parents, tGn); |
tGn->unmade++; |
if (!has_been_built(sGn)) |
|
tGn->unmade++; |
} |
} |
|
|
if ((sGn->type & OP_OPMASK) == OP_DOUBLEDEP) { |
if ((sGn->type & OP_OPMASK) == OP_DOUBLEDEP) { |
|
|
/* Not already linked, so form the proper links |
/* Not already linked, so form the proper links |
* between the target and source. */ |
* between the target and source. */ |
Lst_AtEnd(&gn->parents, tGn); |
Lst_AtEnd(&gn->parents, tGn); |
tGn->unmade++; |
if (!has_been_built(gn)) |
|
tGn->unmade++; |
} |
} |
} |
} |
} |
} |
|
|
Make_HandleUse(gn, tGn); |
Make_HandleUse(gn, tGn); |
|
|
/* Deal with wildcards and variables in any acquired sources. */ |
/* Deal with wildcards and variables in any acquired sources. */ |
for (ln = Lst_Succ(ln); ln != NULL; ln = np) { |
expand_children_from(tGn, Lst_Succ(ln)); |
np = Lst_Adv(ln); |
|
SuffExpandChildren(Lst_Datum(ln), tGn); |
|
} |
|
|
|
/* Keep track of another parent to which this beast is transformed so |
/* Keep track of another parent to which this beast is transformed so |
* the .IMPSRC variable can be set correctly for the parent. */ |
* the .IMPSRC variable can be set correctly for the parent. */ |
|
|
/* Create the link between the two nodes right off. */ |
/* Create the link between the two nodes right off. */ |
if (Lst_AddNew(&gn->children, mem)) { |
if (Lst_AddNew(&gn->children, mem)) { |
Lst_AtEnd(&mem->parents, gn); |
Lst_AtEnd(&mem->parents, gn); |
gn->unmade++; |
if (!has_been_built(mem)) |
|
gn->unmade++; |
} |
} |
|
|
/* Copy variables from member node to this one. */ |
/* Copy variables from member node to this one. */ |
|
|
GNode *gn, /* Node for which to find sources */ |
GNode *gn, /* Node for which to find sources */ |
Lst slst) |
Lst slst) |
{ |
{ |
LstNode np; |
|
LstNode ln; |
|
LIST srcs; /* List of sources at which to look */ |
LIST srcs; /* List of sources at which to look */ |
LIST targs; /* List of targets to which things can be |
LIST targs; /* List of targets to which things can be |
* transformed. They all have the same file, |
* transformed. They all have the same file, |
|
|
|
|
/* Now we've got the important local variables set, expand any sources |
/* Now we've got the important local variables set, expand any sources |
* that still contain variables or wildcards in their names. */ |
* that still contain variables or wildcards in their names. */ |
for (ln = Lst_First(&gn->children); ln != NULL; ln = np) { |
expand_all_children(gn); |
np = Lst_Adv(ln); |
|
SuffExpandChildren(Lst_Datum(ln), gn); |
|
} |
|
|
|
if (targ == NULL) { |
if (targ == NULL) { |
if (DEBUG(SUFF)) |
if (DEBUG(SUFF)) |