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

Diff for /src/usr.bin/cvs/annotate.c between version 1.39 and 1.40

version 1.39, 2007/09/22 16:01:22 version 1.40, 2007/10/09 12:22:27
Line 1 
Line 1 
 /*      $OpenBSD$       */  /*      $OpenBSD$       */
 /*  /*
  * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>  
  * Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org>   * Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org>
    * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 30 
Line 30 
 void    cvs_annotate_local(struct cvs_file *);  void    cvs_annotate_local(struct cvs_file *);
   
 static int       force_head = 0;  static int       force_head = 0;
 static char     *rev = NULL;  
   
 struct cvs_cmd cvs_cmd_annotate = {  struct cvs_cmd cvs_cmd_annotate = {
         CVS_OP_ANNOTATE, 0, "annotate",          CVS_OP_ANNOTATE, 0, "annotate",
Line 64 
Line 63 
                 case 'R':                  case 'R':
                         break;                          break;
                 case 'r':                  case 'r':
                         rev = optarg;                          cvs_specified_tag = optarg;
                         break;                          break;
                 default:                  default:
                         fatal("%s", cvs_cmd_annotate.cmd_synopsis);                          fatal("%s", cvs_cmd_annotate.cmd_synopsis);
Line 87 
Line 86 
                 if (!(flags & CR_RECURSE_DIRS))                  if (!(flags & CR_RECURSE_DIRS))
                         cvs_client_send_request("Argument -l");                          cvs_client_send_request("Argument -l");
   
                 if (rev != NULL)                  if (cvs_specified_tag != NULL)
                         cvs_client_send_request("Argument -r%s", rev);                          cvs_client_send_request("Argument -r%s",
                               cvs_specified_tag);
         } else {          } else {
                 cr.fileproc = cvs_annotate_local;                  cr.fileproc = cvs_annotate_local;
         }          }
Line 115 
Line 115 
 {  {
         int i;          int i;
         char date[10], rnum[13], *p;          char date[10], rnum[13], *p;
         RCSNUM *crev;          RCSNUM *rev;
           struct cvs_line *line;
         struct cvs_line **alines;          struct cvs_line **alines;
   
         cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path);          cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path);
Line 126 
Line 127 
             cf->file_type != CVS_FILE)              cf->file_type != CVS_FILE)
                 return;                  return;
   
         if (rev == NULL)          if (cvs_specified_tag == NULL)
                 rcs_rev_getlines(cf->file_rcs, cf->file_rcsrev, &alines);                  rcs_rev_getlines(cf->file_rcs, cf->file_rcsrev, &alines);
         else {          else {
                 crev = rcsnum_parse(rev);                  rev = rcsnum_parse(cvs_specified_tag);
   
                 if (rcsnum_cmp(crev, cf->file_rcsrev, 0) < 0) {                  if (rcsnum_cmp(rev, cf->file_rcsrev, 0) < 0) {
                         if (!force_head) {                          if (!force_head) {
                                 /* Stick at weird GNU cvs, ignore error. */                                  /* Stick at weird GNU cvs, ignore error. */
                                 rcsnum_free(crev);                                  rcsnum_free(rev);
                                 return;                                  return;
                         }                          }
                         rcsnum_cpy(cf->file_rcsrev, crev, 0);                          rcsnum_cpy(cf->file_rcsrev, rev, 0);
                 }                  }
                 rcs_rev_getlines(cf->file_rcs, crev, &alines);                  rcs_rev_getlines(cf->file_rcs, rev, &alines);
                 rcsnum_free(crev);                  rcsnum_free(rev);
         }          }
   
         /* Stick at weird GNU cvs, ignore error. */          /* Stick at weird GNU cvs, ignore error. */
Line 151 
Line 152 
         cvs_log(LP_RCS, "***************");          cvs_log(LP_RCS, "***************");
   
         for (i = 0; alines[i] != NULL; i++) {          for (i = 0; alines[i] != NULL; i++) {
                 rcsnum_tostr(alines[i]->l_delta->rd_num, rnum, sizeof(rnum));                  line = alines[i];
   
                   rcsnum_tostr(line->l_delta->rd_num, rnum, sizeof(rnum));
                 strftime(date, sizeof(date), "%d-%b-%y",                  strftime(date, sizeof(date), "%d-%b-%y",
                     &(alines[i]->l_delta->rd_date));                      &(line->l_delta->rd_date));
                 if (alines[i]->l_len &&                  if (line->l_len && line->l_line[line->l_len - 1] == '\n')
                     alines[i]->l_line[alines[i]->l_len - 1] == '\n')                          line->l_line[line->l_len - 1] = '\0';
                         alines[i]->l_line[alines[i]->l_len - 1] = '\0';  
                 else {                  else {
                         p = xmalloc(alines[i]->l_len + 1);                          p = xmalloc(line->l_len + 1);
                         memcpy(p, alines[i]->l_line, alines[i]->l_len);                          memcpy(p, line->l_line, line->l_len);
                         p[alines[i]->l_len] = '\0';                          p[line->l_len] = '\0';
   
                         if (alines[i]->l_needsfree)                          if (line->l_needsfree)
                                 xfree(alines[i]->l_line);                                  xfree(line->l_line);
                         alines[i]->l_line = p;                          line->l_line = p;
                         alines[i]->l_len++;                          line->l_len++;
                         alines[i]->l_needsfree = 1;                          line->l_needsfree = 1;
                 }                  }
                 cvs_printf("%-12.12s (%-8.8s %s): %s\n", rnum,                  cvs_printf("%-12.12s (%-8.8s %s): %s\n", rnum,
                     alines[i]->l_delta->rd_author, date, alines[i]->l_line);                      line->l_delta->rd_author, date, line->l_line);
   
                 if (alines[i]->l_needsfree)                  if (line->l_needsfree)
                         xfree(alines[i]->l_line);                          xfree(line->l_line);
                 xfree(alines[i]);                  xfree(line);
         }          }
   
         xfree(alines);          xfree(alines);

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.40