Module: Mesa
Branch: master
Commit: 7a7010d4f5935ca31dc3aee285bb95ecfd6bbef4
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a7010d4f5935ca31dc3aee285bb95ecfd6bbef4

Author: Marcin Ślusarz <[email protected]>
Date:   Mon Nov 30 13:18:42 2020 +0100

intel/tools/aubinator_error_decode: allow "-" as an input file

Signed-off-by: Marcin Ślusarz <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7833>

---

 src/intel/tools/aubinator_error_decode.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/intel/tools/aubinator_error_decode.c 
b/src/intel/tools/aubinator_error_decode.c
index b7bdd88de2f..e1d86be8a59 100644
--- a/src/intel/tools/aubinator_error_decode.c
+++ b/src/intel/tools/aubinator_error_decode.c
@@ -749,7 +749,7 @@ print_help(const char *progname, FILE *file)
 int
 main(int argc, char *argv[])
 {
-   FILE *file;
+   FILE *file = NULL;
    const char *path;
    struct stat st;
    int c, i, error;
@@ -820,11 +820,14 @@ main(int argc, char *argv[])
       }
    } else {
       path = argv[optind];
-      error = stat(path, &st);
-      if (error != 0) {
-         fprintf(stderr, "Error opening %s: %s\n",
-                 path, strerror(errno));
-         exit(EXIT_FAILURE);
+      if (strcmp(path, "-") == 0) {
+         file = stdin;
+      } else {
+         error = stat(path, &st);
+         if (error != 0) {
+            fprintf(stderr, "Error opening %s: %s\n", path, strerror(errno));
+            exit(EXIT_FAILURE);
+         }
       }
    }
 
@@ -834,7 +837,7 @@ main(int argc, char *argv[])
    if (isatty(1) && pager)
       setup_pager();
 
-   if (S_ISDIR(st.st_mode)) {
+   if (!file && S_ISDIR(st.st_mode)) {
       ASSERTED int ret;
       char *filename;
 
@@ -860,7 +863,7 @@ main(int argc, char *argv[])
                  path);
          return EXIT_FAILURE;
       }
-   } else {
+   } else if (!file) {
       file = fopen(path, "r");
       if (!file) {
          fprintf(stderr, "Failed to open %s: %s\n",

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to