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

Diff for /src/usr.bin/rcs/ci.c between version 1.179 and 1.180

version 1.179, 2006/06/02 19:10:23 version 1.180, 2006/06/03 03:05:10
Line 64 
Line 64 
         RCSFILE *file;          RCSFILE *file;
         RCSNUM *frev, *newrev;          RCSNUM *frev, *newrev;
         const char *description, *symbol;          const char *description, *symbol;
         char fpath[MAXPATHLEN], *rcs_msg, *username, *deltatext, *filename;          char fpath[MAXPATHLEN], *rcs_msg, *username, *filename;
         char *author, *state;          char *author, *state;
           BUF *deltatext;
 };  };
   
 static int       checkin_attach_symbol(struct checkin_params *);  static int       checkin_attach_symbol(struct checkin_params *);
 static int       checkin_checklock(struct checkin_params *);  static int       checkin_checklock(struct checkin_params *);
 static char     *checkin_diff_file(struct checkin_params *);  static BUF      *checkin_diff_file(struct checkin_params *);
 static char     *checkin_getlogmsg(RCSNUM *, RCSNUM *, int);  static char     *checkin_getlogmsg(RCSNUM *, RCSNUM *, int);
 static int       checkin_init(struct checkin_params *);  static int       checkin_init(struct checkin_params *);
 static int       checkin_keywordscan(char *, RCSNUM **, time_t *, char **,  static int       checkin_keywordscan(char *, RCSNUM **, time_t *, char **,
Line 315 
Line 316 
  * Generate the diff between the working file and a revision.   * Generate the diff between the working file and a revision.
  * Returns pointer to a char array on success, NULL on failure.   * Returns pointer to a char array on success, NULL on failure.
  */   */
 static char *  static BUF *
 checkin_diff_file(struct checkin_params *pb)  checkin_diff_file(struct checkin_params *pb)
 {  {
         char *path1, *path2;          char *path1, *path2;
         BUF *b1, *b2, *b3;          BUF *b1, *b2, *b3;
         char rbuf[64], *deltatext;          char rbuf[64];
   
         b1 = b2 = b3 = NULL;          b1 = b2 = b3 = NULL;
         deltatext = NULL;  
         rcsnum_tostr(pb->frev, rbuf, sizeof(rbuf));          rcsnum_tostr(pb->frev, rbuf, sizeof(rbuf));
   
         if ((b1 = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) {          if ((b1 = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) {
Line 357 
Line 357 
         if (rcs_diffreg(path1, path2, b3) == D_ERROR)          if (rcs_diffreg(path1, path2, b3) == D_ERROR)
                 goto out;                  goto out;
   
         rcs_buf_putc(b3, '\0');          return (b3);
         deltatext = rcs_buf_release(b3);  
         b3 = NULL;  
   
 out:  out:
         if (b1 != NULL)          if (b1 != NULL)
                 rcs_buf_free(b1);                  rcs_buf_free(b1);
Line 373 
Line 370 
         if (path2 != NULL)          if (path2 != NULL)
                 xfree(path2);                  xfree(path2);
   
         return (deltatext);          return (NULL);
 }  }
   
 /*  /*
Line 436 
Line 433 
         if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)          if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
                 goto fail;                  goto fail;
   
         rcs_buf_putc(bp, '\0');  
         filec = (char *)rcs_buf_release(bp);  
   
         /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */          /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */
         if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev))          if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev))
                 pb->newrev = rcsnum_inc(pb->newrev);                  pb->newrev = rcsnum_inc(pb->newrev);
Line 496 
Line 490 
          * If -f is not specified and there are no differences, tell           * If -f is not specified and there are no differences, tell
          * the user and revert to latest version.           * the user and revert to latest version.
          */           */
         if (!(pb->flags & FORCE) && (strlen(pb->deltatext) < 1)) {          if (!(pb->flags & FORCE) && (rcs_buf_len(pb->deltatext) < 1)) {
                 checkin_revert(pb);                  checkin_revert(pb);
                 goto out;                  goto out;
         }          }
Line 537 
Line 531 
                 pb->newrev = pb->file->rf_head;                  pb->newrev = pb->file->rf_head;
   
         /* New head revision has to contain entire file; */          /* New head revision has to contain entire file; */
         if (rcs_deltatext_set(pb->file, pb->frev, filec) == -1)          if (rcs_deltatext_set(pb->file, pb->frev, bp) == -1)
                 errx(1, "failed to set new head revision");                  errx(1, "failed to set new head revision");
   
         /* Attach a symbolic name to this revision if specified. */          /* Attach a symbolic name to this revision if specified. */
Line 575 
Line 569 
         }          }
   
 out:  out:
         xfree(pb->deltatext);  
         xfree(filec);  
   
         return (0);          return (0);
   
 fail:  fail:
         if (filec != NULL)  
                 xfree(filec);  
         if (pb->deltatext != NULL)  
                 xfree(pb->deltatext);  
         return (-1);          return (-1);
 }  }
   
