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

Diff for /src/usr.bin/cvs/file.c between version 1.255 and 1.256

version 1.255, 2009/03/24 18:33:25 version 1.256, 2009/03/25 21:50:33
Line 81 
Line 81 
 struct ignore_head dir_ign_pats;  struct ignore_head dir_ign_pats;
 struct ignore_head checkout_ign_pats;  struct ignore_head checkout_ign_pats;
   
   RB_GENERATE(cvs_flisthead, cvs_filelist, flist, cvs_filelist_cmp);
   
 void  void
 cvs_file_init(void)  cvs_file_init(void)
 {  {
Line 187 
Line 189 
         int i;          int i;
         struct cvs_flisthead fl;          struct cvs_flisthead fl;
   
         TAILQ_INIT(&fl);          RB_INIT(&fl);
   
         for (i = 0; i < argc; i++)          for (i = 0; i < argc; i++)
                 cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl);                  cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl);
Line 197 
Line 199 
 }  }
   
 struct cvs_filelist *  struct cvs_filelist *
 cvs_file_get(const char *name, int flags, struct cvs_flisthead *fl)  cvs_file_get(char *name, int flags, struct cvs_flisthead *fl)
 {  {
         const char *p;          char *p;
         struct cvs_filelist *l;          struct cvs_filelist *l, find;
   
         for (p = name; p[0] == '.' && p[1] == '/';)          for (p = name; p[0] == '.' && p[1] == '/';)
                 p += 2;                  p += 2;
   
         TAILQ_FOREACH(l, fl, flist)          find.file_path = p;
                 if (!strcmp(l->file_path, p))          l = RB_FIND(cvs_flisthead, fl, &find);
                         return (l);          if (l != NULL)
                   return (l);
   
         l = (struct cvs_filelist *)xmalloc(sizeof(*l));          l = (struct cvs_filelist *)xmalloc(sizeof(*l));
         l->file_path = xstrdup(p);          l->file_path = xstrdup(p);
         l->flags = flags;          l->flags = flags;
   
         TAILQ_INSERT_TAIL(fl, l, flist);          RB_INSERT(cvs_flisthead, fl, l);
         return (l);          return (l);
 }  }
   
Line 259 
Line 262 
         struct cvs_filelist *l, *nxt;          struct cvs_filelist *l, *nxt;
         char *d, *f, repo[MAXPATHLEN], fpath[MAXPATHLEN];          char *d, *f, repo[MAXPATHLEN], fpath[MAXPATHLEN];
   
         for (l = TAILQ_FIRST(fl); l != NULL; l = nxt) {          for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) {
                 if (cvs_quit)                  if (cvs_quit)
                         fatal("received signal %d", sig_received);                          fatal("received signal %d", sig_received);
   
Line 373 
Line 376 
                 cvs_file_free(cf);                  cvs_file_free(cf);
   
 next:  next:
                 nxt = TAILQ_NEXT(l, flist);                  nxt = RB_NEXT(cvs_flisthead, fl, l);
         }          }
 }  }
   
Line 410 
Line 413 
          * locally available directories or try to create them.           * locally available directories or try to create them.
          */           */
         if (!(cmdp->cmd_flags & CVS_USE_WDIR)) {          if (!(cmdp->cmd_flags & CVS_USE_WDIR)) {
                 TAILQ_INIT(&fl);                  RB_INIT(&fl);
                 TAILQ_INIT(&dl);                  RB_INIT(&dl);
                 goto walkrepo;                  goto walkrepo;
         }          }
   
Line 459 
Line 462 
                 bufsize = st.st_blksize;                  bufsize = st.st_blksize;
   
         buf = xmalloc(bufsize);          buf = xmalloc(bufsize);
         TAILQ_INIT(&fl);          RB_INIT(&fl);
         TAILQ_INIT(&dl);          RB_INIT(&dl);
   
         while ((nbytes = getdirentries(cf->fd, buf, bufsize, &base)) > 0) {          while ((nbytes = getdirentries(cf->fd, buf, bufsize, &base)) > 0) {
                 ebuf = buf + nbytes;                  ebuf = buf + nbytes;
Line 615 
Line 618 
 void  void
 cvs_file_freelist(struct cvs_flisthead *fl)  cvs_file_freelist(struct cvs_flisthead *fl)
 {  {
         struct cvs_filelist *f;          struct cvs_filelist *f, *nxt;
   
         while ((f = TAILQ_FIRST(fl)) != NULL) {          for (f = RB_MIN(cvs_flisthead, fl); f != NULL; f = nxt) {
                 TAILQ_REMOVE(fl, f, flist);                  nxt = RB_NEXT(cvs_flisthead, fl, f);
                   RB_REMOVE(cvs_flisthead, fl, f);
                 xfree(f->file_path);                  xfree(f->file_path);
                 xfree(f);                  xfree(f);
         }          }
Line 1103 
Line 1107 
         (void)close(src);          (void)close(src);
   
         return (ret);          return (ret);
   }
   
   int
   cvs_filelist_cmp(struct cvs_filelist *f1, struct cvs_filelist *f2)
   {
           return (strcmp(f1->file_path, f2->file_path));
 }  }

Legend:
Removed from v.1.255  
changed lines
  Added in v.1.256