diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-12-08 11:26:03 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-08 11:28:23 -0800 |
commit | d9be07670c2a7e3d54b6defb5ce5334b41ae1d90 (patch) | |
tree | f44c45c7c2f0ca61427a74d488f098b23e7fbaf0 /parse-xml.c | |
parent | 77664e715026c8c587b6a9c60b774ea31d5e75d5 (diff) | |
download | subsurface-d9be07670c2a7e3d54b6defb5ce5334b41ae1d90.tar.gz |
Don't ignore when we can't parse a file
We are quite inconsistent when it comes to reporting back errors.
One case where this caused somewhat unexpected behavior was when the
user would try to open a .csv file by passing it as command line
argument. The file was silently ignored, but treated as if it had been
opened successfully.
Now we issue a somewhat reasonable error message.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/parse-xml.c b/parse-xml.c index 80cd2021a..f1b439e28 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1745,7 +1745,7 @@ const char *preprocess_divelog_de(const char *buffer) return buffer; } -void parse_xml_buffer(const char *url, const char *buffer, int size, +int parse_xml_buffer(const char *url, const char *buffer, int size, struct dive_table *table, const char **params) { xmlDoc *doc; @@ -1756,10 +1756,9 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, if (res != buffer) free((char *)res); - if (!doc) { - report_error(translate("gettextFromC", "Failed to parse '%s'"), url); - return; - } + if (!doc) + return report_error(translate("gettextFromC", "Failed to parse '%s'"), url); + set_save_userid_local(false); set_userid(""); reset_all(); @@ -1768,6 +1767,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, traverse(xmlDocGetRootElement(doc)); dive_end(); xmlFreeDoc(doc); + + return 0; } void parse_mkvi_buffer(struct membuffer *txt, struct membuffer *csv, const char *starttime) |