version 1.23, 2000/03/14 19:00:32 |
version 1.24, 2000/03/26 15:51:31 |
|
|
Lst searchPath; /* The path along which files of this suffix |
Lst searchPath; /* The path along which files of this suffix |
* may be found */ |
* may be found */ |
int sNum; /* The suffix number */ |
int sNum; /* The suffix number */ |
int refCount; /* Reference count of list membership */ |
|
Lst parents; /* Suffixes we have a transformation to */ |
Lst parents; /* Suffixes we have a transformation to */ |
Lst children; /* Suffixes we have a transformation from */ |
Lst children; /* Suffixes we have a transformation from */ |
Lst ref; /* List of lists this suffix is referenced */ |
Lst ref; /* List of lists this suffix is referenced */ |
|
|
static void SuffUnRef __P((ClientData, ClientData)); |
static void SuffUnRef __P((ClientData, ClientData)); |
static void SuffFree __P((ClientData)); |
static void SuffFree __P((ClientData)); |
static void SuffInsert __P((Lst, Suff *)); |
static void SuffInsert __P((Lst, Suff *)); |
static Suff *SuffRemove __P((Lst, Suff *)); |
static void SuffRemove __P((Lst, Suff *)); |
static Boolean SuffParseTransform __P((char *, Suff **, Suff **)); |
static Boolean SuffParseTransform __P((char *, Suff **, Suff **)); |
static int SuffRebuildGraph __P((ClientData, ClientData)); |
static int SuffRebuildGraph __P((ClientData, ClientData)); |
static int SuffAddSrc __P((ClientData, ClientData)); |
static int SuffAddSrc __P((ClientData, ClientData)); |
|
|
Lst l = (Lst) lp; |
Lst l = (Lst) lp; |
|
|
LstNode ln = Lst_Member(l, sp); |
LstNode ln = Lst_Member(l, sp); |
if (ln != NULL) { |
if (ln != NULL) |
Lst_Remove(l, ln); |
Lst_Remove(l, ln); |
((Suff *) sp)->refCount--; |
|
} |
|
} |
} |
|
|
/*- |
/*- |
|
|
if (s == emptySuff) |
if (s == emptySuff) |
emptySuff = NULL; |
emptySuff = NULL; |
|
|
#ifdef notdef |
|
/* We don't delete suffixes in order, so we cannot use this */ |
|
if (s->refCount) |
|
Punt("Internal error deleting suffix `%s' with refcount = %d", s->name, |
|
s->refCount); |
|
#endif |
|
|
|
Lst_Destroy (s->ref, NOFREE); |
Lst_Destroy (s->ref, NOFREE); |
Lst_Destroy (s->children, NOFREE); |
Lst_Destroy (s->children, NOFREE); |
Lst_Destroy (s->parents, NOFREE); |
Lst_Destroy (s->parents, NOFREE); |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* SuffRemove -- |
* SuffRemove -- |
* Remove the suffix into the list |
* Remove the suffix from the list |
* |
|
* Results: |
|
* None |
|
* |
|
* Side Effects: |
|
* The reference count for the suffix is decremented and the |
|
* suffix is possibly freed |
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static Suff * |
static void |
SuffRemove(l, s) |
SuffRemove(l, s) |
Lst l; |
Lst l; |
Suff *s; |
Suff *s; |
{ |
{ |
SuffUnRef((ClientData) l, (ClientData) s); |
SuffUnRef((ClientData) l, (ClientData) s); |
#if 0 |
|
if (s->refCount == 0) { |
|
SuffUnRef ((ClientData) sufflist, (ClientData) s); |
|
SuffFree((ClientData) s); |
|
s = NULL; |
|
} |
|
#endif |
|
return (s); |
|
} |
} |
|
|
/*- |
/*- |
|
|
printf("at end of list\n"); |
printf("at end of list\n"); |
} |
} |
Lst_AtEnd (l, (ClientData)s); |
Lst_AtEnd (l, (ClientData)s); |
s->refCount++; |
|
Lst_AtEnd(s->ref, (ClientData) l); |
Lst_AtEnd(s->ref, (ClientData) l); |
} else if (s2->sNum != s->sNum) { |
} else if (s2->sNum != s->sNum) { |
if (DEBUG(SUFF)) { |
if (DEBUG(SUFF)) { |
printf("before %s(%d)\n", s2->name, s2->sNum); |
printf("before %s(%d)\n", s2->name, s2->sNum); |
} |
} |
Lst_Insert(l, ln, (ClientData)s); |
Lst_Insert(l, ln, (ClientData)s); |
s->refCount++; |
|
Lst_AtEnd(s->ref, (ClientData) l); |
Lst_AtEnd(s->ref, (ClientData) l); |
} else if (DEBUG(SUFF)) { |
} else if (DEBUG(SUFF)) { |
printf("already there\n"); |
printf("already there\n"); |
|
|
} |
} |
|
|
/* |
/* |
* Remove the source from the target's children list. We check for a |
* Remove the source from the target's children list. |
* 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 |
* We'll be called twice when the next target is seen, but .c and .o |
* are only linked once... |
* are only linked once... |
*/ |
*/ |
s = SuffRemove(t->children, s); |
SuffRemove(t->children, s); |
|
|
/* |
/* |
* Remove the target from the source's parents list |
* Remove the target from the source's parents list |
*/ |
*/ |
if (s != NULL) |
SuffRemove(s->parents, t); |
SuffRemove(s->parents, t); |
|
} else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) { |
} else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) { |
printf("transformation %s complete\n", gn->name); |
printf("transformation %s complete\n", gn->name); |
} |
} |
|
|
s->ref = Lst_Init(); |
s->ref = Lst_Init(); |
s->sNum = sNum++; |
s->sNum = sNum++; |
s->flags = 0; |
s->flags = 0; |
s->refCount = 0; |
|
|
|
Lst_AtEnd(sufflist, (ClientData)s); |
Lst_AtEnd(sufflist, (ClientData)s); |
/* |
/* |
|
|
s2->parent = targ; |
s2->parent = targ; |
s2->node = NULL; |
s2->node = NULL; |
s2->suff = s; |
s2->suff = s; |
s->refCount++; |
|
s2->children = 0; |
s2->children = 0; |
targ->children += 1; |
targ->children += 1; |
Lst_AtEnd(ls->l, (ClientData)s2); |
Lst_AtEnd(ls->l, (ClientData)s2); |
|
|
s2->parent = targ; |
s2->parent = targ; |
s2->node = NULL; |
s2->node = NULL; |
s2->suff = s; |
s2->suff = s; |
s->refCount++; |
|
s2->children = 0; |
s2->children = 0; |
targ->children += 1; |
targ->children += 1; |
Lst_AtEnd(ls->l, (ClientData)s2); |
Lst_AtEnd(ls->l, (ClientData)s2); |
|
|
ret->file = estrdup(s->name); |
ret->file = estrdup(s->name); |
ret->pref = targ->pref; |
ret->pref = targ->pref; |
ret->suff = suff; |
ret->suff = suff; |
suff->refCount++; |
|
ret->parent = targ; |
ret->parent = targ; |
ret->node = s; |
ret->node = s; |
ret->children = 0; |
ret->children = 0; |
|
|
targ = (Src *)emalloc(sizeof (Src)); |
targ = (Src *)emalloc(sizeof (Src)); |
targ->file = estrdup(gn->name); |
targ->file = estrdup(gn->name); |
targ->suff = (Suff *)Lst_Datum(ln); |
targ->suff = (Suff *)Lst_Datum(ln); |
targ->suff->refCount++; |
|
targ->node = gn; |
targ->node = gn; |
targ->parent = (Src *)NULL; |
targ->parent = (Src *)NULL; |
targ->children = 0; |
targ->children = 0; |
|
|
targ = (Src *)emalloc(sizeof (Src)); |
targ = (Src *)emalloc(sizeof (Src)); |
targ->file = estrdup(gn->name); |
targ->file = estrdup(gn->name); |
targ->suff = suffNull; |
targ->suff = suffNull; |
targ->suff->refCount++; |
|
targ->node = gn; |
targ->node = gn; |
targ->parent = (Src *)NULL; |
targ->parent = (Src *)NULL; |
targ->children = 0; |
targ->children = 0; |
|
|
int savep = strlen(gn->path) - targ->suff->nameLen; |
int savep = strlen(gn->path) - targ->suff->nameLen; |
char savec; |
char savec; |
|
|
if (gn->suffix) |
|
gn->suffix->refCount--; |
|
gn->suffix = targ->suff; |
gn->suffix = targ->suff; |
gn->suffix->refCount++; |
|
|
|
savec = gn->path[savep]; |
savec = gn->path[savep]; |
gn->path[savep] = '\0'; |
gn->path[savep] = '\0'; |
|
|
* The .PREFIX gets the full path if the target has |
* The .PREFIX gets the full path if the target has |
* no known suffix. |
* no known suffix. |
*/ |
*/ |
if (gn->suffix) |
|
gn->suffix->refCount--; |
|
gn->suffix = NULL; |
gn->suffix = NULL; |
|
|
if ((ptr = strrchr(gn->path, '/')) != NULL) |
if ((ptr = strrchr(gn->path, '/')) != NULL) |
|
|
* path to be the name so Dir_MTime won't go grovelling for |
* path to be the name so Dir_MTime won't go grovelling for |
* it. |
* it. |
*/ |
*/ |
if (gn->suffix) |
|
gn->suffix->refCount--; |
|
gn->suffix = (targ == NULL) ? NULL : targ->suff; |
gn->suffix = (targ == NULL) ? NULL : targ->suff; |
if (gn->suffix) |
|
gn->suffix->refCount++; |
|
efree(gn->path); |
efree(gn->path); |
gn->path = estrdup(gn->name); |
gn->path = estrdup(gn->name); |
} |
} |
|
|
for (src = bottom; src->parent != (Src *)NULL; src = src->parent) { |
for (src = bottom; src->parent != (Src *)NULL; src = src->parent) { |
targ = src->parent; |
targ = src->parent; |
|
|
if (src->node->suffix) |
|
src->node->suffix->refCount--; |
|
src->node->suffix = src->suff; |
src->node->suffix = src->suff; |
src->node->suffix->refCount++; |
|
|
|
if (targ->node == NULL) { |
if (targ->node == NULL) { |
targ->node = Targ_FindNode(targ->file, TARG_CREATE); |
targ->node = Targ_FindNode(targ->file, TARG_CREATE); |
|
|
} |
} |
} |
} |
|
|
if (gn->suffix) |
|
gn->suffix->refCount--; |
|
gn->suffix = src->suff; |
gn->suffix = src->suff; |
gn->suffix->refCount++; |
|
|
|
/* |
/* |
* So Dir_MTime doesn't go questing for it... |
* So Dir_MTime doesn't go questing for it... |
|
|
Suff *s; |
Suff *s; |
|
|
ln = Lst_Find(sufflist, SuffSuffHasNameP, (ClientData)LIBSUFF); |
ln = Lst_Find(sufflist, SuffSuffHasNameP, (ClientData)LIBSUFF); |
if (gn->suffix) |
|
gn->suffix->refCount--; |
|
if (ln != NULL) { |
if (ln != NULL) { |
gn->suffix = s = (Suff *) Lst_Datum (ln); |
gn->suffix = s = (Suff *) Lst_Datum (ln); |
gn->suffix->refCount++; |
|
Arch_FindLib (gn, s->searchPath); |
Arch_FindLib (gn, s->searchPath); |
} else { |
} else { |
gn->suffix = NULL; |
gn->suffix = NULL; |
|
|
suffNull->ref = Lst_Init(); |
suffNull->ref = Lst_Init(); |
suffNull->sNum = sNum++; |
suffNull->sNum = sNum++; |
suffNull->flags = SUFF_NULL; |
suffNull->flags = SUFF_NULL; |
suffNull->refCount = 1; |
|
|
|
} |
} |
|
|
|
|
int flags; |
int flags; |
int flag; |
int flag; |
|
|
printf ("# `%s' [%d] ", s->name, s->refCount); |
printf ("# `%s' ", s->name); |
|
|
flags = s->flags; |
flags = s->flags; |
if (flags) { |
if (flags) { |