register xmlSchemaSetValidErrors, patch from Brent Hendricks in the
* python/libxml.c: register xmlSchemaSetValidErrors, patch from
Brent Hendricks in the mailing-list
* include/libxml/valid.h HTMLparser.c SAX2.c valid.c
parserInternals.c: fix #156626 and more generally how to find out
if a validation contect is part of a parsing context or not. This
can probably be improved to make 100% sure that vctxt->userData
is the parser context too. It's a bit hairy because we can't
change the xmlValidCtxt structure without breaking the ABI since
this change xmlParserCtxt information indexes.
Daniel
diff --git a/ChangeLog b/ChangeLog
index c7d7dc7..223f130 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Oct 29 14:03:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+ * python/libxml.c: register xmlSchemaSetValidErrors, patch from
+ Brent Hendricks in the mailing-list
+ * include/libxml/valid.h HTMLparser.c SAX2.c valid.c
+ parserInternals.c: fix #156626 and more generally how to find out
+ if a validation contect is part of a parsing context or not. This
+ can probably be improved to make 100% sure that vctxt->userData
+ is the parser context too. It's a bit hairy because we can't
+ change the xmlValidCtxt structure without breaking the ABI since
+ this change xmlParserCtxt information indexes.
+
Wed Oct 27 19:26:20 CEST 2004 Daniel Veillard <daniel@veillard.com>
* ChangeLog NEWS configure.in doc/*: preparing release 2.6.15
diff --git a/HTMLparser.c b/HTMLparser.c
index 947e4aa..6022ed5 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -4136,6 +4136,7 @@
ctxt->replaceEntities = 0;
ctxt->linenumbers = xmlLineNumbersDefaultValue;
ctxt->html = 1;
+ ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
ctxt->vctxt.userData = ctxt;
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.warning = xmlParserValidityWarning;
diff --git a/NEWS b/NEWS
index 585a53f..564afcb 100644
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,9 @@
describes the recents commits
to the CVS at
http://cvs.gnome.org/viewcvs/libxml2/
- code base.There is the list of public releases:2.6.15: Oct 27 2004 - security fixes on the nanoftp and nanohttp modules
+ code base.There is the list of public releases:
+2.6.15: Oct 27 2004:
+ - security fixes on the nanoftp and nanohttp modules
- build fixes: xmllint detection bug in configure, building outside the
source tree (Thomas Fitzsimmons)
- bug fixes: HTML parser on broken ASCII chars in names (William), Python
diff --git a/SAX2.c b/SAX2.c
index cda9ac5..af36df9 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1562,7 +1562,7 @@
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
- if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
+ if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@@ -1571,7 +1571,7 @@
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
- ctxt->vctxt.finishDtd = 1;
+ ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
}
#endif /* LIBXML_VALID_ENABLED */
@@ -2132,7 +2132,7 @@
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
- if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
+ if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@@ -2141,7 +2141,7 @@
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
- ctxt->vctxt.finishDtd = 1;
+ ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
}
#endif /* LIBXML_VALID_ENABLED */
}
diff --git a/configure.in b/configure.in
index 64a6c0e..ed6b94c 100644
--- a/configure.in
+++ b/configure.in
@@ -446,7 +446,9 @@
with_docbook="yes"
fi
fi
+ if test "${CC}" = "gcc" ; then
CFLAGS="-g -O -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
+ fi
STATIC_BINARIES="-static"
dnl -Wcast-qual -ansi
else
diff --git a/include/libxml/valid.h b/include/libxml/valid.h
index a734902..99777d1 100644
--- a/include/libxml/valid.h
+++ b/include/libxml/valid.h
@@ -58,6 +58,21 @@
const char *msg,
...);
+#ifdef IN_LIBXML
+/**
+ * XML_CTXT_FINISH_DTD_0:
+ *
+ * Special value for finishDtd field when embedded in an xmlParserCtxt
+ */
+#define XML_CTXT_FINISH_DTD_0 0xabcd1234
+/**
+ * XML_CTXT_FINISH_DTD_1:
+ *
+ * Special value for finishDtd field when embedded in an xmlParserCtxt
+ */
+#define XML_CTXT_FINISH_DTD_1 0xabcd1235
+#endif
+
/*
* xmlValidCtxt:
* An xmlValidCtxt is used for error reporting when validating.
@@ -75,7 +90,7 @@
int nodeMax; /* Max depth of the parsing stack */
xmlNodePtr *nodeTab; /* array of nodes */
- int finishDtd; /* finished validating the Dtd ? */
+ unsigned int finishDtd; /* finished validating the Dtd ? */
xmlDocPtr doc; /* the document */
int valid; /* temporary validity check result */
diff --git a/parserInternals.c b/parserInternals.c
index 09f8bb8..42db411 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1630,6 +1630,7 @@
if (ctxt->keepBlanks == 0)
ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
+ ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
ctxt->vctxt.userData = ctxt;
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.warning = xmlParserValidityWarning;
diff --git a/python/libxml.c b/python/libxml.c
index bb2649a..9d33c77 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -3505,6 +3505,7 @@
#ifdef LIBXML_SCHEMAS_ENABLED
{(char *)"xmlRelaxNGSetValidErrors", libxml_xmlRelaxNGSetValidErrors, METH_VARARGS, NULL},
{(char *)"xmlRelaxNGFreeValidCtxt", libxml_xmlRelaxNGFreeValidCtxt, METH_VARARGS, NULL},
+ {(char *)"xmlSchemaSetValidErrors", libxml_xmlSchemaSetValidErrors, METH_VARARGS, NULL},
#endif
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
diff --git a/valid.c b/valid.c
index b853992..3884c90 100644
--- a/valid.c
+++ b/valid.c
@@ -59,7 +59,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
if (extra)
__xmlRaiseError(NULL, channel, data,
@@ -92,7 +97,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
if (extra)
__xmlRaiseError(NULL, channel, data,
@@ -132,7 +142,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
@@ -168,7 +183,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
@@ -202,7 +222,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_WARNING, NULL, 0,