=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/suff.c,v retrieving revision 1.17 retrieving revision 1.18 diff -c -r1.17 -r1.18 *** src/usr.bin/make/suff.c 1999/12/18 02:11:27 1.17 --- src/usr.bin/make/suff.c 1999/12/18 21:53:33 1.18 *************** *** 1,4 **** ! /* $OpenBSD: suff.c,v 1.17 1999/12/18 02:11:27 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: suff.c,v 1.18 1999/12/18 21:53:33 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* *************** *** 43,49 **** #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else ! static char rcsid[] = "$OpenBSD: suff.c,v 1.17 1999/12/18 02:11:27 espie Exp $"; #endif #endif /* not lint */ --- 43,49 ---- #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else ! static char rcsid[] = "$OpenBSD: suff.c,v 1.18 1999/12/18 21:53:33 espie Exp $"; #endif #endif /* not lint */ *************** *** 94,100 **** * * Suff_FindDeps Find implicit sources for and the location of * a target based on its suffix. Returns the ! * bottom-most node added to the graph or NILGNODE * if the target had no implicit sources. */ --- 94,100 ---- * * Suff_FindDeps Find implicit sources for and the location of * a target based on its suffix. Returns the ! * bottom-most node added to the graph or NULL * if the target had no implicit sources. */ *************** *** 342,348 **** Lst l = (Lst) lp; LstNode ln = Lst_Member(l, sp); ! if (ln != NILLNODE) { Lst_Remove(l, ln); ((Suff *) sp)->refCount--; } --- 342,348 ---- Lst l = (Lst) lp; LstNode ln = Lst_Member(l, sp); ! if (ln != NULL) { Lst_Remove(l, ln); ((Suff *) sp)->refCount--; } *************** *** 439,445 **** if (Lst_Open (l) == FAILURE) { return; } ! while ((ln = Lst_Next (l)) != NILLNODE) { s2 = (Suff *) Lst_Datum (ln); if (s2->sNum >= s->sNum) { break; --- 439,445 ---- if (Lst_Open (l) == FAILURE) { return; } ! while ((ln = Lst_Next (l)) != NULL) { s2 = (Suff *) Lst_Datum (ln); if (s2->sNum >= s->sNum) { break; *************** *** 450,456 **** if (DEBUG(SUFF)) { printf("inserting %s(%d)...", s->name, s->sNum); } ! if (ln == NILLNODE) { if (DEBUG(SUFF)) { printf("at end of list\n"); } --- 450,456 ---- if (DEBUG(SUFF)) { printf("inserting %s(%d)...", s->name, s->sNum); } ! if (ln == NULL) { if (DEBUG(SUFF)) { printf("at end of list\n"); } *************** *** 525,532 **** Suff *single = NULL;/* Source of possible transformation to * null suffix */ ! srcLn = NILLNODE; ! singleLn = NILLNODE; /* * Loop looking first for a suffix that matches the start of the --- 525,532 ---- Suff *single = NULL;/* Source of possible transformation to * null suffix */ ! srcLn = NULL; ! singleLn = NULL; /* * Loop looking first for a suffix that matches the start of the *************** *** 535,551 **** * parsed the string. */ for (;;) { ! if (srcLn == NILLNODE) { srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix); } else { srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str, SuffSuffIsPrefix); } ! if (srcLn == NILLNODE) { /* * Ran out of source suffixes -- no such rule */ ! if (singleLn != NILLNODE) { /* * Not so fast Mr. Smith! There was a suffix that encompassed * the entire string, so we assume it was a transformation --- 535,551 ---- * parsed the string. */ for (;;) { ! if (srcLn == NULL) { srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix); } else { srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str, SuffSuffIsPrefix); } ! if (srcLn == NULL) { /* * Ran out of source suffixes -- no such rule */ ! if (singleLn != NULL) { /* * Not so fast Mr. Smith! There was a suffix that encompassed * the entire string, so we assume it was a transformation *************** *** 568,574 **** singleLn = srcLn; } else { targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP); ! if (targLn != NILLNODE) { *srcPtr = src; *targPtr = (Suff *)Lst_Datum(targLn); return (TRUE); --- 568,574 ---- singleLn = srcLn; } else { targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP); ! if (targLn != NULL) { *srcPtr = src; *targPtr = (Suff *)Lst_Datum(targLn); return (TRUE); *************** *** 624,630 **** LstNode ln; /* Node for existing transformation */ ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP); ! if (ln == NILLNODE) { /* * Make a new graph node for the transformation. It will be filled in * by the Parse module. --- 624,630 ---- LstNode ln; /* Node for existing transformation */ ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP); ! if (ln == NULL) { /* * Make a new graph node for the transformation. It will be filled in * by the Parse module. *************** *** 700,706 **** /* * Remove the source from the target's children list. We check for a ! * nil 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 --- 700,706 ---- /* * 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 *************** *** 756,762 **** cp = SuffStrIsPrefix(s->name, transform->name); if (cp != (char *)NULL) { ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP); ! if (ln != NILLNODE) { /* * Found target. Link in and return, since it can't be anything * else. --- 756,762 ---- cp = SuffStrIsPrefix(s->name, transform->name); if (cp != (char *)NULL) { ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP); ! if (ln != NULL) { /* * Found target. Link in and return, since it can't be anything * else. *************** *** 782,788 **** * Replace the start of the target suffix */ cp[1] = s->name[0]; ! if (ln != NILLNODE) { /* * Found it -- establish the proper relationship */ --- 782,788 ---- * Replace the start of the target suffix */ cp[1] = s->name[0]; ! if (ln != NULL) { /* * Found it -- establish the proper relationship */ *************** *** 816,822 **** LstNode ln; ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP); ! if (ln == NILLNODE) { s = (Suff *) emalloc (sizeof (Suff)); s->name = estrdup (str); --- 816,822 ---- LstNode ln; ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP); ! if (ln == NULL) { s = (Suff *) emalloc (sizeof (Suff)); s->name = estrdup (str); *************** *** 844,850 **** * Return the search path for the given suffix, if it's defined. * * Results: ! * The searchPath for the desired suffix or NILLST if the suffix isn't * defined. * * Side Effects: --- 844,850 ---- * Return the search path for the given suffix, if it's defined. * * Results: ! * The searchPath for the desired suffix or NULL if the suffix isn't * defined. * * Side Effects: *************** *** 859,866 **** Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln == NILLNODE) { ! return (NILLST); } else { s = (Suff *) Lst_Datum (ln); return (s->searchPath); --- 859,866 ---- Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln == NULL) { ! return (NULL); } else { s = (Suff *) Lst_Datum (ln); return (s->searchPath); *************** *** 901,907 **** inIncludes = Lst_Init(); inLibs = Lst_Init(); ! while ((ln = Lst_Next (sufflist)) != NILLNODE) { s = (Suff *) Lst_Datum (ln); if (!Lst_IsEmpty (s->searchPath)) { #ifdef INCLUDES --- 901,907 ---- inIncludes = Lst_Init(); inLibs = Lst_Init(); ! while ((ln = Lst_Next (sufflist)) != NULL) { s = (Suff *) Lst_Datum (ln); if (!Lst_IsEmpty (s->searchPath)) { #ifdef INCLUDES *************** *** 955,961 **** Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln != NILLNODE) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_INCLUDE; } --- 955,961 ---- Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln != NULL) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_INCLUDE; } *************** *** 985,991 **** Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln != NILLNODE) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_LIBRARY; } --- 985,991 ---- Suff *s; ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); ! if (ln != NULL) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_LIBRARY; } *************** *** 1029,1035 **** s2->file = estrdup(targ->pref); s2->pref = targ->pref; s2->parent = targ; ! s2->node = NILGNODE; s2->suff = s; s->refCount++; s2->children = 0; --- 1029,1035 ---- s2->file = estrdup(targ->pref); s2->pref = targ->pref; s2->parent = targ; ! s2->node = NULL; s2->suff = s; s->refCount++; s2->children = 0; *************** *** 1047,1053 **** s2->file = str_concat (targ->pref, s->name, 0); s2->pref = targ->pref; s2->parent = targ; ! s2->node = NILGNODE; s2->suff = s; s->refCount++; s2->children = 0; --- 1047,1053 ---- s2->file = str_concat (targ->pref, s->name, 0); s2->pref = targ->pref; s2->parent = targ; ! s2->node = NULL; s2->suff = s; s->refCount++; s2->children = 0; *************** *** 1119,1125 **** #endif ! while ((ln = Lst_Next (l)) != NILLNODE) { s = (Src *) Lst_Datum (ln); if (s->children == 0) { free ((Address)s->file); --- 1119,1125 ---- #endif ! while ((ln = Lst_Next (l)) != NULL) { s = (Src *) Lst_Datum (ln); if (s->children == 0) { free ((Address)s->file); *************** *** 1128,1134 **** else { #ifdef DEBUG_SRC LstNode ln = Lst_Member(s->parent->cp, (ClientData)s); ! if (ln != NILLNODE) Lst_Remove(s->parent->cp, ln); #endif --s->parent->children; --- 1128,1134 ---- else { #ifdef DEBUG_SRC LstNode ln = Lst_Member(s->parent->cp, (ClientData)s); ! if (ln != NULL) Lst_Remove(s->parent->cp, ln); #endif --s->parent->children; *************** *** 1191,1197 **** * A file is considered to exist if either a node exists in the * graph for it or the file actually exists. */ ! if (Targ_FindNode(s->file, TARG_NOCREATE) != NILGNODE) { #ifdef DEBUG_SRC printf("remove %x from %x\n", s, srcs); #endif --- 1191,1197 ---- * A file is considered to exist if either a node exists in the * graph for it or the file actually exists. */ ! if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) { #ifdef DEBUG_SRC printf("remove %x from %x\n", s, srcs); #endif *************** *** 1230,1236 **** * a Src structure is put together for it and returned. * * Results: ! * The Src structure of the "winning" child, or NIL if no such beast. * * Side Effects: * A Src structure may be allocated. --- 1230,1236 ---- * a Src structure is put together for it and returned. * * Results: ! * The Src structure of the "winning" child, or NULL if no such beast. * * Side Effects: * A Src structure may be allocated. *************** *** 1254,1260 **** (void) Lst_Open (t->children); prefLen = strlen (targ->pref); ! while ((ln = Lst_Next (t->children)) != NILLNODE) { s = (GNode *)Lst_Datum (ln); cp = strrchr (s->name, '/'); --- 1254,1260 ---- (void) Lst_Open (t->children); prefLen = strlen (targ->pref); ! while ((ln = Lst_Next (t->children)) != NULL) { s = (GNode *)Lst_Datum (ln); cp = strrchr (s->name, '/'); *************** *** 1270,1276 **** */ ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], SuffSuffHasNameP); ! if (ln != NILLNODE) { /* * It even has a known suffix, see if there's a transformation * defined between the node's suffix and the target's suffix. --- 1270,1276 ---- */ ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], SuffSuffHasNameP); ! if (ln != NULL) { /* * It even has a known suffix, see if there's a transformation * defined between the node's suffix and the target's suffix. *************** *** 1280,1286 **** suff = (Suff *)Lst_Datum (ln); if (Lst_Member (suff->parents, ! (ClientData)targ->suff) != NILLNODE) { /* * Hot Damn! Create a new Src structure to describe --- 1280,1286 ---- suff = (Suff *)Lst_Datum (ln); if (Lst_Member (suff->parents, ! (ClientData)targ->suff) != NULL) { /* * Hot Damn! Create a new Src structure to describe *************** *** 1450,1456 **** if (DEBUG(SUFF)) { printf("%s...", gn->name); } ! if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); prevLN = Lst_Succ(prevLN); (void)Lst_AtEnd(gn->parents, (ClientData)pgn); --- 1450,1456 ---- if (DEBUG(SUFF)) { printf("%s...", gn->name); } ! if (Lst_Member(pgn->children, (ClientData)gn) == NULL) { (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); prevLN = Lst_Succ(prevLN); (void)Lst_AtEnd(gn->parents, (ClientData)pgn); *************** *** 1492,1498 **** printf("Wildcard expanding \"%s\"...", cgn->name); } ! if (ln != NILLNODE) { Suff *s = (Suff *)Lst_Datum(ln); if (DEBUG(SUFF)) { --- 1492,1498 ---- printf("Wildcard expanding \"%s\"...", cgn->name); } ! if (ln != NULL) { Suff *s = (Suff *)Lst_Datum(ln); if (DEBUG(SUFF)) { *************** *** 1527,1533 **** * If gn isn't already a child of the parent, make it so and * up the parent's count of unmade children. */ ! if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); prevLN = Lst_Succ(prevLN); (void)Lst_AtEnd(gn->parents, (ClientData)pgn); --- 1527,1533 ---- * If gn isn't already a child of the parent, make it so and * up the parent's count of unmade children. */ ! if (Lst_Member(pgn->children, (ClientData)gn) == NULL) { (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); prevLN = Lst_Succ(prevLN); (void)Lst_AtEnd(gn->parents, (ClientData)pgn); *************** *** 1584,1590 **** char *tname; /* Name of transformation rule */ GNode *gn; /* Node for same */ ! if (Lst_Member(tGn->children, (ClientData)sGn) == NILLNODE) { /* * Not already linked, so form the proper links between the * target and source. --- 1584,1590 ---- char *tname; /* Name of transformation rule */ GNode *gn; /* Node for same */ ! if (Lst_Member(tGn->children, (ClientData)sGn) == NULL) { /* * Not already linked, so form the proper links between the * target and source. *************** *** 1601,1610 **** * sGn gets the target in its iParents list, however, as that * will be sufficient to get the .IMPSRC variable set for tGn */ ! for (ln=Lst_First(sGn->cohorts); ln != NILLNODE; ln=Lst_Succ(ln)) { gn = (GNode *)Lst_Datum(ln); ! if (Lst_Member(tGn->children, (ClientData)gn) == NILLNODE) { /* * Not already linked, so form the proper links between the * target and source. --- 1601,1610 ---- * sGn gets the target in its iParents list, however, as that * will be sufficient to get the .IMPSRC variable set for tGn */ ! for (ln=Lst_First(sGn->cohorts); ln != NULL; ln=Lst_Succ(ln)) { gn = (GNode *)Lst_Datum(ln); ! if (Lst_Member(tGn->children, (ClientData)gn) == NULL) { /* * Not already linked, so form the proper links between the * target and source. *************** *** 1622,1628 **** ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); free(tname); ! if (ln == NILLNODE) { /* * Not really such a transformation rule (can happen when we're * called to link an OP_MEMBER and OP_ARCHV node), so return --- 1622,1628 ---- ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); free(tname); ! if (ln == NULL) { /* * Not really such a transformation rule (can happen when we're * called to link an OP_MEMBER and OP_ARCHV node), so return *************** *** 1651,1657 **** * Deal with wildcards and variables in any acquired sources */ ln = Lst_Succ(ln); ! if (ln != NILLNODE) { Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, (ClientData)tGn); } --- 1651,1657 ---- * Deal with wildcards and variables in any acquired sources */ ln = Lst_Succ(ln); ! if (ln != NULL) { Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, (ClientData)tGn); } *************** *** 1722,1728 **** /* * Create the link between the two nodes right off */ ! if (Lst_Member(gn->children, (ClientData)mem) == NILLNODE) { (void)Lst_AtEnd(gn->children, (ClientData)mem); (void)Lst_AtEnd(mem->parents, (ClientData)gn); gn->unmade += 1; --- 1722,1728 ---- /* * Create the link between the two nodes right off */ ! if (Lst_Member(gn->children, (ClientData)mem) == NULL) { (void)Lst_AtEnd(gn->children, (ClientData)mem); (void)Lst_AtEnd(mem->parents, (ClientData)gn); gn->unmade += 1; *************** *** 1768,1774 **** */ ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP); ! if (ln != NILLNODE) { /* * Got one -- apply it */ --- 1768,1774 ---- */ ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP); ! if (ln != NULL) { /* * Got one -- apply it */ *************** *** 1864,1876 **** * Should we find one, we discard the one we found before. */ ! while (ln != NILLNODE) { /* * Look for next possible suffix... */ ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP); ! if (ln != NILLNODE) { int prefLen; /* Length of the prefix */ Src *targ; --- 1864,1876 ---- * Should we find one, we discard the one we found before. */ ! while (ln != NULL) { /* * Look for next possible suffix... */ ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP); ! if (ln != NULL) { int prefLen; /* Length of the prefix */ Src *targ; *************** *** 2093,2099 **** * up to, but not including, the parent node. */ while (bottom && bottom->parent != NULL) { ! if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) { Lst_AtEnd(slst, (ClientData) bottom); } bottom = bottom->parent; --- 2093,2099 ---- * up to, but not including, the parent node. */ while (bottom && bottom->parent != NULL) { ! if (Lst_Member(slst, (ClientData) bottom) == NULL) { Lst_AtEnd(slst, (ClientData) bottom); } bottom = bottom->parent; *************** *** 2121,2127 **** * transformation rule. Also, the unmade field of gn is incremented. * Etc. */ ! if (bottom->node == NILGNODE) { bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); } --- 2121,2127 ---- * transformation rule. Also, the unmade field of gn is incremented. * Etc. */ ! if (bottom->node == NULL) { bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); } *************** *** 2133,2139 **** src->node->suffix = src->suff; src->node->suffix->refCount++; ! if (targ->node == NILGNODE) { targ->node = Targ_FindNode(targ->file, TARG_CREATE); } --- 2133,2139 ---- src->node->suffix = src->suff; src->node->suffix->refCount++; ! if (targ->node == NULL) { targ->node = Targ_FindNode(targ->file, TARG_CREATE); } *************** *** 2175,2181 **** */ sfnd_return: if (bottom) ! if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) Lst_AtEnd(slst, (ClientData) bottom); while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) --- 2175,2181 ---- */ sfnd_return: if (bottom) ! if (Lst_Member(slst, (ClientData) bottom) == NULL) Lst_AtEnd(slst, (ClientData) bottom); while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) *************** *** 2260,2266 **** ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); if (gn->suffix) gn->suffix->refCount--; ! if (ln != NILLNODE) { gn->suffix = s = (Suff *) Lst_Datum (ln); gn->suffix->refCount++; Arch_FindLib (gn, s->searchPath); --- 2260,2266 ---- ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); if (gn->suffix) gn->suffix->refCount--; ! if (ln != NULL) { gn->suffix = s = (Suff *) Lst_Datum (ln); gn->suffix->refCount++; Arch_FindLib (gn, s->searchPath); *************** *** 2304,2310 **** LstNode ln; ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP); ! if (ln != NILLNODE) { s = (Suff *)Lst_Datum(ln); if (suffNull != (Suff *)NULL) { suffNull->flags &= ~SUFF_NULL; --- 2304,2310 ---- LstNode ln; ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP); ! if (ln != NULL) { s = (Suff *)Lst_Datum(ln); if (suffNull != (Suff *)NULL) { suffNull->flags &= ~SUFF_NULL;