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

Diff for /src/usr.bin/diff/diff.c between version 1.14 and 1.15

version 1.14, 2003/06/26 07:20:12 version 1.15, 2003/06/26 18:19:29
Line 34 
Line 34 
  * POSSIBILITY OF SUCH DAMAGE.   * POSSIBILITY OF SUCH DAMAGE.
  */   */
   
   #include <errno.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <stdarg.h>
 #include <unistd.h>  #include <unistd.h>
   
 #include "diff.h"  #include "diff.h"
Line 88 
Line 90 
 const char *diffh = _PATH_DIFFH;  const char *diffh = _PATH_DIFFH;
 const char *pr = _PATH_PR;  const char *pr = _PATH_PR;
   
 static void noroom(void);  
 __dead void usage(void);  __dead void usage(void);
   
 int  int
Line 178 
Line 179 
         argv += optind;          argv += optind;
   
         if (argc != 2)          if (argc != 2)
                 errx(1, "two filename arguments required");                  errorx("two filename arguments required");
         file1 = argv[0];          file1 = argv[0];
         file2 = argv[1];          file2 = argv[1];
         if (hflag && opt)          if (hflag && opt)
                 errx(1, "-h doesn't support -D, -c, -C, -e, -f, -I, -n, -u or -U");                  errorx("-h doesn't support -D, -c, -C, -e, -f, -I, -n, -u or -U");
         if (!strcmp(file1, "-"))          if (!strcmp(file1, "-"))
                 stb1.st_mode = S_IFREG;                  stb1.st_mode = S_IFREG;
         else if (stat(file1, &stb1) < 0)          else if (stat(file1, &stb1) < 0)
                 err(1, "%s", file1);                  error("%s", file1);
         if (!strcmp(file2, "-"))          if (!strcmp(file2, "-"))
                 stb2.st_mode = S_IFREG;                  stb2.st_mode = S_IFREG;
         else if (stat(file2, &stb2) < 0)          else if (stat(file2, &stb2) < 0)
                 err(1, "%s", file2);                  error("%s", file2);
         if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode))          if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode))
                 diffdir(argv);                  diffdir(argv);
         else          else
Line 215 
Line 216 
 __dead void  __dead void
 done(int sig)  done(int sig)
 {  {
         if (tempfiles[0])          if (tempfiles[0] != NULL)
                 unlink(tempfiles[0]);                  unlink(tempfiles[0]);
         if (tempfiles[1])          if (tempfiles[1] != NULL)
                 unlink(tempfiles[1]);                  unlink(tempfiles[1]);
         if (sig)          if (sig)
                 _exit(status);                  _exit(status);
Line 230 
Line 231 
         void *p;          void *p;
   
         if ((p = malloc(n)) == NULL)          if ((p = malloc(n)) == NULL)
                 noroom();                  error("files too big, try -h");
         return (p);          return (p);
 }  }
   
Line 240 
Line 241 
         void *q;          void *q;
   
         if ((q = realloc(p, n)) == NULL)          if ((q = realloc(p, n)) == NULL)
                 noroom();                  error("files too big, try -h");
         return (q);          return (q);
 }  }
   
 static void  __dead void
 noroom(void)  error(const char *fmt, ...)
 {  {
         warn("files too big, try -h");          va_list ap;
         done(0);          int sverrno = errno;
   
           if (tempfiles[0] != NULL)
                   unlink(tempfiles[0]);
           if (tempfiles[1] != NULL)
                   unlink(tempfiles[1]);
           errno = sverrno;
           va_start(ap, fmt);
           verr(status, fmt, ap);
           va_end(ap);
 }  }
   
 __dead void  __dead void
   errorx(const char *fmt, ...)
   {
           va_list ap;
   
           if (tempfiles[0] != NULL)
                   unlink(tempfiles[0]);
           if (tempfiles[1] != NULL)
                   unlink(tempfiles[1]);
           va_start(ap, fmt);
           verrx(status, fmt, ap);
           va_end(ap);
   }
   
   __dead void
 usage(void)  usage(void)
 {  {
         (void)fprintf(stderr,          (void)fprintf(stderr,
Line 262 
Line 286 
             "       diff [-biwt] [-c | -e | -f | -h | -n | -u ] "              "       diff [-biwt] [-c | -e | -f | -h | -n | -u ] "
             "[-l] [-r] [-s] [-S name]\n            dir1 dir2\n");              "[-l] [-r] [-s] [-S name]\n            dir1 dir2\n");
   
         exit(1);          exit(2);
 }  }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15