summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/diffreg.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-11-21 01:28:01 +0000
committermillert <millert@openbsd.org>2003-11-21 01:28:01 +0000
commit5afc3be2d892708f1ff2a7172769332ada6271b1 (patch)
treebfbcf9941f4b69b8999a94c59488f502a84f614e /usr.bin/diff/diffreg.c
parentbuild statically, to ease disaster recovery in some situations. (diff)
downloadwireguard-openbsd-5afc3be2d892708f1ff2a7172769332ada6271b1.tar.xz
wireguard-openbsd-5afc3be2d892708f1ff2a7172769332ada6271b1.zip
Fix broken assumption that a file must contain differences if files_differ()
fails. Fixes "diff -i" exit value. Problem found by Claudio Jeker.
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r--usr.bin/diff/diffreg.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 467c797021a..bedb5ef0806 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.52 2003/11/10 18:51:35 millert Exp $ */
+/* $OpenBSD: diffreg.c,v 1.53 2003/11/21 01:28:01 millert Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -65,7 +65,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.52 2003/11/10 18:51:35 millert Exp $";
+static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.53 2003/11/21 01:28:01 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -352,11 +352,6 @@ diffreg(char *ofile1, char *ofile2, int flags)
goto closem;
}
- /*
- * Files certainly differ at this point; set status accordingly
- */
- status |= 1;
- rval = D_DIFFER;
if (!asciifile(f1) || !asciifile(f2)) {
rval = D_BINARY;
goto closem;
@@ -447,6 +442,11 @@ diffreg(char *ofile1, char *ofile2, int flags)
waitpid(pid, &wstatus, 0);
}
closem:
+ if (anychange) {
+ status |= 1;
+ if (rval == D_SAME)
+ rval = D_DIFFER;
+ }
if (f1 != NULL)
fclose(f1);
if (f2 != NULL)