git: f08f90e69877 - main - asa: Read from stdin if *argv is "-".

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 15 Jun 2023 19:28:02 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=f08f90e6987775f88d25efbd8762c361819f40ba

commit f08f90e6987775f88d25efbd8762c361819f40ba
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-06-15 19:23:22 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-06-15 19:24:58 +0000

    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
---
 usr.bin/asa/asa.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/usr.bin/asa/asa.c b/usr.bin/asa/asa.c
index 11438b607466..a6c3d7d7c1e5 100644
--- a/usr.bin/asa/asa.c
+++ b/usr.bin/asa/asa.c
@@ -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);
+			}
 		}
 	}