From 69d865d664e8c74decbe33f48efb822fb002b28f Mon Sep 17 00:00:00 2001 From: Ray Lai Date: Thu, 15 Jul 2010 11:10:24 +0000 Subject: Sync with diff/diffreg.c r1.75: Return -1 on error as advertised. Handle case when only one stream failed. OK xsa, stsp --- usr.bin/cvs/diff_internals.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'usr.bin/cvs/diff_internals.c') diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c index 4baed471620..0eaf95039ec 100644 --- a/usr.bin/cvs/diff_internals.c +++ b/usr.bin/cvs/diff_internals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff_internals.c,v 1.28 2009/06/07 08:39:13 ray Exp $ */ +/* $OpenBSD: diff_internals.c,v 1.29 2010/07/15 11:10:23 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -430,13 +430,12 @@ files_differ(FILE *f1, FILE *f2) for (;;) { i = fread(buf1, 1, sizeof(buf1), f1); j = fread(buf2, 1, sizeof(buf2), f2); + if ((!i && ferror(f1)) || (!j && ferror(f2))) + return (-1); if (i != j) return (1); - if (i == 0 && j == 0) { - if (ferror(f1) || ferror(f2)) - return (1); + if (i == 0) return (0); - } if (memcmp(buf1, buf2, i) != 0) return (1); } -- cgit v1.2.3