[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.131 and 1.132

version 1.131, 2005/12/04 17:39:02 version 1.132, 2005/12/10 20:27:45
Line 181 
Line 181 
         char *cp;          char *cp;
         struct cvs_ignpat *ip;          struct cvs_ignpat *ip;
   
         ip = (struct cvs_ignpat *)malloc(sizeof(*ip));          ip = (struct cvs_ignpat *)xmalloc(sizeof(*ip));
         if (ip == NULL) {  
                 cvs_log(LP_ERR, "failed to allocate space for ignore pattern");  
                 return (-1);  
         }  
   
         strlcpy(ip->ip_pat, pat, sizeof(ip->ip_pat));          strlcpy(ip->ip_pat, pat, sizeof(ip->ip_pat));
   
         /* check if we will need globbing for that pattern */          /* check if we will need globbing for that pattern */
Line 278 
Line 273 
                         return (NULL);                          return (NULL);
                 }                  }
   
                 cfp->cf_repo = strdup(repo);                  cfp->cf_repo = xstrdup(repo);
                 if (cfp->cf_repo == NULL) {  
                         cvs_file_free(cfp);  
                         return (NULL);  
                 }  
   
                 if (((mkdir(path, mode) == -1) && (errno != EEXIST)) ||                  if (((mkdir(path, mode) == -1) && (errno != EEXIST)) ||
                     (cvs_mkadmin(path, cfp->cf_root->cr_str, cfp->cf_repo,                      (cvs_mkadmin(path, cfp->cf_root->cr_str, cfp->cf_repo,
                     NULL, NULL, 0) < 0)) {                      NULL, NULL, 0) < 0)) {
Line 405 
Line 395 
          */           */
         if (cf->cf_repo != NULL) {          if (cf->cf_repo != NULL) {
                 if (cvs_repo_base != NULL)                  if (cvs_repo_base != NULL)
                         free(cvs_repo_base);                          xfree(cvs_repo_base);
                 cvs_repo_base = strdup(cf->cf_repo);                  cvs_repo_base = xstrdup(cf->cf_repo);
                 if (cvs_repo_base == NULL) {  
                         cvs_log(LP_ERRNO, "strdup failed");  
                         cvs_file_free(cf);  
                         return (-1);  
                 }  
         }          }
   
         /*          /*
          * This will go away when we have support for multiple Roots.           * This will go away when we have support for multiple Roots.
          */           */
         if (cvs_rootstr == NULL && cf->cf_root != NULL) {          if (cvs_rootstr == NULL && cf->cf_root != NULL) {
                 cvs_rootstr = strdup(cf->cf_root->cr_str);                  cvs_rootstr = xstrdup(cf->cf_root->cr_str);
                 if (cvs_rootstr == NULL) {  
                         cvs_log(LP_ERRNO, "strdup failed");  
                         cvs_file_free(cf);  
                         return (-1);  
                 }  
         }          }
   
         cvs_error = CVS_EX_OK;          cvs_error = CVS_EX_OK;
Line 789 
Line 769 
         }          }
   
         if ((stat(pbuf, &st) == 0) && S_ISDIR(st.st_mode)) {          if ((stat(pbuf, &st) == 0) && S_ISDIR(st.st_mode)) {
                 if (cvs_readrepo(fpath, pbuf, sizeof(pbuf)) == 0) {                  if (cvs_readrepo(fpath, pbuf, sizeof(pbuf)) == 0)
                         cf->cf_repo = strdup(pbuf);                          cf->cf_repo = xstrdup(pbuf);
                         if (cf->cf_repo == NULL) {  
                                 cvs_log(LP_ERRNO,  
                                     "failed to dup repository string");  
                                 return (-1);  
                         }  
                 }  
         } else {          } else {
                 /*                  /*
                  * Fill in the repo path ourselfs.                   * Fill in the repo path ourselfs.
Line 807 
Line 781 
                         if (l == -1 || l >= (int)sizeof(pbuf))                          if (l == -1 || l >= (int)sizeof(pbuf))
                                 return (-1);                                  return (-1);
   
                         cf->cf_repo = strdup(pbuf);                          cf->cf_repo = xstrdup(pbuf);
                         if (cf->cf_repo == NULL) {  
                                 cvs_log(LP_ERRNO, "failed to dup repo string");  
                                 return (-1);  
                         }  
                 } else                  } else
                         cf->cf_repo = NULL;                          cf->cf_repo = NULL;
         }          }
Line 855 
Line 825 
                     (cf->cf_dir != NULL) ? cf->cf_dir : "");                      (cf->cf_dir != NULL) ? cf->cf_dir : "");
                 if (ret == -1 || ret >= (int)sizeof(fpath))                  if (ret == -1 || ret >= (int)sizeof(fpath))
                         return (-1);                          return (-1);
                 free(cf->cf_dir);                  xfree(cf->cf_dir);
                 if ((cf->cf_dir = strdup(fpath)) == NULL)                  cf->cf_dir = xstrdup(fpath);
                         return (-1);  
         }          }
   
         nfiles = ndirs = 0;          nfiles = ndirs = 0;
Line 1052 
Line 1021 
         CVSFILE *child;          CVSFILE *child;
   
         if (cf->cf_name != NULL)          if (cf->cf_name != NULL)
                 free(cf->cf_name);                  xfree(cf->cf_name);
   
         if (cf->cf_dir != NULL)          if (cf->cf_dir != NULL)
                 free(cf->cf_dir);                  xfree(cf->cf_dir);
   
         if (cf->cf_type == DT_DIR) {          if (cf->cf_type == DT_DIR) {
                 if (cf->cf_root != NULL)                  if (cf->cf_root != NULL)
                         cvsroot_remove(cf->cf_root);                          cvsroot_remove(cf->cf_root);
                 if (cf->cf_repo != NULL)                  if (cf->cf_repo != NULL)
                         free(cf->cf_repo);                          xfree(cf->cf_repo);
                 while (!SIMPLEQ_EMPTY(&(cf->cf_files))) {                  while (!SIMPLEQ_EMPTY(&(cf->cf_files))) {
                         child = SIMPLEQ_FIRST(&(cf->cf_files));                          child = SIMPLEQ_FIRST(&(cf->cf_files));
                         SIMPLEQ_REMOVE_HEAD(&(cf->cf_files), cf_list);                          SIMPLEQ_REMOVE_HEAD(&(cf->cf_files), cf_list);
Line 1069 
Line 1038 
                 }                  }
         } else {          } else {
                 if (cf->cf_tag != NULL)                  if (cf->cf_tag != NULL)
                         free(cf->cf_tag);                          xfree(cf->cf_tag);
                 if (cf->cf_opts != NULL)                  if (cf->cf_opts != NULL)
                         free(cf->cf_opts);                          xfree(cf->cf_opts);
         }          }
   
         free(cf);          xfree(cf);
 }  }
   
   
Line 1106 
Line 1075 
                         /* rebuild the list and abort sorting */                          /* rebuild the list and abort sorting */
                         while (--i >= 0)                          while (--i >= 0)
                                 SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);                                  SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);
                         free(cfvec);                          xfree(cfvec);
                         return (-1);                          return (-1);
                 }                  }
                 cfvec[i++] = cf;                  cfvec[i++] = cf;
