[BACK]Return to suff.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/suff.c between version 1.17 and 1.18

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

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18