cleanup fixing bug #125653 sometimes the error handlers can get a parser
* Makefile.am: cleanup
* error.c valid.c include/libxml/xmlerror.h: fixing bug #125653
sometimes the error handlers can get a parser context on DTD
errors, and sometime they don't. So be very careful when trying
to grab those informations.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 648396a..ba2c414 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Oct 28 16:42:16 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * Makefile.am: cleanup
+ * error.c valid.c include/libxml/xmlerror.h: fixing bug #125653
+ sometimes the error handlers can get a parser context on DTD
+ errors, and sometime they don't. So be very careful when trying
+ to grab those informations.
+
Tue Oct 28 15:26:18 CET 2003 Daniel Veillard <daniel@veillard.com>
* tree.c: applied patch from Kasimier Buchcik which fixes a
diff --git a/Makefile.am b/Makefile.am
index c037fd4..c501ad1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -184,9 +184,7 @@
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
rm result.$$name.sax ; \
fi ; fi ; done)
- @echo "##"
@echo "## Push HTML SAX regression tests"
- @echo "##"
-@(for i in $(srcdir)/test/HTML/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
diff --git a/error.c b/error.c
index acf7ff3..3d4188b 100644
--- a/error.c
+++ b/error.c
@@ -301,6 +301,7 @@
channel(data, "namespace ");
break;
case XML_FROM_DTD:
+ case XML_FROM_VALID:
channel(data, "validity ");
break;
case XML_FROM_HTML:
@@ -454,6 +455,14 @@
(ctxt->sax->initialized == XML_SAX2_MAGIC))
schannel = ctxt->sax->serror;
}
+ if ((domain == XML_FROM_VALID) &&
+ ((channel == xmlParserValidityError) ||
+ (channel == xmlParserValidityWarning))) {
+ ctxt = (xmlParserCtxtPtr) ctx;
+ if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
+ (ctxt->sax->initialized == XML_SAX2_MAGIC))
+ schannel = ctxt->sax->serror;
+ }
if (code == XML_ERR_OK)
return;
/*
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index 1fcdf96..3532023 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -29,7 +29,7 @@
XML_FROM_PARSER, /* The XML parser */
XML_FROM_TREE, /* The tree module */
XML_FROM_NAMESPACE, /* The XML Namespace module */
- XML_FROM_DTD, /* The XML DTD validation */
+ XML_FROM_DTD, /* The XML DTD validation with parser context*/
XML_FROM_HTML, /* The HTML parser */
XML_FROM_MEMORY, /* The memory allocator */
XML_FROM_OUTPUT, /* The serialization code */
@@ -47,7 +47,8 @@
XML_FROM_RELAXNGV, /* The Relax-NG validator module */
XML_FROM_CATALOG, /* The Catalog module */
XML_FROM_C14N, /* The Canonicalization module */
- XML_FROM_XSLT /* The XSLT engine from libxslt */
+ XML_FROM_XSLT, /* The XSLT engine from libxslt */
+ XML_FROM_VALID /* The XML DTD validation with valid context */
} xmlErrorDomain;
/**
diff --git a/valid.c b/valid.c
index 0a2cedc..8b9c429 100644
--- a/valid.c
+++ b/valid.c
@@ -62,12 +62,12 @@
}
if (extra)
__xmlRaiseError(NULL, channel, data,
- pctxt, NULL, XML_FROM_DTD, XML_ERR_NO_MEMORY,
+ pctxt, NULL, XML_FROM_VALID, XML_ERR_NO_MEMORY,
XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0,
"Memory allocation failed : %s\n", extra);
else
__xmlRaiseError(NULL, channel, data,
- pctxt, NULL, XML_FROM_DTD, XML_ERR_NO_MEMORY,
+ pctxt, NULL, XML_FROM_VALID, XML_ERR_NO_MEMORY,
XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0,
"Memory allocation failed\n");
}
@@ -95,12 +95,12 @@
}
if (extra)
__xmlRaiseError(NULL, channel, data,
- pctxt, NULL, XML_FROM_DTD, error,
+ pctxt, NULL, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0,
msg, extra);
else
__xmlRaiseError(NULL, channel, data,
- pctxt, NULL, XML_FROM_DTD, error,
+ pctxt, NULL, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0,
msg);
}
@@ -118,7 +118,7 @@
* Handle a validation error, provide contextual informations
*/
static void
-xmlErrValidNodeNr(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
+xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
xmlNodePtr node, xmlParserErrors error,
const char *msg, const xmlChar * str1,
int int2, const xmlChar * str3)
@@ -134,7 +134,7 @@
pctxt = ctxt->userData;
pctxt = ctxt->userData;
}
- __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_DTD, error,
+ __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
(const char *) str1,
(const char *) str3,
@@ -168,7 +168,7 @@
pctxt = ctxt->userData;
pctxt = ctxt->userData;
}
- __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_DTD, error,
+ __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
(const char *) str1,
(const char *) str1,
@@ -202,7 +202,7 @@
pctxt = ctxt->userData;
pctxt = ctxt->userData;
}
- __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_DTD, error,
+ __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_WARNING, NULL, 0,
(const char *) str1,
(const char *) str1,