Line 1127 
Line 1096 
         for (i = (int)nb - 1; i >= 0; i--)          for (i = (int)nb - 1; i >= 0; i--)
                 SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);                  SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);
   
         free(cfvec);          xfree(cfvec);
         return (0);          return (0);
 }  }
   
Line 1153 
Line 1122 
         CVSFILE *cfp;          CVSFILE *cfp;
         char *p;          char *p;
   
         cfp = (CVSFILE *)malloc(sizeof(*cfp));          cfp = (CVSFILE *)xmalloc(sizeof(*cfp));
         if (cfp == NULL) {  
                 cvs_log(LP_ERRNO, "failed to allocate CVS file data");  
                 return (NULL);  
         }  
         memset(cfp, 0, sizeof(*cfp));          memset(cfp, 0, sizeof(*cfp));
   
         cfp->cf_type = type;          cfp->cf_type = type;
Line 1167 
Line 1132 
                 SIMPLEQ_INIT(&(cfp->cf_files));                  SIMPLEQ_INIT(&(cfp->cf_files));
         }          }
   
         cfp->cf_name = strdup(basename(path));          cfp->cf_name = xstrdup(basename(path));
         if (cfp->cf_name == NULL) {  
                 cvs_log(LP_ERR, "failed to copy file name");  
                 cvs_file_free(cfp);  
                 return (NULL);  
         }  
   
         if ((p = strrchr(path, '/')) != NULL) {          if ((p = strrchr(path, '/')) != NULL) {
                 *p = '\0';                  *p = '\0';
                 if (strcmp(path, ".")) {                  if (strcmp(path, "."))
                         cfp->cf_dir = strdup(path);                          cfp->cf_dir = xstrdup(path);
                         if (cfp->cf_dir == NULL) {                  else
                                 cvs_log(LP_ERR,  
                                     "failed to copy directory");  
                                 cvs_file_free(cfp);  
                                 return (NULL);  
                         }  
                 } else  
                         cfp->cf_dir = NULL;                          cfp->cf_dir = NULL;
                 *p = '/';                  *p = '/';
         } else          } else
