summaryrefslogtreecommitdiffstats
path: root/usr.bin/asa
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-05-15 03:17:01 +0000
committertjr <tjr@FreeBSD.org>2002-05-15 03:17:01 +0000
commitc0844f47a40f8e16ad76cf2b85df48806795d04b (patch)
treea9b87843d5391b60abb57e441081c5574bbfc7bb /usr.bin/asa
parent5fce6fe1a74674bdaaeccb716b38f178a5451a25 (diff)
downloadFreeBSD-src-c0844f47a40f8e16ad76cf2b85df48806795d04b.zip
FreeBSD-src-c0844f47a40f8e16ad76cf2b85df48806795d04b.tar.gz
Use getopt() to reject options (asa has none), and to the "--" end of options
marker. Exit non-zero if we cannot open one of the input files. Update standards conformance and exit status statements in manual page. PR: 36130 Approved by: mike
Diffstat (limited to 'usr.bin/asa')
-rw-r--r--usr.bin/asa/asa.112
-rw-r--r--usr.bin/asa/asa.c47
2 files changed, 38 insertions, 21 deletions
diff --git a/usr.bin/asa/asa.1 b/usr.bin/asa/asa.1
index 39cfc36..259e9b2 100644
--- a/usr.bin/asa/asa.1
+++ b/usr.bin/asa/asa.1
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 23, 1993
+.Dd May 9, 2002
.Dt ASA 1
.Os
.Sh NAME
@@ -63,10 +63,8 @@ before printing the rest of the line.
.Pp
Lines beginning with characters other than the above are treated as if they
begin with \*[Lt]space\*[Gt].
-.Sh EXIT STATUS
-The
-.Nm
-utility exit 0 on success, and \*[Gt]0 if an error occurs.
+.Sh DIAGNOSTICS
+.Ex -std
.Sh EXAMPLES
To view a file containing the output of a
.Tn FORTRAN
@@ -83,8 +81,6 @@ program and redirect it to a line-printer:
The
.Nm
utility conforms to
-.St -p1003.2-92
-and to
-.St -xcu5 .
+.St -p1003.1-2001 .
.Sh AUTHORS
J.T. Conklin, Winning Strategies, Inc.
diff --git a/usr.bin/asa/asa.c b/usr.bin/asa/asa.c
index 41d189d..8e2b2d7 100644
--- a/usr.bin/asa/asa.c
+++ b/usr.bin/asa/asa.c
@@ -43,29 +43,50 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
static void asa(FILE *);
+static void usage(void);
int
main(int argc, char *argv[])
{
+ int ch, exval;
FILE *fp;
+ const char *fn;
- /* skip progname */
- argv++;
+ while ((ch = getopt(argc, argv, "")) != -1) {
+ switch (ch) {
+ case '?':
+ default:
+ usage();
+ /*NOTREACHED*/
+ }
+ }
+ argc -= optind;
+ argv += optind;
- fp = stdin;
- do {
- if (*argv != NULL) {
- if ((fp = fopen(*argv, "r")) == NULL) {
- warn("%s", *argv);
+ exval = 0;
+ if (argc == 0)
+ asa(stdin);
+ else {
+ while ((fn = *argv++) != NULL) {
+ if ((fp = fopen(fn, "r")) == NULL) {
+ warn("%s", fn);
+ exval = 1;
continue;
}
- }
- asa(fp);
- if (fp != stdin)
- (void)fclose(fp);
- } while (*argv++ != NULL);
+ asa(fp);
+ fclose(fp);
+ }
+ }
+
+ exit(exval);
+}
+
+static void
+usage(void)
+{
- exit(0);
+ fprintf(stderr, "usage: asa [file...]\n");
+ exit(1);
}
static void
OpenPOWER on IntegriCloud