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

Diff for /src/usr.bin/diff/diffreg.c between version 1.40 and 1.41

version 1.40, 2003/07/22 00:20:40 version 1.41, 2003/07/22 01:16:01
Line 209 
Line 209 
 static void change(char *, FILE *, char *, FILE *, int, int, int, int);  static void change(char *, FILE *, char *, FILE *, int, int, int, int);
 static void sort(struct line *, int);  static void sort(struct line *, int);
 static int  asciifile(FILE *);  static int  asciifile(FILE *);
 static int  fetch(long *, int, int, FILE *, char *, int);  static int  fetch(long *, int, int, FILE *, int, int);
 static int  newcand(int, int, int);  static int  newcand(int, int, int);
 static int  search(int *, int, int);  static int  search(int *, int, int);
 static int  skipline(FILE *);  static int  skipline(FILE *);
Line 947 
Line 947 
                         /*                          /*
                          * Print the context/unidiff header first time through.                           * Print the context/unidiff header first time through.
                          */                           */
                         printf("%s %s   %s", format == D_CONTEXT ? "***" : "---",                          if (label != NULL)
                            file1, ctime(&stb1.st_mtime));                                  printf("%s %s\n",
                         printf("%s %s   %s", format == D_CONTEXT ? "---" : "+++",                                      format == D_CONTEXT ? "***" : "---", label);
                             file2, ctime(&stb2.st_mtime));                          else
                                   printf("%s %s   %s",
                                       format == D_CONTEXT ? "***" : "---", file1,
                                       ctime(&stb1.st_mtime));
                           printf("%s %s   %s",
                               format == D_CONTEXT ? "---" : "+++", file2,
                               ctime(&stb2.st_mtime));
                         anychange = 1;                          anychange = 1;
                 } else if (a > context_vec_ptr->b + (2 * context) &&                  } else if (a > context_vec_ptr->b + (2 * context) &&
                     c > context_vec_ptr->d + (2 * context)) {                      c > context_vec_ptr->d + (2 * context)) {
Line 999 
Line 1005 
                 break;                  break;
         }          }
         if (format == D_NORMAL || format == D_IFDEF) {          if (format == D_NORMAL || format == D_IFDEF) {
                 fetch(ixold, a, b, f1, "< ", 1);                  fetch(ixold, a, b, f1, '<', 1);
                 if (a <= b && c <= d && format == D_NORMAL)                  if (a <= b && c <= d && format == D_NORMAL)
                         puts("---");                          puts("---");
         }          }
         i = fetch(ixnew, c, d, f2, format == D_NORMAL ? "> " : "", 0);          i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
         if (i != 0 && format == D_EDIT) {          if (i != 0 && format == D_EDIT) {
                 /*                  /*
                  * A non-zero return value for D_EDIT indicates that the                   * A non-zero return value for D_EDIT indicates that the
Line 1027 
Line 1033 
 }  }
   
 static int  static int
 fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile)  fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
 {  {
         int i, j, c, lastc, col, nc;          int i, j, c, lastc, col, nc;
   
Line 1059 
Line 1065 
         for (i = a; i <= b; i++) {          for (i = a; i <= b; i++) {
                 fseek(lb, f[i - 1], SEEK_SET);                  fseek(lb, f[i - 1], SEEK_SET);
                 nc = f[i] - f[i - 1];                  nc = f[i] - f[i - 1];
                 if (format != D_IFDEF)                  if (format != D_IFDEF && ch != '\0') {
                         fputs(s, stdout);                          putchar(ch);
                           if (Tflag && (format == D_NORMAL || format == D_CONTEXT
                               || format == D_UNIFIED))
                                   putchar('\t');
                           else if (format != D_UNIFIED)
                                   putchar(' ');
                   }
                 col = 0;                  col = 0;
                 for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {                  for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
                         if ((c = getc(lb)) == EOF) {                          if ((c = getc(lb)) == EOF) {
Line 1230 
Line 1242 
                                 ch = (a <= b) ? 'd' : 'a';                                  ch = (a <= b) ? 'd' : 'a';
   
                         if (ch == 'a')                          if (ch == 'a')
                                 fetch(ixold, lowa, b, f1, "  ", 0);                                  fetch(ixold, lowa, b, f1, ' ', 0);
                         else {                          else {
                                 fetch(ixold, lowa, a - 1, f1, "  ", 0);                                  fetch(ixold, lowa, a - 1, f1, ' ', 0);
                                 fetch(ixold, a, b, f1,                                  fetch(ixold, a, b, f1,
                                     ch == 'c' ? "! " : "- ", 0);                                      ch == 'c' ? '!' : '-', 0);
                         }                          }
                         lowa = b + 1;                          lowa = b + 1;
                         cvp++;                          cvp++;
                 }                  }
                 fetch(ixold, b + 1, upb, f1, "  ", 0);                  fetch(ixold, b + 1, upb, f1, ' ', 0);
         }          }
         /* output changes to the "new" file */          /* output changes to the "new" file */
         printf("--- ");          printf("--- ");
Line 1266 
Line 1278 
                                 ch = (a <= b) ? 'd' : 'a';                                  ch = (a <= b) ? 'd' : 'a';
   
                         if (ch == 'd')                          if (ch == 'd')
                                 fetch(ixnew, lowc, d, f2, "  ", 0);                                  fetch(ixnew, lowc, d, f2, ' ', 0);
                         else {                          else {
                                 fetch(ixnew, lowc, c - 1, f2, "  ", 0);                                  fetch(ixnew, lowc, c - 1, f2, ' ', 0);
                                 fetch(ixnew, c, d, f2,                                  fetch(ixnew, c, d, f2,
                                     ch == 'c' ? "! " : "+ ", 0);                                      ch == 'c' ? '!' : '+', 0);
                         }                          }
                         lowc = d + 1;                          lowc = d + 1;
                         cvp++;                          cvp++;
                 }                  }
                 fetch(ixnew, d + 1, upd, f2, "  ", 0);                  fetch(ixnew, d + 1, upd, f2, ' ', 0);
         }          }
         context_vec_ptr = context_vec_start - 1;          context_vec_ptr = context_vec_start - 1;
 }  }
