[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.38 and 1.39

version 1.38, 2003/07/21 21:59:58 version 1.39, 2003/07/22 00:15:55
Line 196 
Line 196 
 static struct context_vec *context_vec_ptr;  static struct context_vec *context_vec_ptr;
   
 static FILE *opentemp(const char *);  static FILE *opentemp(const char *);
 static void fetch(long *, int, int, FILE *, char *, int);  
 static void output(char *, FILE *, char *, FILE *);  static void output(char *, FILE *, char *, FILE *);
 static void check(char *, FILE *, char *, FILE *);  static void check(char *, FILE *, char *, FILE *);
 static void range(int, int, char *);  static void range(int, int, char *);
Line 211 
Line 210 
 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  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 935 
Line 935 
 change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d)  change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d)
 {  {
         static size_t max_context = 64;          static size_t max_context = 64;
           int i;
   
   restart:
         if (format != D_IFDEF && a > b && c > d)          if (format != D_IFDEF && a > b && c > d)
                 return;                  return;
         if (format == D_CONTEXT || format == D_UNIFIED) {          if (format == D_CONTEXT || format == D_UNIFIED) {
Line 1010 
Line 1012 
                 if (a <= b && c <= d && format == D_NORMAL)                  if (a <= b && c <= d && format == D_NORMAL)
                         puts("---");                          puts("---");
         }          }
         fetch(ixnew, c, d, f2, format == D_NORMAL ? "> " : "", 0);          i = fetch(ixnew, c, d, f2, format == D_NORMAL ? "> " : "", 0);
           if (i != 0 && format == D_EDIT) {
                   /*
                    * A non-zero return value for D_EDIT indicates that the
                    * last line printed was a bare dot (".") that has been
                    * escaped as ".." to prevent ed(1) from misinterpreting
                    * it.  We have to add a substitute command to change this
                    * back and restart where we left off.
                    */
                   puts(".");
                   printf("%ds/^\\.\\././\n", a);
                   a += i;
                   c += i;
                   goto restart;
           }
         if ((format == D_EDIT || format == D_REVERSE) && c <= d)          if ((format == D_EDIT || format == D_REVERSE) && c <= d)
                 puts(".");                  puts(".");
         if (inifdef) {          if (inifdef) {
Line 1019 
Line 1035 
         }          }
 }  }
   
 static void  static int
 fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile)  fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile)
 {  {
         int i, j, c, col, nc;          int i, j, c, lastc, col, nc;
   
         /*          /*
          * When doing #ifdef's, copy down to current line           * When doing #ifdef's, copy down to current line
Line 1036 
Line 1052 
                         putchar(getc(lb));                          putchar(getc(lb));
         }          }
         if (a > b)          if (a > b)
                 return;                  return (0);
         if (format == D_IFDEF) {          if (format == D_IFDEF) {
                 if (inifdef) {                  if (inifdef) {
                         printf("#else /* %s%s */\n",                          printf("#else /* %s%s */\n",
Line 1055 
Line 1071 
                 if (format != D_IFDEF)                  if (format != D_IFDEF)
                         fputs(s, stdout);                          fputs(s, stdout);
                 col = 0;                  col = 0;
                 for (j = 0; j < nc; j++) {                  for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
                         if ((c = getc(lb)) == EOF) {                          if ((c = getc(lb)) == EOF) {
                                 puts("\n\\ No newline at end of file");                                  puts("\n\\ No newline at end of file");
                                 return;                                  return (0);;
                         }                          }
                         if (c == '\t' && tflag) {                          if (c == '\t' && tflag) {
                                 do {                                  do {
                                         putchar(' ');                                          putchar(' ');
                                 } while (++col & 7);                                  } while (++col & 7);
                         } else {                          } else {
                                   if (format == D_EDIT && j == 1 && c == '\n'
                                       && lastc == '.') {
                                           /*
                                            * Don't print a bare "." line
                                            * since that will confuse ed(1).
                                            * Print ".." instead and return,
                                            * giving the caller an offset
                                            * from which to restart.
                                            */
                                           puts(".");
                                           return (i - a + 1);
                                   }
                                 putchar(c);                                  putchar(c);
                                 col++;                                  col++;
                         }                          }
                 }                  }
         }          }
           return (0);
 }  }
   
 #define HASHMASK (16 - 1)       /* for masking out 16 bytes */  #define HASHMASK (16 - 1)       /* for masking out 16 bytes */

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