summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--third_party/libxml/ChangeLog301
-rw-r--r--third_party/libxml/HTMLparser.c39
-rw-r--r--third_party/libxml/README.google2
-rw-r--r--third_party/libxml/SAX2.c4
-rw-r--r--third_party/libxml/config.h.in3
-rw-r--r--third_party/libxml/configure76
-rw-r--r--third_party/libxml/configure.in25
-rw-r--r--third_party/libxml/debugXML.c4
-rw-r--r--third_party/libxml/dict.c9
-rw-r--r--third_party/libxml/elfgcchack.h12
-rw-r--r--third_party/libxml/encoding.c11
-rw-r--r--third_party/libxml/error.c2
-rw-r--r--third_party/libxml/globals.c2
-rw-r--r--third_party/libxml/google.patch342
-rw-r--r--third_party/libxml/include/libxml/schematron.h3
-rw-r--r--third_party/libxml/include/libxml/threads.h30
-rw-r--r--third_party/libxml/include/libxml/xmlerror.h6
-rw-r--r--third_party/libxml/include/libxml/xpath.h3
-rw-r--r--third_party/libxml/include/win32config.h6
-rw-r--r--third_party/libxml/libxml2.spec6
-rw-r--r--third_party/libxml/linux/config.h4
-rw-r--r--third_party/libxml/linux/include/libxml/xmlversion.h10
-rwxr-xr-xthird_party/libxml/linux/xml2-config2
-rw-r--r--third_party/libxml/nanohttp.c10
-rw-r--r--third_party/libxml/parser.c490
-rw-r--r--third_party/libxml/schematron.c76
-rw-r--r--third_party/libxml/testModule.c9
-rw-r--r--third_party/libxml/testRegexp.c19
-rw-r--r--third_party/libxml/testapi.c13
-rw-r--r--third_party/libxml/threads.c460
-rw-r--r--third_party/libxml/tree.c42
-rw-r--r--third_party/libxml/uri.c29
-rw-r--r--third_party/libxml/win32/Makefile14
-rw-r--r--third_party/libxml/win32/Makefile.msvc14
-rw-r--r--third_party/libxml/win32/libxml2.def.src2
-rw-r--r--third_party/libxml/xinclude.c23
-rw-r--r--third_party/libxml/xmlIO.c11
-rw-r--r--third_party/libxml/xmlmodule.c2
-rw-r--r--third_party/libxml/xmlreader.c7
-rw-r--r--third_party/libxml/xmlregexp.c25
-rw-r--r--third_party/libxml/xmlsave.c32
-rw-r--r--third_party/libxml/xmlschemas.c14
-rw-r--r--third_party/libxml/xmlschemastypes.c13
-rw-r--r--third_party/libxml/xmlwriter.c9
-rw-r--r--third_party/libxml/xpath.c32
45 files changed, 1587 insertions, 661 deletions
diff --git a/third_party/libxml/ChangeLog b/third_party/libxml/ChangeLog
index bacb7a8..4da35e4 100644
--- a/third_party/libxml/ChangeLog
+++ b/third_party/libxml/ChangeLog
@@ -1,3 +1,304 @@
+Tue Apr 8 10:19:01 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * tree.c: fix a bug introduced when fixing #438208 and reported by
+ Ashwin
+ * python/generator.py: fix an infinite loop bug
+
+Mon Apr 7 14:44:51 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c: fix a link to XmlNodeType doc reported by Martijn Arts
+ * docs/*: rebuilt
+
+Fri Apr 4 18:09:50 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: improve the *Recover* functions documentation
+
+Thu Apr 3 14:57:15 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: patch from Mark Rowe fixing BOM or encoding detection
+ in external parsed entities, should fix #440415
+
+Thu Apr 3 13:16:01 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * tree.c: fix some problems with the *EatName functions when
+ running out of memory raised by Eric Schrock , should fix #438208
+
+Thu Apr 3 12:41:29 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlschemastypes.c: horror around the definition of the lexical
+ values for decimal and derived types, fixing to reject empty
+ values, should fix #503268
+
+Thu Apr 3 11:44:57 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * encoding.c: buffer may not be large enough to convert to
+ UCS4, patch from Christian Fruth , fixes #504015
+
+Thu Apr 3 11:02:02 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * HTMLparser.c: apparently it's okay to forget the semicolumn after
+ entity refs in HTML, fixing char refs parsing accordingly based on
+ T. Manske patch, this should fix #517653
+
+Thu Apr 3 09:30:29 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * error.c: avoid a scary realloc() loop should fix #520383
+
+Thu Apr 3 08:22:52 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: more realloc problems pointed out by Ashwin
+
+Thu Apr 3 07:40:13 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xstc/Makefile.am: applied patch from Mike Hommey fixing distclean,
+ fixes #520387
+
+Thu Apr 3 06:52:32 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * include/libxml/xpath.h: small doc improvement for xmlXPathContext
+ from Jack Jansen, fixes #524759
+ * doc/newapi.xsl doc/*: fixed a problem and regenerated the docs
+
+Tue Apr 1 09:59:22 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xpath.c: two patches from Alvaro Herrera to avoid problem when
+ running out of memory in XPath evaluations.
+
+Mon Mar 31 11:23:19 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: lot of out of memory handling fixes from Ashwin
+ * elfgcchack.h doc/elfgcchack.xsl: work around a problem with xmlDllMain
+ * include/libxml/threads.h: indenting cleanups
+
+Mon Mar 31 10:25:37 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c docs/*: trying to clarify even more the xmlCleanupParser()
+ use and the memory documentation
+
+Wed Mar 26 18:39:58 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: changes based on Alex Khesin patch where xmlParseCharRef
+ seems to not be checked correctly, fixes #520198
+
+Wed Mar 26 15:03:49 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: patch from Ashwin to avoid a problem of attribute
+ redefinition in the DTD. Remove a warning too.
+
+Wed Mar 26 14:38:31 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlschemas.c: fix a problem in externalSubsetSplit with a patch
+ from Ashwin
+
+Tue Mar 25 17:48:02 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fix various attribute normalisation problems reported
+ by Ashwin
+ * result/c14n/without-comments/example-4
+ result/c14n/with-comments/example-4: this impacted the result of
+ two c14n tests :-\
+ * test/att9 test/att10 test/att11 result//att9* result//att10*
+ result//att11*: added 3 specific regression tests coming from the
+ XML spec revision and from Ashwin
+
+Tue Mar 25 14:20:49 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * uri.c: fix saving for file:///X:/ URI embedding Windows file paths
+ should fix #524253
+
+Mon Mar 24 21:42:33 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fix a problem reported by Ashwin for system parameter
+ entities referenced from entities in external subset, add a
+ specific loading routine.
+ * test/valid/dtds/external.ent test/valid/dtds/external2.ent
+ test/valid/t11.xml result/valid/t11.xml*: added the test to
+ the regression suite
+
+Mon Mar 24 15:04:54 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlschemas.c: fix an XML Schemas crash raised by Stefan Behnel
+ when testing with W3C test suite
+
+Mon Mar 24 12:12:00 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * threads.c: check some allocation with Ashwin patch
+
+Wed Mar 19 16:41:52 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * vms/build_libxml.com: update from Tycho Hilhorst, should fix #523378
+
+Tue Mar 18 09:23:05 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * threads.c: check some malloc returns with Ashwin patch, add
+ error messages and reindent the module.
+
+Fri Mar 14 15:28:43 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c: patch from Ashwin removing duplicate tests
+
+Fri Mar 14 13:44:29 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * include/libxml/schematron.h include/libxml/xmlerror.h schematron.c:
+ applied patch from Tobias Minich to allow plugin schematron error
+ reporting in the normal error system, should fix #513998
+
+Fri Mar 14 11:52:09 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c xinclude.c: patch from Vasily Chekalkin fixes memory
+ leaks, should fix 512647
+
+Thu Mar 13 08:17:58 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlregexp.c: found a nasty bug in regexp automata build,
+ reported by Ashwin and Bjorn Reese
+
+Wed Mar 12 18:56:22 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * HTMLparser.c: patch from Arnold Hendriks improving parsing of
+ html within html bogus data, still not a complete fix though
+
+Wed Mar 12 10:22:01 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * python/types.c: fix a memory errro when using namespace nodes
+ returned from XPath queries, should fix #521699
+ * python/tests/Makefile.am python/tests/xpathns.py: add a specific
+ regression test for it
+
+Mon Mar 10 16:25:32 CET 2008 Rob Richards <rrichards@ctindustries.net>
+
+ * include/win32config.h: add ICONV_CONST define for win32 build
+ to satisfy encoding.c change in rev 3693
+
+Fri Mar 7 17:45:27 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlsave.c parser.c: fix handling of empty CDATA nodes as
+ reported and discussed around #514181 and associated patches
+ * test/emptycdata.xml result/emptycdata.xml*
+ result/noent/emptycdata.xml: added a specific test in the
+ regression suite.
+
+Thu Mar 6 15:23:10 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * encoding.c: poblem with encoding detection for UTF-16 reported by
+ Ashwin and found by Bill
+ * test/valid/dtds/utf16b.ent test/valid/dtds/utf16l.ent
+ test/valid/UTF16Entity.xml result/valid/UTF16Entity.xml*: added
+ the example to the regression tests
+
+Tue Mar 4 14:16:38 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlwriter.c: patch from Alex Khesin fixing CDATA output after
+ a text node.
+ * parser.c: fixed the comment for xmlParserCleanup
+ * globals.c: fixed indentation
+
+Mon Feb 25 16:42:19 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * testModule.c: patch from Florent Guiliani to fix build on
+ SCO OpenServer
+
+Thu Feb 21 22:46:08 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * debugXML.c: made one of the changes suggested by Brian Krahmer
+ * testRegexp.c: allow to pass '--' on the command line to allow
+ regexps starting with the character '-'
+
+Tue Feb 19 08:49:32 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * python/Makefile.am python/tests/Makefile.am: applied cleanup
+ patches for cross compilation and MinGW from Roumen Petrov
+
+Sat Feb 16 11:06:54 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlIO.c: fix output bug reported by Petr Pajas and analyzed by
+ Bill
+
+Fri Feb 15 09:32:11 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * include/libxml/xmlerror.h tree.c: patch from Julien Charbon
+ to simplify the processing of xmlSetProp()
+
+Fri Feb 15 08:45:32 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * config.h.in configure.in encoding.c: patch from Roumen Petrov
+ to detect if iconv() needs a const for the second parameter
+
+Fri Feb 15 08:41:31 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * macos/src/XMLTestPrefix2.h win32/Makefile.msvc: EOL cleanups
+ from Florent Guiliani
+
+Wed Feb 13 10:56:38 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlwriter.c: applied patch from Alfred Mickautsch to flush the
+ output at the end of document.
+
+Fri Feb 8 11:57:03 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * doc/examples/examples.xml: regenerated, it was truncated.
+
+Fri Feb 8 11:47:18 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlmodule.c: apply simple patch from Carlo Bramini to avoid
+ compilation problems with Mingw32
+
+Fri Feb 8 11:33:15 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * xmlregexp.c: apply patch from Andrew Tosh to fix behaviour
+ when '.' is used in a posCharGroup
+ * test/schemas/poschargrp0_0.* result/schemas/poschargrp0_0_0*:
+ added the test to the regression suite
+
+Fri Feb 8 10:54:09 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * dict.c: applied patch from Florent Guilian to remove an
+ useless mutex in the xmlDict structure.
+
+Wed Feb 6 17:00:20 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * SAX2.c: another leak reported by Ashwin
+ * xinclude.c: fixed the behaviour when XIncluding a fragment
+ of the current document, patch from Chris Ryan
+
+Wed Feb 6 12:10:08 HKT 2008 William Brack <wbrack@mmm.com.hk>
+
+ * nanohttp.c: added space for port number (when not 80) in
+ xmlNanoHTTPMethodRedir, plus a few more comments. Should
+ fix #514521.
+
+Tue Feb 5 09:41:46 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * schemas.c: apply fix suggested by Ashwin correcting a cut-n-paste
+ error about the SAX callback in cdataBlockSplit when streaming
+ XSD validation
+
+Tue Feb 5 09:36:46 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * uri.c: applied a patch based on Petr Sumbera one to avoid a
+ problem with paths starting with //
+
+Mon Feb 4 17:48:30 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * doc/xml.html doc/xmlmem.html: added a small section on returning
+ memory to the kernel by compacting the heap provided by Wolfram Sang
+
+Fri Jan 25 20:01:42 CET 2007 Rob Richards <rrichards@ctindustries.net>
+
+ * include/win32config.h win32/Makefile.msvc: fix build under VS 2008.
+ patch by David Wimsey
+
+Thu Jan 24 15:37:04 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fix a memeory leak in internal subset parsing with
+ a fix from Ashwin
+ * test/errors/content1.xml result/errors/content1.xml*:
+ add test to regressions
+
+Fri Jan 11 09:00:09 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+ * configure.in doc/*: preparing release of 2.6.31
+
Fri Jan 11 08:58:49 CET 2008 Daniel Veillard <daniel@veillard.com>
* parser.c: avoid a warning on 64bits introduced earlier
diff --git a/third_party/libxml/HTMLparser.c b/third_party/libxml/HTMLparser.c
index 38af5e3..92503a1 100644
--- a/third_party/libxml/HTMLparser.c
+++ b/third_party/libxml/HTMLparser.c
@@ -3115,9 +3115,9 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
val = val * 16 + (CUR - 'A') + 10;
else {
htmlParseErr(ctxt, XML_ERR_INVALID_HEX_CHARREF,
- "htmlParseCharRef: invalid hexadecimal value\n",
+ "htmlParseCharRef: missing semicolumn\n",
NULL, NULL);
- return(0);
+ break;
}
NEXT;
}
@@ -3130,9 +3130,9 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
val = val * 10 + (CUR - '0');
else {
htmlParseErr(ctxt, XML_ERR_INVALID_DEC_CHARREF,
- "htmlParseCharRef: invalid decimal value\n",
+ "htmlParseCharRef: missing semicolumn\n",
NULL, NULL);
- return(0);
+ break;
}
NEXT;
}
@@ -3423,7 +3423,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
*
* [NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
*
- * Returns 0 in case of success and -1 in case of error.
+ * Returns 0 in case of success, -1 in case of error and 1 if discarded
*/
static int
@@ -3436,6 +3436,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
int maxatts;
int meta = 0;
int i;
+ int discardtag = 0;
if ((ctxt == NULL) || (ctxt->input == NULL)) {
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
@@ -3480,14 +3481,14 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <html> tag\n",
name, NULL);
- return 0;
+ discardtag = 1;
}
if ((ctxt->nameNr != 1) &&
(xmlStrEqual(name, BAD_CAST"head"))) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <head> tag\n",
name, NULL);
- return 0;
+ discardtag = 1;
}
if (xmlStrEqual(name, BAD_CAST"body")) {
int indx;
@@ -3496,9 +3497,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <body> tag\n",
name, NULL);
- while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
- NEXT;
- return 0;
+ discardtag = 1;
}
}
}
@@ -3597,12 +3596,14 @@ failed:
/*
* SAX: Start of Element !
*/
- htmlnamePush(ctxt, name);
- if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) {
- if (nbatts != 0)
- ctxt->sax->startElement(ctxt->userData, name, atts);
- else
- ctxt->sax->startElement(ctxt->userData, name, NULL);
+ if (!discardtag) {
+ htmlnamePush(ctxt, name);
+ if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) {
+ if (nbatts != 0)
+ ctxt->sax->startElement(ctxt->userData, name, atts);
+ else
+ ctxt->sax->startElement(ctxt->userData, name, NULL);
+ }
}
if (atts != NULL) {
@@ -3612,7 +3613,7 @@ failed:
}
}
- return 0;
+ return(discardtag);
}
/**
@@ -3991,7 +3992,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
failed = htmlParseStartTag(ctxt);
name = ctxt->name;
- if (failed || (name == NULL)) {
+ if ((failed == -1) || (name == NULL)) {
if (CUR == '>')
NEXT;
return;
@@ -4893,7 +4894,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
failed = htmlParseStartTag(ctxt);
name = ctxt->name;
- if (failed ||
+ if ((failed == -1) ||
(name == NULL)) {
if (CUR == '>')
NEXT;
diff --git a/third_party/libxml/README.google b/third_party/libxml/README.google
index 2cbcd56..f7cd50b 100644
--- a/third_party/libxml/README.google
+++ b/third_party/libxml/README.google
@@ -16,7 +16,7 @@ includes the following modifications :
This allows parsed entities to inherit namespaces.
(http://bugzilla.gnome.org/show_bug.cgi?id=502960 )
-Current version: 2.6.31
+Current version: 2.6.32
To import a new snapshot of libxml:
diff --git a/third_party/libxml/SAX2.c b/third_party/libxml/SAX2.c
index 9739831..7dbc2b2 100644
--- a/third_party/libxml/SAX2.c
+++ b/third_party/libxml/SAX2.c
@@ -2366,7 +2366,9 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
xmlGenericError(xmlGenericErrorContext,
"add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
#endif
- xmlAddChild(ctxt->node, ret);
+ if (xmlAddChild(ctxt->node, ret) == NULL) {
+ xmlFreeNode(ret);
+ }
}
/**
diff --git a/third_party/libxml/config.h.in b/third_party/libxml/config.h.in
index 1dafc10..f8435d4 100644
--- a/third_party/libxml/config.h.in
+++ b/third_party/libxml/config.h.in
@@ -246,6 +246,9 @@
/* Whether __va_copy() is available */
#undef HAVE___VA_COPY
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
+
/* Name of package */
#undef PACKAGE
diff --git a/third_party/libxml/configure b/third_party/libxml/configure
index c2e694a..cf51aed 100644
--- a/third_party/libxml/configure
+++ b/third_party/libxml/configure
@@ -2191,7 +2191,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
LIBXML_MAJOR_VERSION=2
LIBXML_MINOR_VERSION=6
-LIBXML_MICRO_VERSION=31
+LIBXML_MICRO_VERSION=32
LIBXML_MICRO_VERSION_SUFFIX=
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@@ -29052,6 +29052,80 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
fi
+
+ if test "$WITH_ICONV" = "1" ; then
+ { echo "$as_me:$LINENO: checking for iconv declaration" >&5
+echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6; }
+ if test "${xml_cv_iconv_arg2+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ xml_cv_iconv_arg2=""
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ xml_cv_iconv_arg2="const"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+ xml_cv_iconv_decl="extern size_t iconv (iconv_t cd, $xml_cv_iconv_arg2 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
+ { echo "$as_me:$LINENO: result: ${xml_xxx:-
+ }$xml_cv_iconv_decl" >&5
+echo "${ECHO_T}${xml_xxx:-
+ }$xml_cv_iconv_decl" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_CONST $xml_cv_iconv_arg2
+_ACEOF
+
+ fi
fi
case "$host" in
*mingw*) M_LIBS=""
diff --git a/third_party/libxml/configure.in b/third_party/libxml/configure.in
index 699232fd..8fc76e5 100644
--- a/third_party/libxml/configure.in
+++ b/third_party/libxml/configure.in
@@ -5,7 +5,7 @@ AC_CANONICAL_HOST
LIBXML_MAJOR_VERSION=2
LIBXML_MINOR_VERSION=6
-LIBXML_MICRO_VERSION=31
+LIBXML_MICRO_VERSION=32
LIBXML_MICRO_VERSION_SUFFIX=
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@@ -1224,6 +1224,29 @@ iconv (cd, NULL, NULL, NULL, NULL);],[
AC_MSG_RESULT(no)
LIBS="${_libs}"
LDFLAGS="${_ldflags}"])]))
+
+ if test "$WITH_ICONV" = "1" ; then
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL(xml_cv_iconv_arg2, [
+ AC_TRY_COMPILE([#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], xml_cv_iconv_arg2="", xml_cv_iconv_arg2="const")])
+
+ xml_cv_iconv_decl="extern size_t iconv (iconv_t cd, $xml_cv_iconv_arg2 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
+ AC_MSG_RESULT([${xml_xxx:-
+ }$xml_cv_iconv_decl])
+ AC_DEFINE_UNQUOTED(ICONV_CONST, $xml_cv_iconv_arg2,
+ [Define as const if the declaration of iconv() needs const.])
+ fi
fi
case "$host" in
*mingw*) M_LIBS=""
diff --git a/third_party/libxml/debugXML.c b/third_party/libxml/debugXML.c
index 3985ad3..de6fd6c 100644
--- a/third_party/libxml/debugXML.c
+++ b/third_party/libxml/debugXML.c
@@ -320,7 +320,8 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
}
if (node->next == NULL) {
if ((node->parent != NULL) && (node->type != XML_ATTRIBUTE_NODE) &&
- (node->parent->last != node))
+ (node->parent->last != node) &&
+ (node->parent->type == XML_ELEMENT_NODE))
xmlDebugErr(ctxt, XML_CHECK_NO_NEXT,
"Node has no next and not last of parent list\n");
} else {
@@ -3244,6 +3245,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"Unknown command %s\n", command);
}
free(cmdline); /* not xmlFree here ! */
+ cmdline = NULL;
}
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeContext(ctxt->pctxt);
diff --git a/third_party/libxml/dict.c b/third_party/libxml/dict.c
index 3b4054f..c071887 100644
--- a/third_party/libxml/dict.c
+++ b/third_party/libxml/dict.c
@@ -60,7 +60,6 @@ struct _xmlDictStrings {
*/
struct _xmlDict {
int ref_counter;
- xmlRMutexPtr mutex;
struct _xmlDictEntry *dict;
int size;
@@ -337,11 +336,8 @@ xmlDictCreate(void) {
dict->strings = NULL;
dict->subdict = NULL;
if (dict->dict) {
- if ((dict->mutex = xmlNewRMutex()) != NULL) {
- memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
- return(dict);
- }
- xmlFree(dict->dict);
+ memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
+ return(dict);
}
xmlFree(dict);
}
@@ -545,7 +541,6 @@ xmlDictFree(xmlDictPtr dict) {
xmlFree(pool);
pool = nextp;
}
- xmlFreeRMutex(dict->mutex);
xmlFree(dict);
}
diff --git a/third_party/libxml/elfgcchack.h b/third_party/libxml/elfgcchack.h
index cd9605c..e1d21bb 100644
--- a/third_party/libxml/elfgcchack.h
+++ b/third_party/libxml/elfgcchack.h
@@ -10119,6 +10119,18 @@ extern __typeof (xmlSchematronParse) xmlSchematronParse__internal_alias __attrib
#if defined(LIBXML_SCHEMATRON_ENABLED)
#ifdef bottom_schematron
+#undef xmlSchematronSetValidStructuredErrors
+extern __typeof (xmlSchematronSetValidStructuredErrors) xmlSchematronSetValidStructuredErrors __attribute((alias("xmlSchematronSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlSchematronSetValidStructuredErrors
+extern __typeof (xmlSchematronSetValidStructuredErrors) xmlSchematronSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronSetValidStructuredErrors xmlSchematronSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
#undef xmlSchematronValidateDoc
extern __typeof (xmlSchematronValidateDoc) xmlSchematronValidateDoc __attribute((alias("xmlSchematronValidateDoc__internal_alias")));
#else
diff --git a/third_party/libxml/encoding.c b/third_party/libxml/encoding.c
index eb5ed78..c032a6b 100644
--- a/third_party/libxml/encoding.c
+++ b/third_party/libxml/encoding.c
@@ -1788,7 +1788,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
}
icv_inlen = *inlen;
icv_outlen = *outlen;
- ret = iconv(cd, (char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+ ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
*inlen -= icv_inlen;
*outlen -= icv_outlen;
if ((icv_inlen != 0) || (ret == -1)) {
@@ -1922,9 +1922,10 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
* 45 chars should be sufficient to reach the end of the encoding
* declaration without going too far inside the document content.
+ * on UTF-16 this means 90bytes, on UCS4 this means 180
*/
- if (toconv > 45)
- toconv = 45;
+ if (toconv > 180)
+ toconv = 180;
if (toconv * 2 >= written) {
xmlBufferGrow(out, toconv);
written = out->size - out->use - 1;
@@ -2175,8 +2176,8 @@ retry:
toconv = in->use;
if (toconv == 0)
return(0);
- if (toconv * 2 >= written) {
- xmlBufferGrow(out, toconv * 2);
+ if (toconv * 4 >= written) {
+ xmlBufferGrow(out, toconv * 4);
written = out->size - out->use - 1;
}
if (handler->output != NULL) {
diff --git a/third_party/libxml/error.c b/third_party/libxml/error.c
index 722ffbb..5f03d94 100644
--- a/third_party/libxml/error.c
+++ b/third_party/libxml/error.c
@@ -31,7 +31,7 @@ void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
\
size = 150; \
\
- while (1) { \
+ while (size < 64000) { \
va_start(ap, msg); \
chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
diff --git a/third_party/libxml/globals.c b/third_party/libxml/globals.c
index 636ff87..cbc6625 100644
--- a/third_party/libxml/globals.c
+++ b/third_party/libxml/globals.c
@@ -60,7 +60,7 @@ void xmlCleanupGlobals(void)
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
- __xmlGlobalInitMutexDestroy();
+ __xmlGlobalInitMutexDestroy();
}
/************************************************************************
diff --git a/third_party/libxml/google.patch b/third_party/libxml/google.patch
index 5cd4e9b..25ca7d0 100644
--- a/third_party/libxml/google.patch
+++ b/third_party/libxml/google.patch
@@ -1,60 +1,8 @@
-diff -ur libxml2-2.6.31.orig/configure libxml2-2.6.31/configure
---- libxml2-2.6.31.orig/configure 2008-01-11 00:01:56.000000000 -0800
-+++ libxml2-2.6.31/configure 2008-08-05 12:19:40.000000000 -0700
-@@ -952,6 +952,7 @@
- TEST_XPATH
- WITH_OUTPUT
- WITH_ICONV
-+WITH_ICU
- WITH_ISO8859X
- WITH_SCHEMATRON
- TEST_SCHEMATRON
-@@ -28792,6 +28793,8 @@
- fi
-
-
-+WITH_ICU=1
-+
- WITH_ICONV=0
- if test "$with_iconv" = "no" ; then
- echo Disabling ICONV support
-@@ -29213,7 +29216,7 @@
- ln -s Copyright COPYING
-
- # keep on one line for cygwin c.f. #130896
--ac_config_files="$ac_config_files libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc python/setup.py"
-+ac_config_files="$ac_config_files include/libxml/xmlversion.h xml2-config"
-
- cat >confcache <<\_ACEOF
- # This file is a shell script that caches the results of configure
-@@ -30119,6 +30122,7 @@
- TEST_XPATH!$TEST_XPATH$ac_delim
- WITH_OUTPUT!$WITH_OUTPUT$ac_delim
- WITH_ICONV!$WITH_ICONV$ac_delim
-+WITH_ICU!$WITH_ICU$ac_delim
- WITH_ISO8859X!$WITH_ISO8859X$ac_delim
- WITH_SCHEMATRON!$WITH_SCHEMATRON$ac_delim
- TEST_SCHEMATRON!$TEST_SCHEMATRON$ac_delim
-@@ -30130,7 +30134,7 @@
- DEBUG_OBJ!$DEBUG_OBJ$ac_delim
- _ACEOF
-
-- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
-+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 98; then
- break
- elif $ac_last_try; then
- { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
-@@ -30794,5 +30798,5 @@
- fi
-
-
--chmod +x xml2-config python/setup.py
-+chmod +x xml2-config
- echo Done configuring
-diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
---- libxml2-2.6.31/encoding.c 2007-05-28 07:08:52.000000000 -0700
-+++ libxml/encoding.c 2008-03-17 14:28:09.000000000 -0400
-@@ -58,7 +58,7 @@
+Index: encoding.c
+===================================================================
+--- encoding.c (revision 3733)
++++ encoding.c (working copy)
+@@ -58,7 +58,7 @@
static int xmlCharEncodingAliasesNb = 0;
static int xmlCharEncodingAliasesMax = 0;
@@ -63,7 +11,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#if 0
#define DEBUG_ENCODING /* Define this to get encoding traces */
#endif
-@@ -97,6 +97,53 @@
+@@ -97,6 +97,54 @@
NULL, 0, val, NULL, NULL, 0, 0, msg, val);
}
@@ -110,6 +58,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
+ if (conv != NULL) {
+ ucnv_close(conv->uconv);
+ ucnv_close(conv->utf8);
++ xmlFree(conv);
+ }
+}
+#endif /* LIBXML_ICU_ENABLED */
@@ -117,7 +66,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
/************************************************************************
* *
* Conversions To/From UTF8 encoding *
-@@ -1306,7 +1353,11 @@
+@@ -1306,7 +1354,11 @@
#ifdef LIBXML_ICONV_ENABLED
handler->iconv_in = NULL;
handler->iconv_out = NULL;
@@ -130,7 +79,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
/*
* registers and returns the handler.
-@@ -1371,7 +1422,7 @@
+@@ -1371,7 +1423,7 @@
xmlNewCharEncodingHandler("ASCII", asciiToUTF8, NULL);
xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, NULL);
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -139,7 +88,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef LIBXML_ISO8859X_ENABLED
xmlRegisterCharEncodingHandlersISO8859x ();
#endif
-@@ -1576,6 +1627,10 @@
+@@ -1576,6 +1628,10 @@
xmlCharEncodingHandlerPtr enc;
iconv_t icv_in, icv_out;
#endif /* LIBXML_ICONV_ENABLED */
@@ -150,7 +99,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
char upper[100];
int i;
-@@ -1642,6 +1697,35 @@
+@@ -1642,6 +1698,35 @@
"iconv : problems with filters for '%s'\n", name);
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -186,7 +135,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef DEBUG_ENCODING
xmlGenericError(xmlGenericErrorContext,
-@@ -1732,6 +1816,75 @@
+@@ -1732,6 +1817,75 @@
/************************************************************************
* *
@@ -262,7 +211,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
* The real API used by libxml for on-the-fly conversion *
* *
************************************************************************/
-@@ -1793,6 +1946,16 @@
+@@ -1794,6 +1948,16 @@
if (ret == -1) ret = -3;
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -279,7 +228,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef DEBUG_ENCODING
switch (ret) {
case 0:
-@@ -1878,6 +2041,17 @@
+@@ -1879,6 +2043,17 @@
ret = -3;
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -297,7 +246,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
switch (ret) {
case 0:
#ifdef DEBUG_ENCODING
-@@ -1978,6 +2152,15 @@
+@@ -1979,6 +2154,15 @@
out->content[out->use] = 0;
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -313,7 +262,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef DEBUG_ENCODING
xmlGenericError(xmlGenericErrorContext,
"initialized encoder\n");
-@@ -2022,6 +2205,26 @@
+@@ -2023,6 +2207,26 @@
}
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -340,7 +289,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
else {
xmlEncodingErr(XML_I18N_NO_OUTPUT,
"xmlCharEncOutFunc: no output function !\n", NULL);
-@@ -2134,6 +2337,22 @@
+@@ -2135,6 +2339,22 @@
xmlFree(handler);
}
#endif /* LIBXML_ICONV_ENABLED */
@@ -363,7 +312,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef DEBUG_ENCODING
if (ret)
xmlGenericError(xmlGenericErrorContext,
-@@ -2209,6 +2428,22 @@
+@@ -2210,6 +2430,22 @@
cur += toconv;
} while (ret == -2);
#endif
@@ -386,7 +335,7 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
} else {
/* could not find a converter */
return(-1);
-@@ -2220,8 +2455,9 @@
+@@ -2221,8 +2457,9 @@
}
return(in->consumed + (in->cur - in->base));
}
@@ -397,15 +346,16 @@ diff -ur libxml2-2.6.31/encoding.c libxml/encoding.c
#ifdef LIBXML_ISO8859X_ENABLED
/**
-@@ -3293,4 +3529,3 @@
+@@ -3294,4 +3531,3 @@
#define bottom_encoding
#include "elfgcchack.h"
-
-diff -ur libxml2-2.6.31/include/libxml/encoding.h libxml/include/libxml/encoding.h
---- libxml2-2.6.31/include/libxml/encoding.h 2007-01-03 05:07:30.000000000 -0800
-+++ libxml/include/libxml/encoding.h 2008-02-19 17:41:38.256715200 -0800
-@@ -26,6 +26,24 @@
+Index: include/libxml/encoding.h
+===================================================================
+--- include/libxml/encoding.h (revision 3733)
++++ include/libxml/encoding.h (working copy)
+@@ -26,7 +26,25 @@
#ifdef LIBXML_ICONV_ENABLED
#include <iconv.h>
@@ -424,13 +374,14 @@ diff -ur libxml2-2.6.31/include/libxml/encoding.h libxml/include/libxml/encoding
+typedef wchar_t UChar;
+#else
+typedef uint16_t UChar;
+ #endif
+#endif
+#endif
+#endif
- #endif
#ifdef __cplusplus
extern "C" {
-@@ -125,6 +143,13 @@
+ #endif
+@@ -125,6 +143,13 @@
* Block defining the handlers for non UTF-8 encodings.
* If iconv is supported, there are two extra fields.
*/
@@ -444,7 +395,7 @@ diff -ur libxml2-2.6.31/include/libxml/encoding.h libxml/include/libxml/encoding
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
-@@ -136,6 +161,10 @@
+@@ -136,6 +161,10 @@
iconv_t iconv_in;
iconv_t iconv_out;
#endif /* LIBXML_ICONV_ENABLED */
@@ -455,86 +406,90 @@ diff -ur libxml2-2.6.31/include/libxml/encoding.h libxml/include/libxml/encoding
};
#ifdef __cplusplus
-diff -ur libxml2-2.6.31/include/libxml/parser.h libxml/include/libxml/parser.h
---- libxml2-2.6.31/include/libxml/parser.h 2007-01-03 05:07:30.000000000 -0800
-+++ libxml/include/libxml/parser.h 2008-02-19 16:45:35.934484200 -0800
-@@ -276,6 +276,7 @@
- int nsNr; /* the number of inherited namespaces */
- int nsMax; /* the size of the arrays */
- const xmlChar * *nsTab; /* the array of prefix/namespace name */
-+ struct _xmlParserCtxt *nsParent; /* parent context to inherit namespaces from */
- int *attallocs; /* which attribute were allocated */
- void * *pushTab; /* array of data for push */
- xmlHashTablePtr attsDefault; /* defaulted attributes if any */
-@@ -1207,6 +1208,7 @@
- XML_WITH_DEBUG_MEM = 29,
- XML_WITH_DEBUG_RUN = 30,
- XML_WITH_ZLIB = 31,
-+ XML_WITH_ICU = 32,
- XML_WITH_NONE = 99999 /* just to be sure of allocation size */
- } xmlFeature;
-
-@@ -1217,4 +1219,3 @@
- }
- #endif
- #endif /* __XML_PARSER_H__ */
--
-diff -ur libxml2-2.6.31/include/libxml/xmlversion.h.in libxml/include/libxml/xmlversion.h.in
---- libxml2-2.6.31/include/libxml/xmlversion.h.in 2007-05-28 07:08:51.000000000 -0700
-+++ libxml/include/libxml/xmlversion.h.in 2008-02-19 15:12:47.126374800 -0800
-@@ -269,6 +269,15 @@
- #endif
-
- /**
-+ * LIBXML_ICU_ENABLED:
-+ *
-+ * Whether icu support is available
-+ */
-+#if @WITH_ICU@
-+#define LIBXML_ICU_ENABLED
-+#endif
-+
-+/**
- * LIBXML_ISO8859X_ENABLED:
- *
- * Whether ISO-8859-* support is made available in case iconv is not
-diff -ur libxml2-2.6.31/parser.c libxml/parser.c
---- libxml2-2.6.31/parser.c 2008-01-10 22:36:20.000000000 -0800
-+++ libxml/parser.c 2008-02-19 16:38:39.312150600 -0800
-@@ -813,6 +813,12 @@
- #else
- return(0);
- #endif
-+ case XML_WITH_ICU:
-+#ifdef LIBXML_ICU_ENABLED
-+ return(1);
-+#else
-+ return(0);
-+#endif
- default:
- break;
- }
-@@ -7456,6 +7462,7 @@
- return(NULL);
- return(ctxt->nsTab[i + 1]);
- }
-+ if (ctxt->nsParent) return xmlGetNamespace(ctxt->nsParent, prefix);
- return(NULL);
- }
-
-@@ -11666,6 +11673,8 @@
- ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
- ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
-
-+ ctxt->nsParent = oldctxt;
-+
- oldsax = ctxt->sax;
- ctxt->sax = oldctxt->sax;
- xmlDetectSAX2(ctxt);
-diff -ur libxml2-2.6.31/win32/Makefile.msvc libxml/win32/Makefile.msvc
---- libxml2-2.6.31/win32/Makefile.msvc 2007-06-12 01:16:00.000000000 -0700
-+++ libxml/win32/Makefile.msvc 2008-02-19 17:21:25.233228600 -0800
-@@ -71,6 +71,9 @@
+Index: include/libxml/parser.h
+===================================================================
+--- include/libxml/parser.h (revision 3733)
++++ include/libxml/parser.h (working copy)
+@@ -276,6 +276,7 @@
+ int nsNr; /* the number of inherited namespaces */
+ int nsMax; /* the size of the arrays */
+ const xmlChar * *nsTab; /* the array of prefix/namespace name */
++ struct _xmlParserCtxt *nsParent; /* parent context to inherit namespaces from */
+ int *attallocs; /* which attribute were allocated */
+ void * *pushTab; /* array of data for push */
+ xmlHashTablePtr attsDefault; /* defaulted attributes if any */
+@@ -1207,6 +1208,7 @@
+ XML_WITH_DEBUG_MEM = 29,
+ XML_WITH_DEBUG_RUN = 30,
+ XML_WITH_ZLIB = 31,
++ XML_WITH_ICU = 32,
+ XML_WITH_NONE = 99999 /* just to be sure of allocation size */
+ } xmlFeature;
+
+@@ -1217,4 +1219,3 @@
+ }
+ #endif
+ #endif /* __XML_PARSER_H__ */
+-
+Index: include/libxml/xmlversion.h.in
+===================================================================
+--- include/libxml/xmlversion.h.in (revision 3733)
++++ include/libxml/xmlversion.h.in (working copy)
+@@ -269,6 +269,15 @@
+ #endif
+
+ /**
++ * LIBXML_ICU_ENABLED:
++ *
++ * Whether icu support is available
++ */
++#if @WITH_ICU@
++#define LIBXML_ICU_ENABLED
++#endif
++
++/**
+ * LIBXML_ISO8859X_ENABLED:
+ *
+ * Whether ISO-8859-* support is made available in case iconv is not
+Index: parser.c
+===================================================================
+--- parser.c (revision 3733)
++++ parser.c (working copy)
+@@ -816,6 +816,12 @@
+ #else
+ return(0);
+ #endif
++ case XML_WITH_ICU:
++#ifdef LIBXML_ICU_ENABLED
++ return(1);
++#else
++ return(0);
++#endif
+ default:
+ break;
+ }
+@@ -7705,6 +7711,7 @@
+ return(NULL);
+ return(ctxt->nsTab[i + 1]);
+ }
++ if (ctxt->nsParent) return xmlGetNamespace(ctxt->nsParent, prefix);
+ return(NULL);
+ }
+
+@@ -11948,6 +11955,8 @@
+ ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
+ ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
+
++ ctxt->nsParent = oldctxt;
++
+ oldsax = ctxt->sax;
+ ctxt->sax = oldctxt->sax;
+ xmlDetectSAX2(ctxt);
+Index: win32/Makefile.msvc
+===================================================================
+--- win32/Makefile.msvc (revision 3733)
++++ win32/Makefile.msvc (working copy)
+@@ -71,6 +71,9 @@
!if "$(WITH_ICONV)" == "1"
LIBS = $(LIBS) iconv.lib
!endif
@@ -544,10 +499,11 @@ diff -ur libxml2-2.6.31/win32/Makefile.msvc libxml/win32/Makefile.msvc
!if "$(WITH_ZLIB)" == "1"
LIBS = $(LIBS) zdll.lib
!endif
-diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
---- libxml2-2.6.31/win32/configure.js 2007-08-14 06:50:46.000000000 -0700
-+++ libxml/win32/configure.js 2008-02-19 16:47:33.574356300 -0800
-@@ -40,6 +40,7 @@
+Index: win32/configure.js
+===================================================================
+--- win32/configure.js (revision 3733)
++++ win32/configure.js (working copy)
+@@ -40,6 +40,7 @@
var withXptr = true;
var withXinclude = true;
var withIconv = true;
@@ -555,7 +511,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
var withIso8859x = false;
var withZlib = false;
var withDebug = true;
-@@ -124,6 +125,7 @@
+@@ -124,6 +125,7 @@
txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
@@ -563,7 +519,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
-@@ -233,6 +235,7 @@
+@@ -233,6 +235,7 @@
vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
@@ -571,7 +527,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
-@@ -319,6 +322,8 @@
+@@ -319,6 +322,8 @@
of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
} else if (s.search(/\@WITH_ICONV\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
@@ -580,7 +536,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
} else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
} else if (s.search(/\@WITH_ZLIB\@/) != -1) {
-@@ -462,6 +467,8 @@
+@@ -462,6 +467,8 @@
withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "iconv")
withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
@@ -589,7 +545,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
else if (opt == "iso8859x")
withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "zlib")
-@@ -611,7 +618,13 @@
+@@ -611,7 +618,13 @@
makefile = ".\\Makefile.mingw";
else if (compiler == "bcb")
makefile = ".\\Makefile.bcb";
@@ -604,7 +560,7 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
WScript.Echo("Created Makefile.");
// Create the config.h.
var confighsrc = "..\\include\\win32config.h";
-@@ -640,6 +653,7 @@
+@@ -640,6 +653,7 @@
txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
@@ -612,27 +568,29 @@ diff -ur libxml2-2.6.31/win32/configure.js libxml/win32/configure.js
txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
-diff -ur libxml2-2.6.31/xmlmodule.c libxml/xmlmodule.c
---- libxml2-2.6.31/xmlmodule.c 2007-01-03 05:07:52.000000000 -0800
-+++ libxml/xmlmodule.c 2008-02-19 16:11:08.682089700 -0800
-@@ -300,7 +300,7 @@
- static void *
- xmlModulePlatformOpen(const char *name)
- {
-- return LoadLibrary(name);
-+ return LoadLibraryA(name);
- }
-
- /*
-diff -ur libxml2-2.6.31/xmlregexp.c libxml/xmlregexp.c
---- libxml2-2.6.31/xmlregexp.c 2007-11-23 02:47:23.000000000 -0800
-+++ libxml/xmlregexp.c 2008-02-19 16:22:51.380717400 -0800
-@@ -6443,7 +6443,7 @@
- if (name != NULL) {
- value += 30 * (*name);
- while ((ch = *name++) != 0) {
-- value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
-+ value = value ^ ((value << 5) + (value >> 3) + (unsigned short)ch);
- }
- }
- return (value);
+Index: xmlmodule.c
+===================================================================
+--- xmlmodule.c (revision 3733)
++++ xmlmodule.c (working copy)
+@@ -300,7 +300,7 @@
+ static void *
+ xmlModulePlatformOpen(const char *name)
+ {
+- return LoadLibrary(name);
++ return LoadLibraryA(name);
+ }
+
+ /*
+Index: xmlregexp.c
+===================================================================
+--- xmlregexp.c (revision 3733)
++++ xmlregexp.c (working copy)
+@@ -6464,7 +6464,7 @@
+ if (name != NULL) {
+ value += 30 * (*name);
+ while ((ch = *name++) != 0) {
+- value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
++ value = value ^ ((value << 5) + (value >> 3) + (unsigned short)ch);
+ }
+ }
+ return (value);
diff --git a/third_party/libxml/include/libxml/schematron.h b/third_party/libxml/include/libxml/schematron.h
index 6eaa699..9e36c0e 100644
--- a/third_party/libxml/include/libxml/schematron.h
+++ b/third_party/libxml/include/libxml/schematron.h
@@ -25,6 +25,7 @@ typedef enum {
XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */
XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */
XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */
+ XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */
XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */
XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */
XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */
@@ -81,12 +82,12 @@ XMLPUBFUN void XMLCALL
/*
* Interfaces for validating
*/
-/******
XMLPUBFUN void XMLCALL
xmlSchematronSetValidStructuredErrors(
xmlSchematronValidCtxtPtr ctxt,
xmlStructuredErrorFunc serror,
void *ctx);
+/******
XMLPUBFUN void XMLCALL
xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt,
xmlSchematronValidityErrorFunc err,
diff --git a/third_party/libxml/include/libxml/threads.h b/third_party/libxml/include/libxml/threads.h
index f81f982..d31f16a 100644
--- a/third_party/libxml/include/libxml/threads.h
+++ b/third_party/libxml/include/libxml/threads.h
@@ -36,40 +36,40 @@ typedef xmlRMutex *xmlRMutexPtr;
#ifdef __cplusplus
extern "C" {
#endif
-XMLPUBFUN xmlMutexPtr XMLCALL
+XMLPUBFUN xmlMutexPtr XMLCALL
xmlNewMutex (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMutexLock (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMutexUnlock (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeMutex (xmlMutexPtr tok);
-XMLPUBFUN xmlRMutexPtr XMLCALL
+XMLPUBFUN xmlRMutexPtr XMLCALL
xmlNewRMutex (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRMutexLock (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRMutexUnlock (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeRMutex (xmlRMutexPtr tok);
/*
* Library wide APIs.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitThreads (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlLockLibrary (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlUnlockLibrary(void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGetThreadId (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsMainThread (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupThreads(void);
-XMLPUBFUN xmlGlobalStatePtr XMLCALL
+XMLPUBFUN xmlGlobalStatePtr XMLCALL
xmlGetGlobalState(void);
#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
diff --git a/third_party/libxml/include/libxml/xmlerror.h b/third_party/libxml/include/libxml/xmlerror.h
index c5f2164..8cbab5e 100644
--- a/third_party/libxml/include/libxml/xmlerror.h
+++ b/third_party/libxml/include/libxml/xmlerror.h
@@ -61,7 +61,8 @@ typedef enum {
XML_FROM_CHECK, /* The error checking module */
XML_FROM_WRITER, /* The xmlwriter module */
XML_FROM_MODULE, /* The dynamically loaded module module*/
- XML_FROM_I18N /* The module handling character conversion */
+ XML_FROM_I18N, /* The module handling character conversion */
+ XML_FROM_SCHEMATRONV /* The Schematron validator module */
} xmlErrorDomain;
/**
@@ -398,6 +399,7 @@ typedef enum {
XML_TREE_INVALID_HEX = 1300,
XML_TREE_INVALID_DEC, /* 1301 */
XML_TREE_UNTERMINATED_ENTITY, /* 1302 */
+ XML_TREE_NOT_UTF8, /* 1303 */
XML_SAVE_NOT_UTF8 = 1400,
XML_SAVE_CHAR_INVALID, /* 1401 */
XML_SAVE_NO_DOCTYPE, /* 1402 */
@@ -773,6 +775,8 @@ typedef enum {
XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */
XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */
XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */
+ XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */
+ XML_SCHEMATRONV_REPORT,
XML_MODULE_OPEN = 4900, /* 4900 */
XML_MODULE_CLOSE, /* 4901 */
XML_CHECK_FOUND_ELEMENT = 5000,
diff --git a/third_party/libxml/include/libxml/xpath.h b/third_party/libxml/include/libxml/xpath.h
index 725cebe..1a9e30e 100644
--- a/third_party/libxml/include/libxml/xpath.h
+++ b/third_party/libxml/include/libxml/xpath.h
@@ -278,6 +278,9 @@ typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
* - the set of namespace declarations in scope for the expression
* Following the switch to hash tables, this need to be trimmed up at
* the next binary incompatible release.
+ * The node may be modified when the context is passed to libxml2
+ * for an XPath evaluation so you may need to initialize it again
+ * before the next call.
*/
struct _xmlXPathContext {
diff --git a/third_party/libxml/include/win32config.h b/third_party/libxml/include/win32config.h
index 6e9b33b..3fc9be5 100644
--- a/third_party/libxml/include/win32config.h
+++ b/third_party/libxml/include/win32config.h
@@ -23,6 +23,10 @@
#include <libxml/xmlversion.h>
+#ifndef ICONV_CONST
+#define ICONV_CONST const
+#endif
+
#ifdef NEED_SOCKETS
#include <wsockcompat.h>
#endif
@@ -92,7 +96,9 @@ static int isnan (double d) {
#if defined(_MSC_VER)
#define mkdir(p,m) _mkdir(p)
#define snprintf _snprintf
+#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
+#endif
#elif defined(__MINGW32__)
#define mkdir(p,m) _mkdir(p)
#endif
diff --git a/third_party/libxml/libxml2.spec b/third_party/libxml/libxml2.spec
index 40632aa..887e8a1 100644
--- a/third_party/libxml/libxml2.spec
+++ b/third_party/libxml/libxml2.spec
@@ -1,6 +1,6 @@
Summary: Library providing XML and HTML support
Name: libxml2
-Version: 2.6.31
+Version: 2.6.32
Release: 1
License: MIT
Group: Development/Libraries
@@ -128,6 +128,6 @@ rm -fr %{buildroot}
%doc doc/python.html
%changelog
-* Fri Jan 11 2008 Daniel Veillard <veillard@redhat.com>
-- upstream release 2.6.31 see http://xmlsoft.org/news.html
+* Tue Apr 8 2008 Daniel Veillard <veillard@redhat.com>
+- upstream release 2.6.32 see http://xmlsoft.org/news.html
diff --git a/third_party/libxml/linux/config.h b/third_party/libxml/linux/config.h
index a3f8707..c2e0371 100644
--- a/third_party/libxml/linux/config.h
+++ b/third_party/libxml/linux/config.h
@@ -1,7 +1,7 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
#define PACKAGE "libxml2"
-#define VERSION "2.6.31"
+#define VERSION "2.6.32"
#define HAVE_LIBZ 1
/* #undef HAVE_LIBM */
#define HAVE_ISINF
@@ -275,7 +275,7 @@
#define SUPPORT_IP6
/* Version number of package */
-#define VERSION "2.6.31"
+#define VERSION "2.6.32"
/* Determine what socket length (socklen_t) data type is */
#define XML_SOCKLEN_T socklen_t
diff --git a/third_party/libxml/linux/include/libxml/xmlversion.h b/third_party/libxml/linux/include/libxml/xmlversion.h
index 48adae8..b6b2747 100644
--- a/third_party/libxml/linux/include/libxml/xmlversion.h
+++ b/third_party/libxml/linux/include/libxml/xmlversion.h
@@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* the version string like "1.2.3"
*/
-#define LIBXML_DOTTED_VERSION "2.6.31"
+#define LIBXML_DOTTED_VERSION "2.6.32"
/**
* LIBXML_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
-#define LIBXML_VERSION 20631
+#define LIBXML_VERSION 20632
/**
* LIBXML_VERSION_STRING:
*
* the version number string, 1.2.3 value is "10203"
*/
-#define LIBXML_VERSION_STRING "20631"
+#define LIBXML_VERSION_STRING "20632"
/**
* LIBXML_VERSION_EXTRA:
@@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro to check that the libxml version in use is compatible with
* the version the software has been compiled against
*/
-#define LIBXML_TEST_VERSION xmlCheckVersion(20631);
+#define LIBXML_TEST_VERSION xmlCheckVersion(20632);
#ifndef VMS
#if 0
@@ -379,7 +379,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* the string suffix used by dynamic modules (usually shared libraries)
*/
-#define LIBXML_MODULE_EXTENSION ".so"
+#define LIBXML_MODULE_EXTENSION ".dll"
#endif
/**
diff --git a/third_party/libxml/linux/xml2-config b/third_party/libxml/linux/xml2-config
index 2eaeb88..500acaf 100755
--- a/third_party/libxml/linux/xml2-config
+++ b/third_party/libxml/linux/xml2-config
@@ -58,7 +58,7 @@ while test $# -gt 0; do
;;
--version)
- echo 2.6.31
+ echo 2.6.32
exit 0
;;
diff --git a/third_party/libxml/nanohttp.c b/third_party/libxml/nanohttp.c
index 91c7e87..07829c7 100644
--- a/third_party/libxml/nanohttp.c
+++ b/third_party/libxml/nanohttp.c
@@ -1332,13 +1332,23 @@ retry:
if (headers != NULL)
blen += strlen(headers) + 2;
if (contentType && *contentType)
+ /* reserve for string plus 'Content-Type: \r\n" */
blen += strlen(*contentType) + 16;
if (ctxt->query != NULL)
+ /* 1 for '?' */
blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24;
#ifdef HAVE_ZLIB_H
+ /* reserve for possible 'Accept-Encoding: gzip' string */
blen += 23;
#endif
+ if (ctxt->port != 80) {
+ /* reserve space for ':xxxxx', incl. potential proxy */
+ if (proxy)
+ blen += 12;
+ else
+ blen += 6;
+ }
bp = (char*)xmlMallocAtomic(blen);
if ( bp == NULL ) {
xmlNanoHTTPFreeCtxt( ctxt );
diff --git a/third_party/libxml/parser.c b/third_party/libxml/parser.c
index e0e47a9..d12f429 100644
--- a/third_party/libxml/parser.c
+++ b/third_party/libxml/parser.c
@@ -126,6 +126,9 @@ static xmlParserErrors
xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
const xmlChar *string, void *user_data, xmlNodePtr *lst);
+static int
+xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity);
+
/************************************************************************
* *
* Some factorized error routines *
@@ -866,6 +869,103 @@ struct _xmlDefAttrs {
};
/**
+ * xmlAttrNormalizeSpace:
+ * @src: the source string
+ * @dst: the target string
+ *
+ * Normalize the space in non CDATA attribute values:
+ * If the attribute type is not CDATA, then the XML processor MUST further
+ * process the normalized attribute value by discarding any leading and
+ * trailing space (#x20) characters, and by replacing sequences of space
+ * (#x20) characters by a single space (#x20) character.
+ * Note that the size of dst need to be at least src, and if one doesn't need
+ * to preserve dst (and it doesn't come from a dictionary or read-only) then
+ * passing src as dst is just fine.
+ *
+ * Returns a pointer to the normalized value (dst) or NULL if no conversion
+ * is needed.
+ */
+static xmlChar *
+xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
+{
+ if ((src == NULL) || (dst == NULL))
+ return(NULL);
+
+ while (*src == 0x20) src++;
+ while (*src != 0) {
+ if (*src == 0x20) {
+ while (*src == 0x20) src++;
+ if (*src != 0)
+ *dst++ = 0x20;
+ } else {
+ *dst++ = *src++;
+ }
+ }
+ *dst = 0;
+ if (dst == src)
+ return(NULL);
+ return(dst);
+}
+
+/**
+ * xmlAttrNormalizeSpace2:
+ * @src: the source string
+ *
+ * Normalize the space in non CDATA attribute values, a slightly more complex
+ * front end to avoid allocation problems when running on attribute values
+ * coming from the input.
+ *
+ * Returns a pointer to the normalized value (dst) or NULL if no conversion
+ * is needed.
+ */
+static const xmlChar *
+xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, const xmlChar *src, int *len)
+{
+ int i;
+ int remove_head = 0;
+ int need_realloc = 0;
+ const xmlChar *cur;
+
+ if ((ctxt == NULL) || (src == NULL) || (len == NULL))
+ return(NULL);
+ i = *len;
+ if (i <= 0)
+ return(NULL);
+
+ cur = src;
+ while (*cur == 0x20) {
+ cur++;
+ remove_head++;
+ }
+ while (*cur != 0) {
+ if (*cur == 0x20) {
+ cur++;
+ if ((*cur == 0x20) || (*cur == 0)) {
+ need_realloc = 1;
+ break;
+ }
+ } else
+ cur++;
+ }
+ if (need_realloc) {
+ xmlChar *ret;
+
+ ret = xmlStrndup(src + remove_head, i - remove_head + 1);
+ if (ret == NULL) {
+ xmlErrMemory(ctxt, NULL);
+ return(NULL);
+ }
+ xmlAttrNormalizeSpace(ret, ret);
+ *len = (int) strlen((const char *)ret);
+ return(ret);
+ } else if (remove_head) {
+ *len -= remove_head;
+ return(src + remove_head);
+ }
+ return(NULL);
+}
+
+/**
* xmlAddDefAttrs:
* @ctxt: an XML parser context
* @fullname: the element fullname
@@ -884,6 +984,14 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
const xmlChar *name;
const xmlChar *prefix;
+ /*
+ * Allows to detect attribute redefinitions
+ */
+ if (ctxt->attsSpecial != NULL) {
+ if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
+ return;
+ }
+
if (ctxt->attsDefault == NULL) {
ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict);
if (ctxt->attsDefault == NULL)
@@ -914,7 +1022,11 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
goto mem_error;
defaults->nbAttrs = 0;
defaults->maxAttrs = 4;
- xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL);
+ if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
+ defaults, NULL) < 0) {
+ xmlFree(defaults);
+ goto mem_error;
+ }
} else if (defaults->nbAttrs >= defaults->maxAttrs) {
xmlDefAttrsPtr temp;
@@ -924,7 +1036,11 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
goto mem_error;
defaults = temp;
defaults->maxAttrs *= 2;
- xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL);
+ if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
+ defaults, NULL) < 0) {
+ xmlFree(defaults);
+ goto mem_error;
+ }
}
/*
@@ -1147,15 +1263,16 @@ nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
return (-1);
}
} else if (ctxt->nsNr >= ctxt->nsMax) {
+ const xmlChar ** tmp;
ctxt->nsMax *= 2;
- ctxt->nsTab = (const xmlChar **)
- xmlRealloc((char *) ctxt->nsTab,
- ctxt->nsMax * sizeof(ctxt->nsTab[0]));
- if (ctxt->nsTab == NULL) {
+ tmp = (const xmlChar **) xmlRealloc((char *) ctxt->nsTab,
+ ctxt->nsMax * sizeof(ctxt->nsTab[0]));
+ if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
ctxt->nsMax /= 2;
return (-1);
}
+ ctxt->nsTab = tmp;
}
ctxt->nsTab[ctxt->nsNr++] = prefix;
ctxt->nsTab[ctxt->nsNr++] = URL;
@@ -1476,13 +1593,16 @@ namePop(xmlParserCtxtPtr ctxt)
static int spacePush(xmlParserCtxtPtr ctxt, int val) {
if (ctxt->spaceNr >= ctxt->spaceMax) {
+ int *tmp;
+
ctxt->spaceMax *= 2;
- ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab,
- ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
- if (ctxt->spaceTab == NULL) {
+ tmp = (int *) xmlRealloc(ctxt->spaceTab,
+ ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
+ if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
return(0);
}
+ ctxt->spaceTab = tmp;
}
ctxt->spaceTab[ctxt->spaceNr] = val;
ctxt->space = &ctxt->spaceTab[ctxt->spaceNr];
@@ -1972,6 +2092,7 @@ xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
buffer = xmlMallocAtomic(length);
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
+ xmlFree(input);
return(NULL);
}
buffer [0] = ' ';
@@ -2188,7 +2309,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
xmlChar *tmp; \
buffer##_size *= 2; \
tmp = (xmlChar *) \
- xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
+ xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
if (tmp == NULL) goto mem_error; \
buffer = tmp; \
}
@@ -2219,6 +2340,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
int buffer_size = 0;
xmlChar *current = NULL;
+ xmlChar *rep = NULL;
const xmlChar *last;
xmlEntityPtr ent;
int c,l;
@@ -2278,8 +2400,6 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
"predefined entity has no content\n");
}
} else if ((ent != NULL) && (ent->content != NULL)) {
- xmlChar *rep;
-
ctxt->depth++;
rep = xmlStringDecodeEntities(ctxt, ent->content, what,
0, 0, 0);
@@ -2294,6 +2414,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
}
}
xmlFree(rep);
+ rep = NULL;
}
} else if (ent != NULL) {
int i = xmlStrlen(ent->name);
@@ -2313,8 +2434,10 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
"String decoding PE Reference: %.30s\n", str);
ent = xmlParseStringPEReference(ctxt, &str);
if (ent != NULL) {
- xmlChar *rep;
-
+ if (ent->content == NULL) {
+ if (xmlLoadEntityContent(ctxt, ent) < 0) {
+ }
+ }
ctxt->depth++;
rep = xmlStringDecodeEntities(ctxt, ent->content, what,
0, 0, 0);
@@ -2329,6 +2452,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
}
}
xmlFree(rep);
+ rep = NULL;
}
}
} else {
@@ -2348,6 +2472,10 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
mem_error:
xmlErrMemory(ctxt, NULL);
+ if (rep != NULL)
+ xmlFree(rep);
+ if (buffer != NULL)
+ xmlFree(buffer);
return(NULL);
}
@@ -2462,7 +2590,7 @@ static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
* xmlSplitQName:
* @ctxt: an XML parser context
* @name: an XML parser context
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* parse an UTF8 encoded XML qualified name string
*
@@ -2513,7 +2641,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* for the processing speed.
*/
max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
@@ -2528,7 +2656,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
tmp = (xmlChar *) xmlRealloc(buffer,
max * sizeof(xmlChar));
if (tmp == NULL) {
- xmlFree(tmp);
+ xmlFree(buffer);
xmlErrMemory(ctxt, NULL);
return(NULL);
}
@@ -2539,7 +2667,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
}
buffer[len] = 0;
}
-
+
if ((c == ':') && (*cur == 0)) {
if (buffer != NULL)
xmlFree(buffer);
@@ -2592,7 +2720,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* for the processing speed.
*/
max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
@@ -2618,7 +2746,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
}
buffer[len] = 0;
}
-
+
if (buffer == NULL)
ret = xmlStrndup(buf, len);
else {
@@ -3091,6 +3219,7 @@ static xmlChar *
xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
xmlChar limit = 0;
xmlChar *buf = NULL;
+ xmlChar *rep = NULL;
int len = 0;
int buf_size = 0;
int c, l, in_space = 0;
@@ -3109,7 +3238,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
return(NULL);
}
-
+
/*
* allocate a translation buffer.
*/
@@ -3149,7 +3278,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
buf[len++] = '8';
buf[len++] = ';';
}
- } else {
+ } else if (val != 0) {
if (len > buf_size - 10) {
growBuffer(buf);
}
@@ -3174,8 +3303,6 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
}
} else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) {
- xmlChar *rep;
-
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF,
@@ -3189,6 +3316,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
}
}
xmlFree(rep);
+ rep = NULL;
}
} else {
if (len > buf_size - 10) {
@@ -3207,11 +3335,12 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
*/
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(ent->content != NULL)) {
- xmlChar *rep;
rep = xmlStringDecodeEntities(ctxt, ent->content,
- XML_SUBSTITUTE_REF, 0, 0, 0);
- if (rep != NULL)
+ XML_SUBSTITUTE_REF, 0, 0, 0);
+ if (rep != NULL) {
xmlFree(rep);
+ rep = NULL;
+ }
}
/*
@@ -3270,6 +3399,10 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
mem_error:
xmlErrMemory(ctxt, NULL);
+ if (buf != NULL)
+ xmlFree(buf);
+ if (rep != NULL)
+ xmlFree(rep);
return(NULL);
}
@@ -4538,6 +4671,10 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return;
+ }
}
if (ctxt->myDoc->intSubset == NULL)
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
@@ -4606,6 +4743,10 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return;
+ }
}
if (ctxt->myDoc->intSubset == NULL)
@@ -5019,6 +5160,8 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
xmlFreeEnumeration(tree);
break;
}
+ if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
+ xmlAttrNormalizeSpace(defaultValue, defaultValue);
GROW;
if (RAW != '>') {
@@ -5108,6 +5251,8 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
}
NEXT;
ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
+ if (ret == NULL)
+ return(NULL);
if (RAW == '*') {
ret->ocur = XML_ELEMENT_CONTENT_MULT;
NEXT;
@@ -5338,6 +5483,8 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
}
} else {
xmlFatalErr(ctxt, XML_ERR_ELEMCONTENT_NOT_FINISHED, NULL);
+ if ((last != NULL) && (last != ret))
+ xmlFreeDocElementContent(ctxt->myDoc, last);
if (ret != NULL)
xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
@@ -5361,6 +5508,11 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
return(NULL);
}
last = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
+ if (last == NULL) {
+ if (ret != NULL)
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
+ return(NULL);
+ }
if (RAW == '?') {
last->ocur = XML_ELEMENT_CONTENT_OPT;
NEXT;
@@ -5913,6 +6065,21 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
const xmlChar *SystemID) {
xmlDetectSAX2(ctxt);
GROW;
+
+ if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
+ (ctxt->input->end - ctxt->input->cur >= 4)) {
+ xmlChar start[4];
+ xmlCharEncoding enc;
+
+ start[0] = RAW;
+ start[1] = NXT(1);
+ start[2] = NXT(2);
+ start[3] = NXT(3);
+ enc = xmlDetectCharEncoding(start, 4);
+ if (enc != XML_CHAR_ENCODING_NONE)
+ xmlSwitchEncoding(ctxt, enc);
+ }
+
if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
xmlParseTextDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
@@ -5988,6 +6155,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
int hex = NXT(2);
int value = xmlParseCharRef(ctxt);
+ if (value == 0)
+ return;
if (ctxt->charset != XML_CHAR_ENCODING_UTF8) {
/*
* So we are using non-UTF-8 buffers
@@ -6832,6 +7001,86 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
}
/**
+ * xmlLoadEntityContent:
+ * @ctxt: an XML parser context
+ * @entity: an unloaded system entity
+ *
+ * Load the original content of the given system entity from the
+ * ExternalID/SystemID given. This is to be used for Included in Literal
+ * http://www.w3.org/TR/REC-xml/#inliteral processing of entities references
+ *
+ * Returns 0 in case of success and -1 in case of failure
+ */
+static int
+xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
+ xmlParserInputPtr input;
+ xmlBufferPtr buf;
+ int l, c;
+ int count = 0;
+
+ if ((ctxt == NULL) || (entity == NULL) ||
+ ((entity->etype != XML_EXTERNAL_PARAMETER_ENTITY) &&
+ (entity->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY)) ||
+ (entity->content != NULL)) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent parameter error");
+ return(-1);
+ }
+
+ if (xmlParserDebugEntities)
+ xmlGenericError(xmlGenericErrorContext,
+ "Reading %s entity content input\n", entity->name);
+
+ buf = xmlBufferCreate();
+ if (buf == NULL) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent parameter error");
+ return(-1);
+ }
+
+ input = xmlNewEntityInputStream(ctxt, entity);
+ if (input == NULL) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent input error");
+ xmlBufferFree(buf);
+ return(-1);
+ }
+
+ /*
+ * Push the entity as the current input, read char by char
+ * saving to the buffer until the end of the entity or an error
+ */
+ xmlPushInput(ctxt, input);
+ GROW;
+ c = CUR_CHAR(l);
+ while ((ctxt->input == input) && (ctxt->input->cur < ctxt->input->end) &&
+ (IS_CHAR(c))) {
+ xmlBufferAdd(buf, ctxt->input->cur, l);
+ if (count++ > 100) {
+ count = 0;
+ GROW;
+ }
+ NEXTL(l);
+ c = CUR_CHAR(l);
+ }
+
+ if ((ctxt->input == input) && (ctxt->input->cur >= ctxt->input->end)) {
+ xmlPopInput(ctxt);
+ } else if (!IS_CHAR(c)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+ "xmlLoadEntityContent: invalid char value %d\n",
+ c);
+ xmlBufferFree(buf);
+ return(-1);
+ }
+ entity->content = buf->content;
+ buf->content = NULL;
+ xmlBufferFree(buf);
+
+ return(0);
+}
+
+/**
* xmlParseStringPEReference:
* @ctxt: an XML parser context
* @str: a pointer to an index in the string
@@ -6842,7 +7091,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
- * reference to itself, either directly or indirectly.
+ * reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
@@ -7818,9 +8067,10 @@ need_complex:
static const xmlChar *
xmlParseAttribute2(xmlParserCtxtPtr ctxt,
- const xmlChar *pref, const xmlChar *elem,
- const xmlChar **prefix, xmlChar **value,
- int *len, int *alloc) {
+ const xmlChar * pref, const xmlChar * elem,
+ const xmlChar ** prefix, xmlChar ** value,
+ int *len, int *alloc)
+{
const xmlChar *name;
xmlChar *val, *internal_val = NULL;
int normalize = 0;
@@ -7829,9 +8079,9 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
GROW;
name = xmlParseQName(ctxt, prefix);
if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "error parsing attribute name\n");
- return(NULL);
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "error parsing attribute name\n");
+ return (NULL);
}
/*
@@ -7841,8 +8091,9 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
int type;
type = (int) (long) xmlHashQLookup2(ctxt->attsSpecial,
- pref, elem, *prefix, name);
- if (type != 0) normalize = 1;
+ pref, elem, *prefix, name);
+ if (type != 0)
+ normalize = 1;
}
/*
@@ -7851,54 +8102,71 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
SKIP_BLANKS;
if (RAW == '=') {
NEXT;
- SKIP_BLANKS;
- val = xmlParseAttValueInternal(ctxt, len, alloc, normalize);
- ctxt->instate = XML_PARSER_CONTENT;
+ SKIP_BLANKS;
+ val = xmlParseAttValueInternal(ctxt, len, alloc, normalize);
+ if (normalize) {
+ /*
+ * Sometimes a second normalisation pass for spaces is needed
+ * but that only happens if charrefs or entities refernces
+ * have been used in the attribute value, i.e. the attribute
+ * value have been extracted in an allocated string already.
+ */
+ if (*alloc) {
+ const xmlChar *val2;
+
+ val2 = xmlAttrNormalizeSpace2(ctxt, val, len);
+ if (val2 != NULL) {
+ xmlFree(val);
+ val = (xmlChar *) val2;
+ }
+ }
+ }
+ ctxt->instate = XML_PARSER_CONTENT;
} else {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
- "Specification mandate value for attribute %s\n", name);
- return(NULL);
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
+ "Specification mandate value for attribute %s\n",
+ name);
+ return (NULL);
}
- if (*prefix == ctxt->str_xml) {
- /*
- * Check that xml:lang conforms to the specification
- * No more registered as an error, just generate a warning now
- * since this was deprecated in XML second edition
- */
- if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
- internal_val = xmlStrndup(val, *len);
- if (!xmlCheckLanguageID(internal_val)) {
- xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
- "Malformed value for xml:lang : %s\n",
- internal_val, NULL);
- }
- }
+ if (*prefix == ctxt->str_xml) {
+ /*
+ * Check that xml:lang conforms to the specification
+ * No more registered as an error, just generate a warning now
+ * since this was deprecated in XML second edition
+ */
+ if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
+ internal_val = xmlStrndup(val, *len);
+ if (!xmlCheckLanguageID(internal_val)) {
+ xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
+ "Malformed value for xml:lang : %s\n",
+ internal_val, NULL);
+ }
+ }
- /*
- * Check that xml:space conforms to the specification
- */
- if (xmlStrEqual(name, BAD_CAST "space")) {
- internal_val = xmlStrndup(val, *len);
- if (xmlStrEqual(internal_val, BAD_CAST "default"))
- *(ctxt->space) = 0;
- else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
- *(ctxt->space) = 1;
- else {
- xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
-"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
- internal_val, NULL);
- }
- }
- if (internal_val) {
- xmlFree(internal_val);
- }
- }
+ /*
+ * Check that xml:space conforms to the specification
+ */
+ if (xmlStrEqual(name, BAD_CAST "space")) {
+ internal_val = xmlStrndup(val, *len);
+ if (xmlStrEqual(internal_val, BAD_CAST "default"))
+ *(ctxt->space) = 0;
+ else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
+ *(ctxt->space) = 1;
+ else {
+ xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
+ "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
+ internal_val, NULL);
+ }
+ }
+ if (internal_val) {
+ xmlFree(internal_val);
+ }
+ }
*value = val;
- return(name);
+ return (name);
}
-
/**
* xmlParseStartTag2:
* @ctxt: an XML parser context
@@ -8770,6 +9038,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
size *= 2;
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
+ xmlFree(buf);
xmlErrMemory(ctxt, NULL);
return(NULL);
}
@@ -8786,11 +9055,11 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
/**
* xmlParseVersionInfo:
* @ctxt: an XML parser context
- *
+ *
* parse the XML version.
*
* [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
- *
+ *
* [25] Eq ::= S? '=' S?
*
* Returns the version string, e.g. "1.0"
@@ -10170,7 +10439,20 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->input->cur += tmp;
goto encoding_error;
}
- if ((ctxt->sax != NULL) && (base > 0) &&
+ if ((ctxt->sax != NULL) && (base == 0) &&
+ (ctxt->sax->cdataBlock != NULL) &&
+ (!ctxt->disableSAX)) {
+ /*
+ * Special case to provide identical behaviour
+ * between pull and push parsers on enpty CDATA
+ * sections
+ */
+ if ((ctxt->input->cur - ctxt->input->base >= 9) &&
+ (!strncmp((const char *)&ctxt->input->cur[-9],
+ "<![CDATA[", 9)))
+ ctxt->sax->cdataBlock(ctxt->userData,
+ BAD_CAST "", 0);
+ } else if ((ctxt->sax != NULL) && (base > 0) &&
(!ctxt->disableSAX)) {
if (ctxt->sax->cdataBlock != NULL)
ctxt->sax->cdataBlock(ctxt->userData,
@@ -12012,13 +12294,14 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
*
* Returns 0 if the chunk is well balanced, -1 in case of args problem and
* the parser error code otherwise
- *
+ *
* In case recover is set to 1, the nodelist will not be empty even if
- * the parsed chunk is not well balanced.
+ * the parsed chunk is not well balanced, assuming the parsing succeeded to
+ * some extent.
*/
int
xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
- void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst,
+ void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst,
int recover) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
@@ -12370,7 +12653,6 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
int recovery, void *data) {
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
- char *directory = NULL;
xmlInitParser();
@@ -12388,10 +12670,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
ctxt->_private = data;
}
- if ((ctxt->directory == NULL) && (directory == NULL))
- directory = xmlParserGetDirectory(filename);
- if ((ctxt->directory == NULL) && (directory != NULL))
- ctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
+ if (ctxt->directory == NULL)
+ ctxt->directory = xmlParserGetDirectory(filename);
ctxt->recovery = recovery;
@@ -12444,9 +12724,10 @@ xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
* @cur: a pointer to an array of xmlChar
*
* parse an XML in-memory document and build a tree.
- * In the case the document is not Well Formed, a tree is built anyway
- *
- * Returns the resulting document tree
+ * In the case the document is not Well Formed, a attempt to build a
+ * tree is tried anyway
+ *
+ * Returns the resulting document tree or NULL in case of failure
*/
xmlDocPtr
@@ -12476,9 +12757,10 @@ xmlParseFile(const char *filename) {
*
* parse an XML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
- * In the case the document is not Well Formed, a tree is built anyway
+ * In the case the document is not Well Formed, it attempts to build
+ * a tree anyway
*
- * Returns the resulting document tree
+ * Returns the resulting document tree or NULL in case of failure
*/
xmlDocPtr
@@ -12720,9 +13002,10 @@ xmlDocPtr xmlParseMemory(const char *buffer, int size) {
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
- * In the case the document is not Well Formed, a tree is built anyway
- *
- * Returns the resulting document tree
+ * In the case the document is not Well Formed, an attempt to
+ * build a tree is tried anyway
+ *
+ * Returns the resulting document tree or NULL in case of error
*/
xmlDocPtr xmlRecoverMemory(const char *buffer, int size) {
@@ -12958,12 +13241,15 @@ xmlInitParser(void) {
/**
* xmlCleanupParser:
*
- * Cleanup function for the XML library. It tries to reclaim all
- * parsing related global memory allocated for the library processing.
- * It doesn't deallocate any document related memory. Calling this
- * function should not prevent reusing the library but one should
- * call xmlCleanupParser() only when the process has
- * finished using the library or XML document built with it.
+ * This function name is somewhat misleading. It does not clean up
+ * parser state, it cleans up memory allocated by the library itself.
+ * It is a cleanup function for the XML library. It tries to reclaim all
+ * related global memory allocated for the library processing.
+ * It doesn't deallocate any document related memory. One should
+ * call xmlCleanupParser() only when the process has finished using
+ * the library and all XML/HTML documents built with it.
+ * See also xmlInitParser() which has the opposite function of preparing
+ * the library for operations.
*/
void
diff --git a/third_party/libxml/schematron.c b/third_party/libxml/schematron.c
index 146ffc9..81f4704 100644
--- a/third_party/libxml/schematron.c
+++ b/third_party/libxml/schematron.c
@@ -168,6 +168,12 @@ struct _xmlSchematronValidCtxt {
xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */
xmlOutputCloseCallback ioclose;
void *ioctx;
+
+ /* error reporting data */
+ void *userData; /* user specific data block */
+ xmlSchematronValidityErrorFunc error;/* the callback in case of errors */
+ xmlSchematronValidityWarningFunc warning;/* callback in case of warning */
+ xmlStructuredErrorFunc serror; /* the structured function */
};
struct _xmlSchematronParserCtxt {
@@ -193,12 +199,11 @@ struct _xmlSchematronParserCtxt {
int maxIncludes; /* size of the array */
xmlNodePtr *includes; /* the array of includes */
- /* error rreporting data */
+ /* error reporting data */
void *userData; /* user specific data block */
xmlSchematronValidityErrorFunc error;/* the callback in case of errors */
xmlSchematronValidityWarningFunc warning;/* callback in case of warning */
xmlStructuredErrorFunc serror; /* the structured function */
-
};
#define XML_STRON_CTXT_PARSER 1
@@ -1361,7 +1366,7 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
*/
static void
xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
- xmlSchematronTestPtr test, xmlNodePtr cur, int success) {
+ xmlSchematronTestPtr test, xmlNodePtr cur, xmlSchematronPatternPtr pattern, int success) {
if ((ctxt == NULL) || (cur == NULL) || (test == NULL))
return;
/* if quiet and not SVRL report only failures */
@@ -1392,18 +1397,41 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
report = xmlSchematronFormatReport(ctxt, test->node, cur);
if (report == NULL) {
if (test->type == XML_SCHEMATRON_ASSERT) {
- snprintf(msg, 999, "%s line %ld: node failed assert\n",
- (const char *) path, line);
+ report = xmlStrdup((const xmlChar *) "node failed assert");
} else {
- snprintf(msg, 999, "%s line %ld: node failed report\n",
- (const char *) path, line);
+ report = xmlStrdup((const xmlChar *) "node failed report");
+ }
}
- } else {
snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path,
line, (const char *) report);
- xmlFree((char *) report);
+
+ if (ctxt->flags & XML_SCHEMATRON_OUT_ERROR) {
+ xmlStructuredErrorFunc schannel = NULL;
+ xmlGenericErrorFunc channel = NULL;
+ void *data = NULL;
+
+ if (ctxt != NULL) {
+ if (ctxt->serror != NULL)
+ schannel = ctxt->serror;
+ else
+ channel = ctxt->error;
+ data = ctxt->userData;
}
+
+ __xmlRaiseError(schannel, channel, data,
+ NULL, cur, XML_FROM_SCHEMATRONV,
+ (test->type == XML_SCHEMATRON_ASSERT)?XML_SCHEMATRONV_ASSERT:XML_SCHEMATRONV_REPORT,
+ XML_ERR_ERROR, NULL, line,
+ (pattern == NULL)?NULL:((const char *) pattern->name),
+ (const char *) path,
+ (const char *) report, 0, 0,
+ msg);
+ } else {
xmlSchematronReportOutput(ctxt, cur, &msg[0]);
+ }
+
+ xmlFree((char *) report);
+
if ((path != NULL) && (path != (xmlChar *) cur->name))
xmlFree(path);
}
@@ -1421,7 +1449,7 @@ xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
xmlSchematronPatternPtr pattern) {
if ((ctxt == NULL) || (pattern == NULL))
return;
- if (ctxt->flags & XML_SCHEMATRON_OUT_QUIET)
+ if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRON_OUT_ERROR)) /* Error gives pattern name as part of error */
return;
if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
TODO
@@ -1443,6 +1471,26 @@ xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
************************************************************************/
/**
+ * xmlSchematronSetValidStructuredErrors:
+ * @ctxt: a Schematron validation context
+ * @serror: the structured error function
+ * @ctx: the functions context
+ *
+ * Set the structured error callback
+ */
+void
+xmlSchematronSetValidStructuredErrors(xmlSchematronValidCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror, void *ctx)
+{
+ if (ctxt == NULL)
+ return;
+ ctxt->serror = serror;
+ ctxt->error = NULL;
+ ctxt->warning = NULL;
+ ctxt->userData = ctx;
+}
+
+/**
* xmlSchematronNewValidCtxt:
* @schema: a precompiled XML Schematrons
* @options: a set of xmlSchematronValidOptions
@@ -1550,7 +1598,7 @@ xmlSchematronNextNode(xmlNodePtr cur) {
*/
static int
xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
- xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur)
+ xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematronPatternPtr pattern)
{
xmlXPathObjectPtr ret;
int failed;
@@ -1597,7 +1645,7 @@ xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
else if ((!failed) && (test->type == XML_SCHEMATRON_REPORT))
ctxt->nberrors++;
- xmlSchematronReportSuccess(ctxt, test, cur, !failed);
+ xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
return(!failed);
}
@@ -1643,7 +1691,7 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
if (xmlPatternMatch(rule->pattern, cur) == 1) {
test = rule->tests;
while (test != NULL) {
- xmlSchematronRunTest(ctxt, test, instance, cur);
+ xmlSchematronRunTest(ctxt, test, instance, cur, rule->pattern);
test = test->next;
}
}
@@ -1674,7 +1722,7 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
if (xmlPatternMatch(rule->pattern, cur) == 1) {
test = rule->tests;
while (test != NULL) {
- xmlSchematronRunTest(ctxt, test, instance, cur);
+ xmlSchematronRunTest(ctxt, test, instance, cur, pattern);
test = test->next;
}
}
diff --git a/third_party/libxml/testModule.c b/third_party/libxml/testModule.c
index fecc852..8293c45 100644
--- a/third_party/libxml/testModule.c
+++ b/third_party/libxml/testModule.c
@@ -29,6 +29,15 @@
#define MODULE_PATH ".libs"
#endif
+/* Used for SCO Openserver*/
+#ifndef PATH_MAX
+#ifdef _POSIX_PATH_MAX
+#define PATH_MAX _POSIX_PATH_MAX
+#else
+#define PATH_MAX 4096
+#endif
+#endif
+
typedef int (*hello_world_t)(void);
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
diff --git a/third_party/libxml/testRegexp.c b/third_party/libxml/testRegexp.c
index d5228b3..626536e 100644
--- a/third_party/libxml/testRegexp.c
+++ b/third_party/libxml/testRegexp.c
@@ -290,6 +290,9 @@ int main(int argc, char **argv) {
if (argv[i][0] != '-')
continue;
+ if (!strcmp(argv[i], "--"))
+ break;
+
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) {
debug++;
} else if ((!strcmp(argv[i], "-repeat")) ||
@@ -322,10 +325,15 @@ int main(int argc, char **argv) {
#endif
testRegexpFile(filename);
} else {
+ int data = 0;
#ifdef LIBXML_EXPR_ENABLED
+
if (use_exp) {
for (i = 1; i < argc ; i++) {
- if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
+ if (strcmp(argv[i], "--") == 0)
+ data = 1;
+ else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) ||
+ (data == 1)) {
if (pattern == NULL) {
pattern = argv[i];
printf("Testing expr %s:\n", pattern);
@@ -342,13 +350,18 @@ int main(int argc, char **argv) {
}
}
}
- if (expr != NULL)
+ if (expr != NULL) {
xmlExpFree(ctxt, expr);
+ expr = NULL;
+ }
} else
#endif
{
for (i = 1; i < argc ; i++) {
- if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
+ if (strcmp(argv[i], "--") == 0)
+ data = 1;
+ else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) ||
+ (data == 1)) {
if (pattern == NULL) {
pattern = argv[i];
printf("Testing %s:\n", pattern);
diff --git a/third_party/libxml/testapi.c b/third_party/libxml/testapi.c
index af71ac2..8a50e88 100644
--- a/third_party/libxml/testapi.c
+++ b/third_party/libxml/testapi.c
@@ -18024,6 +18024,16 @@ static void des_xmlSchematronValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchematron
static int
+test_xmlSchematronSetValidStructuredErrors(void) {
+ int test_ret = 0;
+
+
+ /* missing type support */
+ return(test_ret);
+}
+
+
+static int
test_xmlSchematronValidateDoc(void) {
int test_ret = 0;
@@ -18067,12 +18077,13 @@ static int
test_schematron(void) {
int test_ret = 0;
- if (quiet == 0) printf("Testing schematron : 1 of 9 functions ...\n");
+ if (quiet == 0) printf("Testing schematron : 1 of 10 functions ...\n");
test_ret += test_xmlSchematronNewDocParserCtxt();
test_ret += test_xmlSchematronNewMemParserCtxt();
test_ret += test_xmlSchematronNewParserCtxt();
test_ret += test_xmlSchematronNewValidCtxt();
test_ret += test_xmlSchematronParse();
+ test_ret += test_xmlSchematronSetValidStructuredErrors();
test_ret += test_xmlSchematronValidateDoc();
if (test_ret != 0)
diff --git a/third_party/libxml/threads.c b/third_party/libxml/threads.c
index d5a177d..6481b40 100644
--- a/third_party/libxml/threads.c
+++ b/third_party/libxml/threads.c
@@ -101,8 +101,8 @@ struct _xmlMutex {
#elif defined HAVE_WIN32_THREADS
HANDLE mutex;
#elif defined HAVE_BEOS_THREADS
- sem_id sem;
- thread_id tid;
+ sem_id sem;
+ thread_id tid;
#else
int empty;
#endif
@@ -114,21 +114,22 @@ struct _xmlMutex {
struct _xmlRMutex {
#ifdef HAVE_PTHREAD_H
pthread_mutex_t lock;
- unsigned int held;
- unsigned int waiters;
- pthread_t tid;
- pthread_cond_t cv;
+ unsigned int held;
+ unsigned int waiters;
+ pthread_t tid;
+ pthread_cond_t cv;
#elif defined HAVE_WIN32_THREADS
CRITICAL_SECTION cs;
unsigned int count;
#elif defined HAVE_BEOS_THREADS
- xmlMutexPtr lock;
- thread_id tid;
- int32 count;
+ xmlMutexPtr lock;
+ thread_id tid;
+ int32 count;
#else
int empty;
#endif
};
+
/*
* This module still has some internal static data.
* - xmlLibraryLock a global lock
@@ -136,8 +137,8 @@ struct _xmlRMutex {
*/
#ifdef HAVE_PTHREAD_H
-static pthread_key_t globalkey;
-static pthread_t mainthread;
+static pthread_key_t globalkey;
+static pthread_t mainthread;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
#elif defined HAVE_WIN32_THREADS
@@ -148,12 +149,12 @@ static __declspec(thread) int tlstate_inited = 0;
static DWORD globalkey = TLS_OUT_OF_INDEXES;
#endif /* HAVE_COMPILER_TLS */
static DWORD mainthread;
-static struct
-{
+static struct {
DWORD done;
DWORD control;
-} run_once = { 0, 0 };
+} run_once = { 0, 0};
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
+
/* endif HAVE_WIN32_THREADS */
#elif defined HAVE_BEOS_THREADS
int32 globalkey = 0;
@@ -163,7 +164,8 @@ static int32 global_init_lock = -1;
static vint32 global_init_count = 0;
#endif
-static xmlRMutexPtr xmlLibraryLock = NULL;
+static xmlRMutexPtr xmlLibraryLock = NULL;
+
#ifdef LIBXML_THREAD_ENABLED
static void xmlOnceInit(void);
#endif
@@ -185,15 +187,15 @@ xmlNewMutex(void)
return (NULL);
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_init(&tok->lock, NULL);
+ pthread_mutex_init(&tok->lock, NULL);
#elif defined HAVE_WIN32_THREADS
tok->mutex = CreateMutex(NULL, FALSE, NULL);
#elif defined HAVE_BEOS_THREADS
- if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
- free(tok);
- return NULL;
- }
- tok->tid = -1;
+ if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
+ free(tok);
+ return NULL;
+ }
+ tok->tid = -1;
#endif
return (tok);
}
@@ -208,15 +210,16 @@ xmlNewMutex(void)
void
xmlFreeMutex(xmlMutexPtr tok)
{
- if (tok == NULL) return;
+ if (tok == NULL)
+ return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_destroy(&tok->lock);
+ pthread_mutex_destroy(&tok->lock);
#elif defined HAVE_WIN32_THREADS
CloseHandle(tok->mutex);
#elif defined HAVE_BEOS_THREADS
- delete_sem(tok->sem);
+ delete_sem(tok->sem);
#endif
free(tok);
}
@@ -234,17 +237,18 @@ xmlMutexLock(xmlMutexPtr tok)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_lock(&tok->lock);
+ pthread_mutex_lock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
WaitForSingleObject(tok->mutex, INFINITE);
#elif defined HAVE_BEOS_THREADS
- if (acquire_sem(tok->sem) != B_NO_ERROR) {
+ if (acquire_sem(tok->sem) != B_NO_ERROR) {
#ifdef DEBUG_THREADS
- xmlGenericError(xmlGenericErrorContext, "xmlMutexLock():BeOS:Couldn't aquire semaphore\n");
- exit();
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlMutexLock():BeOS:Couldn't aquire semaphore\n");
+ exit();
#endif
- }
- tok->tid = find_thread(NULL);
+ }
+ tok->tid = find_thread(NULL);
#endif
}
@@ -262,14 +266,14 @@ xmlMutexUnlock(xmlMutexPtr tok)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_unlock(&tok->lock);
+ pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
ReleaseMutex(tok->mutex);
#elif defined HAVE_BEOS_THREADS
- if (tok->tid == find_thread(NULL)) {
- tok->tid = -1;
- release_sem(tok->sem);
- }
+ if (tok->tid == find_thread(NULL)) {
+ tok->tid = -1;
+ release_sem(tok->sem);
+ }
#endif
}
@@ -292,20 +296,20 @@ xmlNewRMutex(void)
return (NULL);
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0) {
- pthread_mutex_init(&tok->lock, NULL);
- tok->held = 0;
- tok->waiters = 0;
- pthread_cond_init(&tok->cv, NULL);
+ pthread_mutex_init(&tok->lock, NULL);
+ tok->held = 0;
+ tok->waiters = 0;
+ pthread_cond_init(&tok->cv, NULL);
}
#elif defined HAVE_WIN32_THREADS
InitializeCriticalSection(&tok->cs);
tok->count = 0;
#elif defined HAVE_BEOS_THREADS
- if ((tok->lock = xmlNewMutex()) == NULL) {
- free(tok);
- return NULL;
- }
- tok->count = 0;
+ if ((tok->lock = xmlNewMutex()) == NULL) {
+ free(tok);
+ return NULL;
+ }
+ tok->count = 0;
#endif
return (tok);
}
@@ -324,13 +328,13 @@ xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0) {
- pthread_mutex_destroy(&tok->lock);
- pthread_cond_destroy(&tok->cv);
+ pthread_mutex_destroy(&tok->lock);
+ pthread_cond_destroy(&tok->cv);
}
#elif defined HAVE_WIN32_THREADS
DeleteCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
- xmlFreeMutex(tok->lock);
+ xmlFreeMutex(tok->lock);
#endif
free(tok);
}
@@ -370,13 +374,13 @@ xmlRMutexLock(xmlRMutexPtr tok)
EnterCriticalSection(&tok->cs);
++tok->count;
#elif defined HAVE_BEOS_THREADS
- if (tok->lock->tid == find_thread(NULL)) {
- tok->count++;
- return;
- } else {
- xmlMutexLock(tok->lock);
- tok->count = 1;
- }
+ if (tok->lock->tid == find_thread(NULL)) {
+ tok->count++;
+ return;
+ } else {
+ xmlMutexLock(tok->lock);
+ tok->count = 1;
+ }
#endif
}
@@ -394,7 +398,7 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded == 0)
return;
-
+
pthread_mutex_lock(&tok->lock);
tok->held--;
if (tok->held == 0) {
@@ -404,16 +408,16 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
}
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
- if (!--tok->count)
- LeaveCriticalSection(&tok->cs);
+ if (!--tok->count)
+ LeaveCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
- if (tok->lock->tid == find_thread(NULL)) {
- tok->count--;
- if (tok->count == 0) {
- xmlMutexUnlock(tok->lock);
- }
- return;
- }
+ if (tok->lock->tid == find_thread(NULL)) {
+ tok->count--;
+ if (tok->count == 0) {
+ xmlMutexUnlock(tok->lock);
+ }
+ return;
+ }
#endif
}
@@ -435,23 +439,29 @@ __xmlGlobalInitMutexLock(void)
/* Create a new critical section */
if (global_init_lock == NULL) {
- cs = malloc(sizeof(CRITICAL_SECTION));
- InitializeCriticalSection(cs);
+ cs = malloc(sizeof(CRITICAL_SECTION));
+ if (cs == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGlobalInitMutexLock: out of memory\n");
+ return;
+ }
+ InitializeCriticalSection(cs);
- /* Swap it into the global_init_lock */
+ /* Swap it into the global_init_lock */
#ifdef InterlockedCompareExchangePointer
- InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
-#else /* Use older void* version */
- InterlockedCompareExchange((void **)&global_init_lock, (void *)cs, NULL);
+ InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
+#else /* Use older void* version */
+ InterlockedCompareExchange((void **) &global_init_lock,
+ (void *) cs, NULL);
#endif /* InterlockedCompareExchangePointer */
- /* If another thread successfully recorded its critical
- * section in the global_init_lock then discard the one
- * allocated by this thread. */
- if (global_init_lock != cs) {
- DeleteCriticalSection(cs);
- free(cs);
- }
+ /* If another thread successfully recorded its critical
+ * section in the global_init_lock then discard the one
+ * allocated by this thread. */
+ if (global_init_lock != cs) {
+ DeleteCriticalSection(cs);
+ free(cs);
+ }
}
/* Lock the chosen critical section */
@@ -463,25 +473,26 @@ __xmlGlobalInitMutexLock(void)
sem = create_sem(1, "xmlGlobalinitMutex");
while (global_init_lock == -1) {
- if (atomic_add(&global_init_count, 1) == 0) {
- global_init_lock = sem;
- } else {
- snooze(1);
- atomic_add(&global_init_count, -1);
- }
+ if (atomic_add(&global_init_count, 1) == 0) {
+ global_init_lock = sem;
+ } else {
+ snooze(1);
+ atomic_add(&global_init_count, -1);
+ }
}
/* If another thread successfully recorded its critical
* section in the global_init_lock then discard the one
* allocated by this thread. */
if (global_init_lock != sem)
- delete_sem(sem);
+ delete_sem(sem);
/* Acquire the chosen semaphore */
if (acquire_sem(global_init_lock) != B_NO_ERROR) {
#ifdef DEBUG_THREADS
- xmlGenericError(xmlGenericErrorContext, "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n");
- exit();
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n");
+ exit();
#endif
}
#endif
@@ -493,7 +504,9 @@ __xmlGlobalInitMutexUnlock(void)
#ifdef HAVE_PTHREAD_H
pthread_mutex_unlock(&global_init_lock);
#elif defined HAVE_WIN32_THREADS
- LeaveCriticalSection(global_init_lock);
+ if (global_init_lock != NULL) {
+ LeaveCriticalSection(global_init_lock);
+ }
#elif defined HAVE_BEOS_THREADS
release_sem(global_init_lock);
#endif
@@ -505,14 +518,14 @@ __xmlGlobalInitMutexUnlock(void)
* Makes sure that the global initialization mutex is destroyed before
* application termination.
*/
-void __xmlGlobalInitMutexDestroy(void)
+void
+__xmlGlobalInitMutexDestroy(void)
{
#if defined HAVE_WIN32_THREADS
- if (global_init_lock != NULL)
- {
- DeleteCriticalSection(global_init_lock);
- free(global_init_lock);
- global_init_lock = NULL;
+ if (global_init_lock != NULL) {
+ DeleteCriticalSection(global_init_lock);
+ free(global_init_lock);
+ global_init_lock = NULL;
}
#endif
}
@@ -527,6 +540,7 @@ void __xmlGlobalInitMutexDestroy(void)
#ifdef xmlLastError
#undef xmlLastError
#endif
+
/**
* xmlFreeGlobalState:
* @state: a thread global state
@@ -557,10 +571,13 @@ static xmlGlobalStatePtr
xmlNewGlobalState(void)
{
xmlGlobalState *gs;
-
+
gs = malloc(sizeof(xmlGlobalState));
- if (gs == NULL)
- return(NULL);
+ if (gs == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGetGlobalState: out of memory\n");
+ return (NULL);
+ }
memset(gs, 0, sizeof(xmlGlobalState));
xmlInitializeGlobalState(gs);
@@ -572,15 +589,16 @@ xmlNewGlobalState(void)
#ifdef HAVE_WIN32_THREADS
#if !defined(HAVE_COMPILER_TLS)
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
-typedef struct _xmlGlobalStateCleanupHelperParams
-{
+typedef struct _xmlGlobalStateCleanupHelperParams {
HANDLE thread;
void *memory;
} xmlGlobalStateCleanupHelperParams;
-static void XMLCDECL xmlGlobalStateCleanupHelper (void *p)
+static void XMLCDECL
+xmlGlobalStateCleanupHelper(void *p)
{
- xmlGlobalStateCleanupHelperParams *params = (xmlGlobalStateCleanupHelperParams *) p;
+ xmlGlobalStateCleanupHelperParams *params =
+ (xmlGlobalStateCleanupHelperParams *) p;
WaitForSingleObject(params->thread, INFINITE);
CloseHandle(params->thread);
xmlFreeGlobalState(params->memory);
@@ -589,14 +607,13 @@ static void XMLCDECL xmlGlobalStateCleanupHelper (void *p)
}
#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
-typedef struct _xmlGlobalStateCleanupHelperParams
-{
+typedef struct _xmlGlobalStateCleanupHelperParams {
void *memory;
- struct _xmlGlobalStateCleanupHelperParams * prev;
- struct _xmlGlobalStateCleanupHelperParams * next;
+ struct _xmlGlobalStateCleanupHelperParams *prev;
+ struct _xmlGlobalStateCleanupHelperParams *next;
} xmlGlobalStateCleanupHelperParams;
-static xmlGlobalStateCleanupHelperParams * cleanup_helpers_head = NULL;
+static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
static CRITICAL_SECTION cleanup_helpers_cs;
#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
@@ -604,17 +621,20 @@ static CRITICAL_SECTION cleanup_helpers_cs;
#endif /* HAVE_WIN32_THREADS */
#if defined HAVE_BEOS_THREADS
+
/**
* xmlGlobalStateCleanup:
* @data: unused parameter
*
* Used for Beos only
*/
-void xmlGlobalStateCleanup(void *data)
+void
+xmlGlobalStateCleanup(void *data)
{
- void *globalval = tls_get(globalkey);
- if (globalval != NULL)
- xmlFreeGlobalState(globalval);
+ void *globalval = tls_get(globalkey);
+
+ if (globalval != NULL)
+ xmlFreeGlobalState(globalval);
}
#endif
@@ -632,13 +652,15 @@ xmlGetGlobalState(void)
xmlGlobalState *globalval;
if (libxml_is_threaded == 0)
- return(NULL);
+ return (NULL);
pthread_once(&once_control, xmlOnceInit);
if ((globalval = (xmlGlobalState *)
- pthread_getspecific(globalkey)) == NULL) {
+ pthread_getspecific(globalkey)) == NULL) {
xmlGlobalState *tsd = xmlNewGlobalState();
+ if (tsd == NULL)
+ return(NULL);
pthread_setspecific(globalkey, tsd);
return (tsd);
@@ -647,43 +669,53 @@ xmlGetGlobalState(void)
#elif defined HAVE_WIN32_THREADS
#if defined(HAVE_COMPILER_TLS)
if (!tlstate_inited) {
- tlstate_inited = 1;
- xmlInitializeGlobalState(&tlstate);
+ tlstate_inited = 1;
+ xmlInitializeGlobalState(&tlstate);
}
return &tlstate;
#else /* HAVE_COMPILER_TLS */
xmlGlobalState *globalval;
- xmlGlobalStateCleanupHelperParams * p;
+ xmlGlobalStateCleanupHelperParams *p;
xmlOnceInit();
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
- globalval = (xmlGlobalState *)TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) TlsGetValue(globalkey);
#else
- p = (xmlGlobalStateCleanupHelperParams*)TlsGetValue(globalkey);
- globalval = (xmlGlobalState *)(p ? p->memory : NULL);
+ p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) (p ? p->memory : NULL);
#endif
if (globalval == NULL) {
- xmlGlobalState *tsd = xmlNewGlobalState();
- p = (xmlGlobalStateCleanupHelperParams *) malloc(sizeof(xmlGlobalStateCleanupHelperParams));
- p->memory = tsd;
+ xmlGlobalState *tsd = xmlNewGlobalState();
+
+ if (tsd == NULL)
+ return(NULL);
+ p = (xmlGlobalStateCleanupHelperParams *)
+ malloc(sizeof(xmlGlobalStateCleanupHelperParams));
+ if (p == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGetGlobalState: out of memory\n");
+ return(NULL);
+ }
+ p->memory = tsd;
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
- GetCurrentProcess(), &p->thread, 0, TRUE, DUPLICATE_SAME_ACCESS);
- TlsSetValue(globalkey, tsd);
- _beginthread(xmlGlobalStateCleanupHelper, 0, p);
+ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
+ GetCurrentProcess(), &p->thread, 0, TRUE,
+ DUPLICATE_SAME_ACCESS);
+ TlsSetValue(globalkey, tsd);
+ _beginthread(xmlGlobalStateCleanupHelper, 0, p);
#else
- EnterCriticalSection(&cleanup_helpers_cs);
+ EnterCriticalSection(&cleanup_helpers_cs);
if (cleanup_helpers_head != NULL) {
cleanup_helpers_head->prev = p;
}
- p->next = cleanup_helpers_head;
- p->prev = NULL;
- cleanup_helpers_head = p;
- TlsSetValue(globalkey, p);
- LeaveCriticalSection(&cleanup_helpers_cs);
+ p->next = cleanup_helpers_head;
+ p->prev = NULL;
+ cleanup_helpers_head = p;
+ TlsSetValue(globalkey, p);
+ LeaveCriticalSection(&cleanup_helpers_cs);
#endif
- return (tsd);
+ return (tsd);
}
return (globalval);
#endif /* HAVE_COMPILER_TLS */
@@ -692,9 +724,10 @@ xmlGetGlobalState(void)
xmlOnceInit();
- if ((globalval = (xmlGlobalState *)
- tls_get(globalkey)) == NULL) {
+ if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) {
xmlGlobalState *tsd = xmlNewGlobalState();
+ if (tsd == NULL)
+ return (NULL);
tls_set(globalkey, tsd);
on_exit_thread(xmlGlobalStateCleanup, NULL);
@@ -702,7 +735,7 @@ xmlGetGlobalState(void)
}
return (globalval);
#else
- return(NULL);
+ return (NULL);
#endif
}
@@ -724,14 +757,14 @@ xmlGetThreadId(void)
{
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded == 0)
- return(0);
- return((int) pthread_self());
+ return (0);
+ return ((int) pthread_self());
#elif defined HAVE_WIN32_THREADS
return GetCurrentThreadId();
#elif defined HAVE_BEOS_THREADS
- return find_thread(NULL);
+ return find_thread(NULL);
#else
- return((int) 0);
+ return ((int) 0);
#endif
}
@@ -749,25 +782,25 @@ xmlIsMainThread(void)
if (libxml_is_threaded == -1)
xmlInitThreads();
if (libxml_is_threaded == 0)
- return(1);
+ return (1);
pthread_once(&once_control, xmlOnceInit);
#elif defined HAVE_WIN32_THREADS
- xmlOnceInit ();
+ xmlOnceInit();
#elif defined HAVE_BEOS_THREADS
xmlOnceInit();
#endif
-
+
#ifdef DEBUG_THREADS
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
#endif
#ifdef HAVE_PTHREAD_H
- return(mainthread == pthread_self());
+ return (mainthread == pthread_self());
#elif defined HAVE_WIN32_THREADS
- return(mainthread == GetCurrentThreadId ());
+ return (mainthread == GetCurrentThreadId());
#elif defined HAVE_BEOS_THREADS
- return(mainthread == find_thread(NULL));
+ return (mainthread == find_thread(NULL));
#else
- return(1);
+ return (1);
#endif
}
@@ -819,24 +852,25 @@ xmlInitThreads(void)
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded == -1) {
if ((pthread_once != NULL) &&
- (pthread_getspecific != NULL) &&
- (pthread_setspecific != NULL) &&
- (pthread_key_create != NULL) &&
- (pthread_mutex_init != NULL) &&
- (pthread_mutex_destroy != NULL) &&
- (pthread_mutex_lock != NULL) &&
- (pthread_mutex_unlock != NULL) &&
- (pthread_cond_init != NULL) &&
- (pthread_equal != NULL) &&
- (pthread_self != NULL) &&
- (pthread_key_create != NULL) &&
- (pthread_cond_signal != NULL)) {
- libxml_is_threaded = 1;
+ (pthread_getspecific != NULL) &&
+ (pthread_setspecific != NULL) &&
+ (pthread_key_create != NULL) &&
+ (pthread_mutex_init != NULL) &&
+ (pthread_mutex_destroy != NULL) &&
+ (pthread_mutex_lock != NULL) &&
+ (pthread_mutex_unlock != NULL) &&
+ (pthread_cond_init != NULL) &&
+ (pthread_equal != NULL) &&
+ (pthread_self != NULL) &&
+ (pthread_cond_signal != NULL)) {
+ libxml_is_threaded = 1;
+
/* fprintf(stderr, "Running multithreaded\n"); */
- } else {
+ } else {
+
/* fprintf(stderr, "Running without multithread\n"); */
- libxml_is_threaded = 0;
- }
+ libxml_is_threaded = 0;
+ }
}
#endif
}
@@ -855,25 +889,28 @@ xmlCleanupThreads(void)
#endif
#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
if (globalkey != TLS_OUT_OF_INDEXES) {
- xmlGlobalStateCleanupHelperParams * p;
- EnterCriticalSection(&cleanup_helpers_cs);
- p = cleanup_helpers_head;
- while (p != NULL) {
- xmlGlobalStateCleanupHelperParams * temp = p;
- p = p->next;
- xmlFreeGlobalState(temp->memory);
- free(temp);
- }
- cleanup_helpers_head = 0;
- LeaveCriticalSection(&cleanup_helpers_cs);
- TlsFree(globalkey);
- globalkey = TLS_OUT_OF_INDEXES;
+ xmlGlobalStateCleanupHelperParams *p;
+
+ EnterCriticalSection(&cleanup_helpers_cs);
+ p = cleanup_helpers_head;
+ while (p != NULL) {
+ xmlGlobalStateCleanupHelperParams *temp = p;
+
+ p = p->next;
+ xmlFreeGlobalState(temp->memory);
+ free(temp);
+ }
+ cleanup_helpers_head = 0;
+ LeaveCriticalSection(&cleanup_helpers_cs);
+ TlsFree(globalkey);
+ globalkey = TLS_OUT_OF_INDEXES;
}
DeleteCriticalSection(&cleanup_helpers_cs);
#endif
}
#ifdef LIBXML_THREAD_ENABLED
+
/**
* xmlOnceInit
*
@@ -884,7 +921,8 @@ xmlCleanupThreads(void)
* details.
*/
static void
-xmlOnceInit(void) {
+xmlOnceInit(void)
+{
#ifdef HAVE_PTHREAD_H
(void) pthread_key_create(&globalkey, xmlFreeGlobalState);
mainthread = pthread_self();
@@ -892,15 +930,13 @@ xmlOnceInit(void) {
#if defined(HAVE_WIN32_THREADS)
if (!run_once.done) {
- if (InterlockedIncrement(&run_once.control) == 1)
- {
+ if (InterlockedIncrement(&run_once.control) == 1) {
#if !defined(HAVE_COMPILER_TLS)
globalkey = TlsAlloc();
#endif
mainthread = GetCurrentThreadId();
run_once.done = 1;
- }
- else {
+ } else {
/* Another thread is working; give up our slice and
* wait until they're done. */
while (!run_once.done)
@@ -910,12 +946,12 @@ xmlOnceInit(void) {
#endif
#ifdef HAVE_BEOS_THREADS
- if (atomic_add(&run_once_init, 1) == 0) {
- globalkey = tls_allocate();
- tls_set(globalkey, NULL);
- mainthread = find_thread(NULL);
- } else
- atomic_add(&run_once_init, -1);
+ if (atomic_add(&run_once_init, 1) == 0) {
+ globalkey = tls_allocate();
+ tls_set(globalkey, NULL);
+ mainthread = find_thread(NULL);
+ } else
+ atomic_add(&run_once_init, -1);
#endif
}
#endif
@@ -933,36 +969,38 @@ xmlOnceInit(void) {
*/
#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
#if defined(LIBXML_STATIC_FOR_DLL)
-BOOL XMLCALL xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL XMLCALL
+xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#else
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#endif
{
- switch(fdwReason) {
- case DLL_THREAD_DETACH:
- if (globalkey != TLS_OUT_OF_INDEXES) {
- xmlGlobalState *globalval = NULL;
- xmlGlobalStateCleanupHelperParams * p =
- (xmlGlobalStateCleanupHelperParams*)TlsGetValue(globalkey);
- globalval = (xmlGlobalState *)(p ? p->memory : NULL);
- if (globalval) {
- xmlFreeGlobalState(globalval);
- TlsSetValue(globalkey,NULL);
+ switch (fdwReason) {
+ case DLL_THREAD_DETACH:
+ if (globalkey != TLS_OUT_OF_INDEXES) {
+ xmlGlobalState *globalval = NULL;
+ xmlGlobalStateCleanupHelperParams *p =
+ (xmlGlobalStateCleanupHelperParams *)
+ TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) (p ? p->memory : NULL);
+ if (globalval) {
+ xmlFreeGlobalState(globalval);
+ TlsSetValue(globalkey, NULL);
+ }
+ if (p) {
+ EnterCriticalSection(&cleanup_helpers_cs);
+ if (p == cleanup_helpers_head)
+ cleanup_helpers_head = p->next;
+ else
+ p->prev->next = p->next;
+ if (p->next != NULL)
+ p->next->prev = p->prev;
+ LeaveCriticalSection(&cleanup_helpers_cs);
+ free(p);
+ }
}
- if (p)
- {
- EnterCriticalSection(&cleanup_helpers_cs);
- if (p == cleanup_helpers_head)
- cleanup_helpers_head = p->next;
- else
- p->prev->next = p->next;
- if (p->next != NULL)
- p->next->prev = p->prev;
- LeaveCriticalSection(&cleanup_helpers_cs);
- free(p);
- }
- }
- break;
+ break;
}
return TRUE;
}
diff --git a/third_party/libxml/tree.c b/third_party/libxml/tree.c
index 432007e..763381b 100644
--- a/third_party/libxml/tree.c
+++ b/third_party/libxml/tree.c
@@ -92,6 +92,9 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra)
case XML_TREE_UNTERMINATED_ENTITY:
msg = "unterminated entity reference %15s\n";
break;
+ case XML_TREE_NOT_UTF8:
+ msg = "string is not in UTF-8\n";
+ break;
default:
msg = "unexpected error number\n";
}
@@ -1780,7 +1783,9 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
xmlDocPtr doc = NULL;
if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) {
- if (eatname == 1)
+ if ((eatname == 1) &&
+ ((node->doc == NULL) ||
+ (!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
return (NULL);
}
@@ -1790,7 +1795,9 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
*/
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
if (cur == NULL) {
- if (eatname == 1)
+ if ((eatname == 1) &&
+ ((node->doc == NULL) ||
+ (!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
xmlTreeErrMemory("building attribute");
return (NULL);
@@ -1814,11 +1821,15 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
cur->name = name;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
- buffer = xmlEncodeEntitiesReentrant(doc, value);
- cur->children = xmlStringGetNodeList(doc, buffer);
+ if(!xmlCheckUTF8(value)) {
+ xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) doc,
+ NULL);
+ if (doc != NULL)
+ doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ }
+ cur->children = xmlNewDocText(doc, value);
cur->last = NULL;
tmp = cur->children;
while (tmp != NULL) {
@@ -1827,7 +1838,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
cur->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
/*
@@ -1927,7 +1937,7 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
return(NULL);
}
- return xmlNewPropInternal(node, ns, name, value, 1);
+ return xmlNewPropInternal(node, ns, name, value, 1);
}
/**
@@ -2210,8 +2220,8 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
*/
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
if (cur == NULL) {
- xmlFree(name);
xmlTreeErrMemory("building node");
+ /* we can't check here that name comes from the doc dictionnary */
return(NULL);
}
memset(cur, 0, sizeof(xmlNode));
@@ -2290,6 +2300,11 @@ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
cur->children = xmlStringGetNodeList(doc, content);
UPDATE_LAST_CHILD_AND_PARENT(cur)
}
+ } else {
+ /* if name don't come from the doc dictionnary free it here */
+ if ((name != NULL) && (doc != NULL) &&
+ (!(xmlDictOwns(doc->dict, name))))
+ xmlFree(name);
}
return(cur);
}
@@ -6466,11 +6481,15 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
prop->last = NULL;
prop->ns = ns;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
- buffer = xmlEncodeEntitiesReentrant(node->doc, value);
- prop->children = xmlStringGetNodeList(node->doc, buffer);
+ if(!xmlCheckUTF8(value)) {
+ xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
+ NULL);
+ if (node->doc != NULL)
+ node->doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ }
+ prop->children = xmlNewDocText(node->doc, value);
prop->last = NULL;
tmp = prop->children;
while (tmp != NULL) {
@@ -6479,7 +6498,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
prop->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
if (prop->atype == XML_ATTRIBUTE_ID)
xmlAddID(NULL, node->doc, value, prop);
diff --git a/third_party/libxml/uri.c b/third_party/libxml/uri.c
index 34841af..fafd112 100644
--- a/third_party/libxml/uri.c
+++ b/third_party/libxml/uri.c
@@ -421,6 +421,30 @@ xmlSaveUri(xmlURIPtr uri) {
}
if (uri->path != NULL) {
p = uri->path;
+ /*
+ * the colon in file:///d: should not be escaped or
+ * Windows accesses fail later.
+ */
+ if ((uri->scheme != NULL) &&
+ (p[0] == '/') &&
+ (((p[1] >= 'a') && (p[1] <= 'z')) ||
+ ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
+ (p[2] == ':') &&
+ (xmlStrEqual(uri->scheme, BAD_CAST "file"))) {
+ if (len + 3 >= max) {
+ max *= 2;
+ ret = (xmlChar *) xmlRealloc(ret,
+ (max + 1) * sizeof(xmlChar));
+ if (ret == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlSaveUri: out of memory\n");
+ return(NULL);
+ }
+ }
+ ret[len++] = *p++;
+ ret[len++] = *p++;
+ ret[len++] = *p++;
+ }
while (*p != 0) {
if (len + 3 >= max) {
max *= 2;
@@ -2418,6 +2442,11 @@ xmlCanonicPath(const xmlChar *path)
if (path == NULL)
return(NULL);
+
+ /* sanitize filename starting with // so it can be used as URI */
+ if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/'))
+ path++;
+
if ((uri = xmlParseURI((const char *) path)) != NULL) {
xmlFreeURI(uri);
return xmlStrdup(path);
diff --git a/third_party/libxml/win32/Makefile b/third_party/libxml/win32/Makefile
index 517f49b..49b3f86 100644
--- a/third_party/libxml/win32/Makefile
+++ b/third_party/libxml/win32/Makefile
@@ -66,7 +66,7 @@ LDFLAGS = /nologo /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX)
LIBS =
!if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1"
-LIBS = $(LIBS) wsock32.lib
+LIBS = $(LIBS) wsock32.lib ws2_32.lib
!endif
!if "$(WITH_ICONV)" == "1"
LIBS = $(LIBS) iconv.lib
@@ -257,12 +257,12 @@ UTILS = $(UTILS) $(BINDIR)\testThreadsWin32.exe
UTILS = $(UTILS) $(BINDIR)\testThreads.exe
!endif
-!if "$(VCMANIFEST)" == "1"
-_VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
-_VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
-!else
-_VC_MANIFEST_EMBED_EXE=
-_VC_MANIFEST_EMBED_DLL=
+!if "$(VCMANIFEST)" == "1"
+_VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
+_VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
+!else
+_VC_MANIFEST_EMBED_EXE=
+_VC_MANIFEST_EMBED_DLL=
!endif
all : libxml libxmla libxmladll utils
diff --git a/third_party/libxml/win32/Makefile.msvc b/third_party/libxml/win32/Makefile.msvc
index 517f49b..49b3f86 100644
--- a/third_party/libxml/win32/Makefile.msvc
+++ b/third_party/libxml/win32/Makefile.msvc
@@ -66,7 +66,7 @@ LDFLAGS = /nologo /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX)
LIBS =
!if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1"
-LIBS = $(LIBS) wsock32.lib
+LIBS = $(LIBS) wsock32.lib ws2_32.lib
!endif
!if "$(WITH_ICONV)" == "1"
LIBS = $(LIBS) iconv.lib
@@ -257,12 +257,12 @@ UTILS = $(UTILS) $(BINDIR)\testThreadsWin32.exe
UTILS = $(UTILS) $(BINDIR)\testThreads.exe
!endif
-!if "$(VCMANIFEST)" == "1"
-_VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
-_VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
-!else
-_VC_MANIFEST_EMBED_EXE=
-_VC_MANIFEST_EMBED_DLL=
+!if "$(VCMANIFEST)" == "1"
+_VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
+_VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
+!else
+_VC_MANIFEST_EMBED_EXE=
+_VC_MANIFEST_EMBED_DLL=
!endif
all : libxml libxmla libxmladll utils
diff --git a/third_party/libxml/win32/libxml2.def.src b/third_party/libxml/win32/libxml2.def.src
index e37cfe0..db05ad4 100644
--- a/third_party/libxml/win32/libxml2.def.src
+++ b/third_party/libxml/win32/libxml2.def.src
@@ -768,6 +768,7 @@ xmlDictOwns
xmlDictQLookup
xmlDictReference
xmlDictSize
+xmlDllMain
xmlDocCopyNode
xmlDocCopyNodeList
xmlDocDump
@@ -1783,6 +1784,7 @@ xmlSchematronNewMemParserCtxt
xmlSchematronNewParserCtxt
xmlSchematronNewValidCtxt
xmlSchematronParse
+xmlSchematronSetValidStructuredErrors
xmlSchematronValidateDoc
xmlSearchNs
xmlSearchNsByHref
diff --git a/third_party/libxml/xinclude.c b/third_party/libxml/xinclude.c
index 31ea026..bb41180 100644
--- a/third_party/libxml/xinclude.c
+++ b/third_party/libxml/xinclude.c
@@ -419,7 +419,6 @@ static xmlDocPtr
xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
xmlDocPtr ret;
xmlParserCtxtPtr pctxt;
- char *directory = NULL;
xmlParserInputPtr inputStream;
xmlInitParser();
@@ -456,10 +455,8 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
inputPush(pctxt, inputStream);
- if ((pctxt->directory == NULL) && (directory == NULL))
- directory = xmlParserGetDirectory(URL);
- if ((pctxt->directory == NULL) && (directory != NULL))
- pctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
+ if (pctxt->directory == NULL)
+ pctxt->directory = xmlParserGetDirectory(URL);
pctxt->loadsubset |= XML_DETECT_IDS;
@@ -516,9 +513,8 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
if (href == NULL)
return(-1);
- local = 1;
}
- if (href[0] == '#')
+ if ((href[0] == '#') || (href[0] == 0))
local = 1;
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
if (parse != NULL) {
@@ -617,6 +613,19 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
}
/*
+ * If local and xml then we need a fragment
+ */
+ if ((local == 1) && (xml == 1) &&
+ ((fragment == NULL) || (fragment[0] == 0))) {
+ xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
+ "detected a local recursion with no xpointer in %s\n",
+ URL);
+ if (fragment != NULL)
+ xmlFree(fragment);
+ return(-1);
+ }
+
+ /*
* Check the URL against the stack for recursions
*/
if ((!local) && (xml == 1)) {
diff --git a/third_party/libxml/xmlIO.c b/third_party/libxml/xmlIO.c
index 7782776..dd4f7e7 100644
--- a/third_party/libxml/xmlIO.c
+++ b/third_party/libxml/xmlIO.c
@@ -3315,6 +3315,16 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
cons = len;
chunk = (out->buffer->size - out->buffer->use) - 1;
+ /*
+ * make sure we have enough room to save first, if this is
+ * not the case force a flush, but make sure we stay in the loop
+ */
+ if (chunk < 40) {
+ nbchars = 0;
+ oldwritten = -1;
+ goto flush;
+ }
+
/*
* first handle encoding stuff.
*/
@@ -3360,6 +3370,7 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
if ((nbchars < MINLEN) && (len <= 0))
goto done;
+flush:
if (out->writecallback) {
/*
* second write the stuff to the I/O channel
diff --git a/third_party/libxml/xmlmodule.c b/third_party/libxml/xmlmodule.c
index 9d68b9f..cbe30b6 100644
--- a/third_party/libxml/xmlmodule.c
+++ b/third_party/libxml/xmlmodule.c
@@ -190,7 +190,7 @@ xmlModuleFree(xmlModulePtr module)
return (0);
}
-#ifdef HAVE_DLOPEN
+#if defined(HAVE_DLOPEN) && !defined(_WIN32)
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
diff --git a/third_party/libxml/xmlreader.c b/third_party/libxml/xmlreader.c
index d7bddec..92b053e 100644
--- a/third_party/libxml/xmlreader.c
+++ b/third_party/libxml/xmlreader.c
@@ -234,8 +234,6 @@ xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
if (table == NULL)
return(-1);
- if (attr == NULL)
- return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
@@ -2936,7 +2934,7 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
*
* Get the node type of the current node
* Reference:
- * http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html
+ * http://www.gnu.org/software/dotgnu/pnetlib-doc/System/Xml/XmlNodeType.html
*
* Returns the xmlNodeType of the current node or -1 in case of error
*/
@@ -3960,8 +3958,7 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
return(NULL);
if (reader->doc != NULL)
return(reader->doc);
- if ((reader == NULL) || (reader->ctxt == NULL) ||
- (reader->ctxt->myDoc == NULL))
+ if ((reader->ctxt == NULL) || (reader->ctxt->myDoc == NULL))
return(NULL);
reader->preserve = 1;
diff --git a/third_party/libxml/xmlregexp.c b/third_party/libxml/xmlregexp.c
index 660c21b..2f8ae3d 100644
--- a/third_party/libxml/xmlregexp.c
+++ b/third_party/libxml/xmlregexp.c
@@ -1532,6 +1532,8 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
static int
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStatePtr to, xmlRegAtomPtr atom) {
+ xmlRegStatePtr end;
+
if (atom == NULL) {
ERROR("genrate transition: atom == NULL");
return(-1);
@@ -1689,12 +1691,31 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
else {
return(-1);
}
+ }
+ end = to;
+ if ((atom->quant == XML_REGEXP_QUANT_MULT) ||
+ (atom->quant == XML_REGEXP_QUANT_PLUS)) {
+ /*
+ * Do not pollute the target state by adding transitions from
+ * it as it is likely to be the shared target of multiple branches.
+ * So isolate with an epsilon transition.
+ */
+ xmlRegStatePtr tmp;
+
+ tmp = xmlRegNewState(ctxt);
+ if (tmp != NULL)
+ xmlRegStatePush(ctxt, tmp);
+ else {
+ return(-1);
+ }
+ xmlFAGenerateEpsilonTransition(ctxt, tmp, to);
+ to = tmp;
}
if (xmlRegAtomPush(ctxt, atom) < 0) {
return(-1);
}
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
- ctxt->state = to;
+ ctxt->state = end;
switch (atom->quant) {
case XML_REGEXP_QUANT_OPT:
atom->quant = XML_REGEXP_QUANT_ONCE;
@@ -5052,7 +5073,7 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
static void
xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
do {
- if ((CUR == '\\') || (CUR == '.')) {
+ if (CUR == '\\') {
xmlFAParseCharClassEsc(ctxt);
} else {
xmlFAParseCharRange(ctxt);
diff --git a/third_party/libxml/xmlsave.c b/third_party/libxml/xmlsave.c
index cbabd78..2a61577 100644
--- a/third_party/libxml/xmlsave.c
+++ b/third_party/libxml/xmlsave.c
@@ -727,8 +727,8 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- if (cur->content == NULL) {
- xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
} else {
start = end = cur->content;
while (*end != '\0') {
@@ -1236,21 +1236,25 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- start = end = cur->content;
- while (*end != '\0') {
- if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
- end = end + 2;
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ } else {
+ start = end = cur->content;
+ while (*end != '\0') {
+ if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
+ end = end + 2;
+ xmlOutputBufferWrite(buf, 9, "<![CDATA[");
+ xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWrite(buf, 3, "]]>");
+ start = end;
+ }
+ end++;
+ }
+ if (start != end) {
xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWriteString(buf, (const char *)start);
xmlOutputBufferWrite(buf, 3, "]]>");
- start = end;
}
- end++;
- }
- if (start != end) {
- xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWriteString(buf, (const char *)start);
- xmlOutputBufferWrite(buf, 3, "]]>");
}
return;
}
diff --git a/third_party/libxml/xmlschemas.c b/third_party/libxml/xmlschemas.c
index f6b86dd..d57ba9f 100644
--- a/third_party/libxml/xmlschemas.c
+++ b/third_party/libxml/xmlschemas.c
@@ -21808,9 +21808,9 @@ xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
return (1);
}
if (xmlSchemaGetNotation(schema, localName, nsName) != NULL) {
- if (valNeeded && (val != NULL)) {
- (*val) = xmlSchemaNewNOTATIONValue(BAD_CAST localName,
- BAD_CAST xmlStrdup(nsName));
+ if ((valNeeded) && (val != NULL)) {
+ (*val) = xmlSchemaNewNOTATIONValue(xmlStrdup(localName),
+ xmlStrdup(nsName));
if (*val == NULL)
ret = -1;
}
@@ -28108,8 +28108,8 @@ externalSubsetSplit(void *ctx, const xmlChar *name,
{
xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
- (ctxt->user_sax->internalSubset != NULL))
- ctxt->user_sax->internalSubset(ctxt->user_data, name, ExternalID,
+ (ctxt->user_sax->externalSubset != NULL))
+ ctxt->user_sax->externalSubset(ctxt->user_data, name, ExternalID,
SystemID);
}
@@ -28315,8 +28315,8 @@ cdataBlockSplit(void *ctx, const xmlChar *value, int len)
if (ctxt == NULL)
return;
if ((ctxt->user_sax != NULL) &&
- (ctxt->user_sax->ignorableWhitespace != NULL))
- ctxt->user_sax->ignorableWhitespace(ctxt->user_data, value, len);
+ (ctxt->user_sax->cdataBlock != NULL))
+ ctxt->user_sax->cdataBlock(ctxt->user_data, value, len);
if (ctxt->ctxt != NULL)
xmlSchemaSAXHandleCDataSection(ctxt->ctxt, value, len);
}
diff --git a/third_party/libxml/xmlschemastypes.c b/third_party/libxml/xmlschemastypes.c
index a35c539..0d967d0 100644
--- a/third_party/libxml/xmlschemastypes.c
+++ b/third_party/libxml/xmlschemastypes.c
@@ -2063,7 +2063,7 @@ xmlSchemaValAtomicListNode(xmlSchemaTypePtr type, const xmlChar *value,
* Parse an unsigned long into 3 fields.
*
* Returns the number of significant digits in the number or
- * -1 if overflow of the capacity
+ * -1 if overflow of the capacity and -2 if it's not a number.
*/
static int
xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,
@@ -2072,6 +2072,9 @@ xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,
const xmlChar *tmp, *cur = *str;
int ret = 0, i = 0;
+ if (!((*cur >= '0') && (*cur <= '9')))
+ return(-2);
+
while (*cur == '0') { /* ignore leading zeroes */
cur++;
}
@@ -2342,9 +2345,9 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
* Terminate the (preparsed) string.
*/
if (len != 0) {
- *cptr = 0;
+ *cptr = 0;
cptr = cval;
-
+
xmlSchemaParseUInt((const xmlChar **)&cptr,
&v->value.decimal.lo,
&v->value.decimal.mi,
@@ -3116,7 +3119,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
} else if (*cur == '+')
cur++;
ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
- if (ret == -1)
+ if (ret < 0)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
@@ -3161,7 +3164,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
case XML_SCHEMAS_BYTE:
case XML_SCHEMAS_SHORT:
case XML_SCHEMAS_INT:{
- const xmlChar *cur = value;
+ const xmlChar *cur = value;
unsigned long lo, mi, hi;
int sign = 0;
diff --git a/third_party/libxml/xmlwriter.c b/third_party/libxml/xmlwriter.c
index 2d9d1090..69d4b85 100644
--- a/third_party/libxml/xmlwriter.c
+++ b/third_party/libxml/xmlwriter.c
@@ -626,9 +626,10 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
* xmlTextWriterEndDocument:
* @writer: the xmlTextWriterPtr
*
- * End an xml document. All open elements are closed
+ * End an xml document. All open elements are closed, and
+ * the content is flushed to the output.
*
- * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
+ * Returns the bytes written or -1 in case of error
*/
int
xmlTextWriterEndDocument(xmlTextWriterPtr writer)
@@ -702,6 +703,9 @@ xmlTextWriterEndDocument(xmlTextWriterPtr writer)
return -1;
sum += count;
}
+
+ sum += xmlTextWriterFlush(writer);
+
return sum;
}
@@ -2610,6 +2614,7 @@ xmlTextWriterStartCDATA(xmlTextWriterPtr writer)
if (p != 0) {
switch (p->state) {
case XML_TEXTWRITER_NONE:
+ case XML_TEXTWRITER_TEXT:
case XML_TEXTWRITER_PI:
case XML_TEXTWRITER_PI_TEXT:
break;
diff --git a/third_party/libxml/xpath.c b/third_party/libxml/xpath.c
index 22a3f9d..a52c44a 100644
--- a/third_party/libxml/xpath.c
+++ b/third_party/libxml/xpath.c
@@ -3663,6 +3663,8 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
if (val2 == NULL) return(val1);
if (val1 == NULL) {
val1 = xmlXPathNodeSetCreate(NULL);
+ if (val1 == NULL)
+ return (NULL);
#if 0
/*
* TODO: The optimization won't work in every case, since
@@ -3776,6 +3778,8 @@ xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
if (val1 == NULL) {
val1 = xmlXPathNodeSetCreate(NULL);
}
+ if (val1 == NULL)
+ return (NULL);
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
@@ -3852,7 +3856,9 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
xmlNodePtr n1, n2;
if (set1 == NULL)
- set1 = xmlXPathNodeSetCreate(NULL);
+ set1 = xmlXPathNodeSetCreate(NULL);
+ if (set1 == NULL)
+ return (NULL);
initNbSet1 = set1->nodeNr;
for (i = 0;i < set2->nodeNr;i++) {
@@ -3962,6 +3968,8 @@ xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
if (set1 == NULL)
set1 = xmlXPathNodeSetCreate(NULL);
+ if (set1 == NULL)
+ return (NULL);
for (i = 0;i < set2->nodeNr;i++) {
n2 = set2->nodeTab[i];
@@ -4281,8 +4289,9 @@ xmlXPathNewNodeSetList(xmlNodeSetPtr val)
ret = xmlXPathNewNodeSet(NULL);
else {
ret = xmlXPathNewNodeSet(val->nodeTab[0]);
- for (i = 1; i < val->nodeNr; ++i)
- xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i]);
+ if (ret)
+ for (i = 1; i < val->nodeNr; ++i)
+ xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i]);
}
return (ret);
@@ -4381,6 +4390,8 @@ xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
int i, l1;
xmlNodePtr cur;
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes1))
return(ret);
if (xmlXPathNodeSetIsEmpty(nodes2))
@@ -4418,6 +4429,8 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
l = xmlXPathNodeSetGetLength(nodes);
hash = xmlHashCreate (l);
for (i = 0; i < l; i++) {
@@ -4506,6 +4519,8 @@ xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes) ||
(!xmlXPathNodeSetContains(nodes, node)))
return(ret);
@@ -4608,6 +4623,8 @@ xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes) ||
(!xmlXPathNodeSetContains(nodes, node)))
return(ret);
@@ -8432,6 +8449,8 @@ xmlXPathGetElementsByIds (xmlDocPtr doc, const xmlChar *ids) {
if (ids == NULL) return(NULL);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
while (IS_BLANK_CH(*cur)) cur++;
while (*cur != 0) {
@@ -8499,6 +8518,11 @@ xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i;
ret = xmlXPathNodeSetCreate(NULL);
+ /*
+ * FIXME -- in an out-of-memory condition this will behave badly.
+ * The solution is not clear -- we already popped an item from
+ * ctxt, so the object is in a corrupt state.
+ */
if (obj->nodesetval != NULL) {
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
@@ -12481,6 +12505,7 @@ error:
outSeq = seq;
else
outSeq = xmlXPathNodeSetCreate(NULL);
+ /* XXX what if xmlXPathNodeSetCreate returned NULL here? */
}
if ((seq != NULL) && (seq != outSeq)) {
xmlXPathFreeNodeSet(seq);
@@ -12976,6 +13001,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
* key() evaluation are attempted on the predicate
*/
newset = xmlXPathNodeSetCreate(NULL);
+ /* XXX what if xmlXPathNodeSetCreate returned NULL? */
for (i = 0; i < oldset->nodeNr; i++) {
/*