diff --git a/runtest.c b/runtest.c index 0762c088..ba7f16d5 100644 --- a/runtest.c +++ b/runtest.c @@ -1600,8 +1600,6 @@ oldParseTest(const char *filename, const char *result, char *temp; int res = 0; - xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); - nb_tests++; /* * base of the test, parse with the old API @@ -1611,10 +1609,8 @@ oldParseTest(const char *filename, const char *result, #else doc = xmlReadFile(filename, NULL, 0); #endif - if (doc == NULL) { - res = 1; - goto done; - } + if (doc == NULL) + return(1); temp = resultFilename(filename, temp_directory, ".res"); if (temp == NULL) { fprintf(stderr, "out of memory\n"); @@ -1634,10 +1630,8 @@ oldParseTest(const char *filename, const char *result, #else doc = xmlReadFile(temp, NULL, 0); #endif - if (doc == NULL) { - res = 1; - goto done; - } + if (doc == NULL) + return(1); xmlSaveFile(temp, doc); if (compareFiles(temp, result)) { res = 1; @@ -1649,9 +1643,6 @@ oldParseTest(const char *filename, const char *result, free(temp); } -done: - xmlSetStructuredErrorFunc(NULL, NULL); - return(res); } @@ -4377,6 +4368,9 @@ regexpTest(const char *filename, const char *result, const char *err, char expression[5000]; int len, ret, res = 0; + /* + * TODO: Custom error handler for regexp + */ xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); nb_tests++; diff --git a/runxmlconf.c b/runxmlconf.c index b5c3fd8d..bee8bdba 100644 --- a/runxmlconf.c +++ b/runxmlconf.c @@ -163,7 +163,6 @@ initializeLibxml2(void) { */ if (ctxtXPath->cache != NULL) xmlXPathContextSetCache(ctxtXPath, 0, -1, 0); - xmlSetStructuredErrorFunc(NULL, testErrorHandler); } /************************************************************************ @@ -184,6 +183,7 @@ xmlconfTestInvalid(const char *id, const char *filename, int options) { id, filename); return(0); } + xmlCtxtSetErrorHandler(ctxt, testErrorHandler, NULL); doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (doc == NULL) { test_log("test %s : %s invalid document turned not well-formed too\n", @@ -214,6 +214,7 @@ xmlconfTestValid(const char *id, const char *filename, int options) { id, filename); return(0); } + xmlCtxtSetErrorHandler(ctxt, testErrorHandler, NULL); doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (doc == NULL) { test_log("test %s : %s failed to parse a valid document\n", @@ -236,14 +237,17 @@ xmlconfTestValid(const char *id, const char *filename, int options) { static int xmlconfTestNotNSWF(const char *id, const char *filename, int options) { + xmlParserCtxtPtr ctxt; xmlDocPtr doc; int ret = 1; + ctxt = xmlNewParserCtxt(); + xmlCtxtSetErrorHandler(ctxt, testErrorHandler, NULL); /* * In case of Namespace errors, libxml2 will still parse the document * but log a Namespace error. */ - doc = xmlReadFile(filename, NULL, options); + doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (doc == NULL) { test_log("test %s : %s failed to parse the XML\n", id, filename); @@ -261,15 +265,19 @@ xmlconfTestNotNSWF(const char *id, const char *filename, int options) { } xmlFreeDoc(doc); } + xmlFreeParserCtxt(ctxt); return(ret); } static int xmlconfTestNotWF(const char *id, const char *filename, int options) { + xmlParserCtxtPtr ctxt; xmlDocPtr doc; int ret = 1; - doc = xmlReadFile(filename, NULL, options); + ctxt = xmlNewParserCtxt(); + xmlCtxtSetErrorHandler(ctxt, testErrorHandler, NULL); + doc = xmlCtxtReadFile(ctxt, filename, NULL, options); if (doc != NULL) { test_log("test %s : %s failed to detect not well formedness\n", id, filename); @@ -277,6 +285,7 @@ xmlconfTestNotWF(const char *id, const char *filename, int options) { xmlFreeDoc(doc); ret = 0; } + xmlFreeParserCtxt(ctxt); return(ret); } diff --git a/testOOM.c b/testOOM.c index 95a3c8e9..24d55c19 100644 --- a/testOOM.c +++ b/testOOM.c @@ -251,7 +251,6 @@ check_load_file_memory_func (void *data) goto out; xmlTextReaderSetStructuredErrorHandler (reader, error_func, NULL); - xmlSetStructuredErrorFunc(NULL, error_func); if (valid) { if (xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1) == -1) diff --git a/testlimits.c b/testlimits.c index d2a3cb53..7144b9a0 100644 --- a/testlimits.c +++ b/testlimits.c @@ -389,17 +389,11 @@ testExternalEntityLoader(const char *URL, const char *ID, return(ret); } -static void -testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, - const xmlError *err ATTRIBUTE_UNUSED) { -} - static void initializeLibxml2(void) { xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlInitParser(); xmlSetExternalEntityLoader(testExternalEntityLoader); - xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); /* * register the new I/O handlers */ @@ -999,7 +993,7 @@ saxTest(const char *filename, size_t limit, int options, int fail) { fprintf(stderr, "Failed to create parser context\n"); return(1); } - doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + doc = xmlCtxtReadFile(ctxt, filename, NULL, options | XML_PARSE_NOERROR); if (doc != NULL) { fprintf(stderr, "SAX parsing generated a document !\n"); @@ -1046,7 +1040,7 @@ readerTest(const char *filename, size_t limit, int options, int fail) { nb_tests++; maxlen = limit; - reader = xmlReaderForFile(filename , NULL, options); + reader = xmlReaderForFile(filename , NULL, options | XML_PARSE_NOERROR); if (reader == NULL) { fprintf(stderr, "Failed to open '%s' test\n", filename); return(1); diff --git a/testrecurse.c b/testrecurse.c index d4fa5707..0791c1c6 100644 --- a/testrecurse.c +++ b/testrecurse.c @@ -359,17 +359,11 @@ testExternalEntityLoader(const char *URL, const char *ID, return(ret); } -static void -testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, - const xmlError *err ATTRIBUTE_UNUSED) { -} - static void initializeLibxml2(void) { xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlInitParser(); xmlSetExternalEntityLoader(testExternalEntityLoader); - xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); /* * register the new I/O handlers */ @@ -485,7 +479,7 @@ recursiveDetectTest(const char *filename, * without XML_PARSE_NOENT. The validation result doesn't matter * anyway. */ - int parserOptions = XML_PARSE_DTDVALID; + int parserOptions = XML_PARSE_DTDVALID | XML_PARSE_NOERROR; nb_tests++;