summaryrefslogtreecommitdiff
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-07-21 21:57:23 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-07-21 21:57:23 +0000
commitc24f0d3bdf8846189791c8d93da130dd90b8b57a (patch)
treefde9d5bb9af8bb154572249f336136cbd2574332 /usr.bin/diff
parent7a40925232a1a38dee2be684d8b11624260f6d64 (diff)
POSIX-compliant output when there are two paths w/ the same name but
one is a file and the other is a directory in -r mode (cosmetic).
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/diff.c12
-rw-r--r--usr.bin/diff/diff.h7
-rw-r--r--usr.bin/diff/diffreg.c6
3 files changed, 15 insertions, 10 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index 15c112bab53..7b762eb4932 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.28 2003/07/09 00:39:25 millert Exp $ */
+/* $OpenBSD: diff.c,v 1.29 2003/07/21 21:57:22 millert Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -21,7 +21,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diff.c,v 1.28 2003/07/09 00:39:25 millert Exp $";
+static const char rcsid[] = "$OpenBSD: diff.c,v 1.29 2003/07/21 21:57:22 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -334,8 +334,12 @@ print_status(int val, char *path1, char *path2, char *entry)
path1, entry ? entry : "",
path2, entry ? entry : "");
break;
- case D_MISMATCH:
- printf("File %s/%s is a directory but file %s/%s is not\n",
+ case D_MISMATCH1:
+ printf("File %s/%s is a directory while file %s/%s is a file\n",
+ path1, entry ? entry : "", path2, entry ? entry : "");
+ break;
+ case D_MISMATCH2:
+ printf("File %s/%s is a file while file %s/%s is a directory\n",
path1, entry ? entry : "", path2, entry ? entry : "");
break;
}
diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h
index 9ff20a8e913..e7fc2c919fb 100644
--- a/usr.bin/diff/diff.h
+++ b/usr.bin/diff/diff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.h,v 1.19 2003/07/09 00:39:25 millert Exp $ */
+/* $OpenBSD: diff.h,v 1.20 2003/07/21 21:57:22 millert Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -59,8 +59,9 @@
#define D_BINARY 2 /* Binary files are different */
#define D_COMMON 3 /* Subdirectory common to both dirs */
#define D_ONLY 4 /* Only exists in one directory */
-#define D_MISMATCH 5 /* One path was a dir, the other a file */
-#define D_ERROR 6 /* An error ocurred */
+#define D_MISMATCH1 5 /* path1 was a dir, path2 a file */
+#define D_MISMATCH2 6 /* path1 was a file, path2 a dir */
+#define D_ERROR 7 /* An error ocurred */
struct excludes {
char *pattern;
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index d980115d769..2abd158cb4d 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.36 2003/07/21 15:56:48 millert Exp $ */
+/* $OpenBSD: diffreg.c,v 1.37 2003/07/21 21:57:22 millert Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -65,7 +65,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.36 2003/07/21 15:56:48 millert Exp $";
+static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.37 2003/07/21 21:57:22 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -291,7 +291,7 @@ diffreg(char *ofile1, char *ofile2, int flags)
context_vec_ptr = context_vec_start - 1;
chrtran = (iflag ? cup2low : clow2low);
if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))
- return (D_MISMATCH);
+ return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);
if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0)
goto notsame;