diff options
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | dive.h | 4 | ||||
-rw-r--r-- | parse-xml.c | 30 |
3 files changed, 22 insertions, 21 deletions
@@ -118,7 +118,6 @@ ifeq ($(UNAME), linux) GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) OSSUPPORT = linux OSSUPPORT_CFLAGS = $(GTKCFLAGS) $(GCONF2CFLAGS) - XSLT_CAPABLE = 1 else ifeq ($(UNAME), darwin) OSSUPPORT = macos OSSUPPORT_CFLAGS = $(GTKCFLAGS) @@ -131,7 +130,6 @@ else ifeq ($(UNAME), darwin) CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler - XSLT_CAPABLE = 1 else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTKCFLAGS) @@ -140,14 +138,11 @@ else NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in NSIFILE = $(WINDOWSSTAGING)/subsurface.nsi MAKENSIS = makensis - + XSLTDIR = .\\xslt endif ifneq ($(strip $(LIBXSLT)),) - # We still need proper paths and install options for OSX and Windows - ifdef XSLT_CAPABLE - XSLT=-DXSLT='"$(XSLTDIR)"' - endif + XSLT=-DXSLT='"$(XSLTDIR)"' endif LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) @@ -529,10 +529,6 @@ extern void set_filename(const char *filename, gboolean force); extern void parse_file(const char *filename, GError **error, gboolean possible_default_filename); -#ifdef XSLT -extern xmlDoc *test_xslt_transforms(xmlDoc *doc); -#endif - extern void show_dive_info(struct dive *); extern void show_dive_equipment(struct dive *, int w_idx); diff --git a/parse-xml.c b/parse-xml.c index 84a1475a3..ddb3ba347 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -19,10 +19,24 @@ int verbose; +static xmlDoc *test_xslt_transforms(xmlDoc *doc, GError **error); + /* the dive table holds the overall dive list; target table points at * the table we are currently filling */ struct dive_table dive_table; struct dive_table *target_table = NULL; + +static void parser_error(GError **error, const char *fmt, ...) +{ + va_list args; + + if (!error) + return; + va_start(args, fmt); + *error = g_error_new_valist(g_quark_from_string("subsurface"), DIVE_ERROR_PARSE, fmt, args); + va_end(args); +} + /* * Add a dive into the dive_table array */ @@ -1477,19 +1491,13 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, doc = xmlReadMemory(buffer, size, url, NULL, 0); if (!doc) { fprintf(stderr, _("Failed to parse '%s'.\n"), url); - if (error != NULL) - { - *error = g_error_new(g_quark_from_string("subsurface"), - DIVE_ERROR_PARSE, - _("Failed to parse '%s'"), - url); - } + parser_error(error, _("Failed to parse '%s'"), url); return; } reset_all(); dive_start(); #ifdef XSLT - doc = test_xslt_transforms(doc); + doc = test_xslt_transforms(doc, error); #endif traverse(xmlDocGetRootElement(doc)); dive_end(); @@ -1569,7 +1577,7 @@ static struct xslt_files { { NULL, } }; -xmlDoc *test_xslt_transforms(xmlDoc *doc) +static xmlDoc *test_xslt_transforms(xmlDoc *doc, GError **error) { struct xslt_files *info = xslt_files; xmlDoc *transformed; @@ -1593,8 +1601,10 @@ xmlDoc *test_xslt_transforms(xmlDoc *doc) xmlSubstituteEntitiesDefault(1); xslt = get_stylesheet(info->file); - if (xslt == NULL) + if (xslt == NULL) { + parser_error(error, "Can't open stylesheet (%s)/%s", xslt_path, info->file); return doc; + } transformed = xsltApplyStylesheet(xslt, doc, NULL); xmlFreeDoc(doc); xsltFreeStylesheet(xslt); |