xsltproc should return an error code if xinclude fails
authorMalcolm Purvis <malcolm@purvis.id.au>
Thu, 16 Aug 2012 09:08:31 +0000 (17:08 +0800)
committerDaniel Veillard <veillard@redhat.com>
Thu, 16 Aug 2012 09:08:31 +0000 (17:08 +0800)
When running xsltproc with the --xinclude option and if the included file
contains parse errors, then xsltproc exits with a success return code (0)
rather than an error code.  This is despite the fact that parser error
messages are printed out.
* xsltproc/xsltproc.c: check xinclude processing function return code,
  fail with error 6 if it went wrong.

xsltproc/xsltproc.c

index 8244ef3..42d6b9a 100644 (file)
@@ -359,16 +359,23 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
 
 #ifdef LIBXML_XINCLUDE_ENABLED
     if (xinclude) {
+        int ret;
+
        if (timing)
            startTimer();
 #if LIBXML_VERSION >= 20603
-       xmlXIncludeProcessFlags(doc, XSLT_PARSE_OPTIONS);
+       ret = xmlXIncludeProcessFlags(doc, XSLT_PARSE_OPTIONS);
 #else
-       xmlXIncludeProcess(doc);
+       ret = xmlXIncludeProcess(doc);
 #endif
        if (timing) {
            endTimer("XInclude processing %s", filename);
        }
+
+        if (ret < 0) {
+           errorno = 6;
+            return;
+        }
     }
 #endif
     if (timing)