diff options
Diffstat (limited to 'usr.bin/asa')
-rw-r--r-- | usr.bin/asa/asa.1 | 12 | ||||
-rw-r--r-- | usr.bin/asa/asa.c | 47 |
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 |