BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / diff / diff / diff.c
index 84c0977..ddab61f 100644 (file)
@@ -1,14 +1,15 @@
-static char sccsid[] = "@(#)diff.c 4.1 %G%";
+static char sccsid[] = "@(#)diff.c 4.7 5/11/89";
 
 #include "diff.h"
 
 #include "diff.h"
+#include "pathnames.h"
+
 /*
  * diff - driver and subroutines
  */
 
 /*
  * diff - driver and subroutines
  */
 
-char   diff[] = DIFF;
-char   diffh[] = DIFFH;
-char   pr[] = PR;
-extern char _sobuf[];
+char   diff[] = _PATH_DIFF;
+char   diffh[] = _PATH_DIFFH;
+char   pr[] = _PATH_PR;
 
 main(argc, argv)
        int argc;
 
 main(argc, argv)
        int argc;
@@ -19,7 +20,6 @@ main(argc, argv)
        ifdef1 = "FILE1"; ifdef2 = "FILE2";
        status = 2;
        diffargv = argv;
        ifdef1 = "FILE1"; ifdef2 = "FILE2";
        status = 2;
        diffargv = argv;
-       setbuf(stdout, _sobuf);
        argc--, argv++;
        while (argc > 2 && argv[0][0] == '-') {
                argp = &argv[0][1];
        argc--, argv++;
        while (argc > 2 && argv[0][0] == '-') {
                argp = &argv[0][1];
@@ -59,9 +59,21 @@ main(argc, argv)
                case 'f':
                        opt = D_REVERSE;
                        continue;
                case 'f':
                        opt = D_REVERSE;
                        continue;
+               case 'n':
+                       opt = D_NREVERSE;
+                       continue;
                case 'b':
                        bflag = 1;
                        continue;
                case 'b':
                        bflag = 1;
                        continue;
+               case 'w':
+                       wflag = 1;
+                       continue;
+               case 'i':
+                       iflag = 1;
+                       continue;
+               case 't':
+                       tflag = 1;
+                       continue;
                case 'c':
                        opt = D_CONTEXT;
                        if (isdigit(*argp)) {
                case 'c':
                        opt = D_CONTEXT;
                        if (isdigit(*argp)) {
@@ -111,7 +123,7 @@ main(argc, argv)
        file2 = argv[1];
        if (hflag && opt) {
                fprintf(stderr,
        file2 = argv[1];
        if (hflag && opt) {
                fprintf(stderr,
-                   "diff: -h doesn't support -e, -f, -c, or -I\n");
+                   "diff: -h doesn't support -e, -f, -n, -c, or -I\n");
                done();
        }
        if (!strcmp(file1, "-"))
                done();
        }
        if (!strcmp(file1, "-"))
@@ -166,7 +178,8 @@ max(a,b)
 
 done()
 {
 
 done()
 {
-       unlink(tempfile);
+       if (tempfile)
+               unlink(tempfile);
        exit(status);
 }
 
        exit(status);
 }
 
@@ -174,23 +187,20 @@ char *
 talloc(n)
 {
        register char *p;
 talloc(n)
 {
        register char *p;
-       p = malloc((unsigned)n);
-       if(p!=NULL)
+
+       if ((p = malloc((unsigned)n)) != NULL)
                return(p);
        noroom();
 }
 
 char *
                return(p);
        noroom();
 }
 
 char *
-ralloc(p,n)    /*compacting reallocation */
+ralloc(p,n)
 char *p;
 {
        register char *q;
        char *realloc();
 char *p;
 {
        register char *q;
        char *realloc();
-       free(p);
-       free(dummy);
-       dummy = malloc(1);
-       q = realloc(p, (unsigned)n);
-       if(q==NULL)
+
+       if ((q = realloc(p, (unsigned)n)) == NULL)
                noroom();
        return(q);
 }
                noroom();
        return(q);
 }