Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vis Close opened files.



details:   https://anonhg.NetBSD.org/src/rev/a22ecf450246
branches:  trunk
changeset: 494277:a22ecf450246
user:      itohy <itohy%NetBSD.org@localhost>
date:      Wed Jul 05 00:35:28 2000 +0000

description:
Close opened files.
Make the exit status nonzero on errors.

diffstat:

 usr.bin/vis/vis.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r a9e5163f9aeb -r a22ecf450246 usr.bin/vis/vis.c
--- a/usr.bin/vis/vis.c Tue Jul 04 22:36:17 2000 +0000
+++ b/usr.bin/vis/vis.c Wed Jul 05 00:35:28 2000 +0000
@@ -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 @@
 #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 @@
 {
        FILE *fp;
        int ch;
+       int rval;
 
        while ((ch = getopt(argc, argv, "nwctsobfF:ld")) != -1)
                switch((char)ch) {
@@ -116,17 +117,22 @@
        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



Home | Main Index | Thread Index | Old Index