]> granicus.if.org Git - graphviz/commitdiff
Output more useful error message on fopen failure
authorMark Hansen <markhansen@google.com>
Tue, 13 Apr 2021 09:20:26 +0000 (19:20 +1000)
committerMark Hansen <markhansen@google.com>
Wed, 14 Apr 2021 09:37:29 +0000 (19:37 +1000)
This should help with bugs like
https://gitlab.com/graphviz/graphviz.gitlab.io/-/issues/86

CHANGELOG.md
lib/common/input.c

index 92ecbecca66aeac8a09a1bd7a1e89a658f331a9a..3fe340551bd7eba51fe7c266585059eccfa5aea6 100644 (file)
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Changed
+- More detailed error messages when opening input file fails
+
 ### Fixed
 
 - Windows build thinks xdg-open can be used to open a web browser #1954
index fdbf44f0ae0e46f733e1828178d8baf8c2643c18..e4d3778697f030fc5e5b95a678cda7eae5a7abb6 100644 (file)
 #include <ctype.h>
 #include <common/render.h>
 #include <common/htmltable.h>
+#include <errno.h>
 #include <gvc/gvc.h>
 #include <xdot/xdot.h>
 #include <cgraph/agxbuf.h>
 #include <cgraph/strcasecmp.h>
 #include <stddef.h>
+#include <string.h>
 
 static char *usageFmt =
     "Usage: %s [-Vv?] [-(GNE)name=val] [-(KTlso)<val>] <dot files>\n";
@@ -575,7 +577,7 @@ graph_t *gvNextInputGraph(GVC_t *gvc)
            }
            else {
                while ((fn = gvc->input_filenames[fidx++]) && !(fp = fopen(fn, "r")))  {
-                   agerr(AGERR, "%s: can't open %s\n", gvc->common.cmdname, fn);
+                   agerr(AGERR, "%s: can't open %s: %s\n", gvc->common.cmdname, fn, strerror(errno));
                    graphviz_errors++;
                }
            }