Line 1301 
Line 1254 
                 cfp->cf_lrev = ent->ce_rev;                  cfp->cf_lrev = ent->ce_rev;
   
                 if (ent->ce_type == CVS_ENT_FILE) {                  if (ent->ce_type == CVS_ENT_FILE) {
                         if (ent->ce_tag[0] != '\0') {                          if (ent->ce_tag[0] != '\0')
                                 cfp->cf_tag = strdup(ent->ce_tag);                                  cfp->cf_tag = xstrdup(ent->ce_tag);
                                 if (cfp->cf_tag == NULL) {  
                                         cvs_file_free(cfp);  
                                         return (NULL);  
                                 }  
                         }  
   
                         if (ent->ce_opts[0] != '\0') {                          if (ent->ce_opts[0] != '\0')
                                 cfp->cf_opts = strdup(ent->ce_opts);                                  cfp->cf_opts = xstrdup(ent->ce_opts);
                                 if (cfp->cf_opts == NULL) {  
                                         cvs_file_free(cfp);  
                                         return (NULL);  
                                 }  
                         }  
                 }                  }
         }          }
   
Line 1332 
Line 1275 
                 cfp->cf_mode = 0644;                  cfp->cf_mode = 0644;
                 cfp->cf_cvstat = CVS_FST_LOST;                  cfp->cf_cvstat = CVS_FST_LOST;
   
                 if ((c = strdup(cfp->cf_dir)) == NULL) {                  c = xstrdup(cfp->cf_dir);
                         cvs_file_free(cfp);                  xfree(cfp->cf_dir);
                         return (NULL);  
                 }  
   
                 free(cfp->cf_dir);  
   
                 if (strcmp(c, root->cr_dir)) {                  if (strcmp(c, root->cr_dir)) {
                         c += strlen(root->cr_dir) + 1;                          c += strlen(root->cr_dir) + 1;
                         if ((cfp->cf_dir = strdup(c)) == NULL) {                          cfp->cf_dir = xstrdup(c);
                                 cvs_file_free(cfp);  
                                 return (NULL);  
                         }  
   
                         c -= strlen(root->cr_dir) + 1;                          c -= strlen(root->cr_dir) + 1;
                 } else {                  } else {
                         cfp->cf_dir = NULL;                          cfp->cf_dir = NULL;
                 }                  }
   
                 free(c);                  xfree(c);
         }          }
   
         if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) &&          if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) &&

Legend:
Removed from v.1.131  
changed lines
  Added in v.1.132