asa: Read from stdin if *argv is "-".
MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40563
This commit is contained in:
+12
-7
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void asa(FILE *);
|
||||
@@ -71,13 +72,17 @@ main(int argc, char *argv[])
|
||||
asa(stdin);
|
||||
else {
|
||||
while ((fn = *argv++) != NULL) {
|
||||
if ((fp = fopen(fn, "r")) == NULL) {
|
||||
warn("%s", fn);
|
||||
exval = 1;
|
||||
continue;
|
||||
}
|
||||
asa(fp);
|
||||
fclose(fp);
|
||||
if (strcmp(fn, "-") == 0) {
|
||||
asa(stdin);
|
||||
} else {
|
||||
if ((fp = fopen(fn, "r")) == NULL) {
|
||||
warn("%s", fn);
|
||||
exval = 1;
|
||||
continue;
|
||||
}
|
||||
asa(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user