diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-11-21 01:28:02 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-11-21 01:28:02 +0000 |
commit | 8219e373e0ccc3ae576df9b1bdb2555cd1680d5a (patch) | |
tree | fc0a55cc5fe7e602aac1f95daf595a2ccacb3754 | |
parent | 2a4dc45717947cc9d20ca65339ce43bae195311f (diff) |
Fix broken assumption that a file must contain differences if files_differ()
fails. Fixes "diff -i" exit value. Problem found by Claudio Jeker.
-rw-r--r-- | usr.bin/diff/diffreg.c | 14 |
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) |