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

Diff for /src/usr.bin/cvs/diff_internals.c between version 1.10 and 1.11

version 1.10, 2007/05/29 08:02:59 version 1.11, 2007/05/30 02:21:20
Line 126 
Line 126 
  *      6n words for files of length n.   *      6n words for files of length n.
  */   */
   
   #include <sys/param.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <ctype.h>  #include <ctype.h>
Line 318 
Line 319 
                 goto closem;                  goto closem;
         }          }
   
         if (stat(file1, &stb1) < 0) {          if (fstat(fileno(f1), &stb1) < 0) {
                 cvs_log(LP_ERR, "%s", file1);                  cvs_log(LP_ERR, "%s", file1);
                 goto closem;                  goto closem;
         }          }
         if (stat(file2, &stb2) < 0) {          if (fstat(fileno(f2), &stb2) < 0) {
                 cvs_log(LP_ERR, "%s", file2);                  cvs_log(LP_ERR, "%s", file2);
                 goto closem;                  goto closem;
         }          }
Line 405 
Line 406 
         if (stb1.st_size != stb2.st_size)          if (stb1.st_size != stb2.st_size)
                 return (1);                  return (1);
         for (;;) {          for (;;) {
                 i = fread(buf1, (size_t)1, sizeof(buf1), f1);                  i = fread(buf1, 1, sizeof(buf1), f1);
                 j = fread(buf2, (size_t)1, sizeof(buf2), f2);                  j = fread(buf2, 1, sizeof(buf2), f2);
                 if (i != j)                  if (i != j)
                         return (1);                          return (1);
                 if (i == 0 && j == 0) {                  if (i == 0 && j == 0) {
Line 428 
Line 429 
   
         rewind(fd);          rewind(fd);
   
         sz = ((size_t)filesize <= SIZE_MAX ? (size_t)filesize : SIZE_MAX) / 25;          sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25;
         if (sz < 100)          if (sz < 100)
                 sz = 100;                  sz = 100;
   
Line 820 
Line 821 
         }          }
 }  }
   
 static __inline void  static void
 range(int a, int b, char *separator)  range(int a, int b, char *separator)
 {  {
         diff_output("%d", a > b ? b : a);          diff_output("%d", a > b ? b : a);
Line 828 
Line 829 
                 diff_output("%s%d", separator, b);                  diff_output("%s%d", separator, b);
 }  }
   
 static __inline void  static void
 uni_range(int a, int b)  uni_range(int a, int b)
 {  {
         if (a < b)          if (a < b)
Line 848 
Line 849 
         line = xmalloc(rlen + 1);          line = xmalloc(rlen + 1);
         if ((nr = pread(fd, line, rlen, off)) < 0) {          if ((nr = pread(fd, line, rlen, off)) < 0) {
                 cvs_log(LP_ERR, "preadline failed");                  cvs_log(LP_ERR, "preadline failed");
                   xfree(line);
                 return (NULL);                  return (NULL);
         }          }
         line[nr] = '\0';          line[nr] = '\0';
Line 859 
Line 861 
 {  {
         int ret;          int ret;
   
         ret = regexec(&ignore_re, line, (size_t)0, NULL, 0);          ret = regexec(&ignore_re, line, 0, NULL, 0);
         xfree(line);          xfree(line);
         return (ret == 0);      /* if it matched, it should be ignored. */          return (ret == 0);      /* if it matched, it should be ignored. */
 }  }
Line 923 
Line 925 
                         /*                          /*
                          * Print the context/unidiff header first time through.                           * Print the context/unidiff header first time through.
                          */                           */
                         t = localtime(&stb1.st_mtime);                          t = localtime(&stb1.st_mtime);
                         (void)strftime(buf, sizeof(buf),                          (void)strftime(buf, sizeof(buf),
                             "%d %b %G %H:%M:%S", t);                              "%d %b %G %H:%M:%S", t);
   
Line 1144 
Line 1146 
                 return (1);                  return (1);
   
         rewind(f);          rewind(f);
         cnt = fread(buf, (size_t)1, sizeof(buf), f);          cnt = fread(buf, 1, sizeof(buf), f);
         for (i = 0; i < cnt; i++)          for (i = 0; i < cnt; i++)
                 if (!isprint(buf[i]) && !isspace(buf[i]))                  if (!isprint(buf[i]) && !isspace(buf[i]))
                         return (0);                          return (0);
Line 1168 
Line 1170 
                 nc = f[pos] - f[pos - 1];                  nc = f[pos] - f[pos - 1];
                 if (nc >= sizeof(buf))                  if (nc >= sizeof(buf))
                         nc = sizeof(buf) - 1;                          nc = sizeof(buf) - 1;
                 nc = fread(buf, (size_t)1, nc, fp);                  nc = fread(buf, 1, nc, fp);
                 if (nc > 0) {                  if (nc > 0) {
                         buf[nc] = '\0';                          buf[nc] = '\0';
                         p = strchr((const char *)buf, '\n');                          p = strchr((const char *)buf, '\n');

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11