Line 598 
Line 585 
 checkin_init(struct checkin_params *pb)  checkin_init(struct checkin_params *pb)
 {  {
         BUF *bp;          BUF *bp;
         char *filec, numb[64];          char numb[64];
         int fetchlog = 0;          int fetchlog = 0;
         struct stat st;          struct stat st;
   
         filec = NULL;  
   
         /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */          /* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */
         if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev)) {          if (pb->newrev != NULL && RCSNUM_ZERO_ENDING(pb->newrev)) {
                 pb->frev = rcsnum_alloc();                  pb->frev = rcsnum_alloc();
Line 616 
Line 601 
         if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)          if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
                 goto fail;                  goto fail;
   
         rcs_buf_putc(bp, '\0');  
         filec = rcs_buf_release(bp);  
   
         /* Get default values from working copy if -k specified */          /* Get default values from working copy if -k specified */
         if (pb->flags & CI_KEYWORDSCAN)          if (pb->flags & CI_KEYWORDSCAN)
                 checkin_keywordscan(filec, &pb->newrev, &pb->date, &pb->state,                  checkin_keywordscan((char *)rcs_buf_get(bp), &pb->newrev,
                     &pb->author);                      &pb->date, &pb->state, &pb->author);
   
         if (pb->flags & CI_SKIPDESC)          if (pb->flags & CI_SKIPDESC)
                 goto skipdesc;                  goto skipdesc;
Line 670 
Line 652 
                 pb->newrev = pb->file->rf_head;                  pb->newrev = pb->file->rf_head;
   
         /* New head revision has to contain entire file; */          /* New head revision has to contain entire file; */
         if (rcs_deltatext_set(pb->file, pb->file->rf_head, filec) == -1) {          if (rcs_deltatext_set(pb->file, pb->file->rf_head, bp) == -1) {
                 warnx("failed to set new head revision");                  warnx("failed to set new head revision");
                 goto fail;                  goto fail;
         }          }
Line 692 
Line 674 
         pb->file->rf_mode = st.st_mode &          pb->file->rf_mode = st.st_mode &
             (S_IXUSR|S_IXGRP|S_IXOTH|S_IRUSR|S_IRGRP|S_IROTH);              (S_IXUSR|S_IXGRP|S_IXOTH|S_IRUSR|S_IRGRP|S_IROTH);
   
         xfree(filec);  
         (void)close(workfile_fd);          (void)close(workfile_fd);
         (void)unlink(pb->filename);          (void)unlink(pb->filename);
   
Line 713 
Line 694 
   
         return (0);          return (0);
 fail:  fail:
         if (filec != NULL)  
                 xfree(filec);  
         return (-1);          return (-1);
 }  }
   

Legend:
Removed from v.1.179  
changed lines
  Added in v.1.180