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

Diff for /src/usr.bin/cvs/diff.c between version 1.16 and 1.17

version 1.16, 2004/12/28 22:07:31 version 1.17, 2005/01/13 23:39:42
Line 239 
Line 239 
 static int  stone(int *, int, int *, int *);  static int  stone(int *, int, int *, int *);
 static int  readhash(FILE *);  static int  readhash(FILE *);
 static int  files_differ(FILE *, FILE *);  static int  files_differ(FILE *, FILE *);
   static char *match_function(const long *, int, FILE *);
 static char *preadline(int, size_t, off_t);  static char *preadline(int, size_t, off_t);
   
   
 extern int cvs_client;  extern int cvs_client;
   
 static int aflag, bflag, dflag, iflag, Nflag, tflag, Tflag, wflag;  static int aflag, bflag, dflag, iflag, Nflag, pflag, tflag, Tflag, wflag;
 static int context, status;  static int context, status;
 static int format = D_NORMAL;  static int format = D_NORMAL;
 static struct stat stb1, stb2;  static struct stat stb1, stb2;
Line 273 
Line 274 
 static struct context_vec *context_vec_ptr;  static struct context_vec *context_vec_ptr;
   
 #define FUNCTION_CONTEXT_SIZE   41  #define FUNCTION_CONTEXT_SIZE   41
 static int lastline;  static char lastbuf[FUNCTION_CONTEXT_SIZE];
 static int lastmatchline;  static int  lastline;
   static int  lastmatchline;
   
   
 /*  /*
Line 357 
Line 359 
         memset(&darg, 0, sizeof(darg));          memset(&darg, 0, sizeof(darg));
         strlcpy(diffargs, argv[0], sizeof(diffargs));          strlcpy(diffargs, argv[0], sizeof(diffargs));
   
         while ((ch = getopt(argc, argv, "cD:liN:r:u")) != -1) {          while ((ch = getopt(argc, argv, "cD:liNpr:u")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case 'c':                  case 'c':
                         strlcat(diffargs, " -c", sizeof(diffargs));                          strlcat(diffargs, " -c", sizeof(diffargs));
Line 387 
Line 389 
                         strlcat(diffargs, " -N", sizeof(diffargs));                          strlcat(diffargs, " -N", sizeof(diffargs));
                         Nflag = 1;                          Nflag = 1;
                         break;                          break;
                   case 'p':
                           strlcat(diffargs, " -p", sizeof(diffargs));
                           pflag = 1;
                           break;
                 case 'r':                  case 'r':
                         if ((darg.rev1 == NULL) && (darg.date1 == NULL))                          if ((darg.rev1 == NULL) && (darg.date1 == NULL))
                                 darg.rev1 = optarg;                                  darg.rev1 = optarg;
Line 438 
Line 444 
 cvs_diff_sendflags(struct cvsroot *root, struct diff_arg *dap)  cvs_diff_sendflags(struct cvsroot *root, struct diff_arg *dap)
 {  {
         /* send the flags */          /* send the flags */
           if (Nflag && (cvs_sendarg(root, "-N", 0) < 0))
                   return (-1);
           if (pflag && (cvs_sendarg(root, "-p", 0) < 0))
                   return (-1);
   
         if (format == D_CONTEXT)          if (format == D_CONTEXT)
                 cvs_sendarg(root, "-c", 0);                  cvs_sendarg(root, "-c", 0);
         else if (format == D_UNIFIED)          else if (format == D_UNIFIED)
Line 1424 
Line 1435 
         return (1);          return (1);
 }  }
   
   static char*
   match_function(const long *f, int pos, FILE *fp)
   {
           unsigned char buf[FUNCTION_CONTEXT_SIZE];
           size_t nc;
           int last = lastline;
           char *p;
   
           lastline = pos;
           while (pos > last) {
                   fseek(fp, f[pos - 1], SEEK_SET);
                   nc = f[pos] - f[pos - 1];
                   if (nc >= sizeof(buf))
                           nc = sizeof(buf) - 1;
                   nc = fread(buf, 1, nc, fp);
                   if (nc > 0) {
                           buf[nc] = '\0';
                           p = strchr(buf, '\n');
                           if (p != NULL)
                                   *p = '\0';
                           if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
                                   strlcpy(lastbuf, buf, sizeof lastbuf);
                                   lastmatchline = pos;
                                   return lastbuf;
                           }
                   }
                   pos--;
           }
           return (lastmatchline > 0) ? lastbuf : NULL;
   }
   
   
 /* dump accumulated "context" diff changes */  /* dump accumulated "context" diff changes */
 static void  static void
 dump_context_vec(FILE *f1, FILE *f2)  dump_context_vec(FILE *f1, FILE *f2)
Line 1432 
Line 1474 
         struct context_vec *cvp = context_vec_start;          struct context_vec *cvp = context_vec_start;
         int lowa, upb, lowc, upd, do_output;          int lowa, upb, lowc, upd, do_output;
         int a, b, c, d;          int a, b, c, d;
         char ch;          char ch, *f;
   
         if (context_vec_start > context_vec_ptr)          if (context_vec_start > context_vec_ptr)
                 return;                  return;
Line 1444 
Line 1486 
         upd = MIN(len[1], context_vec_ptr->d + context);          upd = MIN(len[1], context_vec_ptr->d + context);
   
         printf("***************");          printf("***************");
           if (pflag) {
                   f = match_function(ixold, lowa - 1, f1);
                   if (f != NULL) {
                           putchar(' ');
                           fputs(f, stdout);
                   }
           }
         printf("\n*** ");          printf("\n*** ");
         range(lowa, upb, ",");          range(lowa, upb, ",");
         printf(" ****\n");          printf(" ****\n");
Line 1530 
Line 1579 
         struct context_vec *cvp = context_vec_start;          struct context_vec *cvp = context_vec_start;
         int lowa, upb, lowc, upd;          int lowa, upb, lowc, upd;
         int a, b, c, d;          int a, b, c, d;
         char ch;          char ch, *f;
   
         if (context_vec_start > context_vec_ptr)          if (context_vec_start > context_vec_ptr)
                 return;                  return;
Line 1546 
Line 1595 
         fputs(" +", stdout);          fputs(" +", stdout);
         uni_range(lowc, upd);          uni_range(lowc, upd);
         fputs(" @@", stdout);          fputs(" @@", stdout);
           if (pflag) {
                   f = match_function(ixold, lowa - 1, f1);
                   if (f != NULL) {
                           putchar(' ');
                           fputs(f, stdout);
                   }
           }
         putchar('\n');          putchar('\n');
   
         /*          /*

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17