From 09523d6f279bf59a03f25320dd3bfcfc3972e297 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 15 Jul 2010 11:10:23 +0000 Subject: [PATCH] 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 ++++----- usr.bin/rcs/diff.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) 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); } diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index 8139c173119..e34cdaae409 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.26 2009/06/07 08:39:13 ray Exp $ */ +/* $OpenBSD: diff.c,v 1.27 2010/07/15 11:10:23 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -413,13 +413,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); } -- 2.20.1