BSD 4_4 release
[unix-history] / usr / src / usr.bin / diff / diff / diffreg.c
index a2435de..2dd37a8 100644 (file)
@@ -1,6 +1,18 @@
-static char sccsid[] = "@(#)diffreg.c 4.19 %G%";
+/*-
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)diffreg.c  8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 #include "diff.h"
 
 #include "diff.h"
+#include "pathnames.h"
 /*
  * diff - compare two files.
  */
 /*
  * diff - compare two files.
  */
@@ -166,7 +178,7 @@ diffreg()
                        perror(file2);
                        done();
                }
                        perror(file2);
                        done();
                }
-       } else if (!strcmp(file1, "-")) {
+       } else if ((stb1.st_mode & S_IFMT) != S_IFREG || !strcmp(file1, "-")) {
                if (!strcmp(file2, "-")) {
                        fprintf(stderr, "diff: can't specify - -\n");
                        done();
                if (!strcmp(file2, "-")) {
                        fprintf(stderr, "diff: can't specify - -\n");
                        done();
@@ -177,7 +189,7 @@ diffreg()
                        perror(file1);
                        done();
                }
                        perror(file1);
                        done();
                }
-       } else if (!strcmp(file2, "-")) {
+       } else if ((stb2.st_mode & S_IFMT) != S_IFREG || !strcmp(file2, "-")) {
                file2 = copytemp();
                if (stat(file2, &stb2) < 0) {
                        fprintf(stderr, "diff: ");
                file2 = copytemp();
                if (stat(file2, &stb2) < 0) {
                        fprintf(stderr, "diff: ");
@@ -262,7 +274,7 @@ same:
        done();
 }
 
        done();
 }
 
-char *tempfile = "/tmp/dXXXXX";
+char tempfile[] = _PATH_TMP;
 
 char *
 copytemp()
 
 char *
 copytemp()
@@ -693,7 +705,6 @@ struct      context_vec     *context_vec_start,
 */
 change(a,b,c,d)
 {
 */
 change(a,b,c,d)
 {
-       int ch;
        int lowa,upb,lowc,upd;
        struct stat stbuf;
 
        int lowa,upb,lowc,upd;
        struct stat stbuf;
 
@@ -716,10 +727,6 @@ change(a,b,c,d)
                        context_vec_ptr = context_vec_start - 1;
                }
        }
                        context_vec_ptr = context_vec_start - 1;
                }
        }
-       if (a <= b && c <= d)
-               ch = 'c';
-       else
-               ch = (a <= b) ? 'd' : 'a';
        if(opt == D_CONTEXT) {
                /*
                 * if this new change is within 'context' lines of
        if(opt == D_CONTEXT) {
                /*
                 * if this new change is within 'context' lines of