static Suff *SuffRemove __P((Lst, Suff *)); static Boolean SuffParseTransform __P((char *, Suff **, Suff **)); static int SuffRebuildGraph __P((ClientData, ClientData)); static int SuffAddSrc __P((ClientData, ClientData)); static int SuffRemoveSrc __P((Lst)); static void SuffAddLevel __P((Lst, Src *)); static Src *SuffFindThem __P((Lst, Lst)); static Src *SuffFindCmds __P((Src *, Lst)); static int SuffExpandChildren __P((ClientData, ClientData)); static Boolean SuffApplyTransform __P((GNode *, GNode *, Suff *, Suff *)); static void SuffFindDeps __P((GNode *, Lst)); static void SuffFindArchiveDeps __P((GNode *, Lst)); static void SuffFindNormalDeps __P((GNode *, Lst)); static int SuffPrintName __P((ClientData, ClientData)); static int SuffPrintSuff __P((ClientData, ClientData)); static int SuffPrintTrans __P((ClientData, ClientData));    static char    * SuffStrIsPrefix (pref, str) register char  *pref;	 register char  *str;	 { while (*str && *pref == *str) { pref++; str++; }  return (*pref ? NULL : str); }   static char * SuffSuffIsSuffix (s, str) register Suff  *s;		 char           *str;	 { register char  *p1;	    	 register char  *p2;	    	  p1 = s->name + s->nameLen; p2 = str;  while (p1 >= s->name && *p1 == *p2) { p1--; p2--; }  return (p1 == s->name - 1 ? p2 : NULL); }   static int SuffSuffIsSuffixP(s, str) ClientData   s; ClientData   str; { return(!SuffSuffIsSuffix((Suff *) s, (char *) str)); }   static int SuffSuffHasNameP (s, sname) ClientData    s;	    	     ClientData    sname; 	     { return (strcmp ((char *) sname, ((Suff *) s)->name)); }   static int SuffSuffIsPrefix (s, str) ClientData   s;		 ClientData   str;	 { return (SuffStrIsPrefix (((Suff *) s)->name, (char *) str) == NULL ? 1 : 0); }   static int SuffGNHasNameP (gn, name) ClientData      gn;		 ClientData      name;	 { return (strcmp ((char *) name, ((GNode *) gn)->name)); }    static void SuffUnRef(lp, sp) ClientData lp; ClientData sp; { Lst l = (Lst) lp;  LstNode ln = Lst_Member(l, sp); if (ln != NULL) { Lst_Remove(l, ln); ((Suff *) sp)->refCount--; } }   static void SuffFree (sp) ClientData sp; { Suff           *s = (Suff *) sp;  if (s == suffNull) suffNull = NULL;  if (s == emptySuff) emptySuff = NULL;  #ifdef notdef  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->children, NOFREE); Lst_Destroy (s->parents, NOFREE); Lst_Destroy (s->searchPath, Dir_Destroy);  free ((Address)s->name); free ((Address)s); }   static Suff *
static Suff *SuffRemove __P((Lst, Suff *));static Boolean SuffParseTransform __P((char *, Suff **, Suff **));static int SuffRebuildGraph __P((ClientData, ClientData));static int SuffAddSrc __P((ClientData, ClientData));static int SuffRemoveSrc __P((Lst));static void SuffAddLevel __P((Lst, Src *));static Src *SuffFindThem __P((Lst, Lst));static Src *SuffFindCmds __P((Src *, Lst));static int SuffExpandChildren __P((ClientData, ClientData));static Boolean SuffApplyTransform __P((GNode *, GNode *, Suff *, Suff *));static void SuffFindDeps __P((GNode *, Lst));static void SuffFindArchiveDeps __P((GNode *, Lst));static void SuffFindNormalDeps __P((GNode *, Lst));static int SuffPrintName __P((ClientData, ClientData));static int SuffPrintSuff __P((ClientData, ClientData));static int SuffPrintTrans __P((ClientData, ClientData));	/*************** Lst Predicates ****************//*- *----------------------------------------------------------------------- * SuffStrIsPrefix  -- *	See if pref is a prefix of str. * * Results: *	NULL if it ain't, pointer to character in str after prefix if so * * Side Effects: *	None *----------------------------------------------------------------------- */static char    *SuffStrIsPrefix (pref, str)    register char  *pref;	/* possible prefix */    register char  *str;	/* string to check */{    while (*str && *pref == *str) {	pref++;	str++;    }    return (*pref ? NULL : str);}/*- *----------------------------------------------------------------------- * SuffSuffIsSuffix  -- *	See if suff is a suffix of str. Str should point to THE END of the *	string to check. (THE END == the null byte) * * Results: *	NULL if it ain't, pointer to character in str before suffix if *	it is. * * Side Effects: *	None *----------------------------------------------------------------------- */static char *SuffSuffIsSuffix (s, str)    register Suff  *s;		/* possible suffix */    char           *str;	/* string to examine */{    register char  *p1;	    	/* Pointer into suffix name */    register char  *p2;	    	/* Pointer into string being examined */    p1 = s->name + s->nameLen;    p2 = str;    while (p1 >= s->name && *p1 == *p2) {	p1--;	p2--;    }    return (p1 == s->name - 1 ? p2 : NULL);}/*- *----------------------------------------------------------------------- * SuffSuffIsSuffixP -- *	Predicate form of SuffSuffIsSuffix. Passed as the callback function *	to Lst_Find. * * Results: *	0 if the suffix is the one desired, non-zero if not. * * Side Effects: *	None. * *----------------------------------------------------------------------- */static intSuffSuffIsSuffixP(s, str)    ClientData   s;    ClientData   str;{    return(!SuffSuffIsSuffix((Suff *) s, (char *) str));}/*- *----------------------------------------------------------------------- * SuffSuffHasNameP -- *	Callback procedure for finding a suffix based on its name. Used by *	Suff_GetPath. * * Results: *	0 if the suffix is of the given name. non-zero otherwise. * * Side Effects: *	None *----------------------------------------------------------------------- */static intSuffSuffHasNameP (s, sname)    ClientData    s;	    	    /* Suffix to check */    ClientData    sname; 	    /* Desired name */{    return (strcmp ((char *) sname, ((Suff *) s)->name));}/*- *----------------------------------------------------------------------- * SuffSuffIsPrefix  -- *	See if the suffix described by s is a prefix of the string. Care *	must be taken when using this to search for transformations and *	what-not, since there could well be two suffixes, one of which *	is a prefix of the other... * * Results: *	0 if s is a prefix of str. non-zero otherwise * * Side Effects: *	None *----------------------------------------------------------------------- */static intSuffSuffIsPrefix (s, str)    ClientData   s;		/* suffix to compare */    ClientData   str;	/* string to examine */{    return (SuffStrIsPrefix (((Suff *) s)->name, (char *) str) == NULL ? 1 : 0);}/*- *----------------------------------------------------------------------- * SuffGNHasNameP  -- *	See if the graph node has the desired name * * Results: *	0 if it does. non-zero if it doesn't * * Side Effects: *	None *----------------------------------------------------------------------- */static intSuffGNHasNameP (gn, name)    ClientData      gn;		/* current node we're looking at */    ClientData      name;	/* name we're looking for */{    return (strcmp ((char *) name, ((GNode *) gn)->name));} 	    /*********** Maintenance Functions ************/static voidSuffUnRef(lp, sp)    ClientData lp;    ClientData sp;{    Lst l = (Lst) lp;    LstNode ln = Lst_Member(l, sp);    if (ln != NULL) {	Lst_Remove(l, ln);	((Suff *) sp)->refCount--;    }}/*- *----------------------------------------------------------------------- * SuffFree  -- *	Free up all memory associated with the given suffix structure. * * Results: *	none * * Side Effects: *	the suffix entry is detroyed *----------------------------------------------------------------------- */static voidSuffFree (sp)    ClientData sp;{    Suff           *s = (Suff *) sp;    if (s == suffNull)	suffNull = NULL;    if (s == emptySuff)	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->children, NOFREE);    Lst_Destroy (s->parents, NOFREE);    Lst_Destroy (s->searchPath, Dir_Destroy);    free ((Address)s->name);    free ((Address)s);}/*- *----------------------------------------------------------------------- * SuffRemove  -- *	Remove the suffix into the list * * Results: *	None * * Side Effects: *	The reference count for the suffix is decremented and the *	suffix is possibly freed *----------------------------------------------------------------------- */static Suff *SuffRemove(l, s)    Lst l;    Suff *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);}