Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/what Add a missing : specified by TOG (Andras Farkas)



details:   https://anonhg.NetBSD.org/src/rev/cd44b9acddff
branches:  trunk
changeset: 1026775:cd44b9acddff
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 06 22:13:56 2021 +0000

description:
Add a missing : specified by TOG (Andras Farkas)
While here, simplify and use warn.

diffstat:

 usr.bin/what/what.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r dcef00af6264 -r cd44b9acddff usr.bin/what/what.c
--- a/usr.bin/what/what.c       Mon Dec 06 22:07:53 2021 +0000
+++ b/usr.bin/what/what.c       Mon Dec 06 22:13:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: what.c,v 1.12 2015/12/12 09:50:12 dholland Exp $       */
+/*     $NetBSD: what.c,v 1.13 2021/12/06 22:13:56 christos Exp $       */
 
 /*
  * Copyright (c) 1980, 1988, 1993
@@ -39,10 +39,11 @@
 #if 0
 static char sccsid[] = "@(#)what.c     8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: what.c,v 1.12 2015/12/12 09:50:12 dholland Exp $");
+__RCSID("$NetBSD: what.c,v 1.13 2021/12/06 22:13:56 christos Exp $");
 #endif /* not lint */
 
 #include <locale.h>
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -81,16 +82,15 @@
                usage();
        } else do {
                if (freopen(*argv, "r", stdin) == NULL) {
-                       perror(*argv);
-                       exit(matches ? EXIT_SUCCESS : 1);
+                       warn("Cannot open `%s", *argv);
+                       break;
                }
-               printf("%s\n", *argv);
+               printf("%s:\n", *argv);
                search();
        } while (*++argv != NULL);
 
        /* Note: the standard explicitly specifies an exit status of 1. */
-       exit(matches ? EXIT_SUCCESS : 1);
-       /* NOTREACHED */
+       return matches ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 static void
@@ -122,6 +122,6 @@
 usage(void)
 {
 
-       (void)fprintf(stderr, "usage: what [-s] file ...\n");
+       (void)fprintf(stderr, "Usage: %s [-s] file ...\n", getprogname());
        exit(1);
 }



Home | Main Index | Thread Index | Old Index