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

Diff for /src/usr.bin/rcs/rcs.c between version 1.58 and 1.59

version 1.58, 2010/07/23 08:31:19 version 1.59, 2010/07/23 21:46:05
Line 1145 
Line 1145 
  *   *
  * Get the whole contents of revision <rev> from the RCSFILE <rfp>.  The   * Get the whole contents of revision <rev> from the RCSFILE <rfp>.  The
  * returned buffer is dynamically allocated and should be released using   * returned buffer is dynamically allocated and should be released using
  * rcs_buf_free() once the caller is done using it.   * buf_free() once the caller is done using it.
  */   */
 BUF*  BUF*
 rcs_getrev(RCSFILE *rfp, RCSNUM *frev)  rcs_getrev(RCSFILE *rfp, RCSNUM *frev)
Line 1190 
Line 1190 
   
         len = rdp->rd_tlen;          len = rdp->rd_tlen;
         if (len == 0) {          if (len == 0) {
                 rbuf = rcs_buf_alloc(1, 0);                  rbuf = buf_alloc(1, 0);
                 rcs_buf_empty(rbuf);                  buf_empty(rbuf);
                 return (rbuf);                  return (rbuf);
         }          }
   
         rbuf = rcs_buf_alloc(len, BUF_AUTOEXT);          rbuf = buf_alloc(len, BUF_AUTOEXT);
         rcs_buf_append(rbuf, rdp->rd_text, len);          buf_append(rbuf, rdp->rd_text, len);
   
         isbranch = 0;          isbranch = 0;
         brev = NULL;          brev = NULL;
Line 1261 
Line 1261 
   
                 rdp = rcs_findrev(rfp, crev);                  rdp = rcs_findrev(rfp, crev);
                 if (rdp == NULL) {                  if (rdp == NULL) {
                         rcs_buf_free(rbuf);                          buf_free(rbuf);
                         return (NULL);                          return (NULL);
                 }                  }
   
                 plen = rdp->rd_tlen;                  plen = rdp->rd_tlen;
                 dlen = rcs_buf_len(rbuf);                  dlen = buf_len(rbuf);
                 patch = rdp->rd_text;                  patch = rdp->rd_text;
                 data = rcs_buf_release(rbuf);                  data = buf_release(rbuf);
                 /* check if we have parsed this rev's deltatext */                  /* check if we have parsed this rev's deltatext */
                 if (rdp->rd_tlen == 0)                  if (rdp->rd_tlen == 0)
                         rcs_parse_deltatexts(rfp, rdp->rd_num);                          rcs_parse_deltatexts(rfp, rdp->rd_num);
Line 1455 
Line 1455 
                 if ((nextbuf = rcs_getrev(rf, nextrdp->rd_num)) == NULL)                  if ((nextbuf = rcs_getrev(rf, nextrdp->rd_num)) == NULL)
                         errx(1, "error getting revision");                          errx(1, "error getting revision");
   
                 newdiff = rcs_buf_alloc(64, BUF_AUTOEXT);                  newdiff = buf_alloc(64, BUF_AUTOEXT);
   
                 /* calculate new diff */                  /* calculate new diff */
                 (void)xasprintf(&path_tmp1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);                  (void)xasprintf(&path_tmp1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
                 rcs_buf_write_stmp(nextbuf, path_tmp1);                  buf_write_stmp(nextbuf, path_tmp1);
                 rcs_buf_free(nextbuf);                  buf_free(nextbuf);
   
                 (void)xasprintf(&path_tmp2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);                  (void)xasprintf(&path_tmp2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
                 rcs_buf_write_stmp(prevbuf, path_tmp2);                  buf_write_stmp(prevbuf, path_tmp2);
                 rcs_buf_free(prevbuf);                  buf_free(prevbuf);
   
                 diff_format = D_RCSDIFF;                  diff_format = D_RCSDIFF;
                 if (diffreg(path_tmp1, path_tmp2, newdiff, D_FORCEASCII) == D_ERROR)                  if (diffreg(path_tmp1, path_tmp2, newdiff, D_FORCEASCII) == D_ERROR)
Line 2662 
Line 2662 
         if (timezone_flag != NULL)          if (timezone_flag != NULL)
                 rcs_set_tz(timezone_flag, rdp, &tb);                  rcs_set_tz(timezone_flag, rdp, &tb);
   
         len = rcs_buf_len(bp);          len = buf_len(bp);
   
         c = rcs_buf_get(bp);          c = buf_get(bp);
         found = 0;          found = 0;
         /* Final character in buffer. */          /* Final character in buffer. */
         fin = c + len - 1;          fin = c + len - 1;
Line 2832 
Line 2832 
                                         errx(1, "rcs_expand_keywords: string truncated");                                          errx(1, "rcs_expand_keywords: string truncated");
   
                         /* Concatenate everything together. */                          /* Concatenate everything together. */
                         tmpbuf = rcs_buf_alloc(len + strlen(expbuf), BUF_AUTOEXT);                          tmpbuf = buf_alloc(len + strlen(expbuf), BUF_AUTOEXT);
                         /* Append everything before keyword. */                          /* Append everything before keyword. */
                         rcs_buf_append(tmpbuf, rcs_buf_get(newbuf),                          buf_append(tmpbuf, buf_get(newbuf),
                             start - (unsigned char *)rcs_buf_get(newbuf));                              start - (unsigned char *)buf_get(newbuf));
                         /* Append keyword. */                          /* Append keyword. */
                         rcs_buf_append(tmpbuf, expbuf, strlen(expbuf));                          buf_append(tmpbuf, expbuf, strlen(expbuf));
                         /* Point c to end of keyword. */                          /* Point c to end of keyword. */
                         c = rcs_buf_get(tmpbuf) + rcs_buf_len(tmpbuf) - 1;                          c = buf_get(tmpbuf) + buf_len(tmpbuf) - 1;
                         /* Append everything after keyword. */                          /* Append everything after keyword. */
                         rcs_buf_append(tmpbuf, end,                          buf_append(tmpbuf, end,
                             ((unsigned char *)rcs_buf_get(newbuf) + rcs_buf_len(newbuf)) - end);                              ((unsigned char *)buf_get(newbuf) + buf_len(newbuf)) - end);
                         /* Point fin to end of data. */                          /* Point fin to end of data. */
                         fin = rcs_buf_get(tmpbuf) + rcs_buf_len(tmpbuf) - 1;                          fin = buf_get(tmpbuf) + buf_len(tmpbuf) - 1;
                         /* Recalculate new length. */                          /* Recalculate new length. */
                         len = rcs_buf_len(tmpbuf);                          len = buf_len(tmpbuf);
   
                         /* tmpbuf is now ready, free old newbuf if allocated here. */                          /* tmpbuf is now ready, free old newbuf if allocated here. */
                         if (newbuf != bp)                          if (newbuf != bp)
                                 rcs_buf_free(newbuf);                                  buf_free(newbuf);
                         newbuf = tmpbuf;                          newbuf = tmpbuf;
                 }                  }
         }          }
Line 2880 
Line 2880 
         if (rdp->rd_text != NULL)          if (rdp->rd_text != NULL)
                 xfree(rdp->rd_text);                  xfree(rdp->rd_text);
   
         len = rcs_buf_len(bp);          len = buf_len(bp);
         dtext = rcs_buf_release(bp);          dtext = buf_release(bp);
         bp = NULL;          bp = NULL;
   
         if (len != 0) {          if (len != 0) {
                 rdp->rd_text = xmalloc(len);                  rdp->rd_text = xmalloc(len);
                 rdp->rd_tlen = len;                  rdp->rd_tlen = len;

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59