From 2e6633a8ffcb18d5d77f5bbe43cfaabaa81cd9c0 Mon Sep 17 00:00:00 2001 From: tobias Date: Wed, 27 Feb 2008 18:10:05 +0000 Subject: Properly check if temporary files have been successfully opened. If not, print error message on stderr (instead of stdout). ok millert, ray, tedu --- usr.bin/diff3/diff3prog.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'usr.bin/diff3/diff3prog.c') diff --git a/usr.bin/diff3/diff3prog.c b/usr.bin/diff3/diff3prog.c index c7456c52c74..73054824a5a 100644 --- a/usr.bin/diff3/diff3prog.c +++ b/usr.bin/diff3/diff3prog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $ */ +/* $OpenBSD: diff3prog.c,v 1.10 2008/02/27 18:10:05 tobias Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -71,7 +71,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $"; +static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.10 2008/02/27 18:10:05 tobias Exp $"; #endif /* not lint */ #include @@ -193,10 +193,8 @@ main(int argc, char **argv) m = readin(argv[0], &d13); n = readin(argv[1], &d23); for (i = 0; i <= 2; i++) { - if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) { - printf("diff3: can't open %s\n", argv[i + 2]); - exit(EXIT_FAILURE); - } + if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) + err(EXIT_FAILURE, "can't open %s", argv[i + 2]); } merge(m, n); exit(EXIT_SUCCESS); @@ -215,6 +213,8 @@ readin(char *name, struct diff **dd) char kind, *p; fp[0] = fopen(name, "r"); + if (fp[0] == NULL) + err(EXIT_FAILURE, "can't open %s", name); for (i=0; (p = getchange(fp[0])); i++) { if (i >= szchanges - 1) increase(); -- cgit v1.2.3-59-g8ed1b