Line 1326 
Line 1338 
   
                 switch (ch) {                  switch (ch) {
                 case 'c':                  case 'c':
                         fetch(ixold, lowa, a - 1, f1, " ", 0);                          fetch(ixold, lowa, a - 1, f1, ' ', 0);
                         fetch(ixold, a, b, f1, "-", 0);                          fetch(ixold, a, b, f1, '-', 0);
                         fetch(ixnew, c, d, f2, "+", 0);                          fetch(ixnew, c, d, f2, '+', 0);
                         break;                          break;
                 case 'd':                  case 'd':
                         fetch(ixold, lowa, a - 1, f1, " ", 0);                          fetch(ixold, lowa, a - 1, f1, ' ', 0);
                         fetch(ixold, a, b, f1, "-", 0);                          fetch(ixold, a, b, f1, '-', 0);
                         break;                          break;
                 case 'a':                  case 'a':
                         fetch(ixnew, lowc, c - 1, f2, " ", 0);                          fetch(ixnew, lowc, c - 1, f2, ' ', 0);
                         fetch(ixnew, c, d, f2, "+", 0);                          fetch(ixnew, c, d, f2, '+', 0);
                         break;                          break;
                 }                  }
                 lowa = b + 1;                  lowa = b + 1;
                 lowc = d + 1;                  lowc = d + 1;
         }          }
         fetch(ixnew, d + 1, upd, f2, " ", 0);          fetch(ixnew, d + 1, upd, f2, ' ', 0);
   
         context_vec_ptr = context_vec_start - 1;          context_vec_ptr = context_vec_start - 1;
 }  }

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