summaryrefslogtreecommitdiff
path: root/usr.bin/vis
diff options
context:
space:
mode:
authoritohy <itohy@NetBSD.org>2000-07-05 00:35:28 +0000
committeritohy <itohy@NetBSD.org>2000-07-05 00:35:28 +0000
commitbe63aecf8f04b986111db990f253bf7f7c8c00ac (patch)
tree38e15dbc70a7ae9f8b7f1f407fa1850061413a35 /usr.bin/vis
parentf184685d10e9c56d5b9caf779d8f4cad1d66f2de (diff)
Close opened files.
Make the exit status nonzero on errors.
Diffstat (limited to 'usr.bin/vis')
-rw-r--r--usr.bin/vis/vis.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/vis/vis.c b/usr.bin/vis/vis.c
index 3f5d551b19c..c0549d7ca96 100644
--- a/usr.bin/vis/vis.c
+++ b/usr.bin/vis/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.5 1997/10/20 03:06:48 lukem Exp $ */
+/* $NetBSD: vis.c,v 1.6 2000/07/05 00:35:28 itohy Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: vis.c,v 1.5 1997/10/20 03:06:48 lukem Exp $");
+__RCSID("$NetBSD: vis.c,v 1.6 2000/07/05 00:35:28 itohy Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -66,6 +66,7 @@ main(argc, argv)
{
FILE *fp;
int ch;
+ int rval;
while ((ch = getopt(argc, argv, "nwctsobfF:ld")) != -1)
switch((char)ch) {
@@ -116,17 +117,22 @@ main(argc, argv)
argc -= optind;
argv += optind;
+ rval = 0;
+
if (*argv)
while (*argv) {
- if ((fp=fopen(*argv, "r")) != NULL)
+ if ((fp=fopen(*argv, "r")) != NULL) {
process(fp, *argv);
- else
+ fclose(fp);
+ } else {
warn("%s", *argv);
+ rval = 1;
+ }
argv++;
}
else
process(stdin, "<stdin>");
- exit(0);
+ exit(rval);
}
void