Imported Upstream version 2.12.5 upstream upstream/2.12.5
authorTizenOpenSource <tizenopensrc@samsung.com>
Tue, 13 Feb 2024 07:12:59 +0000 (16:12 +0900)
committerTizenOpenSource <tizenopensrc@samsung.com>
Tue, 13 Feb 2024 07:12:59 +0000 (16:12 +0900)
760 files changed:
.editorconfig [new file with mode: 0644]
.gitignore
.gitlab-ci.yml
.gitlab-ci/Dockerfile [new file with mode: 0644]
.gitlab-ci/Test-Msvc.ps1 [new file with mode: 0644]
.gitlab-ci/llvm-symbolizer [new file with mode: 0755]
.gitlab-ci/setup_mingw.sh [new file with mode: 0644]
.gitlab-ci/test.sh [new file with mode: 0644]
.gitlab-ci/test_cmake.sh [new file with mode: 0644]
CMakeLists.txt
Copyright
HTMLparser.c
HTMLtree.c
MAINTAINERS.md [new file with mode: 0644]
Makefile.am
Makefile.tests [deleted file]
NEWS
README.md
README.tests [deleted file]
SAX.c
SAX2.c
TODO [deleted file]
TODO_SCHEMAS [deleted file]
buf.c
buf.h [deleted file]
build_glob.py [deleted file]
c14n.c
catalog.c
check-relaxng-test-suite.py
check-relaxng-test-suite2.py
check-xinclude-test-suite.py
check-xml-test-suite.py
check-xsddata-test-suite.py
chvalid.c
config.h.cmake.in
configure.ac
debugXML.c
dict.c
doc/Makefile.am
doc/apibuild.py
doc/buildDocBookCatalog [deleted file]
doc/checkapisym.xsl [deleted file]
doc/devhelp/html.xsl
doc/devhelp/libxml2-HTMLparser.html
doc/devhelp/libxml2-HTMLtree.html
doc/devhelp/libxml2-SAX.html
doc/devhelp/libxml2-SAX2.html
doc/devhelp/libxml2-dict.html
doc/devhelp/libxml2-encoding.html
doc/devhelp/libxml2-entities.html
doc/devhelp/libxml2-globals.html
doc/devhelp/libxml2-hash.html
doc/devhelp/libxml2-parser.html
doc/devhelp/libxml2-parserInternals.html
doc/devhelp/libxml2-threads.html
doc/devhelp/libxml2-tree.html
doc/devhelp/libxml2-uri.html
doc/devhelp/libxml2-valid.html
doc/devhelp/libxml2-xmlIO.html
doc/devhelp/libxml2-xmlerror.html
doc/devhelp/libxml2-xmlexports.html
doc/devhelp/libxml2-xmlmemory.html
doc/devhelp/libxml2-xmlreader.html
doc/devhelp/libxml2-xmlsave.html
doc/devhelp/libxml2-xmlschemastypes.html
doc/devhelp/libxml2-xmlversion.html
doc/devhelp/libxml2-xmlwriter.html
doc/devhelp/libxml2-xpath.html
doc/devhelp/libxml2-xpathInternals.html
doc/devhelp/libxml2.devhelp2
doc/examples/.gitignore [new file with mode: 0644]
doc/examples/Makefile.am
doc/examples/examples.xml
doc/examples/index.html
doc/examples/index.py
doc/examples/io1.c
doc/examples/parse1.c
doc/examples/parse2.c
doc/examples/parse3.c
doc/examples/parse4.c
doc/examples/reader1.c
doc/examples/reader2.c
doc/examples/reader3.c
doc/examples/reader4.c
doc/examples/testWriter.c
doc/examples/tree1.c
doc/examples/tree2.c
doc/examples/xpath1.c
doc/examples/xpath2.c
doc/libxml-doc.el [deleted file]
doc/libxml2-api.xml
doc/symbols.xml [deleted file]
doc/syms.xsl [deleted file]
doc/xmlcatalog.1
doc/xmlcatalog.html
doc/xmlcatalog.xml
doc/xmllint.1
doc/xmllint.html
doc/xmllint.xml
enc.h [deleted file]
encoding.c
entities.c
error.c
example/gjobread.c
fuzz/.gitignore
fuzz/Makefile.am
fuzz/fuzz.c
fuzz/fuzz.h
fuzz/genSeed.c
fuzz/html.c
fuzz/regexp.c
fuzz/schema.c
fuzz/static_seed/regexp/branch-1
fuzz/static_seed/regexp/branch-10
fuzz/static_seed/regexp/branch-11
fuzz/static_seed/regexp/branch-12
fuzz/static_seed/regexp/branch-13
fuzz/static_seed/regexp/branch-2
fuzz/static_seed/regexp/branch-3
fuzz/static_seed/regexp/branch-4
fuzz/static_seed/regexp/branch-5
fuzz/static_seed/regexp/branch-6
fuzz/static_seed/regexp/branch-7
fuzz/static_seed/regexp/branch-8
fuzz/static_seed/regexp/branch-9
fuzz/static_seed/regexp/bug316338-1
fuzz/static_seed/regexp/bug316338-10
fuzz/static_seed/regexp/bug316338-11
fuzz/static_seed/regexp/bug316338-12
fuzz/static_seed/regexp/bug316338-13
fuzz/static_seed/regexp/bug316338-14
fuzz/static_seed/regexp/bug316338-15
fuzz/static_seed/regexp/bug316338-16
fuzz/static_seed/regexp/bug316338-2
fuzz/static_seed/regexp/bug316338-3
fuzz/static_seed/regexp/bug316338-4
fuzz/static_seed/regexp/bug316338-5
fuzz/static_seed/regexp/bug316338-6
fuzz/static_seed/regexp/bug316338-7
fuzz/static_seed/regexp/bug316338-8
fuzz/static_seed/regexp/bug316338-9
fuzz/static_seed/regexp/bug420596-1
fuzz/static_seed/regexp/bug420596-2
fuzz/static_seed/regexp/bug420596-3
fuzz/static_seed/regexp/bug420596-4
fuzz/static_seed/regexp/bug420596-5
fuzz/static_seed/regexp/bug420596-6
fuzz/static_seed/regexp/bug420596-7
fuzz/static_seed/regexp/bug420596-8
fuzz/static_seed/regexp/content-1
fuzz/static_seed/regexp/content-10
fuzz/static_seed/regexp/content-2
fuzz/static_seed/regexp/content-3
fuzz/static_seed/regexp/content-4
fuzz/static_seed/regexp/content-5
fuzz/static_seed/regexp/content-6
fuzz/static_seed/regexp/content-7
fuzz/static_seed/regexp/content-8
fuzz/static_seed/regexp/content-9
fuzz/static_seed/regexp/hard-1
fuzz/static_seed/regexp/hard-10
fuzz/static_seed/regexp/hard-2
fuzz/static_seed/regexp/hard-3
fuzz/static_seed/regexp/hard-4
fuzz/static_seed/regexp/hard-5
fuzz/static_seed/regexp/hard-6
fuzz/static_seed/regexp/hard-7
fuzz/static_seed/regexp/hard-8
fuzz/static_seed/regexp/hard-9
fuzz/static_seed/regexp/ncname-1
fuzz/static_seed/regexp/ncname-2
fuzz/static_seed/regexp/ncname-3
fuzz/static_seed/regexp/ncname-4
fuzz/static_seed/regexp/ncname-5
fuzz/static_seed/regexp/ranges-1
fuzz/static_seed/regexp/ranges-10
fuzz/static_seed/regexp/ranges-11
fuzz/static_seed/regexp/ranges-12
fuzz/static_seed/regexp/ranges-2
fuzz/static_seed/regexp/ranges-3
fuzz/static_seed/regexp/ranges-4
fuzz/static_seed/regexp/ranges-5
fuzz/static_seed/regexp/ranges-6
fuzz/static_seed/regexp/ranges-7
fuzz/static_seed/regexp/ranges-8
fuzz/static_seed/regexp/ranges-9
fuzz/static_seed/regexp/ranges2-1
fuzz/static_seed/regexp/ranges2-10
fuzz/static_seed/regexp/ranges2-11
fuzz/static_seed/regexp/ranges2-12
fuzz/static_seed/regexp/ranges2-2
fuzz/static_seed/regexp/ranges2-3
fuzz/static_seed/regexp/ranges2-4
fuzz/static_seed/regexp/ranges2-5
fuzz/static_seed/regexp/ranges2-6
fuzz/static_seed/regexp/ranges2-7
fuzz/static_seed/regexp/ranges2-8
fuzz/static_seed/regexp/ranges2-9
fuzz/static_seed/regexp/xpath-1
fuzz/static_seed/regexp/xpath-10
fuzz/static_seed/regexp/xpath-11
fuzz/static_seed/regexp/xpath-12
fuzz/static_seed/regexp/xpath-13
fuzz/static_seed/regexp/xpath-14
fuzz/static_seed/regexp/xpath-15
fuzz/static_seed/regexp/xpath-16
fuzz/static_seed/regexp/xpath-17
fuzz/static_seed/regexp/xpath-18
fuzz/static_seed/regexp/xpath-19
fuzz/static_seed/regexp/xpath-2
fuzz/static_seed/regexp/xpath-20
fuzz/static_seed/regexp/xpath-21
fuzz/static_seed/regexp/xpath-22
fuzz/static_seed/regexp/xpath-23
fuzz/static_seed/regexp/xpath-24
fuzz/static_seed/regexp/xpath-25
fuzz/static_seed/regexp/xpath-26
fuzz/static_seed/regexp/xpath-27
fuzz/static_seed/regexp/xpath-28
fuzz/static_seed/regexp/xpath-29
fuzz/static_seed/regexp/xpath-3
fuzz/static_seed/regexp/xpath-30
fuzz/static_seed/regexp/xpath-31
fuzz/static_seed/regexp/xpath-32
fuzz/static_seed/regexp/xpath-33
fuzz/static_seed/regexp/xpath-34
fuzz/static_seed/regexp/xpath-35
fuzz/static_seed/regexp/xpath-4
fuzz/static_seed/regexp/xpath-5
fuzz/static_seed/regexp/xpath-6
fuzz/static_seed/regexp/xpath-7
fuzz/static_seed/regexp/xpath-8
fuzz/static_seed/regexp/xpath-9
fuzz/static_seed/uri/dot
fuzz/static_seed/uri/full
fuzz/testFuzzer.c
fuzz/uri.c
fuzz/valid.c [new file with mode: 0644]
fuzz/valid.options [new file with mode: 0644]
fuzz/xinclude.c [new file with mode: 0644]
fuzz/xinclude.options [new file with mode: 0644]
fuzz/xml.c
fuzz/xpath.c
genChRanges.py
genUnicode.py
gentest.py
global.data [deleted file]
globals.c
hash.c
include/Makefile.am
include/libxml/HTMLparser.h
include/libxml/HTMLtree.h
include/libxml/SAX.h
include/libxml/SAX2.h
include/libxml/c14n.h
include/libxml/catalog.h
include/libxml/chvalid.h
include/libxml/debugXML.h
include/libxml/dict.h
include/libxml/encoding.h
include/libxml/entities.h
include/libxml/globals.h
include/libxml/hash.h
include/libxml/list.h
include/libxml/nanoftp.h
include/libxml/nanohttp.h
include/libxml/parser.h
include/libxml/parserInternals.h
include/libxml/pattern.h
include/libxml/relaxng.h
include/libxml/schemasInternals.h
include/libxml/schematron.h
include/libxml/threads.h
include/libxml/tree.h
include/libxml/uri.h
include/libxml/valid.h
include/libxml/xinclude.h
include/libxml/xlink.h
include/libxml/xmlIO.h
include/libxml/xmlautomata.h
include/libxml/xmlerror.h
include/libxml/xmlexports.h
include/libxml/xmlmemory.h
include/libxml/xmlmodule.h
include/libxml/xmlreader.h
include/libxml/xmlregexp.h
include/libxml/xmlsave.h
include/libxml/xmlschemas.h
include/libxml/xmlschemastypes.h
include/libxml/xmlstring.h
include/libxml/xmlunicode.h
include/libxml/xmlversion.h.in
include/libxml/xmlwriter.h
include/libxml/xpath.h
include/libxml/xpathInternals.h
include/libxml/xpointer.h
include/private/Makefile.am [new file with mode: 0644]
include/private/buf.h [new file with mode: 0644]
include/private/dict.h [new file with mode: 0644]
include/private/enc.h [new file with mode: 0644]
include/private/entities.h [new file with mode: 0644]
include/private/error.h [new file with mode: 0644]
include/private/globals.h [new file with mode: 0644]
include/private/html.h [new file with mode: 0644]
include/private/io.h [new file with mode: 0644]
include/private/memory.h [new file with mode: 0644]
include/private/parser.h [new file with mode: 0644]
include/private/regexp.h [new file with mode: 0644]
include/private/save.h [new file with mode: 0644]
include/private/string.h [new file with mode: 0644]
include/private/threads.h [new file with mode: 0644]
include/private/tree.h [new file with mode: 0644]
include/private/xinclude.h [new file with mode: 0644]
include/private/xpath.h [new file with mode: 0644]
include/private/xzlib.h [new file with mode: 0644]
include/win32config.h
include/wsockcompat.h
legacy.c
libxml-2.0-uninstalled.pc.in
libxml-2.0.pc.in
libxml.h
libxml.m4
libxml.spec.in [deleted file]
libxml2-config.cmake.cmake.in
libxml2-config.cmake.in
libxml2.syms
list.c
m4/ax_append_flag.m4 [new file with mode: 0644]
m4/ax_append_link_flags.m4 [new file with mode: 0644]
m4/ax_check_link_flag.m4 [new file with mode: 0644]
m4/ax_require_defined.m4 [new file with mode: 0644]
nanoftp.c
nanohttp.c
optim/TOTRY [deleted file]
optim/hash_dict.patch [deleted file]
optim/hash_dict.txt [deleted file]
parser.c
parserInternals.c
pattern.c
python/.gitignore [new file with mode: 0644]
python/Makefile.am
python/TODO [deleted file]
python/generator.py
python/libxml.c
python/libxml_wrap.h
python/pyproject.toml [new file with mode: 0755]
python/setup.py.in
python/tests/Makefile.am
python/tests/attribs.py
python/tests/build.py
python/tests/compareNodes.py
python/tests/ctxterror.py
python/tests/cutnpaste.py
python/tests/dtdvalid.py
python/tests/error.py
python/tests/inbuf.py
python/tests/indexes.py
python/tests/input_callback.py
python/tests/nsdel.py
python/tests/outbuf.py
python/tests/push.py
python/tests/pushSAX.py
python/tests/pushSAXhtml.py
python/tests/reader.py
python/tests/reader2.py
python/tests/reader3.py
python/tests/reader4.py
python/tests/reader5.py
python/tests/reader6.py
python/tests/reader7.py
python/tests/reader8.py
python/tests/readererr.py
python/tests/readernext.py
python/tests/regexp.py
python/tests/relaxng.py
python/tests/resolver.py
python/tests/schema.py
python/tests/serialize.py
python/tests/setup_test.py [new file with mode: 0644]
python/tests/sync.py
python/tests/thread2.py
python/tests/tst.py
python/tests/tstLastError.py
python/tests/tstURI.py
python/tests/tstmem.py
python/tests/tstxpath.py
python/tests/validDTD.py
python/tests/validRNG.py
python/tests/validSchemas.py
python/tests/validate.py
python/tests/walker.py
python/tests/xpath.py
python/tests/xpathext.py
python/tests/xpathleak.py
python/tests/xpathns.py
python/tests/xpathret.py
python/types.c
relaxng.c
result/HTML/doc3.htm
result/HTML/names.html [new file with mode: 0644]
result/HTML/names.html.err [new file with mode: 0644]
result/HTML/names.html.sax [new file with mode: 0644]
result/HTML/utf8bug.html
result/HTML/utf8bug.html.err
result/HTML/wired.html
result/HTML/xml-declaration-1.html [new file with mode: 0644]
result/HTML/xml-declaration-1.html.sax [new file with mode: 0644]
result/URI/file.uri [new file with mode: 0644]
result/URI/port.uri [new file with mode: 0644]
result/URI/uri.data
result/VC/ElementValid5.rdr
result/VC/ElementValid6.rdr
result/VC/ElementValid7.rdr
result/VC/ElementValid8
result/VC/ElementValid8.rdr
result/VC/PENesting
result/VC/PENesting2
result/XInclude/fallback.xml.err [new file with mode: 0644]
result/XInclude/fallback2.xml.err [new file with mode: 0644]
result/XInclude/fallback4.xml.err [new file with mode: 0644]
result/XInclude/fallback5.xml.err [new file with mode: 0644]
result/XInclude/fallback6.xml.err [new file with mode: 0644]
result/XInclude/fallback7.xml [new file with mode: 0644]
result/XInclude/fallback7.xml.err [new file with mode: 0644]
result/XInclude/invalid_char.xml.err [new file with mode: 0644]
result/XInclude/invalid_char.xml.rdr [new file with mode: 0644]
result/XInclude/issue424-1.xml [new file with mode: 0644]
result/XInclude/issue424-2.xml [new file with mode: 0644]
result/XInclude/loop.xml.err [new file with mode: 0644]
result/XInclude/max-recurse.xml.err [new file with mode: 0644]
result/XInclude/nodes3.xml [deleted file]
result/XInclude/nodes3.xml.err [new file with mode: 0644]
result/XInclude/ns1.xml.err [new file with mode: 0644]
result/XInclude/ns1.xml.rdr [deleted file]
result/XPath/expr/functions
result/boundaries1.xml [new file with mode: 0644]
result/boundaries1.xml.rde [new file with mode: 0644]
result/boundaries1.xml.rdr [new file with mode: 0644]
result/boundaries1.xml.sax [new file with mode: 0644]
result/boundaries1.xml.sax2 [new file with mode: 0644]
result/ent2.sax
result/ent2.sax2
result/ent7.sax
result/ent7.sax2
result/errors/754946.xml.ent
result/errors/754946.xml.err
result/errors/754946.xml.str
result/errors/754947.xml.ent
result/errors/754947.xml.err
result/errors/754947.xml.str
result/errors/759398.xml.ent
result/errors/759398.xml.err
result/errors/759398.xml.str
result/errors/759573-2.xml.ent
result/errors/759573-2.xml.err
result/errors/759573-2.xml.str
result/errors/759573.xml.ent
result/errors/759573.xml.err
result/errors/759573.xml.str
result/errors/759579.xml.ent
result/errors/759579.xml.err
result/errors/759579.xml.str
result/errors/attr4.xml.ent
result/errors/attr4.xml.err
result/errors/attr5.xml.ent [new file with mode: 0644]
result/errors/attr5.xml.err [new file with mode: 0644]
result/errors/attr5.xml.str [new file with mode: 0644]
result/errors/attr6.xml.ent [new file with mode: 0644]
result/errors/attr6.xml.err [new file with mode: 0644]
result/errors/attr6.xml.str [new file with mode: 0644]
result/errors/cdata.xml.ent
result/errors/cdata.xml.err
result/errors/cdata.xml.str
result/errors/content1.xml.ent
result/errors/content1.xml.err
result/errors/content1.xml.str
result/errors/empty.xml.ent [new file with mode: 0644]
result/errors/empty.xml.err [new file with mode: 0644]
result/errors/empty.xml.str [new file with mode: 0644]
result/errors/extra-content.xml.ent [new file with mode: 0644]
result/errors/extra-content.xml.err [new file with mode: 0644]
result/errors/extra-content.xml.str [new file with mode: 0644]
result/errors/invalid-start-tag-1.xml.ent [new file with mode: 0644]
result/errors/invalid-start-tag-1.xml.err [new file with mode: 0644]
result/errors/invalid-start-tag-1.xml.str [new file with mode: 0644]
result/errors/invalid-start-tag-2.xml.ent [new file with mode: 0644]
result/errors/invalid-start-tag-2.xml.err [new file with mode: 0644]
result/errors/invalid-start-tag-2.xml.str [new file with mode: 0644]
result/errors/name3.xml.ent [new file with mode: 0644]
result/errors/name3.xml.err [new file with mode: 0644]
result/errors/name3.xml.str [new file with mode: 0644]
result/errors/quadratic-defattr.xml.ent [new file with mode: 0644]
result/errors/quadratic-defattr.xml.err [new file with mode: 0644]
result/errors/quadratic-defattr.xml.str [new file with mode: 0644]
result/errors/rec_att_default.xml.ent [new file with mode: 0644]
result/errors/rec_att_default.xml.err [new file with mode: 0644]
result/errors/rec_att_default.xml.str [new file with mode: 0644]
result/errors/rec_ext_ent.xml.ent
result/errors/trailing-null-1.xml.ent [new file with mode: 0644]
result/errors/trailing-null-1.xml.err [new file with mode: 0644]
result/errors/trailing-null-1.xml.str [new file with mode: 0644]
result/errors/trailing-null-2.xml.ent [new file with mode: 0644]
result/errors/trailing-null-2.xml.err [new file with mode: 0644]
result/errors/trailing-null-2.xml.str [new file with mode: 0644]
result/errors/truncated-utf16.xml.ent [new file with mode: 0644]
result/errors/truncated-utf16.xml.err [new file with mode: 0644]
result/errors/truncated-utf16.xml.str [new file with mode: 0644]
result/errors/unclosed-element.xml.ent [new file with mode: 0644]
result/errors/unclosed-element.xml.err [new file with mode: 0644]
result/errors/unclosed-element.xml.str [new file with mode: 0644]
result/errors/utf8-1.xml.ent [new file with mode: 0644]
result/errors/utf8-1.xml.err [new file with mode: 0644]
result/errors/utf8-1.xml.str [new file with mode: 0644]
result/errors/utf8-2.xml.ent [new file with mode: 0644]
result/errors/utf8-2.xml.err [new file with mode: 0644]
result/errors/utf8-2.xml.str [new file with mode: 0644]
result/errors10/781205.xml.err
result/errors10/781361.xml.err
result/issue626.xml [new file with mode: 0644]
result/issue626.xml.rde [new file with mode: 0644]
result/issue626.xml.rdr [new file with mode: 0644]
result/issue626.xml.sax [new file with mode: 0644]
result/issue626.xml.sax2 [new file with mode: 0644]
result/issue643.xml [new file with mode: 0644]
result/issue643.xml.rde [new file with mode: 0644]
result/issue643.xml.rdr [new file with mode: 0644]
result/issue643.xml.sax [new file with mode: 0644]
result/issue643.xml.sax2 [new file with mode: 0644]
result/namespaces/err_5.xml.err
result/namespaces/err_6.xml.err
result/noent/boundaries1.xml [new file with mode: 0644]
result/noent/boundaries1.xml.sax2 [new file with mode: 0644]
result/noent/ent7.sax2
result/noent/issue626.xml [new file with mode: 0644]
result/noent/issue626.xml.sax2 [new file with mode: 0644]
result/noent/issue643.xml [new file with mode: 0644]
result/noent/issue643.xml.sax2 [new file with mode: 0644]
result/noent/ns-ent.xml [new file with mode: 0644]
result/noent/ns-ent.xml.sax2 [new file with mode: 0644]
result/noent/xml2.sax2
result/ns-ent.xml [new file with mode: 0644]
result/ns-ent.xml.rde [new file with mode: 0644]
result/ns-ent.xml.rdr [new file with mode: 0644]
result/ns-ent.xml.sax [new file with mode: 0644]
result/ns-ent.xml.sax2 [new file with mode: 0644]
result/schemas/579746_0_3.err
result/schemas/579746_0_5.err
result/schemas/579746_1_3.err
result/schemas/579746_1_5.err
result/schemas/all_0_3.err
result/schemas/all_0_4.err
result/schemas/all_0_5.err
result/schemas/all_0_6.err
result/schemas/all_0_7.err
result/schemas/all_1_3.err
result/schemas/all_1_5.err
result/schemas/all_1_6.err
result/schemas/all_1_7.err
result/schemas/all_2_0.err
result/schemas/all_2_1.err
result/schemas/all_2_2.err
result/schemas/all_2_4.err
result/schemas/all_2_5.err
result/schemas/allsg_0_3.err
result/schemas/allsg_0_4.err
result/schemas/allsg_0_5.err
result/schemas/any3_0_0.err
result/schemas/any5_0_0.err
result/schemas/any5_0_1.err
result/schemas/any5_0_2.err
result/schemas/any5_0_4.err
result/schemas/any5_0_5.err
result/schemas/any5_0_6.err
result/schemas/any5_1_0.err
result/schemas/any5_1_1.err
result/schemas/any5_1_3.err
result/schemas/any5_1_4.err
result/schemas/any5_1_6.err
result/schemas/any7_1_0.err
result/schemas/any7_1_1.err
result/schemas/any7_2_0.err
result/schemas/any7_2_1.err
result/schemas/anyAttr-processContents-err1_0_0.err
result/schemas/attruse_0_1.err
result/schemas/attruse_0_2.err
result/schemas/bug323510_1_0.err
result/schemas/changelog093_1_0.err
result/schemas/choice_0_2.err
result/schemas/choice_0_3.err
result/schemas/choice_0_4.err
result/schemas/choice_0_5.err
result/schemas/choice_0_6.err
result/schemas/choice_1_2.err
result/schemas/choice_1_3.err
result/schemas/choice_1_5.err
result/schemas/choice_1_6.err
result/schemas/choice_2_4.err
result/schemas/choice_2_6.err
result/schemas/cos-st-restricts-1-2-err_0_0.err
result/schemas/decimal-1_1_0.err
result/schemas/decimal-2_1_0.err
result/schemas/decimal-3_1_0.err
result/schemas/extension1_0_1.err
result/schemas/extension1_0_2.err
result/schemas/facet-unionST-err1_0_0.err
result/schemas/hexbinary_0_1.err
result/schemas/issue491_0_0.err [new file with mode: 0644]
result/schemas/list0_0_1.err
result/schemas/list0_1_0.err
result/schemas/list0_1_1.err
result/schemas/ns0_0_2.err
result/schemas/ns0_0_3.err
result/schemas/ns0_0_4.err
result/schemas/ns0_1_0.err
result/schemas/ns0_1_1.err
result/schemas/ns0_1_2.err
result/schemas/oss-fuzz-51295_0_0.err [new file with mode: 0644]
result/schemas/restriction-enum-1_1_0.err
result/schemas/union2_1_1.err
result/schemas/vdv-first4_0_1.err
result/schemas/vdv-first4_0_2.err
result/valid/781333.xml.err.rdr
result/valid/huge.xml [new file with mode: 0644]
result/valid/ns2.xml
result/valid/pe-latin1.xml [new file with mode: 0644]
result/valid/pe-val-latin1.xml [new file with mode: 0644]
result/valid/t4.dtd.err
result/valid/t4a.dtd.err
result/valid/t6.dtd.err
result/valid/t8.xml.err
result/valid/t8.xml.err.rdr
result/valid/t8a.xml.err
result/valid/t8a.xml.err.rdr
result/xml2.sax
result/xml2.sax2
result/xmlid/id_tst3.xml.err
runsuite.c
runtest.c
runxmlconf.c
save.h [deleted file]
schematron.c
test/HTML/names.html [new file with mode: 0644]
test/HTML/xml-declaration-1.html [new file with mode: 0644]
test/URI/file.uri [new file with mode: 0644]
test/URI/port.uri [new file with mode: 0644]
test/URI/uri.data
test/XInclude/docs/invalid_char.xml [new file with mode: 0644]
test/XInclude/ents/invalid_char.txt [new file with mode: 0644]
test/XInclude/without-reader/fallback7.xml [new file with mode: 0644]
test/XInclude/without-reader/issue424-1.xml [new file with mode: 0644]
test/XInclude/without-reader/issue424-2.xml [new file with mode: 0644]
test/XInclude/without-reader/loop.xml [new file with mode: 0644]
test/XInclude/without-reader/max-recurse.xml [new file with mode: 0644]
test/XInclude/without-reader/ns1.xml [moved from test/XInclude/docs/ns1.xml with 100% similarity]
test/XPath/expr/functions
test/boundaries1.xml [new file with mode: 0644]
test/errors/attr5.xml [new file with mode: 0644]
test/errors/attr6.xml [new file with mode: 0644]
test/errors/empty.xml [new file with mode: 0644]
test/errors/extra-content.xml [new file with mode: 0644]
test/errors/invalid-start-tag-1.xml [new file with mode: 0644]
test/errors/invalid-start-tag-2.xml [new file with mode: 0644]
test/errors/name3.xml [new file with mode: 0644]
test/errors/quadratic-defattr.xml [new file with mode: 0644]
test/errors/rec_att_default.xml [new file with mode: 0644]
test/errors/trailing-null-1.xml [new file with mode: 0644]
test/errors/trailing-null-2.xml [new file with mode: 0644]
test/errors/truncated-utf16.xml [new file with mode: 0644]
test/errors/unclosed-element.xml [new file with mode: 0644]
test/errors/utf8-1.xml [new file with mode: 0644]
test/errors/utf8-2.xml [new file with mode: 0644]
test/issue626.xml [new file with mode: 0644]
test/issue643.xml [new file with mode: 0644]
test/ns-ent.xml [new file with mode: 0644]
test/recurse/g0.ent [new file with mode: 0644]
test/recurse/g1.ent [new file with mode: 0644]
test/recurse/g2.ent [new file with mode: 0644]
test/recurse/g3.ent [new file with mode: 0644]
test/recurse/ga.ent [new file with mode: 0644]
test/recurse/gb.ent [new file with mode: 0644]
test/recurse/gc.ent [new file with mode: 0644]
test/recurse/good.xml
test/recurse/good_attr.xml [new file with mode: 0644]
test/recurse/goodattr.xml [deleted file]
test/recurse/huge_dtd.xml [new file with mode: 0644]
test/recurse/lol3.xml [deleted file]
test/recurse/lol4.patch [deleted file]
test/recurse/lol_classic.xml [moved from test/recurse/lol5.xml with 100% similarity]
test/recurse/lol_eg.xml [new file with mode: 0644]
test/recurse/lol_ep.xml [new file with mode: 0644]
test/recurse/lol_ig_attr.xml [moved from test/recurse/lol2.xml with 100% similarity]
test/recurse/lol_ig_content.xml [moved from test/recurse/lol1.xml with 100% similarity]
test/recurse/lol_ip_content.dtd [new file with mode: 0644]
test/recurse/lol_ip_content.xml [new file with mode: 0644]
test/recurse/lol_ip_value.dtd [moved from test/recurse/lol3.dtd with 100% similarity]
test/recurse/lol_ip_value.xml [new file with mode: 0644]
test/recurse/lol_long_name.xml [moved from test/recurse/lol6.xml with 100% similarity]
test/recurse/lol_long_value.xml [moved from test/recurse/lol4.xml with 100% similarity]
test/recurse/lol_param.xml [new file with mode: 0644]
test/recurse/p0.ent [new file with mode: 0644]
test/recurse/p1.ent [new file with mode: 0644]
test/recurse/p2.ent [new file with mode: 0644]
test/recurse/p3.ent [new file with mode: 0644]
test/recurse/pa.ent [new file with mode: 0644]
test/recurse/pb.ent [new file with mode: 0644]
test/recurse/pc.ent [new file with mode: 0644]
test/schemas/issue491_0.xml [new file with mode: 0644]
test/schemas/issue491_0.xsd [new file with mode: 0644]
test/schemas/oss-fuzz-51295_0.xml [new file with mode: 0644]
test/schemas/oss-fuzz-51295_0.xsd [new file with mode: 0644]
test/valid/dtds/huge.ent [new file with mode: 0644]
test/valid/dtds/pe-latin1.ent [new file with mode: 0644]
test/valid/dtds/pe-val-latin1.dtd [new file with mode: 0644]
test/valid/dtds/pe-val-latin1.ent [new file with mode: 0644]
test/valid/huge.xml [new file with mode: 0644]
test/valid/pe-latin1.xml [new file with mode: 0644]
test/valid/pe-val-latin1.xml [new file with mode: 0644]
testAutomata.c [deleted file]
testModule.c
testOOM.c
testThreads.c
testapi.c
testchar.c
testdict.c
testlimits.c
testparser.c [new file with mode: 0644]
testrecurse.c
threads.c
tree.c
uri.c
valid.c
win32/Makefile.bcb
win32/Makefile.mingw
win32/Makefile.msvc
win32/Readme.txt
win32/configure.js
win32/defgen.xsl [deleted file]
win32/libxml2.def.src [deleted file]
xinclude.c
xlink.c
xml2-config.in
xmlIO.c
xmlcatalog.c
xmllint.c
xmlmemory.c
xmlmodule.c
xmlreader.c
xmlregexp.c
xmlsave.c
xmlschemas.c
xmlschemastypes.c
xmlstring.c
xmlwriter.c
xpath.c
xpointer.c
xstc/.gitignore [new file with mode: 0644]
xstc/fixup-tests.py
xstc/xstc.py
xzlib.c
xzlib.h [deleted file]

diff --git a/.editorconfig b/.editorconfig
new file mode 100644 (file)
index 0000000..273bb06
--- /dev/null
@@ -0,0 +1,15 @@
+# EditorConfig : http://EditorConfig.org
+
+root = true
+
+[Makefile*]
+indent_style = tab
+
+[CMakeLists.txt]
+indent_style = tab
+indent_size = 4
+
+[*.{c,h}]
+indent_style = space
+indent_size = 4
+tab_width = 8
index 5053db2..1ec700f 100644 (file)
 *.exe
 *.o
+*.la
 *.lo
-*.log
 *.pyc
-*.patch
+
+# Executables
+/example/gjobread
+/xmlcatalog
+/xmllint
+
+# Test executables
+/runsuite
+/runtest
+/runxmlconf
+/testModule
+/testThreads
+/testapi
+/testchar
+/testdict
+/testlimits
+/testparser
+/testrecurse
+
+# Tests
+/dba100000.xml
+/missing.lst
+/runsuite.log
+/runxmlconf.log
+/test.out
+/xmlconf
+
+# Generated by build system
+/config.h
+/include/libxml/xmlversion.h
+/libxml-2.0-uninstalled.pc
+/libxml-2.0.pc
+/libxml2-config.cmake
+/xml2-config
+
+# Autotools
 .deps
 .libs
-.memdump
-COPYING
-CVE-*
-INSTALL
 Makefile
 Makefile.in
-aclocal.m4
-autom4te.cache
-bissect*
-compile
-config.guess
-config.h
-config.h.in
-config.h.in~
-config.log
-config.status
-config.sub
-configure
-configure~
-dba100000.xml
-depcomp
-doc/Makefile
-doc/Makefile.in
-doc/devhelp/Makefile
-doc/devhelp/Makefile.in
-doc/examples/.deps
-doc/examples/Makefile
-doc/examples/Makefile.in
-doc/examples/io1
-doc/examples/io2
-doc/examples/parse1
-doc/examples/parse2
-doc/examples/parse3
-doc/examples/parse4
-doc/examples/reader1
-doc/examples/reader2
-doc/examples/reader3
-doc/examples/reader4
-doc/examples/testWriter
-doc/examples/tree1
-doc/examples/tree2
-doc/examples/xpath1
-doc/examples/xpath2
-example/.deps
-example/Makefile
-example/Makefile.in
-example/gjobread
-include/Makefile
-include/Makefile.in
-include/libxml/Makefile
-include/libxml/Makefile.in
-include/libxml/xmlversion.h
-install-sh
-libtool
-libxml-2.0-uninstalled.pc
-libxml-2.0.pc
-libxml2-config.cmake
-libxml2.la
-libxml2.spec
-list
-ltmain.sh
-log
-missing
-missing.lst
-m4/libtool.m4
-m4/lt*.m4
-py-compile
-python/.deps
-python/.libs
-python/Makefile
-python/Makefile.in
-python/gen_prog
-python/libxml2-export.c
-python/libxml2-py.c
-python/libxml2-py.h
-python/libxml2.py
-python/libxml2class.py
-python/libxml2class.txt
-python/libxml2mod.la
-python/setup.py
-python/tests/Makefile
-python/tests/Makefile.in
-python/tests/tmp.xml
-runsuite
-runtest
-runxmlconf
-runxmlconf.log
-stamp-h1
-tags
-test.out
-testAutomata
-testModule
-testThreads
-testapi
-testapi.c.new
-testchar
-testdict
-testdso.la
-testlimits
-testrecurse
-tmp
-tst.c
-tst
-xml2-config
-xmlcatalog
-xmlconf
-xmllint
-xstc/*-test.py
-xstc/Makefile
-xstc/Makefile.in
-xstc/Tests
-xstc/xsts-*.tar.gz
+/INSTALL
+/aclocal.m4
+/autom4te.cache
+/compile
+/config.guess
+/config.h.in
+/config.h.in~
+/config.log
+/config.status
+/config.sub
+/configure
+/configure~
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/missing
+/m4/libtool.m4
+/m4/lt*.m4
+/py-compile
+/stamp-h1
index 8aa58e9..9ef217e 100644 (file)
@@ -1,37 +1,19 @@
 .test:
-  # The image was generated with the following Dockerfile. It is also used
-  # for libxslt, that's why we need git and libgcrypt-dev.
-  #
-  # FROM ubuntu:20.04
-  # ENV DEBIAN_FRONTEND=noninteractive
-  # RUN apt-get update && \
-  #     apt-get upgrade -y && \
-  #     apt-get install -y --no-install-recommends \
-  #         curl git ca-certificates \
-  #         autoconf automake libtool pkg-config \
-  #         make gcc clang llvm \
-  #         zlib1g-dev liblzma-dev libgcrypt-dev \
-  #         python-dev python3-dev \
-  #         cmake
-  # WORKDIR /tests
-  # RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
   image: registry.gitlab.gnome.org/gnome/libxml2
   variables:
     BASE_CONFIG: "--with-ftp --with-legacy --with-xptr-locs"
+  before_script:
+    - rm -rf libxml2-build
+    - mkdir libxml2-build
+    - ln -s /tests/xmlconf libxml2-build
   script:
-    - |
-      rm -rf build
-      mkdir build
-      cd build
-      ln -s /tests/xmlconf
-      sh ../autogen.sh $BASE_CONFIG $CONFIG
-      make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
-      make CFLAGS="$CFLAGS -Werror" check
+    - sh .gitlab-ci/test.sh
 
 gcc:
   extends: .test
   variables:
-    CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=700"
+    CONFIG: "--without-tls"
+    CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=600"
 
 gcc:minimum:
   extends: .test
@@ -39,63 +21,112 @@ gcc:minimum:
     BASE_CONFIG: "--with-minimum"
     CFLAGS: "-O2"
 
+gcc:medium:
+  extends: .test
+  variables:
+    BASE_CONFIG: "--with-minimum"
+    CONFIG: "--with-threads --with-tree --with-xpath --with-output --with-html"
+    CFLAGS: "-O2"
+
+gcc:legacy:
+  extends: .test
+  only:
+    - schedules
+  variables:
+    BASE_CONFIG: "--with-legacy"
+    CFLAGS: "-O2"
+
 gcc:python3:
   extends: .test
   variables:
-    # TODO: Re-enable the warning after #208 is fixed.
-    CFLAGS: "-O2 -Wno-error=deprecated-declarations"
+    CFLAGS: "-O2"
     PYTHON: "/usr/bin/python3"
 
 gcc:static:
   extends: .test
   variables:
-    CONFIG: "--disable-shared --without-python"
+    CONFIG: "--disable-shared --without-python --without-modules"
     CFLAGS: "-O2"
 
 clang:asan:
   extends: .test
+  tags:
+    - asan
   variables:
     CONFIG: "--without-python"
     CC: clang
-    CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,unsigned-integer-overflow,implicit-conversion -fno-sanitize-recover=all -Wno-error=cast-align"
-    # LeakSanitizer requires SYS_CAP_PTRACE
-    ASAN_OPTIONS: "detect_leaks=0"
+    CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all"
     UBSAN_OPTIONS: "print_stacktrace=1"
+    ASAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"
 
 clang:msan:
   extends: .test
-  only:
-    - schedules
+#  only:
+#    - schedules
   variables:
     CONFIG: "--without-python --without-zlib --without-lzma"
     CC: clang
-    CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align"
+    CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory"
+    MSAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"
+
+.mingw:
+  tags:
+    - win32-ps
+  variables:
+    BASE_CONFIG: "--with-ftp --with-legacy --with-xptr-locs"
+    # Disabled for now, see #658
+    CONFIG: "--without-python"
+    CHERE_INVOKING: "yes"
+  before_script:
+    - $Env:Path="C:\msys64\usr\bin;$Env:Path"
+    - bash -lc 'sh .gitlab-ci/setup_mingw.sh autotools'
+  script:
+    - bash -lc 'sh .gitlab-ci/test.sh'
+  cache:
+    key: "$MSYSTEM"
+    paths:
+      - libxml2-build/xmlconf/
+
+mingw:w64-x86_64:shared:
+  extends: .mingw
+  variables:
+    CFLAGS: "-O2"
+    MSYSTEM: MINGW64
+
+mingw:w64-i686:shared:
+  extends: .mingw
+  only:
+    - schedules
+  variables:
+    CFLAGS: "-O2"
+    MSYSTEM: MINGW32
+
+# Disabled, GCC missing?
+.mingw:msys:shared:
+  extends: .mingw
+  variables:
+    CFLAGS: "-O2"
+    MSYSTEM: MSYS
 
 .cmake:linux:
   image: registry.gitlab.gnome.org/gnome/libxml2
+  before_script:
+    - rm -rf libxml2-build
+    - mkdir libxml2-build
+    - ln -s /tests/xmlconf libxml2-build
   script:
-    - cmake -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBXML2_XMLCONF_WORKING_DIR=/tests -S . -B libxml2-build
-    - cmake --build libxml2-build --target install
-    - mkdir -p libxml2-install/share/libxml2
-    - cp Copyright libxml2-install/share/libxml2
-    - cd libxml2-build
-    - ctest -VV
-  after_script:
-    - cd libxml2-install
-    - tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$CC-$SUFFIX.tar.gz *
+    - sh .gitlab-ci/test_cmake.sh
   artifacts:
     paths:
-      - libxml2-$CI_COMMIT_SHORT_SHA-$CC-$SUFFIX.tar.gz
+      - libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz
     expire_in: 1 day
 
 cmake:linux:gcc:shared:
   extends: .cmake:linux
-  only:
-    - schedules
   variables:
     BUILD_SHARED_LIBS: "ON"
     CC: gcc
-    SUFFIX: shared
+    SUFFIX: linux-gcc-shared
 
 cmake:linux:gcc:static:
   extends: .cmake:linux
@@ -104,7 +135,7 @@ cmake:linux:gcc:static:
   variables:
     BUILD_SHARED_LIBS: "OFF"
     CC: gcc
-    SUFFIX: static
+    SUFFIX: linux-gcc-static
 
 cmake:linux:clang:shared:
   extends: .cmake:linux
@@ -113,7 +144,7 @@ cmake:linux:clang:shared:
   variables:
     BUILD_SHARED_LIBS: "ON"
     CC: clang
-    SUFFIX: shared
+    SUFFIX: linux-clang-shared
 
 cmake:linux:clang:static:
   extends: .cmake:linux
@@ -122,48 +153,25 @@ cmake:linux:clang:static:
   variables:
     BUILD_SHARED_LIBS: "OFF"
     CC: clang
-    SUFFIX: static
+    SUFFIX: linux-clang-static
 
 .cmake:mingw:
   tags:
     - win32-ps
+  variables:
+    CHERE_INVOKING: "yes"
   before_script:
-    - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
-    - $Env:Path="C:\msys64\$Env:MINGW_PATH\bin;C:\msys64\usr\bin;$Env:Path"
-    - pacman --noconfirm -Syu
-    - pacman --noconfirm -S
-        $Env:MINGW_PACKAGE_PREFIX-cmake
-        $Env:MINGW_PACKAGE_PREFIX-libiconv
-        $Env:MINGW_PACKAGE_PREFIX-ninja
-        $Env:MINGW_PACKAGE_PREFIX-python
-        $Env:MINGW_PACKAGE_PREFIX-python2
-        $Env:MINGW_PACKAGE_PREFIX-xz
-        $Env:MINGW_PACKAGE_PREFIX-zlib
-    - if (-not (Test-Path 7za.exe)) {
-        Invoke-WebRequest -Uri https://www.7-zip.org/a/7z1900-extra.7z -OutFile 7z1900-extra.7z ;
-        cmake -E tar xf 7z1900-extra.7z 7za.exe
-      }
-    - if (-not (Test-Path libxml2-build/xmlconf)) {
-        Invoke-WebRequest -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz -OutFile xmlts20080827.tar.gz ;
-        .\7za.exe x xmlts20080827.tar.gz -olibxml2-build
-      }
+    - $Env:Path="C:\msys64\usr\bin;$Env:Path"
+    - bash -lc 'sh .gitlab-ci/setup_mingw.sh cmake ninja'
   script:
-    - cmake -G Ninja -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B libxml2-build
-    - cmake --build libxml2-build --target install
-    - New-Item -ItemType Directory libxml2-install\share\libxml2
-    - Copy-Item Copyright libxml2-install\share\libxml2
-    - cd libxml2-build
-    - ctest -VV
-  after_script:
-    - .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:MINGW_PACKAGE_PREFIX-$Env:SUFFIX.7z .\libxml2-install\*
+    - bash -lc 'sh .gitlab-ci/test_cmake.sh -G Ninja'
   cache:
-    key: "$MINGW_PACKAGE_PREFIX"
+    key: "$MSYSTEM"
     paths:
       - libxml2-build/xmlconf/
-      - 7za.exe
   artifacts:
     paths:
-      - libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:MINGW_PACKAGE_PREFIX-$Env:SUFFIX.7z
+      - libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:SUFFIX.tar.gz
     expire_in: 1 day
 
 cmake:mingw:w64-i686:shared:
@@ -172,9 +180,8 @@ cmake:mingw:w64-i686:shared:
     - schedules
   variables:
     BUILD_SHARED_LIBS: "ON"
-    MINGW_PACKAGE_PREFIX: mingw-w64-i686
-    MINGW_PATH: mingw32
-    SUFFIX: shared
+    MSYSTEM: MINGW32
+    SUFFIX: mingw-w64-i686-shared
 
 cmake:mingw:w64-i686:static:
   extends: .cmake:mingw
@@ -182,17 +189,15 @@ cmake:mingw:w64-i686:static:
     - schedules
   variables:
     BUILD_SHARED_LIBS: "OFF"
-    MINGW_PACKAGE_PREFIX: mingw-w64-i686
-    MINGW_PATH: mingw32
-    SUFFIX: static
+    MSYSTEM: MINGW32
+    SUFFIX: mingw-w64-i686-static
 
 cmake:mingw:w64-x86_64:shared:
   extends: .cmake:mingw
   variables:
     BUILD_SHARED_LIBS: "ON"
-    MINGW_PACKAGE_PREFIX: mingw-w64-x86_64
-    MINGW_PATH: mingw64
-    SUFFIX: shared
+    MSYSTEM: MINGW64
+    SUFFIX: mingw-w64-x86_64-shared
 
 cmake:mingw:w64-x86_64:static:
   extends: .cmake:mingw
@@ -200,41 +205,19 @@ cmake:mingw:w64-x86_64:static:
     - schedules
   variables:
     BUILD_SHARED_LIBS: "OFF"
-    MINGW_PACKAGE_PREFIX: mingw-w64-x86_64
-    MINGW_PATH: mingw64
-    SUFFIX: static
+    MSYSTEM: MINGW64
+    SUFFIX: mingw-w64-x86_64-static
 
 .cmake:msvc:
   tags:
     - win32-ps
   variables:
+    # MSVC warns when casting `const char **` to `void *` which is wrong.
+    # Disable warning C4090.
+    CFLAGS: /WX /wd4090
     CMAKE_VERSION: 3.19.4
-  before_script:
-    - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
-    - if (-not (Test-Path cmake-$Env:CMAKE_VERSION-win64-x64)) {
-        Invoke-WebRequest -Uri http://github.com/Kitware/CMake/releases/download/v$Env:CMAKE_VERSION/cmake-$Env:CMAKE_VERSION-win64-x64.zip -OutFile cmake-$Env:CMAKE_VERSION-win64-x64.zip ;
-        Expand-Archive cmake-$Env:CMAKE_VERSION-win64-x64.zip -DestinationPath .
-      }
-    - $Env:Path="$Env:CI_PROJECT_DIR\cmake-$Env:CMAKE_VERSION-win64-x64\bin;$Env:Path"
-    - if (-not (Test-Path 7za.exe)) {
-        Invoke-WebRequest -Uri https://www.7-zip.org/a/7z1900-extra.7z -OutFile 7z1900-extra.7z ;
-        cmake -E tar xf 7z1900-extra.7z 7za.exe
-      }
-    - if (-not (Test-Path libxml2-build/xmlconf)) {
-        Invoke-WebRequest -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz -OutFile xmlts20080827.tar.gz ;
-        .\7za.exe x xmlts20080827.tar.gz -olibxml2-build
-      }
   script:
-    - cmake -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=OFF -S . -B libxml2-build
-    - cmake --build libxml2-build --config Debug --target install
-    - cmake --build libxml2-build --config Release --target install
-    - New-Item -ItemType Directory libxml2-install\share\libxml2
-    - Copy-Item Copyright libxml2-install\share\libxml2
-    - cd libxml2-build
-    - ctest -C Debug -VV
-    - ctest -C Release -VV
-  after_script:
-    - .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
+    - .gitlab-ci/Test-Msvc
   cache:
     key: "msvc"
     paths:
diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile
new file mode 100644 (file)
index 0000000..3937c7d
--- /dev/null
@@ -0,0 +1,16 @@
+# The image is also used for libxslt, that's why we need git and
+# libgcrypt-dev.
+
+FROM ubuntu:22.10
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && \
+    apt-get upgrade -y && \
+    apt-get install -y --no-install-recommends \
+        curl git ca-certificates \
+        autoconf automake libtool pkg-config \
+        make gcc clang llvm \
+        zlib1g-dev liblzma-dev libgcrypt-dev \
+        python2-dev python3-dev \
+        cmake
+WORKDIR /tests
+RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
diff --git a/.gitlab-ci/Test-Msvc.ps1 b/.gitlab-ci/Test-Msvc.ps1
new file mode 100644 (file)
index 0000000..796d75c
--- /dev/null
@@ -0,0 +1,49 @@
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+
+if (-not (Test-Path cmake-$Env:CMAKE_VERSION-win64-x64)) {
+    Invoke-WebRequest `
+        -Uri http://github.com/Kitware/CMake/releases/download/v$Env:CMAKE_VERSION/cmake-$Env:CMAKE_VERSION-win64-x64.zip `
+        -OutFile cmake-$Env:CMAKE_VERSION-win64-x64.zip
+    Expand-Archive cmake-$Env:CMAKE_VERSION-win64-x64.zip -DestinationPath .
+}
+$Env:Path="$Env:CI_PROJECT_DIR\cmake-$Env:CMAKE_VERSION-win64-x64\bin;$Env:Path"
+
+if (-not (Test-Path 7za.exe)) {
+    Invoke-WebRequest `
+        -Uri https://www.7-zip.org/a/7z1900-extra.7z `
+        -OutFile 7z1900-extra.7z
+    cmake -E tar xf 7z1900-extra.7z 7za.exe
+}
+
+if (-not (Test-Path libxml2-build/xmlconf)) {
+    Invoke-WebRequest `
+        -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz `
+        -OutFile xmlts20080827.tar.gz ;
+    .\7za.exe x xmlts20080827.tar.gz -olibxml2-build
+}
+
+cmake `
+    -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" `
+    -DCMAKE_INSTALL_PREFIX=libxml2-install `
+    -DLIBXML2_WITH_ICONV=OFF `
+    -DLIBXML2_WITH_LZMA=OFF `
+    -DLIBXML2_WITH_PYTHON=OFF `
+    -DLIBXML2_WITH_ZLIB=OFF `
+    -S . -B libxml2-build
+cmake --build libxml2-build --config Debug --target install
+cmake --build libxml2-build --config Release --target install
+New-Item -ItemType Directory libxml2-install\share\libxml2
+Copy-Item Copyright libxml2-install\share\libxml2
+
+cd libxml2-build
+ctest -C Debug -VV
+if ($LastExitCode -ne 0) {
+    throw "ctest failed"
+}
+ctest -C Release -VV
+if ($LastExitCode -ne 0) {
+    throw "ctest failed"
+}
+cd ..
+
+.\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
diff --git a/.gitlab-ci/llvm-symbolizer b/.gitlab-ci/llvm-symbolizer
new file mode 100755 (executable)
index 0000000..cfc85e8
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Newer versions of llvm-symbolizer require libxml2 themselves. Running
+# a test program with LD_LIBRARY_PATH set to .libs makes llvm-symbolizer
+# pick up the tested development version of libxml2 which breaks
+# completely if the build is instrumented with ASan. This wrapper script
+# invokes llvm-symbolizer with an empty LD_LIBRARY_PATH.
+
+LD_LIBRARY_PATH='' llvm-symbolizer "$@"
diff --git a/.gitlab-ci/setup_mingw.sh b/.gitlab-ci/setup_mingw.sh
new file mode 100644 (file)
index 0000000..7e61c34
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+pacman --noconfirm -Syu
+
+prefix=
+if [ -n "$MINGW_PACKAGE_PREFIX" ]; then
+    prefix="${MINGW_PACKAGE_PREFIX}-"
+fi
+for module in libiconv python xz zlib "$@"; do
+    pacman --noconfirm -S --needed ${prefix}$module
+done
+
+if [ ! -e libxml2-build/xmlconf ]; then
+    mkdir -p libxml2-build
+    wget https://www.w3.org/XML/Test/xmlts20080827.tar -O - |
+       tar -x -C libxml2-build
+fi
diff --git a/.gitlab-ci/test.sh b/.gitlab-ci/test.sh
new file mode 100644 (file)
index 0000000..0d8942f
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+cd libxml2-build
+sh ../autogen.sh $BASE_CONFIG $CONFIG
+make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
+make CFLAGS="$CFLAGS -Werror" check
diff --git a/.gitlab-ci/test_cmake.sh b/.gitlab-ci/test_cmake.sh
new file mode 100644 (file)
index 0000000..99c22a8
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+CFLAGS="-Werror $CFLAGS" \
+cmake "$@" \
+    -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
+    -DCMAKE_INSTALL_PREFIX=libxml2-install \
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+    -S . -B libxml2-build
+cmake --build libxml2-build --target install
+
+(cd libxml2-build && ctest -VV)
+
+mkdir -p libxml2-install/share/libxml2
+cp Copyright libxml2-install/share/libxml2
+(cd libxml2-install &&
+    tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz *)
index 730aec7..3a074da 100644 (file)
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
+cmake_minimum_required(VERSION 3.18)
 
 file(STRINGS "configure.ac" CONFIGURE_AC_LINES)
 foreach(line ${CONFIGURE_AC_LINES})
@@ -16,9 +16,11 @@ include(CheckCSourceCompiles)
 include(CheckFunctionExists)
 include(CheckIncludeFiles)
 include(CheckLibraryExists)
+include(CheckLinkerFlag)
 include(CheckStructHasMember)
 include(CheckSymbolExists)
 include(CMakePackageConfigHelpers)
+include(FindPkgConfig)
 include(GNUInstallDirs)
 
 option(BUILD_SHARED_LIBS "Build shared libraries" ON)
@@ -44,13 +46,13 @@ option(LIBXML2_WITH_PUSH "Add the PUSH parser interfaces" ON)
 option(LIBXML2_WITH_PYTHON "Build Python bindings" ON)
 option(LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON)
 option(LIBXML2_WITH_REGEXPS "Add Regular Expressions support" ON)
-option(LIBXML2_WITH_RUN_DEBUG "Add the runtime debugging module" OFF)
 option(LIBXML2_WITH_SAX1 "Add the older SAX1 interface" ON)
 option(LIBXML2_WITH_SCHEMAS "Add Relax-NG and Schemas support" ON)
 option(LIBXML2_WITH_SCHEMATRON "Add Schematron support" ON)
 option(LIBXML2_WITH_TESTS "Build tests" ON)
 option(LIBXML2_WITH_THREADS "Add multithread support" ON)
 option(LIBXML2_WITH_THREAD_ALLOC "Add per-thread memory" OFF)
+option(LIBXML2_WITH_TLS "Enable thread-local storage" OFF)
 option(LIBXML2_WITH_TREE "Add the DOM like tree manipulation APIs" ON)
 set(LIBXML2_WITH_TRIO OFF)
 set(LIBXML2_WITH_UNICODE ON)
@@ -63,41 +65,16 @@ option(LIBXML2_WITH_XPTR_LOCS "Add support for XPointer locations" OFF)
 option(LIBXML2_WITH_ZLIB "Use libz" ON)
 set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
 
-if(LIBXML2_WITH_ICONV)
-       find_package(Iconv REQUIRED)
-endif()
-
-if(LIBXML2_WITH_ICU)
-       find_package(ICU REQUIRED COMPONENTS data i18n uc)
-endif()
-
-if(LIBXML2_WITH_LZMA)
-       find_package(LibLZMA REQUIRED)
-endif()
-
 if(LIBXML2_WITH_PYTHON)
        check_include_files(unistd.h HAVE_UNISTD_H)
        check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
-       if(HAVE_UNISTD_H AND HAVE_F_GETFL)
-               find_package(Python COMPONENTS Interpreter Development REQUIRED)
-       else()
-               find_package(Python2 COMPONENTS Interpreter Development REQUIRED)
-               add_library(Python::Python ALIAS Python2::Python)
-               set(Python_EXECUTABLE ${Python2_EXECUTABLE})
-               set(Python_SITEARCH ${Python2_SITEARCH})
-       endif()
-       set(LIBXML2_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
-endif()
-
-if(LIBXML2_WITH_THREADS)
-       find_package(Threads REQUIRED)
-endif()
-
-if(LIBXML2_WITH_ZLIB)
-       find_package(ZLIB REQUIRED)
+       find_package(Python COMPONENTS Interpreter Development REQUIRED)
+        #set(LIBXML2_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
+        set(LIBXML2_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python"
+           CACHE PATH "Python bindings install directory")
 endif()
 
-foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
+foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
        if(LIBXML2_${VARIABLE})
                set(${VARIABLE} 1)
        else()
@@ -116,23 +93,32 @@ math(EXPR LIBXML_VERSION_NUMBER "
 set(MODULE_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}")
 
 set(PACKAGE "libxml2")
-set(PACKAGE_BUGREPORT "xml@gnome.org")
 set(PACKAGE_NAME "libxml2")
 set(PACKAGE_STRING "libxml2 ${VERSION}")
 set(PACKAGE_TARNAME "libxml2")
 set(PACKAGE_URL "https://gitlab.gnome.org/GNOME/libxml2")
 set(PACKAGE_VERSION ${VERSION})
 
-if(LIBLZMA_FOUND)
-       list(APPEND CMAKE_REQUIRED_LIBRARIES LibLZMA::LibLZMA)
+if(LIBXML2_WITH_ICONV)
+       find_package(Iconv REQUIRED)
+endif()
+
+if(LIBXML2_WITH_ICU)
+       find_package(ICU REQUIRED COMPONENTS data i18n uc)
 endif()
 
-if(Threads_FOUND)
+if(LIBXML2_WITH_LZMA)
+       find_package(LibLZMA REQUIRED)
+endif()
+
+if(LIBXML2_WITH_THREADS)
+       find_package(Threads REQUIRED)
+       set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
        list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
 endif()
 
-if(ZLIB_FOUND)
-       list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
+if(LIBXML2_WITH_ZLIB)
+       find_package(ZLIB REQUIRED)
 endif()
 
 if (NOT MSVC)
@@ -144,22 +130,7 @@ if (NOT MSVC)
        if(HAVE_ATTRIBUTE_DESTRUCTOR)
                set(ATTRIBUTE_DESTRUCTOR "__attribute__((destructor))")
        endif()
-       check_c_source_compiles("
-               #include <netdb.h>
-               int main() { (void) gethostbyname((const char*) \"\"); return 0; }
-       " GETHOSTBYNAME_ARG_CAST_CONST)
-       if(NOT GETHOSTBYNAME_ARG_CAST_CONST)
-               set(GETHOSTBYNAME_ARG_CAST "(char *)")
-       else()
-               set(GETHOSTBYNAME_ARG_CAST "/**/")
-       endif()
        check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
-       check_include_files(arpa/nameser.h HAVE_ARPA_NAMESER_H)
-       check_struct_has_member("struct sockaddr_storage" ss_family "sys/socket.h;sys/types.h" HAVE_SS_FAMILY)
-       check_struct_has_member("struct sockaddr_storage" __ss_family "sys/socket.h;sys/types.h" HAVE_BROKEN_SS_FAMILY)
-       if(HAVE_BROKEN_SS_FAMILY)
-               set(ss_family __ss_family)
-       endif()
        check_function_exists(class HAVE_CLASS)
        check_include_files(dlfcn.h HAVE_DLFCN_H)
        check_library_exists(dl dlopen "" HAVE_DLOPEN)
@@ -167,7 +138,6 @@ if (NOT MSVC)
        check_include_files(fcntl.h HAVE_FCNTL_H)
        check_function_exists(fpclass HAVE_FPCLASS)
        check_function_exists(ftime HAVE_FTIME)
-       check_function_exists(getaddrinfo HAVE_GETADDRINFO)
        check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
        check_include_files(inttypes.h HAVE_INTTYPES_H)
        check_function_exists(isascii HAVE_ISASCII)
@@ -178,9 +148,6 @@ if (NOT MSVC)
        check_include_files(netdb.h HAVE_NETDB_H)
        check_include_files(netinet/in.h HAVE_NETINET_IN_H)
        check_include_files(poll.h HAVE_POLL_H)
-       check_function_exists(putenv HAVE_PUTENV)
-       check_function_exists(rand_r HAVE_RAND_R)
-       check_include_files(resolv.h HAVE_RESOLV_H)
        check_library_exists(dld shl_load "" HAVE_SHLLOAD)
        check_function_exists(stat HAVE_STAT)
        check_include_files(stdint.h HAVE_STDINT_H)
@@ -190,21 +157,9 @@ if (NOT MSVC)
        check_include_files(sys/stat.h HAVE_SYS_STAT_H)
        check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
        check_include_files(sys/time.h HAVE_SYS_TIME_H)
-       check_include_files(sys/types.h HAVE_SYS_TYPES_H)
        check_include_files(unistd.h HAVE_UNISTD_H)
-       check_function_exists(va_copy HAVE_VA_COPY)
-       check_function_exists(__va_copy HAVE___VA_COPY)
-       set(LT_OBJDIR ".libs/")
-       check_c_source_compiles("
-               #include <sys/socket.h>
-               #include <sys/types.h>
-               int main() { (void) send(1, (const char*) \"\", 1, 1); return 0; }
-       " SEND_ARG2_CAST_CONST)
-       if(NOT SEND_ARG2_CAST_CONST)
-               set(SEND_ARG2_CAST "(char *)")
-       else()
-               set(SEND_ARG2_CAST "/**/")
-       endif()
+       check_symbol_exists(va_copy stdarg.h HAVE_VA_COPY)
+       check_symbol_exists(__va_copy stdarg.h HAVE___VA_COPY)
        check_c_source_compiles("
                #include <stdarg.h>
                void a(va_list* ap) {};
@@ -218,7 +173,6 @@ if (NOT MSVC)
        check_c_source_compiles("
                #include <stddef.h>
                #include <sys/socket.h>
-               #include <sys/types.h>
                int main() { (void) getsockopt(1, 1, 1, NULL, (socklen_t*) NULL); return 0; }
        " XML_SOCKLEN_T_SOCKLEN_T)
        if(XML_SOCKLEN_T_SOCKLEN_T)
@@ -227,7 +181,6 @@ if (NOT MSVC)
                check_c_source_compiles("
                        #include <stddef.h>
                        #include <sys/socket.h>
-                       #include <sys/types.h>
                        int main() { (void) getsockopt(1, 1, 1, NULL, (size_t*) NULL); return 0; }
                " XML_SOCKLEN_T_SIZE_T)
                if(XML_SOCKLEN_T_SIZE_T)
@@ -236,7 +189,6 @@ if (NOT MSVC)
                        check_c_source_compiles("
                                #include <stddef.h>
                                #include <sys/socket.h>
-                               #include <sys/types.h>
                                int main() { (void) getsockopt (1, 1, 1, NULL, (int*) NULL); return 0; }
                        " XML_SOCKLEN_T_INT)
                        set(XML_SOCKLEN_T int)
@@ -244,6 +196,32 @@ if (NOT MSVC)
        endif()
 endif()
 
+if(LIBXML2_WITH_TLS)
+       check_c_source_compiles(
+               "_Thread_local int v; int main(){return 0;}"
+               XML_THREAD_LOCAL_C11
+       )
+       if (XML_THREAD_LOCAL_C11)
+               set(XML_THREAD_LOCAL "_Thread_local")
+       else()
+               check_c_source_compiles(
+                       "__thread int v; int main(){return 0;}"
+                       XML_THREAD_LOCAL_THREAD
+               )
+               if (XML_THREAD_LOCAL_THREAD)
+                       set(XML_THREAD_LOCAL "__thread")
+               else()
+                       check_c_source_compiles(
+                               "__declspec(thread) int v; int main(){return 0;}"
+                               XML_THREAD_LOCAL_DECLSPEC
+                       )
+                       if (XML_THREAD_LOCAL_DECLSPEC)
+                               set(XML_THREAD_LOCAL "__declspec(thread)")
+                       endif()
+               endif()
+       endif()
+endif()
+
 set(
        LIBXML2_HDRS
        include/libxml/c14n.h
@@ -362,22 +340,9 @@ add_library(LibXml2::LibXml2 ALIAS LibXml2)
 
 target_compile_definitions(LibXml2 PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
 
-if(NOT BUILD_SHARED_LIBS)
-       target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC)
-       set(XML_CFLAGS "-DLIBXML_STATIC")
-endif()
-
-if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
-       if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
-               target_link_options(LibXml2 PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
-       endif()
-endif()
-
 if(LIBXML2_WITH_THREADS)
        target_compile_definitions(LibXml2 PRIVATE _REENTRANT)
-       if(WIN32)
-               target_compile_definitions(LibXml2 PRIVATE HAVE_WIN32_THREADS)
-       else()
+        if(NOT WIN32)
                check_include_files(pthread.h HAVE_PTHREAD_H)
        endif()
 endif()
@@ -390,14 +355,16 @@ target_include_directories(
        $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/libxml2>
 )
 
-if(HAVE_DLOPEN)
-       target_link_libraries(LibXml2 PRIVATE dl)
-       set(MODULE_PLATFORM_LIBS "-ldl")
-endif()
+if(LIBXML2_WITH_MODULES)
+       if(HAVE_DLOPEN)
+               target_link_libraries(LibXml2 PRIVATE dl)
+               set(MODULE_PLATFORM_LIBS "-ldl")
+       endif()
 
-if(HAVE_SHLLOAD)
-       target_link_libraries(LibXml2 PRIVATE dld)
-       set(MODULE_PLATFORM_LIBS "-ldld")
+       if(HAVE_SHLLOAD)
+               target_link_libraries(LibXml2 PRIVATE dld)
+               set(MODULE_PLATFORM_LIBS "-ldld")
+       endif()
 endif()
 
 if(UNIX)
@@ -407,7 +374,7 @@ endif()
 
 if(WIN32)
        target_link_libraries(LibXml2 PRIVATE ws2_32)
-       set(WIN32_EXTRA_LIBADD "-lws2_32")
+       set(WINSOCK_LIBS "-lws2_32")
 endif()
 
 if(LIBXML2_WITH_ICONV)
@@ -420,25 +387,61 @@ endif()
 if(LIBXML2_WITH_ICU)
        target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
        if(WIN32)
-               set(ICU_LIBS "-licudt -licuin -licuuc")
+               set(ICU_LDFLAGS "-licudt -licuin -licuuc")
+       else()
+               set(ICU_LDFLAGS "-licudata -licui18n -licuuc")
+       endif()
+       list(APPEND XML_PRIVATE_LIBS "${ICU_LDFLAGS}")
+       pkg_check_modules(ICU_PC IMPORTED_TARGET icu-i18n)
+       if(ICU_PC_FOUND)
+               list(APPEND XML_PC_REQUIRES icu-i18n)
        else()
-               set(ICU_LIBS "-licudata -licui18n -licuuc")
+               list(APPEND XML_PC_LIBS "${ICU_LDFLAGS}")
        endif()
 endif()
 
 if(LIBXML2_WITH_LZMA)
        target_link_libraries(LibXml2 PRIVATE LibLZMA::LibLZMA)
-       set(LZMA_LIBS "-llzma")
+       set(LibLZMA_LDFLAGS "-llzma")
+       list(APPEND XML_PRIVATE_LIBS "${LibLZMA_LDFLAGS}")
+       pkg_check_modules(LibLZMA_PC IMPORTED_TARGET liblzma)
+       if(LibLZMA_PC_FOUND)
+               list(APPEND XML_PC_REQUIRES liblzma)
+       else()
+               list(APPEND XML_PC_LIBS "${LibLZMA_LDFLAGS}")
+       endif()
 endif()
 
 if(LIBXML2_WITH_THREADS)
        target_link_libraries(LibXml2 PRIVATE Threads::Threads)
-       set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
 endif()
 
 if(LIBXML2_WITH_ZLIB)
        target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
-       set(Z_LIBS "-lz")
+       set(ZLIB_LDFLAGS "-lz")
+       list(APPEND XML_PRIVATE_LIBS "${ZLIB_LDFLAGS}")
+       pkg_check_modules(ZLIB_PC IMPORTED_TARGET zlib)
+       if(ZLIB_PC_FOUND)
+               list(APPEND XML_PC_REQUIRES zlib)
+       else()
+               list(APPEND XML_PC_LIBS "${ZLIB_LDFLAGS}")
+       endif()
+endif()
+
+if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
+       # These compiler flags can break the checks above so keep them here.
+       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow \
+-Wpointer-arith -Wcast-align -Wwrite-strings \
+-Wstrict-prototypes -Wmissing-prototypes \
+-Wno-long-long -Wno-format-extra-args")
+
+       if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
+               check_linker_flag(C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION)
+               if (FLAG_UNDEFINED_VERSION)
+                       target_link_options(LibXml2 PRIVATE "LINKER:--undefined-version")
+               endif()
+               target_link_options(LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
+       endif()
 endif()
 
 set_target_properties(
@@ -449,6 +452,7 @@ set_target_properties(
        POSITION_INDEPENDENT_CODE ON
        PREFIX lib
        VERSION ${PROJECT_VERSION}
+        SOVERSION ${LIBXML_MAJOR_VERSION}
 )
 
 if(MSVC)
@@ -513,11 +517,11 @@ if(LIBXML2_WITH_TESTS)
                runxmlconf
                runsuite
                testapi
-               testAutomata
                testchar
                testdict
                testModule
                testlimits
+               testparser
                testrecurse
                testThreads
        )
@@ -528,13 +532,11 @@ if(LIBXML2_WITH_TESTS)
        endforeach()
        if(Threads_FOUND)
                foreach(TEST runtest testThreads)
-                       if(WIN32)
-                               target_compile_definitions(${TEST} PRIVATE HAVE_WIN32_THREADS)
-                       endif()
                        target_link_libraries(${TEST} Threads::Threads)
                endforeach()
        endif()
        add_test(NAME runtest COMMAND runtest --out ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+       add_test(NAME runsuite COMMAND runsuite WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
        if(EXISTS ${LIBXML2_XMLCONF_WORKING_DIR}/xmlconf/xmlconf.xml)
                add_test(NAME runxmlconf COMMAND runxmlconf WORKING_DIRECTORY ${LIBXML2_XMLCONF_WORKING_DIR})
        endif()
@@ -543,6 +545,7 @@ if(LIBXML2_WITH_TESTS)
        endif()
        add_test(NAME testchar COMMAND testchar)
        add_test(NAME testdict COMMAND testdict)
+       add_test(NAME testparser COMMAND testparser)
        add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
        add_test(NAME testThreads COMMAND testThreads WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 endif()
@@ -584,6 +587,9 @@ if(LIBXML2_WITH_PYTHON)
                PREFIX lib
                VERSION ${PROJECT_VERSION}
        )
+       if (WIN32)
+               set_target_properties(LibXml2Mod PROPERTIES SUFFIX ".pyd")
+       endif()
        install(
                TARGETS LibXml2Mod
                ARCHIVE DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT development
@@ -652,10 +658,29 @@ if(LIBXML2_WITH_PYTHON)
        configure_file(python/setup.py.in setup.py @ONLY)
 endif()
 
+set(NON_PC_LIBS "${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${WINSOCK_LIBS}")
+list(APPEND XML_PC_LIBS "${NON_PC_LIBS}")
+list(APPEND XML_PRIVATE_LIBS "${NON_PC_LIBS}")
+list(REMOVE_DUPLICATES XML_PC_LIBS)
+list(REMOVE_DUPLICATES XML_PRIVATE_LIBS)
+
+list(JOIN XML_PC_REQUIRES " " XML_PC_REQUIRES)
+list(JOIN XML_PC_LIBS " " XML_PC_LIBS)
+list(JOIN XML_PRIVATE_LIBS " " XML_PRIVATE_LIBS)
+
 set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
 set(XML_LIBDIR "-L\${libdir}")
 set(XML_LIBS "-lxml2")
-set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${LIBM} ${WIN32_EXTRA_LIBADD}")
+
+if(BUILD_SHARED_LIBS)
+       set(XML_PC_PRIVATE ".private")
+       set(XML_PC_LIBS_PRIVATE "
+Libs.private:")
+else()
+       target_compile_definitions(LibXml2 PUBLIC LIBXML_STATIC)
+       set(XML_CFLAGS "-DLIBXML_STATIC")
+       set(XML_PRIVATE_LIBS_NO_SHARED "${XML_PRIVATE_LIBS}")
+endif()
 
 file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
 string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
@@ -701,7 +726,6 @@ set(CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "${PACKAGE_TARNAME}-utils")
 set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs")
 set(CPACK_NSIS_PACKAGE_NAME ${PACKAGE_STRING})
 set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_URL})
-set(CPACK_PACKAGE_CONTACT ${PACKAGE_BUGREPORT})
 set(CPACK_PACKAGE_DISPLAY_NAME ${PACKAGE_STRING})
 set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_TARNAME}-${PACKAGE_VERSION}")
 set(CPACK_PACKAGE_NAME ${PACKAGE_TARNAME})
index d613185..c058f02 100644 (file)
--- a/Copyright
+++ b/Copyright
@@ -1,4 +1,4 @@
-Except where otherwise noted in the source code (e.g. the files hash.c,
+Except where otherwise noted in the source code (e.g. the files dict.c,
 list.c and the trio files, which are covered by a similar licence but
 with different Copyright notices) all the files are:
 
index ba88690..097ed23 100644 (file)
 #include <ctype.h>
 #include <stdlib.h>
 
+#include <libxml/HTMLparser.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlerror.h>
-#include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/entities.h>
 #include <libxml/encoding.h>
-#include <libxml/valid.h>
 #include <libxml/xmlIO.h>
-#include <libxml/globals.h>
 #include <libxml/uri.h>
 
-#include "buf.h"
-#include "enc.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
+#include "private/html.h"
+#include "private/io.h"
+#include "private/parser.h"
+#include "private/tree.h"
 
 #define HTML_MAX_NAMELEN 1000
 #define HTML_PARSER_BIG_BUFFER_SIZE 1000
 #define HTML_PARSER_BUFFER_SIZE 100
 
-/* #define DEBUG */
-/* #define DEBUG_PUSH */
-
 static int htmlOmittedDefaultValue = 1;
 
 xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
@@ -145,7 +145,7 @@ htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
  *
  * Pushes a new element name on top of the name stack
  *
- * Returns 0 in case of error, the index in the stack otherwise
+ * Returns -1 in case of error, the index in the stack otherwise
  */
 static int
 htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value)
@@ -155,15 +155,17 @@ htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value)
     if ((ctxt->html < 10) && (xmlStrEqual(value, BAD_CAST "body")))
         ctxt->html = 10;
     if (ctxt->nameNr >= ctxt->nameMax) {
-        ctxt->nameMax *= 2;
-        ctxt->nameTab = (const xmlChar * *)
-                         xmlRealloc((xmlChar * *)ctxt->nameTab,
-                                    ctxt->nameMax *
-                                    sizeof(ctxt->nameTab[0]));
-        if (ctxt->nameTab == NULL) {
+        size_t newSize = ctxt->nameMax * 2;
+        const xmlChar **tmp;
+
+        tmp = xmlRealloc((xmlChar **) ctxt->nameTab,
+                         newSize * sizeof(ctxt->nameTab[0]));
+        if (tmp == NULL) {
             htmlErrMemory(ctxt, NULL);
-            return (0);
+            return (-1);
         }
+        ctxt->nameTab = tmp;
+        ctxt->nameMax = newSize;
     }
     ctxt->nameTab[ctxt->nameNr] = value;
     ctxt->name = value;
@@ -270,8 +272,6 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
  *
  * Clean macros, not dependent of an ASCII context, expect UTF-8 encoding
  *
- *   CURRENT Returns the current char value, with the full decoding of
- *           UTF-8 if we are using this mode. It returns an int.
  *   NEXT    Skip to the next character, this does the proper decoding
  *           in UTF-8 mode. It also pop-up unfinished entities on the fly.
  *   NEXTL(l) Skip the current unicode character of l xmlChars long.
@@ -291,20 +291,17 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
 
 #define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
                   (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
-       xmlParserInputShrink(ctxt->input)
+       xmlParserShrink(ctxt)
 
 #define GROW if ((ctxt->progressive == 0) &&                           \
                 (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK))   \
-       xmlParserInputGrow(ctxt->input, INPUT_CHUNK)
-
-#define CURRENT ((int) (*ctxt->input->cur))
+       xmlParserGrow(ctxt)
 
 #define SKIP_BLANKS htmlSkipBlankChars(ctxt)
 
 /* Imported from XML */
 
-/* #define CUR (ctxt->token ? ctxt->token : (int) (*ctxt->input->cur)) */
-#define CUR ((int) (*ctxt->input->cur))
+#define CUR (*ctxt->input->cur)
 #define NEXT xmlNextChar(ctxt)
 
 #define RAW (ctxt->token ? -1 : (*ctxt->input->cur))
@@ -324,10 +321,9 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
  ************/
 
 #define CUR_CHAR(l) htmlCurrentChar(ctxt, &l)
-#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
 
 #define COPY_BUF(l,b,i,v)                                              \
-    if (l == 1) b[i++] = (xmlChar) v;                                  \
+    if (l == 1) b[i++] = v;                                            \
     else i += xmlCopyChar(l,&b[i],v)
 
 /**
@@ -349,8 +345,7 @@ htmlFindEncoding(xmlParserCtxtPtr ctxt) {
     const xmlChar *start, *cur, *end;
 
     if ((ctxt == NULL) || (ctxt->input == NULL) ||
-        (ctxt->input->encoding != NULL) || (ctxt->input->buf == NULL) ||
-        (ctxt->input->buf->encoder != NULL))
+        (ctxt->input->flags & XML_INPUT_HAS_ENCODING))
         return(NULL);
     if ((ctxt->input->cur == NULL) || (ctxt->input->end == NULL))
         return(NULL);
@@ -409,7 +404,14 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
        *len = 0;
        return(ctxt->token);
     }
-    if (ctxt->charset != XML_CHAR_ENCODING_UTF8) {
+
+    if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) {
+        xmlParserGrow(ctxt);
+        if (ctxt->instate == XML_PARSER_EOF)
+            return(0);
+    }
+
+    if ((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) {
         xmlChar * guess;
         xmlCharEncodingHandlerPtr handler;
 
@@ -418,7 +420,7 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
          * a compatible encoding for the ASCII set, since
          * HTML constructs only use < 128 chars
          */
-        if ((int) *ctxt->input->cur < 0x80) {
+        if (*ctxt->input->cur < 0x80) {
             *len = 1;
             if ((*ctxt->input->cur == 0) &&
                 (ctxt->input->cur < ctxt->input->end)) {
@@ -426,7 +428,7 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
                                 "Char 0x%X out of allowed range\n", 0);
                 return(' ');
             }
-            return((int) *ctxt->input->cur);
+            return(*ctxt->input->cur);
         }
 
         /*
@@ -436,9 +438,6 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
         if (guess == NULL) {
             xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1);
         } else {
-            if (ctxt->input->encoding != NULL)
-                xmlFree((xmlChar *) ctxt->input->encoding);
-            ctxt->input->encoding = guess;
             handler = xmlFindCharEncodingHandler((const char *) guess);
             if (handler != NULL) {
                 /*
@@ -451,8 +450,9 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
                 htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
                              "Unsupported encoding %s", guess, NULL);
             }
+            xmlFree(guess);
         }
-        ctxt->charset = XML_CHAR_ENCODING_UTF8;
+        ctxt->input->flags |= XML_INPUT_HAS_ENCODING;
     }
 
     /*
@@ -469,29 +469,21 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
     cur = ctxt->input->cur;
     c = *cur;
     if (c & 0x80) {
+        size_t avail;
+
         if ((c & 0x40) == 0)
             goto encoding_error;
-        if (cur[1] == 0) {
-            xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-            cur = ctxt->input->cur;
-        }
-        if ((cur[1] & 0xc0) != 0x80)
+
+        avail = ctxt->input->end - ctxt->input->cur;
+
+        if ((avail < 2) || ((cur[1] & 0xc0) != 0x80))
             goto encoding_error;
         if ((c & 0xe0) == 0xe0) {
-
-            if (cur[2] == 0) {
-                xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                cur = ctxt->input->cur;
-            }
-            if ((cur[2] & 0xc0) != 0x80)
+            if ((avail < 3) || ((cur[2] & 0xc0) != 0x80))
                 goto encoding_error;
             if ((c & 0xf0) == 0xf0) {
-                if (cur[3] == 0) {
-                    xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                    cur = ctxt->input->cur;
-                }
                 if (((c & 0xf8) != 0xf0) ||
-                    ((cur[3] & 0xc0) != 0x80))
+                    (avail < 4) || ((cur[3] & 0xc0) != 0x80))
                     goto encoding_error;
                 /* 4-byte code */
                 *len = 4;
@@ -533,17 +525,10 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
         }
         /* 1-byte code */
         *len = 1;
-        return((int) *ctxt->input->cur);
+        return(*ctxt->input->cur);
     }
 
 encoding_error:
-    /*
-     * If we detect an UTF8 error that probably mean that the
-     * input encoding didn't get properly advertised in the
-     * declaration header. Report the error and switch the encoding
-     * to ISO-Latin-1 (if you don't like this policy, just declare the
-     * encoding !)
-     */
     {
         char buffer[150];
 
@@ -559,18 +544,10 @@ encoding_error:
                     BAD_CAST buffer, NULL);
     }
 
-    /*
-     * Don't switch encodings twice. Note that if there's an encoder, we
-     * shouldn't receive invalid UTF-8 anyway.
-     *
-     * Note that if ctxt->input->buf == NULL, switching encodings is
-     * impossible, see Gitlab issue #34.
-     */
-    if ((ctxt->input->buf != NULL) &&
-        (ctxt->input->buf->encoder == NULL))
+    if ((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0)
         xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1);
     *len = 1;
-    return((int) *ctxt->input->cur);
+    return(*ctxt->input->cur);
 }
 
 /**
@@ -587,17 +564,12 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
     int res = 0;
 
     while (IS_BLANK_CH(*(ctxt->input->cur))) {
-       if ((*ctxt->input->cur == 0) &&
-           (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
-               xmlPopInput(ctxt);
-       } else {
-           if (*(ctxt->input->cur) == '\n') {
-               ctxt->input->line++; ctxt->input->col = 1;
-           } else ctxt->input->col++;
-           ctxt->input->cur++;
-           if (*ctxt->input->cur == 0)
-               xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-       }
+        if (*(ctxt->input->cur) == '\n') {
+            ctxt->input->line++; ctxt->input->col = 1;
+        } else ctxt->input->col++;
+        ctxt->input->cur++;
+        if (*ctxt->input->cur == 0)
+            xmlParserGrow(ctxt);
        if (res < INT_MAX)
            res++;
     }
@@ -1223,7 +1195,6 @@ static const htmlStartCloseEntry htmlStartClose[] = {
     { "menu", "form" },
     { "menu", "ul" },
     { "ol", "form" },
-    { "ol", "ul" },
     { "option", "optgroup" },
     { "option", "option" },
     { "p", "address" },
@@ -1307,7 +1278,6 @@ static const htmlStartCloseEntry htmlStartClose[] = {
     { "ul", "address" },
     { "ul", "form" },
     { "ul", "menu" },
-    { "ul", "ol" },
     { "ul", "pre" },
     { "xmp", "dd" },
     { "xmp", "dl" },
@@ -1395,10 +1365,7 @@ static const elementPriority htmlEndPriority[] = {
 /**
  * htmlInitAutoClose:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
- *
- * This is a no-op now.
+ * DEPRECATED: This is a no-op.
  */
 void
 htmlInitAutoClose(void) {
@@ -1565,20 +1532,11 @@ htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt)
 static void
 htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
 {
-    while ((newtag != NULL) && (ctxt->name != NULL) &&
-           (htmlCheckAutoClose(newtag, ctxt->name))) {
-        if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
-            ctxt->sax->endElement(ctxt->userData, ctxt->name);
-       htmlnamePop(ctxt);
-    }
-    if (newtag == NULL) {
-        htmlAutoCloseOnEnd(ctxt);
+    if (newtag == NULL)
         return;
-    }
-    while ((newtag == NULL) && (ctxt->name != NULL) &&
-           ((xmlStrEqual(ctxt->name, BAD_CAST "head")) ||
-            (xmlStrEqual(ctxt->name, BAD_CAST "body")) ||
-            (xmlStrEqual(ctxt->name, BAD_CAST "html")))) {
+
+    while ((ctxt->name != NULL) &&
+           (htmlCheckAutoClose(newtag, ctxt->name))) {
         if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
             ctxt->sax->endElement(ctxt->userData, ctxt->name);
        htmlnamePop(ctxt);
@@ -2075,8 +2033,8 @@ static const htmlEntityDesc  html40EntitiesTable[] = {
 #define growBuffer(buffer) {                                           \
     xmlChar *tmp;                                                      \
     buffer##_size *= 2;                                                        \
-    tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
-    if (tmp == NULL) {                                         \
+    tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size);               \
+    if (tmp == NULL) {                                                 \
        htmlErrMemory(ctxt, "growing buffer\n");                        \
        xmlFree(buffer);                                                \
        return(NULL);                                                   \
@@ -2320,7 +2278,7 @@ htmlEncodeEntities(unsigned char* out, int *outlen,
            else
                cp = ent->name;
            len = strlen(cp);
-           if (out + 2 + len > outend)
+           if (outend - out < len + 2)
                break;
            *out++ = '&';
            memcpy(out, cp, len);
@@ -2572,6 +2530,7 @@ htmlSkipBogusComment(htmlParserCtxtPtr ctxt) {
 
 static const xmlChar *
 htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
+    const xmlChar *ret;
     int i = 0;
     xmlChar loc[HTML_PARSER_BUFFER_SIZE];
 
@@ -2589,7 +2548,11 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
        NEXT;
     }
 
-    return(xmlDictLookup(ctxt->dict, loc, i));
+    ret = xmlDictLookup(ctxt->dict, loc, i);
+    if (ret == NULL)
+        htmlErrMemory(ctxt, NULL);
+
+    return(ret);
 }
 
 
@@ -2674,13 +2637,14 @@ static const xmlChar *
 htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
     int len = 0, l;
     int c;
-    int count = 0;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
     const xmlChar *base = ctxt->input->base;
 
     /*
      * Handler for more complex cases
      */
-    GROW;
     c = CUR_CHAR(l);
     if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
        (!IS_LETTER(c) && (c != '_') &&
@@ -2694,11 +2658,11 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
            (c == '_') || (c == ':') ||
            (IS_COMBINING(c)) ||
            (IS_EXTENDER(c)))) {
-       if (count++ > 100) {
-           count = 0;
-           GROW;
-       }
        len += l;
+        if (len > maxLength) {
+            htmlParseErr(ctxt, XML_ERR_NAME_TOO_LONG, "name too long", NULL, NULL);
+            return(NULL);
+        }
        NEXTL(l);
        c = CUR_CHAR(l);
        if (ctxt->input->base != base) {
@@ -2709,6 +2673,8 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
            return(htmlParseNameComplex(ctxt));
        }
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(NULL);
 
     if (ctxt->input->cur - ctxt->input->base < len) {
         /* Sanity check */
@@ -2736,6 +2702,9 @@ static xmlChar *
 htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
     xmlChar *buffer = NULL;
     int buffer_size = 0;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
     xmlChar *out = NULL;
     const xmlChar *name = NULL;
     const xmlChar *cur = NULL;
@@ -2745,7 +2714,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
      * allocate a translation buffer.
      */
     buffer_size = HTML_PARSER_BUFFER_SIZE;
-    buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar));
+    buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
     if (buffer == NULL) {
        htmlErrMemory(ctxt, "buffer allocation failed\n");
        return(NULL);
@@ -2841,6 +2810,10 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
                out = &buffer[indx];
            }
            c = CUR_CHAR(l);
+            if (ctxt->instate == XML_PARSER_EOF) {
+                xmlFree(buffer);
+                return(NULL);
+            }
            if      (c <    0x80)
                    { *out++  = c;                bits= -6; }
            else if (c <   0x800)
@@ -2853,8 +2826,14 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
            for ( ; bits >= 0; bits-= 6) {
                *out++  = ((c >> bits) & 0x3F) | 0x80;
            }
-           NEXT;
+           NEXTL(l);
        }
+        if (out - buffer > maxLength) {
+            htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+                         "attribute value too long\n", NULL, NULL);
+            xmlFree(buffer);
+            return(NULL);
+        }
     }
     *out = 0;
     return(buffer);
@@ -2865,6 +2844,8 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
  * @ctxt:  an HTML parser context
  * @str:  location to store the entity name
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an HTML ENTITY references
  *
  * [68] EntityRef ::= '&' Name ';'
@@ -2999,9 +2980,9 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
         htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
                      "Unfinished SystemLiteral\n", NULL, NULL);
     } else {
-        NEXT;
         if (err == 0)
             ret = xmlStrndup((BASE_PTR+startPosition), len);
+        NEXT;
     }
 
     return(ret);
@@ -3054,9 +3035,9 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
         htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
                      "Unfinished PubidLiteral\n", NULL, NULL);
     } else {
-        NEXT;
         if (err == 0)
             ret = xmlStrndup((BASE_PTR + startPosition), len);
+        NEXT;
     }
 
     return(ret);
@@ -3089,7 +3070,6 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
     int nbchar = 0;
     int cur,l;
 
-    SHRINK;
     cur = CUR_CHAR(l);
     while (cur != 0) {
        if ((cur == '<') && (NXT(1) == '/')) {
@@ -3128,6 +3108,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
             htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
                             "Invalid char in CDATA 0x%X\n", cur);
         }
+       NEXTL(l);
        if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
             buf[nbchar] = 0;
            if (ctxt->sax->cdataBlock!= NULL) {
@@ -3139,12 +3120,14 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
                ctxt->sax->characters(ctxt->userData, buf, nbchar);
            }
            nbchar = 0;
+            SHRINK;
        }
-       GROW;
-       NEXTL(l);
        cur = CUR_CHAR(l);
     }
 
+    if (ctxt->instate == XML_PARSER_EOF)
+        return;
+
     if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) {
         buf[nbchar] = 0;
        if (ctxt->sax->cdataBlock!= NULL) {
@@ -3175,12 +3158,10 @@ htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
     xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 6];
     int nbchar = 0;
     int cur, l;
-    int chunk = 0;
 
     if (readahead)
         buf[nbchar++] = readahead;
 
-    SHRINK;
     cur = CUR_CHAR(l);
     while (((cur != '<') || (ctxt->token == '<')) &&
            ((cur != '&') || (ctxt->token == '&')) &&
@@ -3191,6 +3172,7 @@ htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
        } else {
            COPY_BUF(l,buf,nbchar,cur);
        }
+       NEXTL(l);
        if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
             buf[nbchar] = 0;
 
@@ -3214,21 +3196,12 @@ htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
                }
            }
            nbchar = 0;
-       }
-       NEXTL(l);
-        chunk++;
-        if (chunk > HTML_PARSER_BUFFER_SIZE) {
-            chunk = 0;
             SHRINK;
-            GROW;
-        }
-       cur = CUR_CHAR(l);
-       if (cur == 0) {
-           SHRINK;
-           GROW;
-           cur = CUR_CHAR(l);
        }
+       cur = CUR_CHAR(l);
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return;
     if (nbchar != 0) {
         buf[nbchar] = 0;
 
@@ -3251,12 +3224,6 @@ htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
                    ctxt->sax->characters(ctxt->userData, buf, nbchar);
            }
        }
-    } else {
-       /*
-        * Loop detection
-        */
-       if (cur == 0)
-           ctxt->instate = XML_PARSER_EOF;
     }
 }
 
@@ -3347,9 +3314,11 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
     int len = 0;
     int size = HTML_PARSER_BUFFER_SIZE;
     int cur, l;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
     const xmlChar *target;
     xmlParserInputState state;
-    int count = 0;
 
     if ((RAW == '<') && (NXT(1) == '?')) {
        state = ctxt->instate;
@@ -3358,7 +3327,6 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
         * this is a Processing Instruction.
         */
        SKIP(2);
-       SHRINK;
 
        /*
         * Parse the target name and check for special support like
@@ -3379,7 +3347,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
                ctxt->instate = state;
                return;
            }
-           buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+           buf = (xmlChar *) xmlMallocAtomic(size);
            if (buf == NULL) {
                htmlErrMemory(ctxt, NULL);
                ctxt->instate = state;
@@ -3397,7 +3365,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
                    xmlChar *tmp;
 
                    size *= 2;
-                   tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+                   tmp = (xmlChar *) xmlRealloc(buf, size);
                    if (tmp == NULL) {
                        htmlErrMemory(ctxt, NULL);
                        xmlFree(buf);
@@ -3406,11 +3374,6 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
                    }
                    buf = tmp;
                }
-               count++;
-               if (count > 50) {
-                   GROW;
-                   count = 0;
-               }
                 if (IS_CHAR(cur)) {
                    COPY_BUF(l,buf,len,cur);
                 } else {
@@ -3418,15 +3381,21 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
                                     "Invalid char in processing instruction "
                                     "0x%X\n", cur);
                 }
+                if (len > maxLength) {
+                    htmlParseErr(ctxt, XML_ERR_PI_NOT_FINISHED,
+                                 "PI %s too long", target, NULL);
+                    xmlFree(buf);
+                    ctxt->instate = state;
+                    return;
+                }
                NEXTL(l);
                cur = CUR_CHAR(l);
-               if (cur == 0) {
-                   SHRINK;
-                   GROW;
-                   cur = CUR_CHAR(l);
-               }
            }
            buf[len] = 0;
+            if (ctxt->instate == XML_PARSER_EOF) {
+                xmlFree(buf);
+                return;
+            }
            if (cur != '>') {
                htmlParseErr(ctxt, XML_ERR_PI_NOT_FINISHED,
                      "ParsePI: PI %s never end ...\n", target, NULL);
@@ -3467,6 +3436,9 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
     int r, rl;
     int cur, l;
     int next, nl;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
     xmlParserInputState state;
 
     /*
@@ -3477,9 +3449,8 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
 
     state = ctxt->instate;
     ctxt->instate = XML_PARSER_COMMENT;
-    SHRINK;
     SKIP(4);
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
         htmlErrMemory(ctxt, "buffer allocation failed\n");
        ctxt->instate = state;
@@ -3511,11 +3482,6 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
            (r != '-') || (q != '-'))) {
        NEXTL(l);
        next = CUR_CHAR(nl);
-       if (next == 0) {
-           SHRINK;
-           GROW;
-           next = CUR_CHAR(nl);
-       }
 
        if ((q == '-') && (r == '-') && (cur == '!') && (next == '>')) {
          htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
@@ -3528,7 +3494,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
            xmlChar *tmp;
 
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlFree(buf);
                htmlErrMemory(ctxt, "growing buffer failed\n");
@@ -3543,6 +3509,13 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
             htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
                             "Invalid char in comment 0x%X\n", q);
         }
+        if (len > maxLength) {
+            htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
+                         "comment too long", NULL, NULL);
+            xmlFree(buf);
+            ctxt->instate = state;
+            return;
+        }
 
        q = r;
        ql = rl;
@@ -3553,6 +3526,10 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
     }
 finished:
     buf[len] = 0;
+    if (ctxt->instate == XML_PARSER_EOF) {
+        xmlFree(buf);
+        return;
+    }
     if (cur == '>') {
         NEXT;
        if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
@@ -3573,6 +3550,8 @@ unfinished:
  * htmlParseCharRef:
  * @ctxt:  an HTML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse Reference declarations
  *
  * [66] CharRef ::= '&#' [0-9]+ ';' |
@@ -3701,7 +3680,8 @@ htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
        htmlParseErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED,
                     "DOCTYPE improperly terminated\n", NULL, NULL);
         /* Ignore bogus content */
-        while ((CUR != 0) && (CUR != '>'))
+        while ((CUR != 0) && (CUR != '>') &&
+               (ctxt->instate != XML_PARSER_EOF))
             NEXT;
     }
     if (CUR == '>')
@@ -3770,93 +3750,6 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
 }
 
 /**
- * htmlCheckEncodingDirect:
- * @ctxt:  an HTML parser context
- * @attvalue: the attribute value
- *
- * Checks an attribute value to detect
- * the encoding
- * If a new encoding is detected the parser is switched to decode
- * it and pass UTF8
- */
-static void
-htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
-
-    if ((ctxt == NULL) || (encoding == NULL) ||
-        (ctxt->options & HTML_PARSE_IGNORE_ENC))
-       return;
-
-    /* do not change encoding */
-    if (ctxt->input->encoding != NULL)
-        return;
-
-    if (encoding != NULL) {
-       xmlCharEncoding enc;
-       xmlCharEncodingHandlerPtr handler;
-
-       while ((*encoding == ' ') || (*encoding == '\t')) encoding++;
-
-       if (ctxt->input->encoding != NULL)
-           xmlFree((xmlChar *) ctxt->input->encoding);
-       ctxt->input->encoding = xmlStrdup(encoding);
-
-       enc = xmlParseCharEncoding((const char *) encoding);
-       /*
-        * registered set of known encodings
-        */
-       if (enc != XML_CHAR_ENCODING_ERROR) {
-           if (((enc == XML_CHAR_ENCODING_UTF16LE) ||
-                (enc == XML_CHAR_ENCODING_UTF16BE) ||
-                (enc == XML_CHAR_ENCODING_UCS4LE) ||
-                (enc == XML_CHAR_ENCODING_UCS4BE)) &&
-               (ctxt->input->buf != NULL) &&
-               (ctxt->input->buf->encoder == NULL)) {
-               htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
-                            "htmlCheckEncoding: wrong encoding meta\n",
-                            NULL, NULL);
-           } else {
-               xmlSwitchEncoding(ctxt, enc);
-           }
-           ctxt->charset = XML_CHAR_ENCODING_UTF8;
-       } else {
-           /*
-            * fallback for unknown encodings
-            */
-           handler = xmlFindCharEncodingHandler((const char *) encoding);
-           if (handler != NULL) {
-               xmlSwitchToEncoding(ctxt, handler);
-               ctxt->charset = XML_CHAR_ENCODING_UTF8;
-           } else {
-               htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-                            "htmlCheckEncoding: unknown encoding %s\n",
-                            encoding, NULL);
-           }
-       }
-
-       if ((ctxt->input->buf != NULL) &&
-           (ctxt->input->buf->encoder != NULL) &&
-           (ctxt->input->buf->raw != NULL) &&
-           (ctxt->input->buf->buffer != NULL)) {
-           int nbchars;
-           int processed;
-
-           /*
-            * convert as much as possible to the parser reading buffer.
-            */
-           processed = ctxt->input->cur - ctxt->input->base;
-           xmlBufShrink(ctxt->input->buf->buffer, processed);
-           nbchars = xmlCharEncInput(ctxt->input->buf, 1);
-            xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
-           if (nbchars < 0) {
-               htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
-                            "htmlCheckEncoding: encoder error\n",
-                            NULL, NULL);
-           }
-       }
-    }
-}
-
-/**
  * htmlCheckEncoding:
  * @ctxt:  an HTML parser context
  * @attvalue: the attribute value
@@ -3884,7 +3777,7 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
        encoding = xmlStrcasestr(attvalue, BAD_CAST"=");
     if (encoding && *encoding == '=') {
        encoding ++;
-       htmlCheckEncodingDirect(ctxt, encoding);
+       xmlSetDeclaredEncoding(ctxt, xmlStrdup(encoding));
     }
 }
 
@@ -3913,7 +3806,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
         && (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
            http = 1;
        else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"charset")))
-           htmlCheckEncodingDirect(ctxt, value);
+           xmlSetDeclaredEncoding(ctxt, xmlStrdup(value));
        else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"content")))
            content = value;
        att = atts[i++];
@@ -4033,7 +3926,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
     SKIP_BLANKS;
     while ((CUR != 0) &&
            (CUR != '>') &&
-          ((CUR != '/') || (NXT(1) != '>'))) {
+          ((CUR != '/') || (NXT(1) != '>')) &&
+           (ctxt->instate != XML_PARSER_EOF)) {
        GROW;
        attname = htmlParseAttribute(ctxt, &attvalue);
         if (attname != NULL) {
@@ -4094,7 +3988,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
             * the end of the tag. */
            while ((CUR != 0) &&
                   !(IS_BLANK_CH(CUR)) && (CUR != '>') &&
-                  ((CUR != '/') || (NXT(1) != '>')))
+                  ((CUR != '/') || (NXT(1) != '>')) &&
+                   (ctxt->instate != XML_PARSER_EOF))
                NEXT;
        }
 
@@ -4461,6 +4356,8 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
         else {
             htmlParseCharData(ctxt);
         }
+
+        SHRINK;
         GROW;
     }
     if (currentNode != NULL) xmlFree(currentNode);
@@ -4470,6 +4367,8 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
  * htmlParseElement:
  * @ctxt:  an HTML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an HTML element, this is highly recursive
  * this is kept for compatibility with previous code versions
  *
@@ -4727,8 +4626,16 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
     int depth;
     const xmlChar *name;
 
-    currentNode = xmlStrdup(ctxt->name);
     depth = ctxt->nameNr;
+    if (depth <= 0) {
+        currentNode = NULL;
+    } else {
+        currentNode = xmlStrdup(ctxt->name);
+        if (currentNode == NULL) {
+            htmlErrMemory(ctxt, NULL);
+            return;
+        }
+    }
     while (1) {
         GROW;
 
@@ -4744,8 +4651,16 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
                if (currentNode != NULL)
                    xmlFree(currentNode);
 
-               currentNode = xmlStrdup(ctxt->name);
                depth = ctxt->nameNr;
+                if (depth <= 0) {
+                    currentNode = NULL;
+                } else {
+                    currentNode = xmlStrdup(ctxt->name);
+                    if (currentNode == NULL) {
+                        htmlErrMemory(ctxt, NULL);
+                        break;
+                    }
+                }
            }
            continue; /* while */
         }
@@ -4767,6 +4682,10 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
                    xmlFree(currentNode);
 
                currentNode = xmlStrdup(ctxt->name);
+                if (currentNode == NULL) {
+                    htmlErrMemory(ctxt, NULL);
+                    break;
+                }
                depth = ctxt->nameNr;
                continue;
            }
@@ -4790,6 +4709,10 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
            if (currentNode != NULL) xmlFree(currentNode);
 
            currentNode = xmlStrdup(ctxt->name);
+            if (currentNode == NULL) {
+                htmlErrMemory(ctxt, NULL);
+                break;
+            }
            depth = ctxt->nameNr;
            continue;
        }
@@ -4841,6 +4764,10 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
             if (currentNode != NULL) xmlFree(currentNode);
 
             currentNode = xmlStrdup(ctxt->name);
+            if (currentNode == NULL) {
+                htmlErrMemory(ctxt, NULL);
+                break;
+            }
             depth = ctxt->nameNr;
         }
         else if (CUR == '<') {
@@ -4872,6 +4799,8 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
         else {
             htmlParseCharData(ctxt);
         }
+
+        SHRINK;
         GROW;
     }
     if (currentNode != NULL) xmlFree(currentNode);
@@ -4904,44 +4833,31 @@ __htmlParseContent(void *ctxt) {
 
 int
 htmlParseDocument(htmlParserCtxtPtr ctxt) {
-    xmlChar start[4];
-    xmlCharEncoding enc;
     xmlDtdPtr dtd;
 
     xmlInitParser();
 
-    htmlDefaultSAXHandlerInit();
-
     if ((ctxt == NULL) || (ctxt->input == NULL)) {
        htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
                     "htmlParseDocument: context error\n", NULL, NULL);
        return(XML_ERR_INTERNAL_ERROR);
     }
-    ctxt->html = 1;
-    ctxt->linenumbers = 1;
-    GROW;
+
     /*
      * SAX: beginning of the document processing.
      */
     if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
         ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
 
-    if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
-        ((ctxt->input->end - ctxt->input->cur) >= 4)) {
-       /*
-        * Get the 4 first bytes and decode the charset
-        * if enc != XML_CHAR_ENCODING_NONE
-        * plug some encoding conversion routines.
-        */
-       start[0] = RAW;
-       start[1] = NXT(1);
-       start[2] = NXT(2);
-       start[3] = NXT(3);
-       enc = xmlDetectCharEncoding(&start[0], 4);
-       if (enc != XML_CHAR_ENCODING_NONE) {
-           xmlSwitchEncoding(ctxt, enc);
-       }
-    }
+    xmlDetectEncoding(ctxt);
+
+    /*
+     * This is wrong but matches long-standing behavior. In most cases,
+     * a document starting with an XML declaration will specify UTF-8.
+     */
+    if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) &&
+        (xmlStrncmp(ctxt->input->cur, BAD_CAST "<?xm", 4) == 0))
+        xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_UTF8);
 
     /*
      * Wipe out everything which is before the first '<'
@@ -5032,6 +4948,8 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
 /**
  * htmlInitParserCtxt:
  * @ctxt:  an HTML parser context
+ * @sax:  SAX handler
+ * @userData:  user data
  *
  * Initialize a parser context
  *
@@ -5039,10 +4957,9 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
  */
 
 static int
-htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
+htmlInitParserCtxt(htmlParserCtxtPtr ctxt, const htmlSAXHandler *sax,
+                   void *userData)
 {
-    htmlSAXHandler *sax;
-
     if (ctxt == NULL) return(-1);
     memset(ctxt, 0, sizeof(htmlParserCtxt));
 
@@ -5051,12 +4968,21 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
         htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
        return(-1);
     }
-    sax = (htmlSAXHandler *) xmlMalloc(sizeof(htmlSAXHandler));
-    if (sax == NULL) {
+
+    if (ctxt->sax == NULL)
+        ctxt->sax = (htmlSAXHandler *) xmlMalloc(sizeof(htmlSAXHandler));
+    if (ctxt->sax == NULL) {
         htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
        return(-1);
     }
-    memset(sax, 0, sizeof(htmlSAXHandler));
+    if (sax == NULL) {
+        memset(ctxt->sax, 0, sizeof(htmlSAXHandler));
+        xmlSAX2InitHtmlDefaultSAXHandler(ctxt->sax);
+        ctxt->userData = ctxt;
+    } else {
+        memcpy(ctxt->sax, sax, sizeof(htmlSAXHandler));
+        ctxt->userData = userData ? userData : ctxt;
+    }
 
     /* Allocate the Input stack */
     ctxt->inputTab = (htmlParserInputPtr *)
@@ -5115,10 +5041,6 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
     ctxt->nodeInfoNr  = 0;
     ctxt->nodeInfoMax = 0;
 
-    ctxt->sax = sax;
-    xmlSAX2InitHtmlDefaultSAXHandler(sax);
-
-    ctxt->userData = ctxt;
     ctxt->myDoc = NULL;
     ctxt->wellFormed = 1;
     ctxt->replaceEntities = 0;
@@ -5162,6 +5084,23 @@ htmlFreeParserCtxt(htmlParserCtxtPtr ctxt)
 htmlParserCtxtPtr
 htmlNewParserCtxt(void)
 {
+    return(htmlNewSAXParserCtxt(NULL, NULL));
+}
+
+/**
+ * htmlNewSAXParserCtxt:
+ * @sax:  SAX handler
+ * @userData:  user data
+ *
+ * Allocate and initialize a new SAX parser context. If userData is NULL,
+ * the parser context will be passed as user data.
+ *
+ * Returns the htmlParserCtxtPtr or NULL in case of allocation error
+ */
+
+htmlParserCtxtPtr
+htmlNewSAXParserCtxt(const htmlSAXHandler *sax, void *userData)
+{
     xmlParserCtxtPtr ctxt;
 
     ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
@@ -5170,7 +5109,7 @@ htmlNewParserCtxt(void)
        return(NULL);
     }
     memset(ctxt, 0, sizeof(xmlParserCtxt));
-    if (htmlInitParserCtxt(ctxt) < 0) {
+    if (htmlInitParserCtxt(ctxt, sax, userData) < 0) {
         htmlFreeParserCtxt(ctxt);
        return(NULL);
     }
@@ -5202,7 +5141,10 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
        return(NULL);
 
     buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
-    if (buf == NULL) return(NULL);
+    if (buf == NULL) {
+       xmlFreeParserCtxt(ctxt);
+        return(NULL);
+    }
 
     input = xmlNewInputStream(ctxt);
     if (input == NULL) {
@@ -5221,7 +5163,7 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
 
 /**
  * htmlCreateDocParserCtxt:
- * @cur:  a pointer to an array of xmlChar
+ * @str:  a pointer to an array of xmlChar
  * @encoding:  a free form C string describing the HTML document encoding, or NULL
  *
  * Create a parser context for an HTML document.
@@ -5231,25 +5173,41 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
  * Returns the new parser context or NULL
  */
 static htmlParserCtxtPtr
-htmlCreateDocParserCtxt(const xmlChar *cur, const char *encoding) {
-    int len;
-    htmlParserCtxtPtr ctxt;
+htmlCreateDocParserCtxt(const xmlChar *str, const char *encoding) {
+    xmlParserCtxtPtr ctxt;
+    xmlParserInputPtr input;
+    xmlParserInputBufferPtr buf;
 
-    if (cur == NULL)
+    if (str == NULL)
        return(NULL);
-    len = xmlStrlen(cur);
-    ctxt = htmlCreateMemoryParserCtxt((char *)cur, len);
+
+    ctxt = htmlNewParserCtxt();
     if (ctxt == NULL)
        return(NULL);
 
+    buf = xmlParserInputBufferCreateString(str);
+    if (buf == NULL) {
+       xmlFreeParserCtxt(ctxt);
+        return(NULL);
+    }
+
+    input = xmlNewInputStream(ctxt);
+    if (input == NULL) {
+       xmlFreeParserInputBuffer(buf);
+       xmlFreeParserCtxt(ctxt);
+       return(NULL);
+    }
+
+    input->filename = NULL;
+    input->buf = buf;
+    xmlBufResetInput(buf->buffer, input);
+
+    inputPush(ctxt, input);
+
     if (encoding != NULL) {
        xmlCharEncoding enc;
        xmlCharEncodingHandlerPtr handler;
 
-       if (ctxt->input->encoding != NULL)
-           xmlFree((xmlChar *) ctxt->input->encoding);
-       ctxt->input->encoding = xmlStrdup((const xmlChar *) encoding);
-
        enc = xmlParseCharEncoding(encoding);
        /*
         * registered set of known encodings
@@ -5275,6 +5233,7 @@ htmlCreateDocParserCtxt(const xmlChar *cur, const char *encoding) {
            }
        }
     }
+
     return(ctxt);
 }
 
@@ -5307,33 +5266,20 @@ static int
 htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
                         xmlChar next, xmlChar third, int ignoreattrval)
 {
-    int base, len;
+    size_t base, len;
     htmlParserInputPtr in;
     const xmlChar *buf;
-    int invalue = 0;
-    char valdellim = 0x0;
+    int quote;
 
     in = ctxt->input;
     if (in == NULL)
         return (-1);
 
-    base = in->cur - in->base;
-    if (base < 0)
-        return (-1);
+    base = ctxt->checkIndex;
+    quote = ctxt->endCheckState;
 
-    if (ctxt->checkIndex > base) {
-        base = ctxt->checkIndex;
-        /* Abuse hasPErefs member to restore current state. */
-        invalue = ctxt->hasPErefs & 1 ? 1 : 0;
-    }
-
-    if (in->buf == NULL) {
-        buf = in->base;
-        len = in->length;
-    } else {
-        buf = xmlBufContent(in->buf->buffer);
-        len = xmlBufUse(in->buf->buffer);
-    }
+    buf = in->cur;
+    len = in->end - in->cur;
 
     /* take into account the sequence length */
     if (third)
@@ -5341,19 +5287,19 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
     else if (next)
         len--;
     for (; base < len; base++) {
+        if (base >= INT_MAX / 2) {
+            ctxt->checkIndex = 0;
+            ctxt->endCheckState = 0;
+            return (base - 2);
+        }
         if (ignoreattrval) {
+            if (quote) {
+                if (buf[base] == quote)
+                    quote = 0;
+                continue;
+            }
             if (buf[base] == '"' || buf[base] == '\'') {
-                if (invalue) {
-                    if (buf[base] == valdellim) {
-                        invalue = 0;
-                        continue;
-                    }
-                } else {
-                    valdellim = buf[base];
-                    invalue = 1;
-                    continue;
-                }
-            } else if (invalue) {
+                quote = buf[base];
                 continue;
             }
         }
@@ -5366,41 +5312,12 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
                     continue;
             }
             ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-            if (next == 0)
-                xmlGenericError(xmlGenericErrorContext,
-                                "HPP: lookup '%c' found at %d\n",
-                                first, base);
-            else if (third == 0)
-                xmlGenericError(xmlGenericErrorContext,
-                                "HPP: lookup '%c%c' found at %d\n",
-                                first, next, base);
-            else
-                xmlGenericError(xmlGenericErrorContext,
-                                "HPP: lookup '%c%c%c' found at %d\n",
-                                first, next, third, base);
-#endif
-            return (base - (in->cur - in->base));
+            ctxt->endCheckState = 0;
+            return (base);
         }
     }
     ctxt->checkIndex = base;
-    /* Abuse hasPErefs member to track current state. */
-    if (invalue)
-        ctxt->hasPErefs |= 1;
-    else
-        ctxt->hasPErefs &= ~1;
-#ifdef DEBUG_PUSH
-    if (next == 0)
-        xmlGenericError(xmlGenericErrorContext,
-                        "HPP: lookup '%c' failed\n", first);
-    else if (third == 0)
-        xmlGenericError(xmlGenericErrorContext,
-                        "HPP: lookup '%c%c' failed\n", first, next);
-    else
-        xmlGenericError(xmlGenericErrorContext,
-                        "HPP: lookup '%c%c%c' failed\n", first, next,
-                        third);
-#endif
+    ctxt->endCheckState = quote;
     return (-1);
 }
 
@@ -5422,16 +5339,23 @@ static int
 htmlParseLookupCommentEnd(htmlParserCtxtPtr ctxt)
 {
     int mark = 0;
-    int cur = CUR_PTR - BASE_PTR;
+    int offset;
 
-    while (mark >= 0) {
+    while (1) {
        mark = htmlParseLookupSequence(ctxt, '-', '-', 0, 0);
-       if ((mark < 0) ||
-           (NXT(mark+2) == '>') ||
+       if (mark < 0)
+            break;
+        if ((NXT(mark+2) == '>') ||
            ((NXT(mark+2) == '!') && (NXT(mark+3) == '>'))) {
-           return mark;
+            ctxt->checkIndex = 0;
+           break;
        }
-       ctxt->checkIndex = cur + mark + 1;
+        offset = (NXT(mark+2) == '!') ? 3 : 2;
+        if (mark + offset >= ctxt->input->end - ctxt->input->cur) {
+           ctxt->checkIndex = mark;
+            return(-1);
+        }
+       ctxt->checkIndex = mark + 1;
     }
     return mark;
 }
@@ -5455,68 +5379,11 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
 
     htmlParserNodeInfo node_info;
 
-#ifdef DEBUG_PUSH
-    switch (ctxt->instate) {
-       case XML_PARSER_EOF:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try EOF\n"); break;
-       case XML_PARSER_START:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try START\n"); break;
-       case XML_PARSER_MISC:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try MISC\n");break;
-       case XML_PARSER_COMMENT:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try COMMENT\n");break;
-       case XML_PARSER_PROLOG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try PROLOG\n");break;
-       case XML_PARSER_START_TAG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try START_TAG\n");break;
-       case XML_PARSER_CONTENT:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try CONTENT\n");break;
-       case XML_PARSER_CDATA_SECTION:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try CDATA_SECTION\n");break;
-       case XML_PARSER_END_TAG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try END_TAG\n");break;
-       case XML_PARSER_ENTITY_DECL:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try ENTITY_DECL\n");break;
-       case XML_PARSER_ENTITY_VALUE:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try ENTITY_VALUE\n");break;
-       case XML_PARSER_ATTRIBUTE_VALUE:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try ATTRIBUTE_VALUE\n");break;
-       case XML_PARSER_DTD:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try DTD\n");break;
-       case XML_PARSER_EPILOG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try EPILOG\n");break;
-       case XML_PARSER_PI:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try PI\n");break;
-       case XML_PARSER_SYSTEM_LITERAL:
-           xmlGenericError(xmlGenericErrorContext,
-                   "HPP: try SYSTEM_LITERAL\n");break;
-    }
-#endif
-
     while (1) {
 
        in = ctxt->input;
        if (in == NULL) break;
-       if (in->buf == NULL)
-           avail = in->length - (in->cur - in->base);
-       else
-           avail = (ptrdiff_t)xmlBufUse(in->buf->buffer) -
-                    (in->cur - in->base);
+       avail = in->end - in->cur;
        if ((avail == 0) && (terminate)) {
            htmlAutoCloseOnEnd(ctxt);
            if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
@@ -5549,17 +5416,23 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                 */
                goto done;
             case XML_PARSER_START:
+                /*
+                 * This is wrong but matches long-standing behavior. In most
+                 * cases, a document starting with an XML declaration will
+                 * specify UTF-8.
+                 */
+                if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) &&
+                    (xmlStrncmp(ctxt->input->cur, BAD_CAST "<?xm", 4) == 0)) {
+                    xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_UTF8);
+                }
+
                /*
                 * Very first chars read from the document flow.
                 */
                cur = in->cur[0];
                if (IS_BLANK_CH(cur)) {
                    SKIP_BLANKS;
-                   if (in->buf == NULL)
-                       avail = in->length - (in->cur - in->base);
-                   else
-                       avail = (ptrdiff_t)xmlBufUse(in->buf->buffer) -
-                                (in->cur - in->base);
+                    avail = in->end - in->cur;
                }
                if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
                    ctxt->sax->setDocumentLocator(ctxt->userData,
@@ -5567,6 +5440,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                if ((ctxt->sax) && (ctxt->sax->startDocument) &&
                    (!ctxt->disableSAX))
                    ctxt->sax->startDocument(ctxt->userData);
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
 
                cur = in->cur[0];
                next = in->cur[1];
@@ -5578,31 +5453,17 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    if ((!terminate) &&
                        (htmlParseLookupSequence(ctxt, '>', 0, 0, 1) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing internal subset\n");
-#endif
                    htmlParseDocTypeDecl(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_PROLOG;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering PROLOG\n");
-#endif
                 } else {
                    ctxt->instate = XML_PARSER_MISC;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering MISC\n");
-#endif
                }
                break;
             case XML_PARSER_MISC:
                SKIP_BLANKS;
-               if (in->buf == NULL)
-                   avail = in->length - (in->cur - in->base);
-               else
-                   avail = (ptrdiff_t)xmlBufUse(in->buf->buffer) -
-                            (in->cur - in->base);
+                avail = in->end - in->cur;
                /*
                 * no chars in buffer
                 */
@@ -5624,21 +5485,17 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    (in->cur[2] == '-') && (in->cur[3] == '-')) {
                    if ((!terminate) && (htmlParseLookupCommentEnd(ctxt) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing Comment\n");
-#endif
                    htmlParseComment(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_MISC;
                } else if ((cur == '<') && (next == '?')) {
                    if ((!terminate) &&
                        (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing PI\n");
-#endif
                    htmlParsePI(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_MISC;
                } else if ((cur == '<') && (next == '!') &&
                    (UPP(2) == 'D') && (UPP(3) == 'O') &&
@@ -5648,34 +5505,20 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    if ((!terminate) &&
                        (htmlParseLookupSequence(ctxt, '>', 0, 0, 1) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing internal subset\n");
-#endif
                    htmlParseDocTypeDecl(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_PROLOG;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering PROLOG\n");
-#endif
                } else if ((cur == '<') && (next == '!') &&
                           (avail < 9)) {
                    goto done;
                } else {
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering START_TAG\n");
-#endif
                }
                break;
             case XML_PARSER_PROLOG:
                SKIP_BLANKS;
-               if (in->buf == NULL)
-                   avail = in->length - (in->cur - in->base);
-               else
-                   avail = (ptrdiff_t)xmlBufUse(in->buf->buffer) -
-                            (in->cur - in->base);
+                avail = in->end - in->cur;
                if (avail < 2)
                    goto done;
                cur = in->cur[0];
@@ -5684,39 +5527,27 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    (in->cur[2] == '-') && (in->cur[3] == '-')) {
                    if ((!terminate) && (htmlParseLookupCommentEnd(ctxt) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing Comment\n");
-#endif
                    htmlParseComment(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_PROLOG;
                } else if ((cur == '<') && (next == '?')) {
                    if ((!terminate) &&
                        (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing PI\n");
-#endif
                    htmlParsePI(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_PROLOG;
                } else if ((cur == '<') && (next == '!') &&
                           (avail < 4)) {
                    goto done;
                } else {
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering START_TAG\n");
-#endif
                }
                break;
             case XML_PARSER_EPILOG:
-               if (in->buf == NULL)
-                   avail = in->length - (in->cur - in->base);
-               else
-                   avail = (ptrdiff_t)xmlBufUse(in->buf->buffer) -
-                            (in->cur - in->base);
+                avail = in->end - in->cur;
                if (avail < 1)
                    goto done;
                cur = in->cur[0];
@@ -5731,21 +5562,17 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    (in->cur[2] == '-') && (in->cur[3] == '-')) {
                    if ((!terminate) && (htmlParseLookupCommentEnd(ctxt) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing Comment\n");
-#endif
                    htmlParseComment(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_EPILOG;
                } else if ((cur == '<') && (next == '?')) {
                    if ((!terminate) &&
                        (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
                        goto done;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: Parsing PI\n");
-#endif
                    htmlParsePI(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_EPILOG;
                } else if ((cur == '<') && (next == '!') &&
                           (avail < 4)) {
@@ -5754,10 +5581,6 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    ctxt->errNo = XML_ERR_DOCUMENT_END;
                    ctxt->wellFormed = 0;
                    ctxt->instate = XML_PARSER_EOF;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering EOF\n");
-#endif
                    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
                        ctxt->sax->endDocument(ctxt->userData);
                    goto done;
@@ -5787,19 +5610,11 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                cur = in->cur[0];
                if (cur != '<') {
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering CONTENT\n");
-#endif
                    break;
                }
                if (next == '/') {
                    ctxt->instate = XML_PARSER_END_TAG;
                    ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering END_TAG\n");
-#endif
                    break;
                }
                if ((!terminate) &&
@@ -5840,11 +5655,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
                        ctxt->sax->endElement(ctxt->userData, name);
                    htmlnamePop(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering CONTENT\n");
-#endif
                    break;
                }
 
@@ -5866,11 +5679,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    if (ctxt->record_info)
                        htmlNodeInfoPush(ctxt, &node_info);
 
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "HPP: entering CONTENT\n");
-#endif
                    break;
                }
 
@@ -5886,11 +5697,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                 if (ctxt->record_info)
                    htmlNodeInfoPush(ctxt, &node_info);
 
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
                ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
                 break;
            }
             case XML_PARSER_CONTENT: {
@@ -5900,7 +5709,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                 * Handle preparsed entities and charRef
                 */
                if (ctxt->token != 0) {
-                   chr[0] = (xmlChar) ctxt->token;
+                   chr[0] = ctxt->token;
                    htmlCheckParagraph(ctxt);
                    if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
                        ctxt->sax->characters(ctxt->userData, chr, 1);
@@ -5952,20 +5761,26 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                        if (idx < 0)
                            goto done;
                        val = in->cur[idx + 2];
-                       if (val == 0) /* bad cut of input */
+                       if (val == 0) { /* bad cut of input */
+                            /*
+                             * FIXME: htmlParseScript checks for additional
+                             * characters after '</'.
+                             */
+                            ctxt->checkIndex = idx;
                            goto done;
+                        }
                    }
                    htmlParseScript(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                    if ((cur == '<') && (next == '/')) {
                        ctxt->instate = XML_PARSER_END_TAG;
                        ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "HPP: entering END_TAG\n");
-#endif
                        break;
                    }
                } else if ((cur == '<') && (next == '!')) {
+                    if (avail < 4)
+                        goto done;
                     /*
                      * Sometimes DOCTYPE arrives in the middle of the document
                      */
@@ -5984,11 +5799,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                         if ((!terminate) &&
                             (htmlParseLookupCommentEnd(ctxt) < 0))
                             goto done;
-#ifdef DEBUG_PUSH
-                        xmlGenericError(xmlGenericErrorContext,
-                                "HPP: Parsing Comment\n");
-#endif
                         htmlParseComment(ctxt);
+                        if (ctxt->instate == XML_PARSER_EOF)
+                            goto done;
                         ctxt->instate = XML_PARSER_CONTENT;
                     } else {
                         if ((!terminate) &&
@@ -6000,31 +5813,19 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                     if ((!terminate) &&
                         (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
                         goto done;
-#ifdef DEBUG_PUSH
-                    xmlGenericError(xmlGenericErrorContext,
-                            "HPP: Parsing PI\n");
-#endif
                     htmlParsePI(ctxt);
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
                     ctxt->instate = XML_PARSER_CONTENT;
-                } else if ((cur == '<') && (next == '!') && (avail < 4)) {
-                    goto done;
                 } else if ((cur == '<') && (next == '/')) {
                     ctxt->instate = XML_PARSER_END_TAG;
                     ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-                    xmlGenericError(xmlGenericErrorContext,
-                            "HPP: entering END_TAG\n");
-#endif
                     break;
                 } else if ((cur == '<') && IS_ASCII_LETTER(next)) {
                     if ((!terminate) && (next == 0))
                         goto done;
                     ctxt->instate = XML_PARSER_START_TAG;
                     ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-                    xmlGenericError(xmlGenericErrorContext,
-                            "HPP: entering START_TAG\n");
-#endif
                     break;
                 } else if (cur == '<') {
                     if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
@@ -6043,10 +5844,6 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                         (htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0))
                         goto done;
                     ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-                    xmlGenericError(xmlGenericErrorContext,
-                            "HPP: Parsing char data\n");
-#endif
                     while ((ctxt->instate != XML_PARSER_EOF) &&
                            (cur != '<') && (in->cur < in->end)) {
                         if (cur == '&') {
@@ -6067,128 +5864,20 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
                    (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
                    goto done;
                htmlParseEndTag(ctxt);
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
                if (ctxt->nameNr == 0) {
                    ctxt->instate = XML_PARSER_EPILOG;
                } else {
                    ctxt->instate = XML_PARSER_CONTENT;
                }
                ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
                break;
-            case XML_PARSER_CDATA_SECTION:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == CDATA\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_DTD:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == DTD\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_COMMENT:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == COMMENT\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_PI:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == PI\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_ENTITY_DECL:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == ENTITY_DECL\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_ENTITY_VALUE:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == ENTITY_VALUE\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering DTD\n");
-#endif
-               break;
-            case XML_PARSER_ATTRIBUTE_VALUE:
+           default:
                htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == ATTRIBUTE_VALUE\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_START_TAG;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering START_TAG\n");
-#endif
-               break;
-           case XML_PARSER_SYSTEM_LITERAL:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                   "HPP: internal error, state == XML_PARSER_SYSTEM_LITERAL\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-           case XML_PARSER_IGNORE:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == XML_PARSER_IGNORE\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
-               break;
-           case XML_PARSER_PUBLIC_LITERAL:
-               htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "HPP: internal error, state == XML_PARSER_LITERAL\n",
-                            NULL, NULL);
-               ctxt->instate = XML_PARSER_CONTENT;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "HPP: entering CONTENT\n");
-#endif
+                            "HPP: internal error\n", NULL, NULL);
+               ctxt->instate = XML_PARSER_EOF;
                break;
-
        }
     }
 done:
@@ -6214,9 +5903,6 @@ done:
                    BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
                    BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
     }
-#ifdef DEBUG_PUSH
-    xmlGenericError(xmlGenericErrorContext, "HPP: done %d\n", ret);
-#endif
     return(ret);
 }
 
@@ -6241,42 +5927,16 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
     }
     if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF))  {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
-       size_t cur = ctxt->input->cur - ctxt->input->base;
+       size_t pos = ctxt->input->cur - ctxt->input->base;
        int res;
 
        res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
+        xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
        if (res < 0) {
-           ctxt->errNo = XML_PARSER_EOF;
-           ctxt->disableSAX = 1;
-           return (XML_PARSER_EOF);
-       }
-#ifdef DEBUG_PUSH
-       xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
-#endif
-
-#if 0
-       if ((terminate) || (ctxt->input->buf->buffer->use > 80))
-           htmlParseTryOrFinish(ctxt, terminate);
-#endif
-    } else if (ctxt->instate != XML_PARSER_EOF) {
-       if ((ctxt->input != NULL) && ctxt->input->buf != NULL) {
-           xmlParserInputBufferPtr in = ctxt->input->buf;
-           if ((in->encoder != NULL) && (in->buffer != NULL) &&
-                   (in->raw != NULL)) {
-               int nbchars;
-               size_t base = xmlBufGetInputBase(in->buffer, ctxt->input);
-               size_t current = ctxt->input->cur - ctxt->input->base;
-
-               nbchars = xmlCharEncInput(in, terminate);
-               xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
-               if (nbchars < 0) {
-                   htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
-                                "encoder error\n", NULL, NULL);
-                   return(XML_ERR_INVALID_ENCODING);
-               }
-           }
+            htmlParseErr(ctxt, ctxt->input->buf->error,
+                         "xmlParserInputBufferPush failed", NULL, NULL);
+            xmlHaltParser(ctxt);
+           return (ctxt->errNo);
        }
     }
     htmlParseTryOrFinish(ctxt, terminate);
@@ -6330,26 +5990,11 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
     buf = xmlAllocParserInputBuffer(enc);
     if (buf == NULL) return(NULL);
 
-    ctxt = htmlNewParserCtxt();
+    ctxt = htmlNewSAXParserCtxt(sax, user_data);
     if (ctxt == NULL) {
        xmlFreeParserInputBuffer(buf);
        return(NULL);
     }
-    if(enc==XML_CHAR_ENCODING_UTF8 || buf->encoder)
-       ctxt->charset=XML_CHAR_ENCODING_UTF8;
-    if (sax != NULL) {
-       if (ctxt->sax != (xmlSAXHandlerPtr) &htmlDefaultSAXHandler)
-           xmlFree(ctxt->sax);
-       ctxt->sax = (htmlSAXHandlerPtr) xmlMalloc(sizeof(htmlSAXHandler));
-       if (ctxt->sax == NULL) {
-           xmlFree(buf);
-           xmlFree(ctxt);
-           return(NULL);
-       }
-       memcpy(ctxt->sax, sax, sizeof(htmlSAXHandler));
-       if (user_data != NULL)
-           ctxt->userData = user_data;
-    }
     if (filename == NULL) {
        ctxt->directory = NULL;
     } else {
@@ -6359,7 +6004,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
     inputStream = htmlNewInputStream(ctxt);
     if (inputStream == NULL) {
        xmlFreeParserCtxt(ctxt);
-       xmlFree(buf);
+       xmlFreeParserInputBuffer(buf);
        return(NULL);
     }
 
@@ -6375,15 +6020,16 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
 
     if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL))  {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
-       size_t cur = ctxt->input->cur - ctxt->input->base;
-
-       xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+       size_t pos = ctxt->input->cur - ctxt->input->base;
+        int res;
 
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
-#ifdef DEBUG_PUSH
-       xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
-#endif
+       res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+        xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
+        if (res < 0) {
+            htmlParseErr(ctxt, ctxt->input->buf->error,
+                         "xmlParserInputBufferPush failed\n", NULL, NULL);
+            xmlHaltParser(ctxt);
+        }
     }
     ctxt->progressive = 1;
 
@@ -6398,6 +6044,8 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
  * @sax:  the SAX handler block
  * @userData: if using SAX, this pointer will be provided on callbacks.
  *
+ * DEPRECATED: Use htmlNewSAXParserCtxt and htmlCtxtReadDoc.
+ *
  * Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks
  * to handle parse events. If sax is NULL, fallback to the default DOM
  * behavior and return a tree.
@@ -6469,8 +6117,6 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
     htmlParserCtxtPtr ctxt;
     htmlParserInputPtr inputStream;
     char *canonicFilename;
-    /* htmlCharEncoding enc; */
-    xmlChar *content, *content_line = (xmlChar *) "charset=";
 
     if (filename == NULL)
         return(NULL);
@@ -6481,11 +6127,6 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
     }
     canonicFilename = (char *) xmlCanonicPath((const xmlChar *) filename);
     if (canonicFilename == NULL) {
-#ifdef LIBXML_SAX1_ENABLED
-       if (xmlDefaultSAXHandler.error != NULL) {
-           xmlDefaultSAXHandler.error(NULL, "out of memory\n");
-       }
-#endif
        xmlFreeParserCtxt(ctxt);
        return(NULL);
     }
@@ -6501,17 +6142,12 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
 
     /* set encoding */
     if (encoding) {
-        size_t l = strlen(encoding);
-
-       if (l < 1000) {
-           content = xmlMallocAtomic (xmlStrlen(content_line) + l + 1);
-           if (content) {
-               strcpy ((char *)content, (char *)content_line);
-               strcat ((char *)content, (char *)encoding);
-               htmlCheckEncoding (ctxt, content);
-               xmlFree (content);
-           }
-       }
+        xmlCharEncodingHandlerPtr hdlr;
+
+        hdlr = xmlFindCharEncodingHandler(encoding);
+        if (hdlr != NULL) {
+            xmlSwitchToEncoding(ctxt, hdlr);
+        }
     }
 
     return(ctxt);
@@ -6524,6 +6160,8 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
  * @sax:  the SAX handler block
  * @userData: if using SAX, this pointer will be provided on callbacks.
  *
+ * DEPRECATED: Use htmlNewSAXParserCtxt and htmlCtxtReadFile.
+ *
  * parse an HTML file and build a tree. Automatic support for ZLIB/Compress
  * compressed document is provided by default if found at compile-time.
  * It use the given SAX function block to handle the parsing callback.
@@ -6792,14 +6430,15 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
     ctxt->disableSAX = 0;
     ctxt->valid = 1;
     ctxt->vctxt.userData = ctxt;
+    ctxt->vctxt.flags = XML_VCTXT_USE_PCTXT;
     ctxt->vctxt.error = xmlParserValidityError;
     ctxt->vctxt.warning = xmlParserValidityWarning;
     ctxt->record_info = 0;
     ctxt->checkIndex = 0;
+    ctxt->endCheckState = 0;
     ctxt->inSubset = 0;
     ctxt->errNo = XML_ERR_OK;
     ctxt->depth = 0;
-    ctxt->charset = XML_CHAR_ENCODING_NONE;
     ctxt->catalogs = NULL;
     xmlInitNodeInfoSeq(&ctxt->node_seq);
 
@@ -6811,6 +6450,11 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
         xmlHashFree(ctxt->attsSpecial, NULL);
         ctxt->attsSpecial = NULL;
     }
+
+    ctxt->nbErrors = 0;
+    ctxt->nbWarnings = 0;
+    if (ctxt->lastError.code != XML_ERR_OK)
+        xmlResetError(&ctxt->lastError);
 }
 
 /**
@@ -6881,6 +6525,7 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
         options -= HTML_PARSE_NOIMPLIED;
     }
     ctxt->dictNames = 0;
+    ctxt->linenumbers = 1;
     return (options);
 }
 
@@ -6910,9 +6555,6 @@ htmlDoRead(htmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
        hdlr = xmlFindCharEncodingHandler(encoding);
        if (hdlr != NULL) {
            xmlSwitchToEncoding(ctxt, hdlr);
-           if (ctxt->input->encoding != NULL)
-             xmlFree((xmlChar *) ctxt->input->encoding);
-            ctxt->input->encoding = xmlStrdup((xmlChar *)encoding);
         }
     }
     if ((URL != NULL) && (ctxt->input != NULL) &&
@@ -6997,12 +6639,9 @@ htmlReadMemory(const char *buffer, int size, const char *URL, const char *encodi
     htmlParserCtxtPtr ctxt;
 
     xmlInitParser();
-    ctxt = xmlCreateMemoryParserCtxt(buffer, size);
+    ctxt = htmlCreateMemoryParserCtxt(buffer, size);
     if (ctxt == NULL)
         return (NULL);
-    htmlDefaultSAXHandlerInit();
-    if (ctxt->sax != NULL)
-        memcpy(ctxt->sax, &htmlDefaultSAXHandler, sizeof(xmlSAXHandlerV1));
     return (htmlDoRead(ctxt, URL, encoding, options, 0));
 }
 
@@ -7099,7 +6738,7 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
 /**
  * htmlCtxtReadDoc:
  * @ctxt:  an HTML parser context
- * @cur:  a pointer to a zero terminated string
+ * @str:  a pointer to a zero terminated string
  * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of htmlParserOption(s)
@@ -7110,13 +6749,33 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
  * Returns the resulting document tree
  */
 htmlDocPtr
-htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
+htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar *str,
                const char *URL, const char *encoding, int options)
 {
-    if (cur == NULL)
+    xmlParserInputBufferPtr input;
+    xmlParserInputPtr stream;
+
+    if (ctxt == NULL)
+        return (NULL);
+    if (str == NULL)
         return (NULL);
-    return (htmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
-                               encoding, options));
+    xmlInitParser();
+
+    htmlCtxtReset(ctxt);
+
+    input = xmlParserInputBufferCreateString(str);
+    if (input == NULL) {
+       return(NULL);
+    }
+
+    stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
+    if (stream == NULL) {
+       xmlFreeParserInputBuffer(input);
+       return(NULL);
+    }
+
+    inputPush(ctxt, stream);
+    return (htmlDoRead(ctxt, URL, encoding, options, 1));
 }
 
 /**
@@ -7182,7 +6841,8 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
 
     htmlCtxtReset(ctxt);
 
-    input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
+    input = xmlParserInputBufferCreateStatic(buffer, size,
+                                             XML_CHAR_ENCODING_NONE);
     if (input == NULL) {
        return(NULL);
     }
index 3dd78a9..8698f53 100644 (file)
 #include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/entities.h>
-#include <libxml/valid.h>
 #include <libxml/xmlerror.h>
 #include <libxml/parserInternals.h>
-#include <libxml/globals.h>
 #include <libxml/uri.h>
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/error.h"
+#include "private/io.h"
+#include "private/save.h"
 
 /************************************************************************
  *                                                                     *
@@ -328,11 +329,6 @@ htmlIsBooleanAttr(const xmlChar *name)
 }
 
 #ifdef LIBXML_OUTPUT_ENABLED
-/*
- * private routine exported from xmlIO.c
- */
-xmlOutputBufferPtr
-xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
 /************************************************************************
  *                                                                     *
  *                     Output error handlers                           *
@@ -417,7 +413,7 @@ htmlBufNodeDumpFormat(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur,
         htmlSaveErrMemory("allocating HTML output buffer");
        return (-1);
     }
-    memset(outbuf, 0, (size_t) sizeof(xmlOutputBuffer));
+    memset(outbuf, 0, sizeof(xmlOutputBuffer));
     outbuf->buffer = buf;
     outbuf->encoder = NULL;
     outbuf->writecallback = NULL;
@@ -622,8 +618,6 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
  *                                                                     *
  ************************************************************************/
 
-void xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
-
 /**
  * htmlDtdDumpOutput:
  * @buf:  the HTML buffer output
@@ -705,10 +699,15 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
                while (IS_BLANK_CH(*tmp)) tmp++;
 
                /*
-                * the < and > have already been escaped at the entity level
-                * And doing so here breaks server side includes
+                 * Angle brackets are technically illegal in URIs, but they're
+                 * used in server side includes, for example. Curly brackets
+                 * are illegal as well and often used in templates.
+                 * Don't escape non-whitespace, printable ASCII chars for
+                 * improved interoperability. Only escape space, control
+                 * and non-ASCII chars.
                 */
-               escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+<>");
+               escaped = xmlURIEscapeStr(tmp,
+                        BAD_CAST "\"#$%&+,/:;<=>?@[\\]^`{|}");
                if (escaped != NULL) {
                    xmlBufWriteQuotedString(buf->buffer, escaped);
                    xmlFree(escaped);
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644 (file)
index 0000000..c5000db
--- /dev/null
@@ -0,0 +1,97 @@
+# Maintainer's Guide
+
+## Working with the test suite
+
+Most of the tests are contained in the `runtest` executable which
+generally reads test cases from the `test` directory and compares output
+to files in the `result` directory.
+
+You can simply add new test cases and run `runtest -u` to update the
+results. If you debug test failures, it's also useful to execute
+`runtest -u` and then `git diff result` to get a diff between actual and
+expected results. You can restore the original results by running
+`git restore result` and `git clean -xd result`.
+
+## Generated files
+
+The documentation and other generated files can be rebuilt by running
+
+    make -C doc rebuild
+
+This requires `xsltproc`, the DocBook stylesheets in your XML Catalog
+and the libxml2 Python bindings to be installed, so it's best done on a
+Linux system. On Debian/Ubuntu, try
+
+    apt install xsltproc python3-libxml2 docbook-xsl docbook-xml
+
+doc/apibuild.py generates doc/libxml2-api.xml which is used to generate
+
+- API documentation with XSLT stylesheets
+- testapi.c with gentest.py
+- Python bindings with python/generator.py
+
+Man pages and HTML documentation for xmllint and xmlcatalog are
+generated with xsltproc and DocBook stylesheets.
+
+## Making a release
+
+### Rebuild generated files and documentation
+
+See above for details and run `make -C doc rebuild`.
+
+Look for new warning messages and inspect changes for correctness
+before committing.
+
+### Update the NEWS file
+
+You can get started by running
+
+    git log --format='- %s (%an)' [previous-release-tag]..
+
+### Bump the version number
+
+Edit the version number in `configure.ac` if you haven't done so already.
+
+### Build the tarball
+
+I'd recommend to build the tarball by running
+
+    make distcheck
+
+which performs some useful checks as well.
+
+### Upload the tarball
+
+Follow the instructions at
+<https://wiki.gnome.org/MaintainersCorner/Releasing>:
+
+    scp libxml2-[version].tar.xz master.gnome.org:
+    ssh master.gnome.org ftpadmin install libxml2-[version].tar.xz
+
+### Tag the release
+
+Create an annotated tag and push it:
+
+    git tag -a [version] -m 'Release [version]'
+    git push origin [version]
+
+### Create a GitLab release
+
+Create a new GitLab release on
+<https://gitlab.gnome.org/GNOME/libxml2/-/releases>.
+
+### Announce the release
+
+Announce the release by sending an email to the mailing list at
+xml@gnome.org.
+
+## Updating the CI Docker image
+
+Note that the CI image is used for libxslt as well. Run the following
+commands with the Dockerfile in the .gitlab-ci directory:
+
+    docker login registry.gitlab.gnome.org
+    docker build -t registry.gitlab.gnome.org/gnome/libxml2 - \
+        < .gitlab-ci/Dockerfile
+    docker push registry.gitlab.gnome.org/gnome/libxml2
+
index 316109b..0a49d37 100644 (file)
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = include . doc example fuzz xstc
+SUBDIRS = include . doc example xstc
 if WITH_PYTHON
 SUBDIRS += python
 endif
+if WITH_GLOB
+SUBDIRS += fuzz
+endif
 
 DIST_SUBDIRS = include . doc example fuzz python xstc
 
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include -DSYSCONFDIR='"$(sysconfdir)"'
 
-AM_CFLAGS = $(EXTRA_CFLAGS)
-
 check_PROGRAMS = \
        runsuite \
        runtest \
        runxmlconf \
-       testAutomata \
        testModule \
        testThreads \
        testapi \
        testchar \
        testdict \
        testlimits \
+       testparser \
        testrecurse
 
 bin_PROGRAMS = xmllint xmlcatalog
 
-nodist_bin_SCRIPTS = xml2-config
+bin_SCRIPTS = xml2-config
 
 lib_LTLIBRARIES = libxml2.la
-libxml2_la_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS)
+libxml2_la_CFLAGS = $(AM_CFLAGS) $(XML_PRIVATE_CFLAGS)
 libxml2_la_LIBADD = $(XML_PRIVATE_LIBS)
 
-if USE_VERSION_SCRIPT
-LIBXML2_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
-else
-LIBXML2_VERSION_SCRIPT =
-endif
-
-libxml2_la_LDFLAGS = $(CYGWIN_EXTRA_LDFLAGS) $(WIN32_EXTRA_LDFLAGS) \
-                    $(LIBXML2_VERSION_SCRIPT) \
+libxml2_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \
                     -version-info $(LIBXML_VERSION_INFO) \
                     $(MODULE_PLATFORM_LIBS)
+if USE_VERSION_SCRIPT
+libxml2_la_LDFLAGS += $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxml2.syms
+endif
 
+libxml2_la_SOURCES = buf.c chvalid.c dict.c entities.c encoding.c error.c \
+                    globals.c hash.c list.c parser.c parserInternals.c \
+                    SAX2.c threads.c tree.c uri.c valid.c xmlIO.c \
+                    xmlmemory.c xmlstring.c
+if WITH_C14N_SOURCES
+libxml2_la_SOURCES += c14n.c
+endif
+if WITH_CATALOG_SOURCES
+libxml2_la_SOURCES += catalog.c
+endif
+if WITH_DEBUG_SOURCES
+libxml2_la_SOURCES += debugXML.c
+endif
+if WITH_FTP_SOURCES
+libxml2_la_SOURCES += nanoftp.c
+endif
+if WITH_HTML_SOURCES
+libxml2_la_SOURCES += HTMLparser.c HTMLtree.c
+endif
+if WITH_HTTP_SOURCES
+libxml2_la_SOURCES += nanohttp.c
+endif
+if WITH_LEGACY_SOURCES
+libxml2_la_SOURCES += legacy.c
+if WITH_SAX1_SOURCES
+libxml2_la_SOURCES += SAX.c
+endif
+endif
+if WITH_LZMA_SOURCES
+libxml2_la_SOURCES += xzlib.c
+endif
+if WITH_MODULES_SOURCES
+libxml2_la_SOURCES += xmlmodule.c
+endif
+if WITH_OUTPUT_SOURCES
+libxml2_la_SOURCES += xmlsave.c
+endif
+if WITH_PATTERN_SOURCES
+libxml2_la_SOURCES += pattern.c
+endif
+if WITH_READER_SOURCES
+libxml2_la_SOURCES += xmlreader.c
+endif
+if WITH_REGEXPS_SOURCES
+libxml2_la_SOURCES += xmlregexp.c xmlunicode.c
+endif
+if WITH_SCHEMAS_SOURCES
+libxml2_la_SOURCES += relaxng.c xmlschemas.c xmlschemastypes.c
+if !WITH_XPATH_SOURCES
+libxml2_la_SOURCES += xpath.c
+endif
+endif
+if WITH_SCHEMATRON_SOURCES
+libxml2_la_SOURCES += schematron.c
+endif
 if WITH_TRIO_SOURCES
-trio_sources = triostr.c trio.c
-else
-trio_sources =
+libxml2_la_SOURCES += triostr.c trio.c
+endif
+if WITH_WRITER_SOURCES
+libxml2_la_SOURCES += xmlwriter.c
+endif
+if WITH_XINCLUDE_SOURCES
+libxml2_la_SOURCES += xinclude.c
+endif
+if WITH_XPATH_SOURCES
+libxml2_la_SOURCES += xpath.c
+endif
+if WITH_XPTR_SOURCES
+libxml2_la_SOURCES += xlink.c xpointer.c
 endif
-
-libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
-               parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c  \
-               valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c  \
-               xpointer.c xinclude.c nanohttp.c nanoftp.c \
-               catalog.c globals.c threads.c c14n.c xmlstring.c buf.c \
-               xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
-               $(trio_sources) \
-               xmlreader.c relaxng.c dict.c SAX2.c \
-               xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
-               xmlmodule.c schematron.c xzlib.c
 
 DEPS = $(top_builddir)/libxml2.la
 LDADDS = $(top_builddir)/libxml2.la
 
 
 m4datadir = $(datadir)/aclocal
-m4data_DATA = libxml.m4
+dist_m4data_DATA = libxml.m4
 
 runtest_SOURCES=runtest.c
-runtest_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS)
-runtest_LDFLAGS = 
+runtest_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 runtest_DEPENDENCIES = $(DEPS)
 runtest_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS)
 
 testrecurse_SOURCES=testrecurse.c
-testrecurse_LDFLAGS = 
 testrecurse_DEPENDENCIES = $(DEPS)
 testrecurse_LDADD= $(LDADDS)
 
 testlimits_SOURCES=testlimits.c
-testlimits_LDFLAGS = 
 testlimits_DEPENDENCIES = $(DEPS)
 testlimits_LDADD= $(LDADDS)
 
 testchar_SOURCES=testchar.c
-testchar_LDFLAGS = 
 testchar_DEPENDENCIES = $(DEPS)
 testchar_LDADD= $(LDADDS)
 
 testdict_SOURCES=testdict.c
-testdict_LDFLAGS = 
 testdict_DEPENDENCIES = $(DEPS)
 testdict_LDADD= $(LDADDS)
 
+testparser_SOURCES=testparser.c
+testparser_DEPENDENCIES = $(DEPS)
+testparser_LDADD= $(LDADDS)
+
 runsuite_SOURCES=runsuite.c
-runsuite_LDFLAGS = 
 runsuite_DEPENDENCIES = $(DEPS)
 runsuite_LDADD= $(LDADDS)
 
 xmllint_SOURCES=xmllint.c
-xmllint_LDFLAGS = 
+xmllint_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS) $(ICONV_CFLAGS)
 xmllint_DEPENDENCIES = $(DEPS)
 xmllint_LDADD=  $(RDL_LIBS) $(LDADDS)
 
 xmlcatalog_SOURCES=xmlcatalog.c
-xmlcatalog_LDFLAGS = 
+xmlcatalog_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS) $(ICONV_CFLAGS)
 xmlcatalog_DEPENDENCIES = $(DEPS)
 xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS)
 
 testThreads_SOURCES = testThreads.c
-testThreads_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS)
-testThreads_LDFLAGS = 
+testThreads_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 testThreads_DEPENDENCIES = $(DEPS)
 testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS)
 
-testAutomata_SOURCES=testAutomata.c
-testAutomata_LDFLAGS = 
-testAutomata_DEPENDENCIES = $(DEPS)
-testAutomata_LDADD= $(LDADDS)
-
 testModule_SOURCES=testModule.c
-testModule_LDFLAGS = 
 testModule_DEPENDENCIES = $(DEPS)
 testModule_LDADD= $(LDADDS)
 
 noinst_LTLIBRARIES = testdso.la
 testdso_la_SOURCES = testdso.c
-testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir)
+testdso_la_LDFLAGS = $(AM_LDFLAGS) \
+                    -module -no-undefined -avoid-version -rpath $(libdir)
 
 # that one forces the rebuild when "make rebuild" is run on doc/
 rebuild_testapi:
@@ -136,17 +179,14 @@ rebuild_testapi:
            $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
 
 testapi_SOURCES=testapi.c
-testapi_LDFLAGS = 
 testapi_DEPENDENCIES = $(DEPS)
 testapi_LDADD= $(LDADDS)
 
 runxmlconf_SOURCES=runxmlconf.c
-runxmlconf_LDFLAGS = 
 runxmlconf_DEPENDENCIES = $(DEPS)
 runxmlconf_LDADD= $(LDADDS)
 
 #testOOM_SOURCES=testOOM.c testOOMlib.h testOOMlib.c
-#testOOM_LDFLAGS = 
 #testOOM_DEPENDENCIES = $(DEPS)
 #testOOM_LDADD= $(LDADDS)
 
@@ -155,12 +195,14 @@ check-local:
        [ -d result ] || $(LN_S) $(srcdir)/result .
        $(CHECKER) ./runtest$(EXEEXT)
        $(CHECKER) ./testrecurse$(EXEEXT)
-       ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) ./testapi$(EXEEXT)
+       $(CHECKER) ./testapi$(EXEEXT)
        $(CHECKER) ./testchar$(EXEEXT)
        $(CHECKER) ./testdict$(EXEEXT)
+       $(CHECKER) ./testparser$(EXEEXT)
        $(CHECKER) ./testModule$(EXEEXT)
        $(CHECKER) ./testThreads$(EXEEXT)
        $(CHECKER) ./runxmlconf$(EXEEXT)
+       $(CHECKER) ./runsuite$(EXEEXT)
 
 # Compatibility name of the check target
 runtests: check
@@ -175,10 +217,29 @@ asan:
        ./configure CFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" CXXFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" LDFLAGS="-fsanitize=address,undefined" CC="clang" CXX="clang++" --disable-shared ; OptimOff  ; $(MAKE) clean ; $(MAKE)
 
 # Old test suite. This should be ported to C.
-tests: $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMATRON) Timingtests $(TEST_VTIME) $(PYTHON_TESTS)
+
+OLD_TESTS = Timingtests
+if WITH_CATALOG_SOURCES
+OLD_TESTS += Catatests
+endif
+if WITH_DEBUG_SOURCES
+OLD_TESTS += Scripttests
+endif
+if WITH_SCHEMAS_SOURCES
+if WITH_PYTHON
+OLD_TESTS += RelaxNGPythonTests SchemasPythonTests
+endif
+endif
+if WITH_SCHEMATRON_SOURCES
+OLD_TESTS += Schematrontests
+endif
+if WITH_VALID_SOURCES
+OLD_TESTS += VTimingtests
+endif
+
+tests: $(OLD_TESTS)
 
 Scripttests : xmllint$(EXEEXT)
-       @(echo > .memdump)
        @echo "## Scripts regression tests"
        @echo "## Some of the base computations may be different if srcdir != ."
        -@(for i in $(srcdir)/test/scripts/*.script ; do \
@@ -188,10 +249,8 @@ Scripttests : xmllint$(EXEEXT)
          if [ ! -f $(srcdir)/result/scripts/$$name ] ; then \
              echo New test file $$name ; \
              $(CHECKER) $(top_builddir)/xmllint --shell $$xml < $$i > $(srcdir)/result/scripts/$$name 2> $(srcdir)/result/scripts/$$name.err ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
          else \
              log=`$(CHECKER) $(top_builddir)/xmllint --shell $$xml < $$i > result.$$name 2> result.$$name.err ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
              diff $(srcdir)/result/scripts/$$name result.$$name ; \
              diff $(srcdir)/result/scripts/$$name.err result.$$name.err` ; \
              if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
@@ -199,7 +258,6 @@ Scripttests : xmllint$(EXEEXT)
          fi ; fi ; done)
 
 Catatests : xmlcatalog$(EXEEXT)
-       @(echo > .memdump)
        @echo "## Catalog regression tests"
        -@(for i in $(srcdir)/test/catalogs/*.script ; do \
          name=`basename $$i .script`; \
@@ -208,10 +266,8 @@ Catatests : xmlcatalog$(EXEEXT)
          if [ ! -f $(srcdir)/result/catalogs/$$name ] ; then \
              echo New test file $$name ; \
              $(CHECKER) $(top_builddir)/xmlcatalog --shell $$xml < $$i 2>&1 > $(srcdir)/result/catalogs/$$name ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
          else \
              log=`$(CHECKER) $(top_builddir)/xmlcatalog --shell $$xml < $$i 2>&1 > result.$$name ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
              diff $(srcdir)/result/catalogs/$$name result.$$name` ; \
              if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
              rm result.$$name ; \
@@ -223,53 +279,24 @@ Catatests : xmlcatalog$(EXEEXT)
          if [ ! -f $(srcdir)/result/catalogs/$$name ] ; then \
              echo New test file $$name ; \
              $(CHECKER) $(top_builddir)/xmlcatalog --shell $$sgml < $$i > $(srcdir)/result/catalogs/$$name ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
          else \
              log=`$(CHECKER) $(top_builddir)/xmlcatalog --shell $$sgml < $$i > result.$$name ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
              diff $(srcdir)/result/catalogs/$$name result.$$name` ; \
              if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
              rm result.$$name ; \
          fi ; fi ; done)
        @echo "## Add and del operations on XML Catalogs"
        -@($(CHECKER) $(top_builddir)/xmlcatalog --create --noout $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --add public Pubid sysid $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --add public Pubid2 sysid2 $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --add public Pubid3 sysid3 $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        diff result/catalogs/mycatalog.full $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --del sysid $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --del sysid3 $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        $(CHECKER) $(top_builddir)/xmlcatalog --noout --del sysid2 $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        diff result/catalogs/mycatalog.empty $(srcdir)/result/catalogs/mycatalog; \
-       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0"; \
        rm -f $(srcdir)/result/catalogs/mycatalog)
 
-Automatatests: testAutomata$(EXEEXT)
-       @(echo > .memdump)
-       @echo "## Automata regression tests"
-       -@(for i in $(srcdir)/test/automata/* ; do \
-         name=`basename $$i`; \
-         if [ ! -d $$i ] ; then \
-         if [ ! -f $(srcdir)/result/automata/$$name ] ; then \
-             echo New test file $$name ; \
-             $(CHECKER) $(top_builddir)/testAutomata $$i > $(srcdir)/result/automata/$$name; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-         else \
-             log=`$(CHECKER) $(top_builddir)/testAutomata $$i 2>&1 > result.$$name ; \
-             grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-             diff $(srcdir)/result/automata/$$name result.$$name` ; \
-             if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-             rm result.$$name ; \
-         fi ; fi ; done)
-
 dba100000.xml: dbgenattr.pl
        @echo "## generating dba100000.xml"
        @($(PERL) $(top_srcdir)/dbgenattr.pl 100000 > dba100000.xml)
@@ -282,30 +309,21 @@ Timingtests: xmllint$(EXEEXT) dba100000.xml
        @echo "## 3/ repeated DOM parsing"
        @echo "## 4/ repeated DOM validation"
        -@($(top_builddir)/xmllint --stream --timing dba100000.xml; \
-          MEM=`cat .memdump | grep "MEMORY ALLOCATED" | awk '{ print $$7}'`;\
           if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
-          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
           exit 0)
        -@($(top_builddir)/xmllint --stream --timing --memory dba100000.xml; \
-          MEM=`cat .memdump | grep "MEMORY ALLOCATED" | awk '{ print $$7}'`;\
           if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
-          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
           exit 0)
        -@($(top_builddir)/xmllint --noout --timing --repeat $(srcdir)/test/valid/REC-xml-19980210.xml; \
-          MEM=`cat .memdump | grep "MEMORY ALLOCATED" | awk '{ print $$7}'`;\
           if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
-          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
           exit 0)
 
 VTimingtests: xmllint$(EXEEXT)
        -@($(top_builddir)/xmllint --noout --timing --valid --repeat $(srcdir)/test/valid/REC-xml-19980210.xml; \
-          MEM=`cat .memdump | grep "MEMORY ALLOCATED" | awk '{ print $$7}'`;\
           if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
-          grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
           exit 0)
 
 Schematrontests: xmllint$(EXEEXT)
-       @(echo > .memdump)
        @echo "## Schematron regression tests"
        -@(for i in $(srcdir)/test/schematron/*.sct ; do \
          name=`basename $$i | sed 's+\.sct++'`; \
@@ -318,11 +336,9 @@ Schematrontests: xmllint$(EXEEXT)
                  $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
                    > $(srcdir)/result/schematron/"$$name"_"$$xno" \
                    2> $(srcdir)/result/schematron/"$$name"_"$$xno".err; \
-                 grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
              else \
                  log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
                    > res.$$name 2> err.$$name;\
-                 grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
                  diff $(srcdir)/result/schematron/"$$name"_"$$xno" \
                       res.$$name;\
                  diff $(srcdir)/result/schematron/"$$name"_"$$xno".err \
@@ -365,42 +381,25 @@ cleanup:
 dist-hook: cleanup
        (cd $(srcdir) ; tar -cf - --exclude .git win32 os400 vms test result) | (cd $(distdir); tar xf -)
 
-dist-source: distdir
-       $(AMTAR) -chof - --exclude Tests --exclude test --exclude result $(distdir) | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-sources+"`.tar.gz
-
-dist-test: distdir
-       (mkdir -p $(distdir))
-       (cd $(srcdir) ; tar -cf - --exclude .git xstc/Tests) | (cd $(distdir); tar xf -)
-       tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests  $(distdir)/Makefile.tests $(distdir)/README.md $(distdir)/README.tests $(distdir)/testapi.c $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
-       @(rm -rf $(distdir)/xstc/Test)
-
-cleantar:
-       @(rm -f libxml*.tar.gz COPYING.LIB)
-
-rpm: cleanup cleantar
-       @(unset CDPATH ; $(MAKE) dist-source dist && rpmbuild -ta $(distdir).tar.gz)
-
-CLEANFILES = runxmlconf.log test.out *.gcda *.gcno *.res
+CLEANFILES = runsuite.log runxmlconf.log test.out *.gcda *.gcno *.res
 DISTCLEANFILES = COPYING missing.lst
 
-EXTRA_DIST = xml2-config.in libxml.spec.in \
-             libxml.m4 Copyright check-xml-test-suite.py gentest.py \
+EXTRA_DIST = Copyright check-xml-test-suite.py gentest.py \
             check-relaxng-test-suite.py check-relaxng-test-suite2.py \
             check-xsddata-test-suite.py check-xinclude-test-suite.py \
              example/Makefile.am example/gjobread.c example/gjobs.xml \
-            libxml-2.0.pc.in libxml-2.0-uninstalled.pc.in \
             libxml2-config.cmake.in autogen.sh \
             trionan.c trionan.h triostr.c triostr.h trio.c trio.h \
-            triop.h triodef.h libxml.h xzlib.h buf.h \
-            enc.h save.h genUnicode.py TODO_SCHEMAS \
+            triop.h triodef.h libxml.h \
+            genUnicode.py \
             dbgen.pl dbgenattr.pl \
-            README.tests Makefile.tests libxml2.syms timsort.h \
+            libxml2.syms timsort.h \
             README.zOS README.md \
             CMakeLists.txt config.h.cmake.in libxml2-config.cmake.cmake.in
 
 
 pkgconfigdir = $(libdir)/pkgconfig
-nodist_pkgconfig_DATA = libxml-2.0.pc
+pkgconfig_DATA = libxml-2.0.pc
 
 cmakedir = $(libdir)/cmake/libxml2
 cmake_DATA = libxml2-config.cmake
@@ -425,7 +424,7 @@ LCOV = /usr/bin/lcov
 GENHTML = /usr/bin/genhtml
 
 cov: clean-cov
-       if [ "`echo $(LDFLAGS) | grep coverage`" = "" ] ; then \
+       if [ "`echo $(AM_LDFLAGS) | grep coverage`" = "" ] ; then \
            echo not configured with coverage; exit 1 ; fi
        if [ ! -x $(LCOV) -o ! -x $(GENHTML) ] ; then \
            echo Need $(LCOV) and $(GENHTML) excecutables; exit 1 ; fi
diff --git a/Makefile.tests b/Makefile.tests
deleted file mode 100644 (file)
index 9f08dcf..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# You may have to adjust to call the right compiler, or other options
-# for compiling and linking
-#
-
-CFLAGS=`xml2-config --cflags`
-LIBS=`xml2-config --libs`
-THREADLIB= -lpthread
-EXEEXT=
-
-all: runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT) testchar$(EXEEXT)
-
-clean:
-       $(RM) runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT)
-
-check: do_runtest do_testchar do_testapi do_runsuite
-
-runtest$(EXEEXT): runtest.c
-       $(CC) -o runtest$(EXEEXT) $(CFLAGS) runtest.c $(LIBS) $(THREADLIB)
-
-do_runtest: runtest$(EXEEXT)
-       ./runtest
-
-runsuite$(EXEEXT): runsuite.c
-       $(CC) -o runsuite$(EXEEXT) $(CFLAGS) runsuite.c $(LIBS)
-
-do_runsuite: runsuite$(EXEEXT)
-       ./runsuite
-
-testapi$(EXEEXT): testapi.c
-       $(CC) -o testapi$(EXEEXT) $(CFLAGS) testapi.c $(LIBS)
-
-do_testapi: testapi$(EXEEXT)
-       ./testapi
-
-testchar$(EXEEXT): testchar.c
-       $(CC) -o testchar$(EXEEXT) $(CFLAGS) testchar.c $(LIBS)
-
-do_testchar: testchar$(EXEEXT)
-       ./testchar
-
diff --git a/NEWS b/NEWS
index 7e35a4d..2c891bb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,715 @@
 NEWS file for libxml2
 
+v2.12.5: Feb 4 2024
+
+### Security
+
+- [CVE-2024-25062] xmlreader: Don't expand XIncludes when backtracking
+
+### Regressions
+
+- parser: Fix crash in xmlParseInNodeContext with HTML documents
+
+
+v2.12.4: Jan 15 2024
+
+### Regressions
+
+- parser: Fix regression parsing standalone declarations
+- autotools: Readd --with-xptr-locs configuration option
+- parser: Fix build --without-output
+- parser: Don't grow or shrink pull parser memory buffers
+- io: Fix memory lifetime issue with input buffers
+
+
+v2.12.3: Dec 12 2023
+
+### Regressions
+
+- parser: Fix namespaces redefined from default attributes
+
+### Build fixes
+
+- include: Rename XML_EMPTY helper macro
+- include: Move declaration of xmlInitGlobals
+- include: Add missing includes
+- include: Move globals from xmlsave.h to parser.h
+- include: Readd circular dependency between tree.h and parser.h
+
+
+v2.12.2: Dec 5 2023
+
+### Regressions
+
+- parser: Fix invalid free in xmlParseBalancedChunkMemoryRecover
+- globals: Disable TLS in static Windows builds
+- html: Reenable buggy detection of XML declarations
+- tree: Fix regression when copying DTDs
+- parser: Make CRLF increment line number
+
+### Build fixes
+
+- build: Disable compiler TLS by default
+- cmake: Update config.h.cmake.in
+- tests: Fix tests --with-valid --without-xinclude
+
+
+v2.12.1: Nov 23 2023
+
+### Regressions
+
+- hash: Fix deletion of entries during scan
+- parser: Only enable SAX2 if there are SAX2 element handlers
+
+### Build fixes
+
+- autotools: Stop checking for snprintf
+- dict: Fix '__thread' before 'static'
+- fix: pthread weak references in globals.c (Mike Dalessio)
+- tests: Fix build with older MSVC
+
+
+v2.12.0: Nov 16 2023
+
+### Major changes
+
+Most of the known issues leading to quadratic behavior in the XML parser
+were fixed. Internal hash tables were rewritten to reduce memory
+consumption.
+
+Starting with this release, it should be enough to add the --with-legacy
+configuration option to provide maximum ABI compatibility. For example,
+if a code module was removed from the default configuration, the option
+will add stubs for the removed symbols.
+
+libxml2 will now store global variables in thread-local storage if supported
+by the compiler. This avoids allocating the data lazily which can result in
+a fatal error condition. A new API function xmlCheckThreadLocalStorage
+was added so the allocation can be checked earlier if compiler TLS is not
+supported. To prepare for future improvements, some API functions now expect
+or return a const xmlError struct.
+
+Several cyclic dependencies in public header files were fixed. As a result,
+certain headers won't include other headers as before.
+
+Refactoring of the encoding code has been mostly completed. Calling
+xmlSwitchEncoding from client code is now fully supported, for example to
+override the encoding for the push parser.
+
+When parsing data from memory, libxml2 will now stream data chunk by chunk
+instead of copying the whole buffer (possibly twice with encodings),
+reducing peak memory consumption considerably.
+
+A new API function xmlCtxtSetMaxAmplification was added to allow parsing
+of files that would otherwise trigger the billion laughs protection.
+
+Several bugs in the regex determinism checks were fixed. Invalid XML
+Schemas which previous versions erroneously accepted will now be
+rejected.
+
+### Deprecations
+
+- globals: Deprecate xmlLastError
+- parser: Deprecate global parser options
+- win32: Deprecate old Windows build system
+
+### Bug fixes
+
+- parser: Stop switching to ISO-8859-1 on encoding errors
+- parser: Support encoded external PEs in entity values
+- string: Fix UTF-8 validation in xmlGetUTF8Char
+- SAX2: Allow multiple top-level elements
+- parser: Update line number after coalescing text nodes
+- parser: Check for truncated multi-byte sequences
+
+### Improvements
+
+- error: Make more xmlError structs constant
+- parser: Remove redundant IS_CHAR check in xmlCurrentChar
+- parser: Fix stack handling in xmlParseTryOrFinish
+- parser: Protect against quadratic default attribute expansion
+- parser: Missing checks for disableSAX
+- entities: Make xmlFreeEntity public
+- examples: Don't use sprintf
+- encoding: Suppress -Wcast-align warnings
+- parser: Use hash tables to avoid quadratic behavior
+- parser: Don't skip CR in xmlCurrentChar
+- dict: Rewrite dictionary hash table code
+- hash: Rewrite hash table code
+- malloc-fail: Report malloc failure in xmlFARegExec
+- malloc-fail: Report malloc failure in xmlRegEpxFromParse
+- parser: Simplify xmlStringCurrentChar
+- regexp: Fix status codes and handle invalid UTF-8
+- error: Make xmlGetLastError return a const error
+- html: Fix logic in htmlAutoClose
+- globals: Move globals back to correct header files
+- globals: Use thread-local storage if available
+- globals: Rework global state destruction on Windows
+- globals: Define globals using macros
+- globals: Introduce xmlCheckThreadLocalStorage
+- globals: Make xmlGlobalState private
+- threads: Move library initialization code to threads.c
+- debug: Remove debugging code
+- globals: Move code from threads.c to globals.c
+- parser: Avoid undefined behavior in xmlParseStartTag2
+- schemas: Fix memory leak of annotations in notations
+- dict: Update hash function
+- dict: Use thread-local storage for PRNG state
+- dict: Use xoroshiro64** as PRNG
+- xmllint: Fix error messages
+- parser: Fix detection of null bytes
+- parser: Improve error handling in push parser
+- parser: Don't check inputNr in xmlParseTryOrFinish
+- parser: Remove push parser debugging code
+- tree: Fix copying of DTDs
+- legacy: Add stubs for disabled modules
+- parser: Allow to set maximum amplification factor
+- entities: Don't change doc when encoding entities
+- parser: Never use UTF-8 encoding handler
+- encoding: Remove debugging code
+- malloc-fail: Fix unsigned integer overflow in xmlTextReaderPushData
+- html: Remove encoding hack in htmlCreateFileParserCtxt
+- parser: Decode all data in xmlCharEncInput
+- parser: Stream data when reading from memory
+- parser: Optimize xmlLoadEntityContent
+- parser: Don't overwrite EOF parser state
+- parser: Simplify input pointer updates
+- parser: Don't reinitialize parser input members
+- encoding: Move rawconsumed accounting to xmlCharEncInput
+- parser: Rework encoding detection
+- parser: Always create UTF-8 in xmlParseReference
+- html: Remove some debugging code in htmlParseTryOrFinish
+- malloc-fail: Fix memory leak in xmlCompileAttributeTest
+- parser: Recover more input from encoding errors
+- malloc-fail: Handle malloc failures in xmlAddEncodingAlias
+- malloc-fail: Fix null-deref with xmllint --copy
+- xpath: Ignore entity ref nodes when computing node hash
+- malloc-fail: Fix null deref after xmlXIncludeNewRef
+- SAX: Always validate xml:ids
+- Stop using sprintf
+- Fix compiler warning on GCC < 8
+- regexp: Fix determinism checks
+- regexp: Fix checks for eliminated transitions
+- regexp: Simplify xmlFAReduceEpsilonTransitions
+- regexp: Fix cycle check in xmlFAReduceEpsilonTransitions
+- schemas: Fix filename in xmlSchemaValidateFile
+- schemas: Fix line numbers in streaming validation
+- writer: Add error check in xmlTextWriterEndDocument
+- encoding: Stop calling xmlEncodingErr
+- xmlIO: Remove some calls to xmlIOErr
+- parser: Improve handling of encoding and IO errors
+- parser: Move xmlFatalErr to parserInternals.c
+- encoding: Rework error codes
+- .gitignore: Split up and rearrange .gitignore files
+- .gitignore: Add runsuite.log
+- Stop calling xmlMemoryDump
+- examples: Don't call xmlCleanupParser and xmlMemoryDump
+- xpath: Remove remaining references to valueFrame
+
+### Portability
+
+- python: Make it compatible with python3.12 (Daniel Garcia Moreno)
+
+### Build systems
+
+- cmake: Check whether static linking dependencies found in config files
+  (James Le Cuirot)
+- autotools: Make --with-minimum disable lzma support
+- build: Remove some GCC warnings
+- Handle NOCONFIG case when setting locations from CMake target properties
+  (Markus Rickert)
+- cmake: Generate better pkg-config file for SYSROOT builds under CMake
+  (James Le Cuirot)
+- autoconf: Include non-pkg-config dependency flags in the pkg-config file
+  (James Le Cuirot)
+- autoconf: Don't bake build time CFLAGS into pkg-config file (James Le Cuirot)
+- build: Generate better pkg-config files for static-only builds (James
+  Le Cuirot)
+- build: Generate better pkg-config file for SYSROOT builds (James Le Cuirot)
+- autoconf: Allow custom --with-icu configure option
+
+### Tests
+
+- tests: Also test xmlNextChar in testchar.c
+- tests: Start with testparser.c for extra tests
+- fuzz: Raise rss_limit_mb
+- fuzz: Test xmlTextReaderRead after EOF or failure
+- fuzz: Test XML_PARSE_XINCLUDE | XML_PARSE_VALID
+- tests: Handle entities in SAX tests
+- fuzz: Disable XML_PARSE_SAX1 option in xml fuzzer
+- tests: Add more tests for redefined attributes
+- hash: Add hash table tests
+- tests: Add ATTRIBUTE_NO_SANITIZE_INTEGER macro
+- fuzz: Allow to fuzz without push, reader or output modules
+- gitlab-ci: Add a "medium" config build
+- python: Fix tests on MinGW
+- test: Add push parser test with overridden encoding
+- testapi: test_xmlSAXDefaultVersion() leaves xmlSAX2DefaultVersionValue set
+  to 1 with LIBXML_SAX1_ENABLED (David Kilzer)
+- gitlab-ci: Lower _XOPEN_SOURCE value
+- testapi: Don't set http_proxy environment variable
+- test: Add push parser tests for split UTF-8 sequences
+- xinclude: Lower initial table size when fuzzing
+- tests: Test streaming schema validation
+- runtest: Skip element name in schema error messages
+
+### Documentation
+
+- doc: Add notes about runtest to MAINTAINERS.md
+- doc: Don't document internal macros in xmlversion.h
+- doc: Allow 'unsigned' without 'int'
+- doc: Improve documentation of configuration options
+
+
+v2.11.6: Nov 16 2023
+
+### Regressions
+
+- threads: Fix --with-thread-alloc
+- xinclude: Fix 'last' pointer in xmlXIncludeCopyNode
+
+### Bug fixes
+
+- parser: Fix potential use-after-free in xmlParseCharDataInternal
+
+
+v2.11.5: Aug 9 2023
+
+### Regressions
+
+- parser: Make xmlSwitchEncoding always skip the BOM
+- autotools: Improve iconv check
+
+### Bug fixes
+
+- valid: Fix c1->parent pointer in xmlCopyDocElementContent
+- encoding: Always call ucnv_convertEx with flush set to false
+
+### Portability
+
+- autotools: fix Python module file ext for cygwin/msys2 (Christoph Reiter)
+
+### Tests
+
+- runtest: Fix compilation without LIBXML_HTML_ENABLED
+
+
+v2.11.4: May 18 2023
+
+Fixes a serious regression.
+
+- parser: Fix regression when push parsing UTF-8 sequences
+
+
+v2.11.3: May 11 2023
+
+Fixes more regressions.
+
+- xinclude: Fix false positives in inclusion loop detection
+- autotools: Fix ICU detection
+- parser: Fix "huge input lookup" error with push parser
+- xpath: Fix build without LIBXML_XPATH_ENABLED
+- hash: Fix possible startup crash with old libxslt versions
+- autoconf: fix iconv library paths (Mike Dalessio)
+
+
+v2.11.2: May 5 2023
+
+Fix regressions.
+
+- threads: Fix startup crash with weak symbol hack
+- win32: Don't depend on removed .def file
+- schemas: Fix memory leak in xmlSchemaValidateStream
+
+
+v2.11.1: Apr 30 2023
+
+Fixes build and ABI issues.
+
+- cmake: Fix va_copy detection (Luca Niccoli)
+- libxml.m4: Fix quoting
+- Link with --undefined-version
+- libxml2.syms: Revert removal of version information
+
+
+v2.11.0: Apr 28 2023
+
+### Major changes
+
+Protection against entity expansion attacks, also known as "billion laughs"
+has been greatly improved. Malicious files should be detected reliably now
+and false positives should be reduced. It is possible though that large
+documents which make heavy use of entities are rejected now.
+
+This release finally fixes symbol visibility on UNIX systems. Internal
+symbols will now be hidden. While these symbols were never declared in public
+headers, it was still possible to declare them manually. Now this won't work.
+
+All symbol information has been removed from the ELF version script to fix
+link errors with --no-undefined-version. The version nodes are kept so it
+should still be possible to run binaries linked against older versions.
+
+About 90 memory errors in code paths handling malloc failures have been fixed.
+While these issues shouldn't impact security, this improves robustness under
+memory pressure.
+
+The XInclude engine has been reworked to properly support nested includes.
+
+Several cases of quadratic behavior in the XML push parser have been fixed.
+
+Refactoring has begun on some buffering and encoding code with the goal of
+simplifying this part of the code base and improving error reporting.
+
+Other highlights:
+
+- Consolidated private header files.
+- Major rework of the autoconf build.
+- Deprecated several outdated and internal functions.
+
+Special thanks to Google's Open Source Security Subsidies program for
+sponsoring much of the work on this release!
+
+Ongoing work on libxml2 relies on funding. For a list of important open
+issues see <https://gitlab.gnome.org/GNOME/libxml2/-/issues/507>
+
+### Security
+
+- Fix use-after-free in xmlParseContentInternal() (David Kilzer)
+- xmllint: Fix use-after-free with --maxmem
+- parser: Fix OOB read when formatting error message
+- entities: Rework entity amplification checks
+
+### Regressions
+
+- parser: Fix regression in xmlParserNodeInfo accounting
+
+### Bug fixes
+
+- Fix memory errors in code handling malloc failures
+- encoding: Fix error code in asciiToUTF8
+- xpath: number('-') should return NaN
+- xmlParseStartTag2() contains typo when checking for default definitions for
+  an attribute in a namespace (David Kilzer)
+- uri: Fix handling of port numbers
+- error: Make sure that error messages are valid UTF-8
+- xinclude: Fix nested includes
+
+### Improvements
+
+- xmllint: Validate --maxmem integer option
+- xmlValidatePopElement() can return invalid value (-1) (David Kilzer)
+- parser: Rework EBCDIC code page detection
+- parser: Limit name length in xmlParseEncName
+- parser: Rework shrinking of input buffers
+- html: Rely on CUR_CHAR to grow the input buffer
+- parser: Rely on CUR_CHAR/NEXT to grow the input buffer
+- valid: Make xmlValidateElement non-recursive
+- html: Fix quadratic behavior in htmlParseTryOrFinish
+- xmllint: Fix memory leak with --pattern --stream
+- parser: Stop calling xmlParserInputShrink
+- html: Impose some length limits
+- valid: Allow xmlFreeValidCtxt(NULL)
+- parser: Stop calling xmlParserInputGrow
+- xinclude: Fix quadratic behavior in xmlXIncludeLoadTxt
+- xinclude: Abort immediately if max depth was exceeded
+- xpath: Only report the first error
+- error: Don't move past current position
+- error: Limit number of parser errors
+- parser: Lower entity nesting limit with XML_PARSE_HUGE
+- parser: Don't increase depth twice when parsing internal entities
+- parser: Improve detection of entity loops
+- parser: Only report a single entity error
+- libxml.h: Remove dubious definition of LIBXML_STATIC
+- html: Improve parsing of nested lists
+- memory: Don't use locks in xmlMemUsed
+- encoding: Remove unused variable xmlDefaultCharEncodingHandler
+- Rework initialization code
+- Add .editorconfig
+- parser: Merge misc, prolog and epilog cases in push parser
+- parser: Fix 'consumed' accounting when switching encodings
+- html: Fix check for end of comment in push parser
+- parser: Fix push parser with 1-3 byte initial chunk
+- parser: Rewrite push parser boundary checks
+- reader: Switch to xmlParserInputBufferCreateMem
+- html: Don't escape ASCII chars in href attributes
+- io: Don't shrink memory input buffers
+- parser: Don't call xmlSHRINK from push parser
+- parser: Ignore cdata argument in xmlParseCharData
+- parser: Rework push parser parser progress checks
+- io: Fix a few integer overflows in I/O statistics
+- io: Rework xmlParserInputBufferGrow with encodings
+- io: Remove xmlInputReadCallbackNop
+- io: Check for memory buffer early in xmlParserInputGrow
+- parser: Fix error message in xmlParseCommentComplex
+- Bypass proxy in nanoHTTP for hosts in "no_proxy" (Markus Jörg)
+- schemas: Fix infinite loop in xmlSchemaCheckElemSubstGroup
+- threads: Remove check for pthread_equal
+- xinclude: Rework XInclude cache
+- xinclude: Remove inefficient refcounting scheme
+- xmllint: Improve handling of empty XPath node sets
+- parser: Fix potential memory leak in xmlParseAttValueInternal
+- error: Don't use initGenericErrorDefaultFunc
+- xpath: Lower XPath recursion limit on Windows
+- Stop including sys/types.h
+- Don't define WIN32 macro
+- Make xmlNewSAXParserCtx take a const sax handler
+- Consolidate private header files
+- Remove internal macros from parserInternals.h
+- Move some HTML functions to correct header file
+- xmllint: Stop calling xmlSAXDefaultVersion
+- Introduce xmlNewSAXParserCtxt and htmlNewSAXParserCtxt
+- Don't mess with parser options in htmlParseDocument
+- Remove useless call to htmlDefaultSAXHandlerInit
+- Remove htmlDefaultSAXHandler from non-SAX1 build
+- Don't initialize SAX handler in htmlReadMemory
+- Fix htmlReadMemory mixing up XML and HTML functions
+- Don't use default SAX handler to report unrelated errors
+- Create stream with buffer in xmlNewStringInputStream
+- xmlcatalog: Fix memory leaks
+
+### Code quality
+
+- xzlib: Fix implicit sign change in xz_open
+- parser: Simplify calculation of available buffer space
+- parser: Use size_t when subtracting input buffer pointers
+- parser: Check for integer overflow when updating checkIndex
+- xpath: Fix harmless integer overflow in xmlXPathTranslateFunction
+- schematron: Use logical and
+- relaxng: Remove useless if statement
+- schemas: Remove useless if statement
+- pattern: Merge identical branches
+- regexp: Add sanity check in xmlRegCalloc2
+- regexp: Simplify xmlRegAtomPush
+- encoding: Cast toupper argument to unsigned char
+- uri: Add explicit cast in xmlSaveUri
+- buf: Fix return value of xmlBufGetInputBase
+- parser: Fix integer overflow of input ID
+- parser: Remove useless ent->etype test in xmlParseReference
+- parser: Remove useless ent->children tests in xmlParseReference
+- xmlmemory.c: Remove xmlMemContentShow
+- libxml.h: Add comments and indentation
+- libxml.h: Don't include stdio.h
+- xmlexports.h: Disable docs for internal macro XMLPUBLIC
+- parser: Simplify xmlParseConditionalSections
+- io: Rearrange code in xmlSwitchInputEncodingInt
+- warnings: Fix -Wstrict-prototypes warning
+- warnings: Remove set-but-unused variables
+- Fix compiler warnings in SAX2.c
+- Fix unused variable warning in python/types.c
+- Fix compiler warning in examples
+- Fix compiler warnings in fuzzing code
+- Remove unused code in nanohttp.c
+- Remove or annotate char casts
+- Don't use sizeof(xmlChar) or sizeof(char)
+- Remove explicit integer casts
+
+### Deprecations
+
+- parser: Deprecate more internal functions
+- parser: Deprecate some parser input functions
+- parser: Deprecate xmlString*DecodeEntities
+- threads: Deprecate some internal functions
+- buf: Deprecate static/immutable buffers
+- Deprecate internal parser functions
+- Deprecate old HTML SAX API
+- Generate deprecation warnings for old SAX API
+- Mark more functions setting globals as deprecated
+- Mark more parser functions as deprecated
+- Mark most SAX1 functions as deprecated
+- Deprecate some global variables
+
+### Portability
+
+- autoconf: Warn about outdated C compilers
+- win32: Remove broken libxml2.def.src
+- Remove symbols from version script
+- catalog.c: Silence a cast warning on VS 2022 (Lukáš Tyrychtr)
+- libxml.h: Remove ancient LynxOS setup
+- Use python3 not python (Ross Burton)
+- xstc/fixup-tests.py: port to Python 3 (Ross Burton)
+- xstc/fixup-tests.py: unify whitespace (Ross Burton)
+- Remove hacky heuristic from b2dc5675 (Alex Richardson)
+- Avoid creating an out-of-bounds pointer by rewriting a check
+  (Alex Richardson)
+- Hide internal functions
+- Correctly relocate internal pointers after realloc() (Alex Richardson)
+- Visual Studio builds: Allow silencing deprecation warnings (Chun-wei Fan)
+- Visual Studio: Define XML_DEPRECATED (Chun-wei Fan)
+- xmllint: Include <io.h> on Windows
+- warnings: Work around MSVC bug
+- sources: Silence C4013 warnings on Visual Studio (Chun-wei Fan)
+- python/setup.py.in: Improve Windows import patching (Chun-wei Fan)
+- python: Create .pyd on Windows
+- Fix Python build on Windows
+- Fix Windows compiler warnings in python/types.c
+- Fix libxml_PyFileGet
+- Remove BeOS support
+- Fix libxml_PyFileGet with stdout on macOS
+- Migrate from PyEval_ to PyObject_
+- Port build_glob.py to Python 3
+- Port genChRanges.py to Python 3
+- xmlexports.h: Remove LIBXML_FASTCALL optimization
+- Remove XMLCALL and XMLCDECL macros from public headers
+- Remove XMLDECL macro from .c files
+
+### Build systems
+
+- cmake: Link against `dl` and `dld` only when `LIBXML2_WITH_MODULES` is
+  enabled (Alexander Kutelev)
+- autotools: Fix make distcheck
+- Remove RPM build, Makefile.tests, README.tests
+- libxml.m4: deprecate AM_PATH_XML2, wrap PKG_CHECK_MODULES instead
+  (Ross Burton)
+- libxml.m4: fix -Wstrict-prototypes (Sam James)
+- cmake: Build static library with -DLIBXML_STATIC
+- autotools: Don't use version script on Windows
+- autotools: Fix winsock detection
+- autotools: Only add network libraries if HTTP/FTP enabled
+- autotools: Disable parallel Python build
+- python: Don't output missing generators during build
+- build: Remove check for broken ss_family
+- http: Simplify IPv6 checks
+- autotools: Fix network checks on Windows
+- Fix detection of GNU libiconv
+- cmake: Fix Python installation
+- cmake: Don't check for Python 2
+- configure.ac: Also check for MSYS host
+- Improve network library detection
+- Detect ws2_32 with AC_SEARCH_LIBS
+- Rework network configure checks
+- Remove arg cast configure checks
+- Fix dlopen check
+- Remove HAVE_WIN32_THREADS configuration flag
+- Rework dlopen and pthread detection
+- Fix test in configure.ac
+- cmake: Enable GCC compiler warnings
+- Always link with -no-undefined
+- Use AM_CFLAGS and AM_LDFLAGS consistently
+- Remove -Wredundant-decls
+- Call AC_CHECK_* with multiple arguments
+- configure.ac: Remove checks for unused programs
+- Rework library detection in configure.ac
+- Rearrange configure.ac
+- Consolidate zlib and lzma detection
+- Remove "runtime debugging"
+- Consolidate simple API modules in configure.ac
+- Fix dependency resolution in configure.ac
+- Fix --with-valid --without-regexps build
+- Fix --with-schemas --without-xpath build
+- Don't build unneeded .c source files
+- Move xmlIsXHTML to tree.c
+- Cleanup distribution settings in Makefile.am
+- Also clean *.pyc files for Python 2
+- Don't distribute libxml2.spec
+
+### Tests
+
+- testchar: Add test for memory pull parser with encoding
+- fuzz: Also test init function of URI fuzzer
+- fuzz: Separate fuzzer for DTD validation
+- gitlab-ci: Enable all "integer" sanitizers
+- fuzz: Inject random malloc failures
+- fuzz: Support variable integer sizes in fuzz data
+- fuzz: Fix duplicate detection in fuzzEntityRecorder
+- fuzz: Set filename in xmlFuzzEntityLoader
+- fuzz: Allow xmlFuzzReadString(NULL)
+- fuzz: Fix Makefile dependencies
+- fuzz: Add test/recurse to seed corpus
+- fuzz: Add separate XInclude fuzzer
+- runsuite: Some errors are expected
+- testrecurse: Test entity expansion stats
+- testapi.c: Initialize catalog early
+- gentest.py: Fix memory leak in API tests
+- tests: Enable "runsuite" test
+- python/tests/reader2: use absolute paths everywhere (Ross Burton)
+- python/tests/reader2: always exit(1) if a test fails (Ross Burton)
+- testModule: exit if the module can't be opened (Ross Burton)
+- CI: disable modules in gcc:static build (Ross Burton)
+- CI: fix CI on MinGW builds (Ross Burton)
+- python: Fix memory leak checks
+- tests: Check that xmlInitParser doesn't allocate memory
+- tests: Fix use-after-free in Python tests
+- tests: Remove unneeded #includes
+- gitlab-ci: Make Test-Msvc exit if ctest fails
+- gitlab-ci: Treat compiler warnings as errors on MSVC
+- test: Add test for push parser boundaries
+- gitlab-ci: Upgrade image to Ubuntu 22.10, reenable MSan
+- gitlab-ci: Reenable LeakSanitizer
+- gitlab-ci: Fix llvm-symbolizer
+- xinclude: Don't create result doc for test with errors
+- xinclude: Also test error messages
+- gitlab-ci: Allow cast-align warnings from clang
+- gitlab-ci: Fix tar invocation
+- gitlab-ci: Move MSVC test to separate script
+- gitlab-ci: Fix SUFFIX, remove MINGW_PATH
+- gitlab-ci: Consolidate CMake test scripts
+- gitlab-ci: Only install MinGW autotools if needed
+- gitlab-ci: Only install cmake MinGW package if needed
+- gitlab-ci: Install 7-Zip using the .msi
+- Use $MSYSTEM and 'bash -lc' in MinGW CI
+- Add CI job for MinGW/Autotools
+- Consolidate CI scripts
+- Allow empty MINGW_PACKAGE_PREFIX
+- Move Dockerfile to .gitlab-ci directory
+- testapi: Disable on Windows for now
+- Disable fuzzer tests if glob.h wasn't found
+- Move automata test to runtest.c
+- Fix testapi when building --without-sax1
+
+# Documentation
+
+- doc: Remove ancient files
+- Remove ancient TODOs
+- html: Fix htmlInitAutoClose documentation
+- doc: Mention new location of XML catalog as breaking change
+- doc: Mention potentially breaking changes in NEWS
+- doc: Remove xmlDllMain from documentation and version script
+- doc: Mention ${sysconfdir} in man pages
+- doc: Document xmlcatalog --convert
+- doc: Document xmllint --nodict and --pedantic
+- doc: Fix indentation in source XML files
+- xmllint: Document --quiet option
+- Improve cross-references in API docs
+- Improve documentation of globals
+- Fix documentation parser
+- Support comments for global variables in documentation
+- Fix update call in apibuild.py
+- Don't index anything in DOC_DISABLE sections
+- Fix warnings from apibuild.py
+- Start with documentation for maintainers
+
+
+v2.10.4: Apr 11 2023
+
+### Security
+
+- [CVE-2023-29469] Hashing of empty dict strings isn't deterministic
+- [CVE-2023-28484] Fix null deref in xmlSchemaFixupComplexType
+- schemas: Fix null-pointer-deref in xmlSchemaCheckCOSSTDerivedOK
+
+### Regressions
+
+- SAX2: Ignore namespaces in HTML documents
+- io: Fix "buffer full" error with certain buffer sizes
+
+
+v2.10.3: Oct 14 2022
+
+### Security
+
+- [CVE-2022-40304] Fix dict corruption caused by entity reference cycles
+- [CVE-2022-40303] Fix integer overflows with XML_PARSE_HUGE
+- Fix overflow check in SAX2.c
+
+### Portability
+
+- win32: Fix build with VS2013
+
+### Build system
+
+- cmake: Set SOVERSION
+
+
 v2.10.2: Aug 29 2022
 
 ### Improvements
@@ -43,6 +753,47 @@ v2.10.1: Aug 25 2022
 
 v2.10.0: Aug 17 2022
 
+### Breaking changes
+
+The Docbook parser module and all related symbols habe been removed completely.
+This was experimental code which never worked and generated a deprecation
+warning for 15+ years. The library's soname wasn't changed in order to allow
+seamless upgrades to later versions. If this concerns you, consider bumping
+soname yourself.
+
+Some other modules are now disabled by default and will eventually be removed
+completely:
+
+- Support for XPointer locations (ranges and points): This was based on
+  a W3C specification which never got beyond Working Draft status. To my
+  knowledge, there's no software supporting this spec which is still
+  maintained. You now have to enable this code by passing the
+  `--with-xptr-locs` configuration option. Be warned that this part of
+  the code base is buggy and had many security issues in the past.
+
+- Support for the built-in FTP client (`--with-ftp`).
+
+- Support for "legacy" functions (`--with-legacy`).
+
+If you're concerned about ABI stability and haven't disabled these modules
+already, add the following configuration options or bump soname yourself:
+
+    --with-ftp
+    --with-legacy
+    --with-xptr-locs
+
+Several functions of the public API were deprecated. Most of them should be
+completely unused and will generate a deprecation warning now.
+
+The autoconf build now uses the sysconfdir variable for the location of
+the default catalog file. The path changed from hardcoded /etc/xml/catalog
+to ${sysconfdir}/xml/catalog. The sysconfdir variable defaults to
+${prefix}/etc, prefix defaults to /usr/local, so without other options
+the path becomes /usr/local/etc/xml/catalog. If you want the old behavior,
+configure with
+
+    --sysconfdir=/etc
+
 ### Security
 
 - [CVE-2022-2309] Reset nsNr in xmlCtxtReset
index ad423e6..e9a5c78 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,15 +3,17 @@
 libxml2 is an XML toolkit implemented in C, originally developed for
 the GNOME Project.
 
-Full documentation is available at
-<https://gitlab.gnome.org/GNOME/libxml2/-/wikis>.
+Official releases can be downloaded from
+<https://download.gnome.org/sources/libxml2/>
+
+The git repository is hosted on GNOME's GitLab server:
+<https://gitlab.gnome.org/GNOME/libxml2>
 
 Bugs should be reported at
-<https://gitlab.gnome.org/GNOME/libxml2/-/issues>.
+<https://gitlab.gnome.org/GNOME/libxml2/-/issues>
 
-A mailing list xml@gnome.org is available. You can subscribe at
-<https://mail.gnome.org/mailman/listinfo/xml>. The list archive is at
-<https://mail.gnome.org/archives/xml/>.
+Documentation is available at
+<https://gitlab.gnome.org/GNOME/libxml2/-/wikis>
 
 ## License
 
@@ -27,23 +29,58 @@ systems in platform-specific subdirectories.
 If you build from a Git tree, you have to install Autotools and start
 by generating the configuration files with:
 
-    ./autogen.sh
+    ./autogen.sh [configuration options]
 
 If you build from a source tarball, extract the archive with:
 
     tar xf libxml2-xxx.tar.gz
     cd libxml2-xxx
 
-To see a list of build options:
-
-    ./configure --help
+Then you can configure and build the library:
 
-Also see the INSTALL file for additional instructions. Then you can
-configure and build the library:
-
-    ./configure [possible options]
+    ./configure [configuration options]
     make
 
+The following options disable or enable code modules and relevant symbols:
+
+    --with-c14n             Canonical XML 1.0 support (on)
+    --with-catalog          XML Catalogs support (on)
+    --with-debug            debugging module and shell (on)
+    --with-history          history support for shell (off)
+    --with-readline[=DIR]   use readline in DIR (for shell history)
+    --with-html             HTML parser (on)
+    --with-http             HTTP support (on)
+    --with-iconv[=DIR]      iconv support (on)
+    --with-icu              ICU support (off)
+    --with-iso8859x         ISO-8859-X support if no iconv (on)
+    --with-lzma[=DIR]       use liblzma in DIR (on)
+    --with-mem-debug        memory debugging module (off)
+    --with-modules          dynamic modules support (on)
+    --with-output           serialization support (on)
+    --with-pattern          xmlPattern selection interface (on)
+    --with-push             push parser interfaces (on)
+    --with-python           Python bindings (on)
+    --with-reader           xmlReader parsing interface (on)
+    --with-regexps          regular expressions support (on)
+    --with-run-debug        runtime debugging module (off)
+    --with-sax1             older SAX1 interface (on)
+    --with-schemas          XML Schemas 1.0 and RELAX NG support (on)
+    --with-schematron       Schematron support (on)
+    --with-threads          multithreading support (on)
+    --with-thread-alloc     per-thread malloc hooks (off)
+    --with-tree             DOM like tree manipulation APIs (on)
+    --with-valid            DTD validation support (on)
+    --with-writer           xmlWriter serialization interface (on)
+    --with-xinclude         XInclude 1.0 support (on)
+    --with-xpath            XPath 1.0 support (on)
+    --with-xptr             XPointer support (on)
+    --with-zlib[=DIR]       use libz in DIR (on)
+
+Other options:
+
+    --with-minimum          build a minimally sized library (off)
+    --with-legacy           maximum ABI compatibility (off)
+
 Note that by default, no optimization options are used. You have to
 enable them manually, for example with:
 
diff --git a/README.tests b/README.tests
deleted file mode 100644 (file)
index 8d86f2a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-                       README.tests
-
-   Instructions for standalone test regressions of libxml2
-
-libxml2-tests-$version.tar.gz contains 3 standalone C programs as well
-as a large amount of tests and results coming from libxml2 itself and
-from W3C, NIST, Sun Microsystems, Microsoft and James Clark. Each C
-program has a different testing purpose:
-
-  runtest.c : runs libxml2 basic internal regression tests
-  runsuite.c: runs libxml2 against external regression tests
-  testapi.c : exercises the library public entry points
-  testchar.c: exercise the check of character ranges and UTF-8 validation
-
-The command:
-
-  make check
-or
-  make -f Makefile.tests check
-
-should be sufficient on an Unix system to build and exercise the tests
-for the version of the library installed on the system. Note however
-that there isn't backward compatibility provided so if the installed
-version is older than the testsuite one, failing to compile or run the tests
-is likely. In any event this won't work with an installed libxml2 older
-than 2.6.20.
-
-Building on other platforms should be a matter of compiling the C files
-like any other program using libxml2, running the test should be done
-simply by launching the resulting executables.
-
-Also note the availability of a "make valgrind" target which will run the
-above tests under valgrind to check for memory errors (but this relies
-on the availability of the valgrind command and take far more time to
-complete).
-
-Daniel Veillard
-Mon May  7 2012
-
diff --git a/SAX.c b/SAX.c
index d8e972b..7f2f297 100644 (file)
--- a/SAX.c
+++ b/SAX.c
@@ -25,7 +25,6 @@
 #include <libxml/uri.h>
 #include <libxml/valid.h>
 #include <libxml/HTMLtree.h>
-#include <libxml/globals.h>
 #include <libxml/SAX2.h>
 
 #ifdef LIBXML_LEGACY_ENABLED
diff --git a/SAX2.c b/SAX2.c
index ec89046..ed21a55 100644 (file)
--- a/SAX2.c
+++ b/SAX2.c
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <limits.h>
 #include <stddef.h>
+#include <libxml/SAX2.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/xmlerror.h>
 #include <libxml/debugXML.h>
 #include <libxml/xmlIO.h>
-#include <libxml/SAX.h>
 #include <libxml/uri.h>
 #include <libxml/valid.h>
 #include <libxml/HTMLtree.h>
-#include <libxml/globals.h>
 
-/* Define SIZE_T_MAX unless defined through <limits.h>. */
-#ifndef SIZE_T_MAX
-# define SIZE_T_MAX     ((size_t)-1)
-#endif /* !SIZE_T_MAX */
-
-/* #define DEBUG_SAX2 */
-/* #define DEBUG_SAX2_TREE */
+#include "private/error.h"
+#include "private/parser.h"
+#include "private/tree.h"
 
 /**
  * TODO:
@@ -332,11 +327,6 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlDtdPtr dtd;
     if (ctx == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2InternalSubset(%s, %s, %s)\n",
-            name, ExternalID, SystemID);
-#endif
 
     if (ctxt->myDoc == NULL)
        return;
@@ -369,11 +359,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     if (ctx == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2ExternalSubset(%s, %s, %s)\n",
-            name, ExternalID, SystemID);
-#endif
     if (((ExternalID != NULL) || (SystemID != NULL)) &&
         (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
         (ctxt->wellFormed && ctxt->myDoc))) {
@@ -385,9 +370,10 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        int oldinputMax;
        xmlParserInputPtr *oldinputTab;
        xmlParserInputPtr input = NULL;
-       xmlCharEncoding enc;
-       int oldcharset;
        const xmlChar *oldencoding;
+       int oldprogressive;
+        unsigned long consumed;
+        size_t buffered;
 
        /*
         * Ask the Entity resolver to load the damn thing
@@ -408,20 +394,22 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        oldinputNr = ctxt->inputNr;
        oldinputMax = ctxt->inputMax;
        oldinputTab = ctxt->inputTab;
-       oldcharset = ctxt->charset;
        oldencoding = ctxt->encoding;
+        oldprogressive = ctxt->progressive;
        ctxt->encoding = NULL;
+        ctxt->progressive = 0;
 
        ctxt->inputTab = (xmlParserInputPtr *)
                         xmlMalloc(5 * sizeof(xmlParserInputPtr));
        if (ctxt->inputTab == NULL) {
            xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
+            xmlFreeInputStream(input);
            ctxt->input = oldinput;
            ctxt->inputNr = oldinputNr;
            ctxt->inputMax = oldinputMax;
            ctxt->inputTab = oldinputTab;
-           ctxt->charset = oldcharset;
            ctxt->encoding = oldencoding;
+            ctxt->progressive = oldprogressive;
            return;
        }
        ctxt->inputNr = 0;
@@ -429,14 +417,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        ctxt->input = NULL;
        xmlPushInput(ctxt, input);
 
-       /*
-        * On the fly encoding conversion if needed
-        */
-       if (ctxt->input->length >= 4) {
-           enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
-           xmlSwitchEncoding(ctxt, enc);
-       }
-
        if (input->filename == NULL)
            input->filename = (char *) xmlCanonicPath(SystemID);
        input->line = 1;
@@ -456,6 +436,18 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
 
        while (ctxt->inputNr > 1)
            xmlPopInput(ctxt);
+
+        consumed = ctxt->input->consumed;
+        buffered = ctxt->input->cur - ctxt->input->base;
+        if (buffered > ULONG_MAX - consumed)
+            consumed = ULONG_MAX;
+        else
+            consumed += buffered;
+        if (consumed > ULONG_MAX - ctxt->sizeentities)
+            ctxt->sizeentities = ULONG_MAX;
+        else
+            ctxt->sizeentities += consumed;
+
        xmlFreeInputStream(ctxt->input);
         xmlFree(ctxt->inputTab);
 
@@ -466,12 +458,12 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        ctxt->inputNr = oldinputNr;
        ctxt->inputMax = oldinputMax;
        ctxt->inputTab = oldinputTab;
-       ctxt->charset = oldcharset;
        if ((ctxt->encoding != NULL) &&
            ((ctxt->dict == NULL) ||
             (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
            xmlFree((xmlChar *) ctxt->encoding);
        ctxt->encoding = oldencoding;
+        ctxt->progressive = oldprogressive;
        /* ctxt->wellFormed = oldwellFormed; */
     }
 }
@@ -506,11 +498,6 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
 
     URI = xmlBuildURI(systemId, (const xmlChar *) base);
 
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2ResolveEntity(%s, %s)\n", publicId, systemId);
-#endif
-
     ret = xmlLoadExternalEntity((const char *) URI,
                                (const char *) publicId, ctxt);
     if (URI != NULL)
@@ -534,10 +521,6 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
     xmlEntityPtr ret = NULL;
 
     if (ctx == NULL) return(NULL);
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2GetEntity(%s)\n", name);
-#endif
 
     if (ctxt->inSubset == 0) {
        ret = xmlGetPredefinedEntity(name);
@@ -584,10 +567,6 @@ xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
     xmlEntityPtr ret;
 
     if (ctx == NULL) return(NULL);
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2GetParameterEntity(%s)\n", name);
-#endif
 
     ret = xmlGetParameterEntity(ctxt->myDoc, name);
     return(ret);
@@ -613,11 +592,6 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
 
     if (ctx == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2EntityDecl(%s, %d, %s, %s, %s)\n",
-            name, type, publicId, systemId, content);
-#endif
     if (ctxt->inSubset == 1) {
        ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
                              systemId, content);
@@ -690,11 +664,6 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
     if ((ctxt == NULL) || (ctxt->myDoc == NULL))
         return;
 
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2AttributeDecl(%s, %s, %d, %d, %s, ...)\n",
-            elem, fullname, type, def, defaultValue);
-#endif
     if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) &&
         (type != XML_ATTRIBUTE_ID)) {
        /*
@@ -760,11 +729,6 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
     if ((ctxt == NULL) || (ctxt->myDoc == NULL))
         return;
 
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-                    "SAX.xmlSAX2ElementDecl(%s, %d, ...)\n", name, type);
-#endif
-
     if (ctxt->inSubset == 1)
         elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
                                  name, (xmlElementTypeVal) type, content);
@@ -809,11 +773,6 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
     if ((ctxt == NULL) || (ctxt->myDoc == NULL))
         return;
 
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2NotationDecl(%s, %s, %s)\n", name, publicId, systemId);
-#endif
-
     if ((publicId == NULL) && (systemId == NULL)) {
        xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
             "SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n",
@@ -858,11 +817,6 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
     xmlEntityPtr ent;
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     if (ctx == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2UnparsedEntityDecl(%s, %s, %s, %s)\n",
-            name, publicId, systemId, notationName);
-#endif
     if (ctxt->inSubset == 1) {
        ent = xmlAddDocEntity(ctxt->myDoc, name,
                        XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,
@@ -921,11 +875,6 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
 void
 xmlSAX2SetDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
 {
-    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2SetDocumentLocator()\n");
-#endif
 }
 
 /**
@@ -942,10 +891,6 @@ xmlSAX2StartDocument(void *ctx)
 
     if (ctx == NULL) return;
 
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2StartDocument()\n");
-#endif
     if (ctxt->html) {
 #ifdef LIBXML_HTML_ENABLED
        if (ctxt->myDoc == NULL)
@@ -971,10 +916,6 @@ xmlSAX2StartDocument(void *ctx)
            if (ctxt->options & XML_PARSE_OLD10)
                doc->properties |= XML_DOC_OLD10;
            doc->parseFlags = ctxt->options;
-           if (ctxt->encoding != NULL)
-               doc->encoding = xmlStrdup(ctxt->encoding);
-           else
-               doc->encoding = NULL;
            doc->standalone = ctxt->standalone;
        } else {
            xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
@@ -1003,10 +944,8 @@ void
 xmlSAX2EndDocument(void *ctx)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2EndDocument()\n");
-#endif
+    xmlDocPtr doc;
+
     if (ctx == NULL) return;
 #ifdef LIBXML_VALID_ENABLED
     if (ctxt->validate && ctxt->wellFormed &&
@@ -1014,23 +953,25 @@ xmlSAX2EndDocument(void *ctx)
        ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
 #endif /* LIBXML_VALID_ENABLED */
 
-    /*
-     * Grab the encoding if it was added on-the-fly
-     */
-    if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
-       (ctxt->myDoc->encoding == NULL)) {
-       ctxt->myDoc->encoding = ctxt->encoding;
-       ctxt->encoding = NULL;
-    }
-    if ((ctxt->inputTab != NULL) &&
-        (ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) &&
-        (ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
-       (ctxt->myDoc->encoding == NULL)) {
-       ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
-    }
-    if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
-       (ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
-       ctxt->myDoc->charset = ctxt->charset;
+    doc = ctxt->myDoc;
+    if ((doc != NULL) && (doc->encoding == NULL)) {
+        const xmlChar *encoding = NULL;
+
+        if ((ctxt->input->flags & XML_INPUT_USES_ENC_DECL) ||
+            (ctxt->input->flags & XML_INPUT_AUTO_ENCODING)) {
+            /* Preserve encoding exactly */
+            encoding = ctxt->encoding;
+        } else if ((ctxt->input->buf) && (ctxt->input->buf->encoder)) {
+            encoding = BAD_CAST ctxt->input->buf->encoder->name;
+        } else if (ctxt->input->flags & XML_INPUT_HAS_ENCODING) {
+            encoding = BAD_CAST "UTF-8";
+        }
+
+        if (encoding != NULL) {
+            doc->encoding = xmlStrdup(encoding);
+            if (doc->encoding == NULL)
+                xmlSAX2ErrMemory(ctxt, "xmlSAX2EndDocument");
+        }
     }
 }
 
@@ -1316,25 +1257,25 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
 
     /* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
     ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL);
+    if (ret == NULL)
+        goto error;
 
-    if (ret != NULL) {
-        if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
-           xmlNodePtr tmp;
-
-           ret->children = xmlStringGetNodeList(ctxt->myDoc, value);
-           tmp = ret->children;
-           while (tmp != NULL) {
-               tmp->parent = (xmlNodePtr) ret;
-               if (tmp->next == NULL)
-                   ret->last = tmp;
-               tmp = tmp->next;
-           }
-       } else if (value != NULL) {
-           ret->children = xmlNewDocText(ctxt->myDoc, value);
-           ret->last = ret->children;
-           if (ret->children != NULL)
-               ret->children->parent = (xmlNodePtr) ret;
-       }
+    if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
+        xmlNodePtr tmp;
+
+        ret->children = xmlStringGetNodeList(ctxt->myDoc, value);
+        tmp = ret->children;
+        while (tmp != NULL) {
+            tmp->parent = (xmlNodePtr) ret;
+            if (tmp->next == NULL)
+                ret->last = tmp;
+            tmp = tmp->next;
+        }
+    } else if (value != NULL) {
+        ret->children = xmlNewDocText(ctxt->myDoc, value);
+        ret->last = ret->children;
+        if (ret->children != NULL)
+            ret->children->parent = (xmlNodePtr) ret;
     }
 
 #ifdef LIBXML_VALID_ENABLED
@@ -1593,11 +1534,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
     int i;
 
     if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return;
-    parent = ctxt->node;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2StartElement(%s)\n", fullname);
-#endif
 
     /*
      * First check on validity:
@@ -1613,12 +1549,15 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
        ctxt->validate = 0;
     }
 
-
-    /*
-     * Split the full name into a namespace prefix and the tag name
-     */
-    name = xmlSplitQName(ctxt, fullname, &prefix);
-
+    if (ctxt->html) {
+        prefix = NULL;
+        name = xmlStrdup(fullname);
+    } else {
+        /*
+         * Split the full name into a namespace prefix and the tag name
+         */
+        name = xmlSplitQName(ctxt, fullname, &prefix);
+    }
 
     /*
      * Note : the namespace resolution is deferred until the end of the
@@ -1632,30 +1571,24 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
        xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
         return;
     }
-    if (ctxt->myDoc->children == NULL) {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name);
-#endif
-        xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
-    } else if (parent == NULL) {
-        parent = ctxt->myDoc->children;
-    }
     ctxt->nodemem = -1;
     if (ctxt->linenumbers) {
        if (ctxt->input != NULL) {
-           if (ctxt->input->line < USHRT_MAX)
-               ret->line = (unsigned short) ctxt->input->line;
+           if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
+               ret->line = ctxt->input->line;
            else
                ret->line = USHRT_MAX;
        }
     }
 
+    /* Initialize parent before pushing node */
+    parent = ctxt->node;
+    if (parent == NULL)
+        parent = (xmlNodePtr) ctxt->myDoc;
+
     /*
      * We are parsing a new node.
      */
-#ifdef DEBUG_SAX_TREE
-    xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
-#endif
     if (nodePush(ctxt, ret) < 0) {
         xmlUnlinkNode(ret);
         xmlFreeNode(ret);
@@ -1667,22 +1600,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
     /*
      * Link the child element
      */
-    if (parent != NULL) {
-        if (parent->type == XML_ELEMENT_NODE) {
-#ifdef DEBUG_SAX_TREE
-           xmlGenericError(xmlGenericErrorContext,
-                   "adding child %s to %s\n", name, parent->name);
-#endif
-           xmlAddChild(parent, ret);
-       } else {
-#ifdef DEBUG_SAX_TREE
-           xmlGenericError(xmlGenericErrorContext,
-                   "adding sibling %s to ", name);
-           xmlDebugDumpOneNode(stderr, parent, 0);
-#endif
-           xmlAddSibling(parent, ret);
-       }
-    }
+    xmlAddChild(parent, ret);
 
     if (!ctxt->html) {
         /*
@@ -1797,40 +1715,22 @@ void
 xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-    xmlNodePtr cur;
 
     if (ctx == NULL) return;
-    cur = ctxt->node;
-#ifdef DEBUG_SAX
-    if (name == NULL)
-        xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(NULL)\n");
-    else
-       xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name);
-#endif
 
-    /* Capture end position and add node */
-    if (cur != NULL && ctxt->record_info) {
-      ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;
-      ctxt->nodeInfo->end_line = ctxt->input->line;
-      ctxt->nodeInfo->node = cur;
-      xmlParserAddNodeInfo(ctxt, ctxt->nodeInfo);
-    }
     ctxt->nodemem = -1;
 
 #ifdef LIBXML_VALID_ENABLED
     if (ctxt->validate && ctxt->wellFormed &&
         ctxt->myDoc && ctxt->myDoc->intSubset)
         ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
-                                            cur);
+                                            ctxt->node);
 #endif /* LIBXML_VALID_ENABLED */
 
 
     /*
      * end of parsing of this node.
      */
-#ifdef DEBUG_SAX_TREE
-    xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name);
-#endif
     nodePop(ctxt);
 }
 #endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLED || LIBXML_LEGACY_ENABLED */
@@ -1906,18 +1806,6 @@ skip:
     } else
        ret->content = (xmlChar *) intern;
 
-    if (ctxt->linenumbers) {
-       if (ctxt->input != NULL) {
-           if (ctxt->input->line < USHRT_MAX)
-               ret->line = (unsigned short) ctxt->input->line;
-           else {
-               ret->line = USHRT_MAX;
-               if (ctxt->options & XML_PARSE_BIG_LINES)
-                   ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
-           }
-       }
-    }
-
     if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
        xmlRegisterNodeDefaultValue(ret);
     return(ret);
@@ -1967,8 +1855,10 @@ decode:
  * The default handling is to convert the attribute into an
  * DOM subtree and past it in a new xmlAttr element added to
  * the element.
+ *
+ * Returns the new attribute or NULL in case of error.
  */
-static void
+static xmlAttrPtr
 xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
                    const xmlChar * localname,
                    const xmlChar * prefix,
@@ -1982,8 +1872,12 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
     /*
      * Note: if prefix == NULL, the attribute is not in the default namespace
      */
-    if (prefix != NULL)
-       namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
+    if (prefix != NULL) {
+       namespace = xmlParserNsLookupSax(ctxt, prefix);
+       if ((namespace == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
+           namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
+       }
+    }
 
     /*
      * allocate the node
@@ -1992,42 +1886,37 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
         ret = ctxt->freeAttrs;
        ctxt->freeAttrs = ret->next;
        ctxt->freeAttrsNr--;
-       memset(ret, 0, sizeof(xmlAttr));
-       ret->type = XML_ATTRIBUTE_NODE;
+    } else {
+        ret = xmlMalloc(sizeof(*ret));
+        if (ret == NULL) {
+            xmlSAX2ErrMemory(ctxt, NULL);
+            return(NULL);
+        }
+    }
 
-       ret->parent = ctxt->node;
-       ret->doc = ctxt->myDoc;
-       ret->ns = namespace;
+    memset(ret, 0, sizeof(xmlAttr));
+    ret->type = XML_ATTRIBUTE_NODE;
 
-       if (ctxt->dictNames)
-           ret->name = localname;
-       else
-           ret->name = xmlStrdup(localname);
+    /*
+     * xmlParseBalancedChunkMemoryRecover had a bug that could result in
+     * a mismatch between ctxt->node->doc and ctxt->myDoc. We use
+     * ctxt->node->doc here, but we should somehow make sure that the
+     * document pointers match.
+     */
 
-        /* link at the end to preserve order, TODO speed up with a last */
-       if (ctxt->node->properties == NULL) {
-           ctxt->node->properties = ret;
-       } else {
-           xmlAttrPtr prev = ctxt->node->properties;
+    /* assert(ctxt->node->doc == ctxt->myDoc); */
 
-           while (prev->next != NULL) prev = prev->next;
-           prev->next = ret;
-           ret->prev = prev;
-       }
+    ret->parent = ctxt->node;
+    ret->doc = ctxt->node->doc;
+    ret->ns = namespace;
 
-       if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
-           xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
-    } else {
-       if (ctxt->dictNames)
-           ret = xmlNewNsPropEatName(ctxt->node, namespace,
-                                     (xmlChar *) localname, NULL);
-       else
-           ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
-       if (ret == NULL) {
-           xmlErrMemory(ctxt, "xmlSAX2AttributeNs");
-           return;
-       }
-    }
+    if (ctxt->dictNames)
+        ret->name = localname;
+    else
+        ret->name = xmlStrdup(localname);
+
+    if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
+        xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
 
     if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
        xmlNodePtr tmp;
@@ -2159,15 +2048,11 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
             *
             * Open issue: normalization of the value.
             */
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
-#ifdef LIBXML_VALID_ENABLED
            if (xmlValidateNCName(content, 1) != 0) {
                xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
                      "xml:id : attribute value %s is not an NCName\n",
                            (const char *) content, NULL);
            }
-#endif
-#endif
            xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
        } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
            xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
@@ -2177,6 +2062,8 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
     }
     if (dup != NULL)
        xmlFree(dup);
+
+    return(ret);
 }
 
 /**
@@ -2216,7 +2103,6 @@ xmlSAX2StartElementNs(void *ctx,
     int i, j;
 
     if (ctx == NULL) return;
-    parent = ctxt->node;
     /*
      * First check on validity:
      */
@@ -2265,6 +2151,7 @@ xmlSAX2StartElementNs(void *ctx,
                ret->name = lname;
            if (ret->name == NULL) {
                xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
+                xmlFree(ret);
                return;
            }
        }
@@ -2286,16 +2173,13 @@ xmlSAX2StartElementNs(void *ctx,
     }
     if (ctxt->linenumbers) {
        if (ctxt->input != NULL) {
-           if (ctxt->input->line < USHRT_MAX)
-               ret->line = (unsigned short) ctxt->input->line;
+           if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
+               ret->line = ctxt->input->line;
            else
                ret->line = USHRT_MAX;
        }
     }
 
-    if (parent == NULL) {
-        xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
-    }
     /*
      * Build the namespace list
      */
@@ -2320,6 +2204,9 @@ xmlSAX2StartElementNs(void *ctx,
              */
            continue;
        }
+
+        xmlParserNsUpdateSax(ctxt, pref, ns);
+
 #ifdef LIBXML_VALID_ENABLED
        if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
            ctxt->myDoc && ctxt->myDoc->intSubset) {
@@ -2330,6 +2217,11 @@ xmlSAX2StartElementNs(void *ctx,
     }
     ctxt->nodemem = -1;
 
+    /* Initialize parent before pushing node */
+    parent = ctxt->node;
+    if (parent == NULL)
+        parent = (xmlNodePtr) ctxt->myDoc;
+
     /*
      * We are parsing a new node.
      */
@@ -2342,13 +2234,7 @@ xmlSAX2StartElementNs(void *ctx,
     /*
      * Link the child element
      */
-    if (parent != NULL) {
-        if (parent->type == XML_ELEMENT_NODE) {
-           xmlAddChild(parent, ret);
-       } else {
-           xmlAddSibling(parent, ret);
-       }
-    }
+    xmlAddChild(parent, ret);
 
     /*
      * Insert the defaulted attributes from the DTD only if requested:
@@ -2362,7 +2248,7 @@ xmlSAX2StartElementNs(void *ctx,
      * Note that, if prefix is NULL, this searches for the default Ns
      */
     if ((URI != NULL) && (ret->ns == NULL)) {
-        ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
+        ret->ns = xmlParserNsLookupSax(ctxt, prefix);
        if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
            ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
        }
@@ -2388,7 +2274,11 @@ xmlSAX2StartElementNs(void *ctx,
      * process all the other attributes
      */
     if (nb_attributes > 0) {
+        xmlAttrPtr prev = NULL;
+
         for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
+            xmlAttrPtr attr = NULL;
+
            /*
             * Handle the rare case of an undefined attribute prefix
             */
@@ -2399,23 +2289,38 @@ xmlSAX2StartElementNs(void *ctx,
                    fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
                                              attributes[j]);
                    if (fullname != NULL) {
-                       xmlSAX2AttributeNs(ctxt, fullname, NULL,
-                                          attributes[j+3], attributes[j+4]);
-                       continue;
+                        attr = xmlSAX2AttributeNs(ctxt, fullname, NULL,
+                                                  attributes[j+3],
+                                                  attributes[j+4]);
+                        goto have_attr;
                    }
                } else {
                    lname = xmlBuildQName(attributes[j], attributes[j+1],
                                          NULL, 0);
                    if (lname != NULL) {
-                       xmlSAX2AttributeNs(ctxt, lname, NULL,
-                                          attributes[j+3], attributes[j+4]);
+                        attr = xmlSAX2AttributeNs(ctxt, lname, NULL,
+                                                  attributes[j+3],
+                                                  attributes[j+4]);
                        xmlFree(lname);
-                       continue;
+                        goto have_attr;
                    }
                }
            }
-           xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
-                              attributes[j+3], attributes[j+4]);
+            attr = xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
+                                      attributes[j+3], attributes[j+4]);
+have_attr:
+            if (attr == NULL)
+                continue;
+
+            /* link at the end to preserve order */
+            if (prev == NULL) {
+                ctxt->node->properties = attr;
+            } else {
+                prev->next = attr;
+                attr->prev = prev;
+            }
+
+            prev = attr;
        }
     }
 
@@ -2456,24 +2361,15 @@ xmlSAX2EndElementNs(void *ctx,
                    const xmlChar * URI ATTRIBUTE_UNUSED)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-    xmlParserNodeInfo node_info;
-    xmlNodePtr cur;
 
     if (ctx == NULL) return;
-    cur = ctxt->node;
-    /* Capture end position and add node */
-    if ((ctxt->record_info) && (cur != NULL)) {
-        node_info.end_pos = ctxt->input->cur - ctxt->input->base;
-        node_info.end_line = ctxt->input->line;
-        node_info.node = cur;
-        xmlParserAddNodeInfo(ctxt, &node_info);
-    }
     ctxt->nodemem = -1;
 
 #ifdef LIBXML_VALID_ENABLED
     if (ctxt->validate && ctxt->wellFormed &&
         ctxt->myDoc && ctxt->myDoc->intSubset)
-        ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, cur);
+        ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
+                                             ctxt->node);
 #endif /* LIBXML_VALID_ENABLED */
 
     /*
@@ -2496,18 +2392,7 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
     xmlNodePtr ret;
 
     if (ctx == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2Reference(%s)\n", name);
-#endif
-    if (name[0] == '#')
-       ret = xmlNewCharRef(ctxt->myDoc, name);
-    else
-       ret = xmlNewReference(ctxt->myDoc, name);
-#ifdef DEBUG_SAX_TREE
-    xmlGenericError(xmlGenericErrorContext,
-           "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
-#endif
+    ret = xmlNewReference(ctxt->myDoc, name);
     if (xmlAddChild(ctxt->node, ret) == NULL) {
         xmlFreeNode(ret);
     }
@@ -2529,10 +2414,6 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
     xmlNodePtr lastChild;
 
     if (ctxt == NULL) return;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len);
-#endif
     /*
      * Handle the data if any. If there is no child
      * add it as content, otherwise if the last child is text,
@@ -2540,17 +2421,9 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
      */
 
     if (ctxt->node == NULL) {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "add chars: ctxt->node == NULL !\n");
-#endif
         return;
     }
     lastChild = ctxt->node->last;
-#ifdef DEBUG_SAX_TREE
-    xmlGenericError(xmlGenericErrorContext,
-           "add chars to %s \n", ctxt->node->name);
-#endif
 
     /*
      * Here we needed an accelerator mechanism in case of very large
@@ -2596,22 +2469,23 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
                xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
                return;
            }
-            if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
+           if (ctxt->nodelen > INT_MAX - len) {
+                xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
+                return;
+           }
+            if ((ctxt->nodelen + len > XML_MAX_TEXT_LENGTH) &&
                 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
                 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
                 return;
             }
-           if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
-               (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
-                xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
-                return;
-           }
            if (ctxt->nodelen + len >= ctxt->nodemem) {
                xmlChar *newbuf;
-               size_t size;
+               int size;
 
-               size = ctxt->nodemem + len;
-               size *= 2;
+               size = ctxt->nodemem > INT_MAX - len ?
+                       INT_MAX :
+                       ctxt->nodemem + len;
+               size = size > INT_MAX / 2 ? INT_MAX : size * 2;
                 newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
                if (newbuf == NULL) {
                    xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
@@ -2635,7 +2509,8 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
            /* Mixed content, first time */
             if (type == XML_TEXT_NODE) {
                 lastChild = xmlSAX2TextNode(ctxt, ch, len);
-                lastChild->doc = ctxt->myDoc;
+                if (lastChild != NULL)
+                    lastChild->doc = ctxt->myDoc;
             } else
                 lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
            if (lastChild != NULL) {
@@ -2647,6 +2522,19 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
            }
        }
     }
+
+    if ((lastChild != NULL) &&
+        (type == XML_TEXT_NODE) &&
+        (ctxt->linenumbers) &&
+        (ctxt->input != NULL)) {
+        if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
+            lastChild->line = ctxt->input->line;
+        else {
+            lastChild->line = USHRT_MAX;
+            if (ctxt->options & XML_PARSE_BIG_LINES)
+                lastChild->psvi = (void *) (ptrdiff_t) ctxt->input->line;
+        }
+    }
 }
 
 /**
@@ -2675,11 +2563,6 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
 void
 xmlSAX2IgnorableWhitespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED)
 {
-    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2IgnorableWhitespace(%.30s, %d)\n", ch, len);
-#endif
 }
 
 /**
@@ -2700,18 +2583,14 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
 
     if (ctx == NULL) return;
     parent = ctxt->node;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext,
-           "SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data);
-#endif
 
     ret = xmlNewDocPI(ctxt->myDoc, target, data);
     if (ret == NULL) return;
 
     if (ctxt->linenumbers) {
        if (ctxt->input != NULL) {
-           if (ctxt->input->line < USHRT_MAX)
-               ret->line = (unsigned short) ctxt->input->line;
+           if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
+               ret->line = ctxt->input->line;
            else
                ret->line = USHRT_MAX;
        }
@@ -2724,25 +2603,12 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
        return;
     }
     if (parent == NULL) {
-#ifdef DEBUG_SAX_TREE
-           xmlGenericError(xmlGenericErrorContext,
-                   "Setting PI %s as root\n", target);
-#endif
         xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
        return;
     }
     if (parent->type == XML_ELEMENT_NODE) {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "adding PI %s child to %s\n", target, parent->name);
-#endif
        xmlAddChild(parent, ret);
     } else {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "adding PI %s sibling to ", target);
-       xmlDebugDumpOneNode(stderr, parent, 0);
-#endif
        xmlAddSibling(parent, ret);
     }
 }
@@ -2763,15 +2629,12 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
 
     if (ctx == NULL) return;
     parent = ctxt->node;
-#ifdef DEBUG_SAX
-    xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Comment(%s)\n", value);
-#endif
     ret = xmlNewDocComment(ctxt->myDoc, value);
     if (ret == NULL) return;
     if (ctxt->linenumbers) {
        if (ctxt->input != NULL) {
-           if (ctxt->input->line < USHRT_MAX)
-               ret->line = (unsigned short) ctxt->input->line;
+           if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
+               ret->line = ctxt->input->line;
            else
                ret->line = USHRT_MAX;
        }
@@ -2785,25 +2648,12 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
        return;
     }
     if (parent == NULL) {
-#ifdef DEBUG_SAX_TREE
-           xmlGenericError(xmlGenericErrorContext,
-                   "Setting xmlSAX2Comment as root\n");
-#endif
         xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
        return;
     }
     if (parent->type == XML_ELEMENT_NODE) {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "adding xmlSAX2Comment child to %s\n", parent->name);
-#endif
        xmlAddChild(parent, ret);
     } else {
-#ifdef DEBUG_SAX_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "adding xmlSAX2Comment sibling to ");
-       xmlDebugDumpOneNode(stderr, parent, 0);
-#endif
        xmlAddSibling(parent, ret);
     }
 }
@@ -2829,6 +2679,8 @@ static int xmlSAX2DefaultVersionValue = 2;
  * xmlSAXDefaultVersion:
  * @version:  the version, 1 or 2
  *
+ * DEPRECATED: Use parser option XML_PARSE_SAX1.
+ *
  * Set the default version of SAX used globally by the library.
  * By default, during initialization the default is set to 2.
  * Note that it is generally a better coding style to use
@@ -2863,20 +2715,23 @@ xmlSAXVersion(xmlSAXHandler *hdlr, int version)
 {
     if (hdlr == NULL) return(-1);
     if (version == 2) {
-       hdlr->startElement = NULL;
-       hdlr->endElement = NULL;
        hdlr->startElementNs = xmlSAX2StartElementNs;
        hdlr->endElementNs = xmlSAX2EndElementNs;
        hdlr->serror = NULL;
        hdlr->initialized = XML_SAX2_MAGIC;
 #ifdef LIBXML_SAX1_ENABLED
     } else if (version == 1) {
-       hdlr->startElement = xmlSAX2StartElement;
-       hdlr->endElement = xmlSAX2EndElement;
        hdlr->initialized = 1;
 #endif /* LIBXML_SAX1_ENABLED */
     } else
         return(-1);
+#ifdef LIBXML_SAX1_ENABLED
+    hdlr->startElement = xmlSAX2StartElement;
+    hdlr->endElement = xmlSAX2EndElement;
+#else
+    hdlr->startElement = NULL;
+    hdlr->endElement = NULL;
+#endif /* LIBXML_SAX1_ENABLED */
     hdlr->internalSubset = xmlSAX2InternalSubset;
     hdlr->externalSubset = xmlSAX2ExternalSubset;
     hdlr->isStandalone = xmlSAX2IsStandalone;
@@ -2929,7 +2784,7 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
 /**
  * xmlDefaultSAXHandlerInit:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * DEPRECATED: This function is a no-op. Call xmlInitParser to
  * initialize the library.
  *
  * Initialize the default SAX2 handler
@@ -2937,9 +2792,6 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
 void
 xmlDefaultSAXHandlerInit(void)
 {
-#ifdef LIBXML_SAX1_ENABLED
-    xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1);
-#endif /* LIBXML_SAX1_ENABLED */
 }
 
 #ifdef LIBXML_HTML_ENABLED
@@ -2990,15 +2842,12 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
 /**
  * htmlDefaultSAXHandlerInit:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
+ * DEPRECATED: This function is a no-op. Call xmlInitParser to
  * initialize the library.
- *
- * Initialize the default SAX handler
  */
 void
 htmlDefaultSAXHandlerInit(void)
 {
-    xmlSAX2InitHtmlDefaultSAXHandler((xmlSAXHandlerPtr) &htmlDefaultSAXHandler);
 }
 
 #endif /* LIBXML_HTML_ENABLED */
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 95e1c34..0000000
--- a/TODO
+++ /dev/null
@@ -1,276 +0,0 @@
-124907 HTML parse buffer problem when parsing larse in-memory docs
-124110 DTD validation && wrong namespace
-123564 xmllint --html --format
-
-           TODO for the XML parser and stuff:
-          ==================================
-
-    this tend to be outdated :-\ ...
-
-DOCS:
-=====
-
-- use case of using XInclude to load for example a description.
-  order document + product base -(XSLT)-> quote with XIncludes 
-                                                   |
-  HTML output with description of parts <---(XSLT)--
-
-TODO:
-=====
-- XInclude at the SAX level (libSRVG)
-- fix the C code prototype to bring back doc/libxml-undocumented.txt
-  to a reasonable level
-- Computation of base when HTTP redirect occurs, might affect HTTP
-  interfaces.
-- Computation of base in XInclude. Relativization of URIs.
-- listing all attributes in a node.
-- Better checking of external parsed entities TAG 1234
-- Go through erratas and do the cleanup.
-  http://www.w3.org/XML/xml-19980210-errata ... started ...
-- jamesh suggestion: SAX like functions to save a document ie. call a
-  function to open a new element with given attributes, write character
-  data, close last element, etc
-  + inversted SAX, initial patch in April 2002 archives.
-- htmlParseDoc has parameter encoding which is not used.
-  Function htmlCreateDocParserCtxt ignore it.
-- fix realloc() usage.
-- Stricten the UTF8 conformance (Martin Duerst):
-  http://www.w3.org/2001/06/utf-8-test/.
-  The bad files are in http://www.w3.org/2001/06/utf-8-wrong/.
-- xml:id normalized value
-
-TODO:
-=====
-
-- move all string manipulation functions (xmlStrdup, xmlStrlen, etc.) to
-  global.c. Bjorn noted that the following files depends on parser.o solely
-  because of these string functions: entities.o, global.o, hash.o, tree.o,
-  xmlIO.o, and xpath.o.
-
-- Optimization of tag strings allocation ?
-
-- maintain coherency of namespace when doing cut'n paste operations
-  => the functions are coded, but need testing
-
-- function to rebuild the ID table
-- functions to rebuild the DTD hash tables (after DTD changes).
-   
-
-EXTENSIONS:
-===========
-
-- Tools to produce man pages from the SGML docs.
-
-- Add Xpointer recognition/API
-
-- Add Xlink recognition/API
-  => started adding an xlink.[ch] with a unified API for XML and HTML.
-     it's crap :-(
-
-- Implement XSchemas
-  => Really need to be done <grin/>
-  - datatype are complete, but structure support is very limited.
-
-- extend the shell with:
-   - edit
-   - load/save
-   - mv (yum, yum, but it's harder because directories are ordered in
-     our case, mvup and mvdown would be required)
-
-
-Done:
-=====
-
-- Add HTML validation using the XHTML DTD
-  - problem: do we want to keep and maintain the code for handling
-    DTD/System ID cache directly in libxml ?
-  => not really done that way, but there are new APIs to check elements
-     or attributes. Otherwise XHTML validation directly ...
-
-- XML Schemas datatypes except Base64 and BinHex
-
-- Relax NG validation
-
-- XmlTextReader streaming API + validation
-
-- Add a DTD cache prefilled with xhtml DTDs and entities and a program to
-  manage them -> like the /usr/bin/install-catalog from SGML
-  right place seems $datadir/xmldtds
-  Maybe this is better left to user apps
-  => use a catalog instead , and xhtml1-dtd package
-
-- Add output to XHTML
-  => XML serializer automatically recognize the DTd and apply the specific
-     rules.
-
-- Fix output of <tst val="x&#xA;y"/>
-
-- compliance to XML-Namespace checking, see section 6 of
-  http://www.w3.org/TR/REC-xml-names/
-
-- Correct standalone checking/emitting (hard)
-  2.9 Standalone Document Declaration
-
-- Implement OASIS XML Catalog support
-  http://www.oasis-open.org/committees/entity/
-
-- Get OASIS testsuite to a more friendly result, check all the results
-  once stable. the check-xml-test-suite.py script does this
-
-- Implement XSLT
-  => libxslt
-
-- Finish XPath
-  => attributes addressing troubles
-  => defaulted attributes handling
-  => namespace axis ?
-  done as XSLT got debugged
-
-- bug reported by Michael Meallin on validation problems
-  => Actually means I need to add support (and warn) for non-deterministic
-     content model.
-- Handle undefined namespaces in entity contents better ... at least
-  issue a warning
-- DOM needs
-  int xmlPruneProp(xmlNodePtr node, xmlAtttrPtr attr);
-  => done it's actually xmlRemoveProp xmlUnsetProp xmlUnsetNsProp
-
-- HTML: handling of Script and style data elements, need special code in
-  the parser and saving functions (handling of < > " ' ...):
-  http://www.w3.org/TR/html4/types.html#type-script
-  Attributes are no problems since entities are accepted.
-- DOM needs
-  xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value)
-- problem when parsing hrefs with & with the HTML parser (IRC ac)
-- If the internal encoding is not UTF8 saving to a given encoding doesn't
-  work => fix to force UTF8 encoding ...
-  done, added documentation too
-- Add an ASCII I/O encoder (asciiToUTF8 and UTF8Toascii)
-- Issue warning when using non-absolute namespaces URI.
-- the html parser should add <head> and <body> if they don't exist
-  started, not finished.
-  Done, the automatic closing is added and 3 testcases were inserted
-- Command to force the parser to stop parsing and ignore the rest of the file.
-  xmlStopParser() should allow this, mostly untested
-- support for HTML empty attributes like <hr noshade>
-- plugged iconv() in for support of a large set of encodings.
-- xmlSwitchToEncoding() rewrite done
-- URI checkings (no fragments) rfc2396.txt
-- Added a clean mechanism for overload or added input methods:
-  xmlRegisterInputCallbacks()
-- dynamically adapt the alloc entry point to use g_alloc()/g_free()
-  if the programmer wants it: 
-    - use xmlMemSetup() to reset the routines used.
-- Check attribute normalization especially xmlGetProp()
-- Validity checking problems for NOTATIONS attributes
-- Validity checking problems for ENTITY ENTITIES attributes
-- Parsing of a well balanced chunk xmlParseBalancedChunkMemory()
-- URI module: validation, base, etc ... see uri.[ch]
-- turn tester into a generic program xmllint installed with libxml
-- extend validity checks to go through entities content instead of
-  just labelling them PCDATA
-- Save Dtds using the children list instead of dumping the tables,
-  order is preserved as well as comments and PIs
-- Wrote a notice of changes requires to go from 1.x to 2.x
-- make sure that all SAX callbacks are disabled if a WF error is detected
-- checking/handling of newline normalization
-  http://localhost/www.xml.com/axml/target.html#sec-line-ends
-- correct checking of '&' '%' on entities content.
-- checking of PE/Nesting on entities declaration
-- checking/handling of xml:space
-   - checking done.
-   - handling done, not well tested
-- Language identification code, productions [33] to [38]
-  => done, the check has been added and report WFness errors
-- Conditional sections in DTDs [61] to [65]
-  => should this crap be really implemented ???
-  => Yep OASIS testsuite uses them
-- Allow parsed entities defined in the internal subset to override
-  the ones defined in the external subset (DtD customization).
-  => This mean that the entity content should be computed only at
-     use time, i.e. keep the orig string only at parse time and expand
-     only when referenced from the external subset :-(
-     Needed for complete use of most DTD from Eve Maler
-- Add regression tests for all WFC errors
-  => did some in test/WFC
-  => added OASIS testsuite routines
-     http://xmlsoft.org/conf/result.html
-
-- I18N: http://wap.trondheim.com/vaer/index.phtml is not XML and accepted
-  by the XML parser, UTF-8 should be checked when there is no "encoding"
-  declared !
-- Support for UTF-8 and UTF-16 encoding
-  => added some conversion routines provided by Martin Durst
-     patched them, got fixes from @@@
-     I plan to keep everything internally as UTF-8 (or ISO-Latin-X)
-     this is slightly more costly but more compact, and recent processors
-     efficiency is cache related. The key for good performances is keeping
-     the data set small, so will I.
-  => the new progressive reading routines call the detection code
-     is enabled, tested the ISO->UTF-8 stuff
-- External entities loading: 
-   - allow override by client code
-   - make sure it is called for all external entities referenced
-  Done, client code should use xmlSetExternalEntityLoader() to set
-  the default loading routine. It will be called each time an external
-  entity entity resolution is triggered.
-- maintain ID coherency when removing/changing attributes
-  The function used to deallocate attributes now check for it being an
-  ID and removes it from the table.
-- push mode parsing i.e. non-blocking state based parser
-  done, both for XML and HTML parsers. Use xmlCreatePushParserCtxt()
-  and xmlParseChunk() and html counterparts.
-  The tester program now has a --push option to select that parser 
-  front-end. Douplicated tests to use both and check results are similar.
-
-- Most of XPath, still see some troubles and occasionnal memleaks.
-- an XML shell, allowing to traverse/manipulate an XML document with
-  a shell like interface, and using XPath for the anming syntax
-  - use of readline and history added when available
-  - the shell interface has been cleanly separated and moved to debugXML.c
-- HTML parser, should be fairly stable now
-- API to search the lang of an attribute
-- Collect IDs at parsing and maintain a table. 
-   PBM: maintain the table coherency
-   PBM: how to detect ID types in absence of DtD !
-- Use it for XPath ID support
-- Add validity checking
-  Should be finished now !
-- Add regression tests with entity substitutions
-
-- External Parsed entities, either XML or external Subset [78] and [79]
-  parsing the xmllang DtD now works, so it should be sufficient for
-  most cases !
-
-- progressive reading. The entity support is a first step toward
-  abstraction of an input stream. A large part of the context is still
-  located on the stack, moving to a state machine and putting everything
-  in the parsing context should provide an adequate solution.
-  => Rather than progressive parsing, give more power to the SAX-like
-     interface. Currently the DOM-like representation is built but
-     => it should be possible to define that only as a set of SAX callbacks
-       and remove the tree creation from the parser code.
-       DONE
-
-- DOM support, instead of using a proprietary in memory
-  format for the document representation, the parser should
-  call a DOM API to actually build the resulting document.
-  Then the parser becomes independent of the in-memory
-  representation of the document. Even better using RPC's
-  the parser can actually build the document in another
-  program.
-  => Work started, now the internal representation is by default
-     very near a direct DOM implementation. The DOM glue is implemented
-     as a separate module. See the GNOME gdome module.
-
-- C++ support : John Ehresman <jehresma@dsg.harvard.edu>
-- Updated code to follow more recent specs, added compatibility flag
-- Better error handling, use a dedicated, overridable error
-  handling function.
-- Support for CDATA.
-- Keep track of line numbers for better error reporting.
-- Support for PI (SAX one).
-- Support for Comments (bad, should be in ASAP, they are parsed
-  but not stored), should be configurable.
-- Improve the support of entities on save (+SAX).
-
diff --git a/TODO_SCHEMAS b/TODO_SCHEMAS
deleted file mode 100644 (file)
index 145a4ed..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-- implement counted transitions at the automata level
-
-- Unicode:
-  + upgrade to 3.2
-  + improve the python script to generate better test
-    expressions to check the list of ranges.
-
-- Implement the interface at the SAX level
-
-- Implement the missing parts in the Structure part
-   + all content model
-   + enumerations
-   + countless others c.f. the TODO scattered in the code
-
-- Complete the Built-In datatype collections and Facets implementations
-
-- Regression tests based on
-  + the primer:
-    http://www.w3.org/TR/xmlschema-0/
-  + the Schemas Test Collection:
-    http://www.w3.org/2001/05/xmlschema-test-collection/
-  + archives of the schemas-dev list
-
-- Integrity constraints:
-  + what's that ? How need to read about it
-
-- "formal" checking, i.e. go through the full Structure spec and
-  bind code and associated parts of the Schemas spec
-
-- go though the erratas
-  http://www.w3.org/2001/05/xmlschema-errata
diff --git a/buf.c b/buf.c
index 6749d97..266395f 100644 (file)
--- a/buf.c
+++ b/buf.c
 #include <stdlib.h>
 
 #include <libxml/tree.h>
-#include <libxml/globals.h>
-#include <libxml/tree.h>
 #include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
-#include "buf.h"
+
+#include "private/buf.h"
+#include "private/error.h"
 
 #ifndef SIZE_MAX
 #define SIZE_MAX ((size_t) -1)
@@ -133,7 +133,7 @@ xmlBufCreate(void) {
     ret->size = xmlDefaultBufferSize;
     UPDATE_COMPAT(ret);
     ret->alloc = xmlBufferAllocScheme;
-    ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+    ret->content = (xmlChar *) xmlMallocAtomic(ret->size);
     if (ret->content == NULL) {
        xmlBufMemoryError(ret, "creating buffer");
        xmlFree(ret);
@@ -169,7 +169,7 @@ xmlBufCreateSize(size_t size) {
     ret->size = (size ? size + 1 : 0);         /* +1 for ending null */
     UPDATE_COMPAT(ret);
     if (ret->size){
-        ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+        ret->content = (xmlChar *) xmlMallocAtomic(ret->size);
         if (ret->content == NULL) {
            xmlBufMemoryError(ret, "creating buffer");
             xmlFree(ret);
@@ -198,8 +198,6 @@ xmlBufDetach(xmlBufPtr buf) {
 
     if (buf == NULL)
         return(NULL);
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
-        return(NULL);
     if (buf->buffer != NULL)
         return(NULL);
     if (buf->error)
@@ -214,40 +212,6 @@ xmlBufDetach(xmlBufPtr buf) {
     return ret;
 }
 
-
-/**
- * xmlBufCreateStatic:
- * @mem: the memory area
- * @size:  the size in byte
- *
- * routine to create an XML buffer from an immutable memory area.
- * The area won't be modified nor copied, and is expected to be
- * present until the end of the buffer lifetime.
- *
- * returns the new structure.
- */
-xmlBufPtr
-xmlBufCreateStatic(void *mem, size_t size) {
-    xmlBufPtr ret;
-
-    if (mem == NULL)
-        return(NULL);
-
-    ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
-    if (ret == NULL) {
-       xmlBufMemoryError(NULL, "creating buffer");
-        return(NULL);
-    }
-    ret->use = size;
-    ret->size = size;
-    UPDATE_COMPAT(ret);
-    ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE;
-    ret->content = (xmlChar *) mem;
-    ret->error = 0;
-    ret->buffer = NULL;
-    return(ret);
-}
-
 /**
  * xmlBufGetAllocationScheme:
  * @buf:  the buffer
@@ -259,10 +223,6 @@ xmlBufCreateStatic(void *mem, size_t size) {
 int
 xmlBufGetAllocationScheme(xmlBufPtr buf) {
     if (buf == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufGetAllocationScheme: buf == NULL\n");
-#endif
         return(-1);
     }
     return(buf->alloc);
@@ -281,19 +241,13 @@ int
 xmlBufSetAllocationScheme(xmlBufPtr buf,
                           xmlBufferAllocationScheme scheme) {
     if ((buf == NULL) || (buf->error != 0)) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufSetAllocationScheme: buf == NULL or in error\n");
-#endif
         return(-1);
     }
-    if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
-        (buf->alloc == XML_BUFFER_ALLOC_IO))
+    if (buf->alloc == XML_BUFFER_ALLOC_IO)
         return(-1);
     if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
         (scheme == XML_BUFFER_ALLOC_EXACT) ||
         (scheme == XML_BUFFER_ALLOC_HYBRID) ||
-        (scheme == XML_BUFFER_ALLOC_IMMUTABLE) ||
        (scheme == XML_BUFFER_ALLOC_BOUNDED)) {
        buf->alloc = scheme;
         if (buf->buffer)
@@ -321,18 +275,13 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
 void
 xmlBufFree(xmlBufPtr buf) {
     if (buf == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufFree: buf == NULL\n");
-#endif
        return;
     }
 
     if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
         (buf->contentIO != NULL)) {
         xmlFree(buf->contentIO);
-    } else if ((buf->content != NULL) &&
-        (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
+    } else if (buf->content != NULL) {
         xmlFree(buf->content);
     }
     xmlFree(buf);
@@ -350,9 +299,7 @@ xmlBufEmpty(xmlBufPtr buf) {
     if (buf->content == NULL) return;
     CHECK_COMPAT(buf)
     buf->use = 0;
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
-        buf->content = BAD_CAST "";
-    } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+    if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
                (buf->contentIO != NULL)) {
         size_t start_buf = buf->content - buf->contentIO;
 
@@ -385,8 +332,7 @@ xmlBufShrink(xmlBufPtr buf, size_t len) {
     if (len > buf->use) return(0);
 
     buf->use -= len;
-    if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
-        ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
+    if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
        /*
         * we just move the content pointer, but also make sure
         * the perceived buffer size has shrunk accordingly
@@ -434,7 +380,6 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
     if ((buf == NULL) || (buf->error != 0)) return(0);
     CHECK_COMPAT(buf)
 
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
     if (len < buf->size - buf->use)
         return(buf->size - buf->use - 1);
     if (len >= SIZE_MAX - buf->use) {
@@ -504,7 +449,7 @@ xmlBufGrow(xmlBufPtr buf, int len) {
     ret = xmlBufGrowInternal(buf, len);
     if (buf->error != 0)
         return(-1);
-    return((int) ret);
+    return(ret > INT_MAX ? INT_MAX : ret);
 }
 
 /**
@@ -520,23 +465,15 @@ xmlBufDump(FILE *file, xmlBufPtr buf) {
     size_t ret;
 
     if ((buf == NULL) || (buf->error != 0)) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufDump: buf == NULL or in error\n");
-#endif
        return(0);
     }
     if (buf->content == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufDump: buf->content == NULL\n");
-#endif
        return(0);
     }
     CHECK_COMPAT(buf)
     if (file == NULL)
        file = stdout;
-    ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
+    ret = fwrite(buf->content, 1, buf->use, file);
     return(ret);
 }
 
@@ -699,7 +636,6 @@ xmlBufResize(xmlBufPtr buf, size_t size)
         return(0);
     CHECK_COMPAT(buf)
 
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
     if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
         /*
         * Used to provide parsing limits
@@ -777,7 +713,8 @@ xmlBufResize(xmlBufPtr buf, size_t size)
        if (buf->content == NULL) {
            rebuf = (xmlChar *) xmlMallocAtomic(newSize);
            buf->use = 0;
-           rebuf[buf->use] = 0;
+            if (rebuf != NULL)
+               rebuf[buf->use] = 0;
        } else if (buf->size - buf->use < 100) {
            rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
         } else {
@@ -825,12 +762,7 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
        return -1;
     CHECK_COMPAT(buf)
 
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
     if (len < -1) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufAdd: len < 0\n");
-#endif
        return -1;
     }
     if (len == 0) return 0;
@@ -863,7 +795,7 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
         }
     }
 
-    memmove(&buf->content[buf->use], str, len*sizeof(xmlChar));
+    memmove(&buf->content[buf->use], str, len);
     buf->use += len;
     buf->content[buf->use] = 0;
     UPDATE_COMPAT(buf)
@@ -885,7 +817,6 @@ xmlBufCat(xmlBufPtr buf, const xmlChar *str) {
     if ((buf == NULL) || (buf->error))
         return(-1);
     CHECK_COMPAT(buf)
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
     if (str == NULL) return -1;
     return xmlBufAdd(buf, str, -1);
 }
@@ -923,14 +854,8 @@ xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string) {
     if ((buf == NULL) || (buf->error))
         return(-1);
     CHECK_COMPAT(buf)
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
-        return(-1);
     if (xmlStrchr(string, '\"')) {
         if (xmlStrchr(string, '\'')) {
-#ifdef DEBUG_BUFFER
-           xmlGenericError(xmlGenericErrorContext,
- "xmlBufWriteQuotedString: string contains quote and double-quotes !\n");
-#endif
            xmlBufCCat(buf, "\"");
             base = cur = string;
             while(*cur != 0){
@@ -1042,11 +967,11 @@ xmlBufBackToBuffer(xmlBufPtr buf) {
          * Keep the buffer but provide a truncated size value.
          */
         xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer");
-        ret->use = (int) buf->use;
+        ret->use = buf->use;
         ret->size = INT_MAX;
     } else {
-        ret->use = (int) buf->use;
-        ret->size = (int) buf->size;
+        ret->use = buf->use;
+        ret->size = buf->size;
     }
     ret->alloc = buf->alloc;
     ret->content = buf->content;
@@ -1092,8 +1017,12 @@ xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer) {
  */
 int
 xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input) {
-    if ((input == NULL) || (buf == NULL) || (buf->error))
+    if (input == NULL)
         return(-1);
+    if ((buf == NULL) || (buf->error)) {
+        input->base = input->cur = input->end = BAD_CAST "";
+        return(-1);
+    }
     CHECK_COMPAT(buf)
     input->base = input->cur = buf->content;
     input->end = &buf->content[buf->use];
@@ -1101,39 +1030,10 @@ xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input) {
 }
 
 /**
- * xmlBufGetInputBase:
- * @buf: an xmlBufPtr
- * @input: an xmlParserInputPtr
- *
- * Get the base of the @input relative to the beginning of the buffer
- *
- * Returns the size_t corresponding to the displacement
- */
-size_t
-xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input) {
-    size_t base;
-
-    if ((input == NULL) || (buf == NULL) || (buf->error))
-        return(-1);
-    CHECK_COMPAT(buf)
-    base = input->base - buf->content;
-    /*
-     * We could do some pointer arithmetic checks but that's probably
-     * sufficient.
-     */
-    if (base > buf->size) {
-        xmlBufOverflowError(buf, "Input reference outside of the buffer");
-        base = 0;
-    }
-    return(base);
-}
-
-/**
- * xmlBufSetInputBaseCur:
+ * xmlBufUpdateInput:
  * @buf: an xmlBufPtr
  * @input: an xmlParserInputPtr
- * @base: the base value relative to the beginning of the buffer
- * @cur: the cur value relative to the beginning of the buffer
+ * @pos: the cur value relative to the beginning of the buffer
  *
  * Update the input to use the base and cur relative to the buffer
  * after a possible reallocation of its content
@@ -1141,17 +1041,20 @@ xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input) {
  * Returns -1 in case of error, 0 otherwise
  */
 int
-xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
-                      size_t base, size_t cur) {
+xmlBufUpdateInput(xmlBufPtr buf, xmlParserInputPtr input, size_t pos) {
     if (input == NULL)
         return(-1);
+    /*
+     * TODO: It might be safer to keep using the buffer content if there
+     * was an error.
+     */
     if ((buf == NULL) || (buf->error)) {
         input->base = input->cur = input->end = BAD_CAST "";
         return(-1);
     }
     CHECK_COMPAT(buf)
-    input->base = &buf->content[base];
-    input->cur = input->base + cur;
+    input->base = buf->content;
+    input->cur = input->base + pos;
     input->end = &buf->content[buf->use];
     return(0);
 }
diff --git a/buf.h b/buf.h
deleted file mode 100644 (file)
index b7bcf61..0000000
--- a/buf.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Summary: Internal Interfaces for memory buffers in libxml2
- * Description: this module describes most of the new xmlBuf buffer
- *              entry points, those are private routines, with a
- *              few exceptions exported in tree.h. This was added
- *              in 2.9.0.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-#ifndef __XML_BUF_H__
-#define __XML_BUF_H__
-
-#include <libxml/tree.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-xmlBufPtr xmlBufCreate(void);
-xmlBufPtr xmlBufCreateSize(size_t size);
-xmlBufPtr xmlBufCreateStatic(void *mem, size_t size);
-
-int xmlBufSetAllocationScheme(xmlBufPtr buf,
-                              xmlBufferAllocationScheme scheme);
-int xmlBufGetAllocationScheme(xmlBufPtr buf);
-
-void xmlBufFree(xmlBufPtr buf);
-void xmlBufEmpty(xmlBufPtr buf);
-
-/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
-int xmlBufGrow(xmlBufPtr buf, int len);
-int xmlBufResize(xmlBufPtr buf, size_t len);
-
-int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
-int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
-int xmlBufCCat(xmlBufPtr buf, const char *str);
-int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
-
-size_t xmlBufAvail(const xmlBufPtr buf);
-size_t xmlBufLength(const xmlBufPtr buf);
-/* size_t xmlBufUse(const xmlBufPtr buf); */
-int xmlBufIsEmpty(const xmlBufPtr buf);
-int xmlBufAddLen(xmlBufPtr buf, size_t len);
-
-/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
-/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
-
-xmlChar * xmlBufDetach(xmlBufPtr buf);
-
-size_t xmlBufDump(FILE *file, xmlBufPtr buf);
-
-xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer);
-xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf);
-int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
-
-int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
-size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
-int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
-                          size_t base, size_t cur);
-#ifdef __cplusplus
-}
-#endif
-#endif /* __XML_BUF_H__ */
-
diff --git a/build_glob.py b/build_glob.py
deleted file mode 100755 (executable)
index 750fd70..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env python
-###
-#
-#       build_glob.py : Build the global_functions.h and global_functions.c
-#                       files which are required to implement the user
-#                       interface to global variables now that thread specific
-#                       data (TSD) is used to emulate global state.
-#
-#       See Copyright for the status of this software.
-#       Gary.Pennington@sun.com
-###
-import os, string
-
-class globvar:
-    def __init__(self, type, name):
-        self.type=type
-        self.name=name
-
-def striplinesep(line):
-    while line and line[-1] in ('\r','\n'):
-        line = line[:-1]
-    return line
-
-def writeline(file, line=None):
-    if line:
-        file.write(line)
-    file.write("\n")
-
-if __name__ == "__main__":
-    globals={}
-    global_data=open("global.data").readlines()
-    global_code=open("globals.c").readlines()
-    global_hdr=open("include/libxml/globals.h").readlines()
-    global_functions_hdr=open("include/libxml/globals.h", "w+")
-    global_functions_impl=open("globals.c", "w+")
-
-    #
-    # Rebuild the beginning of the file up to the
-    # Automatically generated string
-    # 
-    for line in global_hdr:
-        line = striplinesep(line)
-        if line == " * Automatically generated by build_glob.py.":
-           break
-       writeline(global_functions_hdr, line)
-
-    writeline(global_functions_hdr, " * Automatically generated by build_glob.py.")
-    writeline(global_functions_hdr, " * Do not modify the previous line.")
-    writeline(global_functions_hdr, " */")
-    writeline(global_functions_hdr)
-
-    for line in global_code:
-        line = striplinesep(line)
-        if line == " * Automatically generated by build_glob.py.":
-           break
-       writeline(global_functions_impl, line)
-
-    writeline(global_functions_impl, " * Automatically generated by build_glob.py.")
-    writeline(global_functions_impl, " * Do not modify the previous line.")
-    writeline(global_functions_impl, " */")
-    writeline(global_functions_impl)
-
-    # Now process the data and write it to the appropriate output file
-    for line in global_data:
-        if line[0]=='#':
-            continue
-        line = striplinesep(line)
-        fields = string.split(line, ",")
-        # Update the header file
-        writeline(global_functions_hdr)
-        global_functions_hdr.write("XMLPUBFUN "+fields[0]+" * XMLCALL ")
-        if fields[2]:
-            global_functions_hdr.write("(*")
-        global_functions_hdr.write("__"+fields[1]+"(void)")
-        if fields[2]:
-            global_functions_hdr.write(")"+fields[2])
-        writeline(global_functions_hdr,";")
-        writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
-        writeline(global_functions_hdr,"#define "+fields[1]+" \\")
-        writeline(global_functions_hdr,"(*(__"+fields[1]+"()))")
-        writeline(global_functions_hdr,"#else")
-        if fields[2]:
-            writeline(global_functions_hdr,"XMLPUBVAR "+fields[0]+" "+fields[1]+fields[2]+";")
-        else:
-            writeline(global_functions_hdr,"XMLPUBVAR "+fields[0]+" "+fields[1]+";")
-        writeline(global_functions_hdr,"#endif")
-        # set/get for per-thread global defaults
-        if fields[3]:
-            writeline(global_functions_hdr,"XMLPUBFUN "+fields[0]+" XMLCALL "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v);")
-        # Update the implementation file
-        writeline(global_functions_impl)
-#        writeline(global_functions_impl, "extern "+fields[0]+" "+fields[1]+";")
-        writeline(global_functions_impl, "#undef\t"+fields[1])
-        writeline(global_functions_impl, fields[0]+" *")
-        if fields[2]:
-            global_functions_impl.write("(*")
-        global_functions_impl.write("__"+fields[1]+"(void)")
-        if fields[2]:
-            writeline(global_functions_impl, ")[]")
-        writeline(global_functions_impl, " {")
-        writeline(global_functions_impl, "    if (IS_MAIN_THREAD)")
-        writeline(global_functions_impl, "\treturn (&"+fields[1]+");")
-        writeline(global_functions_impl, "    else")
-        writeline(global_functions_impl, "\treturn (&xmlGetGlobalState()->"+fields[1]+");")
-        writeline(global_functions_impl, "}")
-        # set/get for per-thread global defaults
-        if fields[3]:
-            writeline(global_functions_impl,fields[0]+" "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v) {")
-            writeline(global_functions_impl,"    "+fields[0]+" ret;");
-            writeline(global_functions_impl,"    xmlMutexLock(xmlThrDefMutex);")
-            writeline(global_functions_impl,"    ret = "+fields[1][:3]+fields[1][3:]+"ThrDef;")
-            writeline(global_functions_impl,"    "+fields[1][:3]+fields[1][3:]+"ThrDef = v;")
-            writeline(global_functions_impl,"    xmlMutexUnlock(xmlThrDefMutex);")
-            writeline(global_functions_impl,"    return ret;")
-            writeline(global_functions_impl,"}")
-    # Terminate the header file with appropriate boilerplate
-    writeline(global_functions_hdr)
-    writeline(global_functions_hdr, "#ifdef __cplusplus")
-    writeline(global_functions_hdr, "}")
-    writeline(global_functions_hdr, "#endif")
-    writeline(global_functions_hdr)
-    writeline(global_functions_hdr, "#endif /* __XML_GLOBALS_H */")
diff --git a/c14n.c b/c14n.c
index d55729c..3d2e144 100644 (file)
--- a/c14n.c
+++ b/c14n.c
@@ -12,7 +12,6 @@
 #define IN_LIBXML
 #include "libxml.h"
 #ifdef LIBXML_C14N_ENABLED
-#ifdef LIBXML_OUTPUT_ENABLED
 
 #include <stdlib.h>
 #include <string.h>
 #include <libxml/parser.h>
 #include <libxml/uri.h>
 #include <libxml/xmlerror.h>
-#include <libxml/globals.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/c14n.h>
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/error.h"
 
 /************************************************************************
  *                                                                     *
@@ -286,7 +285,7 @@ xmlC14NVisibleNsStackCreate(void) {
         xmlC14NErrMemory("creating namespaces stack");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlC14NVisibleNsStack));
+    memset(ret, 0, sizeof(xmlC14NVisibleNsStack));
     return(ret);
 }
 
@@ -2115,7 +2114,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
 #define growBufferReentrant() {                                                \
     buffer_size *= 2;                                                  \
     buffer = (xmlChar *)                                               \
-               xmlRealloc(buffer, buffer_size * sizeof(xmlChar));      \
+               xmlRealloc(buffer, buffer_size);                        \
     if (buffer == NULL) {                                              \
        xmlC14NErrMemory("growing buffer");                             \
        return(NULL);                                                   \
@@ -2150,7 +2149,7 @@ xmlC11NNormalizeString(const xmlChar * input,
      * allocate an translation buffer.
      */
     buffer_size = 1000;
-    buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar));
+    buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
     if (buffer == NULL) {
        xmlC14NErrMemory("allocating buffer");
         return (NULL);
@@ -2223,6 +2222,5 @@ xmlC11NNormalizeString(const xmlChar * input,
     *out = 0;
     return (buffer);
 }
-#endif /* LIBXML_OUTPUT_ENABLED */
 
 #endif /* LIBXML_C14N_ENABLED */
index b7837e3..945ea2c 100644 (file)
--- a/catalog.c
+++ b/catalog.c
 #ifdef LIBXML_CATALOG_ENABLED
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -37,9 +36,9 @@
 #include <libxml/catalog.h>
 #include <libxml/xmlerror.h>
 #include <libxml/threads.h>
-#include <libxml/globals.h>
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/error.h"
 
 #define MAX_DELEGATE   50
 #define MAX_CATAL_DEPTH        50
@@ -891,11 +890,7 @@ xmlParseCatalogFile(const char *filename) {
 
     ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {
-#ifdef LIBXML_SAX1_ENABLED
-       if (xmlDefaultSAXHandler.error != NULL) {
-           xmlDefaultSAXHandler.error(NULL, "out of memory\n");
-       }
-#endif
+        xmlCatalogErrMemory("allocating parser context");
        return(NULL);
     }
 
@@ -2177,7 +2172,6 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) {
     int len = 0;
     int size = 50;
     xmlChar stop;
-    int count = 0;
 
     *id = NULL;
 
@@ -2190,7 +2184,7 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) {
     } else {
        stop = ' ';
     }
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
         xmlCatalogErrMemory("allocating public ID");
        return(NULL);
@@ -2202,7 +2196,7 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) {
            break;
        if (len + 1 >= size) {
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlCatalogErrMemory("allocating public ID");
                xmlFree(buf);
@@ -2211,7 +2205,6 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) {
            buf = tmp;
        }
        buf[len++] = *cur;
-       count++;
        NEXT;
     }
     buf[len] = 0;
@@ -2975,6 +2968,8 @@ xmlACatalogAdd(xmlCatalogPtr catal, const xmlChar * type,
            if (catal->sgml == NULL)
                catal->sgml = xmlHashCreate(10);
             res = xmlHashAddEntry(catal->sgml, orig, entry);
+            if (res < 0)
+                xmlFreeCatalogEntry(entry, NULL);
         }
     }
     return (res);
@@ -3135,7 +3130,7 @@ xmlInitializeCatalog(void) {
                                        strncpy(p, "\\..\\etc\\catalog", 255 - (p - buf));
                                        uri = xmlCanonicPath((const xmlChar*)buf);
                                        if (uri != NULL) {
-                                               strncpy(XML_XML_DEFAULT_CATALOG, uri, 255);
+                                               strncpy(XML_XML_DEFAULT_CATALOG, (char* )uri, 255);
                                                xmlFree(uri);
                                        }
                                }
index 87ec050..3e15212 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import time
 import os
@@ -395,4 +395,3 @@ if libxml2.debugMemory(1) == 0:
         print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 559503a..779cefa 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import time
 import os
@@ -419,4 +419,3 @@ if libxml2.debugMemory(1) == 0:
         print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 926ceb3..a0ee028 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import time
 import os
index cecb59b..284f7f0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import time
 import os
index c34560e..a08e6af 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import time
 import os
@@ -421,4 +421,3 @@ if libxml2.debugMemory(1) == 0:
         print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index f4fa44a..fb2c715 100644 (file)
--- a/chvalid.c
+++ b/chvalid.c
@@ -14,6 +14,8 @@
 #include "libxml.h"
 #include <libxml/chvalid.h>
 
+#include <stddef.h>
+
 /*
  * The initial tables ({func_name}_tab) are used to validate whether a
  * single-byte character is within the specified group.  Each table
index 1f8be71..9446c3b 100644 (file)
@@ -1,20 +1,11 @@
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define if __attribute__((destructor)) is accepted */
+/* A form that will not confuse apibuild.py */
 #cmakedefine ATTRIBUTE_DESTRUCTOR @ATTRIBUTE_DESTRUCTOR@
 
-/* Type cast for the gethostbyname() argument */
-#cmakedefine GETHOSTBYNAME_ARG_CAST @GETHOSTBYNAME_ARG_CAST@
-
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #cmakedefine HAVE_ARPA_INET_H 1
 
-/* Define to 1 if you have the <arpa/nameser.h> header file. */
-#cmakedefine HAVE_ARPA_NAMESER_H 1
-
-/* Whether struct sockaddr::__ss_family exists */
-#cmakedefine HAVE_BROKEN_SS_FAMILY 1
+/* Define if __attribute__((destructor)) is accepted */
+#cmakedefine HAVE_ATTRIBUTE_DESTRUCTOR 1
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #cmakedefine HAVE_DLFCN_H 1
@@ -31,9 +22,6 @@
 /* Define to 1 if you have the `ftime' function. */
 #cmakedefine HAVE_FTIME 1
 
-/* Define if getaddrinfo is there */
-#cmakedefine HAVE_GETADDRINFO 1
-
 /* Define to 1 if you have the `gettimeofday' function. */
 #cmakedefine HAVE_GETTIMEOFDAY 1
 
 /* Define to 1 if you have the <poll.h> header file. */
 #cmakedefine HAVE_POLL_H 1
 
-/* Define if <pthread.h> is there */
+/* Define to 1 if you have the <pthread.h> header file. */
 #cmakedefine HAVE_PTHREAD_H 1
 
-/* Define to 1 if you have the `putenv' function. */
-#cmakedefine HAVE_PUTENV 1
-
-/* Define to 1 if you have the `rand_r' function. */
-#cmakedefine HAVE_RAND_R 1
-
-/* Define to 1 if you have the <resolv.h> header file. */
-#cmakedefine HAVE_RESOLV_H 1
-
 /* Have shl_load based dso */
 #cmakedefine HAVE_SHLLOAD 1
 
 /* Define to 1 if you have the <sys/time.h> header file. */
 #cmakedefine HAVE_SYS_TIME_H 1
 
-/* Define to 1 if you have the <sys/types.h> header file. */
-#cmakedefine HAVE_SYS_TYPES_H 1
-
 /* Define to 1 if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H 1
 
 /* Whether __va_copy() is available */
 #cmakedefine HAVE___VA_COPY 1
 
-/* Define to the sub-directory where libtool stores uninstalled libraries. */
-#cmakedefine LT_OBJDIR "@LT_OBJDIR@"
-
-/* Name of package */
-#define PACKAGE "@PACKAGE@"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "@PACKAGE_NAME@"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "@PACKAGE_STRING@"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL "@PACKAGE_URL@"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "@PACKAGE_VERSION@"
-
-/* Type cast for the send() function 2nd arg */
-#cmakedefine SEND_ARG2_CAST @SEND_ARG2_CAST@
-
 /* Support for IPv6 */
 #cmakedefine SUPPORT_IP6 1
 
 /* Determine what socket length (socklen_t) data type is */
 #cmakedefine XML_SOCKLEN_T @XML_SOCKLEN_T@
 
+/* TLS specifier */
+#cmakedefine XML_THREAD_LOCAL @XML_THREAD_LOCAL@
+
 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
    <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
    #define below would cause a syntax error. */
 #cmakedefine _UINT32_T @_UINT32_T@
 
-/* ss_family is not defined here, use __ss_family instead */
-#cmakedefine ss_family @ss_family@
-
 /* Define to the type of an unsigned integer type of width exactly 32 bits if
    such a type exists and the standard includes do not define it. */
 #cmakedefine uint32_t @uint32_t@
index 9dedb3a..d099b87 100644 (file)
@@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ([2.63])
 
 m4_define([MAJOR_VERSION], 2)
-m4_define([MINOR_VERSION], 10)
-m4_define([MICRO_VERSION], 2)
+m4_define([MINOR_VERSION], 12)
+m4_define([MICRO_VERSION], 5)
 
 AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION])
 AC_CONFIG_SRCDIR([entities.c])
@@ -48,12 +48,9 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MKDIR_P
-AC_PROG_CPP
-AC_PATH_PROG(MV, mv, /bin/mv)
 AC_PATH_PROG(TAR, tar, /bin/tar)
 AC_PATH_PROG(PERL, perl, /usr/bin/perl)
 AC_PATH_PROG(WGET, wget, /usr/bin/wget)
-AC_PATH_PROG(XMLLINT, xmllint, /usr/bin/xmllint)
 AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
 PKG_PROG_PKG_CONFIG
 
@@ -61,431 +58,261 @@ LT_INIT([disable-static])
 LT_LIB_M
 
 dnl
-dnl if the system support linker version scripts for symbol versioning
-dnl then add it
-dnl
-VERSION_SCRIPT_FLAGS=
-# lt_cv_prog_gnu_ld is from libtool 2.+
-if test "$lt_cv_prog_gnu_ld" = yes; then
-  VERSION_SCRIPT_FLAGS=-Wl,--version-script=
-else
-  case $host in
-  *-*-sunos*) VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,";;
-  esac
-fi
-AC_SUBST(VERSION_SCRIPT_FLAGS)
-AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"])
-
-dnl
 dnl We process the AC_ARG_WITH first so that later we can modify
 dnl some of them to try to prevent impossible combinations.  This
 dnl also allows up so alphabetize the choices
 dnl
 
-dnl
-dnl zlib option might change flags, so we save them initially
-dnl
-_cppflags="${CPPFLAGS}"
-_libs="${LIBS}"
-
 AC_ARG_WITH(c14n,
-[  --with-c14n             add the Canonicalization support (on)])
+[  --with-c14n             Canonical XML 1.0 support (on)])
 AC_ARG_WITH(catalog,
-[  --with-catalog          add the Catalog support (on)])
+[  --with-catalog          XML Catalogs support (on)])
 AC_ARG_WITH(debug,
-[  --with-debug            add the debugging module (on)])
-AC_ARG_WITH(fexceptions,
-[  --with-fexceptions      add GCC flag -fexceptions for C++ exceptions (off)])
+[  --with-debug            debugging module and shell (on)])
 AC_ARG_WITH(ftp,
-[  --with-ftp              add the FTP support (off)])
+[  --with-ftp              FTP support (off)])
 AC_ARG_WITH(history,
-[  --with-history          add history support to xmllint shell(off)])
+[  --with-history          history support for shell (off)])
+AC_ARG_WITH(readline,
+[  --with-readline[[=DIR]]   use readline in DIR (for shell history)])
 AC_ARG_WITH(html,
-[  --with-html             add the HTML support (on)])
+[  --with-html             HTML parser (on)])
 AC_ARG_WITH(http,
-[  --with-http             add the HTTP support (on)])
+[  --with-http             HTTP support (on)])
 AC_ARG_WITH(iconv,
-[  --with-iconv[[=DIR]]      add ICONV support (on)])
+[  --with-iconv[[=DIR]]      iconv support (on)])
 AC_ARG_WITH(icu,
-[  --with-icu                add ICU support (off)])
+[  --with-icu              ICU support (off)])
 AC_ARG_WITH(iso8859x,
-[  --with-iso8859x         add ISO8859X support if no iconv (on)])
-AC_ARG_WITH(legacy,
-[  --with-legacy           add deprecated APIs for compatibility (off)])
+[  --with-iso8859x         ISO-8859-X support if no iconv (on)])
+AC_ARG_WITH(lzma,
+[  --with-lzma[[=DIR]]       use liblzma in DIR (on)])
 AC_ARG_WITH(mem_debug,
-[  --with-mem-debug        add the memory debugging module (off)])
-AC_ARG_WITH(minimum,
-[  --with-minimum          build a minimally sized library (off)])
+[  --with-mem-debug        memory debugging module (off)])
+AC_ARG_WITH(modules,
+[  --with-modules          dynamic modules support (on)])
 AC_ARG_WITH(output,
-[  --with-output           add the serialization support (on)])
+[  --with-output           serialization support (on)])
 AC_ARG_WITH(pattern,
-[  --with-pattern          add the xmlPattern selection interface (on)])
+[  --with-pattern          xmlPattern selection interface (on)])
 AC_ARG_WITH(push,
-[  --with-push             add the PUSH parser interfaces (on)])
+[  --with-push             push parser interfaces (on)])
 AC_ARG_WITH(python,
-[  --with-python           build Python bindings (on)])
+[  --with-python           Python bindings (on)])
 AC_ARG_WITH(reader,
-[  --with-reader           add the xmlReader parsing interface (on)])
-AC_ARG_WITH(readline,
-[  --with-readline=DIR     use readline in DIR],[
-  if test "$withval" != "no" && test "$withval" != "yes"; then
-    RDL_DIR=$withval
-    CPPFLAGS="${CPPFLAGS} -I$withval/include"
-    LDFLAGS="${LDFLAGS} -L$withval/lib"
-  fi
-])
+[  --with-reader           xmlReader parsing interface (on)])
 AC_ARG_WITH(regexps,
-[  --with-regexps          add Regular Expressions support (on)])
+[  --with-regexps          regular expressions support (on)])
 AC_ARG_WITH(run_debug,
-[  --with-run-debug        add the runtime debugging module (off)])
+[  --with-run-debug        runtime debugging module (off)])
 AC_ARG_WITH(sax1,
-[  --with-sax1             add the older SAX1 interface (on)])
+[  --with-sax1             older SAX1 interface (on)])
 AC_ARG_WITH(schemas,
-[  --with-schemas          add Relax-NG and Schemas support (on)])
+[  --with-schemas          XML Schemas 1.0 and RELAX NG support (on)])
 AC_ARG_WITH(schematron,
-[  --with-schematron       add Schematron support (on)])
+[  --with-schematron       Schematron support (on)])
 AC_ARG_WITH(threads,
-[  --with-threads          add multithread support(on)])
+[  --with-threads          multithreading support (on)])
 AC_ARG_WITH(thread-alloc,
-[  --with-thread-alloc     add per-thread memory(off)])
+[  --with-thread-alloc     per-thread malloc hooks (off)])
 AC_ARG_WITH(tree,
-[  --with-tree             add the DOM like tree manipulation APIs (on)])
+[  --with-tree             DOM like tree manipulation APIs (on)])
 AC_ARG_WITH(valid,
-[  --with-valid            add the DTD validation support (on)])
+[  --with-valid            DTD validation support (on)])
 AC_ARG_WITH(writer,
-[  --with-writer           add the xmlWriter saving interface (on)])
+[  --with-writer           xmlWriter serialization interface (on)])
 AC_ARG_WITH(xinclude,
-[  --with-xinclude         add the XInclude support (on)])
+[  --with-xinclude         XInclude 1.0 support (on)])
 AC_ARG_WITH(xpath,
-[  --with-xpath            add the XPATH support (on)])
+[  --with-xpath            XPath 1.0 support (on)])
 AC_ARG_WITH(xptr,
-[  --with-xptr             add the XPointer support (on)])
+[  --with-xptr             XPointer support (on)])
 AC_ARG_WITH(xptr-locs,
-[  --with-xptr-locs        add support for XPointer locations (off)])
-AC_ARG_WITH(modules,
-[  --with-modules          add the dynamic modules support (on)])
+[  --with-xptr-locs        XPointer ranges and points (off)])
 AC_ARG_WITH(zlib,
-[  --with-zlib[[=DIR]]       use libz in DIR],[
-  if test "$withval" != "no" && test "$withval" != "yes"; then
-    Z_DIR=$withval
-    CPPFLAGS="${CPPFLAGS} -I$withval/include"
-    LDFLAGS="${LDFLAGS} -L$withval/lib"
-  fi
-])
-AC_ARG_WITH(lzma,
-[  --with-lzma[[=DIR]]       use liblzma in DIR],[
-  if test "$withval" != "no" && test "$withval" != "yes"; then
-    LZMA_DIR=$withval
-    CPPFLAGS="${CPPFLAGS} -I$withval/include"
-    LDFLAGS="${LDFLAGS} -L$withval/lib"
-  fi
-])
+[  --with-zlib[[=DIR]]       use libz in DIR (on)])
+
+AC_ARG_WITH(minimum,
+[  --with-minimum          build a minimally sized library (off)])
+AC_ARG_WITH(legacy,
+[  --with-legacy           maximum ABI compatibility (off)])
+
+AC_ARG_WITH(tls,
+[  --with-tls              thread-local storage (on)])
+AC_ARG_WITH(fexceptions,
+[  --with-fexceptions      add GCC flag -fexceptions for C++ exceptions (off)])
 AC_ARG_WITH(coverage,
 [  --with-coverage         build for code coverage with GCC (off)])
 
 dnl
 dnl hard dependencies on options
 dnl
-if test "$with_schemas" = "yes"
-then
-    with_pattern=yes
-    with_regexps=yes
-fi
-if test "$with_schematron" = "yes"
-then
-    with_pattern=yes
-    with_tree=yes
-    with_xpath=yes
-fi
-if test "$with_reader" = "yes"
-then
-    with_push=yes
-fi
-if test "$with_xptr_locs" = "yes"
-then
-    with_xptr=yes
-fi
-if test "$with_xptr" = "yes"
-then
-    with_xpath=yes
-fi
-dnl
-dnl option to build a minimal libxml2 library
-dnl
-if test "$with_minimum" = "yes"
-then
-    echo "Configuring for a minimal library"
-    if test "$with_c14n" = ""
-    then
-      with_c14n=no
-    fi
-    if test "$with_catalog" = ""
-    then
-      with_catalog=no
-    fi
-    echo So far so good!
-    if test "$with_debug" = ""
-    then
-      with_debug=no
-    fi
-    if test "$with_fexceptions" = ""
-    then
-      with_fexceptions=no
-    fi
-    if test "$with_history" = ""
-    then
-      with_history=no
-    fi
-    if test "$with_html" = ""
-    then
-      with_html=no
-    fi
-    if test "$with_http" = ""
-    then
-      with_http=no 
-    fi
-    if test "$with_iconv" = ""
-    then
-      with_iconv=no
-    fi
-    if test "$with_iso8859x" = ""
-    then
-      with_iso8859x=no
-    fi
-    if test "$with_mem_debug" = ""
-    then 
-      with_mem_debug=no
+if test "$with_c14n" = "yes"; then
+    if test "$with_output" = "no"; then
+        echo WARNING: --with-c14n overrides --without-output
     fi
-    if test "$with_output" = ""
-    then
-      with_output=no
-    fi
-    if test "$with_pattern" = ""
-    then
-      with_pattern=no
-    fi
-    if test "$with_push" = ""
-    then
-      with_push=no
-    fi
-    if test "$with_python" = ""
-    then
-      with_python=no
-    fi
-    if test "$with_reader" = ""
-    then
-      with_reader=no
-    fi
-    if test "$with_readline" = ""
-    then
-      with_readline=no
-    fi
-    if test "$with_regexps" = ""
-    then
-      with_regexps=no
-    fi
-    if test "$with_run_debug" = ""
-    then
-      with_run_debug=no
+    with_output=yes
+    if test "$with_xpath" = "no"; then
+        echo WARNING: --with-c14n overrides --without-xpath
     fi
-    if test "$with_sax1" = ""
-    then
-      with_sax1=no
+    with_xpath=yes
+fi
+if test "$with_schemas" = "yes"; then
+    if test "$with_pattern" = "no"; then
+        echo WARNING: --with-schemas overrides --without-pattern
     fi
-    if test "$with_schemas" = ""
-    then
-      with_schemas=no
+    with_pattern=yes
+    if test "$with_regexps" = "no"; then
+        echo WARNING: --with-schemas overrides --without-regexps
     fi
-    if test "$with_schematron" = ""
-    then
-      with_schematron=no
+    with_regexps=yes
+fi
+if test "$with_schematron" = "yes"; then
+    if test "$with_pattern" = "no"; then
+        echo WARNING: --with-schematron overrides --without-pattern
     fi
-    if test "$with_threads" = ""
-    then
-      with_threads=no
+    with_pattern=yes
+    if test "$with_tree" = "no"; then
+        echo WARNING: --with-schematron overrides --without-tree
     fi
-    if test "$with_thread_alloc" = ""
-    then
-      with_thread_alloc=no
-   fi
-    if test "$with_tree" = ""
-    then
-      with_tree=no
+    with_tree=yes
+    if test "$with_xpath" = "no"; then
+        echo WARNING: --with-schematron overrides --without-xpath
     fi
-    if test "$with_valid" = ""
-    then
-      with_valid=no
+    with_xpath=yes
+fi
+if test "$with_reader" = "yes"; then
+    if test "$with_push" = "no"; then
+        echo WARNING: --with-reader overrides --without-push
     fi
-    if test "$with_writer" = ""
-    then
-      with_writer=no
+    with_push=yes
+    if test "$with_tree" = "no"; then
+        echo WARNING: --with-reader overrides --without-tree
     fi
-    if test "$with_xinclude" = ""
-    then
-      with_xinclude=no
+    with_tree=yes
+fi
+if test "$with_writer" = "yes"; then
+    if test "$with_output" = "no"; then
+        echo WARNING: --with-writer overrides --without-output
     fi
-    if test "$with_xpath" = ""
-    then
-      with_xpath=no
+    with_output=yes
+    if test "$with_push" = "no"; then
+        echo WARNING: --with-writer overrides --without-push
     fi
-    if test "$with_xptr" = ""
-    then
-      with_xptr=no
+    with_push=yes
+fi
+if test "$with_xinclude" = "yes"; then
+    if test "$with_xpath" = "no"; then
+        echo WARNING: --with-xinclude overrides --without-xpath
     fi
-    if test "$with_zlib" = ""
-    then
-      with_zlib=no
+    with_xpath=yes
+fi
+if test "$with_xptr_locs" = "yes"; then
+    if test "$with_xptr" = "no"; then
+        echo WARNING: --with-xptr-locs overrides --without-xptr
     fi
-    if test "$with_modules" = ""
-    then
-      with_modules=no
+    with_xptr=yes
+fi
+if test "$with_xptr" = "yes"; then
+    if test "$with_xpath" = "no"; then
+        echo WARNING: --with-xptr overrides --without-xpath
     fi
+    with_xpath=yes
 fi
 
-echo Checking zlib
-
-dnl Checks for zlib library.
-
-WITH_ZLIB=0
-if test "$with_zlib" = "no"; then
-    echo "Disabling zlib compression support"
+if test "$with_minimum" = "yes"; then
+    dnl
+    dnl option to build a minimal libxml2 library
+    dnl
+    echo "Configuring for a minimal library"
+    test "$with_c14n" = "" && with_c14n=no
+    test "$with_catalog" = "" && with_catalog=no
+    test "$with_debug" = "" && with_debug=no
+    test "$with_fexceptions" = "" && with_fexceptions=no
+    test "$with_history" = "" && with_history=no
+    test "$with_html" = "" && with_html=no
+    test "$with_http" = "" && with_http=no
+    test "$with_iconv" = "" && with_iconv=no
+    test "$with_iso8859x" = "" && with_iso8859x=no
+    test "$with_lzma" = "" && with_lzma=no
+    test "$with_mem_debug" = "" && with_mem_debug=no
+    test "$with_output" = "" && with_output=no
+    test "$with_pattern" = "" && with_pattern=no
+    test "$with_push" = "" && with_push=no
+    test "$with_python" = "" && with_python=no
+    test "$with_reader" = "" && with_reader=no
+    test "$with_readline" = "" && with_readline=no
+    test "$with_regexps" = "" && with_regexps=no
+    test "$with_run_debug" = "" && with_run_debug=no
+    test "$with_sax1" = "" && with_sax1=no
+    test "$with_schemas" = "" && with_schemas=no
+    test "$with_schematron" = "" && with_schematron=no
+    test "$with_threads" = "" && with_threads=no
+    test "$with_thread_alloc" = "" && with_thread_alloc=no
+    test "$with_tree" = "" && with_tree=no
+    test "$with_valid" = "" && with_valid=no
+    test "$with_writer" = "" && with_writer=no
+    test "$with_xinclude" = "" && with_xinclude=no
+    test "$with_xpath" = "" && with_xpath=no
+    test "$with_xptr" = "" && with_xptr=no
+    test "$with_zlib" = "" && with_zlib=no
+    test "$with_modules" = "" && with_modules=no
 else
-    # Don't run pkg-config if with_zlib contains a path.
-    if test "x$Z_DIR" = "x"; then
-        # Try pkg-config first so that static linking works.
-        PKG_CHECK_MODULES([Z],[zlib],
-            [WITH_ZLIB=1],
-            [:])
+    dnl
+    dnl Disable dependent modules
+    dnl
+    if test "$with_output" = "no"; then
+        with_c14n=no
+        with_writer=no
     fi
-
-    if test "$WITH_ZLIB" = "0"; then
-        AC_CHECK_HEADERS(zlib.h,
-            AC_CHECK_LIB(z, gzread,[
-                WITH_ZLIB=1
-                if test "x${Z_DIR}" != "x"; then
-                    Z_CFLAGS="-I${Z_DIR}/include"
-                    Z_LIBS="-L${Z_DIR}/lib -lz"
-                    [case ${host} in
-                        *-*-solaris*)
-                            Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
-                            ;;
-                    esac]
-                else
-                    Z_LIBS="-lz"
-                fi])
-            )
+    if test "$with_pattern" = "no"; then
+        with_schemas=no
+        with_schematron=no
     fi
-fi
-
-AC_SUBST(Z_CFLAGS)
-AC_SUBST(Z_LIBS)
-AC_SUBST(WITH_ZLIB)
-
-echo Checking lzma
-
-dnl Checks for lzma library.
-
-WITH_LZMA=0
-if test "$with_lzma" = "no"; then
-    echo "Disabling lzma compression support"
-else
-    # Don't run pkg-config if with_lzma contains a path.
-    if test "x$LZMA_DIR" = "x"; then
-        # Try pkg-config first so that static linking works.
-        PKG_CHECK_MODULES([LZMA],[liblzma],
-            [WITH_LZMA=1],
-            [:])
+    if test "$with_push" = "no"; then
+        with_reader=no
+        with_writer=no
     fi
-
-    # If pkg-config failed, fall back to AC_CHECK_LIB. This
-    # will not pick up the necessary LIBS flags for liblzma's
-    # private dependencies, though, so static linking may fail.
-    if test "$WITH_LZMA" = "0"; then
-        AC_CHECK_HEADERS(lzma.h,
-            AC_CHECK_LIB(lzma, lzma_code,[
-                WITH_LZMA=1
-                if test "x${LZMA_DIR}" != "x"; then
-                    LZMA_CFLAGS="-I${LZMA_DIR}/include"
-                    LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
-                else
-                    LZMA_LIBS="-llzma"
-                fi])
-            )
+    if test "$with_regexps" = "no"; then
+        with_schemas=no
+    fi
+    if test "$with_tree" = "no"; then
+        with_reader=no
+        with_schematron=no
+    fi
+    if test "$with_xpath" = "no"; then
+        with_c14n=no
+        with_schematron=no
+        with_xinclude=no
+        with_xptr=no
     fi
 fi
 
-AC_SUBST(LZMA_CFLAGS)
-AC_SUBST(LZMA_LIBS)
-AC_SUBST(WITH_LZMA)
-
-CPPFLAGS=${_cppflags}
-LIBS=${_libs}
-
-echo Checking headers
+XML_PRIVATE_LIBS=
+XML_PRIVATE_CFLAGS=
+XML_PC_LIBS=
+XML_PC_REQUIRES=
 
+dnl
 dnl Checks for header files.
-AC_CHECK_HEADERS([fcntl.h])
-AC_CHECK_HEADERS([unistd.h])
-AC_CHECK_HEADERS([sys/stat.h])
-AC_CHECK_HEADERS([sys/types.h])
-AC_CHECK_HEADERS([stdint.h])
-AC_CHECK_HEADERS([inttypes.h])
-AC_CHECK_HEADERS([sys/socket.h], [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-])
-AC_CHECK_HEADERS([netinet/in.h], [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-])
-AC_CHECK_HEADERS([arpa/inet.h], [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-#if HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-# endif
-])
-AC_CHECK_HEADERS([netdb.h])
-AC_CHECK_HEADERS([sys/time.h])
-AC_CHECK_HEADERS([sys/select.h])
-AC_CHECK_HEADERS([poll.h])
+dnl
+AC_CHECK_HEADERS([stdint.h inttypes.h])
+AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h])
 AC_CHECK_HEADERS([sys/mman.h])
-AC_CHECK_HEADERS([sys/timeb.h])
-AC_CHECK_HEADERS([arpa/nameser.h], [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-])
-AC_CHECK_HEADERS([resolv.h], [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-# endif
-#if HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-# endif
-])
-AC_CHECK_HEADERS([dl.h])
-AC_CHECK_HEADERS([dlfcn.h])
-
-
-echo Checking types
+AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h netdb.h])
+AC_CHECK_HEADERS([sys/select.h poll.h])
+AC_CHECK_HEADERS([sys/time.h sys/timeb.h])
+AC_CHECK_HEADERS([dl.h dlfcn.h])
+AC_CHECK_HEADERS([glob.h])
+AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes")
 
+dnl
+dnl Checking types
+dnl
 AC_TYPE_UINT32_T
 
-
-echo Checking libraries
-
 dnl Checks for library functions.
-AC_CHECK_FUNCS(gettimeofday ftime)
-AC_CHECK_FUNCS(stat)
-AC_CHECK_FUNCS(rand_r)
-AC_CHECK_FUNCS(isascii mmap munmap putenv)
+AC_CHECK_FUNCS([gettimeofday ftime stat isascii mmap munmap])
 
 AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
 #if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
@@ -523,67 +350,108 @@ va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[
   AC_MSG_RESULT(yes)
   AC_DEFINE([VA_LIST_IS_ARRAY], [1],[Define if va_list is an array type])])
 
-dnl Checks for inet libraries:
-AC_SEARCH_LIBS(gethostent, [nsl])
-AC_SEARCH_LIBS(setsockopt, [socket net network])
-AC_SEARCH_LIBS(connect, [inet])
+dnl
+dnl Checks for inet libraries
+dnl
+if test "$with_http" != "no" || test "with_ftp" = "yes"; then
+    case "$host" in
+        *-*-mingw*)
+            dnl AC_SEARCH_LIBS doesn't work because of non-standard calling
+            dnl conventions on 32-bit Windows.
+            NET_LIBS="$NET_LIBS -lws2_32"
+            ;;
+        *)
+            _libs=$LIBS
+            AC_SEARCH_LIBS(gethostbyname, [nsl], [
+                if test "$ac_cv_search_gethostbyname" != "none required"; then
+                    NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname"
+                fi], [:], [$NET_LIBS])
+            AC_SEARCH_LIBS(connect, [bsd socket inet], [
+                if test "$ac_cv_search_connect" != "none required"; then
+                    NET_LIBS="$NET_LIBS $ac_cv_search_connect"
+                fi], [:], [$NET_LIBS])
+            LIBS=$_libs
+            ;;
+    esac
 
-dnl Determine what socket length (socklen_t) data type is
-AC_MSG_CHECKING([for type of socket length (socklen_t)])
-AC_TRY_COMPILE2([
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/socket.h>],[
-(void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[
-  AC_MSG_RESULT(socklen_t *)
-  XML_SOCKLEN_T=socklen_t],[
-  AC_TRY_COMPILE2([
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/socket.h>],[
-(void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[
-    AC_MSG_RESULT(size_t *)
-    XML_SOCKLEN_T=size_t],[
+    dnl Determine what socket length (socklen_t) data type is
+    AC_MSG_CHECKING([for type of socket length (socklen_t)])
     AC_TRY_COMPILE2([
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/socket.h>],[
-(void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[
-      AC_MSG_RESULT(int *)
-      XML_SOCKLEN_T=int],[
-      AC_MSG_WARN(could not determine)
-      XML_SOCKLEN_T="int"])])])
-AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is])
-
-dnl Checking if gethostbyname() argument is const.
-AC_MSG_CHECKING([for const gethostbyname() argument])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
-    [[(void)gethostbyname((const char *)"");]])],
-have_gethostbyname_const_arg=yes,
-have_gethostbyname_const_arg=no)
-AC_MSG_RESULT($have_gethostbyname_const_arg)
-if test x"$have_gethostbyname_const_arg" = x"yes"; then
-    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [],
-      [Type cast for the gethostbyname() argument])
-else
-    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [(char *)],
-      [Type cast for the gethostbyname() argument])
+    #include <stddef.h>
+    #ifdef _WIN32
+      #include <ws2tcpip.h>
+    #else
+      #include <sys/socket.h>
+    #endif],[
+    (void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[
+      AC_MSG_RESULT(socklen_t *)
+      XML_SOCKLEN_T=socklen_t],[
+      AC_TRY_COMPILE2([
+    #include <stddef.h>
+    #include <sys/socket.h>],[
+    (void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[
+        AC_MSG_RESULT(size_t *)
+        XML_SOCKLEN_T=size_t],[
+        AC_TRY_COMPILE2([
+    #include <stddef.h>
+    #include <sys/socket.h>],[
+    (void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[
+          AC_MSG_RESULT(int *)
+          XML_SOCKLEN_T=int],[
+          AC_MSG_WARN(could not determine)
+          XML_SOCKLEN_T="int"])])])
+    AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is])
+
+    dnl
+    dnl Checking for availability of IPv6
+    dnl
+    AC_ARG_ENABLE(ipv6, [  --enable-ipv6[[=yes/no]]  enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes)
+    if test "$with_minimum" = "yes"
+    then
+        enable_ipv6=no
+    fi
+    if test $enable_ipv6 = yes; then
+        AC_MSG_CHECKING([whether to enable IPv6])
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+            #ifdef _WIN32
+              #include <winsock2.h>
+            #else
+              #include <sys/socket.h>
+              #ifdef HAVE_NETDB_H
+                #include <netdb.h>
+              #endif
+            #endif
+            ]], [[
+            struct sockaddr_storage ss;
+            socket(AF_INET6, SOCK_STREAM, 0);
+            getaddrinfo(0, 0, 0, 0);
+            ]])], [
+            AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6])
+            AC_MSG_RESULT([yes])], [
+            AC_MSG_RESULT([no])]
+        )
+    fi
 fi
 
-dnl Checking if send() second argument is const.
-AC_MSG_CHECKING([for const send() second argument])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#include <sys/socket.h>]],
-    [[(void)send(1,(const char *)"",1,1);]])],
-have_send_const_arg2=yes,
-have_send_const_arg2=no)
-AC_MSG_RESULT($have_send_const_arg2)
-if test x"$have_send_const_arg2" = x"yes"; then
-    AC_DEFINE([SEND_ARG2_CAST], [],
-      [Type cast for the send() function 2nd arg])
-else
-    AC_DEFINE([SEND_ARG2_CAST], [(char *)],
-      [Type cast for the send() function 2nd arg])
+dnl
+dnl Extra flags
+dnl
+XML_LIBDIR='-L${libdir}'
+XML_INCLUDEDIR='-I${includedir}/libxml2'
+XML_CFLAGS=""
+
+dnl Thread-local storage
+if test "$with_tls" = "yes"; then
+    AC_COMPILE_IFELSE([
+        AC_LANG_SOURCE([_Thread_local int v;]) ], [
+        AC_DEFINE([XML_THREAD_LOCAL], [_Thread_local], [TLS specifier]) ], [
+    AC_COMPILE_IFELSE([
+        AC_LANG_SOURCE([__thread int v;]) ], [
+        AC_DEFINE([XML_THREAD_LOCAL], [__thread], [TLS specifier]) ], [
+    AC_COMPILE_IFELSE([
+        AC_LANG_SOURCE([__declspec(thread) int v;]) ], [
+        AC_DEFINE([XML_THREAD_LOCAL], [__declspec(thread)], [TLS specifier]) ], [
+    WARN_NO_TLS=1 ])])])
 fi
 
 dnl Checking whether __attribute__((destructor)) is accepted by the compiler
@@ -596,99 +464,29 @@ f(void) {}], [], [
   AC_DEFINE([ATTRIBUTE_DESTRUCTOR], [__attribute__((destructor))],[A form that will not confuse apibuild.py])],[
   AC_MSG_RESULT(no)])
 
-
-dnl ***********************Checking for availability of IPv6*******************
-
-AC_MSG_CHECKING([whether to enable IPv6])
-AC_ARG_ENABLE(ipv6, [  --enable-ipv6[[=yes/no]]  enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes)
-if test "$with_minimum" = "yes"
-then
-    enable_ipv6=no
-fi
-if test $enable_ipv6 = yes; then
-  have_ipv6=no
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#   include <sys/types.h>
-#   include <sys/socket.h>
-    ]], [[
-    struct sockaddr_storage ss;
-    socket(AF_INET6, SOCK_STREAM, 0)
-    ]])],
-    have_ipv6=yes,
-    have_ipv6=no
-  )
-  AC_MSG_RESULT($have_ipv6)
-
-  if test $have_ipv6 = yes; then
-    AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6])
-    have_broken_ss_family=no
-
-    dnl *********************************************************************
-    dnl on some platforms (like AIX 5L), the structure sockaddr doesn't have
-    dnl a ss_family member, but rather __ss_family. Let's detect that
-    dnl and define the HAVE_BROKEN_SS_FAMILY when we are on one of these
-    dnl platforms.  However, we should only do this if ss_family is not
-    dnl present.
-    dnl ********************************************************************
-    AC_MSG_CHECKING([struct sockaddr::ss_family])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#     include <sys/types.h>
-#     include <sys/socket.h>
-      ]], [[
-      struct sockaddr_storage ss ;
-      ss.ss_family = 0 ;
-      ]])],
-      have_ss_family=yes,
-      have_ss_family=no
-    )
-    AC_MSG_RESULT($have_ss_family)
-    if test x$have_ss_family = xno ; then
-      AC_MSG_CHECKING([broken struct sockaddr::ss_family])
-      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#       include <sys/types.h>
-#       include <sys/socket.h>
-        ]], [[
-        struct sockaddr_storage ss ;
-        ss.__ss_family = 0 ;
-        ]])],
-        have_broken_ss_family=yes,
-        have_broken_ss_family=no
-      )
-      AC_MSG_RESULT($have_broken_ss_family)
-      if test x$have_broken_ss_family = xyes ; then
-        AC_DEFINE(HAVE_BROKEN_SS_FAMILY, [],
-         [Whether struct sockaddr::__ss_family exists]) 
-        AC_DEFINE(ss_family, __ss_family,
-         [ss_family is not defined here, use __ss_family instead])
-      else
-        AC_MSG_WARN(ss_family and __ss_family not found)
-      fi
-    fi
-
-    have_getaddrinfo=no
-    AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes)
-    if test $have_getaddrinfo != yes; then
-      for lib in bsd socket inet; do
-        AC_CHECK_LIB($lib, getaddrinfo, [LIBS="$LIBS -l$lib";have_getaddrinfo=yes;break])
-      done
-    fi
-
-    if test $have_getaddrinfo = yes; then
-      AC_DEFINE([HAVE_GETADDRINFO], [], [Define if getaddrinfo is there])
-    fi
-  fi
-fi 
-
-dnl ******************************End IPv6 checks******************************
-
-XML_LIBDIR='-L${libdir}'
-XML_INCLUDEDIR='-I${includedir}/libxml2'
-
 dnl
-dnl Extra flags
+dnl Linker version scripts for symbol versioning
 dnl
-XML_CFLAGS=""
-RDL_LIBS=""
+VERSION_SCRIPT_FLAGS=
+# lt_cv_prog_gnu_ld is from libtool 2.+
+if test "$lt_cv_prog_gnu_ld" = yes; then
+  case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-msys* )
+      ;;
+    *)
+      dnl lld 16 defaults to --no-undefined-version but the version script
+      dnl can contain symbols disabled by configuration options.
+      AX_APPEND_LINK_FLAGS([-Wl,--undefined-version], [VERSION_SCRIPT_FLAGS])
+      AX_APPEND_FLAG([-Wl,--version-script=], [VERSION_SCRIPT_FLAGS])
+      ;;
+  esac
+else
+  case $host in
+  *-*-sunos*) VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,";;
+  esac
+fi
+AC_SUBST(VERSION_SCRIPT_FLAGS)
+AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"])
 
 dnl
 dnl Workaround for native compilers
@@ -698,13 +496,13 @@ dnl
 if test "${GCC}" != "yes" ; then
     case "${host}" in
           hppa*-*-hpux* )
-              EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wp,-H30000"
+              AM_CFLAGS="${AM_CFLAGS} -Wp,-H30000"
               ;;
           *-dec-osf* )
-               EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
+               AM_CFLAGS="${AM_CFLAGS} -ieee"
                ;;
          alpha*-*-linux* )
-              EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
+              AM_CFLAGS="${AM_CFLAGS} -ieee"
               ;;
     esac
 else
@@ -714,19 +512,19 @@ else
        # Not activated by default because this inflates the code size
        # Used to allow propagation of C++ exceptions through the library
        #
-       EXTRA_CFLAGS="${EXTRA_CFLAGS} -fexceptions"
+       AM_CFLAGS="${AM_CFLAGS} -fexceptions"
     fi
 
     # warnings we'd like to see
-    EXTRA_CFLAGS="${EXTRA_CFLAGS} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
+    AM_CFLAGS="${AM_CFLAGS} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
     # warnings we'd like to suppress
-    EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-long-long -Wno-format-extra-args"
+    AM_CFLAGS="${AM_CFLAGS} -Wno-long-long -Wno-format-extra-args"
     case "${host}" in
           alpha*-*-linux* )
-              EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
+              AM_CFLAGS="${AM_CFLAGS} -mieee"
               ;;
          alpha*-*-osf* )
-              EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
+              AM_CFLAGS="${AM_CFLAGS} -mieee"
               ;;
     esac
 fi
@@ -737,302 +535,99 @@ case ${host} in
     hppa*-hp-mpeix)
         NEED_TRIO=1
        ;;
-    *-*-mingw* | *-*-cygwin* | *-*-msvc* )
+    *-*-cygwin* | *-*-mingw* | *-*-msys* )
         # If the host is Windows, and shared libraries are disabled, we
-        # need to add -DLIBXML_STATIC to EXTRA_CFLAGS in order for linking to
+        # need to add -DLIBXML_STATIC to AM_CFLAGS in order for linking to
         # work properly (without it, xmlexports.h would force the use of
         # DLL imports, which obviously aren't present in a static
         # library).
         if test "x$enable_shared" = "xno"; then
             XML_CFLAGS="$XML_CFLAGS -DLIBXML_STATIC"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBXML_STATIC"
+            AM_CFLAGS="$AM_CFLAGS -DLIBXML_STATIC"
         fi
         ;;
 esac
 
 
 dnl
-dnl check for python
+dnl Simple API modules
 dnl
 
-PYTHON_TESTS=
-AS_IF([test "x$with_python" != "xno"], [
-    AM_PATH_PYTHON
-    PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
-])
-AM_CONDITIONAL([WITH_PYTHON], [test "x$with_python" != "xno"])
-
-dnl check for dso support
-WITH_MODULES=0
-
-if test "$with_modules" != "no" ; then
- case "$host" in
-  *-*-cygwin*)
-  MODULE_EXTENSION=".dll"
-  AC_CHECK_LIB(cygwin, dlopen, [
-    WITH_MODULES=1
-    MODULE_PLATFORM_LIBS=
-    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
-  ])
-  ;;
-  *-*-mingw*)
-  MODULE_EXTENSION=".dll"
-  WITH_MODULES=1
-  ;;
-  *)
-  AC_CHECK_FUNC(shl_load, libxml_have_shl_load=yes, [
-    AC_CHECK_LIB(dld, shl_load, [
-      MODULE_PLATFORM_LIBS="-ldld"
-      libxml_have_shl_load=yes], [
-      AC_CHECK_FUNC(dlopen, libxml_have_dlopen=yes, [
-        AC_CHECK_LIB(dl, dlopen, [
-          MODULE_PLATFORM_LIBS="-ldl"
-          libxml_have_dlopen=yes])])])])
-
-  if test "${libxml_have_shl_load}" = "yes"; then
-    MODULE_EXTENSION=".sl"
-    WITH_MODULES=1
-    AC_DEFINE([HAVE_SHLLOAD], [], [Have shl_load based dso])
-  fi
-  if test "${libxml_have_dlopen}" = "yes"; then
-    case "${host}" in
-      *-*-hpux* )
-       MODULE_EXTENSION=".sl"
-       ;;
-      * )
-       MODULE_EXTENSION=".so"
-       ;;
-    esac
-
-    WITH_MODULES=1
-    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
-  fi
- ;;
- esac
-fi
-
-AC_SUBST(WITH_MODULES)
-AC_SUBST(MODULE_PLATFORM_LIBS)
-AC_SUBST(MODULE_EXTENSION)
-
-dnl
-dnl Check for trio string functions
-dnl
-
-if test "${NEED_TRIO}" = "1" ; then
-    echo Adding trio library for string functions
-    WITH_TRIO=1
-else    
-    WITH_TRIO=0
-fi
-AM_CONDITIONAL(WITH_TRIO_SOURCES, test "${NEED_TRIO}" = "1")
-AC_SUBST(WITH_TRIO)
-
-dnl
-dnl Allow to enable/disable various pieces
-dnl
-echo Checking configuration requirements
-
-dnl
-dnl Thread-related stuff
-dnl
-THREAD_LIBS=""
-BASE_THREAD_LIBS=""
-WITH_THREADS=0
-THREAD_CFLAGS=""
-THREADS_W32=""
-WITH_THREAD_ALLOC=0
-
-if test "$with_threads" = "no" ; then
-    echo Disabling multithreaded support
-else
-    echo Enabling multithreaded support
-
-    dnl Default to native threads on Windows
-    case $host_os in
-       *mingw*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
-               WITH_THREADS="1"
-               THREADS_W32="1"
-               THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
-           fi
-       ;;
-    esac
-
-    dnl Use pthread by default in other cases
-    if test -z "$THREADS_W32"; then
-        if test "$with_threads" = "pthread" || test "$with_threads" = "" || test "$with_threads" = "yes" ; then
-            AC_CHECK_HEADER(pthread.h,
-                AC_CHECK_LIB(pthread, pthread_join,[
-                THREAD_LIBS="-lpthread"
-                AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
-                WITH_THREADS="1"]))
-        fi
-    fi
-
-    case $host_os in
-       *cygwin*) THREAD_LIBS=""
-       ;;
-       *beos*) WITH_THREADS="1"
-          THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_BEOS_THREADS"
-       ;;
-       *linux*)
-           if test "${GCC}" = "yes" ; then
-              GCC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
-              GCC_MAJOR=`echo ${GCC_VERSION} | sed 's+\..*++'`
-              GCC_MEDIUM=`echo ${GCC_VERSION} | sed 's+[[0-9]]*\.++' | sed 's+\..*++'`
-              if test "${THREAD_LIBS}" = "-lpthread" ; then
-                  if expr ${GCC_MEDIUM} \> 2 \& ${GCC_MAJOR} = 3 > /dev/null
-                  then
-                      THREAD_LIBS=""
-                      BASE_THREAD_LIBS="-lpthread"
-                  else
-                  if expr ${GCC_MAJOR} \> 3 > /dev/null
-                  then
-                      THREAD_LIBS=""
-                      BASE_THREAD_LIBS="-lpthread"
-                  else
-                      echo old GCC disabling weak symbols for pthread
-                  fi
-                  fi
-              fi
-          fi
-       ;;
-    esac
-    if test "$WITH_THREADS" = "1" ; then
-       THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
-    fi
-fi
-if test "$with_thread_alloc" = "yes" && test "$WITH_THREADS" = "1" ; then
-    WITH_THREAD_ALLOC=1
-fi
-
-AC_SUBST(THREAD_LIBS)
-AC_SUBST(BASE_THREAD_LIBS)
-AC_SUBST(WITH_THREADS)
-AC_SUBST(THREAD_CFLAGS)
-AC_SUBST(WITH_THREAD_ALLOC)
-AM_CONDITIONAL([THREADS_W32],[test -n "$THREADS_W32"])
-
-dnl
-dnl xmllint shell history
-dnl
-if test "$with_history" = "yes" ; then
-    echo Enabling xmllint shell history
-    dnl check for terminal library. this is a very cool solution
-    dnl from octave's configure.in
-    unset tcap
-    for termlib in ncurses curses termcap terminfo termlib; do
-       AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
-       test -n "$tcap" && break
-    done
-
-    AC_CHECK_HEADER(readline/history.h,
-       AC_CHECK_LIB(history, append_history,[
-          RDL_LIBS="-lhistory"
-          AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
-    AC_CHECK_HEADER(readline/readline.h,
-       AC_CHECK_LIB(readline, readline,[
-          RDL_LIBS="-lreadline $RDL_LIBS $tcap"
-          AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
-    if test -n "$RDL_DIR" && test -n "$RDL_LIBS"; then
-       CPPFLAGS="$CPPFLAGS -I${RDL_DIR}/include"
-       RDL_LIBS="-L${RDL_DIR}/lib $RDL_LIBS"
-    fi
-fi
-
-dnl
-dnl Tree functions
-dnl
 if test "$with_tree" = "no" ; then
     echo Disabling DOM like tree manipulation APIs
     WITH_TREE=0
-else    
+else
     WITH_TREE=1
 fi
 AC_SUBST(WITH_TREE)
 
 if test "$with_ftp" != "yes" ; then
-    echo Disabling FTP support
     WITH_FTP=0
-    FTP_OBJ=
-else    
+else
+    echo Enabling FTP support
     WITH_FTP=1
-    FTP_OBJ=nanoftp.o
 fi
 AC_SUBST(WITH_FTP)
-AC_SUBST(FTP_OBJ)
+AM_CONDITIONAL(WITH_FTP_SOURCES, test "$WITH_FTP" = "1")
 
 if test "$with_http" = "no" ; then
     echo Disabling HTTP support
     WITH_HTTP=0
-    HTTP_OBJ=
-else    
+else
     WITH_HTTP=1
-    HTTP_OBJ=nanohttp.o
 fi
 AC_SUBST(WITH_HTTP)
-AC_SUBST(HTTP_OBJ)
+AM_CONDITIONAL(WITH_HTTP_SOURCES, test "$WITH_HTTP" = "1")
 
 if test "$with_legacy" != "yes" ; then
-    echo Disabling deprecated APIs
     WITH_LEGACY=0
-else    
+else
+    echo Enabling deprecated APIs
     WITH_LEGACY=1
 fi
 AC_SUBST(WITH_LEGACY)
+AM_CONDITIONAL(WITH_LEGACY_SOURCES, test "$WITH_LEGACY" = "1")
 
 if test "$with_reader" = "no" ; then
     echo Disabling the xmlReader parsing interface
     WITH_READER=0
-else    
+else
     WITH_READER=1
-    if test "$with_push" = "no" ; then
-        echo xmlReader requires Push interface - enabling it
-       with_push=yes
-    fi
 fi
 AC_SUBST(WITH_READER)
+AM_CONDITIONAL(WITH_READER_SOURCES, test "$WITH_READER" = "1")
 
 if test "$with_writer" = "no" ; then
     echo Disabling the xmlWriter saving interface
     WITH_WRITER=0
-#    WRITER_TEST=
-else    
+else
     WITH_WRITER=1
-#    WRITER_TEST=Writertests
-    if test "$with_push" = "no" ; then
-        echo xmlWriter requires Push interface - enabling it
-       with_push=yes
-    fi
-    if test "$with_output" = "no" ; then
-        echo xmlWriter requires Output interface - enabling it
-       with_output=yes
-    fi
 fi
 AC_SUBST(WITH_WRITER)
-#AC_SUBST(WRITER_TEST)
+AM_CONDITIONAL(WITH_WRITER_SOURCES, test "$WITH_WRITER" = "1")
 
 if test "$with_pattern" = "no" ; then
     echo Disabling the xmlPattern parsing interface
     WITH_PATTERN=0
-else    
+else
     WITH_PATTERN=1
 fi
 AC_SUBST(WITH_PATTERN)
+AM_CONDITIONAL(WITH_PATTERN_SOURCES, test "$WITH_PATTERN" = "1")
 
 if test "$with_sax1" = "no" ; then
     echo Disabling the older SAX1 interface
     WITH_SAX1=0
-else    
+else
     WITH_SAX1=1
 fi
 AC_SUBST(WITH_SAX1)
+AM_CONDITIONAL(WITH_SAX1_SOURCES, test "$WITH_SAX1" = "1")
 
 if test "$with_push" = "no" ; then
     echo Disabling the PUSH parser interfaces
     WITH_PUSH=0
-else    
+else
     WITH_PUSH=1
 fi
 AC_SUBST(WITH_PUSH)
@@ -1040,296 +635,127 @@ AC_SUBST(WITH_PUSH)
 if test "$with_html" = "no" ; then
     echo Disabling HTML support
     WITH_HTML=0
-    HTML_OBJ=
-else    
+else
     WITH_HTML=1
-    HTML_OBJ="HTMLparser.o HTMLtree.o"
 fi
 AC_SUBST(WITH_HTML)
-AC_SUBST(HTML_OBJ)
+AM_CONDITIONAL(WITH_HTML_SOURCES, test "$WITH_HTML" = "1")
 
 if test "$with_valid" = "no" ; then
     echo Disabling DTD validation support
     WITH_VALID=0
-    TEST_VTIME=
-else    
+else
     WITH_VALID=1
-    TEST_VTIME=VTimingtests
 fi
 AC_SUBST(WITH_VALID)
-AC_SUBST(TEST_VALID)
-AC_SUBST(TEST_VTIME)
+AM_CONDITIONAL(WITH_VALID_SOURCES, test "$WITH_VALID" = "1")
 
 if test "$with_catalog" = "no" ; then
     echo Disabling Catalog support
     WITH_CATALOG=0
-    CATALOG_OBJ=
-    TEST_CATALOG=
-else    
+else
     WITH_CATALOG=1
-    CATALOG_OBJ="catalog.o"
-    TEST_CATALOG=Catatests
 fi
 AC_SUBST(WITH_CATALOG)
-AC_SUBST(CATALOG_OBJ)
-AC_SUBST(TEST_CATALOG)
+AM_CONDITIONAL(WITH_CATALOG_SOURCES, test "$WITH_CATALOG" = "1")
 
 if test "$with_xptr" = "no" ; then
     echo Disabling XPointer support
     WITH_XPTR=0
     WITH_XPTR_LOCS=0
-    XPTR_OBJ=
-else    
+else
     WITH_XPTR=1
-    XPTR_OBJ=xpointer.o
-    if test "$with_xpath" = "no" ; then
-        echo XPointer requires XPath support - enabling it
-       with_xpath=yes
-    fi
-    if test "$with_xptr_locs" = "yes" ; then
-        WITH_XPTR_LOCS=1
-    else
-        WITH_XPTR_LOCS=0
-    fi
 fi
 AC_SUBST(WITH_XPTR)
+AM_CONDITIONAL(WITH_XPTR_SOURCES, test "$WITH_XPTR" = "1")
+
+if test "$with_xptr_locs" != "yes" ; then
+    WITH_XPTR_LOCS=0
+else
+    echo Enabling Xpointer locations support
+    WITH_XPTR_LOCS=1
+fi
 AC_SUBST(WITH_XPTR_LOCS)
-AC_SUBST(XPTR_OBJ)
 
 if test "$with_c14n" = "no" ; then
     echo Disabling C14N support
     WITH_C14N=0
-    C14N_OBJ=
-else    
+else
     WITH_C14N=1
-    C14N_OBJ="c14n.c"
-    if test "$with_xpath" = "no" ; then
-        echo C14N requires XPath support - enabling it
-       with_xpath=yes
-    fi
 fi
 AC_SUBST(WITH_C14N)
-AC_SUBST(C14N_OBJ)
+AM_CONDITIONAL(WITH_C14N_SOURCES, test "$WITH_C14N" = "1")
 
 if test "$with_xinclude" = "no" ; then
     echo Disabling XInclude support
     WITH_XINCLUDE=0
-    XINCLUDE_OBJ=
-    with_xinclude="no"
-else    
+else
     WITH_XINCLUDE=1
-    XINCLUDE_OBJ=xinclude.o
-    if test "$with_xpath" = "no" ; then
-        echo XInclude requires XPath support - enabling it
-       with_xpath=yes
-    fi
 fi
 AC_SUBST(WITH_XINCLUDE)
-AC_SUBST(XINCLUDE_OBJ)
-
-if test "$with_xptr" = "" && test "$with_xpath" = "no" ; then
-    with_xptr=no
-fi
-
-if test "$with_schematron" = "" && test "$with_xpath" = "no" ; then
-    with_schematron=no
-fi
+AM_CONDITIONAL(WITH_XINCLUDE_SOURCES, test "$WITH_XINCLUDE" = "1")
 
 if test "$with_schematron" = "no" ; then
     echo "Disabling Schematron support"
     WITH_SCHEMATRON=0
-    TEST_SCHEMATRON=
-else 
-    echo "Enabled Schematron support"
+else
     WITH_SCHEMATRON=1
-    TEST_SCHEMATRON="Schematrontests"
-    with_xpath=yes
-    with_pattern=yes
-    with_schematron=yes
 fi
 AC_SUBST(WITH_SCHEMATRON)
-AC_SUBST(TEST_SCHEMATRON)
+AM_CONDITIONAL(WITH_SCHEMATRON_SOURCES, test "$WITH_SCHEMATRON" = "1")
 
 if test "$with_xpath" = "no" ; then
     echo Disabling XPATH support
     WITH_XPATH=0
-    XPATH_OBJ=
-else    
+else
     WITH_XPATH=1
-    XPATH_OBJ=xpath.o
 fi
 AC_SUBST(WITH_XPATH)
-AC_SUBST(XPATH_OBJ)
+AM_CONDITIONAL(WITH_XPATH_SOURCES, test "$WITH_XPATH" = "1")
 
-dnl
-dnl output functions
-dnl
 if test "$with_output" = "no" ; then
     echo Disabling serialization/saving support
     WITH_OUTPUT=0
-else    
+else
     WITH_OUTPUT=1
 fi
 AC_SUBST(WITH_OUTPUT)
+AM_CONDITIONAL(WITH_OUTPUT_SOURCES, test "$WITH_OUTPUT" = "1")
 
-WITH_ICONV=0
-if test "$with_iconv" = "no" ; then
-    echo Disabling ICONV support
-else
-    if test "$with_iconv" != "yes" && test "$with_iconv" != "" ; then
-       CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
-       # Export this since our headers include iconv.h
-       XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
-       ICONV_LIBS="-L$with_iconv/lib"
-    fi
-
-    AC_CHECK_HEADER(iconv.h,
-       AC_MSG_CHECKING(for iconv)
-       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
-#include <iconv.h>]],[[
-iconv_t cd = iconv_open ("","");
-iconv (cd, NULL, NULL, NULL, NULL);]])],[
-           AC_MSG_RESULT(yes)
-           WITH_ICONV=1],[
-           AC_MSG_RESULT(no)
-           AC_MSG_CHECKING(for iconv in -liconv)
-
-           _ldflags="${LDFLAGS}"
-           _libs="${LIBS}"
-           LDFLAGS="${LDFLAGS} ${ICONV_LIBS}"
-           LIBS="${LIBS} -liconv"
-
-           AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
-#include <iconv.h>]],[[
-iconv_t cd = iconv_open ("","");
-iconv (cd, NULL, NULL, NULL, NULL);]])],[
-               AC_MSG_RESULT(yes)
-               WITH_ICONV=1
-               ICONV_LIBS="${ICONV_LIBS} -liconv"
-               LIBS="${_libs}"
-               LDFLAGS="${_ldflags}"],[
-               AC_MSG_RESULT(no)
-               LIBS="${_libs}"
-               LDFLAGS="${_ldflags}"])]))
-fi
-AC_SUBST(WITH_ICONV)
-
-WITH_ICU=0
-ICU_LIBS=""
-if test "$with_icu" != "yes" ; then
-    echo Disabling ICU support
-else
-    # Try pkg-config first so that static linking works.
-    # If this succeeeds, we ignore the WITH_ICU directory.
-    PKG_CHECK_MODULES([ICU],[icu-i18n],
-        [have_libicu=yes],
-        [have_libicu=no])
-
-    if test "x$have_libicu" = "xyes"; then
-        m4_ifdef([PKG_CHECK_VAR],
-            [PKG_CHECK_VAR([ICU_DEFS], [icu-i18n], [DEFS])])
-        if test "x$ICU_DEFS" != "x"; then
-            CPPFLAGS="$CPPFLAGS $ICU_DEFS"
-        fi
-    fi
-
-    # If pkg-config failed, fall back to AC_CHECK_LIB. This
-    # will not pick up the necessary LIBS flags for liblzma's
-    # private dependencies, though, so static linking may fail.
-    if test "x$have_libicu" = "xno"; then
-        ICU_CONFIG=icu-config
-        if ${ICU_CONFIG} --cflags >/dev/null 2>&1
-        then
-            ICU_LIBS=`${ICU_CONFIG} --ldflags`
-            have_libicu=yes
-            echo Enabling ICU support
-        else
-            if test "$with_icu" != "yes" && test "$with_iconv" != "" ; then
-                CPPFLAGS="${CPPFLAGS} -I$with_icu"
-            fi
-
-            AC_CHECK_HEADER(unicode/ucnv.h,
-            AC_MSG_CHECKING(for icu)
-            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unicode/ucnv.h>]], [[
-        UConverter *utf = ucnv_open("UTF-8", NULL);]])],[
-                AC_MSG_RESULT(yes)
-                have_libicu=yes],[
-                AC_MSG_RESULT(no)
-                AC_MSG_CHECKING(for icu in -licucore)
-
-                _ldflags="${LDFLAGS}"
-                _libs="${LIBS}"
-                LDFLAGS="${LDFLAGS} ${ICU_LIBS}"
-                LIBS="${LIBS} -licucore"
-
-                AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unicode/ucnv.h>]], [[
-        UConverter *utf = ucnv_open("UTF-8", NULL);]])],[
-                    AC_MSG_RESULT(yes)
-                    have_libicu=yes
-                    ICU_LIBS="${ICU_LIBS} -licucore"
-                    LIBS="${_libs}"
-                    LDFLAGS="${_ldflags}"],[
-                    AC_MSG_RESULT(no)
-                    LIBS="${_libs}"
-                LDFLAGS="${_ldflags}"])]))
-        fi
-    fi
-
-    # Found the library via either method?
-    if test "x$have_libicu" = "xyes"; then
-        WITH_ICU=1
-    fi
-fi
-XML_LIBS="-lxml2"
-XML_LIBTOOLLIBS="libxml2.la"
-AC_SUBST(WITH_ICU)
-
-WITH_ISO8859X=1
-if test "$WITH_ICONV" != "1" ; then
-if test "$with_iso8859x" = "no" ; then
+if test "$WITH_ICONV" != "1" && test "$with_iso8859x" = "no" ; then
     echo Disabling ISO8859X support
     WITH_ISO8859X=0
-fi
+else
+    WITH_ISO8859X=1
 fi
 AC_SUBST(WITH_ISO8859X)
 
 if test "$with_schemas" = "no" ; then
     echo "Disabling Schemas/Relax-NG support"
     WITH_SCHEMAS=0
-else    
-    echo "Enabled Schemas/Relax-NG support"
+else
     WITH_SCHEMAS=1
-    AS_IF([test "x$with_python" != "xno"], [
-        PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests"
-    ])
-    with_regexps=yes
 fi
 AC_SUBST(WITH_SCHEMAS)
+AM_CONDITIONAL(WITH_SCHEMAS_SOURCES, test "$WITH_SCHEMAS" = "1")
 
 if test "$with_regexps" = "no" ; then
     echo Disabling Regexps support
     WITH_REGEXPS=0
-    TEST_REGEXPS=
-else    
+else
     WITH_REGEXPS=1
-    TEST_REGEXPS="Automatatests"
 fi
 AC_SUBST(WITH_REGEXPS)
-AC_SUBST(TEST_REGEXPS)
+AM_CONDITIONAL(WITH_REGEXPS_SOURCES, test "$WITH_REGEXPS" = "1")
 
 if test "$with_debug" = "no" ; then
     echo Disabling DEBUG support
     WITH_DEBUG=0
-    DEBUG_OBJ=
-    TEST_DEBUG=
-else    
+else
     WITH_DEBUG=1
-    DEBUG_OBJ=debugXML.o
-    TEST_DEBUG=Scripttests
 fi
 AC_SUBST(WITH_DEBUG)
-AC_SUBST(DEBUG_OBJ)
-AC_SUBST(TEST_DEBUG)
+AM_CONDITIONAL(WITH_DEBUG_SOURCES, test "$WITH_DEBUG" = "1")
 
 if test "$with_mem_debug" = "yes" ; then
     if test "$with_thread_alloc" = "yes" ; then
@@ -1339,107 +765,459 @@ if test "$with_mem_debug" = "yes" ; then
         echo Enabling memory debug support
         WITH_MEM_DEBUG=1
     fi
-else    
+else
     WITH_MEM_DEBUG=0
 fi
 AC_SUBST(WITH_MEM_DEBUG)
 
-if test "$with_run_debug" = "yes" ; then
-    echo Enabling runtime debug support
-    WITH_RUN_DEBUG=1
-else    
-    WITH_RUN_DEBUG=0
+dnl
+dnl Check for Python
+dnl
+
+AS_IF([test "x$with_python" != "xno"], [
+    AM_PATH_PYTHON
+    PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
+])
+AM_CONDITIONAL([WITH_PYTHON], [test "x$with_python" != "xno"])
+
+dnl
+dnl Extra Python flags for Windows
+dnl
+PYTHON_LDFLAGS=
+if test "${PYTHON}" != ""; then
+    case "$host" in
+        *-*-mingw* )
+            PYTHON_LDFLAGS="-no-undefined -shrext .pyd"
+            ;;
+        *-*-cygwin* |*-*-msys* )
+            PYTHON_LDFLAGS="-no-undefined"
+            ;;
+    esac
 fi
-AC_SUBST(WITH_RUN_DEBUG)
-
-WIN32_EXTRA_LIBADD=
-WIN32_EXTRA_LDFLAGS=
-CYGWIN_EXTRA_LDFLAGS=
-CYGWIN_EXTRA_PYTHON_LIBADD=
-WIN32_EXTRA_PYTHON_LIBADD=
-case "$host" in
- *-*-mingw*)
- CPPFLAGS="$CPPFLAGS -DWIN32"
- WIN32_EXTRA_LIBADD="-lws2_32"
- WIN32_EXTRA_LDFLAGS="-no-undefined"
- if test "${PYTHON}" != ""
- then
-   case "$host" in
-     *-w64-mingw*)
-       WIN32_EXTRA_PYTHON_LIBADD="-shrext .pyd -L${pythondir}/../../lib -lpython${PYTHON_VERSION}"
-       ;;
-     *)
-       WIN32_EXTRA_PYTHON_LIBADD="-L${pythondir}/../../libs -lpython$(echo ${PYTHON_VERSION} | tr -d .)"
-       ;;
-   esac
- fi
- ;;
- *-*-cygwin*)
- CYGWIN_EXTRA_LDFLAGS="-no-undefined"
- if test "${PYTHON}" != ""
- then
-   CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
- fi
- ;;
-esac
+AC_SUBST(PYTHON_LDFLAGS)
+
+dnl
+dnl Check for DSO support
+dnl
+WITH_MODULES=0
+
+if test "$with_modules" != "no" ; then
+    case "$host" in
+        *-*-cygwin* | *-*-msys* )
+            MODULE_EXTENSION=".dll"
+            ;;
+        *-*-mingw*)
+            MODULE_EXTENSION=".dll"
+            WITH_MODULES=1
+            ;;
+        *-*-hpux*)
+           MODULE_EXTENSION=".sl"
+           ;;
+        *)
+           MODULE_EXTENSION=".so"
+           ;;
+    esac
 
-XML_PRIVATE_LIBS="$Z_LIBS $LZMA_LIBS $THREAD_LIBS $ICONV_LIBS $ICU_LIBS $LIBM $WIN32_EXTRA_LIBADD"
+    if test "$WITH_MODULES" = "0"; then
+        _libs=$LIBS
+        AC_SEARCH_LIBS([dlopen], [dl], [
+            WITH_MODULES=1
+            if test "$ac_cv_search_dlopen" != "none required"; then
+                MODULE_PLATFORM_LIBS=$ac_cv_search_dlopen
+            fi
+            AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])], [
+            AC_SEARCH_LIBS([shl_load], [dld], [
+                WITH_MODULES=1
+                if test "$ac_cv_search_shl_load" != "none required"; then
+                    MODULE_PLATFORM_LIBS=$ac_cv_search_shl_load
+                fi
+                AC_DEFINE([HAVE_SHLLOAD], [], [Have shl_load based dso])])])
+        LIBS=$_libs
+    fi
+fi
 
-AC_SUBST(WIN32_EXTRA_LIBADD)
-AC_SUBST(WIN32_EXTRA_LDFLAGS)
-AC_SUBST(WIN32_EXTRA_PYTHON_LIBADD)
-AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
-AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
+AC_SUBST(WITH_MODULES)
+AC_SUBST(MODULE_PLATFORM_LIBS)
+AC_SUBST(MODULE_EXTENSION)
+AM_CONDITIONAL(WITH_MODULES_SOURCES, test "$WITH_MODULES" = "1")
 
-dnl Checking the standard string functions availability
 dnl
-dnl Note mingw* has C99 implementation that produce expected xml numbers
-dnl if code use {v}snprintf functions.
-dnl If you like to activate at run-time C99 compatible number output
-dnl see release note for mingw runtime 3.15:
-dnl  http://sourceforge.net/project/shownotes.php?release_id=24832
+dnl Check for trio string functions
 dnl
-dnl Also *win32*config.h files redefine them for various MSC compilers.
+if test "${NEED_TRIO}" = "1" ; then
+    echo Adding trio library for string functions
+    WITH_TRIO=1
+else
+    WITH_TRIO=0
+fi
+AM_CONDITIONAL(WITH_TRIO_SOURCES, test "${NEED_TRIO}" = "1")
+AC_SUBST(WITH_TRIO)
+
 dnl
-dnl So do not redefine {v}snprintf to _{v}snprintf like following:
-dnl  AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
-dnl  AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])
-dnl and do not redefine those functions is C-source files.
+dnl Thread-related stuff
 dnl
-AC_CHECK_FUNCS(snprintf vsnprintf,,
-       NEED_TRIO=1)
+THREAD_LIBS=""
+BASE_THREAD_LIBS=""
+WITH_THREADS=0
+THREAD_CFLAGS=""
+WITH_THREAD_ALLOC=0
+
+if test "$with_threads" = "no" ; then
+    echo Disabling multithreaded support
+else
+    case $host_os in
+        *mingw*)
+            dnl Default to native threads on Windows
+            WITH_THREADS="1"
+            ;;
+        *)
+            dnl Use pthread by default in other cases
+            _libs=$LIBS
+            AC_CHECK_HEADERS(pthread.h,
+                AC_SEARCH_LIBS([pthread_join], [pthread], [
+                    WITH_THREADS="1"
+                    if test "$ac_cv_search_pthread_join" != "none required"; then
+                        THREAD_LIBS=$ac_cv_search_pthread_join
+                    fi
+                    AC_DEFINE([HAVE_PTHREAD_H], [],
+                              [Define if <pthread.h> is there])]))
+            LIBS=$_libs
+            ;;
+    esac
+
+    case $host_os in
+        *linux*)
+            if test "${GCC}" = "yes" ; then
+                BASE_THREAD_LIBS="$THREAD_LIBS"
+                THREAD_LIBS=""
+            fi
+            ;;
+    esac
+
+    if test "$WITH_THREADS" = "1" ; then
+       THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
+    fi
+fi
+if test "$with_thread_alloc" = "yes" && test "$WITH_THREADS" = "1" ; then
+    WITH_THREAD_ALLOC=1
+fi
+
+AC_SUBST(THREAD_LIBS)
+AC_SUBST(BASE_THREAD_LIBS)
+AC_SUBST(WITH_THREADS)
+AC_SUBST(THREAD_CFLAGS)
+AC_SUBST(WITH_THREAD_ALLOC)
+
+dnl
+dnl xmllint shell history
+dnl
+if test "$with_history" = "yes" && test "$with_readline" != "no"; then
+    echo Enabling xmllint shell history
+    dnl check for terminal library. this is a very cool solution
+    dnl from octave's configure.in
+    unset tcap
+    for termlib in ncurses curses termcap terminfo termlib; do
+       AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
+       test -n "$tcap" && break
+    done
+
+    _cppflags=$CPPFLAGS
+    _libs=$LIBS
+    if test "$with_readline" != "" && test "$with_readline" != "yes"; then
+        RDL_DIR=$with_readline
+        CPPFLAGS="${CPPFLAGS} -I$RDL_DIR/include"
+        LIBS="${LIBS} -L$RDL_DIR/lib"
+    fi
+    AC_CHECK_HEADER(readline/history.h,
+       AC_CHECK_LIB(history, append_history,[
+           RDL_LIBS="-lhistory"
+            if test "x${RDL_DIR}" != "x"; then
+                RDL_CFLAGS="-I$RDL_DIR/include"
+                RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
+            fi
+           AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
+    AC_CHECK_HEADER(readline/readline.h,
+       AC_CHECK_LIB(readline, readline,[
+           RDL_LIBS="-lreadline $RDL_LIBS $tcap"
+            if test "x$RDL_DIR" != "x"; then
+                RDL_CFLAGS="-I$RDL_DIR/include"
+                RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
+            fi
+           AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
+    CPPFLAGS=$_cppflags
+    LIBS=$_libs
+fi
+AC_SUBST(RDL_CFLAGS)
+AC_SUBST(RDL_LIBS)
+
+dnl
+dnl Checks for zlib library.
+dnl
+WITH_ZLIB=0
+
+if test "$with_zlib" = "no"; then
+    echo "Disabling zlib compression support"
+else
+    if test "$with_zlib" != "yes"; then
+        Z_DIR=$with_zlib
+    fi
+
+    # Don't run pkg-config if with_zlib contains a path.
+    if test "x$Z_DIR" = "x"; then
+        # Try pkg-config first so that static linking works.
+        PKG_CHECK_MODULES([Z],[zlib],
+            [WITH_ZLIB=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} zlib"],
+            [:])
+    fi
+
+    if test "$WITH_ZLIB" = "0"; then
+        _cppflags=$CPPFLAGS
+        _libs=$LIBS
+        if test "x$Z_DIR" != "x"; then
+            CPPFLAGS="${CPPFLAGS} -I$Z_DIR/include"
+            LIBS="${LIBS} -L$Z_DIR/lib"
+        fi
+        AC_CHECK_HEADERS(zlib.h,
+            AC_CHECK_LIB(z, gzread,[
+                WITH_ZLIB=1
+                if test "x${Z_DIR}" != "x"; then
+                    Z_CFLAGS="-I${Z_DIR}/include"
+                    Z_LIBS="-L${Z_DIR}/lib -lz"
+                    [case ${host} in
+                        *-*-solaris*)
+                            Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
+                            ;;
+                    esac]
+                else
+                    Z_LIBS="-lz"
+                fi])
+                XML_PC_LIBS="${XML_PC_LIBS} ${Z_LIBS}"
+            )
+        CPPFLAGS=$_cppflags
+        LIBS=$_libs
+    fi
+
+    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${Z_CFLAGS}"
+    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${Z_LIBS}"
+fi
+AC_SUBST(WITH_ZLIB)
+
+dnl
+dnl Checks for lzma library.
+dnl
+WITH_LZMA=0
+
+if test "$with_lzma" = "no"; then
+    echo "Disabling lzma compression support"
+else
+    if test "$with_lzma" != "yes"; then
+        LZMA_DIR=$with_lzma
+    fi
+
+    # Don't run pkg-config if with_lzma contains a path.
+    if test "x$LZMA_DIR" = "x"; then
+        # Try pkg-config first so that static linking works.
+        PKG_CHECK_MODULES([LZMA],[liblzma],
+            [WITH_LZMA=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} liblzma"],
+            [:])
+    fi
+
+    # If pkg-config failed, fall back to AC_CHECK_LIB. This
+    # will not pick up the necessary LIBS flags for liblzma's
+    # private dependencies, though, so static linking may fail.
+    if test "$WITH_LZMA" = "0"; then
+        _cppflags=$CPPFLAGS
+        _libs=$LIBS
+        if test "x$LZMA_DIR" != "x"; then
+            CPPFLAGS="${CPPFLAGS} -I$LZMA_DIR/include"
+            LIBS="${LIBS} -L$LZMA_DIR/lib"
+        fi
+        AC_CHECK_HEADERS(lzma.h,
+            AC_CHECK_LIB(lzma, lzma_code,[
+                WITH_LZMA=1
+                if test "x${LZMA_DIR}" != "x"; then
+                    LZMA_CFLAGS="-I${LZMA_DIR}/include"
+                    LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
+                else
+                    LZMA_LIBS="-llzma"
+                fi])
+                XML_PC_LIBS="${XML_PC_LIBS} ${LZMA_LIBS}"
+            )
+        CPPFLAGS=$_cppflags
+        LIBS=$_libs
+    fi
+
+    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${LZMA_CFLAGS}"
+    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${LZMA_LIBS}"
+fi
+AC_SUBST(WITH_LZMA)
+AM_CONDITIONAL(WITH_LZMA_SOURCES, test "$WITH_LZMA" = "1")
+
+dnl
+dnl Checks for iconv library.
+dnl
+WITH_ICONV=0
+
+if test "$with_iconv" = "no" ; then
+    echo Disabling ICONV support
+else
+    _cppflags=$CPPFLAGS
+    _libs=$LIBS
+    if test "$with_iconv" != "yes" && test "$with_iconv" != "" ; then
+       ICONV_DIR=$with_iconv
+       CPPFLAGS="$CPPFLAGS -I$ICONV_DIR/include"
+       LIBS="$LIBS -L$ICONV_DIR/lib"
+    fi
+    AC_MSG_CHECKING([for libiconv])
+    AC_LINK_IFELSE([
+        AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0,0);])
+    ], [
+        WITH_ICONV=1
+        AC_MSG_RESULT([none required])
+    ], [
+        LIBS="$LIBS -liconv"
+        AC_LINK_IFELSE([
+            AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0,0);])
+        ], [
+            WITH_ICONV=1
+            ICONV_LIBS="-liconv"
+            AC_MSG_RESULT([yes])
+        ], [
+            AC_MSG_RESULT([no])
+        ])
+    ])
+    if test "$WITH_ICONV" = "1" && test "$ICONV_DIR" != ""; then
+        ICONV_CFLAGS="-I$ICONV_DIR/include"
+        ICONV_LIBS="-L$ICONV_DIR/lib $ICONV_LIBS"
+       # Export this since our headers include iconv.h
+       XML_INCLUDEDIR="$XML_INCLUDEDIR -I$ICONV_DIR/include"
+    fi
+    CPPFLAGS=$_cppflags
+    LIBS=$_libs
+fi
+AC_SUBST(WITH_ICONV)
+AC_SUBST(ICONV_CFLAGS)
+
+dnl
+dnl Checks for ICU library.
+dnl
+WITH_ICU=0
+
+if test "$with_icu" = "no" || test "$with_icu" = "" ; then
+    echo Disabling ICU support
+else
+    # Try pkg-config first so that static linking works.
+    # If this succeeeds, we ignore the WITH_ICU directory.
+    PKG_CHECK_MODULES([ICU], [icu-i18n], [
+        WITH_ICU=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} icu-i18n"
+        m4_ifdef([PKG_CHECK_VAR],
+            [PKG_CHECK_VAR([ICU_DEFS], [icu-i18n], [DEFS])])
+        if test "x$ICU_DEFS" != "x"; then
+            ICU_CFLAGS="$ICU_CFLAGS $ICU_DEFS"
+        fi],[:])
+
+    if test "$WITH_ICU" = "0"; then
+        ICU_CONFIG=icu-config
+        if ${ICU_CONFIG} --cflags >/dev/null 2>&1
+        then
+            WITH_ICU=1
+            ICU_CFLAGS=`${ICU_CONFIG} --cflags`
+            ICU_LIBS=`${ICU_CONFIG} --ldflags`
+            XML_PC_LIBS="${XML_PC_LIBS} ${ICU_LIBS}"
+        else
+            _cppflags="${CPPFLAGS}"
+            _libs="${LIBS}"
+            if test "$with_icu" != "yes" ; then
+                ICU_DIR=$with_icu
+                CPPFLAGS="${CPPFLAGS} -I$ICU_DIR/include"
+                LIBS="${LIBS} -L$ICU_DIR/lib"
+            fi
+
+            AC_CHECK_HEADER(unicode/ucnv.h, [
+                AC_CHECK_LIB([icucore], [ucnv_open], [
+                    WITH_ICU=1
+                    ICU_LIBS=-licucore
+                    if test "$ICU_DIR" != ""; then
+                        ICU_CFLAGS="-I$ICU_DIR/include"
+                        ICU_LIBS="-L$ICU_DIR/lib $ICU_LIBS"
+                    fi])])
+                    XML_PC_LIBS="${XML_PC_LIBS} ${ICU_LIBS}"
+            CPPFLAGS=$_cppflags
+            LIBS=$_libs
+        fi
+    fi
+
+    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${ICU_CFLAGS}"
+    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${ICU_LIBS}"
+fi
+AC_SUBST(WITH_ICU)
 
 if test "$with_coverage" = "yes" && test "${GCC}" = "yes"
 then
     echo Enabling code coverage for GCC
-    EXTRA_CFLAGS="$EXTRA_CFLAGS -fprofile-arcs -ftest-coverage"
-    LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
+    AM_CFLAGS="$AM_CFLAGS -fprofile-arcs -ftest-coverage"
+    AM_LDFLAGS="$AM_LDFLAGS -fprofile-arcs -ftest-coverage"
 else
     echo Disabling code coverage for GCC
 fi
 
-AC_SUBST(EXTRA_CFLAGS)
+XML_LIBS="-lxml2"
+XML_LIBTOOLLIBS="libxml2.la"
+NON_PC_LIBS="${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${NET_LIBS}"
+XML_PC_LIBS="${XML_PC_LIBS} ${NON_PC_LIBS}"
+XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${NON_PC_LIBS}"
+XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${THREAD_CFLAGS} ${ICONV_CFLAGS}"
+
+dnl When static-only:
+dnl * Duplicate xml-config static --libs into --dynamic.
+dnl * Fold pkg-config private fields into main fields.
+if test "x$enable_shared" = "xno"; then
+  XML_PRIVATE_LIBS_NO_SHARED="${XML_PRIVATE_LIBS}"
+  XML_PC_PRIVATE=
+  XML_PC_LIBS_PRIVATE=
+else
+  XML_PRIVATE_LIBS_NO_SHARED=
+  XML_PC_PRIVATE=".private"
+  XML_PC_LIBS_PRIVATE="
+Libs.private:"
+fi
+AC_SUBST(XML_PRIVATE_LIBS_NO_SHARED)
+AC_SUBST(XML_PC_PRIVATE)
+AC_SUBST(XML_PC_LIBS_PRIVATE)
+AM_SUBST_NOTMAKE(XML_PRIVATE_LIBS_NO_SHARED)
+AM_SUBST_NOTMAKE(XML_PC_PRIVATE)
+AM_SUBST_NOTMAKE(XML_PC_LIBS_PRIVATE)
+
+AC_SUBST(XML_PC_LIBS)
+AC_SUBST(XML_PC_REQUIRES)
+AM_SUBST_NOTMAKE(XML_PC_LIBS)
+AM_SUBST_NOTMAKE(XML_PC_REQUIRES)
+
+AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_LDFLAGS)
 AC_SUBST(XML_CFLAGS)
 
 AC_SUBST(XML_LIBDIR)
 AC_SUBST(XML_LIBS)
 AC_SUBST(XML_PRIVATE_LIBS)
+AC_SUBST(XML_PRIVATE_CFLAGS)
 AC_SUBST(XML_LIBTOOLLIBS)
-AC_SUBST(ICONV_LIBS)
-AC_SUBST(ICU_LIBS)
 AC_SUBST(XML_INCLUDEDIR)
 
-AC_SUBST(RDL_LIBS)
-
 dnl for the spec file
 RELDATE=`date +'%a %b %e %Y'`
 AC_SUBST(RELDATE)
-AC_SUBST(PYTHON_TESTS)
 
 # keep on one line for cygwin c.f. #130896
-AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake])
+AC_CONFIG_FILES([Makefile include/Makefile include/libxml/Makefile include/private/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake])
 AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py])
 AC_CONFIG_FILES([xml2-config], [chmod +x xml2-config])
 AC_OUTPUT
 
-echo Done configuring
+if test "$WARN_NO_TLS" != ""; then
+    echo "================================================================"
+    echo "WARNING: Your C compiler appears to not support thread-local"
+    echo "storage. Future versions of libxml2 will require this feature"
+    echo "for multi-threading."
+    echo "================================================================"
+fi
index f451c9d..303515e 100644 (file)
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
-#include <libxml/valid.h>
 #include <libxml/debugXML.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/HTMLparser.h>
 #include <libxml/xmlerror.h>
-#include <libxml/globals.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/uri.h>
 #ifdef LIBXML_SCHEMAS_ENABLED
 #include <libxml/relaxng.h>
 #endif
 
+#include "private/error.h"
+
 #define DUMP_TEXT_TYPE 1
 
 typedef struct _xmlDebugCtxt xmlDebugCtxt;
@@ -2633,7 +2633,7 @@ xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
     int res = -1;
 
     if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
-    vctxt.userData = NULL;
+    memset(&vctxt, 0, sizeof(vctxt));
     vctxt.error = xmlGenericError;
     vctxt.warning = xmlGenericError;
 
diff --git a/dict.c b/dict.c
index c29d2af..d7156ed 100644 (file)
--- a/dict.c
+++ b/dict.c
 #include "libxml.h"
 
 #include <limits.h>
-#include <stdlib.h>
+#include <string.h>
 #include <time.h>
 
-/*
- * Following http://www.ocert.org/advisories/ocert-2011-003.html
- * it seems that having hash randomization might be a good idea
- * when using XML with untrusted data
- * Note1: that it works correctly only if compiled with WITH_BIG_KEY
- *  which is the default.
- * Note2: the fast function used for a small dict won't protect very
- *  well but since the attack is based on growing a very big hash
- *  list we will use the BigKey algo as soon as the hash size grows
- *  over MIN_DICT_SIZE so this actually works
- */
-#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
-#define DICT_RANDOMIZATION
-#endif
+#include "private/dict.h"
+#include "private/threads.h"
 
-#include <string.h>
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#elif defined(_WIN32)
-typedef unsigned __int32 uint32_t;
-#endif
-#endif
-#include <libxml/tree.h>
+#include <libxml/parser.h>
 #include <libxml/dict.h>
 #include <libxml/xmlmemory.h>
-#include <libxml/xmlerror.h>
-#include <libxml/globals.h>
-
-/* #define DEBUG_GROW */
-/* #define DICT_DEBUG_PATTERNS */
-
-#define MAX_HASH_LEN 3
-#define MIN_DICT_SIZE 128
-#define MAX_DICT_HASH 8 * 2048
-#define WITH_BIG_KEY
-
-#ifdef WITH_BIG_KEY
-#define xmlDictComputeKey(dict, name, len)                              \
-    (((dict)->size == MIN_DICT_SIZE) ?                                  \
-     xmlDictComputeFastKey(name, len, (dict)->seed) :                   \
-     xmlDictComputeBigKey(name, len, (dict)->seed))
-
-#define xmlDictComputeQKey(dict, prefix, plen, name, len)               \
-    (((prefix) == NULL) ?                                               \
-      (xmlDictComputeKey(dict, name, len)) :                             \
-      (((dict)->size == MIN_DICT_SIZE) ?                                \
-       xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) : \
-       xmlDictComputeBigQKey(prefix, plen, name, len, (dict)->seed)))
-
-#else /* !WITH_BIG_KEY */
-#define xmlDictComputeKey(dict, name, len)                              \
-        xmlDictComputeFastKey(name, len, (dict)->seed)
-#define xmlDictComputeQKey(dict, prefix, plen, name, len)               \
-        xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed)
-#endif /* WITH_BIG_KEY */
+#include <libxml/xmlstring.h>
 
-/*
- * An entry in the dictionary
- */
-typedef struct _xmlDictEntry xmlDictEntry;
-typedef xmlDictEntry *xmlDictEntryPtr;
-struct _xmlDictEntry {
-    struct _xmlDictEntry *next;
-    const xmlChar *name;
-    unsigned int len;
-    int valid;
-    unsigned long okey;
-};
+#ifndef SIZE_MAX
+  #define SIZE_MAX ((size_t) -1)
+#endif
+
+#define MAX_FILL_NUM 7
+#define MAX_FILL_DENOM 8
+#define MIN_HASH_SIZE 8
+#define MAX_HASH_SIZE (1u << 31)
 
 typedef struct _xmlDictStrings xmlDictStrings;
 typedef xmlDictStrings *xmlDictStringsPtr;
@@ -105,20 +50,23 @@ struct _xmlDictStrings {
     size_t nbStrings;
     xmlChar array[1];
 };
+
+typedef xmlHashedString xmlDictEntry;
+
 /*
  * The entire dictionary
  */
 struct _xmlDict {
     int ref_counter;
 
-    struct _xmlDictEntry *dict;
+    xmlDictEntry *table;
     size_t size;
     unsigned int nbElems;
     xmlDictStringsPtr strings;
 
     struct _xmlDict *subdict;
     /* used for randomization */
-    int seed;
+    unsigned seed;
     /* used to impose a limit on size */
     size_t limit;
 };
@@ -127,107 +75,51 @@ struct _xmlDict {
  * A mutex for modifying the reference counter for shared
  * dictionaries.
  */
-static xmlMutexPtr xmlDictMutex = NULL;
-
-/*
- * Whether the dictionary mutex was initialized.
- */
-static int xmlDictInitialized = 0;
-
-#ifdef DICT_RANDOMIZATION
-#ifdef HAVE_RAND_R
-/*
- * Internal data for random function, protected by xmlDictMutex
- */
-static unsigned int rand_seed = 0;
-#endif
-#endif
+static xmlMutex xmlDictMutex;
 
 /**
  * xmlInitializeDict:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
+ * DEPRECATED: Alias for xmlInitParser.
  *
- * Do the dictionary mutex initialization.
- *
- * Returns 0 if initialization was already done, and 1 if that
- * call led to the initialization
+ * Returns 0.
  */
-int xmlInitializeDict(void) {
+int
+xmlInitializeDict(void) {
+    xmlInitParser();
     return(0);
 }
 
 /**
- * __xmlInitializeDict:
+ * xmlInitDictInternal:
  *
- * This function is not public
- * Do the dictionary mutex initialization.
- * this function is not thread safe, initialization should
- * normally be done once at setup when called from xmlOnceInit()
- * we may also land in this code if thread support is not compiled in
- *
- * Returns 0 if initialization was already done, and 1 if that
- * call led to the initialization
+ * Initialize mutex.
  */
-int __xmlInitializeDict(void) {
-    if (xmlDictInitialized)
-        return(1);
-
-    if ((xmlDictMutex = xmlNewMutex()) == NULL)
-        return(0);
-    xmlMutexLock(xmlDictMutex);
-
-#ifdef DICT_RANDOMIZATION
-#ifdef HAVE_RAND_R
-    rand_seed = time(NULL);
-    rand_r(& rand_seed);
-#else
-    srand(time(NULL));
-#endif
-#endif
-    xmlDictInitialized = 1;
-    xmlMutexUnlock(xmlDictMutex);
-    return(1);
-}
-
-#ifdef DICT_RANDOMIZATION
-int __xmlRandom(void) {
-    int ret;
-
-    if (xmlDictInitialized == 0)
-        __xmlInitializeDict();
-
-    xmlMutexLock(xmlDictMutex);
-#ifdef HAVE_RAND_R
-    ret = rand_r(& rand_seed);
-#else
-    ret = rand();
-#endif
-    xmlMutexUnlock(xmlDictMutex);
-    return(ret);
+void
+xmlInitDictInternal(void) {
+    xmlInitMutex(&xmlDictMutex);
 }
-#endif
 
 /**
  * xmlDictCleanup:
  *
- * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * DEPRECATED: This function is a no-op. Call xmlCleanupParser
  * to free global state but see the warnings there. xmlCleanupParser
  * should be only called once at program exit. In most cases, you don't
  * have call cleanup functions at all.
- *
- * Free the dictionary mutex. Do not call unless sure the library
- * is not in use anymore !
  */
 void
 xmlDictCleanup(void) {
-    if (!xmlDictInitialized)
-        return;
-
-    xmlFreeMutex(xmlDictMutex);
+}
 
-    xmlDictInitialized = 0;
+/**
+ * xmlCleanupDictInternal:
+ *
+ * Free the dictionary mutex.
+ */
+void
+xmlCleanupDictInternal(void) {
+    xmlCleanupMutex(&xmlDictMutex);
 }
 
 /*
@@ -247,9 +139,6 @@ xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) {
     size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
     size_t limit = 0;
 
-#ifdef DICT_DEBUG_PATTERNS
-    fprintf(stderr, "-");
-#endif
     pool = dict->strings;
     while (pool != NULL) {
        if ((size_t)(pool->end - pool->free) > namelen)
@@ -266,10 +155,20 @@ xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) {
             return(NULL);
         }
 
-        if (size == 0) size = 1000;
-       else size *= 4; /* exponential growth */
-        if (size < 4 * namelen)
-           size = 4 * namelen; /* just in case ! */
+        if (size == 0) {
+            size = 1000;
+        } else {
+            if (size < (SIZE_MAX - sizeof(xmlDictStrings)) / 4)
+                size *= 4; /* exponential growth */
+            else
+                size = SIZE_MAX - sizeof(xmlDictStrings);
+        }
+        if (size / 4 < namelen) {
+            if ((size_t) namelen + 0 < (SIZE_MAX - sizeof(xmlDictStrings)) / 4)
+                size = 4 * (size_t) namelen; /* just in case ! */
+            else
+                return(NULL);
+        }
        pool = (xmlDictStringsPtr) xmlMalloc(sizeof(xmlDictStrings) + size);
        if (pool == NULL)
            return(NULL);
@@ -279,9 +178,6 @@ xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) {
        pool->end = &pool->array[size];
        pool->next = dict->strings;
        dict->strings = pool;
-#ifdef DICT_DEBUG_PATTERNS
-        fprintf(stderr, "+");
-#endif
     }
 found_pool:
     ret = pool->free;
@@ -313,11 +209,6 @@ xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen,
     size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
     size_t limit = 0;
 
-    if (prefix == NULL) return(xmlDictAddString(dict, name, namelen));
-
-#ifdef DICT_DEBUG_PATTERNS
-    fprintf(stderr, "=");
-#endif
     pool = dict->strings;
     while (pool != NULL) {
        if ((size_t)(pool->end - pool->free) > namelen + plen + 1)
@@ -347,9 +238,6 @@ xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen,
        pool->end = &pool->array[size];
        pool->next = dict->strings;
        dict->strings = pool;
-#ifdef DICT_DEBUG_PATTERNS
-        fprintf(stderr, "+");
-#endif
     }
 found_pool:
     ret = pool->free;
@@ -363,209 +251,6 @@ found_pool:
     return(ret);
 }
 
-#ifdef WITH_BIG_KEY
-/*
- * xmlDictComputeBigKey:
- *
- * Calculate a hash key using a good hash function that works well for
- * larger hash table sizes.
- *
- * Hash function by "One-at-a-Time Hash" see
- * http://burtleburtle.net/bob/hash/doobs.html
- */
-
-#ifdef __clang__
-ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
-#endif
-static uint32_t
-xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
-    uint32_t hash;
-    int i;
-
-    if (namelen <= 0 || data == NULL) return(0);
-
-    hash = seed;
-
-    for (i = 0;i < namelen; i++) {
-        hash += data[i];
-       hash += (hash << 10);
-       hash ^= (hash >> 6);
-    }
-    hash += (hash << 3);
-    hash ^= (hash >> 11);
-    hash += (hash << 15);
-
-    return hash;
-}
-
-/*
- * xmlDictComputeBigQKey:
- *
- * Calculate a hash key for two strings using a good hash function
- * that works well for larger hash table sizes.
- *
- * Hash function by "One-at-a-Time Hash" see
- * http://burtleburtle.net/bob/hash/doobs.html
- *
- * Neither of the two strings must be NULL.
- */
-#ifdef __clang__
-ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
-#endif
-static unsigned long
-xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
-                      const xmlChar *name, int len, int seed)
-{
-    uint32_t hash;
-    int i;
-
-    hash = seed;
-
-    for (i = 0;i < plen; i++) {
-        hash += prefix[i];
-       hash += (hash << 10);
-       hash ^= (hash >> 6);
-    }
-    hash += ':';
-    hash += (hash << 10);
-    hash ^= (hash >> 6);
-
-    for (i = 0;i < len; i++) {
-        hash += name[i];
-       hash += (hash << 10);
-       hash ^= (hash >> 6);
-    }
-    hash += (hash << 3);
-    hash ^= (hash >> 11);
-    hash += (hash << 15);
-
-    return hash;
-}
-#endif /* WITH_BIG_KEY */
-
-/*
- * xmlDictComputeFastKey:
- *
- * Calculate a hash key using a fast hash function that works well
- * for low hash table fill.
- */
-static unsigned long
-xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) {
-    unsigned long value = seed;
-
-    if (name == NULL) return(0);
-    value += *name;
-    value <<= 5;
-    if (namelen > 10) {
-        value += name[namelen - 1];
-        namelen = 10;
-    }
-    switch (namelen) {
-        case 10: value += name[9];
-        /* Falls through. */
-        case 9: value += name[8];
-        /* Falls through. */
-        case 8: value += name[7];
-        /* Falls through. */
-        case 7: value += name[6];
-        /* Falls through. */
-        case 6: value += name[5];
-        /* Falls through. */
-        case 5: value += name[4];
-        /* Falls through. */
-        case 4: value += name[3];
-        /* Falls through. */
-        case 3: value += name[2];
-        /* Falls through. */
-        case 2: value += name[1];
-        /* Falls through. */
-        default: break;
-    }
-    return(value);
-}
-
-/*
- * xmlDictComputeFastQKey:
- *
- * Calculate a hash key for two strings using a fast hash function
- * that works well for low hash table fill.
- *
- * Neither of the two strings must be NULL.
- */
-static unsigned long
-xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
-                       const xmlChar *name, int len, int seed)
-{
-    unsigned long value = (unsigned long) seed;
-
-    if (plen == 0)
-       value += 30 * (unsigned long) ':';
-    else
-       value += 30 * (*prefix);
-
-    if (len > 10) {
-        int offset = len - (plen + 1 + 1);
-       if (offset < 0)
-           offset = len - (10 + 1);
-       value += name[offset];
-        len = 10;
-       if (plen > 10)
-           plen = 10;
-    }
-    switch (plen) {
-        case 10: value += prefix[9];
-        /* Falls through. */
-        case 9: value += prefix[8];
-        /* Falls through. */
-        case 8: value += prefix[7];
-        /* Falls through. */
-        case 7: value += prefix[6];
-        /* Falls through. */
-        case 6: value += prefix[5];
-        /* Falls through. */
-        case 5: value += prefix[4];
-        /* Falls through. */
-        case 4: value += prefix[3];
-        /* Falls through. */
-        case 3: value += prefix[2];
-        /* Falls through. */
-        case 2: value += prefix[1];
-        /* Falls through. */
-        case 1: value += prefix[0];
-        /* Falls through. */
-        default: break;
-    }
-    len -= plen;
-    if (len > 0) {
-        value += (unsigned long) ':';
-       len--;
-    }
-    switch (len) {
-        case 10: value += name[9];
-        /* Falls through. */
-        case 9: value += name[8];
-        /* Falls through. */
-        case 8: value += name[7];
-        /* Falls through. */
-        case 7: value += name[6];
-        /* Falls through. */
-        case 6: value += name[5];
-        /* Falls through. */
-        case 5: value += name[4];
-        /* Falls through. */
-        case 4: value += name[3];
-        /* Falls through. */
-        case 3: value += name[2];
-        /* Falls through. */
-        case 2: value += name[1];
-        /* Falls through. */
-        case 1: value += name[0];
-        /* Falls through. */
-        default: break;
-    }
-    return(value);
-}
-
 /**
  * xmlDictCreate:
  *
@@ -577,36 +262,24 @@ xmlDictPtr
 xmlDictCreate(void) {
     xmlDictPtr dict;
 
-    if (!xmlDictInitialized)
-        if (!__xmlInitializeDict())
-            return(NULL);
-
-#ifdef DICT_DEBUG_PATTERNS
-    fprintf(stderr, "C");
-#endif
+    xmlInitParser();
 
     dict = xmlMalloc(sizeof(xmlDict));
-    if (dict) {
-        dict->ref_counter = 1;
-        dict->limit = 0;
-
-        dict->size = MIN_DICT_SIZE;
-       dict->nbElems = 0;
-        dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry));
-       dict->strings = NULL;
-       dict->subdict = NULL;
-        if (dict->dict) {
-           memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
-#ifdef DICT_RANDOMIZATION
-            dict->seed = __xmlRandom();
-#else
-            dict->seed = 0;
+    if (dict == NULL)
+        return(NULL);
+    dict->ref_counter = 1;
+    dict->limit = 0;
+
+    dict->size = 0;
+    dict->nbElems = 0;
+    dict->table = NULL;
+    dict->strings = NULL;
+    dict->subdict = NULL;
+    dict->seed = xmlRandom();
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    dict->seed = 0;
 #endif
-           return(dict);
-        }
-        xmlFree(dict);
-    }
-    return(NULL);
+    return(dict);
 }
 
 /**
@@ -625,9 +298,6 @@ xmlDictCreateSub(xmlDictPtr sub) {
     xmlDictPtr dict = xmlDictCreate();
 
     if ((dict != NULL) && (sub != NULL)) {
-#ifdef DICT_DEBUG_PATTERNS
-        fprintf(stderr, "R");
-#endif
         dict->seed = sub->seed;
         dict->subdict = sub;
        xmlDictReference(dict->subdict);
@@ -645,153 +315,14 @@ xmlDictCreateSub(xmlDictPtr sub) {
  */
 int
 xmlDictReference(xmlDictPtr dict) {
-    if (!xmlDictInitialized)
-        if (!__xmlInitializeDict())
-            return(-1);
-
     if (dict == NULL) return -1;
-    xmlMutexLock(xmlDictMutex);
+    xmlMutexLock(&xmlDictMutex);
     dict->ref_counter++;
-    xmlMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(&xmlDictMutex);
     return(0);
 }
 
 /**
- * xmlDictGrow:
- * @dict: the dictionary
- * @size: the new size of the dictionary
- *
- * resize the dictionary
- *
- * Returns 0 in case of success, -1 in case of failure
- */
-static int
-xmlDictGrow(xmlDictPtr dict, size_t size) {
-    unsigned long key, okey;
-    size_t oldsize, i;
-    xmlDictEntryPtr iter, next;
-    struct _xmlDictEntry *olddict;
-#ifdef DEBUG_GROW
-    unsigned long nbElem = 0;
-#endif
-    int ret = 0;
-    int keep_keys = 1;
-
-    if (dict == NULL)
-       return(-1);
-    if (size < 8)
-        return(-1);
-    if (size > 8 * 2048)
-       return(-1);
-
-#ifdef DICT_DEBUG_PATTERNS
-    fprintf(stderr, "*");
-#endif
-
-    oldsize = dict->size;
-    olddict = dict->dict;
-    if (olddict == NULL)
-        return(-1);
-    if (oldsize == MIN_DICT_SIZE)
-        keep_keys = 0;
-
-    dict->dict = xmlMalloc(size * sizeof(xmlDictEntry));
-    if (dict->dict == NULL) {
-       dict->dict = olddict;
-       return(-1);
-    }
-    memset(dict->dict, 0, size * sizeof(xmlDictEntry));
-    dict->size = size;
-
-    /* If the two loops are merged, there would be situations where
-       a new entry needs to allocated and data copied into it from
-       the main dict. It is nicer to run through the array twice, first
-       copying all the elements in the main array (less probability of
-       allocate) and then the rest, so we only free in the second loop.
-    */
-    for (i = 0; i < oldsize; i++) {
-       if (olddict[i].valid == 0)
-           continue;
-
-       if (keep_keys)
-           okey = olddict[i].okey;
-       else
-           okey = xmlDictComputeKey(dict, olddict[i].name, olddict[i].len);
-       key = okey % dict->size;
-
-       if (dict->dict[key].valid == 0) {
-           memcpy(&(dict->dict[key]), &(olddict[i]), sizeof(xmlDictEntry));
-           dict->dict[key].next = NULL;
-           dict->dict[key].okey = okey;
-       } else {
-           xmlDictEntryPtr entry;
-
-           entry = xmlMalloc(sizeof(xmlDictEntry));
-           if (entry != NULL) {
-               entry->name = olddict[i].name;
-               entry->len = olddict[i].len;
-               entry->okey = okey;
-               entry->next = dict->dict[key].next;
-               entry->valid = 1;
-               dict->dict[key].next = entry;
-           } else {
-               /*
-                * we don't have much ways to alert from here
-                * result is losing an entry and unicity guarantee
-                */
-               ret = -1;
-           }
-       }
-#ifdef DEBUG_GROW
-       nbElem++;
-#endif
-    }
-
-    for (i = 0; i < oldsize; i++) {
-       iter = olddict[i].next;
-       while (iter) {
-           next = iter->next;
-
-           /*
-            * put back the entry in the new dict
-            */
-
-           if (keep_keys)
-               okey = iter->okey;
-           else
-               okey = xmlDictComputeKey(dict, iter->name, iter->len);
-           key = okey % dict->size;
-           if (dict->dict[key].valid == 0) {
-               memcpy(&(dict->dict[key]), iter, sizeof(xmlDictEntry));
-               dict->dict[key].next = NULL;
-               dict->dict[key].valid = 1;
-               dict->dict[key].okey = okey;
-               xmlFree(iter);
-           } else {
-               iter->next = dict->dict[key].next;
-               iter->okey = okey;
-               dict->dict[key].next = iter;
-           }
-
-#ifdef DEBUG_GROW
-           nbElem++;
-#endif
-
-           iter = next;
-       }
-    }
-
-    xmlFree(olddict);
-
-#ifdef DEBUG_GROW
-    xmlGenericError(xmlGenericErrorContext,
-           "xmlDictGrow : from %lu to %lu, %u elems\n", oldsize, size, nbElem);
-#endif
-
-    return(ret);
-}
-
-/**
  * xmlDictFree:
  * @dict: the dictionary
  *
@@ -800,49 +331,27 @@ xmlDictGrow(xmlDictPtr dict, size_t size) {
  */
 void
 xmlDictFree(xmlDictPtr dict) {
-    size_t i;
-    xmlDictEntryPtr iter;
-    xmlDictEntryPtr next;
-    int inside_dict = 0;
     xmlDictStringsPtr pool, nextp;
 
     if (dict == NULL)
        return;
 
-    if (!xmlDictInitialized)
-        if (!__xmlInitializeDict())
-            return;
-
     /* decrement the counter, it may be shared by a parser and docs */
-    xmlMutexLock(xmlDictMutex);
+    xmlMutexLock(&xmlDictMutex);
     dict->ref_counter--;
     if (dict->ref_counter > 0) {
-        xmlMutexUnlock(xmlDictMutex);
+        xmlMutexUnlock(&xmlDictMutex);
         return;
     }
 
-    xmlMutexUnlock(xmlDictMutex);
+    xmlMutexUnlock(&xmlDictMutex);
 
     if (dict->subdict != NULL) {
         xmlDictFree(dict->subdict);
     }
 
-    if (dict->dict) {
-       for(i = 0; ((i < dict->size) && (dict->nbElems > 0)); i++) {
-           iter = &(dict->dict[i]);
-           if (iter->valid == 0)
-               continue;
-           inside_dict = 1;
-           while (iter) {
-               next = iter->next;
-               if (!inside_dict)
-                   xmlFree(iter);
-               dict->nbElems--;
-               inside_dict = 0;
-               iter = next;
-           }
-       }
-       xmlFree(dict->dict);
+    if (dict->table) {
+       xmlFree(dict->table);
     }
     pool = dict->strings;
     while (pool != NULL) {
@@ -854,359 +363,6 @@ xmlDictFree(xmlDictPtr dict) {
 }
 
 /**
- * xmlDictLookup:
- * @dict: the dictionary
- * @name: the name of the userdata
- * @len: the length of the name, if -1 it is recomputed
- *
- * Add the @name to the dictionary @dict if not present.
- *
- * Returns the internal copy of the name or NULL in case of internal error
- */
-const xmlChar *
-xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
-    unsigned long key, okey, nbi = 0;
-    xmlDictEntryPtr entry;
-    xmlDictEntryPtr insert;
-    const xmlChar *ret;
-    unsigned int l;
-
-    if ((dict == NULL) || (name == NULL))
-       return(NULL);
-
-    if (len < 0)
-        l = strlen((const char *) name);
-    else
-        l = len;
-
-    if (((dict->limit > 0) && (l >= dict->limit)) ||
-        (l > INT_MAX / 2))
-        return(NULL);
-
-    /*
-     * Check for duplicate and insertion location.
-     */
-    okey = xmlDictComputeKey(dict, name, l);
-    key = okey % dict->size;
-    if (dict->dict[key].valid == 0) {
-       insert = NULL;
-    } else {
-       for (insert = &(dict->dict[key]); insert->next != NULL;
-            insert = insert->next) {
-#ifdef __GNUC__
-           if ((insert->okey == okey) && (insert->len == l)) {
-               if (!memcmp(insert->name, name, l))
-                   return(insert->name);
-           }
-#else
-           if ((insert->okey == okey) && (insert->len == l) &&
-               (!xmlStrncmp(insert->name, name, l)))
-               return(insert->name);
-#endif
-           nbi++;
-       }
-#ifdef __GNUC__
-       if ((insert->okey == okey) && (insert->len == l)) {
-           if (!memcmp(insert->name, name, l))
-               return(insert->name);
-       }
-#else
-       if ((insert->okey == okey) && (insert->len == l) &&
-           (!xmlStrncmp(insert->name, name, l)))
-           return(insert->name);
-#endif
-    }
-
-    if (dict->subdict) {
-        unsigned long skey;
-
-        /* we cannot always reuse the same okey for the subdict */
-        if (((dict->size == MIN_DICT_SIZE) &&
-            (dict->subdict->size != MIN_DICT_SIZE)) ||
-            ((dict->size != MIN_DICT_SIZE) &&
-            (dict->subdict->size == MIN_DICT_SIZE)))
-           skey = xmlDictComputeKey(dict->subdict, name, l);
-       else
-           skey = okey;
-
-       key = skey % dict->subdict->size;
-       if (dict->subdict->dict[key].valid != 0) {
-           xmlDictEntryPtr tmp;
-
-           for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
-                tmp = tmp->next) {
-#ifdef __GNUC__
-               if ((tmp->okey == skey) && (tmp->len == l)) {
-                   if (!memcmp(tmp->name, name, l))
-                       return(tmp->name);
-               }
-#else
-               if ((tmp->okey == skey) && (tmp->len == l) &&
-                   (!xmlStrncmp(tmp->name, name, l)))
-                   return(tmp->name);
-#endif
-               nbi++;
-           }
-#ifdef __GNUC__
-           if ((tmp->okey == skey) && (tmp->len == l)) {
-               if (!memcmp(tmp->name, name, l))
-                   return(tmp->name);
-           }
-#else
-           if ((tmp->okey == skey) && (tmp->len == l) &&
-               (!xmlStrncmp(tmp->name, name, l)))
-               return(tmp->name);
-#endif
-       }
-       key = okey % dict->size;
-    }
-
-    ret = xmlDictAddString(dict, name, l);
-    if (ret == NULL)
-        return(NULL);
-    if (insert == NULL) {
-       entry = &(dict->dict[key]);
-    } else {
-       entry = xmlMalloc(sizeof(xmlDictEntry));
-       if (entry == NULL)
-            return(NULL);
-    }
-    entry->name = ret;
-    entry->len = l;
-    entry->next = NULL;
-    entry->valid = 1;
-    entry->okey = okey;
-
-
-    if (insert != NULL)
-       insert->next = entry;
-
-    dict->nbElems++;
-
-    if ((nbi > MAX_HASH_LEN) &&
-        (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) {
-       if (xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size) != 0)
-           return(NULL);
-    }
-    /* Note that entry may have been freed at this point by xmlDictGrow */
-
-    return(ret);
-}
-
-/**
- * xmlDictExists:
- * @dict: the dictionary
- * @name: the name of the userdata
- * @len: the length of the name, if -1 it is recomputed
- *
- * Check if the @name exists in the dictionary @dict.
- *
- * Returns the internal copy of the name or NULL if not found.
- */
-const xmlChar *
-xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
-    unsigned long key, okey, nbi = 0;
-    xmlDictEntryPtr insert;
-    unsigned int l;
-
-    if ((dict == NULL) || (name == NULL))
-       return(NULL);
-
-    if (len < 0)
-        l = strlen((const char *) name);
-    else
-        l = len;
-    if (((dict->limit > 0) && (l >= dict->limit)) ||
-        (l > INT_MAX / 2))
-        return(NULL);
-
-    /*
-     * Check for duplicate and insertion location.
-     */
-    okey = xmlDictComputeKey(dict, name, l);
-    key = okey % dict->size;
-    if (dict->dict[key].valid == 0) {
-       insert = NULL;
-    } else {
-       for (insert = &(dict->dict[key]); insert->next != NULL;
-            insert = insert->next) {
-#ifdef __GNUC__
-           if ((insert->okey == okey) && (insert->len == l)) {
-               if (!memcmp(insert->name, name, l))
-                   return(insert->name);
-           }
-#else
-           if ((insert->okey == okey) && (insert->len == l) &&
-               (!xmlStrncmp(insert->name, name, l)))
-               return(insert->name);
-#endif
-           nbi++;
-       }
-#ifdef __GNUC__
-       if ((insert->okey == okey) && (insert->len == l)) {
-           if (!memcmp(insert->name, name, l))
-               return(insert->name);
-       }
-#else
-       if ((insert->okey == okey) && (insert->len == l) &&
-           (!xmlStrncmp(insert->name, name, l)))
-           return(insert->name);
-#endif
-    }
-
-    if (dict->subdict) {
-        unsigned long skey;
-
-        /* we cannot always reuse the same okey for the subdict */
-        if (((dict->size == MIN_DICT_SIZE) &&
-            (dict->subdict->size != MIN_DICT_SIZE)) ||
-            ((dict->size != MIN_DICT_SIZE) &&
-            (dict->subdict->size == MIN_DICT_SIZE)))
-           skey = xmlDictComputeKey(dict->subdict, name, l);
-       else
-           skey = okey;
-
-       key = skey % dict->subdict->size;
-       if (dict->subdict->dict[key].valid != 0) {
-           xmlDictEntryPtr tmp;
-
-           for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
-                tmp = tmp->next) {
-#ifdef __GNUC__
-               if ((tmp->okey == skey) && (tmp->len == l)) {
-                   if (!memcmp(tmp->name, name, l))
-                       return(tmp->name);
-               }
-#else
-               if ((tmp->okey == skey) && (tmp->len == l) &&
-                   (!xmlStrncmp(tmp->name, name, l)))
-                   return(tmp->name);
-#endif
-               nbi++;
-           }
-#ifdef __GNUC__
-           if ((tmp->okey == skey) && (tmp->len == l)) {
-               if (!memcmp(tmp->name, name, l))
-                   return(tmp->name);
-           }
-#else
-           if ((tmp->okey == skey) && (tmp->len == l) &&
-               (!xmlStrncmp(tmp->name, name, l)))
-               return(tmp->name);
-#endif
-       }
-    }
-
-    /* not found */
-    return(NULL);
-}
-
-/**
- * xmlDictQLookup:
- * @dict: the dictionary
- * @prefix: the prefix
- * @name: the name
- *
- * Add the QName @prefix:@name to the hash @dict if not present.
- *
- * Returns the internal copy of the QName or NULL in case of internal error
- */
-const xmlChar *
-xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
-    unsigned long okey, key, nbi = 0;
-    xmlDictEntryPtr entry;
-    xmlDictEntryPtr insert;
-    const xmlChar *ret;
-    unsigned int len, plen, l;
-
-    if ((dict == NULL) || (name == NULL))
-       return(NULL);
-    if (prefix == NULL)
-        return(xmlDictLookup(dict, name, -1));
-
-    l = len = strlen((const char *) name);
-    plen = strlen((const char *) prefix);
-    len += 1 + plen;
-
-    /*
-     * Check for duplicate and insertion location.
-     */
-    okey = xmlDictComputeQKey(dict, prefix, plen, name, l);
-    key = okey % dict->size;
-    if (dict->dict[key].valid == 0) {
-       insert = NULL;
-    } else {
-       for (insert = &(dict->dict[key]); insert->next != NULL;
-            insert = insert->next) {
-           if ((insert->okey == okey) && (insert->len == len) &&
-               (xmlStrQEqual(prefix, name, insert->name)))
-               return(insert->name);
-           nbi++;
-       }
-       if ((insert->okey == okey) && (insert->len == len) &&
-           (xmlStrQEqual(prefix, name, insert->name)))
-           return(insert->name);
-    }
-
-    if (dict->subdict) {
-        unsigned long skey;
-
-        /* we cannot always reuse the same okey for the subdict */
-        if (((dict->size == MIN_DICT_SIZE) &&
-            (dict->subdict->size != MIN_DICT_SIZE)) ||
-            ((dict->size != MIN_DICT_SIZE) &&
-            (dict->subdict->size == MIN_DICT_SIZE)))
-           skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l);
-       else
-           skey = okey;
-
-       key = skey % dict->subdict->size;
-       if (dict->subdict->dict[key].valid != 0) {
-           xmlDictEntryPtr tmp;
-           for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
-                tmp = tmp->next) {
-               if ((tmp->okey == skey) && (tmp->len == len) &&
-                   (xmlStrQEqual(prefix, name, tmp->name)))
-                   return(tmp->name);
-               nbi++;
-           }
-           if ((tmp->okey == skey) && (tmp->len == len) &&
-               (xmlStrQEqual(prefix, name, tmp->name)))
-               return(tmp->name);
-       }
-       key = okey % dict->size;
-    }
-
-    ret = xmlDictAddQString(dict, prefix, plen, name, l);
-    if (ret == NULL)
-        return(NULL);
-    if (insert == NULL) {
-       entry = &(dict->dict[key]);
-    } else {
-       entry = xmlMalloc(sizeof(xmlDictEntry));
-       if (entry == NULL)
-            return(NULL);
-    }
-    entry->name = ret;
-    entry->len = len;
-    entry->next = NULL;
-    entry->valid = 1;
-    entry->okey = okey;
-
-    if (insert != NULL)
-       insert->next = entry;
-
-    dict->nbElems++;
-
-    if ((nbi > MAX_HASH_LEN) &&
-        (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
-       xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
-    /* Note that entry may have been freed at this point by xmlDictGrow */
-
-    return(ret);
-}
-
-/**
  * xmlDictOwns:
  * @dict: the dictionary
  * @str: the string
@@ -1296,3 +452,521 @@ xmlDictGetUsage(xmlDictPtr dict) {
     return(limit);
 }
 
+/*****************************************************************
+ *
+ * The code below was rewritten and is additionally licensed under
+ * the main license in file 'Copyright'.
+ *
+ *****************************************************************/
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+xmlDictHashName(unsigned seed, const xmlChar* data, size_t maxLen,
+                size_t *plen) {
+    unsigned h1, h2;
+    size_t i;
+
+    HASH_INIT(h1, h2, seed);
+
+    for (i = 0; i < maxLen && data[i]; i++) {
+        HASH_UPDATE(h1, h2, data[i]);
+    }
+
+    HASH_FINISH(h1, h2);
+
+    *plen = i;
+    return(h2 | MAX_HASH_SIZE);
+}
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+xmlDictHashQName(unsigned seed, const xmlChar *prefix, const xmlChar *name,
+                 size_t *pplen, size_t *plen) {
+    unsigned h1, h2;
+    size_t i;
+
+    HASH_INIT(h1, h2, seed);
+
+    for (i = 0; prefix[i] != 0; i++) {
+        HASH_UPDATE(h1, h2, prefix[i]);
+    }
+    *pplen = i;
+
+    HASH_UPDATE(h1, h2, ':');
+
+    for (i = 0; name[i] != 0; i++) {
+        HASH_UPDATE(h1, h2, name[i]);
+    }
+    *plen = i;
+
+    HASH_FINISH(h1, h2);
+
+    /*
+     * Always set the upper bit of hash values since 0 means an unoccupied
+     * bucket.
+     */
+    return(h2 | MAX_HASH_SIZE);
+}
+
+unsigned
+xmlDictComputeHash(const xmlDict *dict, const xmlChar *string) {
+    size_t len;
+    return(xmlDictHashName(dict->seed, string, SIZE_MAX, &len));
+}
+
+#define HASH_ROL31(x,n) ((x) << (n) | ((x) & 0x7FFFFFFF) >> (31 - (n)))
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+unsigned
+xmlDictCombineHash(unsigned v1, unsigned v2) {
+    /*
+     * The upper bit of hash values is always set, so we have to operate on
+     * 31-bit hashes here.
+     */
+    v1 ^= v2;
+    v1 += HASH_ROL31(v2, 5);
+
+    return((v1 & 0xFFFFFFFF) | 0x80000000);
+}
+
+/**
+ * xmlDictFindEntry:
+ * @dict: dict
+ * @prefix: optional QName prefix
+ * @name: string
+ * @len: length of string
+ * @hashValue: valid hash value of string
+ * @pfound: result of search
+ *
+ * Try to find a matching hash table entry. If an entry was found, set
+ * @found to 1 and return the entry. Otherwise, set @found to 0 and return
+ * the location where a new entry should be inserted.
+ */
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static xmlDictEntry *
+xmlDictFindEntry(const xmlDict *dict, const xmlChar *prefix,
+                 const xmlChar *name, int len, unsigned hashValue,
+                 int *pfound) {
+    xmlDictEntry *entry;
+    unsigned mask, pos, displ;
+    int found = 0;
+
+    mask = dict->size - 1;
+    pos = hashValue & mask;
+    entry = &dict->table[pos];
+
+    if (entry->hashValue != 0) {
+        /*
+         * Robin hood hashing: abort if the displacement of the entry
+         * is smaller than the displacement of the key we look for.
+         * This also stops at the correct position when inserting.
+         */
+        displ = 0;
+
+        do {
+            if (entry->hashValue == hashValue) {
+                if (prefix == NULL) {
+                    /*
+                     * name is not necessarily null-terminated.
+                     */
+                    if ((strncmp((const char *) entry->name,
+                                 (const char *) name, len) == 0) &&
+                        (entry->name[len] == 0)) {
+                        found = 1;
+                        break;
+                    }
+                } else {
+                    if (xmlStrQEqual(prefix, name, entry->name)) {
+                        found = 1;
+                        break;
+                    }
+                }
+            }
+
+            displ++;
+            pos++;
+            entry++;
+            if ((pos & mask) == 0)
+                entry = dict->table;
+        } while ((entry->hashValue != 0) &&
+                 (((pos - entry->hashValue) & mask) >= displ));
+    }
+
+    *pfound = found;
+    return(entry);
+}
+
+/**
+ * xmlDictGrow:
+ * @dict: dictionary
+ * @size: new size of the dictionary
+ *
+ * Resize the dictionary hash table.
+ *
+ * Returns 0 in case of success, -1 if a memory allocation failed.
+ */
+static int
+xmlDictGrow(xmlDictPtr dict, unsigned size) {
+    const xmlDictEntry *oldentry, *oldend, *end;
+    xmlDictEntry *table;
+    unsigned oldsize, i;
+
+    /* Add 0 to avoid spurious -Wtype-limits warning on 64-bit GCC */
+    if ((size_t) size + 0 > SIZE_MAX / sizeof(table[0]))
+        return(-1);
+    table = xmlMalloc(size * sizeof(table[0]));
+    if (table == NULL)
+        return(-1);
+    memset(table, 0, size * sizeof(table[0]));
+
+    oldsize = dict->size;
+    if (oldsize == 0)
+        goto done;
+
+    oldend = &dict->table[oldsize];
+    end = &table[size];
+
+    /*
+     * Robin Hood sorting order is maintained if we
+     *
+     * - compute dict indices with modulo
+     * - resize by an integer factor
+     * - start to copy from the beginning of a probe sequence
+     */
+    oldentry = dict->table;
+    while (oldentry->hashValue != 0) {
+        if (++oldentry >= oldend)
+            oldentry = dict->table;
+    }
+
+    for (i = 0; i < oldsize; i++) {
+        if (oldentry->hashValue != 0) {
+            xmlDictEntry *entry = &table[oldentry->hashValue & (size - 1)];
+
+            while (entry->hashValue != 0) {
+                if (++entry >= end)
+                    entry = table;
+            }
+            *entry = *oldentry;
+        }
+
+        if (++oldentry >= oldend)
+            oldentry = dict->table;
+    }
+
+    xmlFree(dict->table);
+
+done:
+    dict->table = table;
+    dict->size = size;
+
+    return(0);
+}
+
+/**
+ * xmlDictLookupInternal:
+ * @dict: dict
+ * @prefix: optional QName prefix
+ * @name: string
+ * @maybeLen: length of string or -1 if unknown
+ * @update: whether the string should be added
+ *
+ * Internal lookup and update function.
+ */
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static const xmlDictEntry *
+xmlDictLookupInternal(xmlDictPtr dict, const xmlChar *prefix,
+                      const xmlChar *name, int maybeLen, int update) {
+    xmlDictEntry *entry = NULL;
+    const xmlChar *ret;
+    unsigned hashValue;
+    size_t maxLen, len, plen, klen;
+    int found = 0;
+
+    if ((dict == NULL) || (name == NULL))
+       return(NULL);
+
+    maxLen = (maybeLen < 0) ? SIZE_MAX : (size_t) maybeLen;
+
+    if (prefix == NULL) {
+        hashValue = xmlDictHashName(dict->seed, name, maxLen, &len);
+        if (len > INT_MAX / 2)
+            return(NULL);
+        klen = len;
+    } else {
+        hashValue = xmlDictHashQName(dict->seed, prefix, name, &plen, &len);
+        if ((len > INT_MAX / 2) || (plen >= INT_MAX / 2 - len))
+            return(NULL);
+        klen = plen + 1 + len;
+    }
+
+    if ((dict->limit > 0) && (klen >= dict->limit))
+        return(NULL);
+
+    /*
+     * Check for an existing entry
+     */
+    if (dict->size > 0)
+        entry = xmlDictFindEntry(dict, prefix, name, klen, hashValue, &found);
+    if (found)
+        return(entry);
+
+    if ((dict->subdict != NULL) && (dict->subdict->size > 0)) {
+        xmlDictEntry *subEntry;
+        unsigned subHashValue;
+
+        if (prefix == NULL)
+            subHashValue = xmlDictHashName(dict->subdict->seed, name, len,
+                                           &len);
+        else
+            subHashValue = xmlDictHashQName(dict->subdict->seed, prefix, name,
+                                            &plen, &len);
+        subEntry = xmlDictFindEntry(dict->subdict, prefix, name, klen,
+                                    subHashValue, &found);
+        if (found)
+            return(subEntry);
+    }
+
+    if (!update)
+        return(NULL);
+
+    /*
+     * Grow the hash table if needed
+     */
+    if (dict->nbElems + 1 > dict->size / MAX_FILL_DENOM * MAX_FILL_NUM) {
+        unsigned newSize, mask, displ, pos;
+
+        if (dict->size == 0) {
+            newSize = MIN_HASH_SIZE;
+        } else {
+            if (dict->size >= MAX_HASH_SIZE)
+                return(NULL);
+            newSize = dict->size * 2;
+        }
+        if (xmlDictGrow(dict, newSize) != 0)
+            return(NULL);
+
+        /*
+         * Find new entry
+         */
+        mask = dict->size - 1;
+        displ = 0;
+        pos = hashValue & mask;
+        entry = &dict->table[pos];
+
+        while ((entry->hashValue != 0) &&
+               ((pos - entry->hashValue) & mask) >= displ) {
+            displ++;
+            pos++;
+            entry++;
+            if ((pos & mask) == 0)
+                entry = dict->table;
+        }
+    }
+
+    if (prefix == NULL)
+        ret = xmlDictAddString(dict, name, len);
+    else
+        ret = xmlDictAddQString(dict, prefix, plen, name, len);
+    if (ret == NULL)
+        return(NULL);
+
+    /*
+     * Shift the remainder of the probe sequence to the right
+     */
+    if (entry->hashValue != 0) {
+        const xmlDictEntry *end = &dict->table[dict->size];
+        const xmlDictEntry *cur = entry;
+
+        do {
+            cur++;
+            if (cur >= end)
+                cur = dict->table;
+        } while (cur->hashValue != 0);
+
+        if (cur < entry) {
+            /*
+             * If we traversed the end of the buffer, handle the part
+             * at the start of the buffer.
+             */
+            memmove(&dict->table[1], dict->table,
+                    (char *) cur - (char *) dict->table);
+            cur = end - 1;
+            dict->table[0] = *cur;
+        }
+
+        memmove(&entry[1], entry, (char *) cur - (char *) entry);
+    }
+
+    /*
+     * Populate entry
+     */
+    entry->hashValue = hashValue;
+    entry->name = ret;
+
+    dict->nbElems++;
+
+    return(entry);
+}
+
+/**
+ * xmlDictLookup:
+ * @dict: dictionary
+ * @name: string key
+ * @len: length of the key, if -1 it is recomputed
+ *
+ * Lookup a string and add it to the dictionary if it wasn't found.
+ *
+ * Returns the interned copy of the string or NULL if a memory allocation
+ * failed.
+ */
+const xmlChar *
+xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
+    const xmlDictEntry *entry;
+
+    entry = xmlDictLookupInternal(dict, NULL, name, len, 1);
+    if (entry == NULL)
+        return(NULL);
+    return(entry->name);
+}
+
+/**
+ * xmlDictLookupHashed:
+ * @dict: dictionary
+ * @name: string key
+ * @len: length of the key, if -1 it is recomputed
+ *
+ * Lookup a dictionary entry and add the string to the dictionary if
+ * it wasn't found.
+ *
+ * Returns the dictionary entry.
+ */
+xmlHashedString
+xmlDictLookupHashed(xmlDictPtr dict, const xmlChar *name, int len) {
+    const xmlDictEntry *entry;
+    xmlHashedString ret;
+
+    entry = xmlDictLookupInternal(dict, NULL, name, len, 1);
+
+    if (entry == NULL) {
+        ret.name = NULL;
+        ret.hashValue = 0;
+    } else {
+        ret = *entry;
+    }
+
+    return(ret);
+}
+
+/**
+ * xmlDictExists:
+ * @dict: the dictionary
+ * @name: the name of the userdata
+ * @len: the length of the name, if -1 it is recomputed
+ *
+ * Check if a string exists in the dictionary.
+ *
+ * Returns the internal copy of the name or NULL if not found.
+ */
+const xmlChar *
+xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
+    const xmlDictEntry *entry;
+
+    entry = xmlDictLookupInternal(dict, NULL, name, len, 0);
+    if (entry == NULL)
+        return(NULL);
+    return(entry->name);
+}
+
+/**
+ * xmlDictQLookup:
+ * @dict: the dictionary
+ * @prefix: the prefix
+ * @name: the name
+ *
+ * Lookup the QName @prefix:@name and add it to the dictionary if
+ * it wasn't found.
+ *
+ * Returns the interned copy of the string or NULL if a memory allocation
+ * failed.
+ */
+const xmlChar *
+xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
+    const xmlDictEntry *entry;
+
+    entry = xmlDictLookupInternal(dict, prefix, name, -1, 1);
+    if (entry == NULL)
+        return(NULL);
+    return(entry->name);
+}
+
+/*
+ * Pseudo-random generator
+ */
+
+static xmlMutex xmlRngMutex;
+
+static unsigned globalRngState[2];
+
+#ifdef XML_THREAD_LOCAL
+static XML_THREAD_LOCAL int localRngInitialized = 0;
+static XML_THREAD_LOCAL unsigned localRngState[2];
+#endif
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+void
+xmlInitRandom(void) {
+    int var;
+
+    xmlInitMutex(&xmlRngMutex);
+
+    /* TODO: Get seed values from system PRNG */
+
+    globalRngState[0] = (unsigned) time(NULL) ^
+                        HASH_ROL((unsigned) (size_t) &xmlInitRandom, 8);
+    globalRngState[1] = HASH_ROL((unsigned) (size_t) &xmlRngMutex, 16) ^
+                        HASH_ROL((unsigned) (size_t) &var, 24);
+}
+
+void
+xmlCleanupRandom(void) {
+    xmlCleanupMutex(&xmlRngMutex);
+}
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+xoroshiro64ss(unsigned *s) {
+    unsigned s0 = s[0];
+    unsigned s1 = s[1];
+    unsigned result = HASH_ROL(s0 * 0x9E3779BB, 5) * 5;
+
+    s1 ^= s0;
+    s[0] = HASH_ROL(s0, 26) ^ s1 ^ (s1 << 9);
+    s[1] = HASH_ROL(s1, 13);
+
+    return(result & 0xFFFFFFFF);
+}
+
+unsigned
+xmlRandom(void) {
+#ifdef XML_THREAD_LOCAL
+    if (!localRngInitialized) {
+        xmlMutexLock(&xmlRngMutex);
+        localRngState[0] = xoroshiro64ss(globalRngState);
+        localRngState[1] = xoroshiro64ss(globalRngState);
+        localRngInitialized = 1;
+        xmlMutexUnlock(&xmlRngMutex);
+    }
+
+    return(xoroshiro64ss(localRngState));
+#else
+    unsigned ret;
+
+    xmlMutexLock(&xmlRngMutex);
+    ret = xoroshiro64ss(globalRngState);
+    xmlMutexUnlock(&xmlRngMutex);
+
+    return(ret);
+#endif
+}
+
index 5daef3e..5f16fca 100644 (file)
@@ -58,10 +58,7 @@ dist_man_MANS = xml2-config.1 xmllint.1 xmlcatalog.1
 
 EXTRA_DIST = \
        apibuild.py \
-       checkapisym.xsl \
        libxml2-api.xml \
-       symbols.xml \
-       syms.xsl \
        xmlcatalog.xml \
        xmllint.xml
 
@@ -69,9 +66,6 @@ DOCBOOK_HTML = http://docbook.sourceforge.net/release/xsl/current/html/docbook.x
 
 rebuild:
        cd $(srcdir) && ./apibuild.py
-       cd $(srcdir) && $(XSLTPROC) checkapisym.xsl libxml2-api.xml
-       cd $(srcdir) && $(XSLTPROC) -o ../libxml2.syms syms.xsl symbols.xml
-       cd $(srcdir) && $(XSLTPROC) -o ../win32/libxml2.def.src ../win32/defgen.xsl libxml2-api.xml
        cd $(srcdir) && $(XSLTPROC) --nonet xmllint.xml
        cd $(srcdir) && $(XSLTPROC) --nonet -o xmllint.html $(DOCBOOK_HTML) xmllint.xml
        cd $(srcdir) && $(XSLTPROC) --nonet xmlcatalog.xml
index f46e106..c1ba463 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This is the API builder, it parses the C sources and build the
 # API formal description in XML.
@@ -23,15 +23,12 @@ ignored_files = {
   "trio.c": "too many non standard macros",
   "trionan.c": "too many non standard macros",
   "triostr.c": "too many non standard macros",
-  "acconfig.h": "generated portability layer",
   "config.h": "generated portability layer",
   "libxml.h": "internal only",
   "testOOM.c": "out of memory tester",
   "testOOMlib.h": "out of memory tester",
   "testOOMlib.c": "out of memory tester",
   "rngparser.c": "not yet integrated",
-  "rngparser.h": "not yet integrated",
-  "testAutomata.c": "test tool",
   "testModule.c": "test tool",
   "testThreads.c": "test tool",
   "testapi.c": "generated regression tests",
@@ -41,10 +38,6 @@ ignored_files = {
   "test.c": "not part of the library",
   "testdso.c": "test for dynamid shared libraries",
   "testrecurse.c": "test for entities recursions",
-  "xzlib.h": "Internal API only 2.8.0",
-  "buf.h": "Internal API only 2.9.0",
-  "enc.h": "Internal API only 2.9.0",
-  "/save.h": "Internal API only 2.9.0",
   "timsort.h": "Internal header only for xpath.c 2.9.0",
 }
 
@@ -57,9 +50,7 @@ ignored_words = {
   "XMLPUBFUN": (0, "Special macro for extern funcs for win32"),
   "XSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
   "EXSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
-  "XMLCALL": (0, "Special macro for win32 calls"),
   "XSLTCALL": (0, "Special macro for win32 calls"),
-  "XMLCDECL": (0, "Special macro for win32 calls"),
   "EXSLTCALL": (0, "Special macro for win32 calls"),
   "__declspec": (3, "Windows keyword"),
   "__stdcall": (0, "Windows keyword"),
@@ -72,7 +63,15 @@ ignored_words = {
   "LIBXML_ATTR_FORMAT": (5, "macro for gcc printf args checking extension"),
   "LIBXML_ATTR_ALLOC_SIZE": (3, "macro for gcc checking extension"),
   "ATTRIBUTE_NO_SANITIZE": (3, "macro keyword"),
+  "ATTRIBUTE_NO_SANITIZE_INTEGER": (0, "macro keyword"),
   "XML_DEPRECATED": (0, "macro keyword"),
+  "XML_GLOBALS_ALLOC": (0, "macro keyword"),
+  "XML_GLOBALS_ERROR": (0, "macro keyword"),
+  "XML_GLOBALS_HTML": (0, "macro keyword"),
+  "XML_GLOBALS_IO": (0, "macro keyword"),
+  "XML_GLOBALS_PARSER": (0, "macro keyword"),
+  "XML_GLOBALS_TREE": (0, "macro keyword"),
+  "XML_THREAD_LOCAL": (0, "macro keyword"),
 }
 
 def escape(raw):
@@ -192,10 +191,10 @@ class index:
         if name[0:2] == '__':
             return None
         d = None
-        try:
+        if name in self.identifiers:
            d = self.identifiers[name]
-           d.update(header, module, type, lineno, info, extra, conditionals)
-        except:
+           d.update(header, module, type, info, extra, conditionals)
+        else:
            d = identifier(name, header, module, type, lineno, info, extra, conditionals)
            self.identifiers[name] = d
 
@@ -214,10 +213,10 @@ class index:
         if name[0:2] == '__':
             return None
         d = None
-        try:
+        if name in self.identifiers:
            d = self.identifiers[name]
-           d.update(header, module, type, lineno, info, extra, conditionals)
-        except:
+           d.update(header, module, type, info, extra, conditionals)
+        else:
            d = identifier(name, header, module, type, lineno, info, extra, conditionals)
            self.identifiers[name] = d
 
@@ -301,7 +300,7 @@ class index:
                  continue
              if id in self.enums:
                  continue
-             if id in self.macros:
+             if id in self.macros and id != 'XML_OP':
                  print("macro %s from %s redeclared in %s" % (
                     id, self.macros[id].header, idx.macros[id].header))
              else:
@@ -330,7 +329,19 @@ class index:
          #     else:
          #         print "Function %s from %s is not declared in headers" % (
          #                id, idx.functions[id].module)
-         # TODO: do the same for variables.
+
+        for id in list(idx.variables.keys()):
+            if id in self.variables:
+                # check that variable condition agrees with header
+                # TODO: produces many false positives
+                #if idx.variables[id].conditionals != \
+                #   self.variables[id].conditionals:
+                #    print("Header condition differs from Variable for %s:" \
+                #       % id)
+                #    print("  H: %s" % self.variables[id].conditionals)
+                #    print("  C: %s" % idx.variables[id].conditionals)
+                up = idx.variables[id]
+                self.variables[id].update(None, up.module, up.type, up.info, up.extra)
 
     def analyze_dict(self, type, dict):
         count = 0
@@ -577,23 +588,25 @@ class CParser:
         self.last_comment = ""
         self.comment = None
         self.collect_ref = 0
-        self.no_error = 0
+        self.doc_disable = 0
         self.conditionals = []
         self.defines = []
 
     def collect_references(self):
         self.collect_ref = 1
 
-    def stop_error(self):
-        self.no_error = 1
+    def disable(self):
+        self.doc_disable = 1
 
-    def start_error(self):
-        self.no_error = 0
+    def enable(self):
+        self.doc_disable = 0
 
     def lineno(self):
         return self.lexer.getlineno()
 
     def index_add(self, name, module, static, type, info=None, extra = None):
+        if self.doc_disable:
+            return
         if self.is_header == 1:
             self.index.add(name, module, module, static, type, self.lineno(),
                            info, extra, self.conditionals)
@@ -611,12 +624,12 @@ class CParser:
                                info, extra, self.conditionals)
 
     def warning(self, msg):
-        if self.no_error:
+        if self.doc_disable:
             return
         print(msg)
 
     def error(self, msg, token=-1):
-        if self.no_error:
+        if self.doc_disable:
             return
 
         print("Parse Error: " + msg)
@@ -669,17 +682,17 @@ class CParser:
         token = self.lexer.token()
 
         if self.comment.find("DOC_DISABLE") != -1:
-            self.stop_error()
+            self.disable()
 
         if self.comment.find("DOC_ENABLE") != -1:
-            self.start_error()
+            self.enable()
 
         return token
 
     #
-    # Parse a comment block associate to a typedef
+    # Parse a simple comment block for typedefs or global variables
     #
-    def parseTypeComment(self, name, quiet = 0):
+    def parseSimpleComment(self, name, quiet = False):
         if name[0:2] == '__':
             quiet = 1
 
@@ -688,20 +701,20 @@ class CParser:
 
         if self.comment == None:
             if not quiet:
-                self.warning("Missing comment for type %s" % (name))
-            return((args, desc))
+                self.warning("Missing comment for %s" % (name))
+            return(None)
         if self.comment[0] != '*':
             if not quiet:
-                self.warning("Missing * in type comment for %s" % (name))
-            return((args, desc))
+                self.warning("Missing * in comment for %s" % (name))
+            return(None)
         lines = self.comment.split('\n')
         if lines[0] == '*':
             del lines[0]
         if lines[0] != "* %s:" % (name):
             if not quiet:
-                self.warning("Misformatted type comment for %s" % (name))
+                self.warning("Misformatted comment for %s" % (name))
                 self.warning("  Expecting '* %s:' got '%s'" % (name, lines[0]))
-            return((args, desc))
+            return(None)
         del lines[0]
         while len(lines) > 0 and lines[0] == '*':
             del lines[0]
@@ -718,7 +731,7 @@ class CParser:
 
         if quiet == 0:
             if desc == "":
-                self.warning("Type comment for %s lack description of the macro" % (name))
+                self.warning("Comment for %s lacks description" % (name))
 
         return(desc)
     #
@@ -935,7 +948,7 @@ class CParser:
                     name = name.split('(') [0]
                 except:
                     pass
-                info = self.parseMacroComment(name, not self.is_header)
+                info = self.parseMacroComment(name, True)
                 self.index_add(name, self.filename, not self.is_header,
                                 "macro", info)
                 return token
@@ -1068,7 +1081,7 @@ class CParser:
                         base_type = "struct " + name
                     else:
                         # TODO report missing or misformatted comments
-                        info = self.parseTypeComment(name, 1)
+                        info = self.parseSimpleComment(name, True)
                         self.index_add(name, self.filename, not self.is_header,
                                     "typedef", type, info)
                 token = self.token()
@@ -1103,7 +1116,6 @@ class CParser:
                 token = self.token()
                 token = self.parseBlock(token)
             elif token[0] == "sep" and token[1] == "}":
-                self.comment = None
                 token = self.token()
                 return token
             else:
@@ -1260,26 +1272,29 @@ class CParser:
         if token == None:
             return token
 
+        have_sign = 0
+        done = 0
+
         while token[0] == "name" and (
               token[1] == "const" or \
               token[1] == "unsigned" or \
               token[1] == "signed"):
+            if token[1] == "unsigned" or token[1] == "signed":
+                have_sign = 1
             if self.type == "":
                 self.type = token[1]
             else:
                 self.type = self.type + " " + token[1]
             token = self.token()
 
-        if token[0] == "name" and (token[1] == "long" or token[1] == "short"):
+        if token[0] == "name" and token[1] in ("char", "short", "int", "long"):
             if self.type == "":
                 self.type = token[1]
             else:
                 self.type = self.type + " " + token[1]
-            if token[0] == "name" and token[1] == "int":
-                if self.type == "":
-                    self.type = tmp[1]
-                else:
-                    self.type = self.type + " " + tmp[1]
+
+        elif have_sign:
+            done = 1
 
         elif token[0] == "name" and token[1] == "struct":
             if self.type == "":
@@ -1348,7 +1363,8 @@ class CParser:
             self.error("parsing type %s: expecting a name" % (self.type),
                        token)
             return token
-        token = self.token()
+        if not done:
+            token = self.token()
         while token != None and (token[0] == "op" or
               token[0] == "name" and token[1] == "const"):
             self.type = self.type + " " + token[1]
@@ -1518,25 +1534,24 @@ class CParser:
                     token = self.token()
                     token = self.parseBlock(token)
                 else:
-                    self.comment = None
                     while token != None and (token[0] != "sep" or \
                           (token[1] != ';' and token[1] != ',')):
                             token = self.token()
-                self.comment = None
                 if token == None or token[0] != "sep" or (token[1] != ';' and
                    token[1] != ','):
                     self.error("missing ';' or ',' after value")
 
             if token != None and token[0] == "sep":
                 if token[1] == ";":
-                    self.comment = None
-                    token = self.token()
                     if type == "struct":
                         self.index_add(self.name, self.filename,
                              not self.is_header, "struct", self.struct_fields)
                     else:
+                        info = self.parseSimpleComment(self.name, True)
                         self.index_add(self.name, self.filename,
-                             not self.is_header, "variable", type)
+                             not self.is_header, "variable", type, info)
+                    self.comment = None
+                    token = self.token()
                     break
                 elif token[1] == "(":
                     token = self.token()
@@ -1548,18 +1563,20 @@ class CParser:
                                 ((type, None), self.signature), 1)
                         self.index_add(self.name, self.filename, static,
                                         "function", d)
+                        self.comment = None
                         token = self.token()
                     elif token[0] == "sep" and token[1] == "{":
                         d = self.mergeFunctionComment(self.name,
                                 ((type, None), self.signature), static)
                         self.index_add(self.name, self.filename, static,
                                         "function", d)
+                        self.comment = None
                         token = self.token()
                         token = self.parseBlock(token);
                 elif token[1] == ',':
-                    self.comment = None
                     self.index_add(self.name, self.filename, static,
                                     "variable", type)
+                    self.comment = None
                     type = type_orig
                     token = self.token()
                     while token != None and token[0] == "sep":
@@ -1732,11 +1749,17 @@ class docBuilder:
     def serialize_variable(self, output, name):
         id = self.idx.variables[name]
         if id.info != None:
-            output.write("    <variable name='%s' file='%s' type='%s'/>\n" % (
+            output.write("    <variable name='%s' file='%s' type='%s'" % (
                     name, self.modulename_file(id.header), id.info))
         else:
-            output.write("    <variable name='%s' file='%s'/>\n" % (
+            output.write("    <variable name='%s' file='%s'" % (
                     name, self.modulename_file(id.header)))
+        desc = id.extra
+        if desc != None and desc != "":
+            output.write(">\n      <info>%s</info>\n" % (escape(desc)))
+            output.write("    </variable>\n")
+        else:
+            output.write("/>\n")
 
     def serialize_function(self, output, name):
         id = self.idx.functions[name]
diff --git a/doc/buildDocBookCatalog b/doc/buildDocBookCatalog
deleted file mode 100755 (executable)
index d1b8c94..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-#! /bin/bash
-
-usage()
-{
-    cat <<EOF
-Usage: $pname [OPTION]
-
-Known values for OPTION are:
-  --prefix=DIR        change the output directory for catalog files
-                      [default $DIR]
-  --show              display the output filenames and paths
-  --version=x.y.z     change the DocBook version [default $VERSION]
-  --debug             display script action information
-  --help              display this help and exit
-EOF
-}
-
-setdefault()
-{
-    echo Unable to update root catalog $ROOTCATALOG
-    ROOTCATALOG=$HOME/xmlcatalog
-    CATALOG=$HOME/dbkxmlcatalog
-    DIR=$HOME
-    CAT=xmlcatalog
-    echo Using $ROOTCATALOG as the root catalog
-    echo Remember to export XML_CATALOG_FILES=$ROOTCATALOG
-    echo
-    prefix=1
-}
-
-fixname()
-{
-#
-# ROOTCATALOG contains the full pathname for the catalog.  We will
-# split that into the directory name and the filename, then we will
-# see if the directory exists.  If it does not, we will attempt to
-# create it.
-#
-    if test $verbose = 1
-    then
-        echo Checking path $ROOTCATALOG for permissions
-    fi
-# First we split the filename and directory name
-    CAT=`basename $ROOTCATALOG`
-    DIR=`dirname $ROOTCATALOG`
-    if test "$DIR" = ""
-    then
-        echo Unable to isolate directory name from '$ROOTCATALOG' - exiting
-        exit 1
-    fi
-    CATALOG=${DIR}/docbook
-    parent=`dirname $DIR`
-    if test "$parent" == ""
-    then
-        parent=/
-    fi
-    if [ ! -d $DIR ]
-    then
-        if test $verbose = 1
-        then
-            echo Directory $DIR missing - I will try to create it
-        fi
-        if [ ! -w $parent ]
-        then
-            if test $verbose = 1
-            then
-                echo No write permission for directory $parent
-            fi
-            setdefault
-        else
-            newdir=1
-        fi
-    else
-        if [ -f $ROOTCATALOG -a ! -w $ROOTCATALOG ] ||
-          [ -e $ROOTCATALOG -a ! -f $ROOTCATALOG ] ||
-           [ ! -e $ROOTCATALOG  -a ! -w $DIR ]
-        then
-            setdefault
-        fi
-    fi
-
-}
-finddbx()
-{
-dtd421=""
-s="//OASIS//DTD DocBook XML V${VERSION}//EN"
-found=`find $1 -name docbookx.dtd -exec grep -l "$s" {} \;`
-for dtd in $found; do
-    docbookdir=`dirname $dtd`
-    echo Found DocBook XML $VERSION DTD in $docbookdir
-#
-# The original script had a check for write permission on the file
-# but I can't see why it should be necessary
-#
-    dtd421=$dtd
-    break
-done
-}
-
-#
-# Preset script control params
-show=0
-prefix=0
-newdir=0
-verbose=0
-#
-# Isolate the script name for messages
-pname=`basename $0`
-VERSION=4.1.2
-
-if test "$XML_CATALOG_FILES" != ""
-then
-    ROOTCATALOG=$XML_CATALOG_FILES
-else
-    ROOTCATALOG=/etc/xml/catalog
-fi
-
-#
-# Interpret script parameters
-while test $# -gt 0; do
-    case "$1" in
-    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-    *) optarg= ;;
-    esac
-
-    case "$1" in
-    -p=* | --prefix=*)
-        ROOTCATALOG=$optarg/catalog
-        prefix=1
-        ;;
-
-    -s | --show)
-        show=1
-        ;;
-
-    -v=* | --version=*)
-        VERSION=$optarg
-       ;;
-
-    -d | --debug)
-        verbose=1
-        ;;
-
-    -h | --help)
-        usage
-       exit 0
-       ;;
-
-    * )
-        echo Invalid argument "$1"
-       usage
-        exit 1
-        ;;
-    esac
-    shift
-done
-fixname
-if test $prefix != 0
-then
-    export XML_CATALOG_FILES=$ROOTCATALOG
-fi
-if test $show != 0
-then
-    echo XML Catalog is $ROOTCATALOG
-    echo Docbook Catalog is $CATALOG
-    exit 0
-fi
-if test $newdir!=0
-then
-    mkdir -p $DIR
-    chmod 755 $DIR
-fi
-
-echo Starting run
-#
-# create the catalogs root and docbook specific
-#
-if [ ! -r $ROOTCATALOG ] ; then
-   echo creating XML Catalog root $ROOTCATALOG
-   xmlcatalog --noout --create $ROOTCATALOG
-fi
-if [ ! -r $ROOTCATALOG ] ; then
-   echo Failed creating XML Catalog root $ROOTCATALOG
-   exit 1
-fi
-if [ ! -r $CATALOG ] ; then
-   echo creating DocBook XML Catalog $CATALOG
-   xmlcatalog --noout --create $CATALOG
-fi
-if [ ! -r $CATALOG ] ; then
-   echo Failed creating DocBook XML Catalog $CATALOG
-   exit 1
-fi
-
-#
-# find the prefix for DocBook DTD
-#
-finddbx /usr/share/xml
-if [ "$dtd421" = "" ] ; then
-    finddbx $HOME
-fi
-if [ "$dtd421" = "" ] ; then
-    finddbx /usr/local
-fi
-if [ "$dtd421" = "" ] ; then
-    finddbx /usr/share/sgml
-fi
-
-if [ "$dtd421" = "" ] ; then
-    echo could not locate version $VERSION of DocBook XML
-    exit 1
-fi
-
-xmlcatalog --noout --add "public" \
-    "-//OASIS//ELEMENTS DocBook XML Information Pool V${VERSION}//EN" \
-    "file://$docbookdir/dbpoolx.mod" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//DTD DocBook XML V${VERSION}//EN" \
-    "file://$docbookdir/docbookx.dtd" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//ENTITIES DocBook XML Character Entities V${VERSION}//EN" \
-    "file://$docbookdir/dbcentx.mod" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//ENTITIES DocBook XML Notations V${VERSION}//EN" \
-    "file://$docbookdir/dbnotnx.mod" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//ENTITIES DocBook XML Additional General Entities V${VERSION}//EN" \
-    "file://$docbookdir/dbgenent.mod" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V${VERSION}//EN" \
-    "file://$docbookdir/dbhierx.mod" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
-    "file://$docbookdir/soextblx.dtd" $CATALOG
-xmlcatalog --noout --add "public" \
-    "-//OASIS//DTD DocBook XML CALS Table Model V${VERSION}//EN" \
-    "file://$docbookdir/calstblx.dtd" $CATALOG
-xmlcatalog --noout --add "rewriteSystem" \
-    "http://www.oasis-open.org/docbook/xml/${VERSION}" \
-    "file://$docbookdir" $CATALOG
-xmlcatalog --noout --add "rewriteURI" \
-    "http://www.oasis-open.org/docbook/xml/${VERSION}" \
-    "file://$docbookdir" $CATALOG
-
-xmlcatalog --noout --add "delegatePublic" \
-    "-//OASIS//ENTITIES DocBook XML" \
-    "file://$CATALOG" $ROOTCATALOG
-xmlcatalog --noout --add "delegatePublic" \
-    "-//OASIS//DTD DocBook XML" \
-    "file://$CATALOG" $ROOTCATALOG
-xmlcatalog --noout --add "delegateSystem" \
-    "http://www.oasis-open.org/docbook/" \
-    "file://$CATALOG" $ROOTCATALOG
-xmlcatalog --noout --add "delegateURI" \
-    "http://www.oasis-open.org/docbook/" \
-    "file://$CATALOG" $ROOTCATALOG
-
-#
-# find the prefix for ISO DocBook entities
-#
-top=`dirname $docbookdir`
-found=`find $top -name iso-amsb.ent`
-if [ "$found" = "" ] ; then
-    found=`find /usr/share/xml -name iso-amsb.ent`
-fi
-if [ "$found" = "" ] ; then
-    found=`find $HOME -name iso-amsb.ent`
-fi
-if [ "$found" = "" ] ; then
-    found=`find /usr/local -name iso-amsb.ent`
-fi
-if [ "$found" = "" ] ; then
-    found=`find /usr/share/sgml -name iso-amsb.ent`
-fi
-if [ "$found" = "" ] ; then
-    echo could not locate iso-amsb.ent of ISO DocBook entities
-    exit 1
-fi
-
-entxml=""
-for tst in $found; do
-    check=`grep '<!ENTITY ominus."\&#x2296;">' $tst`
-    if [ "$check" != "" ] ; then
-        entxml=$tst
-        break
-    fi
-done
-
-if [ "$entxml" = "" ] ; then
-    echo could not locate ISO DocBook entities
-    exit 1
-fi
-isodir=`dirname $entxml`
-echo Found ISO DocBook entities in $isodir
-
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Publishing//EN" \
-    "file://$isodir/iso-pub.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Greek Letters//EN" \
-    "file://$isodir/iso-grk1.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Box and Line Drawing//EN" \
-    "file://$isodir/iso-box.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Greek Symbols//EN" \
-    "file://$isodir/iso-grk3.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN" \
-    "file://$isodir/iso-amsn.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" \
-    "file://$isodir/iso-num.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN" \
-    "file://$isodir/iso-grk4.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Diacritical Marks//EN" \
-    "file://$isodir/iso-dia.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Monotoniko Greek//EN" \
-    "file://$isodir/iso-grk2.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN" \
-    "file://$isodir/iso-amsa.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN" \
-    "file://$isodir/iso-amso.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Russian Cyrillic//EN" \
-    "file://$isodir/iso-cyr1.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES General Technical//EN" \
-    "file://$isodir/iso-tech.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN" \
-    "file://$isodir/iso-amsc.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Latin 1//EN" \
-    "file://$isodir/iso-lat1.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN" \
-    "file://$isodir/iso-amsb.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Latin 2//EN" \
-    "file://$isodir/iso-lat2.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN" \
-    "file://$isodir/iso-amsr.ent" $CATALOG
-xmlcatalog --noout --add "public" \
-    "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN" \
-    "file://$isodir/iso-cyr2.ent" $CATALOG
-
-xmlcatalog --noout --add "delegatePublic" \
-    "ISO 8879:1986" \
-    "file://$CATALOG" $ROOTCATALOG
-
-#
-# find the prefix for XSLT stylesheets
-#
-top=`dirname $docbookdir`
-found=`find $top -name chunk.xsl`
-if [ "$found" = "" ] ; then
-    found=`find /usr/share/xml -name chunk.xsl`
-fi
-if [ "$found" = "" ] ; then
-    found=`find $HOME -name chunk.xsl`
-fi
-if [ "$found" = "" ] ; then
-    found=`find /usr/local -name chunk.xsl`
-fi
-if [ "$found" = "" ] ; then
-    found=`find /usr/share/sgml -name chunk.xsl`
-fi
-if [ "$found" = "" ] ; then
-    echo could not locate chunk-common.xsl of DocBook XSLT stylesheets
-    exit 1
-fi
-
-xsldir=""
-for tst in $found; do
-    dir=`dirname $tst`
-    dir=`dirname $dir`
-    if [ -r $dir/html/docbook.xsl -a -r $dir/common/l10n.xml ]; then
-        xsldir=$dir
-        break
-    fi
-done
-
-if [ "$xsldir" = "" ] ; then
-    echo could not locate DocBook XSLT stylesheets
-    exit 1
-fi
-echo Found DocBook XSLT stylesheets in $xsldir
-for version in current 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 \
-               1.48 1.49 1.50
-do
-    xmlcatalog --noout --add "rewriteSystem" \
-       "http://docbook.sourceforge.net/release/xsl/$version" \
-       "file://$xsldir" $CATALOG
-    xmlcatalog --noout --add "rewriteURI" \
-       "http://docbook.sourceforge.net/release/xsl/$version" \
-       "file://$xsldir" $CATALOG
-done
-
-xmlcatalog --noout --add "delegateSystem" \
-    "http://docbook.sourceforge.net/release/xsl/" \
-    "file://$CATALOG" $ROOTCATALOG
-xmlcatalog --noout --add "delegateURI" \
-    "http://docbook.sourceforge.net/release/xsl/" \
-    "file://$CATALOG" $ROOTCATALOG
-
-#
-#
diff --git a/doc/checkapisym.xsl b/doc/checkapisym.xsl
deleted file mode 100644 (file)
index 8591393..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0"?>
-<!-- This stylesheet is used to check that symbols exported
-     from libxml2-api.xml are also present in the symbol file
-     symbols.xml which is used to generate libxml2.syms setting
-     up the allowed access point to the shared libraries -->
-
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0">
-  <xsl:output method="text" encoding="UTF-8"/>
-
-  <xsl:variable name="syms" select="document('symbols.xml')"/>
-
-  <xsl:template match="/">
-    <xsl:message terminate="no">
-      <xsl:text>Looking for functions in symbols.xml</xsl:text>
-    </xsl:message>
-    <xsl:apply-templates select="/api/symbols/function"/>
-    <xsl:message terminate="no">
-      <xsl:text>Found </xsl:text>
-      <xsl:value-of select="count(/api/symbols/function)"/>
-      <xsl:text> functions</xsl:text>
-    </xsl:message>
-    <xsl:message terminate="no">
-      <xsl:text>Looking for variables in symbols.xml</xsl:text>
-    </xsl:message>
-    <xsl:apply-templates select="/api/symbols/variable"/>
-    <xsl:message terminate="no">
-      <xsl:text>Found </xsl:text>
-      <xsl:value-of select="count(/api/symbols/variable)"/>
-      <xsl:text> variables</xsl:text>
-    </xsl:message>
-  </xsl:template>
-
-  <xsl:template match="function|variable">
-    <xsl:variable name="name" select="@name"/>
-    <xsl:variable name="symbol"
-        select="$syms/symbols/release/symbol[. = $name]"/>
-    <xsl:if test="string($symbol) != $name">
-      <xsl:message terminate="yes">
-        <xsl:text>Failed to find export in symbols.xml: </xsl:text>
-        <xsl:value-of select="$name"/>
-      </xsl:message>
-    </xsl:if>
-  </xsl:template>
-
-</xsl:stylesheet>
-
index b658f67..3fce938 100644 (file)
       <xsl:when test="$ref">
         <a href="libxml2-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
       </xsl:when>
+      <!-- TODO: This hack only works for tokens followed by a period. -->
+      <xsl:when test="substring($token, string-length($token)) = '.'">
+        <xsl:variable name="token2" select="substring($token, 1, string-length($token) - 1)"/>
+        <xsl:variable name="ref2" select="key('symbols', $token2)"/>
+        <xsl:choose>
+          <xsl:when test="$ref2">
+            <a href="libxml2-{$ref2/@file}.html#{$ref2/@name}"><xsl:value-of select="$token2"/></a>
+            <xsl:text>.</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$token"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="$token"/>
       </xsl:otherwise>
index 12362b4..5b7865f 100644 (file)
@@ -42,9 +42,10 @@ typedef enum <a href="#htmlStatus">htmlStatus</a>;
 int    <a href="#UTF8ToHtml">UTF8ToHtml</a>                    (unsigned char * out, <br>                                       int * outlen, <br>                                      const unsigned char * in, <br>                                  int * inlen);
 <a href="libxml2-HTMLparser.html#htmlStatus">htmlStatus</a>    <a href="#htmlAttrAllowed">htmlAttrAllowed</a>          (const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> * elt, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * attr, <br>                                         int legacy);
 int    <a href="#htmlAutoCloseTag">htmlAutoCloseTag</a>                (<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a> doc, <br>                                   const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         <a href="libxml2-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> elem);
+<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlCreateFileParserCtxt">htmlCreateFileParserCtxt</a>        (const char * filename, <br>                                                     const char * encoding);
 <a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlCreateMemoryParserCtxt">htmlCreateMemoryParserCtxt</a>    (const char * buffer, <br>                                                       int size);
 <a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlCreatePushParserCtxt">htmlCreatePushParserCtxt</a>        (<a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br>                                                     void * user_data, <br>                                                  const char * chunk, <br>                                                        int size, <br>                                                  const char * filename, <br>                                                     <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
-<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>    <a href="#htmlCtxtReadDoc">htmlCtxtReadDoc</a>          (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options);
+<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>    <a href="#htmlCtxtReadDoc">htmlCtxtReadDoc</a>          (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 <a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>    <a href="#htmlCtxtReadFd">htmlCtxtReadFd</a>            (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    int fd, <br>                                    const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 <a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>    <a href="#htmlCtxtReadFile">htmlCtxtReadFile</a>        (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const char * filename, <br>                                     const char * encoding, <br>                                     int options);
 <a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>    <a href="#htmlCtxtReadIO">htmlCtxtReadIO</a>            (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                      void * ioctx, <br>                                      const char * URL, <br>                                  const char * encoding, <br>                                     int options);
@@ -58,9 +59,11 @@ const <a href="libxml2-HTMLparser.html#htmlEntityDesc">htmlEntityDesc</a> *  <a h
 const <a href="libxml2-HTMLparser.html#htmlEntityDesc">htmlEntityDesc</a> *    <a href="#htmlEntityValueLookup">htmlEntityValueLookup</a>      (unsigned int value);
 void   <a href="#htmlFreeParserCtxt">htmlFreeParserCtxt</a>            (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt);
 int    <a href="#htmlHandleOmittedElem">htmlHandleOmittedElem</a>              (int val);
+void   <a href="#htmlInitAutoClose">htmlInitAutoClose</a>              (void);
 int    <a href="#htmlIsAutoClosed">htmlIsAutoClosed</a>                (<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a> doc, <br>                                   <a href="libxml2-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> elem);
 int    <a href="#htmlIsScriptAttribute">htmlIsScriptAttribute</a>              (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
 <a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlNewParserCtxt">htmlNewParserCtxt</a>      (void);
+<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlNewSAXParserCtxt">htmlNewSAXParserCtxt</a>        (const <a href="libxml2-HTMLparser.html#htmlSAXHandler">htmlSAXHandler</a> * sax, <br>                                           void * userData);
 <a href="libxml2-HTMLparser.html#htmlStatus">htmlStatus</a>    <a href="#htmlNodeStatus">htmlNodeStatus</a>            (const <a href="libxml2-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> node, <br>                                  int legacy);
 int    <a href="#htmlParseCharRef">htmlParseCharRef</a>                (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt);
 int    <a href="#htmlParseChunk">htmlParseChunk</a>                    (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const char * chunk, <br>                                        int size, <br>                                  int terminate);
@@ -385,6 +388,31 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *    <a href=
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="htmlCreateFileParserCtxt"></a>htmlCreateFileParserCtxt ()</h3>
+<pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>  htmlCreateFileParserCtxt        (const char * filename, <br>                                                     const char * encoding)<br>
+</pre>
+<p>Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>filename</tt></i>:</span></td>
+<td>the filename</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>encoding</tt></i>:</span></td>
+<td>a free form C string describing the HTML document encoding, or NULL</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the new parser context or NULL</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="htmlCreateMemoryParserCtxt"></a>htmlCreateMemoryParserCtxt ()</h3>
 <pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>  htmlCreateMemoryParserCtxt      (const char * buffer, <br>                                                       int size)<br>
 </pre>
@@ -452,7 +480,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *     <a href=
 <div class="refsect2" lang="en">
 <h3>
 <a name="htmlCtxtReadDoc"></a>htmlCtxtReadDoc ()</h3>
-<pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>        htmlCtxtReadDoc         (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
+<pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>        htmlCtxtReadDoc         (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
 <p>parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context</p>
 <div class="variablelist"><table border="0">
@@ -463,7 +491,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *     <a href=
 <td>an HTML parser context</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>cur</tt></i>:</span></td>
+<td><span class="term"><i><tt>str</tt></i>:</span></td>
 <td>a pointer to a zero terminated string</td>
 </tr>
 <tr>
@@ -850,6 +878,14 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *    <a href=
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="htmlInitAutoClose"></a>htmlInitAutoClose ()</h3>
+<pre class="programlisting">void       htmlInitAutoClose               (void)<br>
+</pre>
+<p>DEPRECATED: This is a no-op.</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="htmlIsAutoClosed"></a>htmlIsAutoClosed ()</h3>
 <pre class="programlisting">int        htmlIsAutoClosed                (<a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a> doc, <br>                                   <a href="libxml2-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> elem)<br>
 </pre>
@@ -911,6 +947,31 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *    <a href=
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="htmlNewSAXParserCtxt"></a>htmlNewSAXParserCtxt ()</h3>
+<pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>  htmlNewSAXParserCtxt    (const <a href="libxml2-HTMLparser.html#htmlSAXHandler">htmlSAXHandler</a> * sax, <br>                                           void * userData)<br>
+</pre>
+<p>Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>sax</tt></i>:</span></td>
+<td>SAX handler</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>userData</tt></i>:</span></td>
+<td>user data</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the <a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> or NULL in case of allocation error</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="htmlNodeStatus"></a>htmlNodeStatus ()</h3>
 <pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlStatus">htmlStatus</a>        htmlNodeStatus          (const <a href="libxml2-HTMLparser.html#htmlNodePtr">htmlNodePtr</a> node, <br>                                  int legacy)<br>
 </pre>
@@ -939,7 +1000,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *    <a href=
 <a name="htmlParseCharRef"></a>htmlParseCharRef ()</h3>
 <pre class="programlisting">int        htmlParseCharRef                (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse Reference declarations [66] CharRef ::= '&amp;#' [0-9]+ ';' | '&amp;#x' [0-9a-fA-F]+ ';'</p>
+<p>DEPRECATED: Internal function, don't use. parse Reference declarations [66] CharRef ::= '&amp;#' [0-9]+ ';' | '&amp;#x' [0-9a-fA-F]+ ';'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1040,7 +1101,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *   <a href=
 <a name="htmlParseElement"></a>htmlParseElement ()</h3>
 <pre class="programlisting">void       htmlParseElement                (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an HTML element, this is highly recursive this is kept for compatibility with previous code versions [39] element ::= EmptyElemTag | STag content ETag [41] Attribute ::= Name Eq AttValue</p>
+<p>DEPRECATED: Internal function, don't use. parse an HTML element, this is highly recursive this is kept for compatibility with previous code versions [39] element ::= EmptyElemTag | STag content ETag [41] Attribute ::= Name Eq AttValue</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1055,7 +1116,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *   <a href=
 <a name="htmlParseEntityRef"></a>htmlParseEntityRef ()</h3>
 <pre class="programlisting">const <a href="libxml2-HTMLparser.html#htmlEntityDesc">htmlEntityDesc</a> *        htmlParseEntityRef      (<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a> ctxt, <br>                                            const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** str)<br>
 </pre>
-<p>parse an HTML ENTITY references [68] EntityRef ::= '&amp;' Name ';'</p>
+<p>DEPRECATED: Internal function, don't use. parse an HTML ENTITY references [68] EntityRef ::= '&amp;' Name ';'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1278,7 +1339,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *   <a href=
 <a name="htmlSAXParseDoc"></a>htmlSAXParseDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>        htmlSAXParseDoc         (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * encoding, <br>                                     <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br>                                     void * userData)<br>
 </pre>
-<p>Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</p>
+<p>DEPRECATED: Use <a href="libxml2-HTMLparser.html#htmlNewSAXParserCtxt">htmlNewSAXParserCtxt</a> and <a href="libxml2-HTMLparser.html#htmlCtxtReadDoc">htmlCtxtReadDoc</a>. Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1312,7 +1373,7 @@ const <a href="libxml2-HTMLparser.html#htmlElemDesc">htmlElemDesc</a> *   <a href=
 <a name="htmlSAXParseFile"></a>htmlSAXParseFile ()</h3>
 <pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlDocPtr">htmlDocPtr</a>        htmlSAXParseFile        (const char * filename, <br>                                     const char * encoding, <br>                                     <a href="libxml2-HTMLparser.html#htmlSAXHandlerPtr">htmlSAXHandlerPtr</a> sax, <br>                                     void * userData)<br>
 </pre>
-<p>parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
+<p>DEPRECATED: Use <a href="libxml2-HTMLparser.html#htmlNewSAXParserCtxt">htmlNewSAXParserCtxt</a> and <a href="libxml2-HTMLparser.html#htmlCtxtReadFile">htmlCtxtReadFile</a>. parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 203cb38..7e60ab6 100644 (file)
@@ -250,7 +250,7 @@ int <a href="#htmlSetMetaEncoding">htmlSetMetaEncoding</a>          (<a href="libxml2-HT
 <a name="htmlIsBooleanAttr"></a>htmlIsBooleanAttr ()</h3>
 <pre class="programlisting">int        htmlIsBooleanAttr               (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Determine if a given <a href="libxml2-SAX.html#attribute">attribute</a> is a boolean attribute.</p>
+<p>Determine if a given <a href="libxml2-SAX.html#attribute">attribute</a> is a boolean <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index b87a6e6..632836c 100644 (file)
@@ -827,7 +827,7 @@ void        <a href="#unparsedEntityDecl">unparsedEntityDecl</a>            (void * ctx, <br>
 <a name="setDocumentLocator"></a>setDocumentLocator ()</h3>
 <pre class="programlisting">void       setDocumentLocator              (void * ctx, <br>                                        <a href="libxml2-tree.html#xmlSAXLocatorPtr">xmlSAXLocatorPtr</a> loc)<br>
 </pre>
-<p>Receive the document locator at startup, actually <a href="libxml2-globals.html#xmlDefaultSAXLocator">xmlDefaultSAXLocator</a> Everything is available on the context, so this is useless in our case. DEPRECATED</p>
+<p>Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case. DEPRECATED</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 170423c..9d4e2c6 100644 (file)
@@ -69,7 +69,7 @@ int   <a href="#xmlSAXVersion">xmlSAXVersion</a>                      (<a href="libxml2-tree.html#xml
 <a name="htmlDefaultSAXHandlerInit"></a>htmlDefaultSAXHandlerInit ()</h3>
 <pre class="programlisting">void       htmlDefaultSAXHandlerInit       (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the default SAX handler</p>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -77,7 +77,7 @@ int   <a href="#xmlSAXVersion">xmlSAXVersion</a>                      (<a href="libxml2-tree.html#xml
 <a name="xmlDefaultSAXHandlerInit"></a>xmlDefaultSAXHandlerInit ()</h3>
 <pre class="programlisting">void       xmlDefaultSAXHandlerInit        (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the default SAX2 handler</p>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the default SAX2 handler</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -750,7 +750,7 @@ int <a href="#xmlSAXVersion">xmlSAXVersion</a>                      (<a href="libxml2-tree.html#xml
 <a name="xmlSAX2SetDocumentLocator"></a>xmlSAX2SetDocumentLocator ()</h3>
 <pre class="programlisting">void       xmlSAX2SetDocumentLocator       (void * ctx, <br>                                        <a href="libxml2-tree.html#xmlSAXLocatorPtr">xmlSAXLocatorPtr</a> loc)<br>
 </pre>
-<p>Receive the document locator at startup, actually <a href="libxml2-globals.html#xmlDefaultSAXLocator">xmlDefaultSAXLocator</a> Everything is available on the context, so this is useless in our case.</p>
+<p>Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -893,7 +893,7 @@ int <a href="#xmlSAXVersion">xmlSAXVersion</a>                      (<a href="libxml2-tree.html#xml
 <a name="xmlSAXDefaultVersion"></a>xmlSAXDefaultVersion ()</h3>
 <pre class="programlisting">int        xmlSAXDefaultVersion            (int version)<br>
 </pre>
-<p>Set the default version of SAX used globally by the library. By default, during initialization the default is set to 2. Note that it is generally a better coding style to use xmlSAXVersion() to set up the version explicitly for a given parsing context.</p>
+<p>DEPRECATED: Use parser option <a href="libxml2-parser.html#XML_PARSE_SAX1">XML_PARSE_SAX1</a>. Set the default version of SAX used globally by the library. By default, during initialization the default is set to 2. Note that it is generally a better coding style to use xmlSAXVersion() to set up the version explicitly for a given parsing context.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 5a2c883..d2a56c1 100644 (file)
@@ -66,7 +66,7 @@ The content of this structure is not made public by the API.
 <a name="xmlDictCleanup"></a>xmlDictCleanup ()</h3>
 <pre class="programlisting">void       xmlDictCleanup                  (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all. Free the dictionary mutex. Do not call unless sure the library is not in use anymore !</p>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -110,7 +110,7 @@ The content of this structure is not made public by the API.
 <a name="xmlDictExists"></a>xmlDictExists ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlDictExists           (<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         int len)<br>
 </pre>
-<p>Check if the @name exists in the dictionary @dict.</p>
+<p>Check if a string exists in the dictionary.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -175,25 +175,25 @@ The content of this structure is not made public by the API.
 <a name="xmlDictLookup"></a>xmlDictLookup ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlDictLookup           (<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         int len)<br>
 </pre>
-<p>Add the @name to the dictionary @dict if not present.</p>
+<p>Lookup a string and add it to the dictionary if it wasn't found.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
 <td><span class="term"><i><tt>dict</tt></i>:</span></td>
-<td>the dictionary</td>
+<td>dictionary</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td>string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>len</tt></i>:</span></td>
-<td>the length of the name, if -1 it is recomputed</td>
+<td>length of the key, if -1 it is recomputed</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the internal copy of the name or NULL in case of internal error</td>
+<td>the interned copy of the string or NULL if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -229,7 +229,7 @@ The content of this structure is not made public by the API.
 <a name="xmlDictQLookup"></a>xmlDictQLookup ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlDictQLookup          (<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Add the QName @prefix:@name to the hash @dict if not present.</p>
+<p>Lookup the QName @prefix:@name and add it to the dictionary if it wasn't found.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -247,7 +247,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the internal copy of the QName or NULL in case of internal error</td>
+<td>the interned copy of the string or NULL if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -325,12 +325,12 @@ The content of this structure is not made public by the API.
 <a name="xmlInitializeDict"></a>xmlInitializeDict ()</h3>
 <pre class="programlisting">int        xmlInitializeDict               (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Do the dictionary mutex initialization.</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 if initialization was already done, and 1 if that call led to the initialization</td>
+<td>0.</td>
 </tr></tbody>
 </table></div>
 </div>
index 94d7057..3978247 100644 (file)
@@ -22,7 +22,8 @@
 <p>Author(s): Daniel Veillard </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
-<pre class="synopsis">typedef enum <a href="#xmlCharEncoding">xmlCharEncoding</a>;
+<pre class="synopsis">typedef enum <a href="#xmlCharEncError">xmlCharEncError</a>;
+typedef enum <a href="#xmlCharEncoding">xmlCharEncoding</a>;
 typedef struct _xmlCharEncodingHandler <a href="#xmlCharEncodingHandler">xmlCharEncodingHandler</a>;
 typedef <a href="libxml2-encoding.html#xmlCharEncodingHandler">xmlCharEncodingHandler</a> * <a href="#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a>;
 int    <a href="#UTF8Toisolat1">UTF8Toisolat1</a>                      (unsigned char * out, <br>                                       int * outlen, <br>                                      const unsigned char * in, <br>                                  int * inlen);
@@ -54,6 +55,21 @@ void <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 <div class="refsect2" lang="en">
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlCharEncError">Enum </a>xmlCharEncError</h3>
+<pre class="programlisting">enum <a href="#xmlCharEncError">xmlCharEncError</a> {
+    <a name="XML_ENC_ERR_MEMORY">XML_ENC_ERR_MEMORY</a> = -5
+    <a name="XML_ENC_ERR_INTERNAL">XML_ENC_ERR_INTERNAL</a> = -4
+    <a name="XML_ENC_ERR_PARTIAL">XML_ENC_ERR_PARTIAL</a> = -3
+    <a name="XML_ENC_ERR_INPUT">XML_ENC_ERR_INPUT</a> = -2
+    <a name="XML_ENC_ERR_SPACE">XML_ENC_ERR_SPACE</a> = -1
+    <a name="XML_ENC_ERR_SUCCESS">XML_ENC_ERR_SUCCESS</a> = 0
+};
+</pre>
+<p></p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlCharEncoding">Enum </a>xmlCharEncoding</h3>
 <pre class="programlisting">enum <a href="#xmlCharEncoding">xmlCharEncoding</a> {
     <a name="XML_CHAR_ENCODING_ERROR">XML_CHAR_ENCODING_ERROR</a> = -1 /* No char encoding detected */
@@ -202,7 +218,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of bytes written if success, -2 if the transcoding fails, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.</td>
+<td>the number of bytes written or an XML_ENC_ERR code. The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.</td>
 </tr>
 </tbody>
 </table></div>
@@ -235,7 +251,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of bytes written if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.</td>
+<td>the number of bytes written or an XML_ENC_ERR code. The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.</td>
 </tr>
 </tbody>
 </table></div>
@@ -292,7 +308,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 <a name="xmlCharEncFirstLine"></a>xmlCharEncFirstLine ()</h3>
 <pre class="programlisting">int        xmlCharEncFirstLine             (<a href="libxml2-encoding.html#xmlCharEncodingHandler">xmlCharEncodingHandler</a> * handler, <br>                                       <a href="libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> out, <br>                                     <a href="libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> in)<br>
 </pre>
-<p>Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.</p>
+<p>DEPERECATED: Don't use.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -310,7 +326,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or</td>
+<td>the number of bytes written or an XML_ENC_ERR code.</td>
 </tr>
 </tbody>
 </table></div>
@@ -339,7 +355,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or</td>
+<td>the number of bytes written or an XML_ENC_ERR code.</td>
 </tr>
 </tbody>
 </table></div>
@@ -368,7 +384,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or</td>
+<td>the number of bytes written or an XML_ENC_ERR code.</td>
 </tr>
 </tbody>
 </table></div>
@@ -441,7 +457,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 <a name="xmlFindCharEncodingHandler"></a>xmlFindCharEncodingHandler ()</h3>
 <pre class="programlisting"><a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a>    xmlFindCharEncodingHandler      (const char * name)<br>
 </pre>
-<p>Search in the registered set the handler able to read/write that encoding.</p>
+<p>Search in the registered set the handler able to read/write that encoding or create a new one.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -525,7 +541,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 <a name="xmlInitCharEncodingHandlers"></a>xmlInitCharEncodingHandlers ()</h3>
 <pre class="programlisting">void       xmlInitCharEncodingHandlers     (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the char encoding support, it registers the default encoding supported. NOTE: while public, this function usually doesn't need to be called in normal processing.</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -533,7 +549,7 @@ void        <a href="#xmlRegisterCharEncodingHandler">xmlRegisterCharEncodingHandler</a
 <a name="xmlNewCharEncodingHandler"></a>xmlNewCharEncodingHandler ()</h3>
 <pre class="programlisting"><a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a>    xmlNewCharEncodingHandler       (const char * name, <br>                                                         <a href="libxml2-encoding.html#xmlCharEncodingInputFunc">xmlCharEncodingInputFunc</a> input, <br>                                                       <a href="libxml2-encoding.html#xmlCharEncodingOutputFunc">xmlCharEncodingOutputFunc</a> output)<br>
 </pre>
-<p>Create and registers an xmlCharEncodingHandler.</p>
+<p>Create and registers an <a href="libxml2-encoding.html#xmlCharEncodingHandler">xmlCharEncodingHandler</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 2b0ea58..e21cbcf 100644 (file)
@@ -36,6 +36,7 @@ const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *  <a href="#xmlEncode
 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlEncodeEntitiesReentrant">xmlEncodeEntitiesReentrant</a>    (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                           const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * input);
 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlEncodeSpecialChars">xmlEncodeSpecialChars</a>      (const <a href="libxml2-tree.html#xmlDoc">xmlDoc</a> * doc, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * input);
 void   <a href="#xmlFreeEntitiesTable">xmlFreeEntitiesTable</a>                (<a href="libxml2-entities.html#xmlEntitiesTablePtr">xmlEntitiesTablePtr</a> table);
+void   <a href="#xmlFreeEntity">xmlFreeEntity</a>                      (<a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a> entity);
 <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>      <a href="#xmlGetDocEntity">xmlGetDocEntity</a>          (const <a href="libxml2-tree.html#xmlDoc">xmlDoc</a> * doc, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
 <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>      <a href="#xmlGetDtdEntity">xmlGetDtdEntity</a>          (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
 <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>      <a href="#xmlGetParameterEntity">xmlGetParameterEntity</a>      (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
@@ -341,6 +342,21 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlFreeEntity"></a>xmlFreeEntity ()</h3>
+<pre class="programlisting">void       xmlFreeEntity                   (<a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a> entity)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody><tr>
+<td><span class="term"><i><tt>entity</tt></i>:</span></td>
+<td></td>
+</tr></tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlGetDocEntity"></a>xmlGetDocEntity ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>  xmlGetDocEntity         (const <a href="libxml2-tree.html#xmlDoc">xmlDoc</a> * doc, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
index d3b24a6..dbd7b3e 100644 (file)
 </tr></table>
 <h2><span class="refentrytitle">globals</span></h2>
 <p>globals - interface for all global variables of the library</p>
-<p>all the global variables and thread handling for those variables is handled by this module.  The bottom of this file is automatically generated by build_glob.py based on the description file global.data </p>
-<p>Author(s): Gary Pennington &lt;Gary.Pennington@uk.sun.com&gt;, Daniel Veillard </p>
+<p>Deprecated, don't use </p>
+<p>Author(s): </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
 <pre class="synopsis">typedef struct _xmlGlobalState <a href="#xmlGlobalState">xmlGlobalState</a>;
 typedef <a href="libxml2-globals.html#xmlGlobalState">xmlGlobalState</a> * <a href="#xmlGlobalStatePtr">xmlGlobalStatePtr</a>;
 void   <a href="#xmlCleanupGlobals">xmlCleanupGlobals</a>              (void);
-<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> <a href="#xmlDeregisterNodeDefault">xmlDeregisterNodeDefault</a>        (<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func);
-typedef void <a href="#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>                (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
+<a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> <a href="#xmlGetGlobalState">xmlGetGlobalState</a>      (void);
 void   <a href="#xmlInitGlobals">xmlInitGlobals</a>                    (void);
 void   <a href="#xmlInitializeGlobalState">xmlInitializeGlobalState</a>        (<a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> gs);
-<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> <a href="#xmlOutputBufferCreateFilenameDefault">xmlOutputBufferCreateFilenameDefault</a>        (<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func);
-typedef <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> <a href="#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>       (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder, <br>                                                   int compression);
-<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>       <a href="#xmlParserInputBufferCreateFilenameDefault">xmlParserInputBufferCreateFilenameDefault</a>      (<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func);
-typedef <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a> <a href="#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>   (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
-<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>     <a href="#xmlRegisterNodeDefault">xmlRegisterNodeDefault</a>    (<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func);
-typedef void <a href="#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>            (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
-<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a>    <a href="#xmlThrDefBufferAllocScheme">xmlThrDefBufferAllocScheme</a>    (<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> v);
-int    <a href="#xmlThrDefDefaultBufferSize">xmlThrDefDefaultBufferSize</a>    (int v);
-<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> <a href="#xmlThrDefDeregisterNodeDefault">xmlThrDefDeregisterNodeDefault</a>    (<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func);
-int    <a href="#xmlThrDefDoValidityCheckingDefaultValue">xmlThrDefDoValidityCheckingDefaultValue</a>  (int v);
-int    <a href="#xmlThrDefGetWarningsDefaultValue">xmlThrDefGetWarningsDefaultValue</a>        (int v);
-int    <a href="#xmlThrDefIndentTreeOutput">xmlThrDefIndentTreeOutput</a>      (int v);
-int    <a href="#xmlThrDefKeepBlanksDefaultValue">xmlThrDefKeepBlanksDefaultValue</a>  (int v);
-int    <a href="#xmlThrDefLineNumbersDefaultValue">xmlThrDefLineNumbersDefaultValue</a>        (int v);
-int    <a href="#xmlThrDefLoadExtDtdDefaultValue">xmlThrDefLoadExtDtdDefaultValue</a>  (int v);
-<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> <a href="#xmlThrDefOutputBufferCreateFilenameDefault">xmlThrDefOutputBufferCreateFilenameDefault</a>    (<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func);
-int    <a href="#xmlThrDefParserDebugEntities">xmlThrDefParserDebugEntities</a>        (int v);
-<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>       <a href="#xmlThrDefParserInputBufferCreateFilenameDefault">xmlThrDefParserInputBufferCreateFilenameDefault</a>  (<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func);
-int    <a href="#xmlThrDefPedanticParserDefaultValue">xmlThrDefPedanticParserDefaultValue</a>  (int v);
-<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>     <a href="#xmlThrDefRegisterNodeDefault">xmlThrDefRegisterNodeDefault</a>        (<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func);
-int    <a href="#xmlThrDefSaveNoEmptyTags">xmlThrDefSaveNoEmptyTags</a>        (int v);
-void   <a href="#xmlThrDefSetGenericErrorFunc">xmlThrDefSetGenericErrorFunc</a>        (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> handler);
-void   <a href="#xmlThrDefSetStructuredErrorFunc">xmlThrDefSetStructuredErrorFunc</a>  (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> handler);
-int    <a href="#xmlThrDefSubstituteEntitiesDefaultValue">xmlThrDefSubstituteEntitiesDefaultValue</a>  (int v);
-const char *   <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>      (const char * v);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -64,39 +38,7 @@ const char * <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>
 <h3>
 <a name="xmlGlobalState">Structure </a>xmlGlobalState</h3>
 <pre class="programlisting">struct _xmlGlobalState {
-    const char *       xmlParserVersion
-    <a href="libxml2-tree.html#xmlSAXLocator">xmlSAXLocator</a>        xmlDefaultSAXLocator
-    <a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a>  xmlDefaultSAXHandler
-    <a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a>  docbDefaultSAXHandler   : unused
-    <a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a>  htmlDefaultSAXHandler
-    <a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a>       xmlFree
-    <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a>   xmlMalloc
-    <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a>   xmlMemStrdup
-    <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> xmlRealloc
-    <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a>        xmlGenericError
-    <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>  xmlStructuredError
-    void *     xmlGenericErrorContext
-    int        oldXMLWDcompatibility
-    <a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a>        xmlBufferAllocScheme
-    int        xmlDefaultBufferSize
-    int        xmlSubstituteEntitiesDefaultValue
-    int        xmlDoValidityCheckingDefaultValue
-    int        xmlGetWarningsDefaultValue
-    int        xmlKeepBlanksDefaultValue
-    int        xmlLineNumbersDefaultValue
-    int        xmlLoadExtDtdDefaultValue
-    int        xmlParserDebugEntities
-    int        xmlPedanticParserDefaultValue
-    int        xmlSaveNoEmptyTags
-    int        xmlIndentTreeOutput
-    const char *       xmlTreeIndentString
-    <a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> xmlRegisterNodeDefaultValue
-    <a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>     xmlDeregisterNodeDefaultValue
-    <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a>   xmlMallocAtomic
-    <a href="libxml2-xmlerror.html#xmlError">xmlError</a>      xmlLastError
-    <a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>   xmlParserInputBufferCreateFilenameValue
-    <a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>     xmlOutputBufferCreateFilenameValue
-    void *     xmlStructuredErrorContext
+The content of this structure is not made public by the API.
 } xmlGlobalState;
 </pre>
 <p></p>
@@ -112,370 +54,24 @@ const char *      <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlDeregisterNodeFunc"></a>Function type xmlDeregisterNodeFunc</h3>
-<pre class="programlisting">void       xmlDeregisterNodeFunc           (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
-</pre>
-<p>Signature for the deregistration callback of a discarded node</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>node</tt></i>:</span></td>
-<td>the current node</td>
-</tr></tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlOutputBufferCreateFilenameFunc"></a>Function type xmlOutputBufferCreateFilenameFunc</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>      xmlOutputBufferCreateFilenameFunc       (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder, <br>                                                   int compression)<br>
-</pre>
-<p>Signature for the function doing the lookup for a suitable output method corresponding to an URI.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>URI</tt></i>:</span></td>
-<td>the URI to write to</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>encoder</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>compression</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the new <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> in case of success or NULL if no method was found.</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlParserInputBufferCreateFilenameFunc"></a>Function type xmlParserInputBufferCreateFilenameFunc</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>    xmlParserInputBufferCreateFilenameFunc  (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc)<br>
-</pre>
-<p>Signature for the function doing the lookup for a suitable input method corresponding to an URI.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>URI</tt></i>:</span></td>
-<td>the URI to read from</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>enc</tt></i>:</span></td>
-<td>the requested source encoding</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the new <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a> in case of success or NULL if no method was found.</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlRegisterNodeFunc"></a>Function type xmlRegisterNodeFunc</h3>
-<pre class="programlisting">void       xmlRegisterNodeFunc             (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
-</pre>
-<p>Signature for the registration callback of a created node</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>node</tt></i>:</span></td>
-<td>the current node</td>
-</tr></tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="htmlDefaultSAXHandler">Variable </a>htmlDefaultSAXHandler</h3>
-<pre class="programlisting"><a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a> htmlDefaultSAXHandler;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="oldXMLWDcompatibility">Variable </a>oldXMLWDcompatibility</h3>
-<pre class="programlisting">int oldXMLWDcompatibility;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlBufferAllocScheme">Variable </a>xmlBufferAllocScheme</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> xmlBufferAllocScheme;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlDefaultBufferSize">Variable </a>xmlDefaultBufferSize</h3>
-<pre class="programlisting">int xmlDefaultBufferSize;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlDefaultSAXHandler">Variable </a>xmlDefaultSAXHandler</h3>
-<pre class="programlisting"><a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a> xmlDefaultSAXHandler;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlDefaultSAXLocator">Variable </a>xmlDefaultSAXLocator</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlSAXLocator">xmlSAXLocator</a> xmlDefaultSAXLocator;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlDeregisterNodeDefaultValue">Variable </a>xmlDeregisterNodeDefaultValue</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> xmlDeregisterNodeDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlDoValidityCheckingDefaultValue">Variable </a>xmlDoValidityCheckingDefaultValue</h3>
-<pre class="programlisting">int xmlDoValidityCheckingDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlFree">Variable </a>xmlFree</h3>
-<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> xmlFree;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlGenericError">Variable </a>xmlGenericError</h3>
-<pre class="programlisting"><a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> xmlGenericError;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlGenericErrorContext">Variable </a>xmlGenericErrorContext</h3>
-<pre class="programlisting">void * xmlGenericErrorContext;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlGetWarningsDefaultValue">Variable </a>xmlGetWarningsDefaultValue</h3>
-<pre class="programlisting">int xmlGetWarningsDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlIndentTreeOutput">Variable </a>xmlIndentTreeOutput</h3>
-<pre class="programlisting">int xmlIndentTreeOutput;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlKeepBlanksDefaultValue">Variable </a>xmlKeepBlanksDefaultValue</h3>
-<pre class="programlisting">int xmlKeepBlanksDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlLastError">Variable </a>xmlLastError</h3>
-<pre class="programlisting"><a href="libxml2-xmlerror.html#xmlError">xmlError</a> xmlLastError;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlLineNumbersDefaultValue">Variable </a>xmlLineNumbersDefaultValue</h3>
-<pre class="programlisting">int xmlLineNumbersDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlLoadExtDtdDefaultValue">Variable </a>xmlLoadExtDtdDefaultValue</h3>
-<pre class="programlisting">int xmlLoadExtDtdDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlMalloc">Variable </a>xmlMalloc</h3>
-<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMalloc;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlMallocAtomic">Variable </a>xmlMallocAtomic</h3>
-<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMallocAtomic;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlMemStrdup">Variable </a>xmlMemStrdup</h3>
-<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> xmlMemStrdup;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlOutputBufferCreateFilenameValue">Variable </a>xmlOutputBufferCreateFilenameValue</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> xmlOutputBufferCreateFilenameValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlParserDebugEntities">Variable </a>xmlParserDebugEntities</h3>
-<pre class="programlisting">int xmlParserDebugEntities;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlParserInputBufferCreateFilenameValue">Variable </a>xmlParserInputBufferCreateFilenameValue</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> xmlParserInputBufferCreateFilenameValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlParserVersion">Variable </a>xmlParserVersion</h3>
-<pre class="programlisting">const char * xmlParserVersion;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlPedanticParserDefaultValue">Variable </a>xmlPedanticParserDefaultValue</h3>
-<pre class="programlisting">int xmlPedanticParserDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlRealloc">Variable </a>xmlRealloc</h3>
-<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> xmlRealloc;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlRegisterNodeDefaultValue">Variable </a>xmlRegisterNodeDefaultValue</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> xmlRegisterNodeDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlSaveNoEmptyTags">Variable </a>xmlSaveNoEmptyTags</h3>
-<pre class="programlisting">int xmlSaveNoEmptyTags;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlStructuredError">Variable </a>xmlStructuredError</h3>
-<pre class="programlisting"><a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> xmlStructuredError;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlStructuredErrorContext">Variable </a>xmlStructuredErrorContext</h3>
-<pre class="programlisting">void * xmlStructuredErrorContext;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlSubstituteEntitiesDefaultValue">Variable </a>xmlSubstituteEntitiesDefaultValue</h3>
-<pre class="programlisting">int xmlSubstituteEntitiesDefaultValue;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlTreeIndentString">Variable </a>xmlTreeIndentString</h3>
-<pre class="programlisting">const char * xmlTreeIndentString;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlCleanupGlobals"></a>xmlCleanupGlobals ()</h3>
 <pre class="programlisting">void       xmlCleanupGlobals               (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all. Additional cleanup for multi-threading</p>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlDeregisterNodeDefault"></a>xmlDeregisterNodeDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>     xmlDeregisterNodeDefault        (<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func)<br>
+<a name="xmlGetGlobalState"></a>xmlGetGlobalState ()</h3>
+<pre class="programlisting"><a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a>     xmlGetGlobalState       (void)<br>
 </pre>
-<p>Registers a callback for node destruction</p>
+<p>DEPRECATED</p>
 <div class="variablelist"><table border="0">
 <col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td>function pointer to the new DeregisterNodeFunc</td>
-</tr>
-<tr>
+<tbody><tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the previous value of the deregistration function</td>
-</tr>
-</tbody>
+<td>NULL.</td>
+</tr></tbody>
 </table></div>
 </div>
 <hr>
@@ -484,7 +80,7 @@ const char * <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>
 <a name="xmlInitGlobals"></a>xmlInitGlobals ()</h3>
 <pre class="programlisting">void       xmlInitGlobals                  (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Additional initialisation for multi-threading</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -492,7 +88,7 @@ const char * <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>
 <a name="xmlInitializeGlobalState"></a>xmlInitializeGlobalState ()</h3>
 <pre class="programlisting">void       xmlInitializeGlobalState        (<a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> gs)<br>
 </pre>
-<p>xmlInitializeGlobalState() initialize a global state with all the default values of the library.</p>
+<p>DEPRECATED: No-op.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -502,468 +98,6 @@ const char *       <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>
 </table></div>
 </div>
 <hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlOutputBufferCreateFilenameDefault"></a>xmlOutputBufferCreateFilenameDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>     xmlOutputBufferCreateFilenameDefault    (<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func)<br>
-</pre>
-<p>Registers a callback for URI output file handling</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td>function pointer to the new OutputBufferCreateFilenameFunc</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the old value of the registration function</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlParserInputBufferCreateFilenameDefault"></a>xmlParserInputBufferCreateFilenameDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>   xmlParserInputBufferCreateFilenameDefault       (<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func)<br>
-</pre>
-<p>Registers a callback for URI input file handling</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td>function pointer to the new ParserInputBufferCreateFilenameFunc</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the old value of the registration function</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlRegisterNodeDefault"></a>xmlRegisterNodeDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> xmlRegisterNodeDefault  (<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func)<br>
-</pre>
-<p>Registers a callback for node creation</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td>function pointer to the new RegisterNodeFunc</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the old value of the registration function</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefBufferAllocScheme"></a>xmlThrDefBufferAllocScheme ()</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a>        xmlThrDefBufferAllocScheme      (<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefDefaultBufferSize"></a>xmlThrDefDefaultBufferSize ()</h3>
-<pre class="programlisting">int        xmlThrDefDefaultBufferSize      (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefDeregisterNodeDefault"></a>xmlThrDefDeregisterNodeDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>     xmlThrDefDeregisterNodeDefault  (<a href="libxml2-globals.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefDoValidityCheckingDefaultValue"></a>xmlThrDefDoValidityCheckingDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefDoValidityCheckingDefaultValue (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefGetWarningsDefaultValue"></a>xmlThrDefGetWarningsDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefGetWarningsDefaultValue        (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefIndentTreeOutput"></a>xmlThrDefIndentTreeOutput ()</h3>
-<pre class="programlisting">int        xmlThrDefIndentTreeOutput       (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefKeepBlanksDefaultValue"></a>xmlThrDefKeepBlanksDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefKeepBlanksDefaultValue (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefLineNumbersDefaultValue"></a>xmlThrDefLineNumbersDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefLineNumbersDefaultValue        (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefLoadExtDtdDefaultValue"></a>xmlThrDefLoadExtDtdDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefLoadExtDtdDefaultValue (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefOutputBufferCreateFilenameDefault"></a>xmlThrDefOutputBufferCreateFilenameDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>     xmlThrDefOutputBufferCreateFilenameDefault      (<a href="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefParserDebugEntities"></a>xmlThrDefParserDebugEntities ()</h3>
-<pre class="programlisting">int        xmlThrDefParserDebugEntities    (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefParserInputBufferCreateFilenameDefault"></a>xmlThrDefParserInputBufferCreateFilenameDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>   xmlThrDefParserInputBufferCreateFilenameDefault (<a href="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefPedanticParserDefaultValue"></a>xmlThrDefPedanticParserDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefPedanticParserDefaultValue     (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefRegisterNodeDefault"></a>xmlThrDefRegisterNodeDefault ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> xmlThrDefRegisterNodeDefault    (<a href="libxml2-globals.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>func</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefSaveNoEmptyTags"></a>xmlThrDefSaveNoEmptyTags ()</h3>
-<pre class="programlisting">int        xmlThrDefSaveNoEmptyTags        (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefSetGenericErrorFunc"></a>xmlThrDefSetGenericErrorFunc ()</h3>
-<pre class="programlisting">void       xmlThrDefSetGenericErrorFunc    (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> handler)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>handler</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefSetStructuredErrorFunc"></a>xmlThrDefSetStructuredErrorFunc ()</h3>
-<pre class="programlisting">void       xmlThrDefSetStructuredErrorFunc (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> handler)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>handler</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefSubstituteEntitiesDefaultValue"></a>xmlThrDefSubstituteEntitiesDefaultValue ()</h3>
-<pre class="programlisting">int        xmlThrDefSubstituteEntitiesDefaultValue (int v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="xmlThrDefTreeIndentString"></a>xmlThrDefTreeIndentString ()</h3>
-<pre class="programlisting">const char *       xmlThrDefTreeIndentString       (const char * v)<br>
-</pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>v</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
 </div>
 </div>
 </body>
index 894c3f8..4452739 100644 (file)
 <pre class="synopsis">#define <a href="#XML_CAST_FPTR">XML_CAST_FPTR</a>(fptr);
 typedef struct _xmlHashTable <a href="#xmlHashTable">xmlHashTable</a>;
 typedef <a href="libxml2-hash.html#xmlHashTable">xmlHashTable</a> * <a href="#xmlHashTablePtr">xmlHashTablePtr</a>;
-int    <a href="#xmlHashAddEntry">xmlHashAddEntry</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         void * userdata);
-int    <a href="#xmlHashAddEntry2">xmlHashAddEntry2</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        void * userdata);
-int    <a href="#xmlHashAddEntry3">xmlHashAddEntry3</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        void * userdata);
+int    <a href="#xmlHashAddEntry">xmlHashAddEntry</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  void * payload);
+int    <a href="#xmlHashAddEntry2">xmlHashAddEntry2</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         void * payload);
+int    <a href="#xmlHashAddEntry3">xmlHashAddEntry3</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         void * payload);
 typedef void * <a href="#xmlHashCopier">xmlHashCopier</a>                      (void * payload, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
-<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>        <a href="#xmlHashCopy">xmlHashCopy</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashCopier">xmlHashCopier</a> f);
+<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>        <a href="#xmlHashCopy">xmlHashCopy</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashCopier">xmlHashCopier</a> copy);
 <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>        <a href="#xmlHashCreate">xmlHashCreate</a>              (int size);
 <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>        <a href="#xmlHashCreateDict">xmlHashCreateDict</a>      (int size, <br>                                  <a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict);
 typedef void <a href="#xmlHashDeallocator">xmlHashDeallocator</a>              (void * payload, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
-void   <a href="#xmlHashDefaultDeallocator">xmlHashDefaultDeallocator</a>      (void * entry, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
-void   <a href="#xmlHashFree">xmlHashFree</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-void * <a href="#xmlHashLookup">xmlHashLookup</a>                      (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
-void * <a href="#xmlHashLookup2">xmlHashLookup2</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2);
-void * <a href="#xmlHashLookup3">xmlHashLookup3</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3);
-void * <a href="#xmlHashQLookup">xmlHashQLookup</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
-void * <a href="#xmlHashQLookup2">xmlHashQLookup2</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2);
-void * <a href="#xmlHashQLookup3">xmlHashQLookup3</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix3, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3);
-int    <a href="#xmlHashRemoveEntry">xmlHashRemoveEntry</a>            (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-int    <a href="#xmlHashRemoveEntry2">xmlHashRemoveEntry2</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-int    <a href="#xmlHashRemoveEntry3">xmlHashRemoveEntry3</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-void   <a href="#xmlHashScan">xmlHashScan</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> f, <br>                                   void * data);
-void   <a href="#xmlHashScan3">xmlHashScan3</a>                        (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> f, <br>                                   void * data);
-void   <a href="#xmlHashScanFull">xmlHashScanFull</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> f, <br>                                   void * data);
-void   <a href="#xmlHashScanFull3">xmlHashScanFull3</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> f, <br>                                   void * data);
+void   <a href="#xmlHashDefaultDeallocator">xmlHashDefaultDeallocator</a>      (void * entry, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key);
+void   <a href="#xmlHashFree">xmlHashFree</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+void * <a href="#xmlHashLookup">xmlHashLookup</a>                      (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key);
+void * <a href="#xmlHashLookup2">xmlHashLookup2</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2);
+void * <a href="#xmlHashLookup3">xmlHashLookup3</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3);
+void * <a href="#xmlHashQLookup">xmlHashQLookup</a>                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
+void * <a href="#xmlHashQLookup2">xmlHashQLookup2</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2);
+void * <a href="#xmlHashQLookup3">xmlHashQLookup3</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix3, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3);
+int    <a href="#xmlHashRemoveEntry">xmlHashRemoveEntry</a>            (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+int    <a href="#xmlHashRemoveEntry2">xmlHashRemoveEntry2</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+int    <a href="#xmlHashRemoveEntry3">xmlHashRemoveEntry3</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+void   <a href="#xmlHashScan">xmlHashScan</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> scan, <br>                                        void * data);
+void   <a href="#xmlHashScan3">xmlHashScan3</a>                        (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> scan, <br>                                        void * data);
+void   <a href="#xmlHashScanFull">xmlHashScanFull</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> scan, <br>                                        void * data);
+void   <a href="#xmlHashScanFull3">xmlHashScanFull3</a>                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> scan, <br>                                        void * data);
 typedef void <a href="#xmlHashScanner">xmlHashScanner</a>                      (void * payload, <br>                                    void * data, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
 typedef void <a href="#xmlHashScannerFull">xmlHashScannerFull</a>              (void * payload, <br>                                    void * data, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3);
-int    <a href="#xmlHashSize">xmlHashSize</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table);
-int    <a href="#xmlHashUpdateEntry">xmlHashUpdateEntry</a>            (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-int    <a href="#xmlHashUpdateEntry2">xmlHashUpdateEntry2</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
-int    <a href="#xmlHashUpdateEntry3">xmlHashUpdateEntry3</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f);
+int    <a href="#xmlHashSize">xmlHashSize</a>                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash);
+int    <a href="#xmlHashUpdateEntry">xmlHashUpdateEntry</a>            (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+int    <a href="#xmlHashUpdateEntry2">xmlHashUpdateEntry2</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
+int    <a href="#xmlHashUpdateEntry3">xmlHashUpdateEntry3</a>          (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -200,27 +200,27 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashAddEntry"></a>xmlHashAddEntry ()</h3>
-<pre class="programlisting">int        xmlHashAddEntry                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         void * userdata)<br>
+<pre class="programlisting">int        xmlHashAddEntry                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  void * payload)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the @name. Duplicate names generate errors.</p>
+<p>Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -229,31 +229,31 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashAddEntry2"></a>xmlHashAddEntry2 ()</h3>
-<pre class="programlisting">int        xmlHashAddEntry2                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        void * userdata)<br>
+<pre class="programlisting">int        xmlHashAddEntry2                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         void * payload)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the (@name, @name2) tuple. Duplicate tuples generate errors.</p>
+<p>Add a hash table entry with two strings as key. See <a href="libxml2-hash.html#xmlHashAddEntry">xmlHashAddEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -262,35 +262,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashAddEntry3"></a>xmlHashAddEntry3 ()</h3>
-<pre class="programlisting">int        xmlHashAddEntry3                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        void * userdata)<br>
+<pre class="programlisting">int        xmlHashAddEntry3                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         void * payload)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the tuple (@name, @name2, @name3). Duplicate entries generate errors.</p>
+<p>Add a hash table entry with three strings as key. See <a href="libxml2-hash.html#xmlHashAddEntry">xmlHashAddEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -299,23 +299,23 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashCopy"></a>xmlHashCopy ()</h3>
-<pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    xmlHashCopy             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashCopier">xmlHashCopier</a> f)<br>
+<pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    xmlHashCopy             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashCopier">xmlHashCopier</a> copy)<br>
 </pre>
-<p>Scan the hash @table and applied @f to each value.</p>
+<p>Copy the hash @table using @copy to copy payloads.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the copier function for items in the hash</td>
+<td><span class="term"><i><tt>copy</tt></i>:</span></td>
+<td>copier function for items in the hash</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the new table or NULL in case of error.</td>
+<td>the new table or NULL if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -326,17 +326,17 @@ The content of this structure is not made public by the API.
 <a name="xmlHashCreate"></a>xmlHashCreate ()</h3>
 <pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    xmlHashCreate           (int size)<br>
 </pre>
-<p>Create a new xmlHashTablePtr.</p>
+<p>Create a new hash table. Set size to zero if the number of entries can't be estimated.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
 <td><span class="term"><i><tt>size</tt></i>:</span></td>
-<td>the size of the hash table</td>
+<td>initial size of the hash table</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the newly created object, or NULL if an error occurred.</td>
+<td>the newly created object, or NULL if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -347,7 +347,7 @@ The content of this structure is not made public by the API.
 <a name="xmlHashCreateDict"></a>xmlHashCreateDict ()</h3>
 <pre class="programlisting"><a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    xmlHashCreateDict       (int size, <br>                                  <a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br>
 </pre>
-<p>Create a new <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> which will use @dict as the internal dictionary</p>
+<p>Create a new hash table backed by a dictionary. This can reduce resource usage considerably if most keys passed to API functions originate from this dictionary.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -361,7 +361,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the newly created object, or NULL if an error occurred.</td>
+<td>the newly created object, or NULL if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -370,19 +370,19 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashDefaultDeallocator"></a>xmlHashDefaultDeallocator ()</h3>
-<pre class="programlisting">void       xmlHashDefaultDeallocator       (void * entry, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
+<pre class="programlisting">void       xmlHashDefaultDeallocator       (void * entry, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key)<br>
 </pre>
-<p>Free a hash table entry with xmlFree.</p>
+<p>Free a hash table entry with <a href="libxml2-xmlmemory.html#xmlFree">xmlFree</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
 <td><span class="term"><i><tt>entry</tt></i>:</span></td>
-<td>the hash table entry</td>
+<td>hash table entry</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the entry's name</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>the entry's string key</td>
 </tr>
 </tbody>
 </table></div>
@@ -391,19 +391,19 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashFree"></a>xmlHashFree ()</h3>
-<pre class="programlisting">void       xmlHashFree                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">void       xmlHashFree                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Free the hash @table and its contents. The userdata is deallocated with @f if provided.</p>
+<p>Free the hash and its contents. The payload is deallocated with @dealloc if provided.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for items in the hash</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function or NULL</td>
 </tr>
 </tbody>
 </table></div>
@@ -412,23 +412,23 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashLookup"></a>xmlHashLookup ()</h3>
-<pre class="programlisting">void *     xmlHashLookup                   (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
+<pre class="programlisting">void *     xmlHashLookup                   (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key)<br>
 </pre>
-<p>Find the userdata specified by the @name.</p>
+<p>Find the entry specified by @key.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -437,27 +437,27 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashLookup2"></a>xmlHashLookup2 ()</h3>
-<pre class="programlisting">void *     xmlHashLookup2                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2)<br>
+<pre class="programlisting">void *     xmlHashLookup2                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2)<br>
 </pre>
-<p>Find the userdata specified by the (@name, @name2) tuple.</p>
+<p>Find the payload specified by the (@key, @key2) tuple.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -466,31 +466,31 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashLookup3"></a>xmlHashLookup3 ()</h3>
-<pre class="programlisting">void *     xmlHashLookup3                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3)<br>
+<pre class="programlisting">void *     xmlHashLookup3                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3)<br>
 </pre>
-<p>Find the userdata specified by the (@name, @name2, @name3) tuple.</p>
+<p>Find the payload specified by the (@key, @key2, @key3) tuple.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the a pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -499,27 +499,27 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashQLookup"></a>xmlHashQLookup ()</h3>
-<pre class="programlisting">void *     xmlHashQLookup                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
+<pre class="programlisting">void *     xmlHashQLookup                  (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Find the userdata specified by the QName @prefix:@name/@name.</p>
+<p>Find the payload specified by the QName @prefix:@name or @name.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix</tt></i>:</span></td>
-<td>the prefix of the userdata</td>
+<td>prefix of the string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td>local name of the string key</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -528,35 +528,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashQLookup2"></a>xmlHashQLookup2 ()</h3>
-<pre class="programlisting">void *     xmlHashQLookup2                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2)<br>
+<pre class="programlisting">void *     xmlHashQLookup2                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2)<br>
 </pre>
-<p>Find the userdata specified by the QNames tuple</p>
+<p>Find the payload specified by the QNames tuple.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix</tt></i>:</span></td>
-<td>the prefix of the userdata</td>
+<td>first prefix</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td>first local name</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix2</tt></i>:</span></td>
-<td>the second prefix of the userdata</td>
+<td>second prefix</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td>second local name</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -565,43 +565,43 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashQLookup3"></a>xmlHashQLookup3 ()</h3>
-<pre class="programlisting">void *     xmlHashQLookup3                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix3, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3)<br>
+<pre class="programlisting">void *     xmlHashQLookup3                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix2, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix3, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3)<br>
 </pre>
-<p>Find the userdata specified by the (@name, @name2, @name3) tuple.</p>
+<p>Find the payload specified by the QNames tuple.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix</tt></i>:</span></td>
-<td>the prefix of the userdata</td>
+<td>first prefix</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td>first local name</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix2</tt></i>:</span></td>
-<td>the second prefix of the userdata</td>
+<td>second prefix</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td>second local name</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>prefix3</tt></i>:</span></td>
-<td>the third prefix of the userdata</td>
+<td>third prefix</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata</td>
+<td>third local name</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the a pointer to the userdata</td>
+<td>a pointer to the payload or NULL if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -610,27 +610,27 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashRemoveEntry"></a>xmlHashRemoveEntry ()</h3>
-<pre class="programlisting">int        xmlHashRemoveEntry              (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashRemoveEntry              (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Find the userdata specified by the @name and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</p>
+<p>Find the entry specified by the @key and remove it from the hash table. Payload will be freed with @dealloc.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for removed item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for removed item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 if the removal succeeded and -1 in case of error or not found.</td>
+<td>0 on success and -1 if no entry was found.</td>
 </tr>
 </tbody>
 </table></div>
@@ -639,31 +639,31 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashRemoveEntry2"></a>xmlHashRemoveEntry2 ()</h3>
-<pre class="programlisting">int        xmlHashRemoveEntry2             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashRemoveEntry2             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Find the userdata specified by the (@name, @name2) tuple and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</p>
+<p>Remove an entry with two strings as key. See <a href="libxml2-hash.html#xmlHashRemoveEntry">xmlHashRemoveEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for removed item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for removed item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 if the removal succeeded and -1 in case of error or not found.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -672,35 +672,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashRemoveEntry3"></a>xmlHashRemoveEntry3 ()</h3>
-<pre class="programlisting">int        xmlHashRemoveEntry3             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashRemoveEntry3             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Find the userdata specified by the (@name, @name2, @name3) tuple and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</p>
+<p>Remove an entry with three strings as key. See <a href="libxml2-hash.html#xmlHashRemoveEntry">xmlHashRemoveEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for removed item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for removed item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 if the removal succeeded and -1 in case of error or not found.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -709,23 +709,23 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashScan"></a>xmlHashScan ()</h3>
-<pre class="programlisting">void       xmlHashScan                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> f, <br>                                   void * data)<br>
+<pre class="programlisting">void       xmlHashScan                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> scan, <br>                                        void * data)<br>
 </pre>
-<p>Scan the hash @table and applied @f to each value.</p>
+<p>Scan the hash @table and apply @scan to each value.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the scanner function for items in the hash</td>
+<td><span class="term"><i><tt>scan</tt></i>:</span></td>
+<td>scanner function for items in the hash</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>data</tt></i>:</span></td>
-<td>extra data passed to f</td>
+<td>extra data passed to @scan</td>
 </tr>
 </tbody>
 </table></div>
@@ -734,35 +734,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashScan3"></a>xmlHashScan3 ()</h3>
-<pre class="programlisting">void       xmlHashScan3                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> f, <br>                                   void * data)<br>
+<pre class="programlisting">void       xmlHashScan3                    (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashScanner">xmlHashScanner</a> scan, <br>                                        void * data)<br>
 </pre>
-<p>Scan the hash @table and applied @f to each value matching (@name, @name2, @name3) tuple. If one of the names is null, the comparison is considered to match.</p>
+<p>Scan the hash @table and apply @scan to each value matching (@key, @key2, @key3) tuple. If one of the keys is null, the comparison is considered to match.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the scanner function for items in the hash</td>
+<td><span class="term"><i><tt>scan</tt></i>:</span></td>
+<td>scanner function for items in the hash</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>data</tt></i>:</span></td>
-<td>extra data passed to f</td>
+<td>extra data passed to @scan</td>
 </tr>
 </tbody>
 </table></div>
@@ -771,23 +771,23 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashScanFull"></a>xmlHashScanFull ()</h3>
-<pre class="programlisting">void       xmlHashScanFull                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> f, <br>                                   void * data)<br>
+<pre class="programlisting">void       xmlHashScanFull                 (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> scan, <br>                                        void * data)<br>
 </pre>
-<p>Scan the hash @table and applied @f to each value.</p>
+<p>Scan the hash @table and apply @scan to each value.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the scanner function for items in the hash</td>
+<td><span class="term"><i><tt>scan</tt></i>:</span></td>
+<td>scanner function for items in the hash</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>data</tt></i>:</span></td>
-<td>extra data passed to f</td>
+<td>extra data passed to @scan</td>
 </tr>
 </tbody>
 </table></div>
@@ -796,35 +796,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashScanFull3"></a>xmlHashScanFull3 ()</h3>
-<pre class="programlisting">void       xmlHashScanFull3                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> f, <br>                                   void * data)<br>
+<pre class="programlisting">void       xmlHashScanFull3                (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         <a href="libxml2-hash.html#xmlHashScannerFull">xmlHashScannerFull</a> scan, <br>                                        void * data)<br>
 </pre>
-<p>Scan the hash @table and applied @f to each value matching (@name, @name2, @name3) tuple. If one of the names is null, the comparison is considered to match.</p>
+<p>Scan the hash @table and apply @scan to each value matching (@key, @key2, @key3) tuple. If one of the keys is null, the comparison is considered to match.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata or NULL</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key or NULL</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the scanner function for items in the hash</td>
+<td><span class="term"><i><tt>scan</tt></i>:</span></td>
+<td>scanner function for items in the hash</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>data</tt></i>:</span></td>
-<td>extra data passed to f</td>
+<td>extra data passed to @scan</td>
 </tr>
 </tbody>
 </table></div>
@@ -833,19 +833,19 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashSize"></a>xmlHashSize ()</h3>
-<pre class="programlisting">int        xmlHashSize                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table)<br>
+<pre class="programlisting">int        xmlHashSize                     (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash)<br>
 </pre>
-<p>Query the number of elements installed in the hash @table.</p>
+<p>Query the number of elements in the hash table.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of elements in the hash table or -1 in case of error</td>
+<td>the number of elements in the hash table or -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -854,31 +854,31 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashUpdateEntry"></a>xmlHashUpdateEntry ()</h3>
-<pre class="programlisting">int        xmlHashUpdateEntry              (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashUpdateEntry              (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the @name. Existing entry for this @name will be removed and freed with @f if found.</p>
+<p>Add a hash table entry. If an entry with this key already exists, the old payload will be freed and updated with the new value.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for replaced item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for replaced item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 in case of success, -1 if a memory allocation failed.</td>
 </tr>
 </tbody>
 </table></div>
@@ -887,35 +887,35 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashUpdateEntry2"></a>xmlHashUpdateEntry2 ()</h3>
-<pre class="programlisting">int        xmlHashUpdateEntry2             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashUpdateEntry2             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the (@name, @name2) tuple. Existing entry for this tuple will be removed and freed with @f if found.</p>
+<p>Add a hash table entry with two strings as key. See <a href="libxml2-hash.html#xmlHashUpdateEntry">xmlHashUpdateEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for replaced item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for replaced item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -924,39 +924,39 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlHashUpdateEntry3"></a>xmlHashUpdateEntry3 ()</h3>
-<pre class="programlisting">int        xmlHashUpdateEntry3             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> table, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name2, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name3, <br>                                        void * userdata, <br>                                   <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> f)<br>
+<pre class="programlisting">int        xmlHashUpdateEntry3             (<a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a> hash, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key2, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * key3, <br>                                         void * payload, <br>                                    <a href="libxml2-hash.html#xmlHashDeallocator">xmlHashDeallocator</a> dealloc)<br>
 </pre>
-<p>Add the @userdata to the hash @table. This can later be retrieved by using the tuple (@name, @name2, @name3). Existing entry for this tuple will be removed and freed with @f if found.</p>
+<p>Add a hash table entry with three strings as key. See <a href="libxml2-hash.html#xmlHashUpdateEntry">xmlHashUpdateEntry</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>table</tt></i>:</span></td>
-<td>the hash table</td>
+<td><span class="term"><i><tt>hash</tt></i>:</span></td>
+<td>hash table</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the name of the userdata</td>
+<td><span class="term"><i><tt>key</tt></i>:</span></td>
+<td>first string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name2</tt></i>:</span></td>
-<td>a second name of the userdata</td>
+<td><span class="term"><i><tt>key2</tt></i>:</span></td>
+<td>second string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>name3</tt></i>:</span></td>
-<td>a third name of the userdata</td>
+<td><span class="term"><i><tt>key3</tt></i>:</span></td>
+<td>third string key</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>userdata</tt></i>:</span></td>
-<td>a pointer to the userdata</td>
+<td><span class="term"><i><tt>payload</tt></i>:</span></td>
+<td>pointer to the payload</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>f</tt></i>:</span></td>
-<td>the deallocator function for replaced item (if any)</td>
+<td><span class="term"><i><tt>dealloc</tt></i>:</span></td>
+<td>deallocator function for replaced item or NULL</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 the addition succeeded and -1 in case of error.</td>
+<td>0 on success and -1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
index fbddf5a..f18176f 100644 (file)
@@ -27,6 +27,7 @@
 #define <a href="#XML_DETECT_IDS">XML_DETECT_IDS</a>;
 #define <a href="#XML_SAX2_MAGIC">XML_SAX2_MAGIC</a>;
 #define <a href="#XML_SKIP_IDS">XML_SKIP_IDS</a>;
+typedef struct _xmlAttrHashBucket <a href="#xmlAttrHashBucket">xmlAttrHashBucket</a>;
 typedef enum <a href="#xmlFeature">xmlFeature</a>;
 typedef enum <a href="#xmlParserInputState">xmlParserInputState</a>;
 typedef enum <a href="#xmlParserMode">xmlParserMode</a>;
@@ -34,6 +35,7 @@ typedef struct _xmlParserNodeInfo <a href="#xmlParserNodeInfo">xmlParserNodeInfo
 typedef <a href="libxml2-parser.html#xmlParserNodeInfo">xmlParserNodeInfo</a> * <a href="#xmlParserNodeInfoPtr">xmlParserNodeInfoPtr</a>;
 typedef struct _xmlParserNodeInfoSeq <a href="#xmlParserNodeInfoSeq">xmlParserNodeInfoSeq</a>;
 typedef <a href="libxml2-parser.html#xmlParserNodeInfoSeq">xmlParserNodeInfoSeq</a> * <a href="#xmlParserNodeInfoSeqPtr">xmlParserNodeInfoSeqPtr</a>;
+typedef struct _xmlParserNsData <a href="#xmlParserNsData">xmlParserNsData</a>;
 typedef enum <a href="#xmlParserOption">xmlParserOption</a>;
 typedef struct _xmlSAXHandlerV1 <a href="#xmlSAXHandlerV1">xmlSAXHandlerV1</a>;
 typedef <a href="libxml2-parser.html#xmlSAXHandlerV1">xmlSAXHandlerV1</a> * <a href="#xmlSAXHandlerV1Ptr">xmlSAXHandlerV1Ptr</a>;
@@ -72,16 +74,17 @@ long        <a href="#xmlByteConsumed">xmlByteConsumed</a>                  (<a href="libxml2-tree.htm
 void   <a href="#xmlCleanupParser">xmlCleanupParser</a>                (void);
 void   <a href="#xmlClearNodeInfoSeq">xmlClearNodeInfoSeq</a>          (<a href="libxml2-parser.html#xmlParserNodeInfoSeqPtr">xmlParserNodeInfoSeqPtr</a> seq);
 void   <a href="#xmlClearParserCtxt">xmlClearParserCtxt</a>            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
-<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlCreateDocParserCtxt">xmlCreateDocParserCtxt</a>    (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur);
+<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlCreateDocParserCtxt">xmlCreateDocParserCtxt</a>    (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str);
 <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlCreateIOParserCtxt">xmlCreateIOParserCtxt</a>      (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                             void * user_data, <br>                                          <a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                                 <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                              void * ioctx, <br>                                              <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlCreatePushParserCtxt">xmlCreatePushParserCtxt</a>  (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                             void * user_data, <br>                                          const char * chunk, <br>                                                int size, <br>                                          const char * filename);
-<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadDoc">xmlCtxtReadDoc</a>            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options);
+<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadDoc">xmlCtxtReadDoc</a>            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadFd">xmlCtxtReadFd</a>              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int fd, <br>                                    const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadFile">xmlCtxtReadFile</a>          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * filename, <br>                                     const char * encoding, <br>                                     int options);
 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadIO">xmlCtxtReadIO</a>              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                      void * ioctx, <br>                                      const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>    <a href="#xmlCtxtReadMemory">xmlCtxtReadMemory</a>      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * buffer, <br>                                       int size, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options);
 void   <a href="#xmlCtxtReset">xmlCtxtReset</a>                        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
 int    <a href="#xmlCtxtResetPush">xmlCtxtResetPush</a>                (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * chunk, <br>                                        int size, <br>                                  const char * filename, <br>                                     const char * encoding);
+void   <a href="#xmlCtxtSetMaxAmplification">xmlCtxtSetMaxAmplification</a>    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    unsigned maxAmpl);
 int    <a href="#xmlCtxtUseOptions">xmlCtxtUseOptions</a>              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int options);
 typedef <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> <a href="#xmlExternalEntityLoader">xmlExternalEntityLoader</a>     (const char * URL, <br>                                          const char * ID, <br>                                           <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> context);
 void   <a href="#xmlFreeParserCtxt">xmlFreeParserCtxt</a>              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
@@ -98,6 +101,7 @@ int  <a href="#xmlLineNumbersDefault">xmlLineNumbersDefault</a>              (int val);
 <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>    <a href="#xmlLoadExternalEntity">xmlLoadExternalEntity</a>      (const char * URL, <br>                                          const char * ID, <br>                                           <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
 <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>    <a href="#xmlNewIOInputStream">xmlNewIOInputStream</a>  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                            <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a> input, <br>                                             <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlNewParserCtxt">xmlNewParserCtxt</a>        (void);
+<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>      <a href="#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a>  (const <a href="libxml2-tree.html#xmlSAXHandler">xmlSAXHandler</a> * sax, <br>                                           void * userData);
 int    <a href="#xmlParseBalancedChunkMemory">xmlParseBalancedChunkMemory</a>  (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     void * user_data, <br>                                  int depth, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * string, <br>                                       <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> * lst);
 int    <a href="#xmlParseBalancedChunkMemoryRecover">xmlParseBalancedChunkMemoryRecover</a>    (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                           <a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                             void * user_data, <br>                                          int depth, <br>                                                 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * string, <br>                                               <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> * lst, <br>                                               int recover);
 int    <a href="#xmlParseChunk">xmlParseChunk</a>                      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * chunk, <br>                                        int size, <br>                                  int terminate);
@@ -140,6 +144,14 @@ int        <a href="#xmlSetFeature">xmlSetFeature</a>                      (<a href="libxml2-tree.html#xml
 void   <a href="#xmlSetupParserForBuffer">xmlSetupParserForBuffer</a>          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buffer, <br>                                       const char * filename);
 void   <a href="#xmlStopParser">xmlStopParser</a>                      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
 int    <a href="#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a>        (int val);
+int    <a href="#xmlThrDefDoValidityCheckingDefaultValue">xmlThrDefDoValidityCheckingDefaultValue</a>  (int v);
+int    <a href="#xmlThrDefGetWarningsDefaultValue">xmlThrDefGetWarningsDefaultValue</a>        (int v);
+int    <a href="#xmlThrDefKeepBlanksDefaultValue">xmlThrDefKeepBlanksDefaultValue</a>  (int v);
+int    <a href="#xmlThrDefLineNumbersDefaultValue">xmlThrDefLineNumbersDefaultValue</a>        (int v);
+int    <a href="#xmlThrDefLoadExtDtdDefaultValue">xmlThrDefLoadExtDtdDefaultValue</a>  (int v);
+int    <a href="#xmlThrDefParserDebugEntities">xmlThrDefParserDebugEntities</a>        (int v);
+int    <a href="#xmlThrDefPedanticParserDefaultValue">xmlThrDefPedanticParserDefaultValue</a>  (int v);
+int    <a href="#xmlThrDefSubstituteEntitiesDefaultValue">xmlThrDefSubstituteEntitiesDefaultValue</a>  (int v);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -183,7 +195,17 @@ int        <a href="#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a>        (in
 <a name="XML_SKIP_IDS">Macro </a>XML_SKIP_IDS</h3>
 <pre class="programlisting">#define <a href="#XML_SKIP_IDS">XML_SKIP_IDS</a>;
 </pre>
-<p>Bit in the loadsubset context field to tell to not do ID/REFs registration. Used to initialize <a href="libxml2-globals.html#xmlLoadExtDtdDefaultValue">xmlLoadExtDtdDefaultValue</a> in some special cases.</p>
+<p>Bit in the loadsubset context field to tell to not do ID/REFs registration. Used to initialize xmlLoadExtDtdDefaultValue in some special cases.</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlAttrHashBucket">Structure </a>xmlAttrHashBucket</h3>
+<pre class="programlisting">struct _xmlAttrHashBucket {
+The content of this structure is not made public by the API.
+} xmlAttrHashBucket;
+</pre>
+<p></p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -250,7 +272,8 @@ int <a href="#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a>        (in
     <a name="XML_PARSER_SYSTEM_LITERAL">XML_PARSER_SYSTEM_LITERAL</a> = 13 /* within a SYSTEM value */
     <a name="XML_PARSER_EPILOG">XML_PARSER_EPILOG</a> = 14 /* the Misc* after the last end tag */
     <a name="XML_PARSER_IGNORE">XML_PARSER_IGNORE</a> = 15 /* within an IGNORED section */
-    <a name="XML_PARSER_PUBLIC_LITERAL">XML_PARSER_PUBLIC_LITERAL</a> = 16 /*  within a PUBLIC value */
+    <a name="XML_PARSER_PUBLIC_LITERAL">XML_PARSER_PUBLIC_LITERAL</a> = 16 /* within a PUBLIC value */
+    <a name="XML_PARSER_XML_DECL">XML_PARSER_XML_DECL</a> = 17 /*  before XML decl (but after BOM) */
 };
 </pre>
 <p></p>
@@ -315,6 +338,16 @@ int        <a href="#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a>        (in
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlParserNsData">Structure </a>xmlParserNsData</h3>
+<pre class="programlisting">struct _xmlParserNsData {
+The content of this structure is not made public by the API.
+} xmlParserNsData;
+</pre>
+<p></p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlParserOption">Enum </a>xmlParserOption</h3>
 <pre class="programlisting">enum <a href="#xmlParserOption">xmlParserOption</a> {
     <a name="XML_PARSE_RECOVER">XML_PARSE_RECOVER</a> = 1 /* recover on errors */
@@ -845,7 +878,7 @@ The content of this structure is not made public by the API.
 <a name="ignorableWhitespaceSAXFunc"></a>Function type ignorableWhitespaceSAXFunc</h3>
 <pre class="programlisting">void       ignorableWhitespaceSAXFunc      (void * ctx, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * ch, <br>                                   int len)<br>
 </pre>
-<p>Receiving some ignorable whitespaces from the parser. UNUSED: by default the DOM building will use characters.</p>
+<p>Receiving some ignorable whitespaces from the parser. UNUSED: by default the DOM building will use <a href="libxml2-SAX.html#characters">characters</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1234,6 +1267,14 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlParserVersion">Variable </a>xmlParserVersion</h3>
+<pre class="programlisting">const char * const xmlParserVersion;
+</pre>
+<p>Constant string describing the internal version of the library</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlByteConsumed"></a>xmlByteConsumed ()</h3>
 <pre class="programlisting">long       xmlByteConsumed                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
@@ -1266,7 +1307,7 @@ The content of this structure is not made public by the API.
 <a name="xmlClearNodeInfoSeq"></a>xmlClearNodeInfoSeq ()</h3>
 <pre class="programlisting">void       xmlClearNodeInfoSeq             (<a href="libxml2-parser.html#xmlParserNodeInfoSeqPtr">xmlParserNodeInfoSeqPtr</a> seq)<br>
 </pre>
-<p>-- Clear (release memory and reinitialize) node info sequence</p>
+<p>DEPRECATED: Don't use. -- Clear (release memory and reinitialize) node info sequence</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1294,14 +1335,14 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlCreateDocParserCtxt"></a>xmlCreateDocParserCtxt ()</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>  xmlCreateDocParserCtxt  (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur)<br>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>  xmlCreateDocParserCtxt  (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str)<br>
 </pre>
 <p>Creates a parser context for an XML in-memory document.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
 <tr>
-<td><span class="term"><i><tt>cur</tt></i>:</span></td>
+<td><span class="term"><i><tt>str</tt></i>:</span></td>
 <td>a pointer to an array of <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a>
 </td>
 </tr>
@@ -1359,7 +1400,7 @@ The content of this structure is not made public by the API.
 <a name="xmlCreatePushParserCtxt"></a>xmlCreatePushParserCtxt ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>  xmlCreatePushParserCtxt (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                             void * user_data, <br>                                          const char * chunk, <br>                                                int size, <br>                                          const char * filename)<br>
 </pre>
-<p>Create a parser context for using the XML parser in push mode. If @buffer and @size are non-NULL, the data is used to detect the encoding. The remaining <a href="libxml2-SAX.html#characters">characters</a> will be parsed so they don't need to be fed in again through xmlParseChunk. To allow content encoding detection, @size should be &gt;= 4 The value of @filename is used for fetching external entities and error/warning reports.</p>
+<p>Create a parser context for using the XML parser in push mode. If @buffer and @size are non-NULL, the data is used to detect the encoding. The remaining <a href="libxml2-SAX.html#characters">characters</a> will be parsed so they don't need to be fed in again through <a href="libxml2-parser.html#xmlParseChunk">xmlParseChunk</a>. To allow content encoding detection, @size should be &gt;= 4 The value of @filename is used for fetching external entities and error/warning reports.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1394,7 +1435,7 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlCtxtReadDoc"></a>xmlCtxtReadDoc ()</h3>
-<pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlCtxtReadDoc          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlCtxtReadDoc          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
 <p>parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context</p>
 <div class="variablelist"><table border="0">
@@ -1405,7 +1446,7 @@ The content of this structure is not made public by the API.
 <td>an XML parser context</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>cur</tt></i>:</span></td>
+<td><span class="term"><i><tt>str</tt></i>:</span></td>
 <td>a pointer to a zero terminated string</td>
 </tr>
 <tr>
@@ -1643,6 +1684,27 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlCtxtSetMaxAmplification"></a>xmlCtxtSetMaxAmplification ()</h3>
+<pre class="programlisting">void       xmlCtxtSetMaxAmplification      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    unsigned maxAmpl)<br>
+</pre>
+<p>To protect against exponential entity expansion ("billion laughs"), the size of serialized output is (roughly) limited to the input size multiplied by this factor. The default value is 5. When working with documents making heavy use of entity expansion, it can be necessary to increase the value. For security reasons, this should only be considered when processing trusted input.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
+<td>an XML parser context</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>maxAmpl</tt></i>:</span></td>
+<td>maximum amplification factor</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlCtxtUseOptions"></a>xmlCtxtUseOptions ()</h3>
 <pre class="programlisting">int        xmlCtxtUseOptions               (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int options)<br>
 </pre>
@@ -1806,7 +1868,7 @@ The content of this structure is not made public by the API.
 <a name="xmlInitNodeInfoSeq"></a>xmlInitNodeInfoSeq ()</h3>
 <pre class="programlisting">void       xmlInitNodeInfoSeq              (<a href="libxml2-parser.html#xmlParserNodeInfoSeqPtr">xmlParserNodeInfoSeqPtr</a> seq)<br>
 </pre>
-<p>-- Initialize (set to initial state) node info sequence</p>
+<p>DEPRECATED: Don't use. -- Initialize (set to initial state) node info sequence</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1821,7 +1883,7 @@ The content of this structure is not made public by the API.
 <a name="xmlInitParser"></a>xmlInitParser ()</h3>
 <pre class="programlisting">void       xmlInitParser                   (void)<br>
 </pre>
-<p>Initialization function for the XML parser. This is not reentrant. Call once before processing in case of use in multithreaded programs.</p>
+<p>Initialization function for the XML parser. Call once from the main thread before using the library in multithreaded programs.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -1829,7 +1891,7 @@ The content of this structure is not made public by the API.
 <a name="xmlInitParserCtxt"></a>xmlInitParserCtxt ()</h3>
 <pre class="programlisting">int        xmlInitParserCtxt               (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Initialize a parser context</p>
+<p>DEPRECATED: Internal function which will be made private in a future version. Initialize a parser context</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1850,7 +1912,7 @@ The content of this structure is not made public by the API.
 <a name="xmlKeepBlanksDefault"></a>xmlKeepBlanksDefault ()</h3>
 <pre class="programlisting">int        xmlKeepBlanksDefault            (int val)<br>
 </pre>
-<p>Set and return the previous value for default blanks text nodes support. The 1.x version of the parser used an heuristic to try to detect ignorable white spaces. As a result the SAX callback was generating xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when using the DOM output text nodes containing those blanks were not generated. The 2.x and later version will switch to the XML standard way and ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn't allow CDATA or mixed content. This function is provided as a way to force the standard behavior on 1.X libs and to switch back to the old mode for compatibility when running 1.X client code on 2.X . Upgrade of 1.X code should be done by using xmlIsBlankNode() commodity function to detect the "empty" nodes generated. This value also affect autogeneration of indentation when saving code if blanks sections are kept, indentation is not generated.</p>
+<p>DEPRECATED: Use the modern options API with <a href="libxml2-parser.html#XML_PARSE_NOBLANKS">XML_PARSE_NOBLANKS</a>. Set and return the previous value for default blanks text nodes support. The 1.x version of the parser used an heuristic to try to detect ignorable white spaces. As a result the SAX callback was generating xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when using the DOM output text nodes containing those blanks were not generated. The 2.x and later version will switch to the XML standard way and ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn't allow CDATA or mixed content. This function is provided as a way to force the standard behavior on 1.X libs and to switch back to the old mode for compatibility when running 1.X client code on 2.X . Upgrade of 1.X code should be done by using xmlIsBlankNode() commodity function to detect the "empty" nodes generated. This value also affect autogeneration of indentation when saving code if blanks sections are kept, indentation is not generated.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1871,7 +1933,7 @@ The content of this structure is not made public by the API.
 <a name="xmlLineNumbersDefault"></a>xmlLineNumbersDefault ()</h3>
 <pre class="programlisting">int        xmlLineNumbersDefault           (int val)<br>
 </pre>
-<p>Set and return the previous value for enabling line numbers in elements contents. This may break on old application and is turned off by default.</p>
+<p>DEPRECATED: The modern options API always enables line numbers. Set and return the previous value for enabling line numbers in elements contents. This may break on old application and is turned off by default.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1962,6 +2024,31 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlNewSAXParserCtxt"></a>xmlNewSAXParserCtxt ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a>  xmlNewSAXParserCtxt     (const <a href="libxml2-tree.html#xmlSAXHandler">xmlSAXHandler</a> * sax, <br>                                           void * userData)<br>
+</pre>
+<p>Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>sax</tt></i>:</span></td>
+<td>SAX handler</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>userData</tt></i>:</span></td>
+<td>user data</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> or NULL if memory allocation failed.</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlParseBalancedChunkMemory"></a>xmlParseBalancedChunkMemory ()</h3>
 <pre class="programlisting">int        xmlParseBalancedChunkMemory     (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     void * user_data, <br>                                  int depth, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * string, <br>                                       <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> * lst)<br>
 </pre>
@@ -2142,7 +2229,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParseDoc"></a>xmlParseDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlParseDoc             (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur)<br>
 </pre>
-<p>parse an XML in-memory document and build a tree.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadDoc">xmlReadDoc</a>. parse an XML in-memory document and build a tree.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2272,7 +2359,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParseFile"></a>xmlParseFile ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlParseFile            (const char * filename)<br>
 </pre>
-<p>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadFile">xmlReadFile</a>. parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2332,7 +2419,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParseMemory"></a>xmlParseMemory ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlParseMemory          (const char * buffer, <br>                                       int size)<br>
 </pre>
-<p>parse an XML in-memory block and build a tree.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadMemory">xmlReadMemory</a>. parse an XML in-memory block and build a tree.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2357,7 +2444,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParserAddNodeInfo"></a>xmlParserAddNodeInfo ()</h3>
 <pre class="programlisting">void       xmlParserAddNodeInfo            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-parser.html#xmlParserNodeInfoPtr">xmlParserNodeInfoPtr</a> info)<br>
 </pre>
-<p>Insert node info record into the sorted sequence</p>
+<p>DEPRECATED: Don't use. Insert node info record into the sorted sequence</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2378,7 +2465,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParserFindNodeInfo"></a>xmlParserFindNodeInfo ()</h3>
 <pre class="programlisting">const <a href="libxml2-parser.html#xmlParserNodeInfo">xmlParserNodeInfo</a> *      xmlParserFindNodeInfo   (const <a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctx, <br>                                                       const <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
 </pre>
-<p>Find the parser node info struct for a given node</p>
+<p>DEPRECATED: Don't use. Find the parser node info struct for a given node</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2403,7 +2490,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParserFindNodeInfoIndex"></a>xmlParserFindNodeInfoIndex ()</h3>
 <pre class="programlisting">unsigned long      xmlParserFindNodeInfoIndex      (const <a href="libxml2-parser.html#xmlParserNodeInfoSeqPtr">xmlParserNodeInfoSeqPtr</a> seq, <br>                                               const <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
 </pre>
-<p><a href="libxml2-parser.html#xmlParserFindNodeInfoIndex">xmlParserFindNodeInfoIndex</a> : Find the index that the info record for the given node is or should be at in a sorted sequence</p>
+<p>DEPRECATED: Don't use. <a href="libxml2-parser.html#xmlParserFindNodeInfoIndex">xmlParserFindNodeInfoIndex</a> : Find the index that the info record for the given node is or should be at in a sorted sequence</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2428,7 +2515,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParserInputGrow"></a>xmlParserInputGrow ()</h3>
 <pre class="programlisting">int        xmlParserInputGrow              (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> in, <br>                                    int len)<br>
 </pre>
-<p>This function increase the input for the parser. It tries to preserve pointers to the input buffer, and keep already read data</p>
+<p>DEPRECATED: Don't use. This function increase the input for the parser. It tries to preserve pointers to the input buffer, and keep already read data</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2453,7 +2540,7 @@ The content of this structure is not made public by the API.
 <a name="xmlParserInputRead"></a>xmlParserInputRead ()</h3>
 <pre class="programlisting">int        xmlParserInputRead              (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> in, <br>                                    int len)<br>
 </pre>
-<p>This function was internal and is deprecated.</p>
+<p>DEPRECATED: This function was internal and is deprecated.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2478,7 +2565,7 @@ The content of this structure is not made public by the API.
 <a name="xmlPedanticParserDefault"></a>xmlPedanticParserDefault ()</h3>
 <pre class="programlisting">int        xmlPedanticParserDefault        (int val)<br>
 </pre>
-<p>Set and return the previous value for enabling pedantic warnings.</p>
+<p>DEPRECATED: Use the modern options API with <a href="libxml2-parser.html#XML_PARSE_PEDANTIC">XML_PARSE_PEDANTIC</a>. Set and return the previous value for enabling pedantic warnings.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2677,7 +2764,7 @@ The content of this structure is not made public by the API.
 <a name="xmlRecoverDoc"></a>xmlRecoverDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlRecoverDoc           (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur)<br>
 </pre>
-<p>parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is tried anyway</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadDoc">xmlReadDoc</a> with <a href="libxml2-parser.html#XML_PARSE_RECOVER">XML_PARSE_RECOVER</a>. parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is tried anyway</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2699,7 +2786,7 @@ The content of this structure is not made public by the API.
 <a name="xmlRecoverFile"></a>xmlRecoverFile ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlRecoverFile          (const char * filename)<br>
 </pre>
-<p>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, it attempts to build a tree anyway</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadFile">xmlReadFile</a> with <a href="libxml2-parser.html#XML_PARSE_RECOVER">XML_PARSE_RECOVER</a>. 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, it attempts to build a tree anyway</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2720,7 +2807,7 @@ The content of this structure is not made public by the API.
 <a name="xmlRecoverMemory"></a>xmlRecoverMemory ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlRecoverMemory        (const char * buffer, <br>                                       int size)<br>
 </pre>
-<p>parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree is tried anyway</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlReadMemory">xmlReadMemory</a> with <a href="libxml2-parser.html#XML_PARSE_RECOVER">XML_PARSE_RECOVER</a>. parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree is tried anyway</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2745,7 +2832,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseDTD"></a>xmlSAXParseDTD ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDtdPtr">xmlDtdPtr</a>        xmlSAXParseDTD          (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * ExternalID, <br>                                   const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * SystemID)<br>
 </pre>
-<p>Load and parse an external subset.</p>
+<p>DEPRECATED: Don't use. Load and parse an external subset.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2774,7 +2861,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseDoc"></a>xmlSAXParseDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseDoc          (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  int recovery)<br>
 </pre>
-<p>parse an XML in-memory document and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadDoc">xmlCtxtReadDoc</a>. parse an XML in-memory document and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2804,7 +2891,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseEntity"></a>xmlSAXParseEntity ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseEntity       (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const char * filename)<br>
 </pre>
-<p>parse an XML external entity out of context and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. [78] extParsedEnt ::= TextDecl? content This correspond to a "Well Balanced" chunk</p>
+<p>DEPRECATED: Don't use. parse an XML external entity out of context and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. [78] extParsedEnt ::= TextDecl? content This correspond to a "Well Balanced" chunk</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2829,7 +2916,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseFile"></a>xmlSAXParseFile ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseFile         (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const char * filename, <br>                                     int recovery)<br>
 </pre>
-<p>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadFile">xmlCtxtReadFile</a>. parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2858,7 +2945,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseFileWithData"></a>xmlSAXParseFileWithData ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseFileWithData (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const char * filename, <br>                                     int recovery, <br>                                      void * data)<br>
 </pre>
-<p>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadFile">xmlCtxtReadFile</a>. parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2891,7 +2978,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseMemory"></a>xmlSAXParseMemory ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseMemory       (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     const char * buffer, <br>                                       int size, <br>                                  int recovery)<br>
 </pre>
-<p>parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadMemory">xmlCtxtReadMemory</a>. parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2924,7 +3011,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXParseMemoryWithData"></a>xmlSAXParseMemoryWithData ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlSAXParseMemoryWithData       (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                             const char * buffer, <br>                                               int size, <br>                                          int recovery, <br>                                              void * data)<br>
 </pre>
-<p>parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadMemory">xmlCtxtReadMemory</a>. parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2961,7 +3048,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXUserParseFile"></a>xmlSAXUserParseFile ()</h3>
 <pre class="programlisting">int        xmlSAXUserParseFile             (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     void * user_data, <br>                                  const char * filename)<br>
 </pre>
-<p>parse an XML file and call the given SAX handler routines. Automatic support for ZLIB/Compress compressed document is provided</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadFile">xmlCtxtReadFile</a>. parse an XML file and call the given SAX handler routines. Automatic support for ZLIB/Compress compressed document is provided</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2990,7 +3077,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSAXUserParseMemory"></a>xmlSAXUserParseMemory ()</h3>
 <pre class="programlisting">int        xmlSAXUserParseMemory           (<a href="libxml2-tree.html#xmlSAXHandlerPtr">xmlSAXHandlerPtr</a> sax, <br>                                     void * user_data, <br>                                  const char * buffer, <br>                                       int size)<br>
 </pre>
-<p>A better SAX parsing routine. parse an XML in-memory buffer and call the given SAX handler routines.</p>
+<p>DEPRECATED: Use <a href="libxml2-parser.html#xmlNewSAXParserCtxt">xmlNewSAXParserCtxt</a> and <a href="libxml2-parser.html#xmlCtxtReadMemory">xmlCtxtReadMemory</a>. parse an XML in-memory buffer and call the given SAX handler routines.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3067,7 +3154,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSetupParserForBuffer"></a>xmlSetupParserForBuffer ()</h3>
 <pre class="programlisting">void       xmlSetupParserForBuffer         (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buffer, <br>                                       const char * filename)<br>
 </pre>
-<p>Setup the parser context to parse a new buffer; Clears any prior contents from the parser context. The buffer parameter must not be NULL, but the filename parameter can be</p>
+<p>DEPRECATED: Don't use. Setup the parser context to parse a new buffer; Clears any prior contents from the parser context. The buffer parameter must not be NULL, but the filename parameter can be</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3107,7 +3194,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSubstituteEntitiesDefault"></a>xmlSubstituteEntitiesDefault ()</h3>
 <pre class="programlisting">int        xmlSubstituteEntitiesDefault    (int val)<br>
 </pre>
-<p>Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output. This function has to be used to change the default parser behavior SAX::substituteEntities() has to be used for changing that on a file by file basis.</p>
+<p>DEPRECATED: Use the modern options API with <a href="libxml2-parser.html#XML_PARSE_NOENT">XML_PARSE_NOENT</a>. Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output. This function has to be used to change the default parser behavior SAX::substituteEntities() has to be used for changing that on a file by file basis.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3123,6 +3210,174 @@ The content of this structure is not made public by the API.
 </table></div>
 </div>
 <hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefDoValidityCheckingDefaultValue"></a>xmlThrDefDoValidityCheckingDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefDoValidityCheckingDefaultValue (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefGetWarningsDefaultValue"></a>xmlThrDefGetWarningsDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefGetWarningsDefaultValue        (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefKeepBlanksDefaultValue"></a>xmlThrDefKeepBlanksDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefKeepBlanksDefaultValue (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefLineNumbersDefaultValue"></a>xmlThrDefLineNumbersDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefLineNumbersDefaultValue        (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefLoadExtDtdDefaultValue"></a>xmlThrDefLoadExtDtdDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefLoadExtDtdDefaultValue (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefParserDebugEntities"></a>xmlThrDefParserDebugEntities ()</h3>
+<pre class="programlisting">int        xmlThrDefParserDebugEntities    (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefPedanticParserDefaultValue"></a>xmlThrDefPedanticParserDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefPedanticParserDefaultValue     (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefSubstituteEntitiesDefaultValue"></a>xmlThrDefSubstituteEntitiesDefaultValue ()</h3>
+<pre class="programlisting">int        xmlThrDefSubstituteEntitiesDefaultValue (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
 </div>
 </div>
 </body>
index 4de6e6d..38a4641 100644 (file)
 #define <a href="#IS_LETTER_CH">IS_LETTER_CH</a>(c);
 #define <a href="#IS_PUBIDCHAR">IS_PUBIDCHAR</a>(c);
 #define <a href="#IS_PUBIDCHAR_CH">IS_PUBIDCHAR_CH</a>(c);
-#define <a href="#MOVETO_ENDTAG">MOVETO_ENDTAG</a>(p);
-#define <a href="#MOVETO_STARTTAG">MOVETO_STARTTAG</a>(p);
-#define <a href="#SKIP_EOL">SKIP_EOL</a>(p);
 #define <a href="#XML_MAX_DICTIONARY_LIMIT">XML_MAX_DICTIONARY_LIMIT</a>;
+#define <a href="#XML_MAX_HUGE_LENGTH">XML_MAX_HUGE_LENGTH</a>;
 #define <a href="#XML_MAX_LOOKUP_LIMIT">XML_MAX_LOOKUP_LIMIT</a>;
 #define <a href="#XML_MAX_NAMELEN">XML_MAX_NAMELEN</a>;
 #define <a href="#XML_MAX_NAME_LENGTH">XML_MAX_NAME_LENGTH</a>;
@@ -54,8 +52,6 @@
 #define <a href="#XML_SUBSTITUTE_NONE">XML_SUBSTITUTE_NONE</a>;
 #define <a href="#XML_SUBSTITUTE_PEREF">XML_SUBSTITUTE_PEREF</a>;
 #define <a href="#XML_SUBSTITUTE_REF">XML_SUBSTITUTE_REF</a>;
-<a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>      <a href="#htmlCreateFileParserCtxt">htmlCreateFileParserCtxt</a>        (const char * filename, <br>                                                     const char * encoding);
-void   <a href="#htmlInitAutoClose">htmlInitAutoClose</a>              (void);
 <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>    <a href="#inputPop">inputPop</a>        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
 int    <a href="#inputPush">inputPush</a>                      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> value);
 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *   <a href="#namePop">namePop</a>                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt);
@@ -72,7 +68,6 @@ int   <a href="#xmlCopyCharMultiByte">xmlCopyCharMultiByte</a>                (<a href="libxml2-
 int    <a href="#xmlCurrentChar">xmlCurrentChar</a>                    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int * len);
 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlDecodeEntities">xmlDecodeEntities</a>      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int len, <br>                                   int what, <br>                                  <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end, <br>                                  <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end2, <br>                                         <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end3);
 typedef void <a href="#xmlEntityReferenceFunc">xmlEntityReferenceFunc</a>              (<a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a> ent, <br>                                     <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> firstNode, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> lastNode);
-void   <a href="#xmlErrMemory">xmlErrMemory</a>                        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * extra);
 void   <a href="#xmlFreeInputStream">xmlFreeInputStream</a>            (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input);
 void   <a href="#xmlHandleEntity">xmlHandleEntity</a>                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a> entity);
 int    <a href="#xmlIsLetter">xmlIsLetter</a>                  (int c);
@@ -446,55 +441,18 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="MOVETO_ENDTAG">Macro </a>MOVETO_ENDTAG</h3>
-<pre class="programlisting">#define <a href="#MOVETO_ENDTAG">MOVETO_ENDTAG</a>(p);
-</pre>
-<p>Skips to the next '&gt;' char.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>p</tt></i>:</span></td>
-<td>and UTF8 string pointer</td>
-</tr></tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="MOVETO_STARTTAG">Macro </a>MOVETO_STARTTAG</h3>
-<pre class="programlisting">#define <a href="#MOVETO_STARTTAG">MOVETO_STARTTAG</a>(p);
-</pre>
-<p>Skips to the next '&lt;' char.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>p</tt></i>:</span></td>
-<td>and UTF8 string pointer</td>
-</tr></tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="SKIP_EOL">Macro </a>SKIP_EOL</h3>
-<pre class="programlisting">#define <a href="#SKIP_EOL">SKIP_EOL</a>(p);
+<a name="XML_MAX_DICTIONARY_LIMIT">Macro </a>XML_MAX_DICTIONARY_LIMIT</h3>
+<pre class="programlisting">#define <a href="#XML_MAX_DICTIONARY_LIMIT">XML_MAX_DICTIONARY_LIMIT</a>;
 </pre>
-<p>Skips the end of line chars.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>p</tt></i>:</span></td>
-<td>and UTF8 string pointer</td>
-</tr></tbody>
-</table></div>
+<p>Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use <a href="libxml2-parser.html#XML_PARSE_HUGE">XML_PARSE_HUGE</a> option to override it. Introduced in 2.9.0</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="XML_MAX_DICTIONARY_LIMIT">Macro </a>XML_MAX_DICTIONARY_LIMIT</h3>
-<pre class="programlisting">#define <a href="#XML_MAX_DICTIONARY_LIMIT">XML_MAX_DICTIONARY_LIMIT</a>;
+<a name="XML_MAX_HUGE_LENGTH">Macro </a>XML_MAX_HUGE_LENGTH</h3>
+<pre class="programlisting">#define <a href="#XML_MAX_HUGE_LENGTH">XML_MAX_HUGE_LENGTH</a>;
 </pre>
-<p>Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use <a href="libxml2-parser.html#XML_PARSE_HUGE">XML_PARSE_HUGE</a> option to override it. Introduced in 2.9.0</p>
+<p>Maximum size allowed when <a href="libxml2-parser.html#XML_PARSE_HUGE">XML_PARSE_HUGE</a> is set.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -591,7 +549,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParserMaxDepth">Variable </a>xmlParserMaxDepth</h3>
 <pre class="programlisting">unsigned int xmlParserMaxDepth;
 </pre>
-<p></p>
+<p>arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature. It can be disabled with the <a href="libxml2-parser.html#XML_PARSE_HUGE">XML_PARSE_HUGE</a> parser option.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -620,39 +578,6 @@ int        <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="htmlCreateFileParserCtxt"></a>htmlCreateFileParserCtxt ()</h3>
-<pre class="programlisting"><a href="libxml2-HTMLparser.html#htmlParserCtxtPtr">htmlParserCtxtPtr</a>  htmlCreateFileParserCtxt        (const char * filename, <br>                                                     const char * encoding)<br>
-</pre>
-<p>Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>filename</tt></i>:</span></td>
-<td>the filename</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>encoding</tt></i>:</span></td>
-<td>a free form C string describing the HTML document encoding, or NULL</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the new parser context or NULL</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="htmlInitAutoClose"></a>htmlInitAutoClose ()</h3>
-<pre class="programlisting">void       htmlInitAutoClose               (void)<br>
-</pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. This is a no-op now.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="inputPop"></a>inputPop ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>        inputPop        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
@@ -702,7 +627,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="namePop"></a>namePop ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       namePop                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Pops the top element name from the name stack</p>
+<p>DEPRECATED: Internal function, do not use. Pops the top element name from the name stack</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -723,7 +648,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="namePush"></a>namePush ()</h3>
 <pre class="programlisting">int        namePush                        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value)<br>
 </pre>
-<p>Pushes a new element name on top of the name stack</p>
+<p>DEPRECATED: Internal function, do not use. Pushes a new element name on top of the name stack</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -748,7 +673,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="nodePop"></a>nodePop ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      nodePop                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Pops the top element node from the node stack</p>
+<p>DEPRECATED: Internal function, do not use. Pops the top element node from the node stack</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -769,7 +694,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="nodePush"></a>nodePush ()</h3>
 <pre class="programlisting">int        nodePush                        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> value)<br>
 </pre>
-<p>Pushes a new element node on top of the node stack</p>
+<p>DEPRECATED: Internal function, do not use. Pushes a new element node on top of the node stack</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -794,7 +719,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlCheckLanguageID"></a>xmlCheckLanguageID ()</h3>
 <pre class="programlisting">int        xmlCheckLanguageID              (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * lang)<br>
 </pre>
-<p>Checks that the value conforms to the LanguageID production: NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition. [33] LanguageID ::= Langcode ('-' Subcode)* [34] Langcode ::= ISO639Code | IanaCode | UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+ [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+ The current REC <a href="libxml2-SAX.html#reference">reference</a> the successors of RFC 1766, currently 5646 http://www.rfc-editor.org/rfc/rfc5646.txt langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved script = 4ALPHA ; ISO 15924 code region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum) extension = singleton 1*("-" (2*8alphanum)) ; Single alphanumerics ; "x" reserved for private use singleton = DIGIT ; 0 - 9 / %x41-57 ; A - W / %x59-5A ; Y - Z / %x61-77 ; a - w / %x79-7A ; y - z it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn't try to cope with extension or privateuse that could be added but that's not interoperable anyway</p>
+<p>DEPRECATED: Internal function, do not use. Checks that the value conforms to the LanguageID production: NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition. [33] LanguageID ::= Langcode ('-' Subcode)* [34] Langcode ::= ISO639Code | IanaCode | UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+ [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+ The current REC <a href="libxml2-SAX.html#reference">reference</a> the successors of RFC 1766, currently 5646 http://www.rfc-editor.org/rfc/rfc5646.txt langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved script = 4ALPHA ; ISO 15924 code region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum) extension = singleton 1*("-" (2*8alphanum)) ; Single alphanumerics ; "x" reserved for private use singleton = DIGIT ; 0 - 9 / %x41-57 ; A - W / %x59-5A ; Y - Z / %x61-77 ; a - w / %x79-7A ; y - z it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn't try to cope with extension or privateuse that could be added but that's not interoperable anyway</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -972,7 +897,7 @@ int <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlCurrentChar"></a>xmlCurrentChar ()</h3>
 <pre class="programlisting">int        xmlCurrentChar                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int * len)<br>
 </pre>
-<p>The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)</p>
+<p>DEPRECATED: Internal function, do not use. The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1036,27 +961,6 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlErrMemory"></a>xmlErrMemory ()</h3>
-<pre class="programlisting">void       xmlErrMemory                    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const char * extra)<br>
-</pre>
-<p>Handle a redefinition of <a href="libxml2-SAX.html#attribute">attribute</a> error</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>ctxt</tt></i>:</span></td>
-<td>an XML parser context</td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>extra</tt></i>:</span></td>
-<td>extra information</td>
-</tr>
-</tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlFreeInputStream"></a>xmlFreeInputStream ()</h3>
 <pre class="programlisting">void       xmlFreeInputStream              (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input)<br>
 </pre>
@@ -1185,7 +1089,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlNewEntityInputStream"></a>xmlNewEntityInputStream ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>        xmlNewEntityInputStream (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                            <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a> entity)<br>
 </pre>
-<p>Create a new input stream based on an <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a></p>
+<p>DEPRECATED: Internal function, do not use. Create a new input stream based on an <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a></p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1281,7 +1185,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlNextChar"></a>xmlNextChar ()</h3>
 <pre class="programlisting">void       xmlNextChar                     (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Skip to the next char input char.</p>
+<p>DEPRECATED: Internal function, do not use. Skip to the next char input char.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1296,7 +1200,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseAttValue"></a>xmlParseAttValue ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseAttValue        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse a value for an <a href="libxml2-SAX.html#attribute">attribute</a> Note: the parser won't do substitution of entities here, this will be handled later in <a href="libxml2-tree.html#xmlStringGetNodeList">xmlStringGetNodeList</a> [10] AttValue ::= '"' ([^&lt;&amp;"] | Reference)* '"' | "'" ([^&lt;&amp;'] | Reference)* "'" 3.3.3 Attribute-Value Normalization: Before the value of an <a href="libxml2-SAX.html#attribute">attribute</a> is passed to the application or checked for validity, the XML processor must normalize it as follows: - a character <a href="libxml2-SAX.html#reference">reference</a> is processed by appending the referenced character to the <a href="libxml2-SAX.html#attribute">attribute</a> value - an entity <a href="libxml2-SAX.html#reference">reference</a> is processed by recursively processing the replacement text of the entity - a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a "#xD#xA" sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity - other <a href="libxml2-SAX.html#characters">characters</a> are processed by appending them to the normalized value If the declared value is not CDATA, then the XML processor must further process the normalized <a href="libxml2-SAX.html#attribute">attribute</a> value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) <a href="libxml2-SAX.html#characters">characters</a> by a single space (#x20) character. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.</p>
+<p>DEPRECATED: Internal function, don't use. parse a value for an <a href="libxml2-SAX.html#attribute">attribute</a> Note: the parser won't do substitution of entities here, this will be handled later in <a href="libxml2-tree.html#xmlStringGetNodeList">xmlStringGetNodeList</a> [10] AttValue ::= '"' ([^&lt;&amp;"] | Reference)* '"' | "'" ([^&lt;&amp;'] | Reference)* "'" 3.3.3 Attribute-Value Normalization: Before the value of an <a href="libxml2-SAX.html#attribute">attribute</a> is passed to the application or checked for validity, the XML processor must normalize it as follows: - a character <a href="libxml2-SAX.html#reference">reference</a> is processed by appending the referenced character to the <a href="libxml2-SAX.html#attribute">attribute</a> value - an entity <a href="libxml2-SAX.html#reference">reference</a> is processed by recursively processing the replacement text of the entity - a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a "#xD#xA" sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity - other <a href="libxml2-SAX.html#characters">characters</a> are processed by appending them to the normalized value If the declared value is not CDATA, then the XML processor must further process the normalized <a href="libxml2-SAX.html#attribute">attribute</a> value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) <a href="libxml2-SAX.html#characters">characters</a> by a single space (#x20) character. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1317,7 +1221,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseAttribute"></a>xmlParseAttribute ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlParseAttribute       (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** value)<br>
 </pre>
-<p>parse an <a href="libxml2-SAX.html#attribute">attribute</a> [41] Attribute ::= Name Eq AttValue [ WFC: No External Entity References ] Attribute values cannot contain direct or indirect entity references to external entities. [ WFC: No &lt; in Attribute Values ] The replacement text of any entity referred to directly or indirectly in an <a href="libxml2-SAX.html#attribute">attribute</a> value (other than "&amp;lt;") must not contain a &lt;. [ VC: Attribute Value Type ] The <a href="libxml2-SAX.html#attribute">attribute</a> must have been declared; the value must be of the type declared for it. [25] Eq ::= S? '=' S? With namespace: [NS 11] Attribute ::= QName Eq AttValue Also the case QName == xmlns:??? is handled independently as a namespace definition.</p>
+<p>DEPRECATED: Internal function, don't use. parse an <a href="libxml2-SAX.html#attribute">attribute</a> [41] Attribute ::= Name Eq AttValue [ WFC: No External Entity References ] Attribute values cannot contain direct or indirect entity references to external entities. [ WFC: No &lt; in Attribute Values ] The replacement text of any entity referred to directly or indirectly in an <a href="libxml2-SAX.html#attribute">attribute</a> value (other than "&amp;lt;") must not contain a &lt;. [ VC: Attribute Value Type ] The <a href="libxml2-SAX.html#attribute">attribute</a> must have been declared; the value must be of the type declared for it. [25] Eq ::= S? '=' S? With namespace: [NS 11] Attribute ::= QName Eq AttValue Also the case QName == xmlns:??? is handled independently as a namespace definition.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1343,7 +1247,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseAttributeListDecl"></a>xmlParseAttributeListDecl ()</h3>
 <pre class="programlisting">void       xmlParseAttributeListDecl       (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>: parse the Attribute list def for an element [52] AttlistDecl ::= '&lt;!ATTLIST' S Name AttDef* S? '&gt;' [53] AttDef ::= S Name S AttType S DefaultDecl</p>
+<p>DEPRECATED: Internal function, don't use. Parse an <a href="libxml2-SAX.html#attribute">attribute</a> list declaration for an element. Always consumes '&lt;!'. [52] AttlistDecl ::= '&lt;!ATTLIST' S Name AttDef* S? '&gt;' [53] AttDef ::= S Name S AttType S DefaultDecl</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1358,7 +1262,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseAttributeType"></a>xmlParseAttributeType ()</h3>
 <pre class="programlisting">int        xmlParseAttributeType           (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlEnumerationPtr">xmlEnumerationPtr</a> * tree)<br>
 </pre>
-<p>parse the Attribute list def for an element [54] AttType ::= StringType | TokenizedType | EnumeratedType [55] StringType ::= 'CDATA' [56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS' Validity constraints for <a href="libxml2-SAX.html#attribute">attribute</a> values syntax are checked in xmlValidateAttributeValue() [ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them. [ VC: One ID per Element Type ] No element type may have more than one ID <a href="libxml2-SAX.html#attribute">attribute</a> specified. [ VC: ID Attribute Default ] An ID <a href="libxml2-SAX.html#attribute">attribute</a> must have a declared default of #IMPLIED or #REQUIRED. [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID <a href="libxml2-SAX.html#attribute">attribute</a> on some element in the XML document; i.e. IDREF values must match the value of some ID attribute. [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD. [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.</p>
+<p>DEPRECATED: Internal function, don't use. parse the Attribute list def for an element [54] AttType ::= StringType | TokenizedType | EnumeratedType [55] StringType ::= 'CDATA' [56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS' Validity constraints for <a href="libxml2-SAX.html#attribute">attribute</a> values syntax are checked in xmlValidateAttributeValue() [ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them. [ VC: One ID per Element Type ] No element type may have more than one ID <a href="libxml2-SAX.html#attribute">attribute</a> specified. [ VC: ID Attribute Default ] An ID <a href="libxml2-SAX.html#attribute">attribute</a> must have a declared default of #IMPLIED or #REQUIRED. [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID <a href="libxml2-SAX.html#attribute">attribute</a> on some element in the XML document; i.e. IDREF values must match the value of some ID <a href="libxml2-SAX.html#attribute">attribute</a>. [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD. [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1383,7 +1287,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseCDSect"></a>xmlParseCDSect ()</h3>
 <pre class="programlisting">void       xmlParseCDSect                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Parse escaped pure raw content. [18] CDSect ::= CDStart CData CDEnd [19] CDStart ::= '&lt;![CDATA[' [20] Data ::= (Char* - (Char* ']]&gt;' Char*)) [21] CDEnd ::= ']]&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. Parse escaped pure raw content. Always consumes '&lt;!['. [18] CDSect ::= CDStart CData CDEnd [19] CDStart ::= '&lt;![CDATA[' [20] Data ::= (Char* - (Char* ']]&gt;' Char*)) [21] CDEnd ::= ']]&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1398,7 +1302,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseCharData"></a>xmlParseCharData ()</h3>
 <pre class="programlisting">void       xmlParseCharData                (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    int cdata)<br>
 </pre>
-<p>parse a CharData section. if we are within a CDATA section ']]&gt;' marks an end of section. The right angle bracket (&gt;) may be represented using the string "&amp;gt;", and must, for compatibility, be escaped using "&amp;gt;" or a character <a href="libxml2-SAX.html#reference">reference</a> when it appears in the string "]]&gt;" in content, when that string is not marking the end of a CDATA section. [14] CharData ::= [^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;' [^&lt;&amp;]*)</p>
+<p>DEPRECATED: Internal function, don't use.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1408,7 +1312,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 </tr>
 <tr>
 <td><span class="term"><i><tt>cdata</tt></i>:</span></td>
-<td>int indicating whether we are within a CDATA section</td>
+<td>unused</td>
 </tr>
 </tbody>
 </table></div>
@@ -1419,7 +1323,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseCharRef"></a>xmlParseCharRef ()</h3>
 <pre class="programlisting">int        xmlParseCharRef                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse Reference declarations [66] CharRef ::= '&amp;#' [0-9]+ ';' | '&amp;#x' [0-9a-fA-F]+ ';' [ WFC: Legal Character ] Characters referred to using character references must match the production for Char.</p>
+<p>DEPRECATED: Internal function, don't use. Parse a numeric character <a href="libxml2-SAX.html#reference">reference</a>. Always consumes '&amp;'. [66] CharRef ::= '&amp;#' [0-9]+ ';' | '&amp;#x' [0-9a-fA-F]+ ';' [ WFC: Legal Character ] Characters referred to using character references must match the production for Char.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1440,7 +1344,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseComment"></a>xmlParseComment ()</h3>
 <pre class="programlisting">void       xmlParseComment                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>Skip an XML (SGML) <a href="libxml2-SAX.html#comment">comment</a> &lt;!-- .... --&gt; The spec says that "For compatibility, the string "--" (double-hyphen) must not occur within comments. " [15] Comment ::= '&lt;!--' ((Char - '-') | ('-' (Char - '-')))* '--&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. Parse an XML (SGML) <a href="libxml2-SAX.html#comment">comment</a>. Always consumes '&lt;!'. The spec says that "For compatibility, the string "--" (double-hyphen) must not occur within comments. " [15] Comment ::= '&lt;!--' ((Char - '-') | ('-' (Char - '-')))* '--&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1470,7 +1374,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseDefaultDecl"></a>xmlParseDefaultDecl ()</h3>
 <pre class="programlisting">int        xmlParseDefaultDecl             (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** value)<br>
 </pre>
-<p>Parse an <a href="libxml2-SAX.html#attribute">attribute</a> default declaration [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) [ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the <a href="libxml2-SAX.html#attribute">attribute</a> must be specified for all elements of the type in the attribute-list declaration. [ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared <a href="libxml2-SAX.html#attribute">attribute</a> type c.f. xmlValidateAttributeDecl() [ VC: Fixed Attribute Default ] if an <a href="libxml2-SAX.html#attribute">attribute</a> has a default value declared with the #FIXED keyword, instances of that <a href="libxml2-SAX.html#attribute">attribute</a> must match the default value. [ WFC: No &lt; in Attribute Values ] handled in xmlParseAttValue()</p>
+<p>DEPRECATED: Internal function, don't use. Parse an <a href="libxml2-SAX.html#attribute">attribute</a> default declaration [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) [ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the <a href="libxml2-SAX.html#attribute">attribute</a> must be specified for all elements of the type in the attribute-list declaration. [ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared <a href="libxml2-SAX.html#attribute">attribute</a> type c.f. xmlValidateAttributeDecl() [ VC: Fixed Attribute Default ] if an <a href="libxml2-SAX.html#attribute">attribute</a> has a default value declared with the #FIXED keyword, instances of that <a href="libxml2-SAX.html#attribute">attribute</a> must match the default value. [ WFC: No &lt; in Attribute Values ] handled in xmlParseAttValue()</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1485,7 +1389,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, <a href="libxml2-tree.html#XML_ATTRIBUTE_IMPLIED">XML_ATTRIBUTE_IMPLIED</a> or XML_ATTRIBUTE_FIXED.</td>
+<td>XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, <a href="libxml2-tree.html#XML_ATTRIBUTE_IMPLIED">XML_ATTRIBUTE_IMPLIED</a> or <a href="libxml2-tree.html#XML_ATTRIBUTE_FIXED">XML_ATTRIBUTE_FIXED</a>.</td>
 </tr>
 </tbody>
 </table></div>
@@ -1496,7 +1400,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseDocTypeDecl"></a>xmlParseDocTypeDecl ()</h3>
 <pre class="programlisting">void       xmlParseDocTypeDecl             (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse a DOCTYPE declaration [28] doctypedecl ::= '&lt;!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '&gt;' [ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.</p>
+<p>DEPRECATED: Internal function, don't use. parse a DOCTYPE declaration [28] doctypedecl ::= '&lt;!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '&gt;' [ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1511,7 +1415,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseElement"></a>xmlParseElement ()</h3>
 <pre class="programlisting">void       xmlParseElement                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML element [39] element ::= EmptyElemTag | STag content ETag [ WFC: Element Type Match ] The Name in an element's end-tag must match the element type in the start-tag.</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML element [39] element ::= EmptyElemTag | STag content ETag [ WFC: Element Type Match ] The Name in an element's end-tag must match the element type in the start-tag.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1526,7 +1430,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseElementChildrenContentDecl"></a>xmlParseElementChildrenContentDecl ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlElementContentPtr">xmlElementContentPtr</a>  xmlParseElementChildrenContentDecl      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                                    int inputchk)<br>
 </pre>
-<p>parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in <a href="libxml2-parserInternals.html#xmlParseElementContentDecl">xmlParseElementContentDecl</a> [47] children ::= (choice | seq) ('?' | '*' | '+')? [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')? [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')' [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')' [ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity <a href="libxml2-SAX.html#reference">reference</a> appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).</p>
+<p>DEPRECATED: Internal function, don't use. parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in <a href="libxml2-parserInternals.html#xmlParseElementContentDecl">xmlParseElementContentDecl</a> [47] children ::= (choice | seq) ('?' | '*' | '+')? [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')? [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')' [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')' [ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity <a href="libxml2-SAX.html#reference">reference</a> appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1551,7 +1455,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseElementContentDecl"></a>xmlParseElementContentDecl ()</h3>
 <pre class="programlisting">int        xmlParseElementContentDecl      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         <a href="libxml2-tree.html#xmlElementContentPtr">xmlElementContentPtr</a> * result)<br>
 </pre>
-<p>parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in <a href="libxml2-parserInternals.html#xmlParseElementDecl">xmlParseElementDecl</a> [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children</p>
+<p>DEPRECATED: Internal function, don't use. parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in <a href="libxml2-parserInternals.html#xmlParseElementDecl">xmlParseElementDecl</a> [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1580,7 +1484,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseElementDecl"></a>xmlParseElementDecl ()</h3>
 <pre class="programlisting">int        xmlParseElementDecl             (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an Element declaration. [45] elementdecl ::= '&lt;!ELEMENT' S Name S contentspec S? '&gt;' [ VC: Unique Element Type Declaration ] No element type may be declared more than once</p>
+<p>DEPRECATED: Internal function, don't use. Parse an element declaration. Always consumes '&lt;!'. [45] elementdecl ::= '&lt;!ELEMENT' S Name S contentspec S? '&gt;' [ VC: Unique Element Type Declaration ] No element type may be declared more than once</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1601,7 +1505,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseElementMixedContentDecl"></a>xmlParseElementMixedContentDecl ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlElementContentPtr">xmlElementContentPtr</a>  xmlParseElementMixedContentDecl (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                                    int inputchk)<br>
 </pre>
-<p>parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in <a href="libxml2-parserInternals.html#xmlParseElementContentDecl">xmlParseElementContentDecl</a> [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')' [ VC: Proper Group/PE Nesting ] applies to [51] too (see [49]) [ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.</p>
+<p>DEPRECATED: Internal function, don't use. parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in <a href="libxml2-parserInternals.html#xmlParseElementContentDecl">xmlParseElementContentDecl</a> [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')' [ VC: Proper Group/PE Nesting ] applies to [51] too (see [49]) [ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1626,7 +1530,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEncName"></a>xmlParseEncName ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseEncName         (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the XML encoding name [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*</p>
+<p>DEPRECATED: Internal function, don't use. parse the XML encoding name [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1647,7 +1551,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEncodingDecl"></a>xmlParseEncodingDecl ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlParseEncodingDecl    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the XML encoding declaration [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'") this setups the conversion filters.</p>
+<p>DEPRECATED: Internal function, don't use. parse the XML encoding declaration [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'") this setups the conversion filters.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1668,7 +1572,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEndTag"></a>xmlParseEndTag ()</h3>
 <pre class="programlisting">void       xmlParseEndTag                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an end of tag [42] ETag ::= '&lt;/' Name S? '&gt;' With namespace [NS 9] ETag ::= '&lt;/' QName S? '&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. parse an end of tag [42] ETag ::= '&lt;/' Name S? '&gt;' With namespace [NS 9] ETag ::= '&lt;/' QName S? '&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1683,7 +1587,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEntityDecl"></a>xmlParseEntityDecl ()</h3>
 <pre class="programlisting">void       xmlParseEntityDecl              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse &lt;!ENTITY declarations [70] EntityDecl ::= GEDecl | PEDecl [71] GEDecl ::= '&lt;!ENTITY' S Name S EntityDef S? '&gt;' [72] PEDecl ::= '&lt;!ENTITY' S '%' S Name S PEDef S? '&gt;' [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?) [74] PEDef ::= EntityValue | ExternalID [76] NDataDecl ::= S 'NDATA' S Name [ VC: Notation Declared ] The Name must match the declared name of a notation.</p>
+<p>DEPRECATED: Internal function, don't use. Parse an entity declaration. Always consumes '&lt;!'. [70] EntityDecl ::= GEDecl | PEDecl [71] GEDecl ::= '&lt;!ENTITY' S Name S EntityDef S? '&gt;' [72] PEDecl ::= '&lt;!ENTITY' S '%' S Name S PEDef S? '&gt;' [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?) [74] PEDef ::= EntityValue | ExternalID [76] NDataDecl ::= S 'NDATA' S Name [ VC: Notation Declared ] The Name must match the declared name of a notation.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1698,7 +1602,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEntityRef"></a>xmlParseEntityRef ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>  xmlParseEntityRef       (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse ENTITY references declarations [68] EntityRef ::= '&amp;' Name ';' [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity <a href="libxml2-SAX.html#reference">reference</a> must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it. Similarly, the declaration of a general entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'. [ WFC: Parsed Entity ] An entity <a href="libxml2-SAX.html#reference">reference</a> must not contain the name of an unparsed entity</p>
+<p>DEPRECATED: Internal function, don't use. Parse an entitiy <a href="libxml2-SAX.html#reference">reference</a>. Always consumes '&amp;'. [68] EntityRef ::= '&amp;' Name ';' [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity <a href="libxml2-SAX.html#reference">reference</a> must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it. Similarly, the declaration of a general entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'. [ WFC: Parsed Entity ] An entity <a href="libxml2-SAX.html#reference">reference</a> must not contain the name of an unparsed entity</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1719,7 +1623,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEntityValue"></a>xmlParseEntityValue ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseEntityValue     (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** orig)<br>
 </pre>
-<p>parse a value for ENTITY declarations [9] EntityValue ::= '"' ([^%&amp;"] | PEReference | Reference)* '"' | "'" ([^%&amp;'] | PEReference | Reference)* "'"</p>
+<p>DEPRECATED: Internal function, don't use. parse a value for ENTITY declarations [9] EntityValue ::= '"' ([^%&amp;"] | PEReference | Reference)* '"' | "'" ([^%&amp;'] | PEReference | Reference)* "'"</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1744,7 +1648,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEnumeratedType"></a>xmlParseEnumeratedType ()</h3>
 <pre class="programlisting">int        xmlParseEnumeratedType          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlEnumerationPtr">xmlEnumerationPtr</a> * tree)<br>
 </pre>
-<p>parse an Enumerated <a href="libxml2-SAX.html#attribute">attribute</a> type. [57] EnumeratedType ::= NotationType | Enumeration [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'</p>
+<p>DEPRECATED: Internal function, don't use. parse an Enumerated <a href="libxml2-SAX.html#attribute">attribute</a> type. [57] EnumeratedType ::= NotationType | Enumeration [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1771,7 +1675,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseEnumerationType"></a>xmlParseEnumerationType ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlEnumerationPtr">xmlEnumerationPtr</a>        xmlParseEnumerationType (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an Enumeration <a href="libxml2-SAX.html#attribute">attribute</a> type. [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [ VC: Enumeration ] Values of this type must match one of the Nmtoken tokens in the declaration</p>
+<p>DEPRECATED: Internal function, don't use. parse an Enumeration <a href="libxml2-SAX.html#attribute">attribute</a> type. [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [ VC: Enumeration ] Values of this type must match one of the Nmtoken tokens in the declaration</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1792,7 +1696,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseExternalID"></a>xmlParseExternalID ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseExternalID      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** publicID, <br>                                  int strict)<br>
 </pre>
-<p>Parse an External ID or a Public ID NOTE: Productions [75] and [83] interact badly since [75] can generate 'PUBLIC' S PubidLiteral S SystemLiteral [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral [83] PublicID ::= 'PUBLIC' S PubidLiteral</p>
+<p>DEPRECATED: Internal function, don't use. Parse an External ID or a Public ID NOTE: Productions [75] and [83] interact badly since [75] can generate 'PUBLIC' S PubidLiteral S SystemLiteral [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral [83] PublicID ::= 'PUBLIC' S PubidLiteral</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1846,7 +1750,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseMarkupDecl"></a>xmlParseMarkupDecl ()</h3>
 <pre class="programlisting">void       xmlParseMarkupDecl              (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse Markup declarations [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment [ VC: Proper Declaration/PE Nesting ] Parameter-entity replacement text must be properly nested with markup declarations. That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text. [ WFC: PEs in Internal Subset ] In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations. (This does not apply to references that occur in external parameter entities or to the external subset.)</p>
+<p>DEPRECATED: Internal function, don't use. Parse markup declarations. Always consumes '&lt;!' or '&lt;?'. [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment [ VC: Proper Declaration/PE Nesting ] Parameter-entity replacement text must be properly nested with markup declarations. That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text. [ WFC: PEs in Internal Subset ] In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations. (This does not apply to references that occur in external parameter entities or to the external subset.)</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1861,7 +1765,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseMisc"></a>xmlParseMisc ()</h3>
 <pre class="programlisting">void       xmlParseMisc                    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML Misc* optional field. [27] Misc ::= Comment | PI | S</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML Misc* optional field. [27] Misc ::= Comment | PI | S</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1876,7 +1780,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseName"></a>xmlParseName ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlParseName            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML name. [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender [5] Name ::= (Letter | '_' | ':') (NameChar)* [6] Names ::= Name (#x20 Name)*</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML name. [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender [5] Name ::= (Letter | '_' | ':') (NameChar)* [6] Names ::= Name (#x20 Name)*</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1912,7 +1816,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseNmtoken"></a>xmlParseNmtoken ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseNmtoken         (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML Nmtoken. [7] Nmtoken ::= (NameChar)+ [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML Nmtoken. [7] Nmtoken ::= (NameChar)+ [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1933,7 +1837,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseNotationDecl"></a>xmlParseNotationDecl ()</h3>
 <pre class="programlisting">void       xmlParseNotationDecl            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse a notation declaration [82] NotationDecl ::= '&lt;!NOTATION' S Name S (ExternalID | PublicID) S? '&gt;' Hence there is actually 3 choices: 'PUBLIC' S PubidLiteral 'PUBLIC' S PubidLiteral S SystemLiteral and 'SYSTEM' S SystemLiteral See the NOTE on xmlParseExternalID().</p>
+<p>DEPRECATED: Internal function, don't use. Parse a notation declaration. Always consumes '&lt;!'. [82] NotationDecl ::= '&lt;!NOTATION' S Name S (ExternalID | PublicID) S? '&gt;' Hence there is actually 3 choices: 'PUBLIC' S PubidLiteral 'PUBLIC' S PubidLiteral S SystemLiteral and 'SYSTEM' S SystemLiteral See the NOTE on xmlParseExternalID().</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1948,7 +1852,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseNotationType"></a>xmlParseNotationType ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlEnumerationPtr">xmlEnumerationPtr</a>        xmlParseNotationType    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an Notation <a href="libxml2-SAX.html#attribute">attribute</a> type. Note: the leading 'NOTATION' S part has already being parsed... [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' [ VC: Notation Attributes ] Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.</p>
+<p>DEPRECATED: Internal function, don't use. parse an Notation <a href="libxml2-SAX.html#attribute">attribute</a> type. Note: the leading 'NOTATION' S part has already being parsed... [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' [ VC: Notation Attributes ] Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1969,7 +1873,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParsePEReference"></a>xmlParsePEReference ()</h3>
 <pre class="programlisting">void       xmlParsePEReference             (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse PEReference declarations The entity content is handled directly by pushing it's content as a new input stream. [69] PEReference ::= '%' Name ';' [ WFC: No Recursion ] A parsed entity must not contain a recursive <a href="libxml2-SAX.html#reference">reference</a> to itself, either directly or indirectly. [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.</p>
+<p>DEPRECATED: Internal function, don't use. Parse a parameter entity <a href="libxml2-SAX.html#reference">reference</a>. Always consumes '%'. The entity content is handled directly by pushing it's content as a new input stream. [69] PEReference ::= '%' Name ';' [ WFC: No Recursion ] A parsed entity must not contain a recursive <a href="libxml2-SAX.html#reference">reference</a> to itself, either directly or indirectly. [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1984,7 +1888,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParsePI"></a>xmlParsePI ()</h3>
 <pre class="programlisting">void       xmlParsePI                      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML Processing Instruction. [16] PI ::= '&lt;?' PITarget (S (Char* - (Char* '?&gt;' Char*)))? '?&gt;' The processing is transferred to SAX once parsed.</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML Processing Instruction. [16] PI ::= '&lt;?' PITarget (S (Char* - (Char* '?&gt;' Char*)))? '?&gt;' The processing is transferred to SAX once parsed.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -1999,7 +1903,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParsePITarget"></a>xmlParsePITarget ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlParsePITarget        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the name of a PI [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))</p>
+<p>DEPRECATED: Internal function, don't use. parse the name of a PI [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2020,7 +1924,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParsePubidLiteral"></a>xmlParsePubidLiteral ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParsePubidLiteral    (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML public literal [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML public literal [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2062,7 +1966,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseReference"></a>xmlParseReference ()</h3>
 <pre class="programlisting">void       xmlParseReference               (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse and handle entity references in content, depending on the SAX interface, this may end-up in a call to character() if this is a CharRef, a predefined entity, if there is no reference() callback. or if the parser was asked to switch to that mode. [67] Reference ::= EntityRef | CharRef</p>
+<p>DEPRECATED: Internal function, don't use. parse and handle entity references in content, depending on the SAX interface, this may end-up in a call to character() if this is a CharRef, a predefined entity, if there is no reference() callback. or if the parser was asked to switch to that mode. Always consumes '&amp;'. [67] Reference ::= EntityRef | CharRef</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -2077,7 +1981,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseSDDecl"></a>xmlParseSDDecl ()</h3>
 <pre class="programlisting">int        xmlParseSDDecl                  (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the XML standalone declaration [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"')) [ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value "no" if any external markup declarations contain declarations of: - attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or - entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or - attributes with values subject to normalization, where the <a href="libxml2-SAX.html#attribute">attribute</a> appears in the document with a value which will change as a result of normalization, or - element types with element content, if white space occurs directly within any instance of those types.</p>
+<p>DEPRECATED: Internal function, don't use. parse the XML standalone declaration [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"')) [ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value "no" if any external markup declarations contain declarations of: - attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or - entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or - attributes with values subject to normalization, where the <a href="libxml2-SAX.html#attribute">attribute</a> appears in the document with a value which will change as a result of normalization, or - element types with element content, if white space occurs directly within any instance of those types.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2098,7 +2002,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseStartTag"></a>xmlParseStartTag ()</h3>
 <pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       xmlParseStartTag        (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse a start of tag either for rule element or EmptyElement. In both case we don't parse the tag closing chars. [40] STag ::= '&lt;' Name (S Attribute)* S? '&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. [44] EmptyElemTag ::= '&lt;' Name (S Attribute)* S? '/&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. With namespace: [NS 8] STag ::= '&lt;' QName (S Attribute)* S? '&gt;' [NS 10] EmptyElement ::= '&lt;' QName (S Attribute)* S? '/&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. Parse a start tag. Always consumes '&lt;'. [40] STag ::= '&lt;' Name (S Attribute)* S? '&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. [44] EmptyElemTag ::= '&lt;' Name (S Attribute)* S? '/&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. With namespace: [NS 8] STag ::= '&lt;' QName (S Attribute)* S? '&gt;' [NS 10] EmptyElement ::= '&lt;' QName (S Attribute)* S? '/&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2119,7 +2023,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseSystemLiteral"></a>xmlParseSystemLiteral ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseSystemLiteral   (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML Literal [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML Literal [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2140,7 +2044,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseTextDecl"></a>xmlParseTextDecl ()</h3>
 <pre class="programlisting">void       xmlParseTextDecl                (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML declaration header for external entities [77] TextDecl ::= '&lt;?xml' VersionInfo? EncodingDecl S? '?&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML declaration header for external entities [77] TextDecl ::= '&lt;?xml' VersionInfo? EncodingDecl S? '?&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -2155,7 +2059,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseVersionInfo"></a>xmlParseVersionInfo ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseVersionInfo     (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the XML version. [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ") [25] Eq ::= S? '=' S?</p>
+<p>DEPRECATED: Internal function, don't use. parse the XML version. [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ") [25] Eq ::= S? '=' S?</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2176,7 +2080,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseVersionNum"></a>xmlParseVersionNum ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlParseVersionNum      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse the XML version value. [26] VersionNum ::= '1.' [0-9]+ In practice allow [0-9].[0-9]+ at that level</p>
+<p>DEPRECATED: Internal function, don't use. parse the XML version value. [26] VersionNum ::= '1.' [0-9]+ In practice allow [0-9].[0-9]+ at that level</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2197,7 +2101,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParseXMLDecl"></a>xmlParseXMLDecl ()</h3>
 <pre class="programlisting">void       xmlParseXMLDecl                 (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>parse an XML declaration header [23] XMLDecl ::= '&lt;?xml' VersionInfo EncodingDecl? SDDecl? S? '?&gt;'</p>
+<p>DEPRECATED: Internal function, don't use. parse an XML declaration header [23] XMLDecl ::= '&lt;?xml' VersionInfo EncodingDecl? SDDecl? S? '?&gt;'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -2212,7 +2116,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParserHandlePEReference"></a>xmlParserHandlePEReference ()</h3>
 <pre class="programlisting">void       xmlParserHandlePEReference      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>[69] PEReference ::= '%' Name ';' [ WFC: No Recursion ] A parsed entity must not contain a recursive <a href="libxml2-SAX.html#reference">reference</a> to itself, either directly or indirectly. [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled. A PEReference may have been detected in the current input stream the handling is done accordingly to http://www.w3.org/TR/REC-xml#entproc i.e. - Included in literal in entity values - Included as Parameter Entity <a href="libxml2-SAX.html#reference">reference</a> within DTDs</p>
+<p>DEPRECATED: Internal function, do not use. [69] PEReference ::= '%' Name ';' [ WFC: No Recursion ] A parsed entity must not contain a recursive <a href="libxml2-SAX.html#reference">reference</a> to itself, either directly or indirectly. [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any <a href="libxml2-SAX.html#reference">reference</a> to it... [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled. A PEReference may have been detected in the current input stream the handling is done accordingly to http://www.w3.org/TR/REC-xml#entproc i.e. - Included in literal in entity values - Included as Parameter Entity <a href="libxml2-SAX.html#reference">reference</a> within DTDs</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -2242,7 +2146,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlParserInputShrink"></a>xmlParserInputShrink ()</h3>
 <pre class="programlisting">void       xmlParserInputShrink            (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> in)<br>
 </pre>
-<p>This function removes used input for the parser.</p>
+<p>DEPRECATED: Don't use. This function removes used input for the parser.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -2339,7 +2243,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlSkipBlankChars"></a>xmlSkipBlankChars ()</h3>
 <pre class="programlisting">int        xmlSkipBlankChars               (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br>
 </pre>
-<p>skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.</p>
+<p>DEPRECATED: Internal function, do not use. skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2389,7 +2293,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlStringCurrentChar"></a>xmlStringCurrentChar ()</h3>
 <pre class="programlisting">int        xmlStringCurrentChar            (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  int * len)<br>
 </pre>
-<p>The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer.</p>
+<p>DEPRECATED: Internal function, do not use. The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2418,7 +2322,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlStringDecodeEntities"></a>xmlStringDecodeEntities ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlStringDecodeEntities (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  int what, <br>                                  <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end, <br>                                  <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end2, <br>                                         <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end3)<br>
 </pre>
-<p>Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'</p>
+<p>DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2460,7 +2364,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlStringLenDecodeEntities"></a>xmlStringLenDecodeEntities ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlStringLenDecodeEntities      (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                            const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                          int len, <br>                                           int what, <br>                                          <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end, <br>                                          <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end2, <br>                                                 <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> end3)<br>
 </pre>
-<p>Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'</p>
+<p>DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2506,7 +2410,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlSwitchEncoding"></a>xmlSwitchEncoding ()</h3>
 <pre class="programlisting">int        xmlSwitchEncoding               (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc)<br>
 </pre>
-<p>change the input functions when discovering the character encoding of a given entity.</p>
+<p>Use encoding specified by enum to decode input data. This function can be used to enforce the encoding of chunks passed to <a href="libxml2-parser.html#xmlParseChunk">xmlParseChunk</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2531,7 +2435,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlSwitchInputEncoding"></a>xmlSwitchInputEncoding ()</h3>
 <pre class="programlisting">int        xmlSwitchInputEncoding          (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input, <br>                                         <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> handler)<br>
 </pre>
-<p>DEPRECATED: Use <a href="libxml2-parserInternals.html#xmlSwitchToEncoding">xmlSwitchToEncoding</a> change the input functions when discovering the character encoding of a given entity.</p>
+<p>DEPRECATED: Internal function, don't use. Use encoding handler to decode input data.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2560,7 +2464,7 @@ int       <a href="#xmlSwitchToEncoding">xmlSwitchToEncoding</a>          (<a href="libxml2-tr
 <a name="xmlSwitchToEncoding"></a>xmlSwitchToEncoding ()</h3>
 <pre class="programlisting">int        xmlSwitchToEncoding             (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt, <br>                                    <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> handler)<br>
 </pre>
-<p>change the input functions when discovering the character encoding of a given entity.</p>
+<p>Use encoding handler to decode input data. This function can be used to enforce the encoding of chunks passed to <a href="libxml2-parser.html#xmlParseChunk">xmlParseChunk</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 4ab52dc..6efceb7 100644 (file)
 typedef <a href="libxml2-threads.html#xmlMutex">xmlMutex</a> * <a href="#xmlMutexPtr">xmlMutexPtr</a>;
 typedef struct _xmlRMutex <a href="#xmlRMutex">xmlRMutex</a>;
 typedef <a href="libxml2-threads.html#xmlRMutex">xmlRMutex</a> * <a href="#xmlRMutexPtr">xmlRMutexPtr</a>;
+int    <a href="#xmlCheckThreadLocalStorage">xmlCheckThreadLocalStorage</a>    (void);
 void   <a href="#xmlCleanupThreads">xmlCleanupThreads</a>              (void);
-int    <a href="#xmlDllMain">xmlDllMain</a>                    (void * hinstDLL, <br>                                   unsigned long fdwReason, <br>                                   void * lpvReserved);
 void   <a href="#xmlFreeMutex">xmlFreeMutex</a>                        (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
 void   <a href="#xmlFreeRMutex">xmlFreeRMutex</a>                      (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
-<a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> <a href="#xmlGetGlobalState">xmlGetGlobalState</a>      (void);
 int    <a href="#xmlGetThreadId">xmlGetThreadId</a>                    (void);
 void   <a href="#xmlInitThreads">xmlInitThreads</a>                    (void);
 int    <a href="#xmlIsMainThread">xmlIsMainThread</a>                  (void);
@@ -86,39 +85,25 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlCleanupThreads"></a>xmlCleanupThreads ()</h3>
-<pre class="programlisting">void       xmlCleanupThreads               (void)<br>
+<a name="xmlCheckThreadLocalStorage"></a>xmlCheckThreadLocalStorage ()</h3>
+<pre class="programlisting">int        xmlCheckThreadLocalStorage      (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all. xmlCleanupThreads() is used to to cleanup all the thread related data of the libxml2 library once processing has ended. WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !</p>
+<p>Check whether thread-local storage could be allocated. In cross-platform code running in multithreaded environments, this function should be called once in each thread before calling other library functions to make sure that thread-local storage was allocated properly.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody><tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>0 on success or -1 if a memory allocation failed. A failed allocation signals a typically fatal and irrecoverable out-of-memory situation. Don't call any library functions in this case. This function never fails if the library is compiled with support for thread-local storage. This function never fails for the "main" thread which is the first thread calling <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>. Available since v2.12.0.</td>
+</tr></tbody>
+</table></div>
 </div>
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlDllMain"></a>xmlDllMain ()</h3>
-<pre class="programlisting">int        xmlDllMain                      (void * hinstDLL, <br>                                   unsigned long fdwReason, <br>                                   void * lpvReserved)<br>
+<a name="xmlCleanupThreads"></a>xmlCleanupThreads ()</h3>
+<pre class="programlisting">void       xmlCleanupThreads               (void)<br>
 </pre>
-<p></p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody>
-<tr>
-<td><span class="term"><i><tt>hinstDLL</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>fdwReason</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>lpvReserved</tt></i>:</span></td>
-<td></td>
-</tr>
-<tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td></td>
-</tr>
-</tbody>
-</table></div>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -126,7 +111,7 @@ The content of this structure is not made public by the API.
 <a name="xmlFreeMutex"></a>xmlFreeMutex ()</h3>
 <pre class="programlisting">void       xmlFreeMutex                    (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br>
 </pre>
-<p>xmlFreeMutex() is used to reclaim resources associated with a libxml2 token struct.</p>
+<p>Free a mutex.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -153,25 +138,10 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="xmlGetGlobalState"></a>xmlGetGlobalState ()</h3>
-<pre class="programlisting"><a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a>     xmlGetGlobalState       (void)<br>
-</pre>
-<p>xmlGetGlobalState() is called to retrieve the global state for a thread.</p>
-<div class="variablelist"><table border="0">
-<col align="left">
-<tbody><tr>
-<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the thread global state or NULL in case of error</td>
-</tr></tbody>
-</table></div>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlGetThreadId"></a>xmlGetThreadId ()</h3>
 <pre class="programlisting">int        xmlGetThreadId                  (void)<br>
 </pre>
-<p>xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn't mandate pthread_t to be an integer type</p>
+<p>DEPRECATED: Internal function, do not use. xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn't mandate pthread_t to be an integer type</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -186,7 +156,7 @@ The content of this structure is not made public by the API.
 <a name="xmlInitThreads"></a>xmlInitThreads ()</h3>
 <pre class="programlisting">void       xmlInitThreads                  (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. xmlInitThreads() is used to to initialize all the thread related data of the libxml2 library.</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -194,7 +164,7 @@ The content of this structure is not made public by the API.
 <a name="xmlIsMainThread"></a>xmlIsMainThread ()</h3>
 <pre class="programlisting">int        xmlIsMainThread                 (void)<br>
 </pre>
-<p>xmlIsMainThread() check whether the current thread is the main thread.</p>
+<p>DEPRECATED: Internal function, do not use. Check whether the current thread is the main thread.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
index 615abd7..61d6aa7 100644 (file)
@@ -24,7 +24,6 @@
 <h2>Synopsis</h2>
 <pre class="synopsis">#define <a href="#BASE_BUFFER_SIZE">BASE_BUFFER_SIZE</a>;
 #define <a href="#LIBXML2_NEW_BUFFER">LIBXML2_NEW_BUFFER</a>;
-#define <a href="#XML_DOCB_DOCUMENT_NODE">XML_DOCB_DOCUMENT_NODE</a>;
 #define <a href="#XML_GET_CONTENT">XML_GET_CONTENT</a>;
 #define <a href="#XML_GET_LINE">XML_GET_LINE</a>;
 #define <a href="#XML_LOCAL_NAMESPACE">XML_LOCAL_NAMESPACE</a>;
@@ -135,6 +134,8 @@ void        <a href="#xmlDOMWrapFreeCtxt">xmlDOMWrapFreeCtxt</a>            (<a href="libxml2-tre
 <a href="libxml2-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a>    <a href="#xmlDOMWrapNewCtxt">xmlDOMWrapNewCtxt</a>      (void);
 int    <a href="#xmlDOMWrapReconcileNamespaces">xmlDOMWrapReconcileNamespaces</a>      (<a href="libxml2-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> ctxt, <br>                                  <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem, <br>                                        int options);
 int    <a href="#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a>                (<a href="libxml2-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> ctxt, <br>                                  <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        int options);
+<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>    <a href="#xmlDeregisterNodeDefault">xmlDeregisterNodeDefault</a>        (<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func);
+typedef void <a href="#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>                (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlDocCopyNode">xmlDocCopyNode</a>            (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   int extended);
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlDocCopyNodeList">xmlDocCopyNodeList</a>    (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
 int    <a href="#xmlDocDump">xmlDocDump</a>                    (FILE * f, <br>                                  <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> cur);
@@ -219,6 +220,8 @@ void        <a href="#xmlNodeSetName">xmlNodeSetName</a>                    (<a href="libxml2-tree.html#
 void   <a href="#xmlNodeSetSpacePreserve">xmlNodeSetSpacePreserve</a>          (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         int val);
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlPreviousElementSibling">xmlPreviousElementSibling</a>      (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
 int    <a href="#xmlReconciliateNs">xmlReconciliateNs</a>              (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> tree);
+<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>        <a href="#xmlRegisterNodeDefault">xmlRegisterNodeDefault</a>    (<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func);
+typedef void <a href="#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>            (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node);
 int    <a href="#xmlRemoveProp">xmlRemoveProp</a>                      (<a href="libxml2-tree.html#xmlAttrPtr">xmlAttrPtr</a> cur);
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlReplaceNode">xmlReplaceNode</a>            (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> old, <br>                                         <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur);
 int    <a href="#xmlSaveFile">xmlSaveFile</a>                  (const char * filename, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> cur);
@@ -243,6 +246,10 @@ const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       <a href="#xmlSplitQ
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlStringLenGetNodeList">xmlStringLenGetNodeList</a>  (const <a href="libxml2-tree.html#xmlDoc">xmlDoc</a> * doc, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value, <br>                                        int len);
 int    <a href="#xmlTextConcat">xmlTextConcat</a>                      (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content, <br>                                      int len);
 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>  <a href="#xmlTextMerge">xmlTextMerge</a>                (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> first, <br>                                       <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> second);
+<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a>    <a href="#xmlThrDefBufferAllocScheme">xmlThrDefBufferAllocScheme</a>    (<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> v);
+int    <a href="#xmlThrDefDefaultBufferSize">xmlThrDefDefaultBufferSize</a>    (int v);
+<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>    <a href="#xmlThrDefDeregisterNodeDefault">xmlThrDefDeregisterNodeDefault</a>    (<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func);
+<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>        <a href="#xmlThrDefRegisterNodeDefault">xmlThrDefRegisterNodeDefault</a>        (<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func);
 void   <a href="#xmlUnlinkNode">xmlUnlinkNode</a>                      (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur);
 int    <a href="#xmlUnsetNsProp">xmlUnsetNsProp</a>                    (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        <a href="libxml2-tree.html#xmlNsPtr">xmlNsPtr</a> ns, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
 int    <a href="#xmlUnsetProp">xmlUnsetProp</a>                        (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
@@ -269,15 +276,7 @@ int        <a href="#xmlValidateQName">xmlValidateQName</a>                (const <a href="libxml2-xm
 <a name="LIBXML2_NEW_BUFFER">Macro </a>LIBXML2_NEW_BUFFER</h3>
 <pre class="programlisting">#define <a href="#LIBXML2_NEW_BUFFER">LIBXML2_NEW_BUFFER</a>;
 </pre>
-<p>Macro used to express that the API use the new buffers for <a href="libxml2-tree.html#xmlParserInputBuffer">xmlParserInputBuffer</a> and xmlOutputBuffer. The change was introduced in 2.9.0.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XML_DOCB_DOCUMENT_NODE">Macro </a>XML_DOCB_DOCUMENT_NODE</h3>
-<pre class="programlisting">#define <a href="#XML_DOCB_DOCUMENT_NODE">XML_DOCB_DOCUMENT_NODE</a>;
-</pre>
-<p></p>
+<p>Macro used to express that the API use the new buffers for <a href="libxml2-tree.html#xmlParserInputBuffer">xmlParserInputBuffer</a> and <a href="libxml2-tree.html#xmlOutputBuffer">xmlOutputBuffer</a>. The change was introduced in 2.9.0.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -468,7 +467,7 @@ The content of this structure is not made public by the API.
 <pre class="programlisting">enum <a href="#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> {
     <a name="XML_BUFFER_ALLOC_DOUBLEIT">XML_BUFFER_ALLOC_DOUBLEIT</a> = 1 /* double each time one need to grow */
     <a name="XML_BUFFER_ALLOC_EXACT">XML_BUFFER_ALLOC_EXACT</a> = 2 /* grow only to the minimal size */
-    <a name="XML_BUFFER_ALLOC_IMMUTABLE">XML_BUFFER_ALLOC_IMMUTABLE</a> = 3 /* immutable buffer */
+    <a name="XML_BUFFER_ALLOC_IMMUTABLE">XML_BUFFER_ALLOC_IMMUTABLE</a> = 3 /* immutable buffer, deprecated */
     <a name="XML_BUFFER_ALLOC_IO">XML_BUFFER_ALLOC_IO</a> = 4 /* special allocation scheme used for I/O */
     <a name="XML_BUFFER_ALLOC_HYBRID">XML_BUFFER_ALLOC_HYBRID</a> = 5 /* exact up to a threshold, and doubleit thereafter */
     <a name="XML_BUFFER_ALLOC_BOUNDED">XML_BUFFER_ALLOC_BOUNDED</a> = 6 /*  limit the upper size of the buffer */
@@ -525,11 +524,11 @@ The content of this structure is not made public by the API.
     struct _xmlDtd *   extSubset       : the document external subset
     struct _xmlNs *    oldNs   : Global namespace, the old way
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       version : the XML version string
-    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       encoding        : external initial encoding, if any
+    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       encoding        : actual encoding, if any
     void *     ids     : Hash table for ID attributes if any
     void *     refs    : Hash table for IDREFs attributes if any
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       URL     : The URI for that document
-    int        charset : Internal flag for charset handling, actually an <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a>
+    int        charset : unused
     struct _xmlDict *  dict    : dict used to allocate names or NULL
     void *     psvi    : for type/PSVI information
     int        parseFlags      : set of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a> used to parse the document
@@ -744,7 +743,8 @@ The content of this structure is not made public by the API.
     struct _xmlEntity *        nexte   : unused
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       URI     : the full URI as computed
     int        owner   : does the entity own the childrens
-    int        checked : was the entity content checked this is also used to count entities *
+    int        flags   : various flags
+    unsigned long      expandedSize    : expanded size
 } xmlEntity;
 </pre>
 <p></p>
@@ -960,7 +960,7 @@ The content of this structure is not made public by the API.
     int *      spaceTab        : array of space infos
     int        depth   : to prevent entity substitution loops
     <a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a>        entity  : used to check entities boundaries
-    int        charset : encoding of the in-memory content actually an <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a>
+    int        charset : unused
     int        nodelen : Those two fields are there to
     int        nodemem : Speed up large node parsing
     int        pedantic        : signal pedantic warnings
@@ -981,7 +981,7 @@ The content of this structure is not made public by the API.
     int        nsNr    : the number of inherited namespaces
     int        nsMax   : the size of the arrays
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * *     nsTab   : the array of prefix/namespace name
-    int *      attallocs       : which <a href="libxml2-SAX.html#attribute">attribute</a> were allocated
+    unsigned * attallocs       : which <a href="libxml2-SAX.html#attribute">attribute</a> were allocated
     <a href="libxml2-parser.html#xmlStartTag">xmlStartTag</a> *        pushTab : array of data for push
     <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    attsDefault     : defaulted attributes if any
     <a href="libxml2-hash.html#xmlHashTablePtr">xmlHashTablePtr</a>    attsSpecial     : non-CDATA attributes if any
@@ -994,7 +994,7 @@ The content of this structure is not made public by the API.
     <a href="libxml2-tree.html#xmlAttrPtr">xmlAttrPtr</a>      freeAttrs       : * the complete error information for the last error. *
     <a href="libxml2-xmlerror.html#xmlError">xmlError</a>      lastError
     <a href="libxml2-parser.html#xmlParserMode">xmlParserMode</a>      parseMode       : the parser mode
-    unsigned long      nbentities      : number of entities references
+    unsigned long      nbentities      : unused
     unsigned long      sizeentities    : size of parsed entities for use by HTML non-recursive parser
     <a href="libxml2-parser.html#xmlParserNodeInfo">xmlParserNodeInfo</a> *    nodeInfo        : Current NodeInfo
     int        nodeInfoNr      : Depth of the parsing stack
@@ -1002,6 +1002,13 @@ The content of this structure is not made public by the API.
     <a href="libxml2-parser.html#xmlParserNodeInfo">xmlParserNodeInfo</a> *    nodeInfoTab     : array of nodeInfos
     int        input_id        : we need to label inputs
     unsigned long      sizeentcopy     : volume of entity copy
+    int        endCheckState   : quote state for push parser
+    unsigned short     nbErrors        : number of errors
+    unsigned short     nbWarnings      : number of warnings
+    unsigned   maxAmpl : maximum amplification factor
+    <a href="libxml2-parser.html#xmlParserNsData">xmlParserNsData</a> *        nsdb    : namespace database
+    unsigned   attrHashMax     : allocated size
+    <a href="libxml2-parser.html#xmlAttrHashBucket">xmlAttrHashBucket</a> *    attrHash        : atttribute hash table
 } xmlParserCtxt;
 </pre>
 <p></p>
@@ -1027,13 +1034,15 @@ The content of this structure is not made public by the API.
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       end     : end of the array to parse
     int        length  : length if known
     int        line    : Current line
-    int        col     : * NOTE: consumed is only tested for equality in the parser code, *
+    int        col     : Current column
     unsigned long      consumed        : How many xmlChars already consumed
     <a href="libxml2-parser.html#xmlParserInputDeallocate">xmlParserInputDeallocate</a>        free    : function to deallocate the base
-    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       encoding        : the encoding string for entity
+    const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       encoding        : unused
     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       version : the version string for entity
-    int        standalone      : Was that entity marked standalone
+    int        flags   : Flags
     int        id      : an unique identifier for the entity
+    unsigned long      parentConsumed  : consumed bytes from parents
+    <a href="libxml2-tree.html#xmlEntityPtr">xmlEntityPtr</a>  entity  : entity, if any
 } xmlParserInput;
 </pre>
 <p></p>
@@ -1200,6 +1209,36 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlDeregisterNodeFunc"></a>Function type xmlDeregisterNodeFunc</h3>
+<pre class="programlisting">void       xmlDeregisterNodeFunc           (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
+</pre>
+<p>Signature for the deregistration callback of a discarded node</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody><tr>
+<td><span class="term"><i><tt>node</tt></i>:</span></td>
+<td>the current node</td>
+</tr></tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlRegisterNodeFunc"></a>Function type xmlRegisterNodeFunc</h3>
+<pre class="programlisting">void       xmlRegisterNodeFunc             (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br>
+</pre>
+<p>Signature for the registration callback of a created node</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody><tr>
+<td><span class="term"><i><tt>node</tt></i>:</span></td>
+<td>the current node</td>
+</tr></tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlAddChild"></a>xmlAddChild ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlAddChild             (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> parent, <br>                                      <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br>
 </pre>
@@ -1228,7 +1267,7 @@ The content of this structure is not made public by the API.
 <a name="xmlAddChildList"></a>xmlAddChildList ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlAddChildList         (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> parent, <br>                                      <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br>
 </pre>
-<p>Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) See the note regarding namespaces in xmlAddChild.</p>
+<p>Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) See the note regarding namespaces in <a href="libxml2-tree.html#xmlAddChild">xmlAddChild</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1253,7 +1292,7 @@ The content of this structure is not made public by the API.
 <a name="xmlAddNextSibling"></a>xmlAddNextSibling ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlAddNextSibling       (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem)<br>
 </pre>
-<p>Add a new node @elem as the next sibling of @cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging @elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an <a href="libxml2-SAX.html#attribute">attribute</a> with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild.</p>
+<p>Add a new node @elem as the next sibling of @cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging @elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an <a href="libxml2-SAX.html#attribute">attribute</a> with equal name, it is first destroyed. See the note regarding namespaces in <a href="libxml2-tree.html#xmlAddChild">xmlAddChild</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1278,7 +1317,7 @@ The content of this structure is not made public by the API.
 <a name="xmlAddPrevSibling"></a>xmlAddPrevSibling ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlAddPrevSibling       (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem)<br>
 </pre>
-<p>Add a new node @elem as the previous sibling of @cur merging adjacent TEXT nodes (@elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an <a href="libxml2-SAX.html#attribute">attribute</a> with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild.</p>
+<p>Add a new node @elem as the previous sibling of @cur merging adjacent TEXT nodes (@elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an <a href="libxml2-SAX.html#attribute">attribute</a> with equal name, it is first destroyed. See the note regarding namespaces in <a href="libxml2-tree.html#xmlAddChild">xmlAddChild</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1303,7 +1342,7 @@ The content of this structure is not made public by the API.
 <a name="xmlAddSibling"></a>xmlAddSibling ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlAddSibling           (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem)<br>
 </pre>
-<p>Add a new element @elem to the list of siblings of @cur merging adjacent TEXT nodes (@elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild.</p>
+<p>Add a new element @elem to the list of siblings of @cur merging adjacent TEXT nodes (@elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in <a href="libxml2-tree.html#xmlAddChild">xmlAddChild</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1425,7 +1464,7 @@ The content of this structure is not made public by the API.
 <a name="xmlBufNodeDump"></a>xmlBufNodeDump ()</h3>
 <pre class="programlisting">size_t     xmlBufNodeDump                  (<a href="libxml2-tree.html#xmlBufPtr">xmlBufPtr</a> buf, <br>                                   <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         int level, <br>                                         int format)<br>
 </pre>
-<p>Dump an XML node, recursive behaviour,children are printed too. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</p>
+<p>Dump an XML node, recursive behaviour,children are printed too. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1673,7 +1712,7 @@ The content of this structure is not made public by the API.
 <a name="xmlBufferCreateStatic"></a>xmlBufferCreateStatic ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a>  xmlBufferCreateStatic   (void * mem, <br>                                        size_t size)<br>
 </pre>
-<p>routine to create an XML buffer from an immutable memory area. The area won't be modified nor copied, and is expected to be present until the end of the buffer lifetime.</p>
+<p></p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1687,7 +1726,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the new structure.</td>
+<td>an XML buffer initialized with bytes.</td>
 </tr>
 </tbody>
 </table></div>
@@ -2142,7 +2181,7 @@ The content of this structure is not made public by the API.
 <a name="xmlCopyProp"></a>xmlCopyProp ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlAttrPtr">xmlAttrPtr</a>      xmlCopyProp             (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> target, <br>                                      <a href="libxml2-tree.html#xmlAttrPtr">xmlAttrPtr</a> cur)<br>
 </pre>
-<p>Do a copy of the attribute.</p>
+<p>Do a copy of the <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2406,6 +2445,27 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlDeregisterNodeDefault"></a>xmlDeregisterNodeDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>        xmlDeregisterNodeDefault        (<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func)<br>
+</pre>
+<p>Registers a callback for node destruction</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td>function pointer to the new DeregisterNodeFunc</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the previous value of the deregistration function</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlDocCopyNode"></a>xmlDocCopyNode ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlDocCopyNode          (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br>                                        <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   int extended)<br>
 </pre>
@@ -2488,7 +2548,7 @@ The content of this structure is not made public by the API.
 <a name="xmlDocDumpFormatMemory"></a>xmlDocDumpFormatMemory ()</h3>
 <pre class="programlisting">void       xmlDocDumpFormatMemory          (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> cur, <br>                                   <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** mem, <br>                                       int * size, <br>                                        int format)<br>
 </pre>
-<p>Dump an XML document in memory and return the #xmlChar * and it's size. It's up to the caller to free the memory with xmlFree(). Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</p>
+<p>Dump an XML document in memory and return the #xmlChar * and it's size. It's up to the caller to free the memory with xmlFree(). Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2517,7 +2577,7 @@ The content of this structure is not made public by the API.
 <a name="xmlDocDumpFormatMemoryEnc"></a>xmlDocDumpFormatMemoryEnc ()</h3>
 <pre class="programlisting">void       xmlDocDumpFormatMemoryEnc       (<a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> out_doc, <br>                                       <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** doc_txt_ptr, <br>                                       int * doc_txt_len, <br>                                         const char * txt_encoding, <br>                                         int format)<br>
 </pre>
-<p>Dump the current DOM tree into memory using the character encoding specified by the caller. Note it is up to the caller of this function to free the allocated memory with xmlFree(). Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</p>
+<p>Dump the current DOM tree into memory using the character encoding specified by the caller. Note it is up to the caller of this function to free the allocated memory with xmlFree(). Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2622,7 +2682,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of bytes written or -1 in case of failure. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</td>
+<td>the number of bytes written or -1 in case of failure. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</td>
 </tr>
 </tbody>
 </table></div>
@@ -3060,7 +3120,7 @@ The content of this structure is not made public by the API.
 <a name="xmlGetProp"></a>xmlGetProp ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlGetProp              (const <a href="libxml2-tree.html#xmlNode">xmlNode</a> * node, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Search and get the value of an <a href="libxml2-SAX.html#attribute">attribute</a> associated to a node This does the entity substitution. This function looks in DTD <a href="libxml2-SAX.html#attribute">attribute</a> declaration for #FIXED or default declaration values unless DTD use has been turned off. NOTE: this function acts independently of namespaces associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing.</p>
+<p>Search and get the value of an <a href="libxml2-SAX.html#attribute">attribute</a> associated to a node This does the entity substitution. This function looks in DTD <a href="libxml2-SAX.html#attribute">attribute</a> declaration for #FIXED or default declaration values unless DTD use has been turned off. NOTE: this function acts independently of namespaces associated to the <a href="libxml2-SAX.html#attribute">attribute</a>. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3293,7 +3353,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewComment"></a>xmlNewComment ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewComment           (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Use of this function is DISCOURAGED in favor of xmlNewDocComment. Creation of a new node containing a comment.</p>
+<p>Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocComment">xmlNewDocComment</a>. Creation of a new node containing a <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3658,7 +3718,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewNode"></a>xmlNewNode ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewNode              (<a href="libxml2-tree.html#xmlNsPtr">xmlNsPtr</a> ns, <br>                                      const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNode.</p>
+<p>Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocNode">xmlNewDocNode</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3683,7 +3743,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewNodeEatName"></a>xmlNewNodeEatName ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewNodeEatName       (<a href="libxml2-tree.html#xmlNsPtr">xmlNsPtr</a> ns, <br>                                      <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName.</p>
+<p>Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3809,7 +3869,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewPI"></a>xmlNewPI ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewPI                (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Creation of a processing instruction element. Use of this function is DISCOURAGED in favor of xmlNewDocPI.</p>
+<p>Creation of a processing instruction element. Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocPI">xmlNewDocPI</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3891,7 +3951,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewText"></a>xmlNewText ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewText              (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Creation of a new text node. Use of this function is DISCOURAGED in favor of xmlNewDocText.</p>
+<p>Creation of a new text node. Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocText">xmlNewDocText</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -3945,7 +4005,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNewTextLen"></a>xmlNewTextLen ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlNewTextLen           (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content, <br>                                      int len)<br>
 </pre>
-<p>Use of this function is DISCOURAGED in favor of xmlNewDocTextLen. Creation of a new text node with an extra parameter for the content's length</p>
+<p>Use of this function is DISCOURAGED in favor of <a href="libxml2-tree.html#xmlNewDocTextLen">xmlNewDocTextLen</a>. Creation of a new text node with an extra parameter for the content's length</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4062,7 +4122,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNodeDump"></a>xmlNodeDump ()</h3>
 <pre class="programlisting">int        xmlNodeDump                     (<a href="libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> buf, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         int level, <br>                                         int format)<br>
 </pre>
-<p>Dump an XML node, recursive behaviour,children are printed too. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called. Since this is using <a href="libxml2-tree.html#xmlBuffer">xmlBuffer</a> structures it is limited to 2GB and somehow deprecated, use xmlNodeDumpOutput() instead.</p>
+<p>Dump an XML node, recursive behaviour,children are printed too. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called. Since this is using <a href="libxml2-tree.html#xmlBuffer">xmlBuffer</a> structures it is limited to 2GB and somehow deprecated, use xmlNodeDumpOutput() instead.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4099,7 +4159,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNodeDumpOutput"></a>xmlNodeDumpOutput ()</h3>
 <pre class="programlisting">void       xmlNodeDumpOutput               (<a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> buf, <br>                                         <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         int level, <br>                                         int format, <br>                                        const char * encoding)<br>
 </pre>
-<p>Dump an XML node, recursive behaviour, children are printed too. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</p>
+<p>Dump an XML node, recursive behaviour, children are printed too. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4303,7 +4363,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNodeSetBase"></a>xmlNodeSetBase ()</h3>
 <pre class="programlisting">void       xmlNodeSetBase                  (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * uri)<br>
 </pre>
-<p>Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute.</p>
+<p>Set (or reset) the base URI of a node, i.e. the value of the xml:base <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4370,7 +4430,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNodeSetLang"></a>xmlNodeSetLang ()</h3>
 <pre class="programlisting">void       xmlNodeSetLang                  (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * lang)<br>
 </pre>
-<p>Set the language of a node, i.e. the values of the xml:lang attribute.</p>
+<p>Set the language of a node, i.e. the values of the xml:lang <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4412,7 +4472,7 @@ The content of this structure is not made public by the API.
 <a name="xmlNodeSetSpacePreserve"></a>xmlNodeSetSpacePreserve ()</h3>
 <pre class="programlisting">void       xmlNodeSetSpacePreserve         (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br>                                         int val)<br>
 </pre>
-<p>Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space attribute.</p>
+<p>Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4476,6 +4536,27 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlRegisterNodeDefault"></a>xmlRegisterNodeDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>    xmlRegisterNodeDefault  (<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func)<br>
+</pre>
+<p>Registers a callback for node creation</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td>function pointer to the new RegisterNodeFunc</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the old value of the registration function</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlRemoveProp"></a>xmlRemoveProp ()</h3>
 <pre class="programlisting">int        xmlRemoveProp                   (<a href="libxml2-tree.html#xmlAttrPtr">xmlAttrPtr</a> cur)<br>
 </pre>
@@ -4501,7 +4582,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReplaceNode"></a>xmlReplaceNode ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlReplaceNode          (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> old, <br>                                         <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br>
 </pre>
-<p>Unlink the old node from its current context, prune the new one at the same place. If @cur was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild.</p>
+<p>Unlink the old node from its current context, prune the new one at the same place. If @cur was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in <a href="libxml2-tree.html#xmlAddChild">xmlAddChild</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4609,7 +4690,7 @@ The content of this structure is not made public by the API.
 <a name="xmlSaveFormatFile"></a>xmlSaveFormatFile ()</h3>
 <pre class="programlisting">int        xmlSaveFormatFile               (const char * filename, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> cur, <br>                                   int format)<br>
 </pre>
-<p>Dump an XML document to a file. Will use compression if compiled in and enabled. If @filename is "-" the stdout file is used. If @format is set then the document will be indented on output. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</p>
+<p>Dump an XML document to a file. Will use compression if compiled in and enabled. If @filename is "-" the stdout file is used. If @format is set then the document will be indented on output. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -4660,7 +4741,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of bytes written or -1 in case of error. Note that @format = 1 provide node indenting only if <a href="libxml2-globals.html#xmlIndentTreeOutput">xmlIndentTreeOutput</a> = 1 or xmlKeepBlanksDefault(0) was called</td>
+<td>the number of bytes written or -1 in case of error. Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called</td>
 </tr>
 </tbody>
 </table></div>
@@ -5094,6 +5175,90 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlThrDefBufferAllocScheme"></a>xmlThrDefBufferAllocScheme ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a>        xmlThrDefBufferAllocScheme      (<a href="libxml2-tree.html#xmlBufferAllocationScheme">xmlBufferAllocationScheme</a> v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefDefaultBufferSize"></a>xmlThrDefDefaultBufferSize ()</h3>
+<pre class="programlisting">int        xmlThrDefDefaultBufferSize      (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefDeregisterNodeDefault"></a>xmlThrDefDeregisterNodeDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a>        xmlThrDefDeregisterNodeDefault  (<a href="libxml2-tree.html#xmlDeregisterNodeFunc">xmlDeregisterNodeFunc</a> func)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefRegisterNodeDefault"></a>xmlThrDefRegisterNodeDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a>    xmlThrDefRegisterNodeDefault    (<a href="libxml2-tree.html#xmlRegisterNodeFunc">xmlRegisterNodeFunc</a> func)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlUnlinkNode"></a>xmlUnlinkNode ()</h3>
 <pre class="programlisting">void       xmlUnlinkNode                   (<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br>
 </pre>
index 755e78d..de7a0aa 100644 (file)
@@ -358,7 +358,7 @@ char *      <a href="#xmlURIUnescapeString">xmlURIUnescapeString</a>                (const char * s
 <a name="xmlURIEscapeStr"></a>xmlURIEscapeStr ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *     xmlURIEscapeStr         (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br>                                  const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * list)<br>
 </pre>
-<p>This routine escapes a string to hex, ignoring reserved <a href="libxml2-SAX.html#characters">characters</a> (a-z) and the <a href="libxml2-SAX.html#characters">characters</a> in the exception list.</p>
+<p>This routine escapes a string to hex, ignoring reserved <a href="libxml2-SAX.html#characters">characters</a> (a-z, A-Z, 0-9, "@-_.!~*'()") and the <a href="libxml2-SAX.html#characters">characters</a> in the exception list.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 3ea0bb8..7f488dd 100644 (file)
@@ -22,9 +22,7 @@
 <p>Author(s): Daniel Veillard </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
-<pre class="synopsis">#define <a href="#XML_VCTXT_DTD_VALIDATED">XML_VCTXT_DTD_VALIDATED</a>;
-#define <a href="#XML_VCTXT_USE_PCTXT">XML_VCTXT_USE_PCTXT</a>;
-typedef struct _xmlHashTable <a href="#xmlAttributeTable">xmlAttributeTable</a>;
+<pre class="synopsis">typedef struct _xmlHashTable <a href="#xmlAttributeTable">xmlAttributeTable</a>;
 typedef <a href="libxml2-valid.html#xmlAttributeTable">xmlAttributeTable</a> * <a href="#xmlAttributeTablePtr">xmlAttributeTablePtr</a>;
 typedef struct _xmlHashTable <a href="#xmlElementTable">xmlElementTable</a>;
 typedef <a href="libxml2-valid.html#xmlElementTable">xmlElementTable</a> * <a href="#xmlElementTablePtr">xmlElementTablePtr</a>;
@@ -93,7 +91,7 @@ int   <a href="#xmlValidateDocument">xmlValidateDocument</a>          (<a href="libxml2-va
 int    <a href="#xmlValidateDocumentFinal">xmlValidateDocumentFinal</a>        (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc);
 int    <a href="#xmlValidateDtd">xmlValidateDtd</a>                    (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlDtdPtr">xmlDtdPtr</a> dtd);
 int    <a href="#xmlValidateDtdFinal">xmlValidateDtdFinal</a>          (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc);
-int    <a href="#xmlValidateElement">xmlValidateElement</a>            (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem);
+int    <a href="#xmlValidateElement">xmlValidateElement</a>            (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> root);
 int    <a href="#xmlValidateElementDecl">xmlValidateElementDecl</a>            (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlElementPtr">xmlElementPtr</a> elem);
 int    <a href="#xmlValidateNameValue">xmlValidateNameValue</a>                (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value);
 int    <a href="#xmlValidateNamesValue">xmlValidateNamesValue</a>              (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value);
@@ -118,22 +116,6 @@ typedef void <a href="#xmlValidityWarningFunc">xmlValidityWarningFunc</a>          (void
 <div class="refsect2" lang="en">
 <div class="refsect2" lang="en">
 <h3>
-<a name="XML_VCTXT_DTD_VALIDATED">Macro </a>XML_VCTXT_DTD_VALIDATED</h3>
-<pre class="programlisting">#define <a href="#XML_VCTXT_DTD_VALIDATED">XML_VCTXT_DTD_VALIDATED</a>;
-</pre>
-<p>Set after <a href="libxml2-valid.html#xmlValidateDtdFinal">xmlValidateDtdFinal</a> was called.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XML_VCTXT_USE_PCTXT">Macro </a>XML_VCTXT_USE_PCTXT</h3>
-<pre class="programlisting">#define <a href="#XML_VCTXT_USE_PCTXT">XML_VCTXT_USE_PCTXT</a>;
-</pre>
-<p>Set if the validation context is part of a parser context.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlAttributeTable">Structure </a>xmlAttributeTable</h3>
 <pre class="programlisting">struct _xmlHashTable {
 The content of this structure is not made public by the API.
@@ -1713,7 +1695,7 @@ The content of this structure is not made public by the API.
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlValidateElement"></a>xmlValidateElement ()</h3>
-<pre class="programlisting">int        xmlValidateElement              (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> elem)<br>
+<pre class="programlisting">int        xmlValidateElement              (<a href="libxml2-valid.html#xmlValidCtxtPtr">xmlValidCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br>                                   <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> root)<br>
 </pre>
 <p>Try to validate the subtree under an element</p>
 <div class="variablelist"><table border="0">
@@ -1728,7 +1710,7 @@ The content of this structure is not made public by the API.
 <td>a document instance</td>
 </tr>
 <tr>
-<td><span class="term"><i><tt>elem</tt></i>:</span></td>
+<td><span class="term"><i><tt>root</tt></i>:</span></td>
 <td>an element instance</td>
 </tr>
 <tr>
index e25ee02..a8cc38c 100644 (file)
@@ -53,6 +53,8 @@ int   <a href="#xmlOutputBufferClose">xmlOutputBufferClose</a>                (<a href="libxml2-
 <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>  <a href="#xmlOutputBufferCreateFd">xmlOutputBufferCreateFd</a>  (int fd, <br>                                            <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder);
 <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>  <a href="#xmlOutputBufferCreateFile">xmlOutputBufferCreateFile</a>      (FILE * file, <br>                                                       <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder);
 <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>  <a href="#xmlOutputBufferCreateFilename">xmlOutputBufferCreateFilename</a>      (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder, <br>                                                   int compression);
+<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>   <a href="#xmlOutputBufferCreateFilenameDefault">xmlOutputBufferCreateFilenameDefault</a>        (<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func);
+typedef <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> <a href="#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>       (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder, <br>                                                   int compression);
 <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>  <a href="#xmlOutputBufferCreateIO">xmlOutputBufferCreateIO</a>  (<a href="libxml2-xmlIO.html#xmlOutputWriteCallback">xmlOutputWriteCallback</a> iowrite, <br>                                            <a href="libxml2-xmlIO.html#xmlOutputCloseCallback">xmlOutputCloseCallback</a> ioclose, <br>                                            void * ioctx, <br>                                              <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder);
 int    <a href="#xmlOutputBufferFlush">xmlOutputBufferFlush</a>                (<a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> out);
 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *   <a href="#xmlOutputBufferGetContent">xmlOutputBufferGetContent</a>      (<a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> out);
@@ -68,6 +70,8 @@ char *        <a href="#xmlParserGetDirectory">xmlParserGetDirectory</a>              (const char *
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateFd">xmlParserInputBufferCreateFd</a>        (int fd, <br>                                                    <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateFile">xmlParserInputBufferCreateFile</a>    (FILE * file, <br>                                                       <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateFilename">xmlParserInputBufferCreateFilename</a>    (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
+<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> <a href="#xmlParserInputBufferCreateFilenameDefault">xmlParserInputBufferCreateFilenameDefault</a>      (<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func);
+typedef <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a> <a href="#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>   (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateIO">xmlParserInputBufferCreateIO</a>        (<a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                                      void * ioctx, <br>                                                      <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateMem">xmlParserInputBufferCreateMem</a>      (const char * mem, <br>                                                  int size, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
 <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>        <a href="#xmlParserInputBufferCreateStatic">xmlParserInputBufferCreateStatic</a>        (const char * mem, <br>                                                  int size, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc);
@@ -81,6 +85,8 @@ void  <a href="#xmlRegisterDefaultOutputCallbacks">xmlRegisterDefaultOutputCallba
 void   <a href="#xmlRegisterHTTPPostCallbacks">xmlRegisterHTTPPostCallbacks</a>        (void);
 int    <a href="#xmlRegisterInputCallbacks">xmlRegisterInputCallbacks</a>      (<a href="libxml2-xmlIO.html#xmlInputMatchCallback">xmlInputMatchCallback</a> matchFunc, <br>                                    <a href="libxml2-xmlIO.html#xmlInputOpenCallback">xmlInputOpenCallback</a> openFunc, <br>                                       <a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> readFunc, <br>                                       <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> closeFunc);
 int    <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a href="libxml2-xmlIO.html#xmlOutputMatchCallback">xmlOutputMatchCallback</a> matchFunc, <br>                                  <a href="libxml2-xmlIO.html#xmlOutputOpenCallback">xmlOutputOpenCallback</a> openFunc, <br>                                     <a href="libxml2-xmlIO.html#xmlOutputWriteCallback">xmlOutputWriteCallback</a> writeFunc, <br>                                  <a href="libxml2-xmlIO.html#xmlOutputCloseCallback">xmlOutputCloseCallback</a> closeFunc);
+<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>   <a href="#xmlThrDefOutputBufferCreateFilenameDefault">xmlThrDefOutputBufferCreateFilenameDefault</a>    (<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func);
+<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> <a href="#xmlThrDefParserInputBufferCreateFilenameDefault">xmlThrDefParserInputBufferCreateFilenameDefault</a>  (<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -181,6 +187,35 @@ int        <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlOutputBufferCreateFilenameFunc"></a>Function type xmlOutputBufferCreateFilenameFunc</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>      xmlOutputBufferCreateFilenameFunc       (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder, <br>                                                   int compression)<br>
+</pre>
+<p>Signature for the function doing the lookup for a suitable output method corresponding to an URI.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>URI</tt></i>:</span></td>
+<td>the URI to write to</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>encoder</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>compression</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the new <a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a> in case of success or NULL if no method was found.</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlOutputCloseCallback"></a>Function type xmlOutputCloseCallback</h3>
 <pre class="programlisting">int        xmlOutputCloseCallback          (void * context)<br>
 </pre>
@@ -273,6 +308,31 @@ int        <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlParserInputBufferCreateFilenameFunc"></a>Function type xmlParserInputBufferCreateFilenameFunc</h3>
+<pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>    xmlParserInputBufferCreateFilenameFunc  (const char * URI, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc)<br>
+</pre>
+<p>Signature for the function doing the lookup for a suitable input method corresponding to an URI.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>URI</tt></i>:</span></td>
+<td>the URI to read from</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>enc</tt></i>:</span></td>
+<td>the requested source encoding</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the new <a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a> in case of success or NULL if no method was found.</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlAllocOutputBuffer"></a>xmlAllocOutputBuffer ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>      xmlAllocOutputBuffer    (<a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder)<br>
 </pre>
@@ -869,6 +929,27 @@ int        <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlOutputBufferCreateFilenameDefault"></a>xmlOutputBufferCreateFilenameDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>       xmlOutputBufferCreateFilenameDefault    (<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func)<br>
+</pre>
+<p>Registers a callback for URI output file handling</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td>function pointer to the new OutputBufferCreateFilenameFunc</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the old value of the registration function</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlOutputBufferCreateIO"></a>xmlOutputBufferCreateIO ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlOutputBufferPtr">xmlOutputBufferPtr</a>      xmlOutputBufferCreateIO (<a href="libxml2-xmlIO.html#xmlOutputWriteCallback">xmlOutputWriteCallback</a> iowrite, <br>                                            <a href="libxml2-xmlIO.html#xmlOutputCloseCallback">xmlOutputCloseCallback</a> ioclose, <br>                                            void * ioctx, <br>                                              <a href="libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> encoder)<br>
 </pre>
@@ -1146,6 +1227,27 @@ int      <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlParserInputBufferCreateFilenameDefault"></a>xmlParserInputBufferCreateFilenameDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>     xmlParserInputBufferCreateFilenameDefault       (<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func)<br>
+</pre>
+<p>Registers a callback for URI input file handling</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td>function pointer to the new ParserInputBufferCreateFilenameFunc</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the old value of the registration function</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlParserInputBufferCreateIO"></a>xmlParserInputBufferCreateIO ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>    xmlParserInputBufferCreateIO    (<a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                                      void * ioctx, <br>                                                      <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc)<br>
 </pre>
@@ -1211,7 +1313,7 @@ int       <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 <a name="xmlParserInputBufferCreateStatic"></a>xmlParserInputBufferCreateStatic ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlParserInputBufferPtr">xmlParserInputBufferPtr</a>    xmlParserInputBufferCreateStatic        (const char * mem, <br>                                                  int size, <br>                                                  <a href="libxml2-encoding.html#xmlCharEncoding">xmlCharEncoding</a> enc)<br>
 </pre>
-<p>Create a buffered parser input for the progressive parsing for the input from an immutable memory area. This will not copy the memory area to the buffer, but the memory is expected to be available until the end of the parsing, this is useful for example when using mmap'ed file.</p>
+<p>DEPRECATED: Use <a href="libxml2-xmlIO.html#xmlParserInputBufferCreateMem">xmlParserInputBufferCreateMem</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1442,6 +1544,48 @@ int      <a href="#xmlRegisterOutputCallbacks">xmlRegisterOutputCallbacks</a>    (<a hre
 </table></div>
 </div>
 <hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefOutputBufferCreateFilenameDefault"></a>xmlThrDefOutputBufferCreateFilenameDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a>       xmlThrDefOutputBufferCreateFilenameDefault      (<a href="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc">xmlOutputBufferCreateFilenameFunc</a> func)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefParserInputBufferCreateFilenameDefault"></a>xmlThrDefParserInputBufferCreateFilenameDefault ()</h3>
+<pre class="programlisting"><a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a>     xmlThrDefParserInputBufferCreateFilenameDefault (<a href="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc">xmlParserInputBufferCreateFilenameFunc</a> func)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>func</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
 </div>
 </div>
 </body>
index f97c8e1..678770f 100644 (file)
@@ -28,11 +28,11 @@ typedef enum <a href="#xmlErrorLevel">xmlErrorLevel</a>;
 typedef <a href="libxml2-xmlerror.html#xmlError">xmlError</a> * <a href="#xmlErrorPtr">xmlErrorPtr</a>;
 typedef enum <a href="#xmlParserErrors">xmlParserErrors</a>;
 void   <a href="#initGenericErrorDefaultFunc">initGenericErrorDefaultFunc</a>  (<a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> * handler);
-int    <a href="#xmlCopyError">xmlCopyError</a>                        (<a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> from, <br>                                  <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> to);
-<a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>    <a href="#xmlCtxtGetLastError">xmlCtxtGetLastError</a>  (void * ctx);
+int    <a href="#xmlCopyError">xmlCopyError</a>                        (const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> * from, <br>                                        <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> to);
+const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> *  <a href="#xmlCtxtGetLastError">xmlCtxtGetLastError</a>  (void * ctx);
 void   <a href="#xmlCtxtResetLastError">xmlCtxtResetLastError</a>              (void * ctx);
 typedef void <a href="#xmlGenericErrorFunc">xmlGenericErrorFunc</a>            (void * ctx, <br>                                        const char * msg, <br>                                  ... ...);
-<a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>    <a href="#xmlGetLastError">xmlGetLastError</a>          (void);
+const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> *  <a href="#xmlGetLastError">xmlGetLastError</a>  (void);
 void   <a href="#xmlParserError">xmlParserError</a>                    (void * ctx, <br>                                        const char * msg, <br>                                  ... ...);
 void   <a href="#xmlParserPrintFileContext">xmlParserPrintFileContext</a>      (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input);
 void   <a href="#xmlParserPrintFileInfo">xmlParserPrintFileInfo</a>            (<a href="libxml2-tree.html#xmlParserInputPtr">xmlParserInputPtr</a> input);
@@ -43,7 +43,9 @@ void  <a href="#xmlResetError">xmlResetError</a>                      (<a href="libxml2-xmlerror.htm
 void   <a href="#xmlResetLastError">xmlResetLastError</a>              (void);
 void   <a href="#xmlSetGenericErrorFunc">xmlSetGenericErrorFunc</a>            (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> handler);
 void   <a href="#xmlSetStructuredErrorFunc">xmlSetStructuredErrorFunc</a>      (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> handler);
-typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>              (void * userData, <br>                                   <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> error);
+typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>              (void * userData, <br>                                   const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> * error);
+void   <a href="#xmlThrDefSetGenericErrorFunc">xmlThrDefSetGenericErrorFunc</a>        (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> handler);
+void   <a href="#xmlThrDefSetStructuredErrorFunc">xmlThrDefSetStructuredErrorFunc</a>  (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> handler);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -250,6 +252,7 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>           (void
     <a name="XML_ERR_NAME_TOO_LONG">XML_ERR_NAME_TOO_LONG</a> = 110 /* 110 */
     <a name="XML_ERR_USER_STOP">XML_ERR_USER_STOP</a> = 111 /* 111 */
     <a name="XML_ERR_COMMENT_ABRUPTLY_ENDED">XML_ERR_COMMENT_ABRUPTLY_ENDED</a> = 112 /* 112 */
+    <a name="XML_WAR_ENCODING_MISMATCH">XML_WAR_ENCODING_MISMATCH</a> = 113 /* 113 */
     <a name="XML_NS_ERR_XML_NAMESPACE">XML_NS_ERR_XML_NAMESPACE</a> = 200
     <a name="XML_NS_ERR_UNDEFINED_NAMESPACE">XML_NS_ERR_UNDEFINED_NAMESPACE</a> = 201 /* 201 */
     <a name="XML_NS_ERR_QNAME">XML_NS_ERR_QNAME</a> = 202 /* 202 */
@@ -906,7 +909,7 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>           (void
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlStructuredErrorFunc"></a>Function type xmlStructuredErrorFunc</h3>
-<pre class="programlisting">void       xmlStructuredErrorFunc          (void * userData, <br>                                   <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> error)<br>
+<pre class="programlisting">void       xmlStructuredErrorFunc          (void * userData, <br>                                   const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> * error)<br>
 </pre>
 <p>Signature of the function to use when there is an error and the module handles the new error reporting mechanism.</p>
 <div class="variablelist"><table border="0">
@@ -929,7 +932,7 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>           (void
 <a name="initGenericErrorDefaultFunc"></a>initGenericErrorDefaultFunc ()</h3>
 <pre class="programlisting">void       initGenericErrorDefaultFunc     (<a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> * handler)<br>
 </pre>
-<p>Set or reset (if NULL) the default handler for generic errors to the builtin error function.</p>
+<p>DEPRECATED: Use <a href="libxml2-xmlerror.html#xmlSetGenericErrorFunc">xmlSetGenericErrorFunc</a>. Set or reset (if NULL) the default handler for generic errors to the builtin error function.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
@@ -942,7 +945,7 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>           (void
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlCopyError"></a>xmlCopyError ()</h3>
-<pre class="programlisting">int        xmlCopyError                    (<a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> from, <br>                                  <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> to)<br>
+<pre class="programlisting">int        xmlCopyError                    (const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> * from, <br>                                        <a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a> to)<br>
 </pre>
 <p>Save the original error to the new place.</p>
 <div class="variablelist"><table border="0">
@@ -967,7 +970,7 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>           (void
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlCtxtGetLastError"></a>xmlCtxtGetLastError ()</h3>
-<pre class="programlisting"><a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>        xmlCtxtGetLastError     (void * ctx)<br>
+<pre class="programlisting">const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> *      xmlCtxtGetLastError     (void * ctx)<br>
 </pre>
 <p>Get the last parsing error registered.</p>
 <div class="variablelist"><table border="0">
@@ -1003,14 +1006,14 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>               (void
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlGetLastError"></a>xmlGetLastError ()</h3>
-<pre class="programlisting"><a href="libxml2-xmlerror.html#xmlErrorPtr">xmlErrorPtr</a>        xmlGetLastError         (void)<br>
+<pre class="programlisting">const <a href="libxml2-xmlerror.html#xmlError">xmlError</a> *      xmlGetLastError (void)<br>
 </pre>
 <p>Get the last global error registered. This is per thread if compiled with thread support.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>NULL if no error occurred or a pointer to the error</td>
+<td>a pointer to the error</td>
 </tr></tbody>
 </table></div>
 </div>
@@ -1210,6 +1213,48 @@ typedef void <a href="#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a>                (void
 </table></div>
 </div>
 <hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefSetGenericErrorFunc"></a>xmlThrDefSetGenericErrorFunc ()</h3>
+<pre class="programlisting">void       xmlThrDefSetGenericErrorFunc    (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlGenericErrorFunc">xmlGenericErrorFunc</a> handler)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>handler</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefSetStructuredErrorFunc"></a>xmlThrDefSetStructuredErrorFunc ()</h3>
+<pre class="programlisting">void       xmlThrDefSetStructuredErrorFunc (void * ctx, <br>                                        <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> handler)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>ctx</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>handler</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
 </div>
 </div>
 </body>
index 9bf475e..937d7cb 100644 (file)
 <p>Author(s): </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
-<pre class="synopsis">#define <a href="#LIBXML_DLL_IMPORT">LIBXML_DLL_IMPORT</a>;
-#define <a href="#XMLCALL">XMLCALL</a>;
-#define <a href="#XMLCDECL">XMLCDECL</a>;
-#define <a href="#XMLPUBFUN">XMLPUBFUN</a>;
-#define <a href="#XMLPUBLIC">XMLPUBLIC</a>;
+<pre class="synopsis">#define <a href="#XMLPUBFUN">XMLPUBFUN</a>;
 #define <a href="#XMLPUBVAR">XMLPUBVAR</a>;
 </pre>
 </div>
 <div class="refsect2" lang="en">
 <div class="refsect2" lang="en">
 <h3>
-<a name="LIBXML_DLL_IMPORT">Macro </a>LIBXML_DLL_IMPORT</h3>
-<pre class="programlisting">#define <a href="#LIBXML_DLL_IMPORT">LIBXML_DLL_IMPORT</a>;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XMLCALL">Macro </a>XMLCALL</h3>
-<pre class="programlisting">#define <a href="#XMLCALL">XMLCALL</a>;
-</pre>
-<p>Macro which declares the calling convention for exported functions</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XMLCDECL">Macro </a>XMLCDECL</h3>
-<pre class="programlisting">#define <a href="#XMLCDECL">XMLCDECL</a>;
-</pre>
-<p>Macro which declares the calling convention for exported functions that use '...'.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="XMLPUBFUN">Macro </a>XMLPUBFUN</h3>
 <pre class="programlisting">#define <a href="#XMLPUBFUN">XMLPUBFUN</a>;
 </pre>
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="XMLPUBLIC">Macro </a>XMLPUBLIC</h3>
-<pre class="programlisting">#define <a href="#XMLPUBLIC">XMLPUBLIC</a>;
-</pre>
-<p>Macro which declares a public symbol</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="XMLPUBVAR">Macro </a>XMLPUBVAR</h3>
 <pre class="programlisting">#define <a href="#XMLPUBVAR">XMLPUBVAR</a>;
 </pre>
index e1aef9d..0a1198d 100644 (file)
 <p>Author(s): Daniel Veillard </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
-<pre class="synopsis">#define <a href="#DEBUG_MEMORY">DEBUG_MEMORY</a>;
-#define <a href="#xmlMalloc">xmlMalloc</a>;
-#define <a href="#xmlMallocAtomic">xmlMallocAtomic</a>;
-#define <a href="#xmlMemStrdup">xmlMemStrdup</a>;
-#define <a href="#xmlRealloc">xmlRealloc</a>;
-void   <a href="#xmlCleanupMemory">xmlCleanupMemory</a>                (void);
+<pre class="synopsis">void     <a href="#xmlCleanupMemory">xmlCleanupMemory</a>                (void);
 typedef void <a href="#xmlFreeFunc">xmlFreeFunc</a>                    (void * mem);
 int    <a href="#xmlGcMemGet">xmlGcMemGet</a>                  (<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br>                                   <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br>                                     <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocAtomicFunc, <br>                                       <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br>                                  <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc);
 int    <a href="#xmlGcMemSetup">xmlGcMemSetup</a>                      (<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>                                     <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>                                       <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocAtomicFunc, <br>                                         <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>                                    <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc);
@@ -44,6 +39,7 @@ void *        <a href="#xmlMemMalloc">xmlMemMalloc</a>                        (size_t size);
 void * <a href="#xmlMemRealloc">xmlMemRealloc</a>                      (void * ptr, <br>                                        size_t size);
 int    <a href="#xmlMemSetup">xmlMemSetup</a>                  (<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>                                     <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>                                       <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>                                    <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc);
 void   <a href="#xmlMemShow">xmlMemShow</a>                    (FILE * fp, <br>                                         int nr);
+size_t <a href="#xmlMemSize">xmlMemSize</a>                    (void * ptr);
 char * <a href="#xmlMemStrdupLoc">xmlMemStrdupLoc</a>                  (const char * str, <br>                                  const char * file, <br>                                         int line);
 int    <a href="#xmlMemUsed">xmlMemUsed</a>                    (void);
 void   <a href="#xmlMemoryDump">xmlMemoryDump</a>                      (void);
@@ -59,14 +55,6 @@ typedef char * <a href="#xmlStrdupFunc">xmlStrdupFunc</a>                    (const char * str);
 <div class="refsect2" lang="en">
 <div class="refsect2" lang="en">
 <h3>
-<a name="DEBUG_MEMORY">Macro </a>DEBUG_MEMORY</h3>
-<pre class="programlisting">#define <a href="#DEBUG_MEMORY">DEBUG_MEMORY</a>;
-</pre>
-<p><a href="libxml2-xmlmemory.html#DEBUG_MEMORY">DEBUG_MEMORY</a> replaces the allocator with a collect and debug shell to the libc allocator. <a href="libxml2-xmlmemory.html#DEBUG_MEMORY">DEBUG_MEMORY</a> should only be activated when debugging libxml i.e. if libxml has been configured with --with-debug-mem too. #define DEBUG_MEMORY_FREED #define <a href="libxml2-xmlversion.html#DEBUG_MEMORY_LOCATION">DEBUG_MEMORY_LOCATION</a></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlFreeFunc"></a>Function type xmlFreeFunc</h3>
 <pre class="programlisting">void       xmlFreeFunc                     (void * mem)<br>
 </pre>
@@ -149,10 +137,50 @@ typedef char * <a href="#xmlStrdupFunc">xmlStrdupFunc</a>                 (const char * str);
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlFree">Variable </a>xmlFree</h3>
+<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> xmlFree;
+</pre>
+<p>@mem: an already allocated block of memory The variable holding the libxml free() implementation</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlMalloc">Variable </a>xmlMalloc</h3>
+<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMalloc;
+</pre>
+<p>@size: the size requested in bytes The variable holding the libxml malloc() implementation Returns a pointer to the newly allocated block or NULL in case of error</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlMallocAtomic">Variable </a>xmlMallocAtomic</h3>
+<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMallocAtomic;
+</pre>
+<p>@size: the size requested in bytes The variable holding the libxml malloc() implementation for atomic data (i.e. blocks not containing pointers), useful when using a garbage collecting allocator. Returns a pointer to the newly allocated block or NULL in case of error</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlMemStrdup">Variable </a>xmlMemStrdup</h3>
+<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> xmlMemStrdup;
+</pre>
+<p>@str: a zero terminated string The variable holding the libxml strdup() implementation Returns the copy of the string or NULL in case of error</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlRealloc">Variable </a>xmlRealloc</h3>
+<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> xmlRealloc;
+</pre>
+<p>@mem: an already allocated block of memory @size: the new size requested in bytes The variable holding the libxml realloc() implementation Returns a pointer to the newly reallocated block or NULL in case of error</p>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlCleanupMemory"></a>xmlCleanupMemory ()</h3>
 <pre class="programlisting">void       xmlCleanupMemory                (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all. Free up all the memory allocated by the library for its own use. This should not be called by user level code.</p>
+<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -234,12 +262,12 @@ typedef char * <a href="#xmlStrdupFunc">xmlStrdupFunc</a>                 (const char * str);
 <a name="xmlInitMemory"></a>xmlInitMemory ()</h3>
 <pre class="programlisting">int        xmlInitMemory                   (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the memory layer.</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody><tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>0 on success</td>
+<td></td>
 </tr></tbody>
 </table></div>
 </div>
@@ -503,6 +531,27 @@ typedef char * <a href="#xmlStrdupFunc">xmlStrdupFunc</a>                  (const char * str);
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlMemSize"></a>xmlMemSize ()</h3>
+<pre class="programlisting">size_t     xmlMemSize                      (void * ptr)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>ptr</tt></i>:</span></td>
+<td>pointer to the memory allocation</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>the size of a memory allocation.</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlMemStrdupLoc"></a>xmlMemStrdupLoc ()</h3>
 <pre class="programlisting">char *     xmlMemStrdupLoc                 (const char * str, <br>                                  const char * file, <br>                                         int line)<br>
 </pre>
index 0230687..76b3a72 100644 (file)
@@ -109,6 +109,7 @@ int <a href="#xmlTextReaderRelaxNGValidateCtxt">xmlTextReaderRelaxNGValidateCtxt
 int    <a href="#xmlTextReaderSchemaValidate">xmlTextReaderSchemaValidate</a>  (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     const char * xsd);
 int    <a href="#xmlTextReaderSchemaValidateCtxt">xmlTextReaderSchemaValidateCtxt</a>  (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     <a href="libxml2-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br>                                    int options);
 void   <a href="#xmlTextReaderSetErrorHandler">xmlTextReaderSetErrorHandler</a>        (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     <a href="libxml2-xmlreader.html#xmlTextReaderErrorFunc">xmlTextReaderErrorFunc</a> f, <br>                                      void * arg);
+void   <a href="#xmlTextReaderSetMaxAmplification">xmlTextReaderSetMaxAmplification</a>        (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                             unsigned maxAmpl);
 int    <a href="#xmlTextReaderSetParserProp">xmlTextReaderSetParserProp</a>    (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     int prop, <br>                                  int value);
 int    <a href="#xmlTextReaderSetSchema">xmlTextReaderSetSchema</a>            (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     <a href="libxml2-xmlschemas.html#xmlSchemaPtr">xmlSchemaPtr</a> schema);
 void   <a href="#xmlTextReaderSetStructuredErrorHandler">xmlTextReaderSetStructuredErrorHandler</a>    (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                             <a href="libxml2-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> f, <br>                                               void * arg);
@@ -312,7 +313,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderForDoc"></a>xmlReaderForDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a>     xmlReaderForDoc (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption.</p>
+<p>Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -346,7 +347,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderForFd"></a>xmlReaderForFd ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a>     xmlReaderForFd  (int fd, <br>                                    const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Create an xmltextReader for an XML from a file descriptor. The parsing flags @options are a combination of xmlParserOption. NOTE that the file descriptor will not be closed when the reader is closed or reset.</p>
+<p>Create an xmltextReader for an XML from a file descriptor. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. NOTE that the file descriptor will not be closed when the reader is closed or reset.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -380,7 +381,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderForFile"></a>xmlReaderForFile ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a>     xmlReaderForFile        (const char * filename, <br>                                             const char * encoding, <br>                                             int options)<br>
 </pre>
-<p>parse an XML file from the filesystem or the network. The parsing flags @options are a combination of xmlParserOption.</p>
+<p>parse an XML file from the filesystem or the network. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -410,7 +411,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderForIO"></a>xmlReaderForIO ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a>     xmlReaderForIO  (<a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                      void * ioctx, <br>                                      const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Create an xmltextReader for an XML document from I/O functions and source. The parsing flags @options are a combination of xmlParserOption.</p>
+<p>Create an xmltextReader for an XML document from I/O functions and source. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -452,7 +453,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderForMemory"></a>xmlReaderForMemory ()</h3>
 <pre class="programlisting"><a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a>     xmlReaderForMemory      (const char * buffer, <br>                                               int size, <br>                                          const char * URL, <br>                                          const char * encoding, <br>                                             int options)<br>
 </pre>
-<p>Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption.</p>
+<p>Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -490,7 +491,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewDoc"></a>xmlReaderNewDoc ()</h3>
 <pre class="programlisting">int        xmlReaderNewDoc                 (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Setup an xmltextReader to parse an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. This reuses the existing @reader xmlTextReader.</p>
+<p>Setup an xmltextReader to parse an XML in-memory document. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -528,7 +529,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewFd"></a>xmlReaderNewFd ()</h3>
 <pre class="programlisting">int        xmlReaderNewFd                  (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     int fd, <br>                                    const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Setup an xmltextReader to parse an XML from a file descriptor. NOTE that the file descriptor will not be closed when the reader is closed or reset. The parsing flags @options are a combination of xmlParserOption. This reuses the existing @reader xmlTextReader.</p>
+<p>Setup an xmltextReader to parse an XML from a file descriptor. NOTE that the file descriptor will not be closed when the reader is closed or reset. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -566,7 +567,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewFile"></a>xmlReaderNewFile ()</h3>
 <pre class="programlisting">int        xmlReaderNewFile                (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     const char * filename, <br>                                     const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>parse an XML file from the filesystem or the network. The parsing flags @options are a combination of xmlParserOption. This reuses the existing @reader xmlTextReader.</p>
+<p>parse an XML file from the filesystem or the network. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -600,7 +601,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewIO"></a>xmlReaderNewIO ()</h3>
 <pre class="programlisting">int        xmlReaderNewIO                  (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     <a href="libxml2-xmlIO.html#xmlInputReadCallback">xmlInputReadCallback</a> ioread, <br>                                         <a href="libxml2-xmlIO.html#xmlInputCloseCallback">xmlInputCloseCallback</a> ioclose, <br>                                      void * ioctx, <br>                                      const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Setup an xmltextReader to parse an XML document from I/O functions and source. The parsing flags @options are a combination of xmlParserOption. This reuses the existing @reader xmlTextReader.</p>
+<p>Setup an xmltextReader to parse an XML document from I/O functions and source. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -646,7 +647,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewMemory"></a>xmlReaderNewMemory ()</h3>
 <pre class="programlisting">int        xmlReaderNewMemory              (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     const char * buffer, <br>                                       int size, <br>                                  const char * URL, <br>                                  const char * encoding, <br>                                     int options)<br>
 </pre>
-<p>Setup an xmltextReader to parse an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. This reuses the existing @reader xmlTextReader.</p>
+<p>Setup an xmltextReader to parse an XML in-memory document. The parsing flags @options are a combination of <a href="libxml2-parser.html#xmlParserOption">xmlParserOption</a>. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -688,7 +689,7 @@ The content of this structure is not made public by the API.
 <a name="xmlReaderNewWalker"></a>xmlReaderNewWalker ()</h3>
 <pre class="programlisting">int        xmlReaderNewWalker              (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> doc)<br>
 </pre>
-<p>Setup an xmltextReader to parse a preparsed XML document. This reuses the existing @reader xmlTextReader.</p>
+<p>Setup an xmltextReader to parse a preparsed XML document. This reuses the existing @reader <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1032,7 +1033,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextReaderCurrentDoc"></a>xmlTextReaderCurrentDoc ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a>        xmlTextReaderCurrentDoc (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br>
 </pre>
-<p>Hacking interface allowing to get the <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> corresponding to the current document being accessed by the xmlTextReader. NOTE: as a result of this call, the reader will not destroy the associated XML document and calling xmlFreeDoc() on the result is needed once the reader parsing has finished.</p>
+<p>Hacking interface allowing to get the <a href="libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> corresponding to the current document being accessed by the <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>. NOTE: as a result of this call, the reader will not destroy the associated XML document and calling xmlFreeDoc() on the result is needed once the reader parsing has finished.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1053,7 +1054,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextReaderCurrentNode"></a>xmlTextReaderCurrentNode ()</h3>
 <pre class="programlisting"><a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      xmlTextReaderCurrentNode        (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br>
 </pre>
-<p>Hacking interface allowing to get the <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> corresponding to the current node being accessed by the xmlTextReader. This is dangerous because the underlying node may be destroyed on the next Reads.</p>
+<p>Hacking interface allowing to get the <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> corresponding to the current node being accessed by the <a href="libxml2-xmlreader.html#xmlTextReader">xmlTextReader</a>. This is dangerous because the underlying node may be destroyed on the next Reads.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1126,7 +1127,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the qualified name of the attribute.</td>
+<td>the qualified name of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
@@ -1176,11 +1177,11 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>localName</tt></i>:</span></td>
-<td>the local name of the attribute.</td>
+<td>the local name of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>namespaceURI</tt></i>:</span></td>
-<td>the namespace URI of the attribute.</td>
+<td>the namespace URI of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
@@ -1392,7 +1393,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextReaderIsNamespaceDecl"></a>xmlTextReaderIsNamespaceDecl ()</h3>
 <pre class="programlisting">int        xmlTextReaderIsNamespaceDecl    (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br>
 </pre>
-<p>Determine whether the current node is a namespace declaration rather than a regular attribute.</p>
+<p>Determine whether the current node is a namespace declaration rather than a regular <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1532,7 +1533,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>name</tt></i>:</span></td>
-<td>the qualified name of the attribute.</td>
+<td>the qualified name of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
@@ -1582,11 +1583,11 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>localName</tt></i>:</span></td>
-<td>the local name of the attribute.</td>
+<td>the local name of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>namespaceURI</tt></i>:</span></td>
-<td>the namespace URI of the attribute.</td>
+<td>the namespace URI of the <a href="libxml2-SAX.html#attribute">attribute</a>.</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
@@ -1861,7 +1862,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextReaderQuoteChar"></a>xmlTextReaderQuoteChar ()</h3>
 <pre class="programlisting">int        xmlTextReaderQuoteChar          (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br>
 </pre>
-<p>The quotation mark character used to enclose the value of an attribute.</p>
+<p>The quotation mark character used to enclose the value of an <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2163,6 +2164,27 @@ The content of this structure is not made public by the API.
 <hr>
 <div class="refsect2" lang="en">
 <h3>
+<a name="xmlTextReaderSetMaxAmplification"></a>xmlTextReaderSetMaxAmplification ()</h3>
+<pre class="programlisting">void       xmlTextReaderSetMaxAmplification        (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                             unsigned maxAmpl)<br>
+</pre>
+<p>Set the maximum amplification factor. See <a href="libxml2-parser.html#xmlCtxtSetMaxAmplification">xmlCtxtSetMaxAmplification</a>.</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>reader</tt></i>:</span></td>
+<td>an XML reader</td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>maxAmpl</tt></i>:</span></td>
+<td>maximum amplification factor</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
 <a name="xmlTextReaderSetParserProp"></a>xmlTextReaderSetParserProp ()</h3>
 <pre class="programlisting">int        xmlTextReaderSetParserProp      (<a href="libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br>                                     int prop, <br>                                  int value)<br>
 </pre>
index fe2c2d2..2126275 100644 (file)
@@ -35,6 +35,9 @@ int   <a href="#xmlSaveSetEscape">xmlSaveSetEscape</a>                (<a href="libxml2-xmlsave.
 <a href="libxml2-xmlsave.html#xmlSaveCtxtPtr">xmlSaveCtxtPtr</a>       <a href="#xmlSaveToFilename">xmlSaveToFilename</a>      (const char * filename, <br>                                     const char * encoding, <br>                                     int options);
 <a href="libxml2-xmlsave.html#xmlSaveCtxtPtr">xmlSaveCtxtPtr</a>       <a href="#xmlSaveToIO">xmlSaveToIO</a>          (<a href="libxml2-xmlIO.html#xmlOutputWriteCallback">xmlOutputWriteCallback</a> iowrite, <br>                                    <a href="libxml2-xmlIO.html#xmlOutputCloseCallback">xmlOutputCloseCallback</a> ioclose, <br>                                    void * ioctx, <br>                                      const char * encoding, <br>                                     int options);
 long   <a href="#xmlSaveTree">xmlSaveTree</a>                  (<a href="libxml2-xmlsave.html#xmlSaveCtxtPtr">xmlSaveCtxtPtr</a> ctxt, <br>                                     <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur);
+int    <a href="#xmlThrDefIndentTreeOutput">xmlThrDefIndentTreeOutput</a>      (int v);
+int    <a href="#xmlThrDefSaveNoEmptyTags">xmlThrDefSaveNoEmptyTags</a>        (int v);
+const char *   <a href="#xmlThrDefTreeIndentString">xmlThrDefTreeIndentString</a>      (const char * v);
 </pre>
 </div>
 <div class="refsect1" lang="en"><h2>Description</h2></div>
@@ -332,7 +335,7 @@ The content of this structure is not made public by the API.
 </tr>
 <tr>
 <td><span class="term"><i><tt>cur</tt></i>:</span></td>
-<td></td>
+<td>the top node of the subtree to save</td>
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
@@ -342,6 +345,69 @@ The content of this structure is not made public by the API.
 </table></div>
 </div>
 <hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefIndentTreeOutput"></a>xmlThrDefIndentTreeOutput ()</h3>
+<pre class="programlisting">int        xmlThrDefIndentTreeOutput       (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefSaveNoEmptyTags"></a>xmlThrDefSaveNoEmptyTags ()</h3>
+<pre class="programlisting">int        xmlThrDefSaveNoEmptyTags        (int v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
+<div class="refsect2" lang="en">
+<h3>
+<a name="xmlThrDefTreeIndentString"></a>xmlThrDefTreeIndentString ()</h3>
+<pre class="programlisting">const char *       xmlThrDefTreeIndentString       (const char * v)<br>
+</pre>
+<p></p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody>
+<tr>
+<td><span class="term"><i><tt>v</tt></i>:</span></td>
+<td></td>
+</tr>
+<tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td></td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<hr>
 </div>
 </div>
 </body>
index 5760adf..011da78 100644 (file)
@@ -38,7 +38,7 @@ int   <a href="#xmlSchemaGetCanonValueWhtsp">xmlSchemaGetCanonValueWhtsp</a>  (<a h
 unsigned long  <a href="#xmlSchemaGetFacetValueAsULong">xmlSchemaGetFacetValueAsULong</a>      (<a href="libxml2-schemasInternals.html#xmlSchemaFacetPtr">xmlSchemaFacetPtr</a> facet);
 <a href="libxml2-schemasInternals.html#xmlSchemaTypePtr">xmlSchemaTypePtr</a>  <a href="#xmlSchemaGetPredefinedType">xmlSchemaGetPredefinedType</a>    (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * ns);
 <a href="libxml2-schemasInternals.html#xmlSchemaValType">xmlSchemaValType</a>  <a href="#xmlSchemaGetValType">xmlSchemaGetValType</a>  (<a href="libxml2-schemasInternals.html#xmlSchemaValPtr">xmlSchemaValPtr</a> val);
-void   <a href="#xmlSchemaInitTypes">xmlSchemaInitTypes</a>            (void);
+int    <a href="#xmlSchemaInitTypes">xmlSchemaInitTypes</a>            (void);
 int    <a href="#xmlSchemaIsBuiltInTypeFacet">xmlSchemaIsBuiltInTypeFacet</a>  (<a href="libxml2-schemasInternals.html#xmlSchemaTypePtr">xmlSchemaTypePtr</a> type, <br>                                        int facetType);
 <a href="libxml2-schemasInternals.html#xmlSchemaFacetPtr">xmlSchemaFacetPtr</a>        <a href="#xmlSchemaNewFacet">xmlSchemaNewFacet</a>      (void);
 <a href="libxml2-schemasInternals.html#xmlSchemaValPtr">xmlSchemaValPtr</a>    <a href="#xmlSchemaNewNOTATIONValue">xmlSchemaNewNOTATIONValue</a>      (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                                 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * ns);
@@ -114,7 +114,7 @@ const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *        <a href="#xmlSchema
 <a name="xmlSchemaCleanupTypes"></a>xmlSchemaCleanupTypes ()</h3>
 <pre class="programlisting">void       xmlSchemaCleanupTypes           (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all. Cleanup the default XML Schemas type library</p>
+<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have to call cleanup functions at all. Cleanup the default XML Schemas type library</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -413,9 +413,16 @@ const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *       <a href="#xmlSchema
 <div class="refsect2" lang="en">
 <h3>
 <a name="xmlSchemaInitTypes"></a>xmlSchemaInitTypes ()</h3>
-<pre class="programlisting">void       xmlSchemaInitTypes              (void)<br>
+<pre class="programlisting">int        xmlSchemaInitTypes              (void)<br>
 </pre>
 <p>Initialize the default XML Schemas type library</p>
+<div class="variablelist"><table border="0">
+<col align="left">
+<tbody><tr>
+<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
+<td>0 on success, -1 on error.</td>
+</tr></tbody>
+</table></div>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -513,7 +520,7 @@ const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *        <a href="#xmlSchema
 <a name="xmlSchemaNewStringValue"></a>xmlSchemaNewStringValue ()</h3>
 <pre class="programlisting"><a href="libxml2-schemasInternals.html#xmlSchemaValPtr">xmlSchemaValPtr</a>        xmlSchemaNewStringValue (<a href="libxml2-schemasInternals.html#xmlSchemaValType">xmlSchemaValType</a> type, <br>                                        const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value)<br>
 </pre>
-<p>Allocate a new simple type value. The type can be of XML_SCHEMAS_STRING. WARNING: This one is intended to be expanded for other string based types. We need this for anySimpleType as well. The given value is consumed and freed with the struct.</p>
+<p>Allocate a new simple type value. The type can be of <a href="libxml2-schemasInternals.html#XML_SCHEMAS_STRING">XML_SCHEMAS_STRING</a>. WARNING: This one is intended to be expanded for other string based types. We need this for anySimpleType as well. The given value is consumed and freed with the struct.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 98b0819..b7fc9c4 100644 (file)
 <p>Author(s): Daniel Veillard </p>
 <div class="refsynopsisdiv">
 <h2>Synopsis</h2>
-<pre class="synopsis">#define <a href="#ATTRIBUTE_UNUSED">ATTRIBUTE_UNUSED</a>;
-#define <a href="#DEBUG_MEMORY_LOCATION">DEBUG_MEMORY_LOCATION</a>;
-#define <a href="#LIBXML_ATTR_ALLOC_SIZE">LIBXML_ATTR_ALLOC_SIZE</a>;
-#define <a href="#LIBXML_ATTR_FORMAT">LIBXML_ATTR_FORMAT</a>;
+<pre class="synopsis">#define <a href="#DEBUG_MEMORY_LOCATION">DEBUG_MEMORY_LOCATION</a>;
 #define <a href="#LIBXML_AUTOMATA_ENABLED">LIBXML_AUTOMATA_ENABLED</a>;
 #define <a href="#LIBXML_C14N_ENABLED">LIBXML_C14N_ENABLED</a>;
 #define <a href="#LIBXML_CATALOG_ENABLED">LIBXML_CATALOG_ENABLED</a>;
@@ -68,7 +65,6 @@
 #define <a href="#LIBXML_ZLIB_ENABLED">LIBXML_ZLIB_ENABLED</a>;
 #define <a href="#WITHOUT_TRIO">WITHOUT_TRIO</a>;
 #define <a href="#WITH_TRIO">WITH_TRIO</a>;
-#define <a href="#XML_DEPRECATED">XML_DEPRECATED</a>;
 void   <a href="#xmlCheckVersion">xmlCheckVersion</a>                  (int version);
 </pre>
 </div>
@@ -78,14 +74,6 @@ void <a href="#xmlCheckVersion">xmlCheckVersion</a>                  (int version);
 <div class="refsect2" lang="en">
 <div class="refsect2" lang="en">
 <h3>
-<a name="ATTRIBUTE_UNUSED">Macro </a>ATTRIBUTE_UNUSED</h3>
-<pre class="programlisting">#define <a href="#ATTRIBUTE_UNUSED">ATTRIBUTE_UNUSED</a>;
-</pre>
-<p>Macro used to signal to GCC unused function parameters</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="DEBUG_MEMORY_LOCATION">Macro </a>DEBUG_MEMORY_LOCATION</h3>
 <pre class="programlisting">#define <a href="#DEBUG_MEMORY_LOCATION">DEBUG_MEMORY_LOCATION</a>;
 </pre>
@@ -94,22 +82,6 @@ void <a href="#xmlCheckVersion">xmlCheckVersion</a>                  (int version);
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="LIBXML_ATTR_ALLOC_SIZE">Macro </a>LIBXML_ATTR_ALLOC_SIZE</h3>
-<pre class="programlisting">#define <a href="#LIBXML_ATTR_ALLOC_SIZE">LIBXML_ATTR_ALLOC_SIZE</a>;
-</pre>
-<p>Macro used to indicate to GCC this is an allocator function</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="LIBXML_ATTR_FORMAT">Macro </a>LIBXML_ATTR_FORMAT</h3>
-<pre class="programlisting">#define <a href="#LIBXML_ATTR_FORMAT">LIBXML_ATTR_FORMAT</a>;
-</pre>
-<p>Macro used to indicate to GCC the parameter are printf like</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="LIBXML_AUTOMATA_ENABLED">Macro </a>LIBXML_AUTOMATA_ENABLED</h3>
 <pre class="programlisting">#define <a href="#LIBXML_AUTOMATA_ENABLED">LIBXML_AUTOMATA_ENABLED</a>;
 </pre>
@@ -145,7 +117,7 @@ void        <a href="#xmlCheckVersion">xmlCheckVersion</a>                  (int version);
 <a name="LIBXML_DEBUG_RUNTIME">Macro </a>LIBXML_DEBUG_RUNTIME</h3>
 <pre class="programlisting">#define <a href="#LIBXML_DEBUG_RUNTIME">LIBXML_DEBUG_RUNTIME</a>;
 </pre>
-<p>Whether the runtime debugging is configured in</p>
+<p>Removed</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -446,14 +418,6 @@ void       <a href="#xmlCheckVersion">xmlCheckVersion</a>                  (int version);
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="XML_DEPRECATED">Macro </a>XML_DEPRECATED</h3>
-<pre class="programlisting">#define <a href="#XML_DEPRECATED">XML_DEPRECATED</a>;
-</pre>
-<p>Macro used to indicate that a function, variable, type or struct member is deprecated.</p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlCheckVersion"></a>xmlCheckVersion ()</h3>
 <pre class="programlisting">void       xmlCheckVersion                 (int version)<br>
 </pre>
index 9418ea8..a274d09 100644 (file)
@@ -364,7 +364,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterEndComment"></a>xmlTextWriterEndComment ()</h3>
 <pre class="programlisting">int        xmlTextWriterEndComment         (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer)<br>
 </pre>
-<p>End the current xml comment.</p>
+<p>End the current xml <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -662,7 +662,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterStartAttribute"></a>xmlTextWriterStartAttribute ()</h3>
 <pre class="programlisting">int        xmlTextWriterStartAttribute     (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
 </pre>
-<p>Start an xml attribute.</p>
+<p>Start an xml <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -744,7 +744,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterStartComment"></a>xmlTextWriterStartComment ()</h3>
 <pre class="programlisting">int        xmlTextWriterStartComment       (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer)<br>
 </pre>
-<p>Start an xml comment.</p>
+<p>Start an xml <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1002,7 +1002,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteAttribute"></a>xmlTextWriterWriteAttribute ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteAttribute     (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Write an xml attribute.</p>
+<p>Write an xml <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1034,7 +1034,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteAttributeNS"></a>xmlTextWriterWriteAttributeNS ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteAttributeNS   (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>                                       const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * namespaceURI, <br>                                         const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Write an xml attribute.</p>
+<p>Write an xml <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1168,7 +1168,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteComment"></a>xmlTextWriterWriteComment ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteComment       (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                     const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br>
 </pre>
-<p>Write an xml comment.</p>
+<p>Write an xml <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1551,7 +1551,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteFormatAttribute"></a>xmlTextWriterWriteFormatAttribute ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteFormatAttribute       (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                             const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                                 const char * format, <br>                                               ... ...)<br>
 </pre>
-<p>Write a formatted xml attribute.</p>
+<p>Write a formatted xml <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1659,7 +1659,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteFormatComment"></a>xmlTextWriterWriteFormatComment ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteFormatComment (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                     const char * format, <br>                                       ... ...)<br>
 </pre>
-<p>Write an xml comment.</p>
+<p>Write an xml <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2119,7 +2119,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteVFormatAttribute"></a>xmlTextWriterWriteVFormatAttribute ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteVFormatAttribute      (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                             const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>                                                 const char * format, <br>                                               va_list argptr)<br>
 </pre>
-<p>Write a formatted xml attribute.</p>
+<p>Write a formatted xml <a href="libxml2-SAX.html#attribute">attribute</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2227,7 +2227,7 @@ The content of this structure is not made public by the API.
 <a name="xmlTextWriterWriteVFormatComment"></a>xmlTextWriterWriteVFormatComment ()</h3>
 <pre class="programlisting">int        xmlTextWriterWriteVFormatComment        (<a href="libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> writer, <br>                                             const char * format, <br>                                               va_list argptr)<br>
 </pre>
-<p>Write an xml comment.</p>
+<p>Write an xml <a href="libxml2-SAX.html#comment">comment</a>.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index 5b0e1c6..59f9653 100644 (file)
@@ -117,30 +117,6 @@ typedef <a href="libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> <a
 <hr>
 <div class="refsect2" lang="en">
 <h3>
-<a name="XPATH_LOCATIONSET">Macro </a>XPATH_LOCATIONSET</h3>
-<pre class="programlisting">#define <a href="#XPATH_LOCATIONSET">XPATH_LOCATIONSET</a>;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XPATH_POINT">Macro </a>XPATH_POINT</h3>
-<pre class="programlisting">#define <a href="#XPATH_POINT">XPATH_POINT</a>;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
-<a name="XPATH_RANGE">Macro </a>XPATH_RANGE</h3>
-<pre class="programlisting">#define <a href="#XPATH_RANGE">XPATH_RANGE</a>;
-</pre>
-<p></p>
-</div>
-<hr>
-<div class="refsect2" lang="en">
-<h3>
 <a name="xmlXPathNodeSetGetLength">Macro </a>xmlXPathNodeSetGetLength</h3>
 <pre class="programlisting">#define <a href="#xmlXPathNodeSetGetLength">xmlXPathNodeSetGetLength</a>(ns);
 </pre>
@@ -421,7 +397,7 @@ The content of this structure is not made public by the API.
     <a href="libxml2-xpath.html#xmlXPathCompExprPtr">xmlXPathCompExprPtr</a>   comp    : the precompiled expression
     int        xptr    : it this an XPointer expression
     <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a>      ancestor        : used for walking preceding axis
-    int        valueFrame      : used to limit Pop on the stack
+    int        valueFrame      : always zero for compatibility
 } xmlXPathParserContext;
 </pre>
 <p></p>
@@ -1313,7 +1289,7 @@ The content of this structure is not made public by the API.
 <a name="xmlXPathInit"></a>xmlXPathInit ()</h3>
 <pre class="programlisting">void       xmlXPathInit                    (void)<br>
 </pre>
-<p>DEPRECATED: This function will be made private. Call <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a> to initialize the library. Initialize the XPath environment</p>
+<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
 </div>
 <hr>
 <div class="refsect2" lang="en">
@@ -1321,7 +1297,7 @@ The content of this structure is not made public by the API.
 <a name="xmlXPathIsInf"></a>xmlXPathIsInf ()</h3>
 <pre class="programlisting">int        xmlXPathIsInf                   (double val)<br>
 </pre>
-<p></p>
+<p>Checks whether a double is an infinity.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -1342,7 +1318,7 @@ The content of this structure is not made public by the API.
 <a name="xmlXPathIsNaN"></a>xmlXPathIsNaN ()</h3>
 <pre class="programlisting">int        xmlXPathIsNaN                   (double val)<br>
 </pre>
-<p></p>
+<p>Checks whether a double is a NaN.</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
index e5edfac..3a1f3ba 100644 (file)
@@ -650,7 +650,7 @@ void        <a href="#xmlXPatherror">xmlXPatherror</a>                      (<a href="libxml2-xpath.html#x
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the number of items on the value stack, or -1 in case of error.</td>
+<td>the number of items on the value stack, or -1 in case of error. The object is destroyed in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -1227,7 +1227,7 @@ void      <a href="#xmlXPatherror">xmlXPatherror</a>                      (<a href="libxml2-xpath.html#x
 <a name="xmlXPathLangFunction"></a>xmlXPathLangFunction ()</h3>
 <pre class="programlisting">void       xmlXPathLangFunction            (<a href="libxml2-xpath.html#xmlXPathParserContextPtr">xmlXPathParserContextPtr</a> ctxt, <br>                                   int nargs)<br>
 </pre>
-<p>Implement the lang() XPath function boolean lang(string) The lang function returns true or false depending on whether the language of the context node as specified by xml:lang attributes is the same as or is a sublanguage of the language specified by the argument string. The language of the context node is determined by the value of the xml:lang <a href="libxml2-SAX.html#attribute">attribute</a> on the context node, or, if the context node has no xml:lang attribute, by the value of the xml:lang <a href="libxml2-SAX.html#attribute">attribute</a> on the nearest ancestor of the context node that has an xml:lang attribute. If there is no such attribute, then lang</p>
+<p>Implement the lang() XPath function boolean lang(string) The lang function returns true or false depending on whether the language of the context node as specified by xml:lang attributes is the same as or is a sublanguage of the language specified by the argument string. The language of the context node is determined by the value of the xml:lang <a href="libxml2-SAX.html#attribute">attribute</a> on the context node, or, if the context node has no xml:lang attribute, by the value of the xml:lang <a href="libxml2-SAX.html#attribute">attribute</a> on the nearest ancestor of the context node that has an xml:lang <a href="libxml2-SAX.html#attribute">attribute</a>. If there is no such attribute, then lang</p>
 <div class="variablelist"><table border="0">
 <col align="left">
 <tbody>
@@ -2095,7 +2095,7 @@ void      <a href="#xmlXPatherror">xmlXPatherror</a>                      (<a href="libxml2-xpath.html#x
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>@val1 once extended or NULL in case of error.</td>
+<td>@val1 once extended or NULL in case of error. Frees @val1 in case of error.</td>
 </tr>
 </tbody>
 </table></div>
@@ -3164,7 +3164,7 @@ void      <a href="#xmlXPatherror">xmlXPatherror</a>                      (<a href="libxml2-xpath.html#x
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the newly created object.</td>
+<td>the newly created object. In case of error the node set is destroyed and NULL is returned.</td>
 </tr>
 </tbody>
 </table></div>
@@ -3185,7 +3185,7 @@ void      <a href="#xmlXPatherror">xmlXPatherror</a>                      (<a href="libxml2-xpath.html#x
 </tr>
 <tr>
 <td><span class="term"><i><tt>Returns</tt></i>:</span></td>
-<td>the newly created object.</td>
+<td>the newly created object. Frees @val in case of error.</td>
 </tr>
 </tbody>
 </table></div>
index 7954132..b32ce27 100644 (file)
@@ -51,7 +51,6 @@
     </sub>
   </chapters>
   <functions>
-    <keyword type="macro" name="ATTRIBUTE_UNUSED" link="libxml2-xmlversion.html#ATTRIBUTE_UNUSED"/>
     <keyword type="macro" name="BAD_CAST" link="libxml2-xmlstring.html#BAD_CAST"/>
     <keyword type="macro" name="BASE_BUFFER_SIZE" link="libxml2-tree.html#BASE_BUFFER_SIZE"/>
     <keyword type="macro" name="CAST_TO_BOOLEAN" link="libxml2-xpathInternals.html#CAST_TO_BOOLEAN"/>
@@ -62,7 +61,6 @@
     <keyword type="macro" name="CHECK_ERROR0" link="libxml2-xpathInternals.html#CHECK_ERROR0"/>
     <keyword type="macro" name="CHECK_TYPE" link="libxml2-xpathInternals.html#CHECK_TYPE"/>
     <keyword type="macro" name="CHECK_TYPE0" link="libxml2-xpathInternals.html#CHECK_TYPE0"/>
-    <keyword type="macro" name="DEBUG_MEMORY" link="libxml2-xmlmemory.html#DEBUG_MEMORY"/>
     <keyword type="macro" name="DEBUG_MEMORY_LOCATION" link="libxml2-xmlversion.html#DEBUG_MEMORY_LOCATION"/>
     <keyword type="macro" name="HTML_COMMENT_NODE" link="libxml2-HTMLtree.html#HTML_COMMENT_NODE"/>
     <keyword type="macro" name="HTML_ENTITY_REF_NODE" link="libxml2-HTMLtree.html#HTML_ENTITY_REF_NODE"/>
     <keyword type="macro" name="IS_PUBIDCHAR" link="libxml2-parserInternals.html#IS_PUBIDCHAR"/>
     <keyword type="macro" name="IS_PUBIDCHAR_CH" link="libxml2-parserInternals.html#IS_PUBIDCHAR_CH"/>
     <keyword type="macro" name="LIBXML2_NEW_BUFFER" link="libxml2-tree.html#LIBXML2_NEW_BUFFER"/>
-    <keyword type="macro" name="LIBXML_ATTR_ALLOC_SIZE" link="libxml2-xmlversion.html#LIBXML_ATTR_ALLOC_SIZE"/>
-    <keyword type="macro" name="LIBXML_ATTR_FORMAT" link="libxml2-xmlversion.html#LIBXML_ATTR_FORMAT"/>
     <keyword type="macro" name="LIBXML_AUTOMATA_ENABLED" link="libxml2-xmlversion.html#LIBXML_AUTOMATA_ENABLED"/>
     <keyword type="macro" name="LIBXML_C14N_ENABLED" link="libxml2-xmlversion.html#LIBXML_C14N_ENABLED"/>
     <keyword type="macro" name="LIBXML_CATALOG_ENABLED" link="libxml2-xmlversion.html#LIBXML_CATALOG_ENABLED"/>
     <keyword type="macro" name="LIBXML_DEBUG_ENABLED" link="libxml2-xmlversion.html#LIBXML_DEBUG_ENABLED"/>
     <keyword type="macro" name="LIBXML_DEBUG_RUNTIME" link="libxml2-xmlversion.html#LIBXML_DEBUG_RUNTIME"/>
-    <keyword type="macro" name="LIBXML_DLL_IMPORT" link="libxml2-xmlexports.html#LIBXML_DLL_IMPORT"/>
     <keyword type="macro" name="LIBXML_DOTTED_VERSION" link="libxml2-xmlversion.html#LIBXML_DOTTED_VERSION"/>
     <keyword type="macro" name="LIBXML_EXPR_ENABLED" link="libxml2-xmlversion.html#LIBXML_EXPR_ENABLED"/>
     <keyword type="macro" name="LIBXML_FTP_ENABLED" link="libxml2-xmlversion.html#LIBXML_FTP_ENABLED"/>
     <keyword type="macro" name="LIBXML_XPTR_ENABLED" link="libxml2-xmlversion.html#LIBXML_XPTR_ENABLED"/>
     <keyword type="macro" name="LIBXML_XPTR_LOCS_ENABLED" link="libxml2-xmlversion.html#LIBXML_XPTR_LOCS_ENABLED"/>
     <keyword type="macro" name="LIBXML_ZLIB_ENABLED" link="libxml2-xmlversion.html#LIBXML_ZLIB_ENABLED"/>
-    <keyword type="macro" name="MOVETO_ENDTAG" link="libxml2-parserInternals.html#MOVETO_ENDTAG"/>
-    <keyword type="macro" name="MOVETO_STARTTAG" link="libxml2-parserInternals.html#MOVETO_STARTTAG"/>
-    <keyword type="macro" name="SKIP_EOL" link="libxml2-parserInternals.html#SKIP_EOL"/>
     <keyword type="macro" name="SOCKET" link="libxml2-nanoftp.html#SOCKET"/>
     <keyword type="macro" name="WITHOUT_TRIO" link="libxml2-xmlversion.html#WITHOUT_TRIO"/>
     <keyword type="macro" name="WITH_TRIO" link="libxml2-xmlversion.html#WITH_TRIO"/>
     <keyword type="macro" name="XINCLUDE_PARSE_TEXT" link="libxml2-xinclude.html#XINCLUDE_PARSE_TEXT"/>
     <keyword type="macro" name="XINCLUDE_PARSE_XML" link="libxml2-xinclude.html#XINCLUDE_PARSE_XML"/>
     <keyword type="macro" name="XINCLUDE_PARSE_XPOINTER" link="libxml2-xinclude.html#XINCLUDE_PARSE_XPOINTER"/>
-    <keyword type="macro" name="XMLCALL" link="libxml2-xmlexports.html#XMLCALL"/>
-    <keyword type="macro" name="XMLCDECL" link="libxml2-xmlexports.html#XMLCDECL"/>
     <keyword type="macro" name="XMLPUBFUN" link="libxml2-xmlexports.html#XMLPUBFUN"/>
-    <keyword type="macro" name="XMLPUBLIC" link="libxml2-xmlexports.html#XMLPUBLIC"/>
     <keyword type="macro" name="XMLPUBVAR" link="libxml2-xmlexports.html#XMLPUBVAR"/>
     <keyword type="macro" name="XML_CAST_FPTR" link="libxml2-hash.html#XML_CAST_FPTR"/>
     <keyword type="macro" name="XML_CATALOGS_NAMESPACE" link="libxml2-catalog.html#XML_CATALOGS_NAMESPACE"/>
     <keyword type="macro" name="XML_CATALOG_PI" link="libxml2-catalog.html#XML_CATALOG_PI"/>
     <keyword type="macro" name="XML_COMPLETE_ATTRS" link="libxml2-parser.html#XML_COMPLETE_ATTRS"/>
     <keyword type="macro" name="XML_DEFAULT_VERSION" link="libxml2-parser.html#XML_DEFAULT_VERSION"/>
-    <keyword type="macro" name="XML_DEPRECATED" link="libxml2-xmlversion.html#XML_DEPRECATED"/>
     <keyword type="macro" name="XML_DETECT_IDS" link="libxml2-parser.html#XML_DETECT_IDS"/>
-    <keyword type="macro" name="XML_DOCB_DOCUMENT_NODE" link="libxml2-tree.html#XML_DOCB_DOCUMENT_NODE"/>
     <keyword type="macro" name="XML_GET_CONTENT" link="libxml2-tree.html#XML_GET_CONTENT"/>
     <keyword type="macro" name="XML_GET_LINE" link="libxml2-tree.html#XML_GET_LINE"/>
     <keyword type="macro" name="XML_LOCAL_NAMESPACE" link="libxml2-tree.html#XML_LOCAL_NAMESPACE"/>
     <keyword type="macro" name="XML_MAX_DICTIONARY_LIMIT" link="libxml2-parserInternals.html#XML_MAX_DICTIONARY_LIMIT"/>
+    <keyword type="macro" name="XML_MAX_HUGE_LENGTH" link="libxml2-parserInternals.html#XML_MAX_HUGE_LENGTH"/>
     <keyword type="macro" name="XML_MAX_LOOKUP_LIMIT" link="libxml2-parserInternals.html#XML_MAX_LOOKUP_LIMIT"/>
     <keyword type="macro" name="XML_MAX_NAMELEN" link="libxml2-parserInternals.html#XML_MAX_NAMELEN"/>
     <keyword type="macro" name="XML_MAX_NAME_LENGTH" link="libxml2-parserInternals.html#XML_MAX_NAME_LENGTH"/>
     <keyword type="macro" name="XML_SUBSTITUTE_NONE" link="libxml2-parserInternals.html#XML_SUBSTITUTE_NONE"/>
     <keyword type="macro" name="XML_SUBSTITUTE_PEREF" link="libxml2-parserInternals.html#XML_SUBSTITUTE_PEREF"/>
     <keyword type="macro" name="XML_SUBSTITUTE_REF" link="libxml2-parserInternals.html#XML_SUBSTITUTE_REF"/>
-    <keyword type="macro" name="XML_VCTXT_DTD_VALIDATED" link="libxml2-valid.html#XML_VCTXT_DTD_VALIDATED"/>
-    <keyword type="macro" name="XML_VCTXT_USE_PCTXT" link="libxml2-valid.html#XML_VCTXT_USE_PCTXT"/>
     <keyword type="macro" name="XML_XML_ID" link="libxml2-tree.html#XML_XML_ID"/>
     <keyword type="macro" name="XML_XML_NAMESPACE" link="libxml2-tree.html#XML_XML_NAMESPACE"/>
     <keyword type="macro" name="XML_XPATH_CHECKNS" link="libxml2-xpath.html#XML_XPATH_CHECKNS"/>
     <keyword type="macro" name="XML_XPATH_NOVAR" link="libxml2-xpath.html#XML_XPATH_NOVAR"/>
-    <keyword type="macro" name="XPATH_LOCATIONSET" link="libxml2-xpath.html#XPATH_LOCATIONSET"/>
-    <keyword type="macro" name="XPATH_POINT" link="libxml2-xpath.html#XPATH_POINT"/>
-    <keyword type="macro" name="XPATH_RANGE" link="libxml2-xpath.html#XPATH_RANGE"/>
     <keyword type="macro" name="XP_ERROR" link="libxml2-xpathInternals.html#XP_ERROR"/>
     <keyword type="macro" name="XP_ERROR0" link="libxml2-xpathInternals.html#XP_ERROR0"/>
     <keyword type="macro" name="htmlDefaultSubelement" link="libxml2-HTMLparser.html#htmlDefaultSubelement"/>
     <keyword type="enum" name="XML_ELEMENT_TYPE_EMPTY" link="libxml2-tree.html#XML_ELEMENT_TYPE_EMPTY"/>
     <keyword type="enum" name="XML_ELEMENT_TYPE_MIXED" link="libxml2-tree.html#XML_ELEMENT_TYPE_MIXED"/>
     <keyword type="enum" name="XML_ELEMENT_TYPE_UNDEFINED" link="libxml2-tree.html#XML_ELEMENT_TYPE_UNDEFINED"/>
+    <keyword type="enum" name="XML_ENC_ERR_INPUT" link="libxml2-encoding.html#XML_ENC_ERR_INPUT"/>
+    <keyword type="enum" name="XML_ENC_ERR_INTERNAL" link="libxml2-encoding.html#XML_ENC_ERR_INTERNAL"/>
+    <keyword type="enum" name="XML_ENC_ERR_MEMORY" link="libxml2-encoding.html#XML_ENC_ERR_MEMORY"/>
+    <keyword type="enum" name="XML_ENC_ERR_PARTIAL" link="libxml2-encoding.html#XML_ENC_ERR_PARTIAL"/>
+    <keyword type="enum" name="XML_ENC_ERR_SPACE" link="libxml2-encoding.html#XML_ENC_ERR_SPACE"/>
+    <keyword type="enum" name="XML_ENC_ERR_SUCCESS" link="libxml2-encoding.html#XML_ENC_ERR_SUCCESS"/>
     <keyword type="enum" name="XML_ENTITY_DECL" link="libxml2-tree.html#XML_ENTITY_DECL"/>
     <keyword type="enum" name="XML_ENTITY_NODE" link="libxml2-tree.html#XML_ENTITY_NODE"/>
     <keyword type="enum" name="XML_ENTITY_REF_NODE" link="libxml2-tree.html#XML_ENTITY_REF_NODE"/>
     <keyword type="enum" name="XML_PARSER_SUBST_ENTITIES" link="libxml2-xmlreader.html#XML_PARSER_SUBST_ENTITIES"/>
     <keyword type="enum" name="XML_PARSER_SYSTEM_LITERAL" link="libxml2-parser.html#XML_PARSER_SYSTEM_LITERAL"/>
     <keyword type="enum" name="XML_PARSER_VALIDATE" link="libxml2-xmlreader.html#XML_PARSER_VALIDATE"/>
+    <keyword type="enum" name="XML_PARSER_XML_DECL" link="libxml2-parser.html#XML_PARSER_XML_DECL"/>
     <keyword type="enum" name="XML_PARSE_BIG_LINES" link="libxml2-parser.html#XML_PARSE_BIG_LINES"/>
     <keyword type="enum" name="XML_PARSE_COMPACT" link="libxml2-parser.html#XML_PARSE_COMPACT"/>
     <keyword type="enum" name="XML_PARSE_DOM" link="libxml2-parser.html#XML_PARSE_DOM"/>
     <keyword type="enum" name="XML_TREE_NOT_UTF8" link="libxml2-xmlerror.html#XML_TREE_NOT_UTF8"/>
     <keyword type="enum" name="XML_TREE_UNTERMINATED_ENTITY" link="libxml2-xmlerror.html#XML_TREE_UNTERMINATED_ENTITY"/>
     <keyword type="enum" name="XML_WAR_CATALOG_PI" link="libxml2-xmlerror.html#XML_WAR_CATALOG_PI"/>
+    <keyword type="enum" name="XML_WAR_ENCODING_MISMATCH" link="libxml2-xmlerror.html#XML_WAR_ENCODING_MISMATCH"/>
     <keyword type="enum" name="XML_WAR_ENTITY_REDEFINED" link="libxml2-xmlerror.html#XML_WAR_ENTITY_REDEFINED"/>
     <keyword type="enum" name="XML_WAR_LANG_VALUE" link="libxml2-xmlerror.html#XML_WAR_LANG_VALUE"/>
     <keyword type="enum" name="XML_WAR_NS_COLUMN" link="libxml2-xmlerror.html#XML_WAR_NS_COLUMN"/>
     <keyword type="typedef" name="xmlChRangeGroupPtr" link="libxml2-chvalid.html#xmlChRangeGroupPtr"/>
     <keyword type="typedef" name="xmlChSRangePtr" link="libxml2-chvalid.html#xmlChSRangePtr"/>
     <keyword type="typedef" name="xmlChar" link="libxml2-xmlstring.html#xmlChar"/>
+    <keyword type="typedef" name="xmlCharEncError" link="libxml2-encoding.html#xmlCharEncError"/>
     <keyword type="typedef" name="xmlCharEncoding" link="libxml2-encoding.html#xmlCharEncoding"/>
     <keyword type="typedef" name="xmlCharEncodingHandlerPtr" link="libxml2-encoding.html#xmlCharEncodingHandlerPtr"/>
     <keyword type="typedef" name="xmlDOMWrapCtxtPtr" link="libxml2-tree.html#xmlDOMWrapCtxtPtr"/>
     <keyword type="struct" name="htmlEntityDesc" link="libxml2-HTMLparser.html#htmlEntityDesc"/>
     <keyword type="struct" name="xlinkHandler" link="libxml2-xlink.html#xlinkHandler"/>
     <keyword type="struct" name="xmlAttr" link="libxml2-tree.html#xmlAttr"/>
+    <keyword type="struct" name="xmlAttrHashBucket" link="libxml2-parser.html#xmlAttrHashBucket"/>
     <keyword type="struct" name="xmlAttribute" link="libxml2-tree.html#xmlAttribute"/>
     <keyword type="struct" name="xmlAttributeTable" link="libxml2-valid.html#xmlAttributeTable"/>
     <keyword type="struct" name="xmlAutomata" link="libxml2-xmlautomata.html#xmlAutomata"/>
     <keyword type="struct" name="xmlParserInputBuffer" link="libxml2-tree.html#xmlParserInputBuffer"/>
     <keyword type="struct" name="xmlParserNodeInfo" link="libxml2-parser.html#xmlParserNodeInfo"/>
     <keyword type="struct" name="xmlParserNodeInfoSeq" link="libxml2-parser.html#xmlParserNodeInfoSeq"/>
+    <keyword type="struct" name="xmlParserNsData" link="libxml2-parser.html#xmlParserNsData"/>
     <keyword type="struct" name="xmlPattern" link="libxml2-pattern.html#xmlPattern"/>
     <keyword type="struct" name="xmlRMutex" link="libxml2-threads.html#xmlRMutex"/>
     <keyword type="struct" name="xmlRef" link="libxml2-tree.html#xmlRef"/>
     <keyword type="function" name="xmlCharEncodingInputFunc" link="libxml2-encoding.html#xmlCharEncodingInputFunc"/>
     <keyword type="function" name="xmlCharEncodingOutputFunc" link="libxml2-encoding.html#xmlCharEncodingOutputFunc"/>
     <keyword type="function" name="xmlDOMWrapAcquireNsFunction" link="libxml2-tree.html#xmlDOMWrapAcquireNsFunction"/>
-    <keyword type="function" name="xmlDeregisterNodeFunc" link="libxml2-globals.html#xmlDeregisterNodeFunc"/>
+    <keyword type="function" name="xmlDeregisterNodeFunc" link="libxml2-tree.html#xmlDeregisterNodeFunc"/>
     <keyword type="function" name="xmlEntityReferenceFunc" link="libxml2-parserInternals.html#xmlEntityReferenceFunc"/>
     <keyword type="function" name="xmlExternalEntityLoader" link="libxml2-parser.html#xmlExternalEntityLoader"/>
     <keyword type="function" name="xmlFreeFunc" link="libxml2-xmlmemory.html#xmlFreeFunc"/>
     <keyword type="function" name="xmlListDeallocator" link="libxml2-list.html#xmlListDeallocator"/>
     <keyword type="function" name="xmlListWalker" link="libxml2-list.html#xmlListWalker"/>
     <keyword type="function" name="xmlMallocFunc" link="libxml2-xmlmemory.html#xmlMallocFunc"/>
-    <keyword type="function" name="xmlOutputBufferCreateFilenameFunc" link="libxml2-globals.html#xmlOutputBufferCreateFilenameFunc"/>
+    <keyword type="function" name="xmlOutputBufferCreateFilenameFunc" link="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameFunc"/>
     <keyword type="function" name="xmlOutputCloseCallback" link="libxml2-xmlIO.html#xmlOutputCloseCallback"/>
     <keyword type="function" name="xmlOutputMatchCallback" link="libxml2-xmlIO.html#xmlOutputMatchCallback"/>
     <keyword type="function" name="xmlOutputOpenCallback" link="libxml2-xmlIO.html#xmlOutputOpenCallback"/>
     <keyword type="function" name="xmlOutputWriteCallback" link="libxml2-xmlIO.html#xmlOutputWriteCallback"/>
-    <keyword type="function" name="xmlParserInputBufferCreateFilenameFunc" link="libxml2-globals.html#xmlParserInputBufferCreateFilenameFunc"/>
+    <keyword type="function" name="xmlParserInputBufferCreateFilenameFunc" link="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameFunc"/>
     <keyword type="function" name="xmlParserInputDeallocate" link="libxml2-parser.html#xmlParserInputDeallocate"/>
     <keyword type="function" name="xmlReallocFunc" link="libxml2-xmlmemory.html#xmlReallocFunc"/>
     <keyword type="function" name="xmlRegExecCallbacks" link="libxml2-xmlregexp.html#xmlRegExecCallbacks"/>
-    <keyword type="function" name="xmlRegisterNodeFunc" link="libxml2-globals.html#xmlRegisterNodeFunc"/>
+    <keyword type="function" name="xmlRegisterNodeFunc" link="libxml2-tree.html#xmlRegisterNodeFunc"/>
     <keyword type="function" name="xmlRelaxNGValidityErrorFunc" link="libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc"/>
     <keyword type="function" name="xmlRelaxNGValidityWarningFunc" link="libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc"/>
     <keyword type="function" name="xmlSchemaValidityErrorFunc" link="libxml2-xmlschemas.html#xmlSchemaValidityErrorFunc"/>
     <keyword type="function" name="xmlXPathVariableLookupFunc" link="libxml2-xpath.html#xmlXPathVariableLookupFunc"/>
     <keyword type="macro" name="emptyExp" link="libxml2-xmlregexp.html#emptyExp"/>
     <keyword type="macro" name="forbiddenExp" link="libxml2-xmlregexp.html#forbiddenExp"/>
-    <keyword type="macro" name="htmlDefaultSAXHandler" link="libxml2-globals.html#htmlDefaultSAXHandler"/>
-    <keyword type="macro" name="oldXMLWDcompatibility" link="libxml2-globals.html#oldXMLWDcompatibility"/>
-    <keyword type="macro" name="xmlBufferAllocScheme" link="libxml2-globals.html#xmlBufferAllocScheme"/>
-    <keyword type="macro" name="xmlDefaultBufferSize" link="libxml2-globals.html#xmlDefaultBufferSize"/>
-    <keyword type="macro" name="xmlDefaultSAXHandler" link="libxml2-globals.html#xmlDefaultSAXHandler"/>
-    <keyword type="macro" name="xmlDefaultSAXLocator" link="libxml2-globals.html#xmlDefaultSAXLocator"/>
-    <keyword type="macro" name="xmlDeregisterNodeDefaultValue" link="libxml2-globals.html#xmlDeregisterNodeDefaultValue"/>
-    <keyword type="macro" name="xmlDoValidityCheckingDefaultValue" link="libxml2-globals.html#xmlDoValidityCheckingDefaultValue"/>
-    <keyword type="macro" name="xmlFree" link="libxml2-globals.html#xmlFree"/>
-    <keyword type="macro" name="xmlGenericError" link="libxml2-globals.html#xmlGenericError"/>
-    <keyword type="macro" name="xmlGenericErrorContext" link="libxml2-globals.html#xmlGenericErrorContext"/>
-    <keyword type="macro" name="xmlGetWarningsDefaultValue" link="libxml2-globals.html#xmlGetWarningsDefaultValue"/>
-    <keyword type="macro" name="xmlIndentTreeOutput" link="libxml2-globals.html#xmlIndentTreeOutput"/>
+    <keyword type="macro" name="xmlFree" link="libxml2-xmlmemory.html#xmlFree"/>
     <keyword type="macro" name="xmlIsBaseCharGroup" link="libxml2-chvalid.html#xmlIsBaseCharGroup"/>
     <keyword type="macro" name="xmlIsCharGroup" link="libxml2-chvalid.html#xmlIsCharGroup"/>
     <keyword type="macro" name="xmlIsCombiningGroup" link="libxml2-chvalid.html#xmlIsCombiningGroup"/>
     <keyword type="macro" name="xmlIsExtenderGroup" link="libxml2-chvalid.html#xmlIsExtenderGroup"/>
     <keyword type="macro" name="xmlIsIdeographicGroup" link="libxml2-chvalid.html#xmlIsIdeographicGroup"/>
     <keyword type="macro" name="xmlIsPubidChar_tab" link="libxml2-chvalid.html#xmlIsPubidChar_tab"/>
-    <keyword type="macro" name="xmlKeepBlanksDefaultValue" link="libxml2-globals.html#xmlKeepBlanksDefaultValue"/>
-    <keyword type="macro" name="xmlLastError" link="libxml2-globals.html#xmlLastError"/>
-    <keyword type="macro" name="xmlLineNumbersDefaultValue" link="libxml2-globals.html#xmlLineNumbersDefaultValue"/>
-    <keyword type="macro" name="xmlLoadExtDtdDefaultValue" link="libxml2-globals.html#xmlLoadExtDtdDefaultValue"/>
-    <keyword type="macro" name="xmlMalloc" link="libxml2-globals.html#xmlMalloc"/>
-    <keyword type="macro" name="xmlMallocAtomic" link="libxml2-globals.html#xmlMallocAtomic"/>
-    <keyword type="macro" name="xmlMemStrdup" link="libxml2-globals.html#xmlMemStrdup"/>
-    <keyword type="macro" name="xmlOutputBufferCreateFilenameValue" link="libxml2-globals.html#xmlOutputBufferCreateFilenameValue"/>
-    <keyword type="macro" name="xmlParserDebugEntities" link="libxml2-globals.html#xmlParserDebugEntities"/>
-    <keyword type="macro" name="xmlParserInputBufferCreateFilenameValue" link="libxml2-globals.html#xmlParserInputBufferCreateFilenameValue"/>
+    <keyword type="macro" name="xmlMalloc" link="libxml2-xmlmemory.html#xmlMalloc"/>
+    <keyword type="macro" name="xmlMallocAtomic" link="libxml2-xmlmemory.html#xmlMallocAtomic"/>
+    <keyword type="macro" name="xmlMemStrdup" link="libxml2-xmlmemory.html#xmlMemStrdup"/>
     <keyword type="macro" name="xmlParserMaxDepth" link="libxml2-parserInternals.html#xmlParserMaxDepth"/>
-    <keyword type="macro" name="xmlParserVersion" link="libxml2-globals.html#xmlParserVersion"/>
-    <keyword type="macro" name="xmlPedanticParserDefaultValue" link="libxml2-globals.html#xmlPedanticParserDefaultValue"/>
-    <keyword type="macro" name="xmlRealloc" link="libxml2-globals.html#xmlRealloc"/>
-    <keyword type="macro" name="xmlRegisterNodeDefaultValue" link="libxml2-globals.html#xmlRegisterNodeDefaultValue"/>
-    <keyword type="macro" name="xmlSaveNoEmptyTags" link="libxml2-globals.html#xmlSaveNoEmptyTags"/>
+    <keyword type="macro" name="xmlParserVersion" link="libxml2-parser.html#xmlParserVersion"/>
+    <keyword type="macro" name="xmlRealloc" link="libxml2-xmlmemory.html#xmlRealloc"/>
     <keyword type="macro" name="xmlStringComment" link="libxml2-parserInternals.html#xmlStringComment"/>
     <keyword type="macro" name="xmlStringText" link="libxml2-parserInternals.html#xmlStringText"/>
     <keyword type="macro" name="xmlStringTextNoenc" link="libxml2-parserInternals.html#xmlStringTextNoenc"/>
-    <keyword type="macro" name="xmlStructuredError" link="libxml2-globals.html#xmlStructuredError"/>
-    <keyword type="macro" name="xmlStructuredErrorContext" link="libxml2-globals.html#xmlStructuredErrorContext"/>
-    <keyword type="macro" name="xmlSubstituteEntitiesDefaultValue" link="libxml2-globals.html#xmlSubstituteEntitiesDefaultValue"/>
-    <keyword type="macro" name="xmlTreeIndentString" link="libxml2-globals.html#xmlTreeIndentString"/>
     <keyword type="macro" name="xmlXPathNAN" link="libxml2-xpath.html#xmlXPathNAN"/>
     <keyword type="macro" name="xmlXPathNINF" link="libxml2-xpath.html#xmlXPathNINF"/>
     <keyword type="macro" name="xmlXPathPINF" link="libxml2-xpath.html#xmlXPathPINF"/>
     <keyword type="function" name="hasInternalSubset ()" link="libxml2-SAX.html#hasInternalSubset"/>
     <keyword type="function" name="htmlAttrAllowed ()" link="libxml2-HTMLparser.html#htmlAttrAllowed"/>
     <keyword type="function" name="htmlAutoCloseTag ()" link="libxml2-HTMLparser.html#htmlAutoCloseTag"/>
-    <keyword type="function" name="htmlCreateFileParserCtxt ()" link="libxml2-parserInternals.html#htmlCreateFileParserCtxt"/>
+    <keyword type="function" name="htmlCreateFileParserCtxt ()" link="libxml2-HTMLparser.html#htmlCreateFileParserCtxt"/>
     <keyword type="function" name="htmlCreateMemoryParserCtxt ()" link="libxml2-HTMLparser.html#htmlCreateMemoryParserCtxt"/>
     <keyword type="function" name="htmlCreatePushParserCtxt ()" link="libxml2-HTMLparser.html#htmlCreatePushParserCtxt"/>
     <keyword type="function" name="htmlCtxtReadDoc ()" link="libxml2-HTMLparser.html#htmlCtxtReadDoc"/>
     <keyword type="function" name="htmlFreeParserCtxt ()" link="libxml2-HTMLparser.html#htmlFreeParserCtxt"/>
     <keyword type="function" name="htmlGetMetaEncoding ()" link="libxml2-HTMLtree.html#htmlGetMetaEncoding"/>
     <keyword type="function" name="htmlHandleOmittedElem ()" link="libxml2-HTMLparser.html#htmlHandleOmittedElem"/>
-    <keyword type="function" name="htmlInitAutoClose ()" link="libxml2-parserInternals.html#htmlInitAutoClose"/>
+    <keyword type="function" name="htmlInitAutoClose ()" link="libxml2-HTMLparser.html#htmlInitAutoClose"/>
     <keyword type="function" name="htmlIsAutoClosed ()" link="libxml2-HTMLparser.html#htmlIsAutoClosed"/>
     <keyword type="function" name="htmlIsBooleanAttr ()" link="libxml2-HTMLtree.html#htmlIsBooleanAttr"/>
     <keyword type="function" name="htmlIsScriptAttribute ()" link="libxml2-HTMLparser.html#htmlIsScriptAttribute"/>
     <keyword type="function" name="htmlNewDoc ()" link="libxml2-HTMLtree.html#htmlNewDoc"/>
     <keyword type="function" name="htmlNewDocNoDtD ()" link="libxml2-HTMLtree.html#htmlNewDocNoDtD"/>
     <keyword type="function" name="htmlNewParserCtxt ()" link="libxml2-HTMLparser.html#htmlNewParserCtxt"/>
+    <keyword type="function" name="htmlNewSAXParserCtxt ()" link="libxml2-HTMLparser.html#htmlNewSAXParserCtxt"/>
     <keyword type="function" name="htmlNodeDump ()" link="libxml2-HTMLtree.html#htmlNodeDump"/>
     <keyword type="function" name="htmlNodeDumpFile ()" link="libxml2-HTMLtree.html#htmlNodeDumpFile"/>
     <keyword type="function" name="htmlNodeDumpFileFormat ()" link="libxml2-HTMLtree.html#htmlNodeDumpFileFormat"/>
     <keyword type="function" name="xmlCheckFilename ()" link="libxml2-xmlIO.html#xmlCheckFilename"/>
     <keyword type="function" name="xmlCheckHTTPInput ()" link="libxml2-xmlIO.html#xmlCheckHTTPInput"/>
     <keyword type="function" name="xmlCheckLanguageID ()" link="libxml2-parserInternals.html#xmlCheckLanguageID"/>
+    <keyword type="function" name="xmlCheckThreadLocalStorage ()" link="libxml2-threads.html#xmlCheckThreadLocalStorage"/>
     <keyword type="function" name="xmlCheckUTF8 ()" link="libxml2-xmlstring.html#xmlCheckUTF8"/>
     <keyword type="function" name="xmlCheckVersion ()" link="libxml2-xmlversion.html#xmlCheckVersion"/>
     <keyword type="function" name="xmlChildElementCount ()" link="libxml2-tree.html#xmlChildElementCount"/>
     <keyword type="function" name="xmlCtxtReset ()" link="libxml2-parser.html#xmlCtxtReset"/>
     <keyword type="function" name="xmlCtxtResetLastError ()" link="libxml2-xmlerror.html#xmlCtxtResetLastError"/>
     <keyword type="function" name="xmlCtxtResetPush ()" link="libxml2-parser.html#xmlCtxtResetPush"/>
+    <keyword type="function" name="xmlCtxtSetMaxAmplification ()" link="libxml2-parser.html#xmlCtxtSetMaxAmplification"/>
     <keyword type="function" name="xmlCtxtUseOptions ()" link="libxml2-parser.html#xmlCtxtUseOptions"/>
     <keyword type="function" name="xmlCurrentChar ()" link="libxml2-parserInternals.html#xmlCurrentChar"/>
     <keyword type="function" name="xmlDOMWrapAdoptNode ()" link="libxml2-tree.html#xmlDOMWrapAdoptNode"/>
     <keyword type="function" name="xmlDecodeEntities ()" link="libxml2-parserInternals.html#xmlDecodeEntities"/>
     <keyword type="function" name="xmlDefaultSAXHandlerInit ()" link="libxml2-SAX2.html#xmlDefaultSAXHandlerInit"/>
     <keyword type="function" name="xmlDelEncodingAlias ()" link="libxml2-encoding.html#xmlDelEncodingAlias"/>
-    <keyword type="function" name="xmlDeregisterNodeDefault ()" link="libxml2-globals.html#xmlDeregisterNodeDefault"/>
+    <keyword type="function" name="xmlDeregisterNodeDefault ()" link="libxml2-tree.html#xmlDeregisterNodeDefault"/>
     <keyword type="function" name="xmlDetectCharEncoding ()" link="libxml2-encoding.html#xmlDetectCharEncoding"/>
     <keyword type="function" name="xmlDictCleanup ()" link="libxml2-dict.html#xmlDictCleanup"/>
     <keyword type="function" name="xmlDictCreate ()" link="libxml2-dict.html#xmlDictCreate"/>
     <keyword type="function" name="xmlDictReference ()" link="libxml2-dict.html#xmlDictReference"/>
     <keyword type="function" name="xmlDictSetLimit ()" link="libxml2-dict.html#xmlDictSetLimit"/>
     <keyword type="function" name="xmlDictSize ()" link="libxml2-dict.html#xmlDictSize"/>
-    <keyword type="function" name="xmlDllMain ()" link="libxml2-threads.html#xmlDllMain"/>
     <keyword type="function" name="xmlDocCopyNode ()" link="libxml2-tree.html#xmlDocCopyNode"/>
     <keyword type="function" name="xmlDocCopyNodeList ()" link="libxml2-tree.html#xmlDocCopyNodeList"/>
     <keyword type="function" name="xmlDocDump ()" link="libxml2-tree.html#xmlDocDump"/>
     <keyword type="function" name="xmlEncodeEntities ()" link="libxml2-entities.html#xmlEncodeEntities"/>
     <keyword type="function" name="xmlEncodeEntitiesReentrant ()" link="libxml2-entities.html#xmlEncodeEntitiesReentrant"/>
     <keyword type="function" name="xmlEncodeSpecialChars ()" link="libxml2-entities.html#xmlEncodeSpecialChars"/>
-    <keyword type="function" name="xmlErrMemory ()" link="libxml2-parserInternals.html#xmlErrMemory"/>
     <keyword type="function" name="xmlExpCtxtNbCons ()" link="libxml2-xmlregexp.html#xmlExpCtxtNbCons"/>
     <keyword type="function" name="xmlExpCtxtNbNodes ()" link="libxml2-xmlregexp.html#xmlExpCtxtNbNodes"/>
     <keyword type="function" name="xmlExpDump ()" link="libxml2-xmlregexp.html#xmlExpDump"/>
     <keyword type="function" name="xmlFreeElementContent ()" link="libxml2-valid.html#xmlFreeElementContent"/>
     <keyword type="function" name="xmlFreeElementTable ()" link="libxml2-valid.html#xmlFreeElementTable"/>
     <keyword type="function" name="xmlFreeEntitiesTable ()" link="libxml2-entities.html#xmlFreeEntitiesTable"/>
+    <keyword type="function" name="xmlFreeEntity ()" link="libxml2-entities.html#xmlFreeEntity"/>
     <keyword type="function" name="xmlFreeEnumeration ()" link="libxml2-valid.html#xmlFreeEnumeration"/>
     <keyword type="function" name="xmlFreeIDTable ()" link="libxml2-valid.html#xmlFreeIDTable"/>
     <keyword type="function" name="xmlFreeInputStream ()" link="libxml2-parserInternals.html#xmlFreeInputStream"/>
     <keyword type="function" name="xmlGetExternalEntityLoader ()" link="libxml2-parser.html#xmlGetExternalEntityLoader"/>
     <keyword type="function" name="xmlGetFeature ()" link="libxml2-parser.html#xmlGetFeature"/>
     <keyword type="function" name="xmlGetFeaturesList ()" link="libxml2-parser.html#xmlGetFeaturesList"/>
-    <keyword type="function" name="xmlGetGlobalState ()" link="libxml2-threads.html#xmlGetGlobalState"/>
+    <keyword type="function" name="xmlGetGlobalState ()" link="libxml2-globals.html#xmlGetGlobalState"/>
     <keyword type="function" name="xmlGetID ()" link="libxml2-valid.html#xmlGetID"/>
     <keyword type="function" name="xmlGetIntSubset ()" link="libxml2-tree.html#xmlGetIntSubset"/>
     <keyword type="function" name="xmlGetLastChild ()" link="libxml2-tree.html#xmlGetLastChild"/>
     <keyword type="function" name="xmlMemRealloc ()" link="libxml2-xmlmemory.html#xmlMemRealloc"/>
     <keyword type="function" name="xmlMemSetup ()" link="libxml2-xmlmemory.html#xmlMemSetup"/>
     <keyword type="function" name="xmlMemShow ()" link="libxml2-xmlmemory.html#xmlMemShow"/>
+    <keyword type="function" name="xmlMemSize ()" link="libxml2-xmlmemory.html#xmlMemSize"/>
     <keyword type="function" name="xmlMemStrdupLoc ()" link="libxml2-xmlmemory.html#xmlMemStrdupLoc"/>
     <keyword type="function" name="xmlMemUsed ()" link="libxml2-xmlmemory.html#xmlMemUsed"/>
     <keyword type="function" name="xmlMemoryDump ()" link="libxml2-xmlmemory.html#xmlMemoryDump"/>
     <keyword type="function" name="xmlNewProp ()" link="libxml2-tree.html#xmlNewProp"/>
     <keyword type="function" name="xmlNewRMutex ()" link="libxml2-threads.html#xmlNewRMutex"/>
     <keyword type="function" name="xmlNewReference ()" link="libxml2-tree.html#xmlNewReference"/>
+    <keyword type="function" name="xmlNewSAXParserCtxt ()" link="libxml2-parser.html#xmlNewSAXParserCtxt"/>
     <keyword type="function" name="xmlNewStringInputStream ()" link="libxml2-parserInternals.html#xmlNewStringInputStream"/>
     <keyword type="function" name="xmlNewText ()" link="libxml2-tree.html#xmlNewText"/>
     <keyword type="function" name="xmlNewTextChild ()" link="libxml2-tree.html#xmlNewTextChild"/>
     <keyword type="function" name="xmlOutputBufferCreateFd ()" link="libxml2-xmlIO.html#xmlOutputBufferCreateFd"/>
     <keyword type="function" name="xmlOutputBufferCreateFile ()" link="libxml2-xmlIO.html#xmlOutputBufferCreateFile"/>
     <keyword type="function" name="xmlOutputBufferCreateFilename ()" link="libxml2-xmlIO.html#xmlOutputBufferCreateFilename"/>
-    <keyword type="function" name="xmlOutputBufferCreateFilenameDefault ()" link="libxml2-globals.html#xmlOutputBufferCreateFilenameDefault"/>
+    <keyword type="function" name="xmlOutputBufferCreateFilenameDefault ()" link="libxml2-xmlIO.html#xmlOutputBufferCreateFilenameDefault"/>
     <keyword type="function" name="xmlOutputBufferCreateIO ()" link="libxml2-xmlIO.html#xmlOutputBufferCreateIO"/>
     <keyword type="function" name="xmlOutputBufferFlush ()" link="libxml2-xmlIO.html#xmlOutputBufferFlush"/>
     <keyword type="function" name="xmlOutputBufferGetContent ()" link="libxml2-xmlIO.html#xmlOutputBufferGetContent"/>
     <keyword type="function" name="xmlParserInputBufferCreateFd ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateFd"/>
     <keyword type="function" name="xmlParserInputBufferCreateFile ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateFile"/>
     <keyword type="function" name="xmlParserInputBufferCreateFilename ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateFilename"/>
-    <keyword type="function" name="xmlParserInputBufferCreateFilenameDefault ()" link="libxml2-globals.html#xmlParserInputBufferCreateFilenameDefault"/>
+    <keyword type="function" name="xmlParserInputBufferCreateFilenameDefault ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateFilenameDefault"/>
     <keyword type="function" name="xmlParserInputBufferCreateIO ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateIO"/>
     <keyword type="function" name="xmlParserInputBufferCreateMem ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateMem"/>
     <keyword type="function" name="xmlParserInputBufferCreateStatic ()" link="libxml2-xmlIO.html#xmlParserInputBufferCreateStatic"/>
     <keyword type="function" name="xmlRegisterDefaultOutputCallbacks ()" link="libxml2-xmlIO.html#xmlRegisterDefaultOutputCallbacks"/>
     <keyword type="function" name="xmlRegisterHTTPPostCallbacks ()" link="libxml2-xmlIO.html#xmlRegisterHTTPPostCallbacks"/>
     <keyword type="function" name="xmlRegisterInputCallbacks ()" link="libxml2-xmlIO.html#xmlRegisterInputCallbacks"/>
-    <keyword type="function" name="xmlRegisterNodeDefault ()" link="libxml2-globals.html#xmlRegisterNodeDefault"/>
+    <keyword type="function" name="xmlRegisterNodeDefault ()" link="libxml2-tree.html#xmlRegisterNodeDefault"/>
     <keyword type="function" name="xmlRegisterOutputCallbacks ()" link="libxml2-xmlIO.html#xmlRegisterOutputCallbacks"/>
     <keyword type="function" name="xmlRelaxNGCleanupTypes ()" link="libxml2-relaxng.html#xmlRelaxNGCleanupTypes"/>
     <keyword type="function" name="xmlRelaxNGDump ()" link="libxml2-relaxng.html#xmlRelaxNGDump"/>
     <keyword type="function" name="xmlTextReaderSchemaValidate ()" link="libxml2-xmlreader.html#xmlTextReaderSchemaValidate"/>
     <keyword type="function" name="xmlTextReaderSchemaValidateCtxt ()" link="libxml2-xmlreader.html#xmlTextReaderSchemaValidateCtxt"/>
     <keyword type="function" name="xmlTextReaderSetErrorHandler ()" link="libxml2-xmlreader.html#xmlTextReaderSetErrorHandler"/>
+    <keyword type="function" name="xmlTextReaderSetMaxAmplification ()" link="libxml2-xmlreader.html#xmlTextReaderSetMaxAmplification"/>
     <keyword type="function" name="xmlTextReaderSetParserProp ()" link="libxml2-xmlreader.html#xmlTextReaderSetParserProp"/>
     <keyword type="function" name="xmlTextReaderSetSchema ()" link="libxml2-xmlreader.html#xmlTextReaderSetSchema"/>
     <keyword type="function" name="xmlTextReaderSetStructuredErrorHandler ()" link="libxml2-xmlreader.html#xmlTextReaderSetStructuredErrorHandler"/>
     <keyword type="function" name="xmlTextWriterWriteVFormatPI ()" link="libxml2-xmlwriter.html#xmlTextWriterWriteVFormatPI"/>
     <keyword type="function" name="xmlTextWriterWriteVFormatRaw ()" link="libxml2-xmlwriter.html#xmlTextWriterWriteVFormatRaw"/>
     <keyword type="function" name="xmlTextWriterWriteVFormatString ()" link="libxml2-xmlwriter.html#xmlTextWriterWriteVFormatString"/>
-    <keyword type="function" name="xmlThrDefBufferAllocScheme ()" link="libxml2-globals.html#xmlThrDefBufferAllocScheme"/>
-    <keyword type="function" name="xmlThrDefDefaultBufferSize ()" link="libxml2-globals.html#xmlThrDefDefaultBufferSize"/>
-    <keyword type="function" name="xmlThrDefDeregisterNodeDefault ()" link="libxml2-globals.html#xmlThrDefDeregisterNodeDefault"/>
-    <keyword type="function" name="xmlThrDefDoValidityCheckingDefaultValue ()" link="libxml2-globals.html#xmlThrDefDoValidityCheckingDefaultValue"/>
-    <keyword type="function" name="xmlThrDefGetWarningsDefaultValue ()" link="libxml2-globals.html#xmlThrDefGetWarningsDefaultValue"/>
-    <keyword type="function" name="xmlThrDefIndentTreeOutput ()" link="libxml2-globals.html#xmlThrDefIndentTreeOutput"/>
-    <keyword type="function" name="xmlThrDefKeepBlanksDefaultValue ()" link="libxml2-globals.html#xmlThrDefKeepBlanksDefaultValue"/>
-    <keyword type="function" name="xmlThrDefLineNumbersDefaultValue ()" link="libxml2-globals.html#xmlThrDefLineNumbersDefaultValue"/>
-    <keyword type="function" name="xmlThrDefLoadExtDtdDefaultValue ()" link="libxml2-globals.html#xmlThrDefLoadExtDtdDefaultValue"/>
-    <keyword type="function" name="xmlThrDefOutputBufferCreateFilenameDefault ()" link="libxml2-globals.html#xmlThrDefOutputBufferCreateFilenameDefault"/>
-    <keyword type="function" name="xmlThrDefParserDebugEntities ()" link="libxml2-globals.html#xmlThrDefParserDebugEntities"/>
-    <keyword type="function" name="xmlThrDefParserInputBufferCreateFilenameDefault ()" link="libxml2-globals.html#xmlThrDefParserInputBufferCreateFilenameDefault"/>
-    <keyword type="function" name="xmlThrDefPedanticParserDefaultValue ()" link="libxml2-globals.html#xmlThrDefPedanticParserDefaultValue"/>
-    <keyword type="function" name="xmlThrDefRegisterNodeDefault ()" link="libxml2-globals.html#xmlThrDefRegisterNodeDefault"/>
-    <keyword type="function" name="xmlThrDefSaveNoEmptyTags ()" link="libxml2-globals.html#xmlThrDefSaveNoEmptyTags"/>
-    <keyword type="function" name="xmlThrDefSetGenericErrorFunc ()" link="libxml2-globals.html#xmlThrDefSetGenericErrorFunc"/>
-    <keyword type="function" name="xmlThrDefSetStructuredErrorFunc ()" link="libxml2-globals.html#xmlThrDefSetStructuredErrorFunc"/>
-    <keyword type="function" name="xmlThrDefSubstituteEntitiesDefaultValue ()" link="libxml2-globals.html#xmlThrDefSubstituteEntitiesDefaultValue"/>
-    <keyword type="function" name="xmlThrDefTreeIndentString ()" link="libxml2-globals.html#xmlThrDefTreeIndentString"/>
+    <keyword type="function" name="xmlThrDefBufferAllocScheme ()" link="libxml2-tree.html#xmlThrDefBufferAllocScheme"/>
+    <keyword type="function" name="xmlThrDefDefaultBufferSize ()" link="libxml2-tree.html#xmlThrDefDefaultBufferSize"/>
+    <keyword type="function" name="xmlThrDefDeregisterNodeDefault ()" link="libxml2-tree.html#xmlThrDefDeregisterNodeDefault"/>
+    <keyword type="function" name="xmlThrDefDoValidityCheckingDefaultValue ()" link="libxml2-parser.html#xmlThrDefDoValidityCheckingDefaultValue"/>
+    <keyword type="function" name="xmlThrDefGetWarningsDefaultValue ()" link="libxml2-parser.html#xmlThrDefGetWarningsDefaultValue"/>
+    <keyword type="function" name="xmlThrDefIndentTreeOutput ()" link="libxml2-xmlsave.html#xmlThrDefIndentTreeOutput"/>
+    <keyword type="function" name="xmlThrDefKeepBlanksDefaultValue ()" link="libxml2-parser.html#xmlThrDefKeepBlanksDefaultValue"/>
+    <keyword type="function" name="xmlThrDefLineNumbersDefaultValue ()" link="libxml2-parser.html#xmlThrDefLineNumbersDefaultValue"/>
+    <keyword type="function" name="xmlThrDefLoadExtDtdDefaultValue ()" link="libxml2-parser.html#xmlThrDefLoadExtDtdDefaultValue"/>
+    <keyword type="function" name="xmlThrDefOutputBufferCreateFilenameDefault ()" link="libxml2-xmlIO.html#xmlThrDefOutputBufferCreateFilenameDefault"/>
+    <keyword type="function" name="xmlThrDefParserDebugEntities ()" link="libxml2-parser.html#xmlThrDefParserDebugEntities"/>
+    <keyword type="function" name="xmlThrDefParserInputBufferCreateFilenameDefault ()" link="libxml2-xmlIO.html#xmlThrDefParserInputBufferCreateFilenameDefault"/>
+    <keyword type="function" name="xmlThrDefPedanticParserDefaultValue ()" link="libxml2-parser.html#xmlThrDefPedanticParserDefaultValue"/>
+    <keyword type="function" name="xmlThrDefRegisterNodeDefault ()" link="libxml2-tree.html#xmlThrDefRegisterNodeDefault"/>
+    <keyword type="function" name="xmlThrDefSaveNoEmptyTags ()" link="libxml2-xmlsave.html#xmlThrDefSaveNoEmptyTags"/>
+    <keyword type="function" name="xmlThrDefSetGenericErrorFunc ()" link="libxml2-xmlerror.html#xmlThrDefSetGenericErrorFunc"/>
+    <keyword type="function" name="xmlThrDefSetStructuredErrorFunc ()" link="libxml2-xmlerror.html#xmlThrDefSetStructuredErrorFunc"/>
+    <keyword type="function" name="xmlThrDefSubstituteEntitiesDefaultValue ()" link="libxml2-parser.html#xmlThrDefSubstituteEntitiesDefaultValue"/>
+    <keyword type="function" name="xmlThrDefTreeIndentString ()" link="libxml2-xmlsave.html#xmlThrDefTreeIndentString"/>
     <keyword type="function" name="xmlUCSIsAegeanNumbers ()" link="libxml2-xmlunicode.html#xmlUCSIsAegeanNumbers"/>
     <keyword type="function" name="xmlUCSIsAlphabeticPresentationForms ()" link="libxml2-xmlunicode.html#xmlUCSIsAlphabeticPresentationForms"/>
     <keyword type="function" name="xmlUCSIsArabic ()" link="libxml2-xmlunicode.html#xmlUCSIsArabic"/>
diff --git a/doc/examples/.gitignore b/doc/examples/.gitignore
new file mode 100644 (file)
index 0000000..ec244f2
--- /dev/null
@@ -0,0 +1,15 @@
+/io1
+/io2
+/parse1
+/parse2
+/parse3
+/parse4
+/reader1
+/reader2
+/reader3
+/reader4
+/testWriter
+/tree1
+/tree2
+/xpath1
+/xpath2
index 75e138b..e30c02b 100644 (file)
@@ -22,7 +22,6 @@ uninstall-local:
 
 clean-local:
        test -f Makefile.am || rm -f test?.xml
-       rm -f .memdump
 
 EXTRA_DIST = \
        examples.xml \
@@ -86,35 +85,18 @@ valgrind:
 check-local:
        @test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .
        @(echo '## examples regression tests')
-       @(echo > .memdump)
        @$(CHECKER) ./io1 >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./io2 >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./parse1 test1.xml
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./parse2 test2.xml
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./parse3
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./parse4 test3.xml
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./reader1 test2.xml >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./reader2 test2.xml >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./reader3 >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./reader4 test1.xml test2.xml test3.xml >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./testWriter
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./tree1 test2.xml >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./tree2 >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
-       @$(CHECKER) ./xpath1 test3.xml '//child2' >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @$(CHECKER) ./xpath2 test3.xml '//discarded' discarded >/dev/null
-       @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0
        @rm -f *.tmp
index 3b26bca..0cf0f2b 100644 (file)
@@ -8,21 +8,19 @@
     <copy>see Copyright for the status of this software. </copy>
     <section>InputOutput</section>
     <includes>
-      <include line='16'>&lt;libxml/parser.h&gt;</include>
-      <include line='17'>&lt;libxml/tree.h&gt;</include>
-      <include line='18'>&lt;libxml/xinclude.h&gt;</include>
-      <include line='19'>&lt;libxml/xmlIO.h&gt;</include>
+      <include line='17'>&lt;libxml/parser.h&gt;</include>
+      <include line='18'>&lt;libxml/tree.h&gt;</include>
+      <include line='19'>&lt;libxml/xinclude.h&gt;</include>
+      <include line='20'>&lt;libxml/xmlIO.h&gt;</include>
     </includes>
     <uses>
-      <macro line='117' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='154' file='parser' name='xmlCleanupParser'/>
-      <function line='143' file='tree' name='xmlDocDump'/>
-      <typedef line='105' file='tree' name='xmlDocPtr'/>
-      <function line='149' file='tree' name='xmlFreeDoc'/>
-      <function line='158' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='124' file='parser' name='xmlReadMemory'/>
-      <function line='117' file='xmlIO' name='xmlRegisterInputCallbacks'/>
-      <function line='134' file='xinclude' name='xmlXIncludeProcess'/>
+      <macro line='118' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+      <function line='144' file='tree' name='xmlDocDump'/>
+      <typedef line='106' file='tree' name='xmlDocPtr'/>
+      <function line='150' file='tree' name='xmlFreeDoc'/>
+      <function line='125' file='parser' name='xmlReadMemory'/>
+      <function line='118' file='xmlIO' name='xmlRegisterInputCallbacks'/>
+      <function line='135' file='xinclude' name='xmlXIncludeProcess'/>
     </uses>
   </example>
   <example filename='io2.c'>
@@ -40,7 +38,7 @@
       <function line='36' file='tree' name='xmlDocDumpFormatMemory'/>
       <typedef line='20' file='tree' name='xmlDocPtr'/>
       <function line='30' file='tree' name='xmlDocSetRootElement'/>
-      <variable line='42' file='globals' name='xmlFree'/>
+      <variable line='42' file='xmlmemory' name='xmlFree'/>
       <function line='43' file='tree' name='xmlFreeDoc'/>
       <function line='27' file='tree' name='xmlNewDoc'/>
       <function line='28' file='tree' name='xmlNewDocNode'/>
     </includes>
     <uses>
       <macro line='45' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='50' file='parser' name='xmlCleanupParser'/>
       <typedef line='24' file='tree' name='xmlDocPtr'/>
       <function line='31' file='tree' name='xmlFreeDoc'/>
-      <function line='54' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='26' file='parser' name='xmlReadFile'/>
     </uses>
   </example>
     <uses>
       <macro line='61' file='xmlversion' name='LIBXML_TEST_VERSION'/>
       <enum line='35' file='parser' name='XML_PARSE_DTDVALID'/>
-      <function line='66' file='parser' name='xmlCleanupParser'/>
       <function line='35' file='parser' name='xmlCtxtReadFile'/>
       <typedef line='26' file='tree' name='xmlDocPtr'/>
       <function line='44' file='tree' name='xmlFreeDoc'/>
       <function line='47' file='parser' name='xmlFreeParserCtxt'/>
-      <function line='70' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='29' file='parser' name='xmlNewParserCtxt'/>
       <typedef line='25' file='tree' name='xmlParserCtxtPtr'/>
     </uses>
     </includes>
     <uses>
       <macro line='49' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='54' file='parser' name='xmlCleanupParser'/>
       <typedef line='27' file='tree' name='xmlDocPtr'/>
       <function line='38' file='tree' name='xmlFreeDoc'/>
-      <function line='58' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='33' file='parser' name='xmlReadMemory'/>
     </uses>
   </example>
     </includes>
     <uses>
       <macro line='120' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='131' file='parser' name='xmlCleanupParser'/>
       <function line='67' file='parser' name='xmlCreatePushParserCtxt'/>
       <typedef line='47' file='tree' name='xmlDocPtr'/>
       <function line='103' file='tree' name='xmlFreeDoc'/>
       <function line='94' file='parser' name='xmlFreeParserCtxt'/>
-      <function line='135' file='xmlmemory' name='xmlMemoryDump'/>
-      <function line='86' file='parser' name='xmlParseChunk'/>
+      <function line='80' file='parser' name='xmlParseChunk'/>
       <typedef line='45' file='tree' name='xmlParserCtxtPtr'/>
     </uses>
   </example>
     </includes>
     <uses>
       <macro line='89' file='xmlversion' name='LIBXML_TEST_VERSION'/>
-      <function line='94' file='parser' name='xmlCleanupParser'/>
       <function line='69' file='xmlreader' name='xmlFreeTextReader'/>
-      <function line='98' file='xmlmemory' name='xmlMemoryDump'/>
       <function line='62' file='xmlreader' name='xmlReaderForFile'/>
       <function line='44' file='xmlstring' name='xmlStrlen'/>
       <function line='29' file='xmlreader' name='xmlTextReaderConstName'/>
       <function line='39' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
       <function line='37' file='xmlreader' name='xmlTextReaderNodeType'/>
       <typedef line='59' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='67' file='xmlreader' name='xmlTextReaderRead'/>
+      <function line='64' file='xmlreader' name='xmlTextReaderRead'/>
     </uses>
   </example>
   <example filename='reader2.c'>
     <copy>see Copyright for the status of this software. </copy>
     <section>xmlReader</section>
     <includes>
+      <include line='17'>&lt;libxml/parser.h&gt;</include>
       <include line='16'>&lt;libxml/xmlreader.h&gt;</include>
     </includes>
     <uses>
-      <enum line='69' file='parser' name='XML_PARSE_DTDATTR'/>
-      <enum line='71' file='parser' name='XML_PARSE_DTDVALID'/>
-      <enum line='70' file='parser' name='XML_PARSE_NOENT'/>
-      <function line='84' file='xmlreader' name='xmlFreeTextReader'/>
-      <function line='68' file='xmlreader' name='xmlReaderForFile'/>
-      <function line='45' file='xmlstring' name='xmlStrlen'/>
-      <function line='30' file='xmlreader' name='xmlTextReaderConstName'/>
-      <function line='34' file='xmlreader' name='xmlTextReaderConstValue'/>
-      <function line='37' file='xmlreader' name='xmlTextReaderDepth'/>
-      <function line='41' file='xmlreader' name='xmlTextReaderHasValue'/>
-      <function line='40' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
-      <function line='81' file='xmlreader' name='xmlTextReaderIsValid'/>
-      <function line='38' file='xmlreader' name='xmlTextReaderNodeType'/>
-      <typedef line='60' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='76' file='xmlreader' name='xmlTextReaderRead'/>
+      <enum line='70' file='parser' name='XML_PARSE_DTDATTR'/>
+      <enum line='72' file='parser' name='XML_PARSE_DTDVALID'/>
+      <enum line='71' file='parser' name='XML_PARSE_NOENT'/>
+      <function line='85' file='xmlreader' name='xmlFreeTextReader'/>
+      <function line='69' file='xmlreader' name='xmlReaderForFile'/>
+      <function line='46' file='xmlstring' name='xmlStrlen'/>
+      <function line='31' file='xmlreader' name='xmlTextReaderConstName'/>
+      <function line='35' file='xmlreader' name='xmlTextReaderConstValue'/>
+      <function line='38' file='xmlreader' name='xmlTextReaderDepth'/>
+      <function line='42' file='xmlreader' name='xmlTextReaderHasValue'/>
+      <function line='41' file='xmlreader' name='xmlTextReaderIsEmptyElement'/>
+      <function line='82' file='xmlreader' name='xmlTextReaderIsValid'/>
+      <function line='39' file='xmlreader' name='xmlTextReaderNodeType'/>
+      <typedef line='61' file='xmlreader' name='xmlTextReaderPtr'/>
+      <function line='74' file='xmlreader' name='xmlTextReaderRead'/>
     </uses>
   </example>
   <example filename='reader3.c'>
     </includes>
     <uses>
       <function line='96' file='tree' name='xmlDocDump'/>
-      <function line='66' file='xmlreader' name='xmlFreeTextReader'/>
+      <function line='56' file='xmlreader' name='xmlFreeTextReader'/>
       <function line='38' file='xmlreader' name='xmlReaderForFile'/>
       <function line='62' file='xmlreader' name='xmlTextReaderCurrentDoc'/>
       <function line='43' file='xmlreader' name='xmlTextReaderPreservePattern'/>
       <typedef line='32' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='52' file='xmlreader' name='xmlTextReaderRead'/>
+      <function line='50' file='xmlreader' name='xmlTextReaderRead'/>
     </uses>
   </example>
   <example filename='reader4.c'>
       <function line='104' file='xmlreader' name='xmlFreeTextReader'/>
       <function line='72' file='xmlreader' name='xmlReaderForFile'/>
       <function line='83' file='xmlreader' name='xmlReaderNewFile'/>
-      <function line='97' file='xmlreader' name='xmlTextReaderCurrentDoc'/>
+      <function line='34' file='xmlreader' name='xmlTextReaderCurrentDoc'/>
       <typedef line='54' file='xmlreader' name='xmlTextReaderPtr'/>
-      <function line='26' file='xmlreader' name='xmlTextReaderRead'/>
+      <function line='24' file='xmlreader' name='xmlTextReaderRead'/>
     </uses>
   </example>
   <example filename='testWriter.c'>
     <section>xmlWriter</section>
     <includes>
       <include line='16'>&lt;libxml/encoding.h&gt;</include>
+      <include line='18'>&lt;libxml/parser.h&gt;</include>
       <include line='17'>&lt;libxml/xmlwriter.h&gt;</include>
     </includes>
     <uses>
-      <macro line='885' file='parser' name='XML_DEFAULT_VERSION'/>
-      <function line='347' file='tree' name='xmlBufferCreate'/>
-      <function line='613' file='tree' name='xmlBufferFree'/>
-      <typedef line='341' file='tree' name='xmlBufferPtr'/>
-      <typedef line='1151' file='encoding' name='xmlCharEncodingHandlerPtr'/>
-      <function line='901' file='tree' name='xmlDocSetRootElement'/>
-      <function line='1156' file='encoding' name='xmlFindCharEncodingHandler'/>
-      <variable line='1180' file='globals' name='xmlFree'/>
-      <function line='1127' file='xmlwriter' name='xmlFreeTextWriter'/>
-      <variable line='1166' file='globals' name='xmlMalloc'/>
-      <function line='885' file='tree' name='xmlNewDoc'/>
-      <function line='894' file='tree' name='xmlNewDocNode'/>
-      <function line='632' file='xmlwriter' name='xmlNewTextWriterDoc'/>
-      <function line='76' file='xmlwriter' name='xmlNewTextWriterFilename'/>
-      <function line='355' file='xmlwriter' name='xmlNewTextWriterMemory'/>
-      <function line='904' file='xmlwriter' name='xmlNewTextWriterTree'/>
-      <typedef line='880' file='tree' name='xmlNodePtr'/>
-      <variable line='1183' file='globals' name='xmlRealloc'/>
-      <function line='1129' file='tree' name='xmlSaveFileEnc'/>
-      <function line='1121' file='xmlwriter' name='xmlTextWriterEndDocument'/>
-      <function line='1111' file='xmlwriter' name='xmlTextWriterEndElement'/>
-      <typedef line='878' file='xmlwriter' name='xmlTextWriterPtr'/>
-      <function line='913' file='xmlwriter' name='xmlTextWriterStartDocument'/>
-      <function line='1096' file='xmlwriter' name='xmlTextWriterStartElement'/>
-      <function line='949' file='xmlwriter' name='xmlTextWriterWriteAttribute'/>
-      <function line='925' file='xmlwriter' name='xmlTextWriterWriteComment'/>
-      <function line='1103' file='xmlwriter' name='xmlTextWriterWriteElement'/>
-      <function line='959' file='xmlwriter' name='xmlTextWriterWriteFormatComment'/>
-      <function line='1073' file='xmlwriter' name='xmlTextWriterWriteFormatElement'/>
+      <macro line='878' file='parser' name='XML_DEFAULT_VERSION'/>
+      <function line='340' file='tree' name='xmlBufferCreate'/>
+      <function line='606' file='tree' name='xmlBufferFree'/>
+      <typedef line='334' file='tree' name='xmlBufferPtr'/>
+      <typedef line='1144' file='encoding' name='xmlCharEncodingHandlerPtr'/>
+      <function line='894' file='tree' name='xmlDocSetRootElement'/>
+      <function line='1149' file='encoding' name='xmlFindCharEncodingHandler'/>
+      <variable line='106' file='xmlmemory' name='xmlFree'/>
+      <function line='320' file='xmlwriter' name='xmlFreeTextWriter'/>
+      <variable line='1159' file='xmlmemory' name='xmlMalloc'/>
+      <function line='878' file='tree' name='xmlNewDoc'/>
+      <function line='887' file='tree' name='xmlNewDocNode'/>
+      <function line='625' file='xmlwriter' name='xmlNewTextWriterDoc'/>
+      <function line='69' file='xmlwriter' name='xmlNewTextWriterFilename'/>
+      <function line='348' file='xmlwriter' name='xmlNewTextWriterMemory'/>
+      <function line='897' file='xmlwriter' name='xmlNewTextWriterTree'/>
+      <typedef line='873' file='tree' name='xmlNodePtr'/>
+      <variable line='1176' file='xmlmemory' name='xmlRealloc'/>
+      <function line='856' file='tree' name='xmlSaveFileEnc'/>
+      <function line='313' file='xmlwriter' name='xmlTextWriterEndDocument'/>
+      <function line='193' file='xmlwriter' name='xmlTextWriterEndElement'/>
+      <typedef line='65' file='xmlwriter' name='xmlTextWriterPtr'/>
+      <function line='78' file='xmlwriter' name='xmlTextWriterStartDocument'/>
+      <function line='87' file='xmlwriter' name='xmlTextWriterStartElement'/>
+      <function line='117' file='xmlwriter' name='xmlTextWriterWriteAttribute'/>
+      <function line='100' file='xmlwriter' name='xmlTextWriterWriteComment'/>
+      <function line='174' file='xmlwriter' name='xmlTextWriterWriteElement'/>
+      <function line='136' file='xmlwriter' name='xmlTextWriterWriteFormatComment'/>
+      <function line='155' file='xmlwriter' name='xmlTextWriterWriteFormatElement'/>
     </uses>
   </example>
   <example filename='tree1.c'>
       <include line='13'>&lt;libxml/tree.h&gt;</include>
     </includes>
     <uses>
-      <function line='77' file='tree' name='xmlAddChild'/>
+      <function line='76' file='tree' name='xmlAddChild'/>
       <function line='45' file='tree' name='xmlCreateIntSubset'/>
       <function line='40' file='tree' name='xmlDocSetRootElement'/>
-      <function line='87' file='tree' name='xmlNewChild'/>
+      <function line='51' file='tree' name='xmlNewChild'/>
       <function line='38' file='tree' name='xmlNewDoc'/>
-      <function line='73' file='tree' name='xmlNewDocNode'/>
+      <function line='39' file='tree' name='xmlNewDocNode'/>
       <function line='74' file='tree' name='xmlNewDocText'/>
-      <function line='88' file='tree' name='xmlNewProp'/>
+      <function line='65' file='tree' name='xmlNewProp'/>
       <function line='95' file='tree' name='xmlSaveFormatFileEnc'/>
     </uses>
   </example>
       <include line='19'>&lt;libxml/xpathInternals.h&gt;</include>
     </includes>
     <uses>
-      <enum line='229' file='tree' name='XML_ELEMENT_NODE'/>
-      <enum line='217' file='tree' name='XML_NAMESPACE_DECL'/>
-      <variable line='193' file='globals' name='xmlFree'/>
+      <enum line='222' file='tree' name='XML_ELEMENT_NODE'/>
+      <enum line='210' file='tree' name='XML_NAMESPACE_DECL'/>
+      <variable line='166' file='xmlmemory' name='xmlFree'/>
       <function line='39' file='parser' name='xmlInitParser'/>
-      <typedef line='206' file='tree' name='xmlNodePtr'/>
-      <typedef line='218' file='tree' name='xmlNsPtr'/>
-      <function line='94' file='parser' name='xmlParseFile'/>
-      <function line='180' file='xmlstring' name='xmlStrchr'/>
-      <function line='156' file='xmlstring' name='xmlStrdup'/>
-      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
-      <function line='117' file='xpath' name='xmlXPathEvalExpression'/>
-      <function line='130' file='xpath' name='xmlXPathFreeContext'/>
-      <function line='129' file='xpath' name='xmlXPathFreeObject'/>
-      <function line='101' file='xpath' name='xmlXPathNewContext'/>
-      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
-      <function line='186' file='xpathInternals' name='xmlXPathRegisterNs'/>
+      <typedef line='199' file='tree' name='xmlNodePtr'/>
+      <typedef line='211' file='tree' name='xmlNsPtr'/>
+      <function line='87' file='parser' name='xmlParseFile'/>
+      <function line='163' file='xmlstring' name='xmlStrchr'/>
+      <function line='149' file='xmlstring' name='xmlStrdup'/>
+      <typedef line='80' file='xpath' name='xmlXPathContextPtr'/>
+      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
+      <function line='104' file='xpath' name='xmlXPathFreeContext'/>
+      <function line='122' file='xpath' name='xmlXPathFreeObject'/>
+      <function line='94' file='xpath' name='xmlXPathNewContext'/>
+      <typedef line='81' file='xpath' name='xmlXPathObjectPtr'/>
+      <function line='179' file='xpathInternals' name='xmlXPathRegisterNs'/>
     </uses>
   </example>
   <example filename='xpath2.c'>
       <include line='19'>&lt;libxml/xpathInternals.h&gt;</include>
     </includes>
     <uses>
-      <enum line='180' file='tree' name='XML_NAMESPACE_DECL'/>
-      <function line='127' file='tree' name='xmlDocDump'/>
+      <enum line='173' file='tree' name='XML_NAMESPACE_DECL'/>
+      <function line='120' file='tree' name='xmlDocDump'/>
       <function line='41' file='parser' name='xmlInitParser'/>
-      <function line='162' file='tree' name='xmlNodeSetContent'/>
-      <function line='95' file='parser' name='xmlParseFile'/>
-      <typedef line='87' file='xpath' name='xmlXPathContextPtr'/>
-      <function line='110' file='xpath' name='xmlXPathEvalExpression'/>
-      <function line='124' file='xpath' name='xmlXPathFreeContext'/>
-      <function line='123' file='xpath' name='xmlXPathFreeObject'/>
-      <function line='102' file='xpath' name='xmlXPathNewContext'/>
-      <typedef line='88' file='xpath' name='xmlXPathObjectPtr'/>
+      <function line='155' file='tree' name='xmlNodeSetContent'/>
+      <function line='88' file='parser' name='xmlParseFile'/>
+      <typedef line='80' file='xpath' name='xmlXPathContextPtr'/>
+      <function line='103' file='xpath' name='xmlXPathEvalExpression'/>
+      <function line='106' file='xpath' name='xmlXPathFreeContext'/>
+      <function line='116' file='xpath' name='xmlXPathFreeObject'/>
+      <function line='95' file='xpath' name='xmlXPathNewContext'/>
+      <typedef line='81' file='xpath' name='xmlXPathObjectPtr'/>
     </uses>
   </example>
   <symbols>
     <symbol name='xmlCharEncodingHandlerPtr'>
       <ref filename='testWriter.c'/>
     </symbol>
-    <symbol name='xmlCleanupParser'>
-      <ref filename='io1.c'/>
-      <ref filename='parse1.c'/>
-      <ref filename='parse2.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='parse4.c'/>
-      <ref filename='reader1.c'/>
-    </symbol>
     <symbol name='xmlCreateIntSubset'>
       <ref filename='tree2.c'/>
     </symbol>
     <symbol name='xmlMalloc'>
       <ref filename='testWriter.c'/>
     </symbol>
-    <symbol name='xmlMemoryDump'>
-      <ref filename='io1.c'/>
-      <ref filename='parse1.c'/>
-      <ref filename='parse2.c'/>
-      <ref filename='parse3.c'/>
-      <ref filename='parse4.c'/>
-      <ref filename='reader1.c'/>
-    </symbol>
     <symbol name='xmlNewChild'>
       <ref filename='tree2.c'/>
     </symbol>
index 3f45687..1469403 100644 (file)
@@ -80,15 +80,13 @@ install</i> step or when installing the libxml2 development package:</p>
     </ul>
     <p>Uses:</p>
     <ul>
-      <li> line 105: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li>
-      <li> line 117: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 117: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlIO.html#xmlRegisterInputCallbacks">xmlRegisterInputCallbacks</a> from xmlIO.h</li>
-      <li> line 124: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlReadMemory">xmlReadMemory</a> from parser.h</li>
-      <li> line 134: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xinclude.html#xmlXIncludeProcess">xmlXIncludeProcess</a> from xinclude.h</li>
-      <li> line 143: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocDump">xmlDocDump</a> from tree.h</li>
-      <li> line 149: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
-      <li> line 154: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 158: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
+      <li> line 106: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li>
+      <li> line 118: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
+      <li> line 118: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlIO.html#xmlRegisterInputCallbacks">xmlRegisterInputCallbacks</a> from xmlIO.h</li>
+      <li> line 125: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlReadMemory">xmlReadMemory</a> from parser.h</li>
+      <li> line 135: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xinclude.html#xmlXIncludeProcess">xmlXIncludeProcess</a> from xinclude.h</li>
+      <li> line 144: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocDump">xmlDocDump</a> from tree.h</li>
+      <li> line 150: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
     </ul>
     <p>Usage:</p>
     <p>io1</p>
@@ -133,8 +131,6 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 26: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlReadFile">xmlReadFile</a> from parser.h</li>
       <li> line 31: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
       <li> line 45: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 50: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 54: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
     </ul>
     <p>Usage:</p>
     <p>parse1 test1.xml</p>
@@ -159,8 +155,6 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 44: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
       <li> line 47: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlFreeParserCtxt">xmlFreeParserCtxt</a> from parser.h</li>
       <li> line 61: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 66: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 70: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
     </ul>
     <p>Usage:</p>
     <p>parse2 test2.xml</p>
@@ -182,8 +176,6 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 33: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlReadMemory">xmlReadMemory</a> from parser.h</li>
       <li> line 38: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
       <li> line 49: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 54: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 58: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
     </ul>
     <p>Usage:</p>
     <p>parse3</p>
@@ -204,12 +196,10 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 45: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> from tree.h</li>
       <li> line 47: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li>
       <li> line 67: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCreatePushParserCtxt">xmlCreatePushParserCtxt</a> from parser.h</li>
-      <li> line 86: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseChunk">xmlParseChunk</a> from parser.h</li>
+      <li> line 80: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseChunk">xmlParseChunk</a> from parser.h</li>
       <li> line 94: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlFreeParserCtxt">xmlFreeParserCtxt</a> from parser.h</li>
       <li> line 103: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li>
       <li> line 120: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 131: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 135: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
     </ul>
     <p>Usage:</p>
     <p>parse4 test3.xml</p>
@@ -248,13 +238,13 @@ install</i> step or when installing the libxml2 development package:</p>
     <p>Uses:</p>
     <ul>
       <li> line 38: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDoc">xmlNewDoc</a> from tree.h</li>
+      <li> line 39: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDocNode">xmlNewDocNode</a> from tree.h</li>
       <li> line 40: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocSetRootElement">xmlDocSetRootElement</a> from tree.h</li>
       <li> line 45: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlCreateIntSubset">xmlCreateIntSubset</a> from tree.h</li>
-      <li> line 73: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDocNode">xmlNewDocNode</a> from tree.h</li>
+      <li> line 51: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewChild">xmlNewChild</a> from tree.h</li>
+      <li> line 65: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewProp">xmlNewProp</a> from tree.h</li>
       <li> line 74: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDocText">xmlNewDocText</a> from tree.h</li>
-      <li> line 77: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlAddChild">xmlAddChild</a> from tree.h</li>
-      <li> line 87: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewChild">xmlNewChild</a> from tree.h</li>
-      <li> line 88: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewProp">xmlNewProp</a> from tree.h</li>
+      <li> line 76: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlAddChild">xmlAddChild</a> from tree.h</li>
       <li> line 95: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlSaveFormatFileEnc">xmlSaveFormatFileEnc</a> from tree.h</li>
     </ul>
     <p>Usage:</p>
@@ -281,18 +271,18 @@ install</i> step or when installing the libxml2 development package:</p>
     <p>Uses:</p>
     <ul>
       <li> line 39: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlInitParser">xmlInitParser</a> from parser.h</li>
-      <li> line 87: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li>
-      <li> line 88: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li>
-      <li> line 94: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li>
-      <li> line 101: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li>
-      <li> line 117: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li>
-      <li> line 129: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li>
-      <li> line 130: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li>
-      <li> line 156: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrdup">xmlStrdup</a> from xmlstring.h</li>
-      <li> line 180: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrchr">xmlStrchr</a> from xmlstring.h</li>
-      <li> line 186: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpathInternals.html#xmlXPathRegisterNs">xmlXPathRegisterNs</a> from xpathInternals.h</li>
-      <li> line 206: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li>
-      <li> line 218: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNsPtr">xmlNsPtr</a> from tree.h</li>
+      <li> line 80: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li>
+      <li> line 81: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li>
+      <li> line 87: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li>
+      <li> line 94: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li>
+      <li> line 104: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li>
+      <li> line 110: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li>
+      <li> line 122: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li>
+      <li> line 149: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrdup">xmlStrdup</a> from xmlstring.h</li>
+      <li> line 163: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrchr">xmlStrchr</a> from xmlstring.h</li>
+      <li> line 179: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpathInternals.html#xmlXPathRegisterNs">xmlXPathRegisterNs</a> from xpathInternals.h</li>
+      <li> line 199: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li>
+      <li> line 211: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNsPtr">xmlNsPtr</a> from tree.h</li>
     </ul>
     <p>Usage:</p>
     <p>xpath1 &lt;xml-file&gt; &lt;xpath-expr&gt; [&lt;known-ns-list&gt;]</p>
@@ -317,15 +307,15 @@ install</i> step or when installing the libxml2 development package:</p>
     <p>Uses:</p>
     <ul>
       <li> line 41: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlInitParser">xmlInitParser</a> from parser.h</li>
-      <li> line 87: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li>
-      <li> line 88: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li>
-      <li> line 95: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li>
-      <li> line 102: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li>
-      <li> line 110: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li>
-      <li> line 123: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li>
-      <li> line 124: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li>
-      <li> line 127: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocDump">xmlDocDump</a> from tree.h</li>
-      <li> line 162: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodeSetContent">xmlNodeSetContent</a> from tree.h</li>
+      <li> line 80: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li>
+      <li> line 81: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li>
+      <li> line 88: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li>
+      <li> line 95: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li>
+      <li> line 103: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li>
+      <li> line 106: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li>
+      <li> line 116: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li>
+      <li> line 120: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocDump">xmlDocDump</a> from tree.h</li>
+      <li> line 155: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodeSetContent">xmlNodeSetContent</a> from tree.h</li>
     </ul>
     <p>Usage:</p>
     <p>xpath2 &lt;xml-file&gt; &lt;xpath-expr&gt; &lt;new-value&gt;</p>
@@ -350,11 +340,9 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 44: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrlen">xmlStrlen</a> from xmlstring.h</li>
       <li> line 59: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> from xmlreader.h</li>
       <li> line 62: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderForFile">xmlReaderForFile</a> from xmlreader.h</li>
-      <li> line 67: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 64: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
       <li> line 69: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
       <li> line 89: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li>
-      <li> line 94: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li>
-      <li> line 98: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a> from xmlmemory.h</li>
     </ul>
     <p>Usage:</p>
     <p>reader1 &lt;filename&gt;</p>
@@ -366,21 +354,24 @@ install</i> step or when installing the libxml2 development package:</p>
       <li>
         <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html">&lt;libxml/xmlreader.h&gt;</a>
       </li>
+      <li>
+        <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html">&lt;libxml/parser.h&gt;</a>
+      </li>
     </ul>
     <p>Uses:</p>
     <ul>
-      <li> line 30: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderConstName">xmlTextReaderConstName</a> from xmlreader.h</li>
-      <li> line 34: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderConstValue">xmlTextReaderConstValue</a> from xmlreader.h</li>
-      <li> line 37: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderDepth">xmlTextReaderDepth</a> from xmlreader.h</li>
-      <li> line 38: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderNodeType">xmlTextReaderNodeType</a> from xmlreader.h</li>
-      <li> line 40: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderIsEmptyElement">xmlTextReaderIsEmptyElement</a> from xmlreader.h</li>
-      <li> line 41: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderHasValue">xmlTextReaderHasValue</a> from xmlreader.h</li>
-      <li> line 45: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrlen">xmlStrlen</a> from xmlstring.h</li>
-      <li> line 60: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> from xmlreader.h</li>
-      <li> line 68: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderForFile">xmlReaderForFile</a> from xmlreader.h</li>
-      <li> line 76: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
-      <li> line 81: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderIsValid">xmlTextReaderIsValid</a> from xmlreader.h</li>
-      <li> line 84: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
+      <li> line 31: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderConstName">xmlTextReaderConstName</a> from xmlreader.h</li>
+      <li> line 35: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderConstValue">xmlTextReaderConstValue</a> from xmlreader.h</li>
+      <li> line 38: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderDepth">xmlTextReaderDepth</a> from xmlreader.h</li>
+      <li> line 39: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderNodeType">xmlTextReaderNodeType</a> from xmlreader.h</li>
+      <li> line 41: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderIsEmptyElement">xmlTextReaderIsEmptyElement</a> from xmlreader.h</li>
+      <li> line 42: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderHasValue">xmlTextReaderHasValue</a> from xmlreader.h</li>
+      <li> line 46: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlstring.html#xmlStrlen">xmlStrlen</a> from xmlstring.h</li>
+      <li> line 61: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> from xmlreader.h</li>
+      <li> line 69: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderForFile">xmlReaderForFile</a> from xmlreader.h</li>
+      <li> line 74: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 82: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderIsValid">xmlTextReaderIsValid</a> from xmlreader.h</li>
+      <li> line 85: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
     </ul>
     <p>Usage:</p>
     <p>reader2 &lt;valid_xml_filename&gt;</p>
@@ -398,9 +389,9 @@ install</i> step or when installing the libxml2 development package:</p>
       <li> line 32: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> from xmlreader.h</li>
       <li> line 38: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderForFile">xmlReaderForFile</a> from xmlreader.h</li>
       <li> line 43: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a> from xmlreader.h</li>
-      <li> line 52: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 50: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 56: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
       <li> line 62: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderCurrentDoc">xmlTextReaderCurrentDoc</a> from xmlreader.h</li>
-      <li> line 66: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
       <li> line 96: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocDump">xmlDocDump</a> from tree.h</li>
     </ul>
     <p>Usage:</p>
@@ -416,11 +407,11 @@ install</i> step or when installing the libxml2 development package:</p>
     </ul>
     <p>Uses:</p>
     <ul>
-      <li> line 26: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 24: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderRead">xmlTextReaderRead</a> from xmlreader.h</li>
+      <li> line 34: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderCurrentDoc">xmlTextReaderCurrentDoc</a> from xmlreader.h</li>
       <li> line 54: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> from xmlreader.h</li>
       <li> line 72: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderForFile">xmlReaderForFile</a> from xmlreader.h</li>
       <li> line 83: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlReaderNewFile">xmlReaderNewFile</a> from xmlreader.h</li>
-      <li> line 97: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlTextReaderCurrentDoc">xmlTextReaderCurrentDoc</a> from xmlreader.h</li>
       <li> line 104: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlreader.html#xmlFreeTextReader">xmlFreeTextReader</a> from xmlreader.h</li>
     </ul>
     <p>Usage:</p>
@@ -437,35 +428,38 @@ install</i> step or when installing the libxml2 development package:</p>
       <li>
         <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html">&lt;libxml/xmlwriter.h&gt;</a>
       </li>
+      <li>
+        <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html">&lt;libxml/parser.h&gt;</a>
+      </li>
     </ul>
     <p>Uses:</p>
     <ul>
-      <li> line 76: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterFilename">xmlNewTextWriterFilename</a> from xmlwriter.h</li>
-      <li> line 341: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> from tree.h</li>
-      <li> line 347: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferCreate">xmlBufferCreate</a> from tree.h</li>
-      <li> line 355: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterMemory">xmlNewTextWriterMemory</a> from xmlwriter.h</li>
-      <li> line 613: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferFree">xmlBufferFree</a> from tree.h</li>
-      <li> line 632: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterDoc">xmlNewTextWriterDoc</a> from xmlwriter.h</li>
-      <li> line 878: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> from xmlwriter.h</li>
-      <li> line 880: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li>
-      <li> line 885: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#XML_DEFAULT_VERSION">XML_DEFAULT_VERSION</a> from parser.h</li>
-      <li> line 885: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDoc">xmlNewDoc</a> from tree.h</li>
-      <li> line 894: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDocNode">xmlNewDocNode</a> from tree.h</li>
-      <li> line 901: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocSetRootElement">xmlDocSetRootElement</a> from tree.h</li>
-      <li> line 904: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterTree">xmlNewTextWriterTree</a> from xmlwriter.h</li>
-      <li> line 913: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterStartDocument">xmlTextWriterStartDocument</a> from xmlwriter.h</li>
-      <li> line 925: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteComment">xmlTextWriterWriteComment</a> from xmlwriter.h</li>
-      <li> line 949: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteAttribute">xmlTextWriterWriteAttribute</a> from xmlwriter.h</li>
-      <li> line 959: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteFormatComment">xmlTextWriterWriteFormatComment</a> from xmlwriter.h</li>
-      <li> line 1073: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteFormatElement">xmlTextWriterWriteFormatElement</a> from xmlwriter.h</li>
-      <li> line 1096: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterStartElement">xmlTextWriterStartElement</a> from xmlwriter.h</li>
-      <li> line 1103: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteElement">xmlTextWriterWriteElement</a> from xmlwriter.h</li>
-      <li> line 1111: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterEndElement">xmlTextWriterEndElement</a> from xmlwriter.h</li>
-      <li> line 1121: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterEndDocument">xmlTextWriterEndDocument</a> from xmlwriter.h</li>
-      <li> line 1127: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlFreeTextWriter">xmlFreeTextWriter</a> from xmlwriter.h</li>
-      <li> line 1129: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlSaveFileEnc">xmlSaveFileEnc</a> from tree.h</li>
-      <li> line 1151: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> from encoding.h</li>
-      <li> line 1156: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-encoding.html#xmlFindCharEncodingHandler">xmlFindCharEncodingHandler</a> from encoding.h</li>
+      <li> line 65: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterPtr">xmlTextWriterPtr</a> from xmlwriter.h</li>
+      <li> line 69: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterFilename">xmlNewTextWriterFilename</a> from xmlwriter.h</li>
+      <li> line 78: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterStartDocument">xmlTextWriterStartDocument</a> from xmlwriter.h</li>
+      <li> line 87: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterStartElement">xmlTextWriterStartElement</a> from xmlwriter.h</li>
+      <li> line 100: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteComment">xmlTextWriterWriteComment</a> from xmlwriter.h</li>
+      <li> line 117: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteAttribute">xmlTextWriterWriteAttribute</a> from xmlwriter.h</li>
+      <li> line 136: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteFormatComment">xmlTextWriterWriteFormatComment</a> from xmlwriter.h</li>
+      <li> line 155: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteFormatElement">xmlTextWriterWriteFormatElement</a> from xmlwriter.h</li>
+      <li> line 174: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterWriteElement">xmlTextWriterWriteElement</a> from xmlwriter.h</li>
+      <li> line 193: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterEndElement">xmlTextWriterEndElement</a> from xmlwriter.h</li>
+      <li> line 313: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlTextWriterEndDocument">xmlTextWriterEndDocument</a> from xmlwriter.h</li>
+      <li> line 320: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlFreeTextWriter">xmlFreeTextWriter</a> from xmlwriter.h</li>
+      <li> line 334: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> from tree.h</li>
+      <li> line 340: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferCreate">xmlBufferCreate</a> from tree.h</li>
+      <li> line 348: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterMemory">xmlNewTextWriterMemory</a> from xmlwriter.h</li>
+      <li> line 606: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlBufferFree">xmlBufferFree</a> from tree.h</li>
+      <li> line 625: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterDoc">xmlNewTextWriterDoc</a> from xmlwriter.h</li>
+      <li> line 856: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlSaveFileEnc">xmlSaveFileEnc</a> from tree.h</li>
+      <li> line 873: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li>
+      <li> line 878: Macro <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#XML_DEFAULT_VERSION">XML_DEFAULT_VERSION</a> from parser.h</li>
+      <li> line 878: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDoc">xmlNewDoc</a> from tree.h</li>
+      <li> line 887: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlNewDocNode">xmlNewDocNode</a> from tree.h</li>
+      <li> line 894: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-tree.html#xmlDocSetRootElement">xmlDocSetRootElement</a> from tree.h</li>
+      <li> line 897: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xmlwriter.html#xmlNewTextWriterTree">xmlNewTextWriterTree</a> from xmlwriter.h</li>
+      <li> line 1144: Type <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-encoding.html#xmlCharEncodingHandlerPtr">xmlCharEncodingHandlerPtr</a> from encoding.h</li>
+      <li> line 1149: Function <a href="https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-encoding.html#xmlFindCharEncodingHandler">xmlFindCharEncodingHandler</a> from encoding.h</li>
     </ul>
     <p>Usage:</p>
     <p>testWriter</p>
index 8ce8d12..bceae8b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Indexes the examples and build an XML description
 #
@@ -262,10 +262,8 @@ clean-local:
     Makefile = Makefile + "tests: $(check_PROGRAMS)\n"
     Makefile = Makefile + "\t@test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .\n"
     Makefile = Makefile + "\t@(echo '## examples regression tests')\n"
-    Makefile = Makefile + "\t@(echo > .memdump)\n"
     for test in tests:
         Makefile = Makefile + "\t@$(CHECKER) %s\n" % (test)
-        Makefile = Makefile + '\t@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0\n'
     Makefile = Makefile + "\t@rm *.tmp\n"
     try:
         old = open("Makefile.am", "r").read()
index 5c2b25d..0db37c7 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -148,14 +149,6 @@ int main(void) {
      */
     xmlFreeDoc(doc);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 #else
index e3c9d3a..01087d1 100644 (file)
@@ -44,13 +44,5 @@ int main(int argc, char **argv) {
 
     example1Func(argv[1]);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
index 4dcbfde..0732e1e 100644 (file)
@@ -60,13 +60,5 @@ int main(int argc, char **argv) {
 
     exampleFunc(argv[1]);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
index 076a786..15349dc 100644 (file)
@@ -48,13 +48,5 @@ int main(void) {
 
     example3Func(document, 6);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
index 49191d5..eaeab40 100644 (file)
@@ -125,18 +125,10 @@ int main(int argc, char **argv) {
         fprintf(stderr, "Failed to parse %s\n", argv[1]);
     }
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 #else /* ! LIBXML_PUSH_ENABLED */
-int main(int argc, char **argv) {
+int main(void) {
     fprintf(stderr, "Library not compiled with push parser support\n");
     return(0);
 }
index 1030168..eafb6e1 100644 (file)
@@ -88,14 +88,6 @@ int main(int argc, char **argv) {
 
     streamFile(argv[1]);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 
index 9c2d2e6..f07f9cd 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <stdio.h>
 #include <libxml/xmlreader.h>
+#include <libxml/parser.h>
 
 #ifdef LIBXML_READER_ENABLED
 
@@ -103,14 +104,6 @@ int main(int argc, char **argv) {
 
     streamFile(argv[1]);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 
index f608297..d6a43b1 100644 (file)
@@ -100,15 +100,6 @@ int main(int argc, char **argv) {
        xmlFreeDoc(doc);
     }
 
-
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 
index f4277ec..3c0d1b9 100644 (file)
@@ -103,14 +103,6 @@ int main(int argc, char **argv) {
      */
     xmlFreeTextReader(readerPtr);
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 
index a77eec7..0fe141c 100644 (file)
@@ -15,6 +15,7 @@
 #include <string.h>
 #include <libxml/encoding.h>
 #include <libxml/xmlwriter.h>
+#include <libxml/parser.h>
 
 #if defined(LIBXML_WRITER_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
 
@@ -48,14 +49,6 @@ main(void)
     /* next, the tree version */
     testXmlwriterTree("writer4.tmp");
 
-    /*
-     * Cleanup function for the XML library.
-     */
-    xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return 0;
 }
 
index e8fc8d1..28fc1b7 100644 (file)
@@ -78,12 +78,6 @@ main(int argc, char **argv)
     /*free the document */
     xmlFreeDoc(doc);
 
-    /*
-     *Free the global variables that may
-     *have been allocated by the parser.
-     */
-    xmlCleanupParser();
-
     return 0;
 }
 #else
index 83f29a0..ef137af 100644 (file)
@@ -80,10 +80,10 @@ main(int argc, char **argv)
      * A simple loop that "automates" nodes creation 
      */
     for (i = 5; i < 7; i++) {
-        sprintf(buff, "node%d", i);
+        snprintf(buff, sizeof(buff), "node%d", i);
         node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL);
         for (j = 1; j < 4; j++) {
-            sprintf(buff, "node%d%d", i, j);
+            snprintf(buff, sizeof(buff), "node%d%d", i, j);
             node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL);
             xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes"));
         }
@@ -97,16 +97,6 @@ main(int argc, char **argv)
     /*free the document */
     xmlFreeDoc(doc);
 
-    /*
-     *Free the global variables that may
-     *have been allocated by the parser.
-     */
-    xmlCleanupParser();
-
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(0);
 }
 #else
index af996e6..14efcba 100644 (file)
@@ -45,13 +45,6 @@ main(int argc, char **argv) {
        return(-1);
     }
 
-    /* Shutdown libxml */
-    xmlCleanupParser();
-    
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return 0;
 }
 
index a17a025..bf4e631 100644 (file)
@@ -47,13 +47,6 @@ main(int argc, char **argv) {
        return(-1);
     }
 
-    /* Shutdown libxml */
-    xmlCleanupParser();
-    
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return 0;
 }
 
diff --git a/doc/libxml-doc.el b/doc/libxml-doc.el
deleted file mode 100644 (file)
index 43d9688..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-;;; libxml-doc.el - look up libxml-symbols and start browser on documentation
-
-;; Author: Felix Natter <fnatter@gmx.net>, Geert Kloosterman <geertk@ai.rug.nl>
-;; Created: Jun 21 2000
-;; Keywords: libxml documentation
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;; 
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;; 
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ;;; Commentary / README
-
-;; these functions allow you to browse the libxml documentation
-;; (using lynx within emacs by default)
-;;
-;; ----- Installing
-;; 1. add the following to ~/.emacs (adapt path and remove comments !)
-;; (autoload 'libxmldoc-lookup-symbol "~/elisp/libxml-doc" 
-;;  "Look up libxml-symbols and start browser on documentation." t)
-;; or put this file in load-path and use this:
-;; (autoload 'libxmldoc-lookup-symbol "libxml-doc"
-;;  "Look up libxml-symbols and start browser on documentation." t)
-;;
-;; 2. adapt libxmldoc-root:
-;; i.e. (setq libxmldoc-root "~/libxml2-2.0.0/doc/html")
-;;
-;; 3. change the filter-regex: by default, cpp-defines, callbacks and
-;; html-functions are excluded (C-h v libxmldoc-filter-regexp)
-;;
-;; 4. consider customizing libxmldoc-browse-url (lynx by default);
-;; cannot use Emacs/W3 4.0pre46 because it has problems with the html
-;;
-;; ----- Using
-;; call M-x libxmldoc-lookup-symbol: this will prompt with completion and
-;; then open the browser showing the documentation. If the word around the
-;; point matches a symbol, that is used instead.  You can also call
-;; libxmldoc-lookup-symbol noninteractively and pass the symbol.
-
-;; Note:
-;; an alternative to libxml-doc is emacs tags:
-;; $ cd libxml2-2.3.8
-;; $ make TAGS
-;; $ emacs
-;; M-. (M-x find-tag) ...  or
-;; M-x tags-search ... RET M-, M-, ...
-;; (for more information: info emacs RET m Tags RET)
-
-
- ;;; ChangeLog:
-;; Wed Jun 21 01:07:12 2000: initial release
-;; Wed Jun 21 01:45:29 2000: added libxmldoc-lookup-symbol-at-point
-;; Wed Jun 21 23:37:58 2000: libxmldoc-lookup-symbol now uses
-;; (thing-at-point 'word) if it matches a symbol
-;; Thu Jun 22 02:37:46 2000: filtering is only done for completion
-;; Thu Jun 22 21:03:41 2000: libxmldoc-browse-url can be customized
-;; Thu May 31 2001 (Geert): 
-;;       - Changed the `gnome-xml-' html file prefix into `libxml-'.
-;;       - Changed the 'word match from thing-at-point into 'symbol.
-;;         With 'word, identifiers with an underscore (e.g. BAD_CAST)
-;;         don't get matched.
-;; Fri Jun  8 16:29:18 2001, Sat Jun 23 16:19:47 2001:
-;; complete rewrite of libxmldoc-lookup-symbol
-;; by Felix Natter <fnatter@gmx.net>, Geert Kloosterman <geertk@ai.rug.nl>:
-;;       - Now keeps the list of symbols between calls to speed things up.
-;;       - filtering is only used when no symbol is passed and
-;;       thing-at-point does not match a symbol and "*" + thing-at-point
-;;       does not match a symbol (this is used to catch callbacks) and
-;;       libxmldoc-filter-regexp is non-nil.
-;; Sat Jun 23 16:20:34 2001: update the docstrings
-;; Sat Jun 23 16:22:54 2001 (Geert Kloosterman <geertk@ai.rug.nl>):
-;; update README: use autoload instead of load+c-mode-hook
-;; Sat Jul 7 19:00:31 2001: fixed a problem with XEmacs: the
-;; string-match of XEmacs when used in completing-read used the
-;; minibuffer's value of case-fold-search, and not the one in the
-;; c-mode buffer that we had set => so there's a new *-string-match-cs
-;; (case sensitive) function which binds case-fold-search and runs string-match
-;; Wed Sep 1 20:26:29 2004: adapted for libxml2-2.6.9: handle
-;; document-relative (#XXX) links
-
-;;; TODO:
-;; - use command-execute for libxmldoc-browse-url
-;; - keep (match-string 1) in a variable (libxmldoc-get-list-of-symbols)
-;;   (only if it improves performance)
-;; - check the (require ..)-statements
-
- ;;; Code:
-
-(require 'browse-url)
-(require 'term)
-
-(defvar libxmldoc-root "~/src/libxml2-2.3.8/doc/html"
-  "The root-directory of the libxml2-documentation (~ will be expanded).")
-(defvar libxmldoc-filter-regexp "^html\\|^\\*\\|^[A-Z_]+"
-  "Symbols that match this regular expression will be excluded when doing
-completion and no symbol is specified.
- For example:
-   callbacks:     \"^\\\\*\" 
-   cpp-defines:   \"[A-Z_]+\"
-   xml-functions  \"^xml\"
-   html-functions \"^html\"
-   sax-functions  \".*SAX\"
-By default, callbacks, cpp-defines and html* are excluded.
-Set this to nil if you don't want filtering.")
-(defvar libxmldoc-browse-url 'browse-url-lynx-emacs
-  "Browser used for browsing documentation. Emacs/W3 4.0pre46 cannot handle
-the html (and would be too slow), so lynx-emacs is used by default.")
-(defvar libxmldoc-symbol-history nil
-  "History for looking up libxml-symbols.")
-(defvar libxmldoc-symbols nil 
-  "The list of libxml-symbols.")
-
- ;;;; public functions
-
-(defun libxmldoc-lookup-symbol(&optional symbol)
-  "Look up xml-symbol." (interactive)
-  ;; setting case-fold-search is now done in libxmldoc-string-match-cs
-
-  ;; Build up a symbol list if necessary
-  (if (null libxmldoc-symbols)
-      (setq libxmldoc-symbols (libxmldoc-get-list-of-symbols)))
-    
-  (cond
-   (symbol ;; symbol is specified as argument
-    (if (not (assoc symbol libxmldoc-symbols))
-        (setq symbol nil)))
-   ((assoc (thing-at-point 'symbol) libxmldoc-symbols)
-    (setq symbol (thing-at-point 'symbol)))
-   ;; this is needed to catch callbacks
-   ;; note: this could be rewritten to use (thing-at-point 'word)
-   ((assoc (concat "*" (thing-at-point 'symbol)) libxmldoc-symbols)
-    (setq symbol (concat "*" (thing-at-point 'symbol))))
-   )
-
-  ;; omit "" t) from call to completing-read for the sake of xemacs
-  (setq symbol (completing-read 
-                "Libxml: " libxmldoc-symbols
-                (if (or symbol (null libxmldoc-filter-regexp))
-                    nil
-                  '(lambda(key,value)
-                     (not (libxmldoc-string-match-cs libxmldoc-filter-regexp
-                                                     (car key,value)))))
-                t symbol
-                'libxmldoc-symbol-history))
-    
-    
-  ;; start browser
-  (apply libxmldoc-browse-url 
-         (list (cdr (assoc symbol libxmldoc-symbols)))))
-
-;; (if (or symbol
-;;         (null libxmldoc-filter-regexp))
-;;     libxmldoc-symbols
-;;   (mapcar
-;;    '(lambda(key,value)
-;;       (if (null (string-match 
-;;                  libxmldoc-filter-regexp
-;;                  (car key,value)))
-;;           key,value))
-;;    libxmldoc-symbols))
-
-
-;;;; internal
-
-(defun libxmldoc-string-match-cs(regexp str)
-  "This is needed because string-match in XEmacs uses the current-
-buffer's value of case-fold-search (different from GNU Emacs)."
-  (let ((case-fold-search nil))
-    (string-match regexp str)))
-
-(defun libxmldoc-get-list-of-symbols()
-  "Get the list of html-links in the libxml-documentation."
-  (let ((files
-         (directory-files
-          libxmldoc-root t
-          (concat "^" (if (file-exists-p (concat libxmldoc-root
-                                                 "/libxml-parser.html"))
-                          "libxml-"
-                        "gnome-xml-")
-                  ".*\\.html$") t))
-        (symbols ())
-        (case-fold-search t)
-        (uri))
-    (message "collecting libxml-symbols...")
-    (while (car files)
-      (message "processing %s" (car files))
-      (with-temp-buffer
-        (insert-file-contents (car files))
-        (goto-char (point-min))
-        (while (re-search-forward
-                "<a[^>]*href[ \t\n]*=[ \t\n]*\"\\([^=>]*\\)\"[^>]*>" nil t nil)
-          ;; is it a relative link (#XXX)?
-          (if (char-equal (elt (match-string 1) 0) ?#)
-              (setq uri (concat "file://" (car files) (match-string 1)))
-            (setq uri (concat "file://" (expand-file-name libxmldoc-root)
-                              "/" (match-string 1))))
-          (if (not (re-search-forward "\\([^<]*\\)<" nil t nil))
-              (error "regexp error while getting libxml-symbols.."))
-          ;; this needs add-to-list because i.e. xmlChar appears often
-          (if (not (string-equal "" (match-string 1)))
-              (add-to-list 'symbols (cons (match-string 1) uri))))
-        ;;  (setq symbols (cons (cons (match-string 1) uri) symbols)))
-        )
-      (setq files (cdr files)))
-    symbols))
-
-(provide 'libxmldoc)
-
-;;; libxml-doc.el ends here
-\f
-;;; Local Variables:
-;;; indent-tabs-mode: nil
-;;; End:
index 89a4476..1dee142 100644 (file)
@@ -43,6 +43,7 @@
      <exports symbol='UTF8ToHtml' type='function'/>
      <exports symbol='htmlAttrAllowed' type='function'/>
      <exports symbol='htmlAutoCloseTag' type='function'/>
+     <exports symbol='htmlCreateFileParserCtxt' type='function'/>
      <exports symbol='htmlCreateMemoryParserCtxt' type='function'/>
      <exports symbol='htmlCreatePushParserCtxt' type='function'/>
      <exports symbol='htmlCtxtReadDoc' type='function'/>
      <exports symbol='htmlEntityValueLookup' type='function'/>
      <exports symbol='htmlFreeParserCtxt' type='function'/>
      <exports symbol='htmlHandleOmittedElem' type='function'/>
+     <exports symbol='htmlInitAutoClose' type='function'/>
      <exports symbol='htmlIsAutoClosed' type='function'/>
      <exports symbol='htmlIsScriptAttribute' type='function'/>
      <exports symbol='htmlNewParserCtxt' type='function'/>
+     <exports symbol='htmlNewSAXParserCtxt' type='function'/>
      <exports symbol='htmlNodeStatus' type='function'/>
      <exports symbol='htmlParseCharRef' type='function'/>
      <exports symbol='htmlParseChunk' type='function'/>
      <exports symbol='XML_CHAR_ENCODING_UTF16BE' type='enum'/>
      <exports symbol='XML_CHAR_ENCODING_UTF16LE' type='enum'/>
      <exports symbol='XML_CHAR_ENCODING_UTF8' type='enum'/>
+     <exports symbol='XML_ENC_ERR_INPUT' type='enum'/>
+     <exports symbol='XML_ENC_ERR_INTERNAL' type='enum'/>
+     <exports symbol='XML_ENC_ERR_MEMORY' type='enum'/>
+     <exports symbol='XML_ENC_ERR_PARTIAL' type='enum'/>
+     <exports symbol='XML_ENC_ERR_SPACE' type='enum'/>
+     <exports symbol='XML_ENC_ERR_SUCCESS' type='enum'/>
+     <exports symbol='xmlCharEncError' type='typedef'/>
      <exports symbol='xmlCharEncoding' type='typedef'/>
      <exports symbol='xmlCharEncodingHandler' type='typedef'/>
      <exports symbol='xmlCharEncodingHandlerPtr' type='typedef'/>
+     <exports symbol='_xmlBuffer' type='struct'/>
      <exports symbol='_xmlCharEncodingHandler' type='struct'/>
      <exports symbol='UTF8Toisolat1' type='function'/>
      <exports symbol='isolat1ToUTF8' type='function'/>
      <exports symbol='xmlEncodeEntitiesReentrant' type='function'/>
      <exports symbol='xmlEncodeSpecialChars' type='function'/>
      <exports symbol='xmlFreeEntitiesTable' type='function'/>
+     <exports symbol='xmlFreeEntity' type='function'/>
      <exports symbol='xmlGetDocEntity' type='function'/>
      <exports symbol='xmlGetDtdEntity' type='function'/>
      <exports symbol='xmlGetParameterEntity' type='function'/>
     </file>
     <file name='globals'>
      <summary>interface for all global variables of the library</summary>
-     <description>all the global variables and thread handling for those variables is handled by this module.  The bottom of this file is automatically generated by build_glob.py based on the description file global.data </description>
-     <author>Gary Pennington &lt;Gary.Pennington@uk.sun.com&gt;, Daniel Veillard </author>
+     <description>Deprecated, don&apos;t use </description>
      <exports symbol='xmlGlobalState' type='typedef'/>
      <exports symbol='xmlGlobalStatePtr' type='typedef'/>
-     <exports symbol='_xmlGlobalState' type='struct'/>
-     <exports symbol='htmlDefaultSAXHandler' type='variable'/>
-     <exports symbol='oldXMLWDcompatibility' type='variable'/>
-     <exports symbol='xmlBufferAllocScheme' type='variable'/>
-     <exports symbol='xmlDefaultBufferSize' type='variable'/>
-     <exports symbol='xmlDefaultSAXHandler' type='variable'/>
-     <exports symbol='xmlDefaultSAXLocator' type='variable'/>
-     <exports symbol='xmlDeregisterNodeDefaultValue' type='variable'/>
-     <exports symbol='xmlDoValidityCheckingDefaultValue' type='variable'/>
-     <exports symbol='xmlFree' type='variable'/>
-     <exports symbol='xmlGenericError' type='variable'/>
-     <exports symbol='xmlGenericErrorContext' type='variable'/>
-     <exports symbol='xmlGetWarningsDefaultValue' type='variable'/>
-     <exports symbol='xmlIndentTreeOutput' type='variable'/>
-     <exports symbol='xmlKeepBlanksDefaultValue' type='variable'/>
-     <exports symbol='xmlLastError' type='variable'/>
-     <exports symbol='xmlLineNumbersDefaultValue' type='variable'/>
-     <exports symbol='xmlLoadExtDtdDefaultValue' type='variable'/>
-     <exports symbol='xmlMalloc' type='variable'/>
-     <exports symbol='xmlMallocAtomic' type='variable'/>
-     <exports symbol='xmlMemStrdup' type='variable'/>
-     <exports symbol='xmlOutputBufferCreateFilenameValue' type='variable'/>
-     <exports symbol='xmlParserDebugEntities' type='variable'/>
-     <exports symbol='xmlParserInputBufferCreateFilenameValue' type='variable'/>
-     <exports symbol='xmlParserVersion' type='variable'/>
-     <exports symbol='xmlPedanticParserDefaultValue' type='variable'/>
-     <exports symbol='xmlRealloc' type='variable'/>
-     <exports symbol='xmlRegisterNodeDefaultValue' type='variable'/>
-     <exports symbol='xmlSaveNoEmptyTags' type='variable'/>
-     <exports symbol='xmlStructuredError' type='variable'/>
-     <exports symbol='xmlStructuredErrorContext' type='variable'/>
-     <exports symbol='xmlSubstituteEntitiesDefaultValue' type='variable'/>
-     <exports symbol='xmlTreeIndentString' type='variable'/>
      <exports symbol='xmlCleanupGlobals' type='function'/>
-     <exports symbol='xmlDeregisterNodeDefault' type='function'/>
-     <exports symbol='xmlDeregisterNodeFunc' type='function'/>
+     <exports symbol='xmlGetGlobalState' type='function'/>
      <exports symbol='xmlInitGlobals' type='function'/>
      <exports symbol='xmlInitializeGlobalState' type='function'/>
-     <exports symbol='xmlOutputBufferCreateFilenameDefault' type='function'/>
-     <exports symbol='xmlOutputBufferCreateFilenameFunc' type='function'/>
-     <exports symbol='xmlParserInputBufferCreateFilenameDefault' type='function'/>
-     <exports symbol='xmlParserInputBufferCreateFilenameFunc' type='function'/>
-     <exports symbol='xmlRegisterNodeDefault' type='function'/>
-     <exports symbol='xmlRegisterNodeFunc' type='function'/>
-     <exports symbol='xmlThrDefBufferAllocScheme' type='function'/>
-     <exports symbol='xmlThrDefDefaultBufferSize' type='function'/>
-     <exports symbol='xmlThrDefDeregisterNodeDefault' type='function'/>
-     <exports symbol='xmlThrDefDoValidityCheckingDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefGetWarningsDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefIndentTreeOutput' type='function'/>
-     <exports symbol='xmlThrDefKeepBlanksDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefLineNumbersDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefLoadExtDtdDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefOutputBufferCreateFilenameDefault' type='function'/>
-     <exports symbol='xmlThrDefParserDebugEntities' type='function'/>
-     <exports symbol='xmlThrDefParserInputBufferCreateFilenameDefault' type='function'/>
-     <exports symbol='xmlThrDefPedanticParserDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefRegisterNodeDefault' type='function'/>
-     <exports symbol='xmlThrDefSaveNoEmptyTags' type='function'/>
-     <exports symbol='xmlThrDefSetGenericErrorFunc' type='function'/>
-     <exports symbol='xmlThrDefSetStructuredErrorFunc' type='function'/>
-     <exports symbol='xmlThrDefSubstituteEntitiesDefaultValue' type='function'/>
-     <exports symbol='xmlThrDefTreeIndentString' type='function'/>
     </file>
     <file name='hash'>
      <summary>Chained hash tables</summary>
      <exports symbol='XML_PARSER_START' type='enum'/>
      <exports symbol='XML_PARSER_START_TAG' type='enum'/>
      <exports symbol='XML_PARSER_SYSTEM_LITERAL' type='enum'/>
+     <exports symbol='XML_PARSER_XML_DECL' type='enum'/>
      <exports symbol='XML_PARSE_BIG_LINES' type='enum'/>
      <exports symbol='XML_PARSE_COMPACT' type='enum'/>
      <exports symbol='XML_PARSE_DOM' type='enum'/>
      <exports symbol='XML_WITH_XPATH' type='enum'/>
      <exports symbol='XML_WITH_XPTR' type='enum'/>
      <exports symbol='XML_WITH_ZLIB' type='enum'/>
+     <exports symbol='xmlAttrHashBucket' type='typedef'/>
      <exports symbol='xmlFeature' type='typedef'/>
      <exports symbol='xmlParserInputState' type='typedef'/>
      <exports symbol='xmlParserMode' type='typedef'/>
      <exports symbol='xmlParserNodeInfoPtr' type='typedef'/>
      <exports symbol='xmlParserNodeInfoSeq' type='typedef'/>
      <exports symbol='xmlParserNodeInfoSeqPtr' type='typedef'/>
+     <exports symbol='xmlParserNsData' type='typedef'/>
      <exports symbol='xmlParserOption' type='typedef'/>
      <exports symbol='xmlSAXHandlerV1' type='typedef'/>
      <exports symbol='xmlSAXHandlerV1Ptr' type='typedef'/>
      <exports symbol='_xmlSAXHandler' type='struct'/>
      <exports symbol='_xmlSAXHandlerV1' type='struct'/>
      <exports symbol='_xmlSAXLocator' type='struct'/>
+     <exports symbol='xmlParserVersion' type='variable'/>
      <exports symbol='attributeDeclSAXFunc' type='function'/>
      <exports symbol='attributeSAXFunc' type='function'/>
      <exports symbol='cdataBlockSAXFunc' type='function'/>
      <exports symbol='xmlCtxtReadMemory' type='function'/>
      <exports symbol='xmlCtxtReset' type='function'/>
      <exports symbol='xmlCtxtResetPush' type='function'/>
+     <exports symbol='xmlCtxtSetMaxAmplification' type='function'/>
      <exports symbol='xmlCtxtUseOptions' type='function'/>
      <exports symbol='xmlExternalEntityLoader' type='function'/>
      <exports symbol='xmlFreeParserCtxt' type='function'/>
      <exports symbol='xmlLoadExternalEntity' type='function'/>
      <exports symbol='xmlNewIOInputStream' type='function'/>
      <exports symbol='xmlNewParserCtxt' type='function'/>
+     <exports symbol='xmlNewSAXParserCtxt' type='function'/>
      <exports symbol='xmlParseBalancedChunkMemory' type='function'/>
      <exports symbol='xmlParseBalancedChunkMemoryRecover' type='function'/>
      <exports symbol='xmlParseChunk' type='function'/>
      <exports symbol='xmlSetupParserForBuffer' type='function'/>
      <exports symbol='xmlStopParser' type='function'/>
      <exports symbol='xmlSubstituteEntitiesDefault' type='function'/>
+     <exports symbol='xmlThrDefDoValidityCheckingDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefGetWarningsDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefKeepBlanksDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefLineNumbersDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefLoadExtDtdDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefParserDebugEntities' type='function'/>
+     <exports symbol='xmlThrDefPedanticParserDefaultValue' type='function'/>
+     <exports symbol='xmlThrDefSubstituteEntitiesDefaultValue' type='function'/>
     </file>
     <file name='parserInternals'>
      <summary>internals routines and limits exported by the parser.</summary>
      <exports symbol='IS_LETTER_CH' type='macro'/>
      <exports symbol='IS_PUBIDCHAR' type='macro'/>
      <exports symbol='IS_PUBIDCHAR_CH' type='macro'/>
-     <exports symbol='MOVETO_ENDTAG' type='macro'/>
-     <exports symbol='MOVETO_STARTTAG' type='macro'/>
-     <exports symbol='SKIP_EOL' type='macro'/>
      <exports symbol='XML_MAX_DICTIONARY_LIMIT' type='macro'/>
+     <exports symbol='XML_MAX_HUGE_LENGTH' type='macro'/>
      <exports symbol='XML_MAX_LOOKUP_LIMIT' type='macro'/>
      <exports symbol='XML_MAX_NAMELEN' type='macro'/>
      <exports symbol='XML_MAX_NAME_LENGTH' type='macro'/>
      <exports symbol='xmlStringComment' type='variable'/>
      <exports symbol='xmlStringText' type='variable'/>
      <exports symbol='xmlStringTextNoenc' type='variable'/>
-     <exports symbol='htmlCreateFileParserCtxt' type='function'/>
-     <exports symbol='htmlInitAutoClose' type='function'/>
      <exports symbol='inputPop' type='function'/>
      <exports symbol='inputPush' type='function'/>
      <exports symbol='namePop' type='function'/>
      <exports symbol='xmlCurrentChar' type='function'/>
      <exports symbol='xmlDecodeEntities' type='function'/>
      <exports symbol='xmlEntityReferenceFunc' type='function'/>
-     <exports symbol='xmlErrMemory' type='function'/>
      <exports symbol='xmlFreeInputStream' type='function'/>
      <exports symbol='xmlHandleEntity' type='function'/>
      <exports symbol='xmlIsLetter' type='function'/>
      <exports symbol='xmlMutexPtr' type='typedef'/>
      <exports symbol='xmlRMutex' type='typedef'/>
      <exports symbol='xmlRMutexPtr' type='typedef'/>
+     <exports symbol='xmlCheckThreadLocalStorage' type='function'/>
      <exports symbol='xmlCleanupThreads' type='function'/>
-     <exports symbol='xmlDllMain' type='function'/>
      <exports symbol='xmlFreeMutex' type='function'/>
      <exports symbol='xmlFreeRMutex' type='function'/>
-     <exports symbol='xmlGetGlobalState' type='function'/>
      <exports symbol='xmlGetThreadId' type='function'/>
      <exports symbol='xmlInitThreads' type='function'/>
      <exports symbol='xmlIsMainThread' type='function'/>
      <author>Daniel Veillard </author>
      <exports symbol='BASE_BUFFER_SIZE' type='macro'/>
      <exports symbol='LIBXML2_NEW_BUFFER' type='macro'/>
-     <exports symbol='XML_DOCB_DOCUMENT_NODE' type='macro'/>
      <exports symbol='XML_GET_CONTENT' type='macro'/>
      <exports symbol='XML_GET_LINE' type='macro'/>
      <exports symbol='XML_LOCAL_NAMESPACE' type='macro'/>
      <exports symbol='xmlDOMWrapNewCtxt' type='function'/>
      <exports symbol='xmlDOMWrapReconcileNamespaces' type='function'/>
      <exports symbol='xmlDOMWrapRemoveNode' type='function'/>
+     <exports symbol='xmlDeregisterNodeDefault' type='function'/>
+     <exports symbol='xmlDeregisterNodeFunc' type='function'/>
      <exports symbol='xmlDocCopyNode' type='function'/>
      <exports symbol='xmlDocCopyNodeList' type='function'/>
      <exports symbol='xmlDocDump' type='function'/>
      <exports symbol='xmlNodeSetSpacePreserve' type='function'/>
      <exports symbol='xmlPreviousElementSibling' type='function'/>
      <exports symbol='xmlReconciliateNs' type='function'/>
+     <exports symbol='xmlRegisterNodeDefault' type='function'/>
+     <exports symbol='xmlRegisterNodeFunc' type='function'/>
      <exports symbol='xmlRemoveProp' type='function'/>
      <exports symbol='xmlReplaceNode' type='function'/>
      <exports symbol='xmlSaveFile' type='function'/>
      <exports symbol='xmlStringLenGetNodeList' type='function'/>
      <exports symbol='xmlTextConcat' type='function'/>
      <exports symbol='xmlTextMerge' type='function'/>
+     <exports symbol='xmlThrDefBufferAllocScheme' type='function'/>
+     <exports symbol='xmlThrDefDefaultBufferSize' type='function'/>
+     <exports symbol='xmlThrDefDeregisterNodeDefault' type='function'/>
+     <exports symbol='xmlThrDefRegisterNodeDefault' type='function'/>
      <exports symbol='xmlUnlinkNode' type='function'/>
      <exports symbol='xmlUnsetNsProp' type='function'/>
      <exports symbol='xmlUnsetProp' type='function'/>
      <summary>The DTD validation</summary>
      <description>API for the DTD handling and the validity checking </description>
      <author>Daniel Veillard </author>
-     <exports symbol='XML_VCTXT_DTD_VALIDATED' type='macro'/>
-     <exports symbol='XML_VCTXT_USE_PCTXT' type='macro'/>
      <exports symbol='xmlAttributeTable' type='typedef'/>
      <exports symbol='xmlAttributeTablePtr' type='typedef'/>
      <exports symbol='xmlElementTable' type='typedef'/>
      <exports symbol='xmlOutputBufferCreateFd' type='function'/>
      <exports symbol='xmlOutputBufferCreateFile' type='function'/>
      <exports symbol='xmlOutputBufferCreateFilename' type='function'/>
+     <exports symbol='xmlOutputBufferCreateFilenameDefault' type='function'/>
+     <exports symbol='xmlOutputBufferCreateFilenameFunc' type='function'/>
      <exports symbol='xmlOutputBufferCreateIO' type='function'/>
      <exports symbol='xmlOutputBufferFlush' type='function'/>
      <exports symbol='xmlOutputBufferGetContent' type='function'/>
      <exports symbol='xmlParserInputBufferCreateFd' type='function'/>
      <exports symbol='xmlParserInputBufferCreateFile' type='function'/>
      <exports symbol='xmlParserInputBufferCreateFilename' type='function'/>
+     <exports symbol='xmlParserInputBufferCreateFilenameDefault' type='function'/>
+     <exports symbol='xmlParserInputBufferCreateFilenameFunc' type='function'/>
      <exports symbol='xmlParserInputBufferCreateIO' type='function'/>
      <exports symbol='xmlParserInputBufferCreateMem' type='function'/>
      <exports symbol='xmlParserInputBufferCreateStatic' type='function'/>
      <exports symbol='xmlRegisterHTTPPostCallbacks' type='function'/>
      <exports symbol='xmlRegisterInputCallbacks' type='function'/>
      <exports symbol='xmlRegisterOutputCallbacks' type='function'/>
+     <exports symbol='xmlThrDefOutputBufferCreateFilenameDefault' type='function'/>
+     <exports symbol='xmlThrDefParserInputBufferCreateFilenameDefault' type='function'/>
     </file>
     <file name='xmlautomata'>
      <summary>API to build regexp automata</summary>
      <exports symbol='XML_TREE_NOT_UTF8' type='enum'/>
      <exports symbol='XML_TREE_UNTERMINATED_ENTITY' type='enum'/>
      <exports symbol='XML_WAR_CATALOG_PI' type='enum'/>
+     <exports symbol='XML_WAR_ENCODING_MISMATCH' type='enum'/>
      <exports symbol='XML_WAR_ENTITY_REDEFINED' type='enum'/>
      <exports symbol='XML_WAR_LANG_VALUE' type='enum'/>
      <exports symbol='XML_WAR_NS_COLUMN' type='enum'/>
      <exports symbol='xmlErrorPtr' type='typedef'/>
      <exports symbol='xmlParserErrors' type='typedef'/>
      <exports symbol='_xmlError' type='struct'/>
+     <exports symbol='_xmlParserInput' type='struct'/>
      <exports symbol='initGenericErrorDefaultFunc' type='function'/>
      <exports symbol='xmlCopyError' type='function'/>
      <exports symbol='xmlCtxtGetLastError' type='function'/>
      <exports symbol='xmlSetGenericErrorFunc' type='function'/>
      <exports symbol='xmlSetStructuredErrorFunc' type='function'/>
      <exports symbol='xmlStructuredErrorFunc' type='function'/>
+     <exports symbol='xmlThrDefSetGenericErrorFunc' type='function'/>
+     <exports symbol='xmlThrDefSetStructuredErrorFunc' type='function'/>
     </file>
     <file name='xmlexports'>
      <summary>macros for marking symbols as exportable/importable.</summary>
      <description>macros for marking symbols as exportable/importable. </description>
-     <exports symbol='LIBXML_DLL_IMPORT' type='macro'/>
-     <exports symbol='XMLCALL' type='macro'/>
-     <exports symbol='XMLCDECL' type='macro'/>
      <exports symbol='XMLPUBFUN' type='macro'/>
-     <exports symbol='XMLPUBLIC' type='macro'/>
      <exports symbol='XMLPUBVAR' type='macro'/>
     </file>
     <file name='xmlmemory'>
      <summary>interface for the memory allocator</summary>
      <description>provides interfaces for the memory allocator, including debugging capabilities. </description>
      <author>Daniel Veillard </author>
-     <exports symbol='DEBUG_MEMORY' type='macro'/>
-     <exports symbol='xmlMalloc' type='macro'/>
-     <exports symbol='xmlMallocAtomic' type='macro'/>
-     <exports symbol='xmlMemStrdup' type='macro'/>
-     <exports symbol='xmlRealloc' type='macro'/>
+     <exports symbol='xmlFree' type='variable'/>
+     <exports symbol='xmlMalloc' type='variable'/>
+     <exports symbol='xmlMallocAtomic' type='variable'/>
+     <exports symbol='xmlMemStrdup' type='variable'/>
+     <exports symbol='xmlRealloc' type='variable'/>
      <exports symbol='xmlCleanupMemory' type='function'/>
      <exports symbol='xmlFreeFunc' type='function'/>
      <exports symbol='xmlGcMemGet' type='function'/>
      <exports symbol='xmlMemRealloc' type='function'/>
      <exports symbol='xmlMemSetup' type='function'/>
      <exports symbol='xmlMemShow' type='function'/>
+     <exports symbol='xmlMemSize' type='function'/>
      <exports symbol='xmlMemStrdupLoc' type='function'/>
      <exports symbol='xmlMemUsed' type='function'/>
      <exports symbol='xmlMemoryDump' type='function'/>
      <exports symbol='xmlTextReaderSchemaValidate' type='function'/>
      <exports symbol='xmlTextReaderSchemaValidateCtxt' type='function'/>
      <exports symbol='xmlTextReaderSetErrorHandler' type='function'/>
+     <exports symbol='xmlTextReaderSetMaxAmplification' type='function'/>
      <exports symbol='xmlTextReaderSetParserProp' type='function'/>
      <exports symbol='xmlTextReaderSetSchema' type='function'/>
      <exports symbol='xmlTextReaderSetStructuredErrorHandler' type='function'/>
      <exports symbol='xmlSaveToFilename' type='function'/>
      <exports symbol='xmlSaveToIO' type='function'/>
      <exports symbol='xmlSaveTree' type='function'/>
+     <exports symbol='xmlThrDefIndentTreeOutput' type='function'/>
+     <exports symbol='xmlThrDefSaveNoEmptyTags' type='function'/>
+     <exports symbol='xmlThrDefTreeIndentString' type='function'/>
     </file>
     <file name='xmlschemas'>
      <summary>incomplete XML Schemas structure implementation</summary>
      <summary>compile-time version information</summary>
      <description>compile-time version information for the XML library </description>
      <author>Daniel Veillard </author>
-     <exports symbol='ATTRIBUTE_UNUSED' type='macro'/>
      <exports symbol='DEBUG_MEMORY_LOCATION' type='macro'/>
-     <exports symbol='LIBXML_ATTR_ALLOC_SIZE' type='macro'/>
-     <exports symbol='LIBXML_ATTR_FORMAT' type='macro'/>
      <exports symbol='LIBXML_AUTOMATA_ENABLED' type='macro'/>
      <exports symbol='LIBXML_C14N_ENABLED' type='macro'/>
      <exports symbol='LIBXML_CATALOG_ENABLED' type='macro'/>
      <exports symbol='LIBXML_ZLIB_ENABLED' type='macro'/>
      <exports symbol='WITHOUT_TRIO' type='macro'/>
      <exports symbol='WITH_TRIO' type='macro'/>
-     <exports symbol='XML_DEPRECATED' type='macro'/>
      <exports symbol='xmlCheckVersion' type='function'/>
     </file>
     <file name='xmlwriter'>
     </file>
   </files>
   <symbols>
-    <macro name='ATTRIBUTE_UNUSED' file='xmlversion'>
-      <info>Macro used to signal to GCC unused function parameters</info>
-    </macro>
     <macro name='BAD_CAST' file='xmlstring'>
       <info>Macro to cast a string to an xmlChar * when one know its safe.</info>
     </macro>
       <info>Macro to check that the value on top of the XPath stack is of a given type. Return(0) in case of failure</info>
       <arg name='typeval' info='the XPath type'/>
     </macro>
-    <macro name='DEBUG_MEMORY' file='xmlmemory'>
-      <info>DEBUG_MEMORY replaces the allocator with a collect and debug shell to the libc allocator. DEBUG_MEMORY should only be activated when debugging libxml i.e. if libxml has been configured with --with-debug-mem too. #define DEBUG_MEMORY_FREED #define DEBUG_MEMORY_LOCATION</info>
-    </macro>
     <macro name='DEBUG_MEMORY_LOCATION' file='xmlversion'>
       <info>Whether the memory debugging is configured in</info>
     </macro>
     <macro name='LIBXML2_NEW_BUFFER' file='tree'>
       <info>Macro used to express that the API use the new buffers for xmlParserInputBuffer and xmlOutputBuffer. The change was introduced in 2.9.0.</info>
     </macro>
-    <macro name='LIBXML_ATTR_ALLOC_SIZE' file='xmlversion'>
-      <info>Macro used to indicate to GCC this is an allocator function</info>
-    </macro>
-    <macro name='LIBXML_ATTR_FORMAT' file='xmlversion'>
-      <info>Macro used to indicate to GCC the parameter are printf like</info>
-    </macro>
     <macro name='LIBXML_AUTOMATA_ENABLED' file='xmlversion'>
       <info>Whether the automata interfaces are compiled in</info>
     </macro>
       <info>Whether Debugging module is configured in</info>
     </macro>
     <macro name='LIBXML_DEBUG_RUNTIME' file='xmlversion'>
-      <info>Whether the runtime debugging is configured in</info>
-    </macro>
-    <macro name='LIBXML_DLL_IMPORT' file='xmlexports'>
+      <info>Removed</info>
     </macro>
     <macro name='LIBXML_DOTTED_VERSION' file='xmlversion'>
       <info>the version string like &quot;1.2.3&quot;</info>
     <macro name='LIBXML_ZLIB_ENABLED' file='xmlversion'>
       <info>Whether the Zlib support is compiled in</info>
     </macro>
-    <macro name='MOVETO_ENDTAG' file='parserInternals'>
-      <info>Skips to the next &apos;&gt;&apos; char.</info>
-      <arg name='p' info='and UTF8 string pointer'/>
-    </macro>
-    <macro name='MOVETO_STARTTAG' file='parserInternals'>
-      <info>Skips to the next &apos;&lt;&apos; char.</info>
-      <arg name='p' info='and UTF8 string pointer'/>
-    </macro>
-    <macro name='SKIP_EOL' file='parserInternals'>
-      <info>Skips the end of line chars.</info>
-      <arg name='p' info='and UTF8 string pointer'/>
-    </macro>
     <macro name='SOCKET' file='nanoftp'>
       <info>macro used to provide portability of code to windows sockets</info>
     </macro>
     <macro name='XINCLUDE_PARSE_XPOINTER' file='xinclude'>
       <info>Macro defining &quot;xpointer&quot;</info>
     </macro>
-    <macro name='XMLCALL' file='xmlexports'>
-      <info>Macro which declares the calling convention for exported functions</info>
-    </macro>
-    <macro name='XMLCDECL' file='xmlexports'>
-      <info>Macro which declares the calling convention for exported functions that use &apos;...&apos;.</info>
-    </macro>
     <macro name='XMLPUBFUN' file='xmlexports'>
       <info>Macro which declares an exportable function</info>
     </macro>
-    <macro name='XMLPUBLIC' file='xmlexports'>
-      <info>Macro which declares a public symbol</info>
-    </macro>
     <macro name='XMLPUBVAR' file='xmlexports'>
       <info>Macro which declares an exportable variable</info>
     </macro>
     <macro name='XML_DEFAULT_VERSION' file='parser'>
       <info>The default version of XML used: 1.0</info>
     </macro>
-    <macro name='XML_DEPRECATED' file='xmlversion'>
-      <info>Macro used to indicate that a function, variable, type or struct member is deprecated.</info>
-    </macro>
     <macro name='XML_DETECT_IDS' file='parser'>
       <info>Bit in the loadsubset context field to tell to do ID/REFs lookups. Use it to initialize xmlLoadExtDtdDefaultValue.</info>
     </macro>
-    <macro name='XML_DOCB_DOCUMENT_NODE' file='tree'>
-    </macro>
     <macro name='XML_GET_CONTENT' file='tree'>
       <info>Macro to extract the content pointer of a node.</info>
     </macro>
     <macro name='XML_MAX_DICTIONARY_LIMIT' file='parserInternals'>
       <info>Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0</info>
     </macro>
+    <macro name='XML_MAX_HUGE_LENGTH' file='parserInternals'>
+      <info>Maximum size allowed when XML_PARSE_HUGE is set.</info>
+    </macro>
     <macro name='XML_MAX_LOOKUP_LIMIT' file='parserInternals'>
       <info>Maximum size allowed by the parser for ahead lookup This is an upper boundary enforced by the parser to avoid bad behaviour on &quot;unfriendly&apos; content Introduced in 2.9.0</info>
     </macro>
     <macro name='XML_SUBSTITUTE_REF' file='parserInternals'>
       <info>Whether general entities need to be substituted.</info>
     </macro>
-    <macro name='XML_VCTXT_DTD_VALIDATED' file='valid'>
-      <info>Set after xmlValidateDtdFinal was called.</info>
-    </macro>
-    <macro name='XML_VCTXT_USE_PCTXT' file='valid'>
-      <info>Set if the validation context is part of a parser context.</info>
-    </macro>
     <macro name='XML_XML_ID' file='tree'>
       <info>This is the name for the special xml:id attribute</info>
     </macro>
     <macro name='XML_XPATH_NOVAR' file='xpath'>
       <info>forbid variables in expression</info>
     </macro>
-    <macro name='XPATH_LOCATIONSET' file='xpath'>
-    </macro>
-    <macro name='XPATH_POINT' file='xpath'>
-    </macro>
-    <macro name='XPATH_RANGE' file='xpath'>
-    </macro>
     <macro name='XP_ERROR' file='xpathInternals'>
       <info>Macro to raise an XPath error and return.</info>
       <arg name='X' info='the error code'/>
     <enum name='XML_BUFFER_ALLOC_DOUBLEIT' file='tree' value='1' type='xmlBufferAllocationScheme' info='double each time one need to grow'/>
     <enum name='XML_BUFFER_ALLOC_EXACT' file='tree' value='2' type='xmlBufferAllocationScheme' info='grow only to the minimal size'/>
     <enum name='XML_BUFFER_ALLOC_HYBRID' file='tree' value='5' type='xmlBufferAllocationScheme' info='exact up to a threshold, and doubleit thereafter'/>
-    <enum name='XML_BUFFER_ALLOC_IMMUTABLE' file='tree' value='3' type='xmlBufferAllocationScheme' info='immutable buffer'/>
+    <enum name='XML_BUFFER_ALLOC_IMMUTABLE' file='tree' value='3' type='xmlBufferAllocationScheme' info='immutable buffer, deprecated'/>
     <enum name='XML_BUFFER_ALLOC_IO' file='tree' value='4' type='xmlBufferAllocationScheme' info='special allocation scheme used for I/O'/>
     <enum name='XML_BUF_OVERFLOW' file='xmlerror' value='7000' type='xmlParserErrors'/>
     <enum name='XML_C14N_1_0' file='c14n' value='0' type='xmlC14NMode' info='Original C14N 1.0 spec'/>
@@ -4860,6 +4783,12 @@ and not by parsing an instance'/>
     <enum name='XML_ELEMENT_TYPE_EMPTY' file='tree' value='1' type='xmlElementTypeVal'/>
     <enum name='XML_ELEMENT_TYPE_MIXED' file='tree' value='3' type='xmlElementTypeVal'/>
     <enum name='XML_ELEMENT_TYPE_UNDEFINED' file='tree' value='0' type='xmlElementTypeVal'/>
+    <enum name='XML_ENC_ERR_INPUT' file='encoding' value='-2' type='xmlCharEncError'/>
+    <enum name='XML_ENC_ERR_INTERNAL' file='encoding' value='-4' type='xmlCharEncError'/>
+    <enum name='XML_ENC_ERR_MEMORY' file='encoding' value='-5' type='xmlCharEncError'/>
+    <enum name='XML_ENC_ERR_PARTIAL' file='encoding' value='-3' type='xmlCharEncError'/>
+    <enum name='XML_ENC_ERR_SPACE' file='encoding' value='-1' type='xmlCharEncError'/>
+    <enum name='XML_ENC_ERR_SUCCESS' file='encoding' value='0' type='xmlCharEncError'/>
     <enum name='XML_ENTITY_DECL' file='tree' value='17' type='xmlElementType'/>
     <enum name='XML_ENTITY_NODE' file='tree' value='6' type='xmlElementType'/>
     <enum name='XML_ENTITY_REF_NODE' file='tree' value='5' type='xmlElementType'/>
@@ -5115,7 +5044,7 @@ and not by parsing an instance'/>
     <enum name='XML_PARSER_MISC' file='parser' value='1' type='xmlParserInputState' info='Misc* before int subset'/>
     <enum name='XML_PARSER_PI' file='parser' value='2' type='xmlParserInputState' info='Within a processing instruction'/>
     <enum name='XML_PARSER_PROLOG' file='parser' value='4' type='xmlParserInputState' info='Misc* after internal subset'/>
-    <enum name='XML_PARSER_PUBLIC_LITERAL' file='parser' value='16' type='xmlParserInputState' info=' within a PUBLIC value'/>
+    <enum name='XML_PARSER_PUBLIC_LITERAL' file='parser' value='16' type='xmlParserInputState' info='within a PUBLIC value'/>
     <enum name='XML_PARSER_SEVERITY_ERROR' file='xmlreader' value='4' type='xmlParserSeverities'/>
     <enum name='XML_PARSER_SEVERITY_VALIDITY_ERROR' file='xmlreader' value='2' type='xmlParserSeverities'/>
     <enum name='XML_PARSER_SEVERITY_VALIDITY_WARNING' file='xmlreader' value='1' type='xmlParserSeverities'/>
@@ -5125,6 +5054,7 @@ and not by parsing an instance'/>
     <enum name='XML_PARSER_SUBST_ENTITIES' file='xmlreader' value='4' type='xmlParserProperties'/>
     <enum name='XML_PARSER_SYSTEM_LITERAL' file='parser' value='13' type='xmlParserInputState' info='within a SYSTEM value'/>
     <enum name='XML_PARSER_VALIDATE' file='xmlreader' value='3' type='xmlParserProperties'/>
+    <enum name='XML_PARSER_XML_DECL' file='parser' value='17' type='xmlParserInputState' info=' before XML decl (but after BOM)'/>
     <enum name='XML_PARSE_BIG_LINES' file='parser' value='4194304' type='xmlParserOption' info=' Store big lines numbers in text PSVI field'/>
     <enum name='XML_PARSE_COMPACT' file='parser' value='65536' type='xmlParserOption' info='compact small text nodes; no modification of
 the tree allowed afterwards (will possibly
@@ -5779,6 +5709,7 @@ crash if you try to modify the tree)'/>
     <enum name='XML_TREE_NOT_UTF8' file='xmlerror' value='1303' type='xmlParserErrors' info='1303'/>
     <enum name='XML_TREE_UNTERMINATED_ENTITY' file='xmlerror' value='1302' type='xmlParserErrors' info='1302'/>
     <enum name='XML_WAR_CATALOG_PI' file='xmlerror' value='93' type='xmlParserErrors' info='93'/>
+    <enum name='XML_WAR_ENCODING_MISMATCH' file='xmlerror' value='113' type='xmlParserErrors' info='113'/>
     <enum name='XML_WAR_ENTITY_REDEFINED' file='xmlerror' value='107' type='xmlParserErrors' info='107'/>
     <enum name='XML_WAR_LANG_VALUE' file='xmlerror' value='98' type='xmlParserErrors' info='98'/>
     <enum name='XML_WAR_NS_COLUMN' file='xmlerror' value='106' type='xmlParserErrors' info='106'/>
@@ -5975,6 +5906,7 @@ if necessary or NULL'/>
       <field name='atype' type='xmlAttributeType' info=' the attribute type if validating'/>
       <field name='psvi' type='void *' info=' for type/PSVI information'/>
     </struct>
+    <struct name='xmlAttrHashBucket' file='parser' type='struct _xmlAttrHashBucket'/>
     <typedef name='xmlAttrPtr' file='tree' type='xmlAttr *'/>
     <struct name='xmlAttribute' file='tree' type='struct _xmlAttribute'>
       <field name='_private' type='void *' info=' application data'/>
@@ -6045,6 +5977,7 @@ if necessary or NULL'/>
     <typedef name='xmlChar' file='xmlstring' type='unsigned char'>
       <info>This is a basic byte in an UTF-8 encoded string. It&apos;s unsigned allowing to pinpoint case where char * are assigned to xmlChar * (possibly making serialization back impossible).</info>
     </typedef>
+    <typedef name='xmlCharEncError' file='encoding' type='enum'/>
     <typedef name='xmlCharEncoding' file='encoding' type='enum'/>
     <struct name='xmlCharEncodingHandler' file='encoding' type='struct _xmlCharEncodingHandler'>
       <field name='name' type='char *' info=''/>
@@ -6091,12 +6024,11 @@ standalone attribute was specified'/>
       <field name='extSubset' type='struct _xmlDtd *' info=' the document external subset'/>
       <field name='oldNs' type='struct _xmlNs *' info=' Global namespace, the old way'/>
       <field name='version' type='const xmlChar *' info=' the XML version string'/>
-      <field name='encoding' type='const xmlChar *' info=' external initial encoding, if any'/>
+      <field name='encoding' type='const xmlChar *' info=' actual encoding, if any'/>
       <field name='ids' type='void *' info=' Hash table for ID attributes if any'/>
       <field name='refs' type='void *' info=' Hash table for IDREFs attributes if any'/>
       <field name='URL' type='const xmlChar *' info=' The URI for that document'/>
-      <field name='charset' type='int' info=' Internal flag for charset handling,
-actually an xmlCharEncoding'/>
+      <field name='charset' type='int' info=' unused'/>
       <field name='dict' type='struct _xmlDict *' info=' dict used to allocate names or NULL'/>
       <field name='psvi' type='void *' info=' for type/PSVI information'/>
       <field name='parseFlags' type='int' info=' set of xmlParserOption used to parse the
@@ -6180,9 +6112,8 @@ set at the end of parsing'/>
       <field name='nexte' type='struct _xmlEntity *' info=' unused'/>
       <field name='URI' type='const xmlChar *' info=' the full URI as computed'/>
       <field name='owner' type='int' info=' does the entity own the childrens'/>
-      <field name='checked' type='int' info=' was the entity content checked this is also used to count entities
-* references done from that entity
-* and if it contains &apos;&lt;&apos;'/>
+      <field name='flags' type='int' info=' various flags'/>
+      <field name='expandedSize' type='unsigned long' info=' expanded size'/>
     </struct>
     <typedef name='xmlEntityPtr' file='tree' type='xmlEntity *'/>
     <typedef name='xmlEntityType' file='entities' type='enum'/>
@@ -6215,41 +6146,7 @@ set at the end of parsing'/>
     <typedef name='xmlExpNodePtr' file='xmlregexp' type='xmlExpNode *'/>
     <typedef name='xmlExpNodeType' file='xmlregexp' type='enum'/>
     <typedef name='xmlFeature' file='parser' type='enum'/>
-    <struct name='xmlGlobalState' file='globals' type='struct _xmlGlobalState'>
-      <field name='xmlParserVersion' type='const char *' info=''/>
-      <field name='xmlDefaultSAXLocator' type='xmlSAXLocator' info=''/>
-      <field name='xmlDefaultSAXHandler' type='xmlSAXHandlerV1' info=''/>
-      <field name='docbDefaultSAXHandler' type='xmlSAXHandlerV1' info=' unused'/>
-      <field name='htmlDefaultSAXHandler' type='xmlSAXHandlerV1' info=''/>
-      <field name='xmlFree' type='xmlFreeFunc' info=''/>
-      <field name='xmlMalloc' type='xmlMallocFunc' info=''/>
-      <field name='xmlMemStrdup' type='xmlStrdupFunc' info=''/>
-      <field name='xmlRealloc' type='xmlReallocFunc' info=''/>
-      <field name='xmlGenericError' type='xmlGenericErrorFunc' info=''/>
-      <field name='xmlStructuredError' type='xmlStructuredErrorFunc' info=''/>
-      <field name='xmlGenericErrorContext' type='void *' info=''/>
-      <field name='oldXMLWDcompatibility' type='int' info=''/>
-      <field name='xmlBufferAllocScheme' type='xmlBufferAllocationScheme' info=''/>
-      <field name='xmlDefaultBufferSize' type='int' info=''/>
-      <field name='xmlSubstituteEntitiesDefaultValue' type='int' info=''/>
-      <field name='xmlDoValidityCheckingDefaultValue' type='int' info=''/>
-      <field name='xmlGetWarningsDefaultValue' type='int' info=''/>
-      <field name='xmlKeepBlanksDefaultValue' type='int' info=''/>
-      <field name='xmlLineNumbersDefaultValue' type='int' info=''/>
-      <field name='xmlLoadExtDtdDefaultValue' type='int' info=''/>
-      <field name='xmlParserDebugEntities' type='int' info=''/>
-      <field name='xmlPedanticParserDefaultValue' type='int' info=''/>
-      <field name='xmlSaveNoEmptyTags' type='int' info=''/>
-      <field name='xmlIndentTreeOutput' type='int' info=''/>
-      <field name='xmlTreeIndentString' type='const char *' info=''/>
-      <field name='xmlRegisterNodeDefaultValue' type='xmlRegisterNodeFunc' info=''/>
-      <field name='xmlDeregisterNodeDefaultValue' type='xmlDeregisterNodeFunc' info=''/>
-      <field name='xmlMallocAtomic' type='xmlMallocFunc' info=''/>
-      <field name='xmlLastError' type='xmlError' info=''/>
-      <field name='xmlParserInputBufferCreateFilenameValue' type='xmlParserInputBufferCreateFilenameFunc' info=''/>
-      <field name='xmlOutputBufferCreateFilenameValue' type='xmlOutputBufferCreateFilenameFunc' info=''/>
-      <field name='xmlStructuredErrorContext' type='void *' info=''/>
-    </struct>
+    <struct name='xmlGlobalState' file='globals' type='struct _xmlGlobalState'/>
     <typedef name='xmlGlobalStatePtr' file='globals' type='xmlGlobalState *'/>
     <struct name='xmlHashTable' file='hash' type='struct _xmlHashTable'/>
     <typedef name='xmlHashTablePtr' file='hash' type='xmlHashTable *'/>
@@ -6386,8 +6283,7 @@ set at the end of parsing'/>
       <field name='spaceTab' type='int *' info=' array of space infos'/>
       <field name='depth' type='int' info=' to prevent entity substitution loops'/>
       <field name='entity' type='xmlParserInputPtr' info=' used to check entities boundaries'/>
-      <field name='charset' type='int' info=' encoding of the in-memory content
-actually an xmlCharEncoding'/>
+      <field name='charset' type='int' info=' unused'/>
       <field name='nodelen' type='int' info=' Those two fields are there to'/>
       <field name='nodemem' type='int' info=' Speed up large node parsing'/>
       <field name='pedantic' type='int' info=' signal pedantic warnings'/>
@@ -6410,7 +6306,7 @@ actually an xmlCharEncoding'/>
       <field name='nsNr' type='int' info=' the number of inherited namespaces'/>
       <field name='nsMax' type='int' info=' the size of the arrays'/>
       <field name='nsTab' type='const xmlChar * *' info=' the array of prefix/namespace name'/>
-      <field name='attallocs' type='int *' info=' which attribute were allocated'/>
+      <field name='attallocs' type='unsigned *' info=' which attribute were allocated'/>
       <field name='pushTab' type='xmlStartTag *' info=' array of data for push'/>
       <field name='attsDefault' type='xmlHashTablePtr' info=' defaulted attributes if any'/>
       <field name='attsSpecial' type='xmlHashTablePtr' info=' non-CDATA attributes if any'/>
@@ -6425,7 +6321,7 @@ actually an xmlCharEncoding'/>
 *'/>
       <field name='lastError' type='xmlError' info=''/>
       <field name='parseMode' type='xmlParserMode' info=' the parser mode'/>
-      <field name='nbentities' type='unsigned long' info=' number of entities references'/>
+      <field name='nbentities' type='unsigned long' info=' unused'/>
       <field name='sizeentities' type='unsigned long' info=' size of parsed entities for use by HTML non-recursive parser'/>
       <field name='nodeInfo' type='xmlParserNodeInfo *' info=' Current NodeInfo'/>
       <field name='nodeInfoNr' type='int' info=' Depth of the parsing stack'/>
@@ -6433,6 +6329,13 @@ actually an xmlCharEncoding'/>
       <field name='nodeInfoTab' type='xmlParserNodeInfo *' info=' array of nodeInfos'/>
       <field name='input_id' type='int' info=' we need to label inputs'/>
       <field name='sizeentcopy' type='unsigned long' info=' volume of entity copy'/>
+      <field name='endCheckState' type='int' info=' quote state for push parser'/>
+      <field name='nbErrors' type='unsigned short' info=' number of errors'/>
+      <field name='nbWarnings' type='unsigned short' info=' number of warnings'/>
+      <field name='maxAmpl' type='unsigned' info=' maximum amplification factor'/>
+      <field name='nsdb' type='xmlParserNsData *' info=' namespace database'/>
+      <field name='attrHashMax' type='unsigned' info=' allocated size'/>
+      <field name='attrHash' type='xmlAttrHashBucket *' info=' atttribute hash table'/>
     </struct>
     <typedef name='xmlParserCtxtPtr' file='tree' type='xmlParserCtxt *'/>
     <typedef name='xmlParserErrors' file='xmlerror' type='enum'/>
@@ -6445,16 +6348,15 @@ actually an xmlCharEncoding'/>
       <field name='end' type='const xmlChar *' info=' end of the array to parse'/>
       <field name='length' type='int' info=' length if known'/>
       <field name='line' type='int' info=' Current line'/>
-      <field name='col' type='int' info='* NOTE: consumed is only tested for equality in the parser code,
-*       so even if there is an overflow this should not give troubles
-*       for parsing very large instances.
-*'/>
+      <field name='col' type='int' info=' Current column'/>
       <field name='consumed' type='unsigned long' info=' How many xmlChars already consumed'/>
       <field name='free' type='xmlParserInputDeallocate' info=' function to deallocate the base'/>
-      <field name='encoding' type='const xmlChar *' info=' the encoding string for entity'/>
+      <field name='encoding' type='const xmlChar *' info=' unused'/>
       <field name='version' type='const xmlChar *' info=' the version string for entity'/>
-      <field name='standalone' type='int' info=' Was that entity marked standalone'/>
+      <field name='flags' type='int' info=' Flags'/>
       <field name='id' type='int' info=' an unique identifier for the entity'/>
+      <field name='parentConsumed' type='unsigned long' info=' consumed bytes from parents'/>
+      <field name='entity' type='xmlEntityPtr' info=' entity, if any'/>
     </struct>
     <struct name='xmlParserInputBuffer' file='tree' type='struct _xmlParserInputBuffer'>
       <field name='context' type='void *' info=''/>
@@ -6485,6 +6387,7 @@ actually an xmlCharEncoding'/>
       <field name='buffer' type='xmlParserNodeInfo *' info=''/>
     </struct>
     <typedef name='xmlParserNodeInfoSeqPtr' file='parser' type='xmlParserNodeInfoSeq *'/>
+    <struct name='xmlParserNsData' file='parser' type='struct _xmlParserNsData'/>
     <typedef name='xmlParserOption' file='parser' type='enum'/>
     <typedef name='xmlParserProperties' file='xmlreader' type='enum'/>
     <typedef name='xmlParserSeverities' file='xmlreader' type='enum'/>
@@ -6948,7 +6851,7 @@ Could we use @subtypes for this?'/>
       <field name='comp' type='xmlXPathCompExprPtr' info=' the precompiled expression'/>
       <field name='xptr' type='int' info=' it this an XPointer expression'/>
       <field name='ancestor' type='xmlNodePtr' info=' used for walking preceding axis'/>
-      <field name='valueFrame' type='int' info=' used to limit Pop on the stack'/>
+      <field name='valueFrame' type='int' info=' always zero for compatibility'/>
     </struct>
     <typedef name='xmlXPathParserContextPtr' file='xpath' type='xmlXPathParserContext *'/>
     <struct name='xmlXPathType' file='xpath' type='struct _xmlXPathType'>
@@ -6963,19 +6866,9 @@ Could we use @subtypes for this?'/>
     <typedef name='xmlXPathVariablePtr' file='xpath' type='xmlXPathVariable *'/>
     <variable name='emptyExp' file='xmlregexp' type='xmlExpNodePtr'/>
     <variable name='forbiddenExp' file='xmlregexp' type='xmlExpNodePtr'/>
-    <variable name='htmlDefaultSAXHandler' file='globals' type='xmlSAXHandlerV1'/>
-    <variable name='oldXMLWDcompatibility' file='globals' type='int'/>
-    <variable name='xmlBufferAllocScheme' file='globals' type='xmlBufferAllocationScheme'/>
-    <variable name='xmlDefaultBufferSize' file='globals' type='int'/>
-    <variable name='xmlDefaultSAXHandler' file='globals' type='xmlSAXHandlerV1'/>
-    <variable name='xmlDefaultSAXLocator' file='globals' type='xmlSAXLocator'/>
-    <variable name='xmlDeregisterNodeDefaultValue' file='globals' type='xmlDeregisterNodeFunc'/>
-    <variable name='xmlDoValidityCheckingDefaultValue' file='globals' type='int'/>
-    <variable name='xmlFree' file='globals' type='xmlFreeFunc'/>
-    <variable name='xmlGenericError' file='globals' type='xmlGenericErrorFunc'/>
-    <variable name='xmlGenericErrorContext' file='globals' type='void *'/>
-    <variable name='xmlGetWarningsDefaultValue' file='globals' type='int'/>
-    <variable name='xmlIndentTreeOutput' file='globals' type='int'/>
+    <variable name='xmlFree' file='xmlmemory' type='xmlFreeFunc'>
+      <info>@mem: an already allocated block of memory  The variable holding the libxml free() implementation</info>
+    </variable>
     <variable name='xmlIsBaseCharGroup' file='chvalid' type='const xmlChRangeGroup'/>
     <variable name='xmlIsCharGroup' file='chvalid' type='const xmlChRangeGroup'/>
     <variable name='xmlIsCombiningGroup' file='chvalid' type='const xmlChRangeGroup'/>
@@ -6983,29 +6876,27 @@ Could we use @subtypes for this?'/>
     <variable name='xmlIsExtenderGroup' file='chvalid' type='const xmlChRangeGroup'/>
     <variable name='xmlIsIdeographicGroup' file='chvalid' type='const xmlChRangeGroup'/>
     <variable name='xmlIsPubidChar_tab' file='chvalid' type='const unsigned charxmlIsPubidChar_tab[256]'/>
-    <variable name='xmlKeepBlanksDefaultValue' file='globals' type='int'/>
-    <variable name='xmlLastError' file='globals' type='xmlError'/>
-    <variable name='xmlLineNumbersDefaultValue' file='globals' type='int'/>
-    <variable name='xmlLoadExtDtdDefaultValue' file='globals' type='int'/>
-    <variable name='xmlMalloc' file='globals' type='xmlMallocFunc'/>
-    <variable name='xmlMallocAtomic' file='globals' type='xmlMallocFunc'/>
-    <variable name='xmlMemStrdup' file='globals' type='xmlStrdupFunc'/>
-    <variable name='xmlOutputBufferCreateFilenameValue' file='globals' type='xmlOutputBufferCreateFilenameFunc'/>
-    <variable name='xmlParserDebugEntities' file='globals' type='int'/>
-    <variable name='xmlParserInputBufferCreateFilenameValue' file='globals' type='xmlParserInputBufferCreateFilenameFunc'/>
-    <variable name='xmlParserMaxDepth' file='parserInternals' type='unsigned int'/>
-    <variable name='xmlParserVersion' file='globals' type='const char *'/>
-    <variable name='xmlPedanticParserDefaultValue' file='globals' type='int'/>
-    <variable name='xmlRealloc' file='globals' type='xmlReallocFunc'/>
-    <variable name='xmlRegisterNodeDefaultValue' file='globals' type='xmlRegisterNodeFunc'/>
-    <variable name='xmlSaveNoEmptyTags' file='globals' type='int'/>
+    <variable name='xmlMalloc' file='xmlmemory' type='xmlMallocFunc'>
+      <info>@size:  the size requested in bytes  The variable holding the libxml malloc() implementation  Returns a pointer to the newly allocated block or NULL in case of error</info>
+    </variable>
+    <variable name='xmlMallocAtomic' file='xmlmemory' type='xmlMallocFunc'>
+      <info>@size:  the size requested in bytes  The variable holding the libxml malloc() implementation for atomic data (i.e. blocks not containing pointers), useful when using a garbage collecting allocator.  Returns a pointer to the newly allocated block or NULL in case of error</info>
+    </variable>
+    <variable name='xmlMemStrdup' file='xmlmemory' type='xmlStrdupFunc'>
+      <info>@str: a zero terminated string  The variable holding the libxml strdup() implementation  Returns the copy of the string or NULL in case of error</info>
+    </variable>
+    <variable name='xmlParserMaxDepth' file='parserInternals' type='unsigned int'>
+      <info>arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature. It can be disabled with the XML_PARSE_HUGE parser option.</info>
+    </variable>
+    <variable name='xmlParserVersion' file='parser' type='const char * const'>
+      <info>Constant string describing the internal version of the library</info>
+    </variable>
+    <variable name='xmlRealloc' file='xmlmemory' type='xmlReallocFunc'>
+      <info>@mem: an already allocated block of memory @size:  the new size requested in bytes  The variable holding the libxml realloc() implementation  Returns a pointer to the newly reallocated block or NULL in case of error</info>
+    </variable>
     <variable name='xmlStringComment' file='parserInternals' type='const xmlCharxmlStringComment[]'/>
     <variable name='xmlStringText' file='parserInternals' type='const xmlCharxmlStringText[]'/>
     <variable name='xmlStringTextNoenc' file='parserInternals' type='const xmlCharxmlStringTextNoenc[]'/>
-    <variable name='xmlStructuredError' file='globals' type='xmlStructuredErrorFunc'/>
-    <variable name='xmlStructuredErrorContext' file='globals' type='void *'/>
-    <variable name='xmlSubstituteEntitiesDefaultValue' file='globals' type='int'/>
-    <variable name='xmlTreeIndentString' file='globals' type='const char *'/>
     <variable name='xmlXPathNAN' file='xpath' type='double'/>
     <variable name='xmlXPathNINF' file='xpath' type='double'/>
     <variable name='xmlXPathPINF' file='xpath' type='double'/>
@@ -7021,7 +6912,7 @@ Could we use @subtypes for this?'/>
     <function name='UTF8Toisolat1' file='encoding' module='encoding'>
       <cond>defined(LIBXML_OUTPUT_ENABLED)</cond>
       <info>Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1 block of chars out.</info>
-      <return type='int' info='the number of bytes written if success, -2 if the transcoding fails, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.'/>
+      <return type='int' info='the number of bytes written or an XML_ENC_ERR code.  The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.'/>
       <arg name='out' type='unsigned char *' info='a pointer to an array of bytes to store the result'/>
       <arg name='outlen' type='int *' info='the length of @out'/>
       <arg name='in' type='const unsigned char *' info='a pointer to an array of UTF-8 chars'/>
@@ -7343,7 +7234,7 @@ Could we use @subtypes for this?'/>
       <arg name='name' type='const xmlChar *' info='The tag name'/>
       <arg name='elem' type='htmlNodePtr' info='the HTML element'/>
     </function>
-    <function name='htmlCreateFileParserCtxt' file='parserInternals' module='HTMLparser'>
+    <function name='htmlCreateFileParserCtxt' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
       <info>Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</info>
       <return type='htmlParserCtxtPtr' info='the new parser context or NULL'/>
@@ -7373,7 +7264,7 @@ Could we use @subtypes for this?'/>
       <info>parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context</info>
       <return type='htmlDocPtr' info='the resulting document tree'/>
       <arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
-      <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='str' type='const xmlChar *' info='a pointer to a zero terminated string'/>
       <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of htmlParserOption(s)'/>
@@ -7435,7 +7326,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='htmlDefaultSAXHandlerInit' file='SAX2' module='SAX2'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Initialize the default SAX handler</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlInitParser to initialize the library.</info>
       <return type='void'/>
     </function>
     <function name='htmlDocContentDumpFormatOutput' file='HTMLtree' module='HTMLtree'>
@@ -7533,9 +7424,9 @@ Could we use @subtypes for this?'/>
       <return type='int' info='the last value for 0 for no handling, 1 for auto insertion.'/>
       <arg name='val' type='int' info='int 0 or 1'/>
     </function>
-    <function name='htmlInitAutoClose' file='parserInternals' module='HTMLparser'>
+    <function name='htmlInitAutoClose' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  This is a no-op now.</info>
+      <info>DEPRECATED: This is a no-op.</info>
       <return type='void'/>
     </function>
     <function name='htmlIsAutoClosed' file='HTMLparser' module='HTMLparser'>
@@ -7576,6 +7467,13 @@ Could we use @subtypes for this?'/>
       <info>Allocate and initialize a new parser context.</info>
       <return type='htmlParserCtxtPtr' info='the htmlParserCtxtPtr or NULL in case of allocation error'/>
     </function>
+    <function name='htmlNewSAXParserCtxt' file='HTMLparser' module='HTMLparser'>
+      <cond>defined(LIBXML_HTML_ENABLED)</cond>
+      <info>Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.</info>
+      <return type='htmlParserCtxtPtr' info='the htmlParserCtxtPtr or NULL in case of allocation error'/>
+      <arg name='sax' type='const htmlSAXHandler *' info='SAX handler'/>
+      <arg name='userData' type='void *' info='user data'/>
+    </function>
     <function name='htmlNodeDump' file='HTMLtree' module='HTMLtree'>
       <cond>defined(LIBXML_HTML_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
       <info>Dump an HTML node, recursive behaviour,children are printed too, and formatting returns are added.</info>
@@ -7630,7 +7528,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='htmlParseCharRef' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>parse Reference declarations  [66] CharRef ::= &apos;&amp;#&apos; [0-9]+ &apos;;&apos; | &apos;&amp;#x&apos; [0-9a-fA-F]+ &apos;;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse Reference declarations  [66] CharRef ::= &apos;&amp;#&apos; [0-9]+ &apos;;&apos; | &apos;&amp;#x&apos; [0-9a-fA-F]+ &apos;;&apos;</info>
       <return type='int' info='the value parsed (as an int)'/>
       <arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
     </function>
@@ -7658,13 +7556,13 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='htmlParseElement' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>parse an HTML element, this is highly recursive this is kept for compatibility with previous code versions  [39] element ::= EmptyElemTag | STag content ETag  [41] Attribute ::= Name Eq AttValue</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an HTML element, this is highly recursive this is kept for compatibility with previous code versions  [39] element ::= EmptyElemTag | STag content ETag  [41] Attribute ::= Name Eq AttValue</info>
       <return type='void'/>
       <arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
     </function>
     <function name='htmlParseEntityRef' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>parse an HTML ENTITY references  [68] EntityRef ::= &apos;&amp;&apos; Name &apos;;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an HTML ENTITY references  [68] EntityRef ::= &apos;&amp;&apos; Name &apos;;&apos;</info>
       <return type='const htmlEntityDesc *' info='the associated htmlEntityDescPtr if found, or NULL otherwise, if non-NULL *str will have to be freed by the caller.'/>
       <arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
       <arg name='str' type='const xmlChar **' info='location to store the entity name'/>
@@ -7725,7 +7623,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='htmlSAXParseDoc' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</info>
+      <info>DEPRECATED: Use htmlNewSAXParserCtxt and htmlCtxtReadDoc.  Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks to handle parse events. If sax is NULL, fallback to the default DOM behavior and return a tree.</info>
       <return type='htmlDocPtr' info='the resulting document tree unless SAX is NULL or the document is not well formed.'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
       <arg name='encoding' type='const char *' info='a free form C string describing the HTML document encoding, or NULL'/>
@@ -7734,7 +7632,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='htmlSAXParseFile' file='HTMLparser' module='HTMLparser'>
       <cond>defined(LIBXML_HTML_ENABLED)</cond>
-      <info>parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
+      <info>DEPRECATED: Use htmlNewSAXParserCtxt and htmlCtxtReadFile.  parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
       <return type='htmlDocPtr' info='the resulting document tree unless SAX is NULL or the document is not well formed.'/>
       <arg name='filename' type='const char *' info='the filename'/>
       <arg name='encoding' type='const char *' info='a free form C string describing the HTML document encoding, or NULL'/>
@@ -7794,7 +7692,7 @@ Could we use @subtypes for this?'/>
       <arg name='len' type='int' info='the number of xmlChar'/>
     </functype>
     <function name='initGenericErrorDefaultFunc' file='xmlerror' module='error'>
-      <info>Set or reset (if NULL) the default handler for generic errors to the builtin error function.</info>
+      <info>DEPRECATED: Use xmlSetGenericErrorFunc.  Set or reset (if NULL) the default handler for generic errors to the builtin error function.</info>
       <return type='void'/>
       <arg name='handler' type='xmlGenericErrorFunc *' info='the handler'/>
     </function>
@@ -7852,19 +7750,19 @@ Could we use @subtypes for this?'/>
     </functype>
     <function name='isolat1ToUTF8' file='encoding' module='encoding'>
       <info>Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8 block of chars out.</info>
-      <return type='int' info='the number of bytes written if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.'/>
+      <return type='int' info='the number of bytes written or an XML_ENC_ERR code.  The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.'/>
       <arg name='out' type='unsigned char *' info='a pointer to an array of bytes to store the result'/>
       <arg name='outlen' type='int *' info='the length of @out'/>
       <arg name='in' type='const unsigned char *' info='a pointer to an array of ISO Latin 1 chars'/>
       <arg name='inlen' type='int *' info='the length of @in'/>
     </function>
     <function name='namePop' file='parserInternals' module='parser'>
-      <info>Pops the top element name from the name stack</info>
+      <info>DEPRECATED: Internal function, do not use.  Pops the top element name from the name stack</info>
       <return type='const xmlChar *' info='the name just removed'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='namePush' file='parserInternals' module='parser'>
-      <info>Pushes a new element name on top of the name stack</info>
+      <info>DEPRECATED: Internal function, do not use.  Pushes a new element name on top of the name stack</info>
       <return type='int' info='-1 in case of error, the index in the stack otherwise'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='value' type='const xmlChar *' info='the element name'/>
@@ -7878,12 +7776,12 @@ Could we use @subtypes for this?'/>
       <arg name='prefix' type='const xmlChar *' info='the namespace prefix'/>
     </function>
     <function name='nodePop' file='parserInternals' module='parser'>
-      <info>Pops the top element node from the node stack</info>
+      <info>DEPRECATED: Internal function, do not use.  Pops the top element node from the node stack</info>
       <return type='xmlNodePtr' info='the node just removed'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='nodePush' file='parserInternals' module='parser'>
-      <info>Pushes a new element node on top of the node stack</info>
+      <info>DEPRECATED: Internal function, do not use.  Pushes a new element node on top of the node stack</info>
       <return type='int' info='-1 in case of error, the index in the stack otherwise'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='value' type='xmlNodePtr' info='the element node'/>
@@ -8035,7 +7933,7 @@ Could we use @subtypes for this?'/>
     <function name='valuePush' file='xpathInternals' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
       <info>Pushes a new XPath object on top of the value stack. If value is NULL, a memory error is recorded in the parser context.</info>
-      <return type='int' info='the number of items on the value stack, or -1 in case of error.'/>
+      <return type='int' info='the number of items on the value stack, or -1 in case of error.  The object is destroyed in case of error.'/>
       <arg name='ctxt' type='xmlXPathParserContextPtr' info='an XPath evaluation context'/>
       <arg name='value' type='xmlXPathObjectPtr' info='the XPath object'/>
     </function>
@@ -8539,8 +8437,8 @@ Could we use @subtypes for this?'/>
       <arg name='size' type='size_t' info='initial size of buffer'/>
     </function>
     <function name='xmlBufferCreateStatic' file='tree' module='tree'>
-      <info>routine to create an XML buffer from an immutable memory area. The area won&apos;t be modified nor copied, and is expected to be present until the end of the buffer lifetime.</info>
-      <return type='xmlBufferPtr' info='the new structure.'/>
+      <info></info>
+      <return type='xmlBufferPtr' info='an XML buffer initialized with bytes.'/>
       <arg name='mem' type='void *' info='the memory area'/>
       <arg name='size' type='size_t' info='the size in byte'/>
     </function>
@@ -8638,7 +8536,7 @@ Could we use @subtypes for this?'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlC14NDocDumpMemory' file='c14n' module='c14n'>
-      <cond>defined(LIBXML_C14N_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
+      <cond>defined(LIBXML_C14N_ENABLED)</cond>
       <info>Dumps the canonized image of given XML document into memory. For details see &quot;Canonical XML&quot; (http://www.w3.org/TR/xml-c14n) or &quot;Exclusive XML Canonicalization&quot; (http://www.w3.org/TR/xml-exc-c14n)</info>
       <return type='int' info='the number of bytes written on success or a negative value on fail'/>
       <arg name='doc' type='xmlDocPtr' info='the XML document for canonization'/>
@@ -8649,7 +8547,7 @@ Could we use @subtypes for this?'/>
       <arg name='doc_txt_ptr' type='xmlChar **' info='the memory pointer for allocated canonical XML text; the caller of this functions is responsible for calling xmlFree() to free allocated memory'/>
     </function>
     <function name='xmlC14NDocSave' file='c14n' module='c14n'>
-      <cond>defined(LIBXML_C14N_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
+      <cond>defined(LIBXML_C14N_ENABLED)</cond>
       <info>Dumps the canonized image of given XML document into the file. For details see &quot;Canonical XML&quot; (http://www.w3.org/TR/xml-c14n) or &quot;Exclusive XML Canonicalization&quot; (http://www.w3.org/TR/xml-exc-c14n)</info>
       <return type='int' info='the number of bytes written success or a negative value on fail'/>
       <arg name='doc' type='xmlDocPtr' info='the XML document for canonization'/>
@@ -8661,7 +8559,7 @@ Could we use @subtypes for this?'/>
       <arg name='compression' type='int' info='the compression level (zlib required): -1 - libxml default, 0 - uncompressed, &gt;0 - compression level'/>
     </function>
     <function name='xmlC14NDocSaveTo' file='c14n' module='c14n'>
-      <cond>defined(LIBXML_C14N_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
+      <cond>defined(LIBXML_C14N_ENABLED)</cond>
       <info>Dumps the canonized image of given XML document into the provided buffer. For details see &quot;Canonical XML&quot; (http://www.w3.org/TR/xml-c14n) or &quot;Exclusive XML Canonicalization&quot; (http://www.w3.org/TR/xml-exc-c14n)</info>
       <return type='int' info='non-negative value on success or a negative value on fail'/>
       <arg name='doc' type='xmlDocPtr' info='the XML document for canonization'/>
@@ -8672,7 +8570,7 @@ Could we use @subtypes for this?'/>
       <arg name='buf' type='xmlOutputBufferPtr' info='the output buffer to store canonical XML; this buffer MUST have encoder==NULL because C14N requires UTF-8 output'/>
     </function>
     <function name='xmlC14NExecute' file='c14n' module='c14n'>
-      <cond>defined(LIBXML_C14N_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
+      <cond>defined(LIBXML_C14N_ENABLED)</cond>
       <info>Dumps the canonized image of given XML document into the provided buffer. For details see &quot;Canonical XML&quot; (http://www.w3.org/TR/xml-c14n) or &quot;Exclusive XML Canonicalization&quot; (http://www.w3.org/TR/xml-exc-c14n)</info>
       <return type='int' info='non-negative value on success or a negative value on fail'/>
       <arg name='doc' type='xmlDocPtr' info='the XML document for canonization'/>
@@ -8684,7 +8582,7 @@ Could we use @subtypes for this?'/>
       <arg name='buf' type='xmlOutputBufferPtr' info='the output buffer to store canonical XML; this buffer MUST have encoder==NULL because C14N requires UTF-8 output'/>
     </function>
     <functype name='xmlC14NIsVisibleCallback' file='c14n' module='c14n'>
-      <cond>defined(LIBXML_C14N_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
+      <cond>defined(LIBXML_C14N_ENABLED)</cond>
       <info>Signature for a C14N callback on visible nodes</info>
       <return type='int' info='1 if the node should be included'/>
       <arg name='user_data' type='void *' info='user data'/>
@@ -8826,22 +8724,22 @@ Could we use @subtypes for this?'/>
       <arg name='handler' type='xmlCharEncodingHandler *' info='char encoding transformation data structure'/>
     </function>
     <function name='xmlCharEncFirstLine' file='encoding' module='encoding'>
-      <info>Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.</info>
-      <return type='int' info='the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can&apos;t fit into the encoding we want), or'/>
+      <info>DEPERECATED: Don&apos;t use.</info>
+      <return type='int' info='the number of bytes written or an XML_ENC_ERR code.'/>
       <arg name='handler' type='xmlCharEncodingHandler *' info='char encoding transformation data structure'/>
       <arg name='out' type='xmlBufferPtr' info='an xmlBuffer for the output.'/>
       <arg name='in' type='xmlBufferPtr' info='an xmlBuffer for the input'/>
     </function>
     <function name='xmlCharEncInFunc' file='encoding' module='encoding'>
       <info>Generic front-end for the encoding handler input function</info>
-      <return type='int' info='the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can&apos;t fit into the encoding we want), or'/>
+      <return type='int' info='the number of bytes written or an XML_ENC_ERR code.'/>
       <arg name='handler' type='xmlCharEncodingHandler *' info='char encoding transformation data structure'/>
       <arg name='out' type='xmlBufferPtr' info='an xmlBuffer for the output.'/>
       <arg name='in' type='xmlBufferPtr' info='an xmlBuffer for the input'/>
     </function>
     <function name='xmlCharEncOutFunc' file='encoding' module='encoding'>
       <info>Generic front-end for the encoding handler output function a first call with @in == NULL has to be made firs to initiate the output in case of non-stateless encoding needing to initiate their state or the output (like the BOM in UTF16). In case of UTF8 sequence conversion errors for the given encoder, the content will be automatically remapped to a CharRef sequence.</info>
-      <return type='int' info='the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can&apos;t fit into the encoding we want), or'/>
+      <return type='int' info='the number of bytes written or an XML_ENC_ERR code.'/>
       <arg name='handler' type='xmlCharEncodingHandler *' info='char encoding transformation data structure'/>
       <arg name='out' type='xmlBufferPtr' info='an xmlBuffer for the output.'/>
       <arg name='in' type='xmlBufferPtr' info='an xmlBuffer for the input'/>
@@ -8891,10 +8789,14 @@ Could we use @subtypes for this?'/>
       <arg name='ret' type='xmlParserInputPtr' info='an XML parser input'/>
     </function>
     <function name='xmlCheckLanguageID' file='parserInternals' module='parser'>
-      <info>Checks that the value conforms to the LanguageID production:  NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition.  [33] LanguageID ::= Langcode (&apos;-&apos; Subcode)* [34] Langcode ::= ISO639Code |  IanaCode |  UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= (&apos;i&apos; | &apos;I&apos;) &apos;-&apos; ([a-z] | [A-Z])+ [37] UserCode ::= (&apos;x&apos; | &apos;X&apos;) &apos;-&apos; ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+  The current REC reference the successors of RFC 1766, currently 5646  http://www.rfc-editor.org/rfc/rfc5646.txt langtag       = language [&quot;-&quot; script] [&quot;-&quot; region] *(&quot;-&quot; variant) *(&quot;-&quot; extension) [&quot;-&quot; privateuse] language      = 2*3ALPHA            ; shortest ISO 639 code [&quot;-&quot; extlang]       ; sometimes followed by ; extended language subtags / 4ALPHA              ; or reserved for future use / 5*8ALPHA            ; or registered language subtag  extlang       = 3ALPHA              ; selected ISO 639 codes *2(&quot;-&quot; 3ALPHA)      ; permanently reserved  script        = 4ALPHA              ; ISO 15924 code  region        = 2ALPHA              ; ISO 3166-1 code / 3DIGIT              ; UN M.49 code  variant       = 5*8alphanum         ; registered variants / (DIGIT 3alphanum)  extension     = singleton 1*(&quot;-&quot; (2*8alphanum))  ; Single alphanumerics ; &quot;x&quot; reserved for private use singleton     = DIGIT               ; 0 - 9 / %x41-57             ; A - W / %x59-5A             ; Y - Z / %x61-77             ; a - w / %x79-7A             ; y - z  it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn&apos;t try to cope with extension or privateuse that could be added but that&apos;s not interoperable anyway</info>
+      <info>DEPRECATED: Internal function, do not use.  Checks that the value conforms to the LanguageID production:  NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition.  [33] LanguageID ::= Langcode (&apos;-&apos; Subcode)* [34] Langcode ::= ISO639Code |  IanaCode |  UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= (&apos;i&apos; | &apos;I&apos;) &apos;-&apos; ([a-z] | [A-Z])+ [37] UserCode ::= (&apos;x&apos; | &apos;X&apos;) &apos;-&apos; ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+  The current REC reference the successors of RFC 1766, currently 5646  http://www.rfc-editor.org/rfc/rfc5646.txt langtag       = language [&quot;-&quot; script] [&quot;-&quot; region] *(&quot;-&quot; variant) *(&quot;-&quot; extension) [&quot;-&quot; privateuse] language      = 2*3ALPHA            ; shortest ISO 639 code [&quot;-&quot; extlang]       ; sometimes followed by ; extended language subtags / 4ALPHA              ; or reserved for future use / 5*8ALPHA            ; or registered language subtag  extlang       = 3ALPHA              ; selected ISO 639 codes *2(&quot;-&quot; 3ALPHA)      ; permanently reserved  script        = 4ALPHA              ; ISO 15924 code  region        = 2ALPHA              ; ISO 3166-1 code / 3DIGIT              ; UN M.49 code  variant       = 5*8alphanum         ; registered variants / (DIGIT 3alphanum)  extension     = singleton 1*(&quot;-&quot; (2*8alphanum))  ; Single alphanumerics ; &quot;x&quot; reserved for private use singleton     = DIGIT               ; 0 - 9 / %x41-57             ; A - W / %x59-5A             ; Y - Z / %x61-77             ; a - w / %x79-7A             ; y - z  it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn&apos;t try to cope with extension or privateuse that could be added but that&apos;s not interoperable anyway</info>
       <return type='int' info='1 if correct 0 otherwise'/>
       <arg name='lang' type='const xmlChar *' info='pointer to the string value'/>
     </function>
+    <function name='xmlCheckThreadLocalStorage' file='threads' module='globals'>
+      <info>Check whether thread-local storage could be allocated.  In cross-platform code running in multithreaded environments, this function should be called once in each thread before calling other library functions to make sure that thread-local storage was allocated properly.</info>
+      <return type='int' info='0 on success or -1 if a memory allocation failed. A failed allocation signals a typically fatal and irrecoverable out-of-memory situation. Don&apos;t call any library functions in this case.  This function never fails if the library is compiled with support for thread-local storage.  This function never fails for the &quot;main&quot; thread which is the first thread calling xmlInitParser.  Available since v2.12.0.'/>
+    </function>
     <function name='xmlCheckUTF8' file='xmlstring' module='xmlstring'>
       <info>Checks @utf for being valid UTF-8. @utf is assumed to be null-terminated. This function is not super-strict, as it will allow longer UTF-8 sequences than necessary. Note that Java is capable of producing these sequences if provoked. Also note, this routine checks for the 4-byte maximum size, but does not check for 0x10ffff maximum value.</info>
       <return type='int' info='value: true if @utf is valid.'/>
@@ -8920,7 +8822,7 @@ Could we use @subtypes for this?'/>
       <return type='void'/>
     </function>
     <function name='xmlCleanupGlobals' file='globals' module='globals'>
-      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.  Additional cleanup for multi-threading</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.</info>
       <return type='void'/>
     </function>
     <function name='xmlCleanupInputCallbacks' file='xmlIO' module='xmlIO'>
@@ -8928,7 +8830,7 @@ Could we use @subtypes for this?'/>
       <return type='void'/>
     </function>
     <function name='xmlCleanupMemory' file='xmlmemory' module='xmlmemory'>
-      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.  Free up all the memory allocated by the library for its own use. This should not be called by user level code.</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.</info>
       <return type='void'/>
     </function>
     <function name='xmlCleanupOutputCallbacks' file='xmlIO' module='xmlIO'>
@@ -8936,7 +8838,7 @@ Could we use @subtypes for this?'/>
       <info>clears the entire output callback table. this includes the compiled-in I/O callbacks.</info>
       <return type='void'/>
     </function>
-    <function name='xmlCleanupParser' file='parser' module='parser'>
+    <function name='xmlCleanupParser' file='parser' module='threads'>
       <info>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&apos;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.  WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It&apos;s sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !</info>
       <return type='void'/>
     </function>
@@ -8946,11 +8848,11 @@ Could we use @subtypes for this?'/>
       <return type='void'/>
     </function>
     <function name='xmlCleanupThreads' file='threads' module='threads'>
-      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.  xmlCleanupThreads() is used to to cleanup all the thread related data of the libxml2 library once processing has ended.  WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It&apos;s sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.</info>
       <return type='void'/>
     </function>
     <function name='xmlClearNodeInfoSeq' file='parser' module='parserInternals'>
-      <info>-- Clear (release memory and reinitialize) node info sequence</info>
+      <info>DEPRECATED: Don&apos;t use.  -- Clear (release memory and reinitialize) node info sequence</info>
       <return type='void'/>
       <arg name='seq' type='xmlParserNodeInfoSeqPtr' info='a node info sequence pointer'/>
     </function>
@@ -9029,7 +8931,7 @@ Could we use @subtypes for this?'/>
     <function name='xmlCopyError' file='xmlerror' module='error'>
       <info>Save the original error to the new place.</info>
       <return type='int' info='0 in case of success and -1 in case of error.'/>
-      <arg name='from' type='xmlErrorPtr' info='a source error'/>
+      <arg name='from' type='const xmlError *' info='a source error'/>
       <arg name='to' type='xmlErrorPtr' info='a target error'/>
     </function>
     <function name='xmlCopyNamespace' file='tree' module='tree'>
@@ -9074,7 +8976,7 @@ Could we use @subtypes for this?'/>
     <function name='xmlCreateDocParserCtxt' file='parser' module='parser'>
       <info>Creates a parser context for an XML in-memory document.</info>
       <return type='xmlParserCtxtPtr' info='the new parser context or NULL'/>
-      <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
+      <arg name='str' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
     </function>
     <function name='xmlCreateEntitiesTable' file='entities' module='entities'>
       <info>create and initialize an empty entities hash table. This really doesn&apos;t make sense and should be deprecated</info>
@@ -9143,14 +9045,14 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlCtxtGetLastError' file='xmlerror' module='error'>
       <info>Get the last parsing error registered.</info>
-      <return type='xmlErrorPtr' info='NULL if no error occurred or a pointer to the error'/>
+      <return type='const xmlError *' info='NULL if no error occurred or a pointer to the error'/>
       <arg name='ctx' type='void *' info='an XML parser context'/>
     </function>
     <function name='xmlCtxtReadDoc' file='parser' module='parser'>
       <info>parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
-      <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='str' type='const xmlChar *' info='a pointer to a zero terminated string'/>
       <arg name='URL' type='const char *' info='the base URL to use for the document'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption'/>
@@ -9212,6 +9114,12 @@ Could we use @subtypes for this?'/>
       <arg name='filename' type='const char *' info='an optional file name or URI'/>
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
     </function>
+    <function name='xmlCtxtSetMaxAmplification' file='parser' module='parser'>
+      <info>To protect against exponential entity expansion (&quot;billion laughs&quot;), the size of serialized output is (roughly) limited to the input size multiplied by this factor. The default value is 5.  When working with documents making heavy use of entity expansion, it can be necessary to increase the value. For security reasons, this should only be considered when processing trusted input.</info>
+      <return type='void'/>
+      <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
+      <arg name='maxAmpl' type='unsigned' info='maximum amplification factor'/>
+    </function>
     <function name='xmlCtxtUseOptions' file='parser' module='parser'>
       <info>Applies the options to the parser context</info>
       <return type='int' info='0 in case of success, the set of unknown or unimplemented options in case of error.'/>
@@ -9219,7 +9127,7 @@ Could we use @subtypes for this?'/>
       <arg name='options' type='int' info='a combination of xmlParserOption'/>
     </function>
     <function name='xmlCurrentChar' file='parserInternals' module='parserInternals'>
-      <info>The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence &quot;#xD#xA&quot; or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)</info>
+      <info>DEPRECATED: Internal function, do not use.  The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence &quot;#xD#xA&quot; or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)</info>
       <return type='int' info='the current char value and its length'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the XML parser context'/>
       <arg name='len' type='int *' info='pointer to the length of the char read'/>
@@ -9372,7 +9280,7 @@ Could we use @subtypes for this?'/>
       <arg name='end3' type='xmlChar' info='an end marker xmlChar, 0 if none'/>
     </function>
     <function name='xmlDefaultSAXHandlerInit' file='SAX2' module='SAX2'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Initialize the default SAX2 handler</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlInitParser to initialize the library.  Initialize the default SAX2 handler</info>
       <return type='void'/>
     </function>
     <function name='xmlDelEncodingAlias' file='encoding' module='encoding'>
@@ -9380,12 +9288,12 @@ Could we use @subtypes for this?'/>
       <return type='int' info='0 in case of success, -1 in case of error'/>
       <arg name='alias' type='const char *' info='the alias name as parsed, in UTF-8 format (ASCII actually)'/>
     </function>
-    <function name='xmlDeregisterNodeDefault' file='globals' module='globals'>
+    <function name='xmlDeregisterNodeDefault' file='tree' module='tree'>
       <info>Registers a callback for node destruction</info>
       <return type='xmlDeregisterNodeFunc' info='the previous value of the deregistration function'/>
       <arg name='func' type='xmlDeregisterNodeFunc' info='function pointer to the new DeregisterNodeFunc'/>
     </function>
-    <functype name='xmlDeregisterNodeFunc' file='globals' module='globals'>
+    <functype name='xmlDeregisterNodeFunc' file='tree' module='tree'>
       <info>Signature for the deregistration callback of a discarded node</info>
       <return type='void'/>
       <arg name='node' type='xmlNodePtr' info='the current node'/>
@@ -9397,7 +9305,7 @@ Could we use @subtypes for this?'/>
       <arg name='len' type='int' info='pointer to the length of the buffer'/>
     </function>
     <function name='xmlDictCleanup' file='dict' module='dict'>
-      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.  Free the dictionary mutex. Do not call unless sure the library is not in use anymore !</info>
+      <info>DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.</info>
       <return type='void'/>
     </function>
     <function name='xmlDictCreate' file='dict' module='dict'>
@@ -9410,7 +9318,7 @@ Could we use @subtypes for this?'/>
       <arg name='sub' type='xmlDictPtr' info='an existing dictionary'/>
     </function>
     <function name='xmlDictExists' file='dict' module='dict'>
-      <info>Check if the @name exists in the dictionary @dict.</info>
+      <info>Check if a string exists in the dictionary.</info>
       <return type='const xmlChar *' info='the internal copy of the name or NULL if not found.'/>
       <arg name='dict' type='xmlDictPtr' info='the dictionary'/>
       <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
@@ -9427,11 +9335,11 @@ Could we use @subtypes for this?'/>
       <arg name='dict' type='xmlDictPtr' info='the dictionary'/>
     </function>
     <function name='xmlDictLookup' file='dict' module='dict'>
-      <info>Add the @name to the dictionary @dict if not present.</info>
-      <return type='const xmlChar *' info='the internal copy of the name or NULL in case of internal error'/>
-      <arg name='dict' type='xmlDictPtr' info='the dictionary'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='len' type='int' info='the length of the name, if -1 it is recomputed'/>
+      <info>Lookup a string and add it to the dictionary if it wasn&apos;t found.</info>
+      <return type='const xmlChar *' info='the interned copy of the string or NULL if a memory allocation failed.'/>
+      <arg name='dict' type='xmlDictPtr' info='dictionary'/>
+      <arg name='name' type='const xmlChar *' info='string key'/>
+      <arg name='len' type='int' info='length of the key, if -1 it is recomputed'/>
     </function>
     <function name='xmlDictOwns' file='dict' module='dict'>
       <info>check if a string is owned by the dictionary</info>
@@ -9440,8 +9348,8 @@ Could we use @subtypes for this?'/>
       <arg name='str' type='const xmlChar *' info='the string'/>
     </function>
     <function name='xmlDictQLookup' file='dict' module='dict'>
-      <info>Add the QName @prefix:@name to the hash @dict if not present.</info>
-      <return type='const xmlChar *' info='the internal copy of the QName or NULL in case of internal error'/>
+      <info>Lookup the QName @prefix:@name and add it to the dictionary if it wasn&apos;t found.</info>
+      <return type='const xmlChar *' info='the interned copy of the string or NULL if a memory allocation failed.'/>
       <arg name='dict' type='xmlDictPtr' info='the dictionary'/>
       <arg name='prefix' type='const xmlChar *' info='the prefix'/>
       <arg name='name' type='const xmlChar *' info='the name'/>
@@ -9462,13 +9370,6 @@ Could we use @subtypes for this?'/>
       <return type='int' info='the number of elements in the dictionary or -1 in case of error'/>
       <arg name='dict' type='xmlDictPtr' info='the dictionary'/>
     </function>
-    <function name='xmlDllMain' file='threads' module='threads'>
-      <info></info>
-      <return type='int' info=''/>
-      <arg name='hinstDLL' type='void *' info=''/>
-      <arg name='fdwReason' type='unsigned long' info=''/>
-      <arg name='lpvReserved' type='void *' info=''/>
-    </function>
     <function name='xmlDocCopyNode' file='tree' module='tree'>
       <info>Do a copy of the node to a given document.</info>
       <return type='xmlNodePtr' info='a new #xmlNodePtr, or NULL in case of error.'/>
@@ -9636,12 +9537,6 @@ Could we use @subtypes for this?'/>
       <arg name='firstNode' type='xmlNodePtr' info='the fist node in the chunk'/>
       <arg name='lastNode' type='xmlNodePtr' info='the last nod in the chunk'/>
     </functype>
-    <function name='xmlErrMemory' file='parserInternals' module='parserInternals'>
-      <info>Handle a redefinition of attribute error</info>
-      <return type='void'/>
-      <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
-      <arg name='extra' type='const char *' info='extra information'/>
-    </function>
     <function name='xmlExpCtxtNbCons' file='xmlregexp' module='xmlregexp'>
       <cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
       <info>Debugging facility provides the number of allocated nodes over lifetime</info>
@@ -9812,7 +9707,7 @@ Could we use @subtypes for this?'/>
       <arg name='len' type='int' info='number of bytes to write'/>
     </function>
     <function name='xmlFindCharEncodingHandler' file='encoding' module='encoding'>
-      <info>Search in the registered set the handler able to read/write that encoding.</info>
+      <info>Search in the registered set the handler able to read/write that encoding or create a new one.</info>
       <return type='xmlCharEncodingHandlerPtr' info='the handler or NULL if not found'/>
       <arg name='name' type='const char *' info='a string describing the char encoding.'/>
     </function>
@@ -9870,6 +9765,11 @@ Could we use @subtypes for this?'/>
       <return type='void'/>
       <arg name='table' type='xmlEntitiesTablePtr' info='An entity table'/>
     </function>
+    <function name='xmlFreeEntity' file='entities' module='entities'>
+      <info></info>
+      <return type='void'/>
+      <arg name='entity' type='xmlEntityPtr' info=''/>
+    </function>
     <function name='xmlFreeEnumeration' file='valid' module='valid'>
       <info>free an enumeration attribute node (recursive).</info>
       <return type='void'/>
@@ -9891,7 +9791,7 @@ Could we use @subtypes for this?'/>
       <arg name='input' type='xmlParserInputPtr' info='an xmlParserInputPtr'/>
     </function>
     <function name='xmlFreeMutex' file='threads' module='threads'>
-      <info>xmlFreeMutex() is used to reclaim resources associated with a libxml2 token struct.</info>
+      <info>Free a mutex.</info>
       <return type='void'/>
       <arg name='tok' type='xmlMutexPtr' info='the simple mutex'/>
     </function>
@@ -10109,9 +10009,9 @@ Could we use @subtypes for this?'/>
       <arg name='len' type='int *' info='the length of the features name array (input/output)'/>
       <arg name='result' type='const char **' info='an array of string to be filled with the features name.'/>
     </function>
-    <function name='xmlGetGlobalState' file='threads' module='threads'>
-      <info>xmlGetGlobalState() is called to retrieve the global state for a thread.</info>
-      <return type='xmlGlobalStatePtr' info='the thread global state or NULL in case of error'/>
+    <function name='xmlGetGlobalState' file='globals' module='globals'>
+      <info>DEPRECATED</info>
+      <return type='xmlGlobalStatePtr' info='NULL.'/>
     </function>
     <function name='xmlGetID' file='valid' module='valid'>
       <info>Search the attribute declaring the given ID</info>
@@ -10131,7 +10031,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlGetLastError' file='xmlerror' module='error'>
       <info>Get the last global error registered. This is per thread if compiled with thread support.</info>
-      <return type='xmlErrorPtr' info='NULL if no error occurred or a pointer to the error'/>
+      <return type='const xmlError *' info='a pointer to the error'/>
     </function>
     <function name='xmlGetLineNo' file='tree' module='tree'>
       <info>Get line number of @node. Try to override the limitation of lines being store in 16 bits ints if XML_PARSE_BIG_LINES parser option was used</info>
@@ -10188,7 +10088,7 @@ Could we use @subtypes for this?'/>
       <arg name='ID' type='const xmlChar *' info='the ID value'/>
     </function>
     <function name='xmlGetThreadId' file='threads' module='threads'>
-      <info>xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn&apos;t mandate pthread_t to be an integer type</info>
+      <info>DEPRECATED: Internal function, do not use.  xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn&apos;t mandate pthread_t to be an integer type</info>
       <return type='int' info='the current thread ID number'/>
     </function>
     <function name='xmlGetUTF8Char' file='xmlstring' module='xmlstring'>
@@ -10223,28 +10123,28 @@ Could we use @subtypes for this?'/>
       <arg name='name' type='const xmlChar *' info='the attribute name'/>
     </function>
     <function name='xmlHashAddEntry' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the @name. Duplicate names generate errors.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
+      <info>Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can&apos;t be distinguished from out-of-memory errors, so this function should be used with care.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
     </function>
     <function name='xmlHashAddEntry2' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the (@name, @name2) tuple. Duplicate tuples generate errors.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
+      <info>Add a hash table entry with two strings as key.  See xmlHashAddEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
     </function>
     <function name='xmlHashAddEntry3' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the tuple (@name, @name2, @name3). Duplicate entries generate errors.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
+      <info>Add a hash table entry with three strings as key.  See xmlHashAddEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='key3' type='const xmlChar *' info='third string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
     </function>
     <functype name='xmlHashCopier' file='hash' module='hash'>
       <info>Callback to copy data from a hash.</info>
@@ -10253,19 +10153,19 @@ Could we use @subtypes for this?'/>
       <arg name='name' type='const xmlChar *' info='the name associated'/>
     </functype>
     <function name='xmlHashCopy' file='hash' module='hash'>
-      <info>Scan the hash @table and applied @f to each value.</info>
-      <return type='xmlHashTablePtr' info='the new table or NULL in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='f' type='xmlHashCopier' info='the copier function for items in the hash'/>
+      <info>Copy the hash @table using @copy to copy payloads.</info>
+      <return type='xmlHashTablePtr' info='the new table or NULL if a memory allocation failed.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='copy' type='xmlHashCopier' info='copier function for items in the hash'/>
     </function>
     <function name='xmlHashCreate' file='hash' module='hash'>
-      <info>Create a new xmlHashTablePtr.</info>
-      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occurred.'/>
-      <arg name='size' type='int' info='the size of the hash table'/>
+      <info>Create a new hash table. Set size to zero if the number of entries can&apos;t be estimated.</info>
+      <return type='xmlHashTablePtr' info='the newly created object, or NULL if a memory allocation failed.'/>
+      <arg name='size' type='int' info='initial size of the hash table'/>
     </function>
     <function name='xmlHashCreateDict' file='hash' module='hash'>
-      <info>Create a new xmlHashTablePtr which will use @dict as the internal dictionary</info>
-      <return type='xmlHashTablePtr' info='the newly created object, or NULL if an error occurred.'/>
+      <info>Create a new hash table backed by a dictionary. This can reduce resource usage considerably if most keys passed to API functions originate from this dictionary.</info>
+      <return type='xmlHashTablePtr' info='the newly created object, or NULL if a memory allocation failed.'/>
       <arg name='size' type='int' info='the size of the hash table'/>
       <arg name='dict' type='xmlDictPtr' info='a dictionary to use for the hash'/>
     </function>
@@ -10278,120 +10178,120 @@ Could we use @subtypes for this?'/>
     <function name='xmlHashDefaultDeallocator' file='hash' module='hash'>
       <info>Free a hash table entry with xmlFree.</info>
       <return type='void'/>
-      <arg name='entry' type='void *' info='the hash table entry'/>
-      <arg name='name' type='const xmlChar *' info='the entry&apos;s name'/>
+      <arg name='entry' type='void *' info='hash table entry'/>
+      <arg name='key' type='const xmlChar *' info='the entry&apos;s string key'/>
     </function>
     <function name='xmlHashFree' file='hash' module='hash'>
-      <info>Free the hash @table and its contents. The userdata is deallocated with @f if provided.</info>
+      <info>Free the hash and its contents. The payload is deallocated with @dealloc if provided.</info>
       <return type='void'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for items in the hash'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function or NULL'/>
     </function>
     <function name='xmlHashLookup' file='hash' module='hash'>
-      <info>Find the userdata specified by the @name.</info>
-      <return type='void *' info='the pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
+      <info>Find the entry specified by @key.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='string key'/>
     </function>
     <function name='xmlHashLookup2' file='hash' module='hash'>
-      <info>Find the userdata specified by the (@name, @name2) tuple.</info>
-      <return type='void *' info='the pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
+      <info>Find the payload specified by the (@key, @key2) tuple.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
     </function>
     <function name='xmlHashLookup3' file='hash' module='hash'>
-      <info>Find the userdata specified by the (@name, @name2, @name3) tuple.</info>
-      <return type='void *' info='the a pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata'/>
+      <info>Find the payload specified by the (@key, @key2, @key3) tuple.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='key3' type='const xmlChar *' info='third string key'/>
     </function>
     <function name='xmlHashQLookup' file='hash' module='hash'>
-      <info>Find the userdata specified by the QName @prefix:@name/@name.</info>
-      <return type='void *' info='the pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='prefix' type='const xmlChar *' info='the prefix of the userdata'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
+      <info>Find the payload specified by the QName @prefix:@name or @name.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='prefix' type='const xmlChar *' info='prefix of the string key'/>
+      <arg name='name' type='const xmlChar *' info='local name of the string key'/>
     </function>
     <function name='xmlHashQLookup2' file='hash' module='hash'>
-      <info>Find the userdata specified by the QNames tuple</info>
-      <return type='void *' info='the pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='prefix' type='const xmlChar *' info='the prefix of the userdata'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='prefix2' type='const xmlChar *' info='the second prefix of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
+      <info>Find the payload specified by the QNames tuple.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='prefix' type='const xmlChar *' info='first prefix'/>
+      <arg name='name' type='const xmlChar *' info='first local name'/>
+      <arg name='prefix2' type='const xmlChar *' info='second prefix'/>
+      <arg name='name2' type='const xmlChar *' info='second local name'/>
     </function>
     <function name='xmlHashQLookup3' file='hash' module='hash'>
-      <info>Find the userdata specified by the (@name, @name2, @name3) tuple.</info>
-      <return type='void *' info='the a pointer to the userdata'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='prefix' type='const xmlChar *' info='the prefix of the userdata'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='prefix2' type='const xmlChar *' info='the second prefix of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='prefix3' type='const xmlChar *' info='the third prefix of the userdata'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata'/>
+      <info>Find the payload specified by the QNames tuple.</info>
+      <return type='void *' info='a pointer to the payload or NULL if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='prefix' type='const xmlChar *' info='first prefix'/>
+      <arg name='name' type='const xmlChar *' info='first local name'/>
+      <arg name='prefix2' type='const xmlChar *' info='second prefix'/>
+      <arg name='name2' type='const xmlChar *' info='second local name'/>
+      <arg name='prefix3' type='const xmlChar *' info='third prefix'/>
+      <arg name='name3' type='const xmlChar *' info='third local name'/>
     </function>
     <function name='xmlHashRemoveEntry' file='hash' module='hash'>
-      <info>Find the userdata specified by the @name and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</info>
-      <return type='int' info='0 if the removal succeeded and -1 in case of error or not found.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for removed item (if any)'/>
+      <info>Find the entry specified by the @key and remove it from the hash table. Payload will be freed with @dealloc.</info>
+      <return type='int' info='0 on success and -1 if no entry was found.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='string key'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for removed item or NULL'/>
     </function>
     <function name='xmlHashRemoveEntry2' file='hash' module='hash'>
-      <info>Find the userdata specified by the (@name, @name2) tuple and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</info>
-      <return type='int' info='0 if the removal succeeded and -1 in case of error or not found.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for removed item (if any)'/>
+      <info>Remove an entry with two strings as key.  See xmlHashRemoveEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for removed item or NULL'/>
     </function>
     <function name='xmlHashRemoveEntry3' file='hash' module='hash'>
-      <info>Find the userdata specified by the (@name, @name2, @name3) tuple and remove it from the hash @table. Existing userdata for this tuple will be removed and freed with @f.</info>
-      <return type='int' info='0 if the removal succeeded and -1 in case of error or not found.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for removed item (if any)'/>
+      <info>Remove an entry with three strings as key.  See xmlHashRemoveEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='key3' type='const xmlChar *' info='third string key'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for removed item or NULL'/>
     </function>
     <function name='xmlHashScan' file='hash' module='hash'>
-      <info>Scan the hash @table and applied @f to each value.</info>
+      <info>Scan the hash @table and apply @scan to each value.</info>
       <return type='void'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='f' type='xmlHashScanner' info='the scanner function for items in the hash'/>
-      <arg name='data' type='void *' info='extra data passed to f'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='scan' type='xmlHashScanner' info='scanner function for items in the hash'/>
+      <arg name='data' type='void *' info='extra data passed to @scan'/>
     </function>
     <function name='xmlHashScan3' file='hash' module='hash'>
-      <info>Scan the hash @table and applied @f to each value matching (@name, @name2, @name3) tuple. If one of the names is null, the comparison is considered to match.</info>
+      <info>Scan the hash @table and apply @scan to each value matching (@key, @key2, @key3) tuple. If one of the keys is null, the comparison is considered to match.</info>
       <return type='void'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata or NULL'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata or NULL'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata or NULL'/>
-      <arg name='f' type='xmlHashScanner' info='the scanner function for items in the hash'/>
-      <arg name='data' type='void *' info='extra data passed to f'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key or NULL'/>
+      <arg name='key2' type='const xmlChar *' info='second string key or NULL'/>
+      <arg name='key3' type='const xmlChar *' info='third string key or NULL'/>
+      <arg name='scan' type='xmlHashScanner' info='scanner function for items in the hash'/>
+      <arg name='data' type='void *' info='extra data passed to @scan'/>
     </function>
     <function name='xmlHashScanFull' file='hash' module='hash'>
-      <info>Scan the hash @table and applied @f to each value.</info>
+      <info>Scan the hash @table and apply @scan to each value.</info>
       <return type='void'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='f' type='xmlHashScannerFull' info='the scanner function for items in the hash'/>
-      <arg name='data' type='void *' info='extra data passed to f'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='scan' type='xmlHashScannerFull' info='scanner function for items in the hash'/>
+      <arg name='data' type='void *' info='extra data passed to @scan'/>
     </function>
     <function name='xmlHashScanFull3' file='hash' module='hash'>
-      <info>Scan the hash @table and applied @f to each value matching (@name, @name2, @name3) tuple. If one of the names is null, the comparison is considered to match.</info>
+      <info>Scan the hash @table and apply @scan to each value matching (@key, @key2, @key3) tuple. If one of the keys is null, the comparison is considered to match.</info>
       <return type='void'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata or NULL'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata or NULL'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata or NULL'/>
-      <arg name='f' type='xmlHashScannerFull' info='the scanner function for items in the hash'/>
-      <arg name='data' type='void *' info='extra data passed to f'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key or NULL'/>
+      <arg name='key2' type='const xmlChar *' info='second string key or NULL'/>
+      <arg name='key3' type='const xmlChar *' info='third string key or NULL'/>
+      <arg name='scan' type='xmlHashScannerFull' info='scanner function for items in the hash'/>
+      <arg name='data' type='void *' info='extra data passed to @scan'/>
     </function>
     <functype name='xmlHashScanner' file='hash' module='hash'>
       <info>Callback when scanning data in a hash with the simple scanner.</info>
@@ -10410,36 +10310,36 @@ Could we use @subtypes for this?'/>
       <arg name='name3' type='const xmlChar *' info='the third name associated'/>
     </functype>
     <function name='xmlHashSize' file='hash' module='hash'>
-      <info>Query the number of elements installed in the hash @table.</info>
-      <return type='int' info='the number of elements in the hash table or -1 in case of error'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
+      <info>Query the number of elements in the hash table.</info>
+      <return type='int' info='the number of elements in the hash table or -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
     </function>
     <function name='xmlHashUpdateEntry' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the @name. Existing entry for this @name will be removed and freed with @f if found.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for replaced item (if any)'/>
+      <info>Add a hash table entry. If an entry with this key already exists, the old payload will be freed and updated with the new value.</info>
+      <return type='int' info='0 in case of success, -1 if a memory allocation failed.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for replaced item or NULL'/>
     </function>
     <function name='xmlHashUpdateEntry2' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the (@name, @name2) tuple. Existing entry for this tuple will be removed and freed with @f if found.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for replaced item (if any)'/>
+      <info>Add a hash table entry with two strings as key.  See xmlHashUpdateEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for replaced item or NULL'/>
     </function>
     <function name='xmlHashUpdateEntry3' file='hash' module='hash'>
-      <info>Add the @userdata to the hash @table. This can later be retrieved by using the tuple (@name, @name2, @name3). Existing entry for this tuple will be removed and freed with @f if found.</info>
-      <return type='int' info='0 the addition succeeded and -1 in case of error.'/>
-      <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
-      <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
-      <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
-      <arg name='name3' type='const xmlChar *' info='a third name of the userdata'/>
-      <arg name='userdata' type='void *' info='a pointer to the userdata'/>
-      <arg name='f' type='xmlHashDeallocator' info='the deallocator function for replaced item (if any)'/>
+      <info>Add a hash table entry with three strings as key.  See xmlHashUpdateEntry.</info>
+      <return type='int' info='0 on success and -1 in case of error.'/>
+      <arg name='hash' type='xmlHashTablePtr' info='hash table'/>
+      <arg name='key' type='const xmlChar *' info='first string key'/>
+      <arg name='key2' type='const xmlChar *' info='second string key'/>
+      <arg name='key3' type='const xmlChar *' info='third string key'/>
+      <arg name='payload' type='void *' info='pointer to the payload'/>
+      <arg name='dealloc' type='xmlHashDeallocator' info='deallocator function for replaced item or NULL'/>
     </function>
     <function name='xmlIOFTPClose' file='xmlIO' module='xmlIO'>
       <cond>defined(LIBXML_FTP_ENABLED)</cond>
@@ -10509,33 +10409,33 @@ Could we use @subtypes for this?'/>
       <arg name='enc' type='xmlCharEncoding' info='the charset encoding if known'/>
     </function>
     <function name='xmlInitCharEncodingHandlers' file='encoding' module='encoding'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Initialize the char encoding support, it registers the default encoding supported. NOTE: while public, this function usually doesn&apos;t need to be called in normal processing.</info>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
       <return type='void'/>
     </function>
     <function name='xmlInitGlobals' file='globals' module='globals'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Additional initialisation for multi-threading</info>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
       <return type='void'/>
     </function>
     <function name='xmlInitMemory' file='xmlmemory' module='xmlmemory'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Initialize the memory layer.</info>
-      <return type='int' info='0 on success'/>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
+      <return type='int' info=''/>
     </function>
     <function name='xmlInitNodeInfoSeq' file='parser' module='parserInternals'>
-      <info>-- Initialize (set to initial state) node info sequence</info>
+      <info>DEPRECATED: Don&apos;t use.  -- Initialize (set to initial state) node info sequence</info>
       <return type='void'/>
       <arg name='seq' type='xmlParserNodeInfoSeqPtr' info='a node info sequence pointer'/>
     </function>
-    <function name='xmlInitParser' file='parser' module='parser'>
-      <info>Initialization function for the XML parser. This is not reentrant. Call once before processing in case of use in multithreaded programs.</info>
+    <function name='xmlInitParser' file='parser' module='threads'>
+      <info>Initialization function for the XML parser.  Call once from the main thread before using the library in multithreaded programs.</info>
       <return type='void'/>
     </function>
     <function name='xmlInitParserCtxt' file='parser' module='parserInternals'>
-      <info>Initialize a parser context</info>
+      <info>DEPRECATED: Internal function which will be made private in a future version.  Initialize a parser context</info>
       <return type='int' info='0 in case of success and -1 in case of error'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlInitThreads' file='threads' module='threads'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  xmlInitThreads() is used to to initialize all the thread related data of the libxml2 library.</info>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
       <return type='void'/>
     </function>
     <function name='xmlInitializeCatalog' file='catalog' module='catalog'>
@@ -10544,11 +10444,11 @@ Could we use @subtypes for this?'/>
       <return type='void'/>
     </function>
     <function name='xmlInitializeDict' file='dict' module='dict'>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Do the dictionary mutex initialization.</info>
-      <return type='int' info='0 if initialization was already done, and 1 if that call led to the initialization'/>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
+      <return type='int' info='0.'/>
     </function>
     <function name='xmlInitializeGlobalState' file='globals' module='globals'>
-      <info>xmlInitializeGlobalState() initialize a global state with all the default values of the library.</info>
+      <info>DEPRECATED: No-op.</info>
       <return type='void'/>
       <arg name='gs' type='xmlGlobalStatePtr' info='a pointer to a newly allocated global state'/>
     </function>
@@ -10631,8 +10531,8 @@ Could we use @subtypes for this?'/>
       <return type='int' info='0 if not, non-zero otherwise'/>
       <arg name='c' type='int' info='an unicode character (int)'/>
     </function>
-    <function name='xmlIsMainThread' file='threads' module='threads'>
-      <info>xmlIsMainThread() check whether the current thread is the main thread.</info>
+    <function name='xmlIsMainThread' file='threads' module='globals'>
+      <info>DEPRECATED: Internal function, do not use.  Check whether the current thread is the main thread.</info>
       <return type='int' info='1 if the current thread is the main thread, 0 otherwise'/>
     </function>
     <function name='xmlIsMixedElement' file='valid' module='valid'>
@@ -10653,14 +10553,14 @@ Could we use @subtypes for this?'/>
       <arg name='elem' type='xmlNodePtr' info='the element carrying the attribute'/>
       <arg name='attr' type='xmlAttrPtr' info='the attribute'/>
     </function>
-    <function name='xmlIsXHTML' file='tree' module='xmlsave'>
+    <function name='xmlIsXHTML' file='tree' module='tree'>
       <info>Try to find if the document correspond to an XHTML DTD</info>
       <return type='int' info='1 if true, 0 if not and -1 in case of error'/>
       <arg name='systemID' type='const xmlChar *' info='the system identifier'/>
       <arg name='publicID' type='const xmlChar *' info='the public identifier'/>
     </function>
     <function name='xmlKeepBlanksDefault' file='parser' module='parserInternals'>
-      <info>Set and return the previous value for default blanks text nodes support. The 1.x version of the parser used an heuristic to try to detect ignorable white spaces. As a result the SAX callback was generating xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when using the DOM output text nodes containing those blanks were not generated. The 2.x and later version will switch to the XML standard way and ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn&apos;t allow CDATA or mixed content. This function is provided as a way to force the standard behavior on 1.X libs and to switch back to the old mode for compatibility when running 1.X client code on 2.X . Upgrade of 1.X code should be done by using xmlIsBlankNode() commodity function to detect the &quot;empty&quot; nodes generated. This value also affect autogeneration of indentation when saving code if blanks sections are kept, indentation is not generated.</info>
+      <info>DEPRECATED: Use the modern options API with XML_PARSE_NOBLANKS.  Set and return the previous value for default blanks text nodes support. The 1.x version of the parser used an heuristic to try to detect ignorable white spaces. As a result the SAX callback was generating xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when using the DOM output text nodes containing those blanks were not generated. The 2.x and later version will switch to the XML standard way and ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn&apos;t allow CDATA or mixed content. This function is provided as a way to force the standard behavior on 1.X libs and to switch back to the old mode for compatibility when running 1.X client code on 2.X . Upgrade of 1.X code should be done by using xmlIsBlankNode() commodity function to detect the &quot;empty&quot; nodes generated. This value also affect autogeneration of indentation when saving code if blanks sections are kept, indentation is not generated.</info>
       <return type='int' info='the last value for 0 for no substitution, 1 for substitution.'/>
       <arg name='val' type='int' info='int 0 or 1'/>
     </function>
@@ -10671,7 +10571,7 @@ Could we use @subtypes for this?'/>
       <arg name='parent' type='xmlNodePtr' info='the parent node'/>
     </function>
     <function name='xmlLineNumbersDefault' file='parser' module='parserInternals'>
-      <info>Set and return the previous value for enabling line numbers in elements contents. This may break on old application and is turned off by default.</info>
+      <info>DEPRECATED: The modern options API always enables line numbers.  Set and return the previous value for enabling line numbers in elements contents. This may break on old application and is turned off by default.</info>
       <return type='int' info='the last value for 0 for no substitution, 1 for substitution.'/>
       <arg name='val' type='int' info='int 0 or 1'/>
     </function>
@@ -10958,6 +10858,11 @@ Could we use @subtypes for this?'/>
       <arg name='fp' type='FILE *' info='a FILE descriptor used as the output file'/>
       <arg name='nr' type='int' info='number of entries to dump'/>
     </function>
+    <function name='xmlMemSize' file='xmlmemory' module='xmlmemory'>
+      <info></info>
+      <return type='size_t' info='the size of a memory allocation.'/>
+      <arg name='ptr' type='void *' info='pointer to the memory allocation'/>
+    </function>
     <function name='xmlMemStrdupLoc' file='xmlmemory' module='xmlmemory'>
       <info>a strdup() equivalent, with logging of the allocation info.</info>
       <return type='char *' info='a pointer to the new string or NULL if allocation error occurred.'/>
@@ -11446,7 +11351,7 @@ Could we use @subtypes for this?'/>
       <arg name='content' type='const xmlChar *' info='the entity content'/>
     </function>
     <function name='xmlNewEntityInputStream' file='parserInternals' module='parserInternals'>
-      <info>Create a new input stream based on an xmlEntityPtr</info>
+      <info>DEPRECATED: Internal function, do not use.  Create a new input stream based on an xmlEntityPtr</info>
       <return type='xmlParserInputPtr' info='the new input stream or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='entity' type='xmlEntityPtr' info='an Entity pointer'/>
@@ -11544,6 +11449,12 @@ Could we use @subtypes for this?'/>
       <arg name='doc' type='const xmlDoc *' info='the document'/>
       <arg name='name' type='const xmlChar *' info='the reference name, or the reference string with &amp; and ;'/>
     </function>
+    <function name='xmlNewSAXParserCtxt' file='parser' module='parserInternals'>
+      <info>Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.</info>
+      <return type='xmlParserCtxtPtr' info='the xmlParserCtxtPtr or NULL if memory allocation failed.'/>
+      <arg name='sax' type='const xmlSAXHandler *' info='SAX handler'/>
+      <arg name='userData' type='void *' info='user data'/>
+    </function>
     <function name='xmlNewStringInputStream' file='parserInternals' module='parserInternals'>
       <info>Create a new input stream based on a memory buffer.</info>
       <return type='xmlParserInputPtr' info='the new input stream'/>
@@ -11631,7 +11542,7 @@ Could we use @subtypes for this?'/>
       <return type='xmlValidCtxtPtr' info='NULL if not, otherwise the new validation context structure'/>
     </function>
     <function name='xmlNextChar' file='parserInternals' module='parserInternals'>
-      <info>Skip to the next char input char.</info>
+      <info>DEPRECATED: Internal function, do not use.  Skip to the next char input char.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the XML parser context'/>
     </function>
@@ -11816,12 +11727,12 @@ Could we use @subtypes for this?'/>
       <arg name='encoder' type='xmlCharEncodingHandlerPtr' info='the encoding converter or NULL'/>
       <arg name='compression' type='int' info='the compression ration (0 none, 9 max).'/>
     </function>
-    <function name='xmlOutputBufferCreateFilenameDefault' file='globals' module='xmlIO'>
+    <function name='xmlOutputBufferCreateFilenameDefault' file='xmlIO' module='xmlIO'>
       <info>Registers a callback for URI output file handling</info>
       <return type='xmlOutputBufferCreateFilenameFunc' info='the old value of the registration function'/>
       <arg name='func' type='xmlOutputBufferCreateFilenameFunc' info='function pointer to the new OutputBufferCreateFilenameFunc'/>
     </function>
-    <functype name='xmlOutputBufferCreateFilenameFunc' file='globals' module='globals'>
+    <functype name='xmlOutputBufferCreateFilenameFunc' file='xmlIO' module='xmlIO'>
       <info>Signature for the function doing the lookup for a suitable output method corresponding to an URI.</info>
       <return type='xmlOutputBufferPtr' info='the new xmlOutputBufferPtr in case of success or NULL if no method was found.'/>
       <arg name='URI' type='const char *' info='the URI to write to'/>
@@ -11905,24 +11816,24 @@ Could we use @subtypes for this?'/>
       <arg name='len' type='int' info='the length of the buffer in bytes'/>
     </functype>
     <function name='xmlParseAttValue' file='parserInternals' module='parser'>
-      <info>parse a value for an attribute Note: the parser won&apos;t do substitution of entities here, this will be handled later in xmlStringGetNodeList  [10] AttValue ::= &apos;&quot;&apos; ([^&lt;&amp;&quot;] | Reference)* &apos;&quot;&apos; | &quot;&apos;&quot; ([^&lt;&amp;&apos;] | Reference)* &quot;&apos;&quot;  3.3.3 Attribute-Value Normalization: Before the value of an attribute is passed to the application or checked for validity, the XML processor must normalize it as follows: - a character reference is processed by appending the referenced character to the attribute value - an entity reference is processed by recursively processing the replacement text of the entity - a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a &quot;#xD#xA&quot; sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity - other characters are processed by appending them to the normalized value If the declared value 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. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse a value for an attribute Note: the parser won&apos;t do substitution of entities here, this will be handled later in xmlStringGetNodeList  [10] AttValue ::= &apos;&quot;&apos; ([^&lt;&amp;&quot;] | Reference)* &apos;&quot;&apos; | &quot;&apos;&quot; ([^&lt;&amp;&apos;] | Reference)* &quot;&apos;&quot;  3.3.3 Attribute-Value Normalization: Before the value of an attribute is passed to the application or checked for validity, the XML processor must normalize it as follows: - a character reference is processed by appending the referenced character to the attribute value - an entity reference is processed by recursively processing the replacement text of the entity - a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a &quot;#xD#xA&quot; sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity - other characters are processed by appending them to the normalized value If the declared value 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. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.</info>
       <return type='xmlChar *' info='the AttValue parsed or NULL. The value has to be freed by the caller.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseAttribute' file='parserInternals' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an attribute  [41] Attribute ::= Name Eq AttValue  [ WFC: No External Entity References ] Attribute values cannot contain direct or indirect entity references to external entities.  [ WFC: No &lt; in Attribute Values ] The replacement text of any entity referred to directly or indirectly in an attribute value (other than &quot;&amp;lt;&quot;) must not contain a &lt;.  [ VC: Attribute Value Type ] The attribute must have been declared; the value must be of the type declared for it.  [25] Eq ::= S? &apos;=&apos; S?  With namespace:  [NS 11] Attribute ::= QName Eq AttValue  Also the case QName == xmlns:??? is handled independently as a namespace definition.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an attribute  [41] Attribute ::= Name Eq AttValue  [ WFC: No External Entity References ] Attribute values cannot contain direct or indirect entity references to external entities.  [ WFC: No &lt; in Attribute Values ] The replacement text of any entity referred to directly or indirectly in an attribute value (other than &quot;&amp;lt;&quot;) must not contain a &lt;.  [ VC: Attribute Value Type ] The attribute must have been declared; the value must be of the type declared for it.  [25] Eq ::= S? &apos;=&apos; S?  With namespace:  [NS 11] Attribute ::= QName Eq AttValue  Also the case QName == xmlns:??? is handled independently as a namespace definition.</info>
       <return type='const xmlChar *' info='the attribute name, and the value in *value.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='value' type='xmlChar **' info='a xmlChar ** used to store the value of the attribute'/>
     </function>
     <function name='xmlParseAttributeListDecl' file='parserInternals' module='parser'>
-      <info>: parse the Attribute list def for an element  [52] AttlistDecl ::= &apos;&lt;!ATTLIST&apos; S Name AttDef* S? &apos;&gt;&apos;  [53] AttDef ::= S Name S AttType S DefaultDecl</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an attribute list declaration for an element. Always consumes &apos;&lt;!&apos;.  [52] AttlistDecl ::= &apos;&lt;!ATTLIST&apos; S Name AttDef* S? &apos;&gt;&apos;  [53] AttDef ::= S Name S AttType S DefaultDecl</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseAttributeType' file='parserInternals' module='parser'>
-      <info>parse the Attribute list def for an element  [54] AttType ::= StringType | TokenizedType | EnumeratedType  [55] StringType ::= &apos;CDATA&apos;  [56] TokenizedType ::= &apos;ID&apos; | &apos;IDREF&apos; | &apos;IDREFS&apos; | &apos;ENTITY&apos; | &apos;ENTITIES&apos; | &apos;NMTOKEN&apos; | &apos;NMTOKENS&apos;  Validity constraints for attribute values syntax are checked in xmlValidateAttributeValue()  [ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.  [ VC: One ID per Element Type ] No element type may have more than one ID attribute specified.  [ VC: ID Attribute Default ] An ID attribute must have a declared default of #IMPLIED or #REQUIRED.  [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID attribute on some element in the XML document; i.e. IDREF values must match the value of some ID attribute.  [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD.  [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the Attribute list def for an element  [54] AttType ::= StringType | TokenizedType | EnumeratedType  [55] StringType ::= &apos;CDATA&apos;  [56] TokenizedType ::= &apos;ID&apos; | &apos;IDREF&apos; | &apos;IDREFS&apos; | &apos;ENTITY&apos; | &apos;ENTITIES&apos; | &apos;NMTOKEN&apos; | &apos;NMTOKENS&apos;  Validity constraints for attribute values syntax are checked in xmlValidateAttributeValue()  [ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.  [ VC: One ID per Element Type ] No element type may have more than one ID attribute specified.  [ VC: ID Attribute Default ] An ID attribute must have a declared default of #IMPLIED or #REQUIRED.  [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID attribute on some element in the XML document; i.e. IDREF values must match the value of some ID attribute.  [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD.  [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.</info>
       <return type='int' info='the attribute type'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='tree' type='xmlEnumerationPtr *' info='the enumeration tree built while parsing'/>
@@ -11951,7 +11862,7 @@ Could we use @subtypes for this?'/>
       <arg name='recover' type='int' info='return nodes even if the data is broken (use 0)'/>
     </function>
     <function name='xmlParseCDSect' file='parserInternals' module='parser'>
-      <info>Parse escaped pure raw content.  [18] CDSect ::= CDStart CData CDEnd  [19] CDStart ::= &apos;&lt;![CDATA[&apos;  [20] Data ::= (Char* - (Char* &apos;]]&gt;&apos; Char*))  [21] CDEnd ::= &apos;]]&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse escaped pure raw content. Always consumes &apos;&lt;![&apos;.  [18] CDSect ::= CDStart CData CDEnd  [19] CDStart ::= &apos;&lt;![CDATA[&apos;  [20] Data ::= (Char* - (Char* &apos;]]&gt;&apos; Char*))  [21] CDEnd ::= &apos;]]&gt;&apos;</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -11962,10 +11873,10 @@ Could we use @subtypes for this?'/>
       <arg name='filename' type='const char *' info='the filename'/>
     </function>
     <function name='xmlParseCharData' file='parserInternals' module='parser'>
-      <info>parse a CharData section. if we are within a CDATA section &apos;]]&gt;&apos; marks an end of section.  The right angle bracket (&gt;) may be represented using the string &quot;&amp;gt;&quot;, and must, for compatibility, be escaped using &quot;&amp;gt;&quot; or a character reference when it appears in the string &quot;]]&gt;&quot; in content, when that string is not marking the end of a CDATA section.  [14] CharData ::= [^&lt;&amp;]* - ([^&lt;&amp;]* &apos;]]&gt;&apos; [^&lt;&amp;]*)</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
-      <arg name='cdata' type='int' info='int indicating whether we are within a CDATA section'/>
+      <arg name='cdata' type='int' info='unused'/>
     </function>
     <function name='xmlParseCharEncoding' file='encoding' module='encoding'>
       <info>Compare the string to the encoding schemes already known. Note that the comparison is case insensitive accordingly to the section [XML] 4.3.3 Character Encoding in Entities.</info>
@@ -11973,7 +11884,7 @@ Could we use @subtypes for this?'/>
       <arg name='name' type='const char *' info='the encoding name as parsed, in UTF-8 format (ASCII actually)'/>
     </function>
     <function name='xmlParseCharRef' file='parserInternals' module='parser'>
-      <info>parse Reference declarations  [66] CharRef ::= &apos;&amp;#&apos; [0-9]+ &apos;;&apos; | &apos;&amp;#x&apos; [0-9a-fA-F]+ &apos;;&apos;  [ WFC: Legal Character ] Characters referred to using character references must match the production for Char.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse a numeric character reference. Always consumes &apos;&amp;&apos;.  [66] CharRef ::= &apos;&amp;#&apos; [0-9]+ &apos;;&apos; | &apos;&amp;#x&apos; [0-9a-fA-F]+ &apos;;&apos;  [ WFC: Legal Character ] Characters referred to using character references must match the production for Char.</info>
       <return type='int' info='the value parsed (as an int), 0 in case of error'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -11987,7 +11898,7 @@ Could we use @subtypes for this?'/>
       <arg name='terminate' type='int' info='last chunk indicator'/>
     </function>
     <function name='xmlParseComment' file='parserInternals' module='parser'>
-      <info>Skip an XML (SGML) comment &lt;!-- .... --&gt; The spec says that &quot;For compatibility, the string &quot;--&quot; (double-hyphen) must not occur within comments. &quot;  [15] Comment ::= &apos;&lt;!--&apos; ((Char - &apos;-&apos;) | (&apos;-&apos; (Char - &apos;-&apos;)))* &apos;--&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an XML (SGML) comment. Always consumes &apos;&lt;!&apos;.  The spec says that &quot;For compatibility, the string &quot;--&quot; (double-hyphen) must not occur within comments. &quot;  [15] Comment ::= &apos;&lt;!--&apos; ((Char - &apos;-&apos;) | (&apos;-&apos; (Char - &apos;-&apos;)))* &apos;--&gt;&apos;</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12012,19 +11923,19 @@ Could we use @subtypes for this?'/>
       <arg name='SystemID' type='const xmlChar *' info='a NAME* containing the URL to the DTD'/>
     </function>
     <function name='xmlParseDefaultDecl' file='parserInternals' module='parser'>
-      <info>Parse an attribute default declaration  [60] DefaultDecl ::= &apos;#REQUIRED&apos; | &apos;#IMPLIED&apos; | ((&apos;#FIXED&apos; S)? AttValue)  [ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.  [ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared attribute type c.f. xmlValidateAttributeDecl()  [ VC: Fixed Attribute Default ] if an attribute has a default value declared with the #FIXED keyword, instances of that attribute must match the default value.  [ WFC: No &lt; in Attribute Values ] handled in xmlParseAttValue()</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an attribute default declaration  [60] DefaultDecl ::= &apos;#REQUIRED&apos; | &apos;#IMPLIED&apos; | ((&apos;#FIXED&apos; S)? AttValue)  [ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.  [ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared attribute type c.f. xmlValidateAttributeDecl()  [ VC: Fixed Attribute Default ] if an attribute has a default value declared with the #FIXED keyword, instances of that attribute must match the default value.  [ WFC: No &lt; in Attribute Values ] handled in xmlParseAttValue()</info>
       <return type='int' info='XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED or XML_ATTRIBUTE_FIXED.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='value' type='xmlChar **' info='Receive a possible fixed default value for the attribute'/>
     </function>
     <function name='xmlParseDoc' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory document and build a tree.</info>
+      <info>DEPRECATED: Use xmlReadDoc.  parse an XML in-memory document and build a tree.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
     </function>
     <function name='xmlParseDocTypeDecl' file='parserInternals' module='parser'>
-      <info>parse a DOCTYPE declaration  [28] doctypedecl ::= &apos;&lt;!DOCTYPE&apos; S Name (S ExternalID)? S? (&apos;[&apos; (markupdecl | PEReference | S)* &apos;]&apos; S?)? &apos;&gt;&apos;  [ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse a DOCTYPE declaration  [28] doctypedecl ::= &apos;&lt;!DOCTYPE&apos; S Name (S ExternalID)? S? (&apos;[&apos; (markupdecl | PEReference | S)* &apos;]&apos; S?)? &apos;&gt;&apos;  [ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12034,47 +11945,47 @@ Could we use @subtypes for this?'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseElement' file='parserInternals' module='parser'>
-      <info>parse an XML element  [39] element ::= EmptyElemTag | STag content ETag  [ WFC: Element Type Match ] The Name in an element&apos;s end-tag must match the element type in the start-tag.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML element  [39] element ::= EmptyElemTag | STag content ETag  [ WFC: Element Type Match ] The Name in an element&apos;s end-tag must match the element type in the start-tag.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseElementChildrenContentDecl' file='parserInternals' module='parser'>
-      <info>parse the declaration for a Mixed Element content The leading &apos;(&apos; and spaces have been skipped in xmlParseElementContentDecl  [47] children ::= (choice | seq) (&apos;?&apos; | &apos;*&apos; | &apos;+&apos;)?  [48] cp ::= (Name | choice | seq) (&apos;?&apos; | &apos;*&apos; | &apos;+&apos;)?  [49] choice ::= &apos;(&apos; S? cp ( S? &apos;|&apos; S? cp )* S? &apos;)&apos;  [50] seq ::= &apos;(&apos; S? cp ( S? &apos;,&apos; S? cp )* S? &apos;)&apos;  [ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the declaration for a Mixed Element content The leading &apos;(&apos; and spaces have been skipped in xmlParseElementContentDecl  [47] children ::= (choice | seq) (&apos;?&apos; | &apos;*&apos; | &apos;+&apos;)?  [48] cp ::= (Name | choice | seq) (&apos;?&apos; | &apos;*&apos; | &apos;+&apos;)?  [49] choice ::= &apos;(&apos; S? cp ( S? &apos;|&apos; S? cp )* S? &apos;)&apos;  [50] seq ::= &apos;(&apos; S? cp ( S? &apos;,&apos; S? cp )* S? &apos;)&apos;  [ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).</info>
       <return type='xmlElementContentPtr' info='the tree of xmlElementContentPtr describing the element hierarchy.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='inputchk' type='int' info='the input used for the current entity, needed for boundary checks'/>
     </function>
     <function name='xmlParseElementContentDecl' file='parserInternals' module='parser'>
-      <info>parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in xmlParseElementDecl  [46] contentspec ::= &apos;EMPTY&apos; | &apos;ANY&apos; | Mixed | children</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in xmlParseElementDecl  [46] contentspec ::= &apos;EMPTY&apos; | &apos;ANY&apos; | Mixed | children</info>
       <return type='int' info='the type of element content XML_ELEMENT_TYPE_xxx'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='name' type='const xmlChar *' info='the name of the element being defined.'/>
       <arg name='result' type='xmlElementContentPtr *' info='the Element Content pointer will be stored here if any'/>
     </function>
     <function name='xmlParseElementDecl' file='parserInternals' module='parser'>
-      <info>parse an Element declaration.  [45] elementdecl ::= &apos;&lt;!ELEMENT&apos; S Name S contentspec S? &apos;&gt;&apos;  [ VC: Unique Element Type Declaration ] No element type may be declared more than once</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an element declaration. Always consumes &apos;&lt;!&apos;.  [45] elementdecl ::= &apos;&lt;!ELEMENT&apos; S Name S contentspec S? &apos;&gt;&apos;  [ VC: Unique Element Type Declaration ] No element type may be declared more than once</info>
       <return type='int' info='the type of the element, or -1 in case of error'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseElementMixedContentDecl' file='parserInternals' module='parser'>
-      <info>parse the declaration for a Mixed Element content The leading &apos;(&apos; and spaces have been skipped in xmlParseElementContentDecl  [51] Mixed ::= &apos;(&apos; S? &apos;#PCDATA&apos; (S? &apos;|&apos; S? Name)* S? &apos;)*&apos; | &apos;(&apos; S? &apos;#PCDATA&apos; S? &apos;)&apos;  [ VC: Proper Group/PE Nesting ] applies to [51] too (see [49])  [ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the declaration for a Mixed Element content The leading &apos;(&apos; and spaces have been skipped in xmlParseElementContentDecl  [51] Mixed ::= &apos;(&apos; S? &apos;#PCDATA&apos; (S? &apos;|&apos; S? Name)* S? &apos;)*&apos; | &apos;(&apos; S? &apos;#PCDATA&apos; S? &apos;)&apos;  [ VC: Proper Group/PE Nesting ] applies to [51] too (see [49])  [ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.</info>
       <return type='xmlElementContentPtr' info='the list of the xmlElementContentPtr describing the element choices'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='inputchk' type='int' info='the input used for the current entity, needed for boundary checks'/>
     </function>
     <function name='xmlParseEncName' file='parserInternals' module='parser'>
-      <info>parse the XML encoding name  [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | &apos;-&apos;)*</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the XML encoding name  [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | &apos;-&apos;)*</info>
       <return type='xmlChar *' info='the encoding name value or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseEncodingDecl' file='parserInternals' module='parser'>
-      <info>parse the XML encoding declaration  [80] EncodingDecl ::= S &apos;encoding&apos; Eq (&apos;&quot;&apos; EncName &apos;&quot;&apos; |  &quot;&apos;&quot; EncName &quot;&apos;&quot;)  this setups the conversion filters.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the XML encoding declaration  [80] EncodingDecl ::= S &apos;encoding&apos; Eq (&apos;&quot;&apos; EncName &apos;&quot;&apos; |  &quot;&apos;&quot; EncName &quot;&apos;&quot;)  this setups the conversion filters.</info>
       <return type='const xmlChar *' info='the encoding value or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseEndTag' file='parserInternals' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an end of tag  [42] ETag ::= &apos;&lt;/&apos; Name S? &apos;&gt;&apos;  With namespace  [NS 9] ETag ::= &apos;&lt;/&apos; QName S? &apos;&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an end of tag  [42] ETag ::= &apos;&lt;/&apos; Name S? &apos;&gt;&apos;  With namespace  [NS 9] ETag ::= &apos;&lt;/&apos; QName S? &apos;&gt;&apos;</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12085,29 +11996,29 @@ Could we use @subtypes for this?'/>
       <arg name='filename' type='const char *' info='the filename'/>
     </function>
     <function name='xmlParseEntityDecl' file='parserInternals' module='parser'>
-      <info>parse &lt;!ENTITY declarations  [70] EntityDecl ::= GEDecl | PEDecl  [71] GEDecl ::= &apos;&lt;!ENTITY&apos; S Name S EntityDef S? &apos;&gt;&apos;  [72] PEDecl ::= &apos;&lt;!ENTITY&apos; S &apos;%&apos; S Name S PEDef S? &apos;&gt;&apos;  [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)  [74] PEDef ::= EntityValue | ExternalID  [76] NDataDecl ::= S &apos;NDATA&apos; S Name  [ VC: Notation Declared ] The Name must match the declared name of a notation.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an entity declaration. Always consumes &apos;&lt;!&apos;.  [70] EntityDecl ::= GEDecl | PEDecl  [71] GEDecl ::= &apos;&lt;!ENTITY&apos; S Name S EntityDef S? &apos;&gt;&apos;  [72] PEDecl ::= &apos;&lt;!ENTITY&apos; S &apos;%&apos; S Name S PEDef S? &apos;&gt;&apos;  [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)  [74] PEDef ::= EntityValue | ExternalID  [76] NDataDecl ::= S &apos;NDATA&apos; S Name  [ VC: Notation Declared ] The Name must match the declared name of a notation.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseEntityRef' file='parserInternals' module='parser'>
-      <info>parse ENTITY references declarations  [68] EntityRef ::= &apos;&amp;&apos; Name &apos;;&apos;  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot.  The declaration of a parameter entity must precede any reference to it.  Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone=&apos;yes&apos;.  [ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an entitiy reference. Always consumes &apos;&amp;&apos;.  [68] EntityRef ::= &apos;&amp;&apos; Name &apos;;&apos;  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot.  The declaration of a parameter entity must precede any reference to it.  Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone=&apos;yes&apos;.  [ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity</info>
       <return type='xmlEntityPtr' info='the xmlEntityPtr if found, or NULL otherwise.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseEntityValue' file='parserInternals' module='parser'>
-      <info>parse a value for ENTITY declarations  [9] EntityValue ::= &apos;&quot;&apos; ([^%&amp;&quot;] | PEReference | Reference)* &apos;&quot;&apos; | &quot;&apos;&quot; ([^%&amp;&apos;] | PEReference | Reference)* &quot;&apos;&quot;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse a value for ENTITY declarations  [9] EntityValue ::= &apos;&quot;&apos; ([^%&amp;&quot;] | PEReference | Reference)* &apos;&quot;&apos; | &quot;&apos;&quot; ([^%&amp;&apos;] | PEReference | Reference)* &quot;&apos;&quot;</info>
       <return type='xmlChar *' info='the EntityValue parsed with reference substituted or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='orig' type='xmlChar **' info='if non-NULL store a copy of the original entity value'/>
     </function>
     <function name='xmlParseEnumeratedType' file='parserInternals' module='parser'>
-      <info>parse an Enumerated attribute type.  [57] EnumeratedType ::= NotationType | Enumeration  [58] NotationType ::= &apos;NOTATION&apos; S &apos;(&apos; S? Name (S? &apos;|&apos; S? Name)* S? &apos;)&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an Enumerated attribute type.  [57] EnumeratedType ::= NotationType | Enumeration  [58] NotationType ::= &apos;NOTATION&apos; S &apos;(&apos; S? Name (S? &apos;|&apos; S? Name)* S? &apos;)&apos;</info>
       <return type='int' info='XML_ATTRIBUTE_ENUMERATION or XML_ATTRIBUTE_NOTATION'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='tree' type='xmlEnumerationPtr *' info='the enumeration tree built while parsing'/>
     </function>
     <function name='xmlParseEnumerationType' file='parserInternals' module='parser'>
-      <info>parse an Enumeration attribute type.  [59] Enumeration ::= &apos;(&apos; S? Nmtoken (S? &apos;|&apos; S? Nmtoken)* S? &apos;)&apos;  [ VC: Enumeration ] Values of this type must match one of the Nmtoken tokens in the declaration</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an Enumeration attribute type.  [59] Enumeration ::= &apos;(&apos; S? Nmtoken (S? &apos;|&apos; S? Nmtoken)* S? &apos;)&apos;  [ VC: Enumeration ] Values of this type must match one of the Nmtoken tokens in the declaration</info>
       <return type='xmlEnumerationPtr' info='the enumeration attribute tree built while parsing'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12129,7 +12040,7 @@ Could we use @subtypes for this?'/>
       <arg name='lst' type='xmlNodePtr *' info='the return value for the set of parsed nodes'/>
     </function>
     <function name='xmlParseExternalID' file='parserInternals' module='parser'>
-      <info>Parse an External ID or a Public ID  NOTE: Productions [75] and [83] interact badly since [75] can generate &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral  [75] ExternalID ::= &apos;SYSTEM&apos; S SystemLiteral | &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral  [83] PublicID ::= &apos;PUBLIC&apos; S PubidLiteral</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse an External ID or a Public ID  NOTE: Productions [75] and [83] interact badly since [75] can generate &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral  [75] ExternalID ::= &apos;SYSTEM&apos; S SystemLiteral | &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral  [83] PublicID ::= &apos;PUBLIC&apos; S PubidLiteral</info>
       <return type='xmlChar *' info='the function returns SystemLiteral and in the second case publicID receives PubidLiteral, is strict is off it is possible to return NULL and have publicID set.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='publicID' type='xmlChar **' info='a xmlChar** receiving PubidLiteral'/>
@@ -12144,7 +12055,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlParseFile' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</info>
+      <info>DEPRECATED: Use xmlReadFile.  parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.</info>
       <return type='xmlDocPtr' info='the resulting document tree if the file was wellformed, NULL otherwise.'/>
       <arg name='filename' type='const char *' info='the filename'/>
     </function>
@@ -12158,24 +12069,24 @@ Could we use @subtypes for this?'/>
       <arg name='lst' type='xmlNodePtr *' info='the return value for the set of parsed nodes'/>
     </function>
     <function name='xmlParseMarkupDecl' file='parserInternals' module='parser'>
-      <info>parse Markup declarations  [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment  [ VC: Proper Declaration/PE Nesting ] Parameter-entity replacement text must be properly nested with markup declarations. That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text.  [ WFC: PEs in Internal Subset ] In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations. (This does not apply to references that occur in external parameter entities or to the external subset.)</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse markup declarations. Always consumes &apos;&lt;!&apos; or &apos;&lt;?&apos;.  [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment  [ VC: Proper Declaration/PE Nesting ] Parameter-entity replacement text must be properly nested with markup declarations. That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text.  [ WFC: PEs in Internal Subset ] In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations. (This does not apply to references that occur in external parameter entities or to the external subset.)</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseMemory' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory block and build a tree.</info>
+      <info>DEPRECATED: Use xmlReadMemory.  parse an XML in-memory block and build a tree.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='buffer' type='const char *' info='an pointer to a char array'/>
       <arg name='size' type='int' info='the size of the array'/>
     </function>
     <function name='xmlParseMisc' file='parserInternals' module='parser'>
-      <info>parse an XML Misc* optional field.  [27] Misc ::= Comment | PI |  S</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML Misc* optional field.  [27] Misc ::= Comment | PI |  S</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseName' file='parserInternals' module='parser'>
-      <info>parse an XML name.  [4] NameChar ::= Letter | Digit | &apos;.&apos; | &apos;-&apos; | &apos;_&apos; | &apos;:&apos; | CombiningChar | Extender  [5] Name ::= (Letter | &apos;_&apos; | &apos;:&apos;) (NameChar)*  [6] Names ::= Name (#x20 Name)*</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML name.  [4] NameChar ::= Letter | Digit | &apos;.&apos; | &apos;-&apos; | &apos;_&apos; | &apos;:&apos; | CombiningChar | Extender  [5] Name ::= (Letter | &apos;_&apos; | &apos;:&apos;) (NameChar)*  [6] Names ::= Name (#x20 Name)*</info>
       <return type='const xmlChar *' info='the Name parsed or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12186,37 +12097,37 @@ Could we use @subtypes for this?'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseNmtoken' file='parserInternals' module='parser'>
-      <info>parse an XML Nmtoken.  [7] Nmtoken ::= (NameChar)+  [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML Nmtoken.  [7] Nmtoken ::= (NameChar)+  [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*</info>
       <return type='xmlChar *' info='the Nmtoken parsed or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseNotationDecl' file='parserInternals' module='parser'>
-      <info>parse a notation declaration  [82] NotationDecl ::= &apos;&lt;!NOTATION&apos; S Name S (ExternalID |  PublicID) S? &apos;&gt;&apos;  Hence there is actually 3 choices: &apos;PUBLIC&apos; S PubidLiteral &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral and &apos;SYSTEM&apos; S SystemLiteral  See the NOTE on xmlParseExternalID().</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse a notation declaration. Always consumes &apos;&lt;!&apos;.  [82] NotationDecl ::= &apos;&lt;!NOTATION&apos; S Name S (ExternalID |  PublicID) S? &apos;&gt;&apos;  Hence there is actually 3 choices: &apos;PUBLIC&apos; S PubidLiteral &apos;PUBLIC&apos; S PubidLiteral S SystemLiteral and &apos;SYSTEM&apos; S SystemLiteral  See the NOTE on xmlParseExternalID().</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseNotationType' file='parserInternals' module='parser'>
-      <info>parse an Notation attribute type.  Note: the leading &apos;NOTATION&apos; S part has already being parsed...  [58] NotationType ::= &apos;NOTATION&apos; S &apos;(&apos; S? Name (S? &apos;|&apos; S? Name)* S? &apos;)&apos;  [ VC: Notation Attributes ] Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an Notation attribute type.  Note: the leading &apos;NOTATION&apos; S part has already being parsed...  [58] NotationType ::= &apos;NOTATION&apos; S &apos;(&apos; S? Name (S? &apos;|&apos; S? Name)* S? &apos;)&apos;  [ VC: Notation Attributes ] Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.</info>
       <return type='xmlEnumerationPtr' info='the notation attribute tree built while parsing'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParsePEReference' file='parserInternals' module='parser'>
-      <info>parse PEReference declarations The entity content is handled directly by pushing it&apos;s content as a new input stream.  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;  [ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ VC: Entity Declared ] In a document with an external subset or external parameter entities with &quot;standalone=&apos;no&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse a parameter entity reference. Always consumes &apos;%&apos;.  The entity content is handled directly by pushing it&apos;s content as a new input stream.  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;  [ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ VC: Entity Declared ] In a document with an external subset or external parameter entities with &quot;standalone=&apos;no&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParsePI' file='parserInternals' module='parser'>
-      <info>parse an XML Processing Instruction.  [16] PI ::= &apos;&lt;?&apos; PITarget (S (Char* - (Char* &apos;?&gt;&apos; Char*)))? &apos;?&gt;&apos;  The processing is transferred to SAX once parsed.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML Processing Instruction.  [16] PI ::= &apos;&lt;?&apos; PITarget (S (Char* - (Char* &apos;?&gt;&apos; Char*)))? &apos;?&gt;&apos;  The processing is transferred to SAX once parsed.</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParsePITarget' file='parserInternals' module='parser'>
-      <info>parse the name of a PI  [17] PITarget ::= Name - ((&apos;X&apos; | &apos;x&apos;) (&apos;M&apos; | &apos;m&apos;) (&apos;L&apos; | &apos;l&apos;))</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the name of a PI  [17] PITarget ::= Name - ((&apos;X&apos; | &apos;x&apos;) (&apos;M&apos; | &apos;m&apos;) (&apos;L&apos; | &apos;l&apos;))</info>
       <return type='const xmlChar *' info='the PITarget name or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParsePubidLiteral' file='parserInternals' module='parser'>
-      <info>parse an XML public literal  [12] PubidLiteral ::= &apos;&quot;&apos; PubidChar* &apos;&quot;&apos; | &quot;&apos;&quot; (PubidChar - &quot;&apos;&quot;)* &quot;&apos;&quot;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML public literal  [12] PubidLiteral ::= &apos;&quot;&apos; PubidChar* &apos;&quot;&apos; | &quot;&apos;&quot; (PubidChar - &quot;&apos;&quot;)* &quot;&apos;&quot;</info>
       <return type='xmlChar *' info='the PubidLiteral parsed or NULL.'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12227,28 +12138,28 @@ Could we use @subtypes for this?'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseReference' file='parserInternals' module='parser'>
-      <info>parse and handle entity references in content, depending on the SAX interface, this may end-up in a call to character() if this is a CharRef, a predefined entity, if there is no reference() callback. or if the parser was asked to switch to that mode.  [67] Reference ::= EntityRef | CharRef</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse and handle entity references in content, depending on the SAX interface, this may end-up in a call to character() if this is a CharRef, a predefined entity, if there is no reference() callback. or if the parser was asked to switch to that mode.  Always consumes &apos;&amp;&apos;.  [67] Reference ::= EntityRef | CharRef</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseSDDecl' file='parserInternals' module='parser'>
-      <info>parse the XML standalone declaration  [32] SDDecl ::= S &apos;standalone&apos; Eq ((&quot;&apos;&quot; (&apos;yes&apos; | &apos;no&apos;) &quot;&apos;&quot;) | (&apos;&quot;&apos; (&apos;yes&apos; | &apos;no&apos;)&apos;&quot;&apos;))  [ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value &quot;no&quot; if any external markup declarations contain declarations of: - attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or - entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or - attributes with values subject to normalization, where the attribute appears in the document with a value which will change as a result of normalization, or - element types with element content, if white space occurs directly within any instance of those types.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the XML standalone declaration  [32] SDDecl ::= S &apos;standalone&apos; Eq ((&quot;&apos;&quot; (&apos;yes&apos; | &apos;no&apos;) &quot;&apos;&quot;) | (&apos;&quot;&apos; (&apos;yes&apos; | &apos;no&apos;)&apos;&quot;&apos;))  [ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value &quot;no&quot; if any external markup declarations contain declarations of: - attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or - entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or - attributes with values subject to normalization, where the attribute appears in the document with a value which will change as a result of normalization, or - element types with element content, if white space occurs directly within any instance of those types.</info>
       <return type='int' info='1 if standalone=&quot;yes&quot; 0 if standalone=&quot;no&quot; -2 if standalone attribute is missing or invalid (A standalone value of -2 means that the XML declaration was found, but no value was specified for the standalone attribute).'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseStartTag' file='parserInternals' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse a start of tag either for rule element or EmptyElement. In both case we don&apos;t parse the tag closing chars.  [40] STag ::= &apos;&lt;&apos; Name (S Attribute)* S? &apos;&gt;&apos;  [ WFC: Unique Att Spec ] No attribute name may appear more than once in the same start-tag or empty-element tag.  [44] EmptyElemTag ::= &apos;&lt;&apos; Name (S Attribute)* S? &apos;/&gt;&apos;  [ WFC: Unique Att Spec ] No attribute name may appear more than once in the same start-tag or empty-element tag.  With namespace:  [NS 8] STag ::= &apos;&lt;&apos; QName (S Attribute)* S? &apos;&gt;&apos;  [NS 10] EmptyElement ::= &apos;&lt;&apos; QName (S Attribute)* S? &apos;/&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Parse a start tag. Always consumes &apos;&lt;&apos;.  [40] STag ::= &apos;&lt;&apos; Name (S Attribute)* S? &apos;&gt;&apos;  [ WFC: Unique Att Spec ] No attribute name may appear more than once in the same start-tag or empty-element tag.  [44] EmptyElemTag ::= &apos;&lt;&apos; Name (S Attribute)* S? &apos;/&gt;&apos;  [ WFC: Unique Att Spec ] No attribute name may appear more than once in the same start-tag or empty-element tag.  With namespace:  [NS 8] STag ::= &apos;&lt;&apos; QName (S Attribute)* S? &apos;&gt;&apos;  [NS 10] EmptyElement ::= &apos;&lt;&apos; QName (S Attribute)* S? &apos;/&gt;&apos;</info>
       <return type='const xmlChar *' info='the element name parsed'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseSystemLiteral' file='parserInternals' module='parser'>
-      <info>parse an XML Literal  [11] SystemLiteral ::= (&apos;&quot;&apos; [^&quot;]* &apos;&quot;&apos;) | (&quot;&apos;&quot; [^&apos;]* &quot;&apos;&quot;)</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML Literal  [11] SystemLiteral ::= (&apos;&quot;&apos; [^&quot;]* &apos;&quot;&apos;) | (&quot;&apos;&quot; [^&apos;]* &quot;&apos;&quot;)</info>
       <return type='xmlChar *' info='the SystemLiteral parsed or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseTextDecl' file='parserInternals' module='parser'>
-      <info>parse an XML declaration header for external entities  [77] TextDecl ::= &apos;&lt;?xml&apos; VersionInfo? EncodingDecl S? &apos;?&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML declaration header for external entities  [77] TextDecl ::= &apos;&lt;?xml&apos; VersionInfo? EncodingDecl S? &apos;?&gt;&apos;</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
@@ -12270,22 +12181,22 @@ Could we use @subtypes for this?'/>
       <arg name='str' type='const char *' info='the string to analyze'/>
     </function>
     <function name='xmlParseVersionInfo' file='parserInternals' module='parser'>
-      <info>parse the XML version.  [24] VersionInfo ::= S &apos;version&apos; Eq (&apos; VersionNum &apos; | &quot; VersionNum &quot;)  [25] Eq ::= S? &apos;=&apos; S?</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the XML version.  [24] VersionInfo ::= S &apos;version&apos; Eq (&apos; VersionNum &apos; | &quot; VersionNum &quot;)  [25] Eq ::= S? &apos;=&apos; S?</info>
       <return type='xmlChar *' info='the version string, e.g. &quot;1.0&quot;'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseVersionNum' file='parserInternals' module='parser'>
-      <info>parse the XML version value.  [26] VersionNum ::= &apos;1.&apos; [0-9]+  In practice allow [0-9].[0-9]+ at that level</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse the XML version value.  [26] VersionNum ::= &apos;1.&apos; [0-9]+  In practice allow [0-9].[0-9]+ at that level</info>
       <return type='xmlChar *' info='the string giving the XML version number, or NULL'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParseXMLDecl' file='parserInternals' module='parser'>
-      <info>parse an XML declaration header  [23] XMLDecl ::= &apos;&lt;?xml&apos; VersionInfo EncodingDecl? SDDecl? S? &apos;?&gt;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  parse an XML declaration header  [23] XMLDecl ::= &apos;&lt;?xml&apos; VersionInfo EncodingDecl? SDDecl? S? &apos;?&gt;&apos;</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
     </function>
     <function name='xmlParserAddNodeInfo' file='parser' module='parserInternals'>
-      <info>Insert node info record into the sorted sequence</info>
+      <info>DEPRECATED: Don&apos;t use.  Insert node info record into the sorted sequence</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='info' type='const xmlParserNodeInfoPtr' info='a node info sequence pointer'/>
@@ -12298,13 +12209,13 @@ Could we use @subtypes for this?'/>
       <arg name='...' type='...' info='extra parameters for the message display'/>
     </function>
     <function name='xmlParserFindNodeInfo' file='parser' module='parserInternals'>
-      <info>Find the parser node info struct for a given node</info>
+      <info>DEPRECATED: Don&apos;t use.  Find the parser node info struct for a given node</info>
       <return type='const xmlParserNodeInfo *' info='an xmlParserNodeInfo block pointer or NULL'/>
       <arg name='ctx' type='const xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='node' type='const xmlNodePtr' info='an XML node within the tree'/>
     </function>
     <function name='xmlParserFindNodeInfoIndex' file='parser' module='parserInternals'>
-      <info>xmlParserFindNodeInfoIndex : Find the index that the info record for the given node is or should be at in a sorted sequence</info>
+      <info>DEPRECATED: Don&apos;t use.  xmlParserFindNodeInfoIndex : Find the index that the info record for the given node is or should be at in a sorted sequence</info>
       <return type='unsigned long' info='a long indicating the position of the record'/>
       <arg name='seq' type='const xmlParserNodeInfoSeqPtr' info='a node info sequence pointer'/>
       <arg name='node' type='const xmlNodePtr' info='an XML node pointer'/>
@@ -12315,7 +12226,7 @@ Could we use @subtypes for this?'/>
       <arg name='filename' type='const char *' info='the path to a file'/>
     </function>
     <function name='xmlParserHandlePEReference' file='parserInternals' module='parser'>
-      <info>[69] PEReference ::= &apos;%&apos; Name &apos;;&apos;  [ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ VC: Entity Declared ] In a document with an external subset or external parameter entities with &quot;standalone=&apos;no&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.  A PEReference may have been detected in the current input stream the handling is done accordingly to http://www.w3.org/TR/REC-xml#entproc i.e. - Included in literal in entity values - Included as Parameter Entity reference within DTDs</info>
+      <info>DEPRECATED: Internal function, do not use.  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;  [ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.  [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with &quot;standalone=&apos;yes&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ VC: Entity Declared ] In a document with an external subset or external parameter entities with &quot;standalone=&apos;no&apos;&quot;, ...  ... The declaration of a parameter entity must precede any reference to it...  [ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.  A PEReference may have been detected in the current input stream the handling is done accordingly to http://www.w3.org/TR/REC-xml#entproc i.e. - Included in literal in entity values - Included as Parameter Entity reference within DTDs</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
     </function>
@@ -12343,12 +12254,12 @@ Could we use @subtypes for this?'/>
       <arg name='URI' type='const char *' info='a C string containing the URI or filename'/>
       <arg name='enc' type='xmlCharEncoding' info='the charset encoding if known'/>
     </function>
-    <function name='xmlParserInputBufferCreateFilenameDefault' file='globals' module='xmlIO'>
+    <function name='xmlParserInputBufferCreateFilenameDefault' file='xmlIO' module='xmlIO'>
       <info>Registers a callback for URI input file handling</info>
       <return type='xmlParserInputBufferCreateFilenameFunc' info='the old value of the registration function'/>
       <arg name='func' type='xmlParserInputBufferCreateFilenameFunc' info='function pointer to the new ParserInputBufferCreateFilenameFunc'/>
     </function>
-    <functype name='xmlParserInputBufferCreateFilenameFunc' file='globals' module='globals'>
+    <functype name='xmlParserInputBufferCreateFilenameFunc' file='xmlIO' module='xmlIO'>
       <info>Signature for the function doing the lookup for a suitable input method corresponding to an URI.</info>
       <return type='xmlParserInputBufferPtr' info='the new xmlParserInputBufferPtr in case of success or NULL if no method was found.'/>
       <arg name='URI' type='const char *' info='the URI to read from'/>
@@ -12370,7 +12281,7 @@ Could we use @subtypes for this?'/>
       <arg name='enc' type='xmlCharEncoding' info='the charset encoding if known'/>
     </function>
     <function name='xmlParserInputBufferCreateStatic' file='xmlIO' module='xmlIO'>
-      <info>Create a buffered parser input for the progressive parsing for the input from an immutable memory area. This will not copy the memory area to the buffer, but the memory is expected to be available until the end of the parsing, this is useful for example when using mmap&apos;ed file.</info>
+      <info>DEPRECATED: Use xmlParserInputBufferCreateMem.</info>
       <return type='xmlParserInputBufferPtr' info='the new parser input or NULL'/>
       <arg name='mem' type='const char *' info='the memory input'/>
       <arg name='size' type='int' info='the length of the memory block'/>
@@ -12401,19 +12312,19 @@ Could we use @subtypes for this?'/>
       <arg name='str' type='xmlChar *' info='the string to deallocate'/>
     </functype>
     <function name='xmlParserInputGrow' file='parser' module='parserInternals'>
-      <info>This function increase the input for the parser. It tries to preserve pointers to the input buffer, and keep already read data</info>
+      <info>DEPRECATED: Don&apos;t use.  This function increase the input for the parser. It tries to preserve pointers to the input buffer, and keep already read data</info>
       <return type='int' info='the amount of char read, or -1 in case of error, 0 indicate the end of this entity'/>
       <arg name='in' type='xmlParserInputPtr' info='an XML parser input'/>
       <arg name='len' type='int' info='an indicative size for the lookahead'/>
     </function>
     <function name='xmlParserInputRead' file='parser' module='parserInternals'>
-      <info>This function was internal and is deprecated.</info>
+      <info>DEPRECATED: This function was internal and is deprecated.</info>
       <return type='int' info='-1 as this is an error to use it.'/>
       <arg name='in' type='xmlParserInputPtr' info='an XML parser input'/>
       <arg name='len' type='int' info='an indicative size for the lookahead'/>
     </function>
     <function name='xmlParserInputShrink' file='parserInternals' module='parserInternals'>
-      <info>This function removes used input for the parser.</info>
+      <info>DEPRECATED: Don&apos;t use.  This function removes used input for the parser.</info>
       <return type='void'/>
       <arg name='in' type='xmlParserInputPtr' info='an XML parser input'/>
     </function>
@@ -12500,7 +12411,7 @@ Could we use @subtypes for this?'/>
       <arg name='namespaces' type='const xmlChar **' info='the prefix definitions, array of [URI, prefix] or NULL'/>
     </function>
     <function name='xmlPedanticParserDefault' file='parser' module='parserInternals'>
-      <info>Set and return the previous value for enabling pedantic warnings.</info>
+      <info>DEPRECATED: Use the modern options API with XML_PARSE_PEDANTIC.  Set and return the previous value for enabling pedantic warnings.</info>
       <return type='int' info='the last value for 0 for no substitution, 1 for substitution.'/>
       <arg name='val' type='int' info='int 0 or 1'/>
     </function>
@@ -12723,19 +12634,19 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlRecoverDoc' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is tried anyway</info>
+      <info>DEPRECATED: Use xmlReadDoc with XML_PARSE_RECOVER.  parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is tried anyway</info>
       <return type='xmlDocPtr' info='the resulting document tree or NULL in case of failure'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
     </function>
     <function name='xmlRecoverFile' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>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, it attempts to build a tree anyway</info>
+      <info>DEPRECATED: Use xmlReadFile with XML_PARSE_RECOVER.  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, it attempts to build a tree anyway</info>
       <return type='xmlDocPtr' info='the resulting document tree or NULL in case of failure'/>
       <arg name='filename' type='const char *' info='the filename'/>
     </function>
     <function name='xmlRecoverMemory' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree is tried anyway</info>
+      <info>DEPRECATED: Use xmlReadMemory with XML_PARSE_RECOVER.  parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree is tried anyway</info>
       <return type='xmlDocPtr' info='the resulting document tree or NULL in case of error'/>
       <arg name='buffer' type='const char *' info='an pointer to a char array'/>
       <arg name='size' type='int' info='the size of the array'/>
@@ -12860,12 +12771,12 @@ Could we use @subtypes for this?'/>
       <arg name='readFunc' type='xmlInputReadCallback' info='the xmlInputReadCallback'/>
       <arg name='closeFunc' type='xmlInputCloseCallback' info='the xmlInputCloseCallback'/>
     </function>
-    <function name='xmlRegisterNodeDefault' file='globals' module='globals'>
+    <function name='xmlRegisterNodeDefault' file='tree' module='tree'>
       <info>Registers a callback for node creation</info>
       <return type='xmlRegisterNodeFunc' info='the old value of the registration function'/>
       <arg name='func' type='xmlRegisterNodeFunc' info='function pointer to the new RegisterNodeFunc'/>
     </function>
-    <functype name='xmlRegisterNodeFunc' file='globals' module='globals'>
+    <functype name='xmlRegisterNodeFunc' file='tree' module='tree'>
       <info>Signature for the registration callback of a created node</info>
       <return type='void'/>
       <arg name='node' type='xmlNodePtr' info='the current node'/>
@@ -13321,13 +13232,13 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXDefaultVersion' file='SAX2' module='SAX2'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>Set the default version of SAX used globally by the library. By default, during initialization the default is set to 2. Note that it is generally a better coding style to use xmlSAXVersion() to set up the version explicitly for a given parsing context.</info>
+      <info>DEPRECATED: Use parser option XML_PARSE_SAX1.  Set the default version of SAX used globally by the library. By default, during initialization the default is set to 2. Note that it is generally a better coding style to use xmlSAXVersion() to set up the version explicitly for a given parsing context.</info>
       <return type='int' info='the previous value in case of success and -1 in case of error.'/>
       <arg name='version' type='int' info='the version, 1 or 2'/>
     </function>
     <function name='xmlSAXParseDTD' file='parser' module='parser'>
       <cond>defined(LIBXML_VALID_ENABLED)</cond>
-      <info>Load and parse an external subset.</info>
+      <info>DEPRECATED: Don&apos;t use.  Load and parse an external subset.</info>
       <return type='xmlDtdPtr' info='the resulting xmlDtdPtr or NULL in case of error.'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='ExternalID' type='const xmlChar *' info='a NAME* containing the External ID of the DTD'/>
@@ -13335,7 +13246,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXParseDoc' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory document and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadDoc.  parse an XML in-memory document and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='cur' type='const xmlChar *' info='a pointer to an array of xmlChar'/>
@@ -13343,14 +13254,14 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXParseEntity' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML external entity out of context and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  [78] extParsedEnt ::= TextDecl? content  This correspond to a &quot;Well Balanced&quot; chunk</info>
+      <info>DEPRECATED: Don&apos;t use.  parse an XML external entity out of context and build a tree. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  [78] extParsedEnt ::= TextDecl? content  This correspond to a &quot;Well Balanced&quot; chunk</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='filename' type='const char *' info='the filename'/>
     </function>
     <function name='xmlSAXParseFile' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.  parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='filename' type='const char *' info='the filename'/>
@@ -13358,7 +13269,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXParseFileWithData' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  User data (void *) is stored within the parser context in the context&apos;s _private member, so it is available nearly everywhere in libxml</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.  parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  User data (void *) is stored within the parser context in the context&apos;s _private member, so it is available nearly everywhere in libxml</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='filename' type='const char *' info='the filename'/>
@@ -13367,7 +13278,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXParseMemory' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.  parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='buffer' type='const char *' info='an pointer to a char array'/>
@@ -13376,7 +13287,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXParseMemoryWithData' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  User data (void *) is stored within the parser context in the context&apos;s _private member, so it is available nearly everywhere in libxml</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.  parse an XML in-memory block and use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.  User data (void *) is stored within the parser context in the context&apos;s _private member, so it is available nearly everywhere in libxml</info>
       <return type='xmlDocPtr' info='the resulting document tree'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='the SAX handler block'/>
       <arg name='buffer' type='const char *' info='an pointer to a char array'/>
@@ -13386,7 +13297,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXUserParseFile' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>parse an XML file and call the given SAX handler routines. Automatic support for ZLIB/Compress compressed document is provided</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.  parse an XML file and call the given SAX handler routines. Automatic support for ZLIB/Compress compressed document is provided</info>
       <return type='int' info='0 in case of success or a error number otherwise'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='a SAX handler'/>
       <arg name='user_data' type='void *' info='The user data returned on SAX callbacks'/>
@@ -13394,7 +13305,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSAXUserParseMemory' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>A better SAX parsing routine. parse an XML in-memory buffer and call the given SAX handler routines.</info>
+      <info>DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.  parse an XML in-memory buffer and call the given SAX handler routines.</info>
       <return type='int' info='0 in case of success or a error number otherwise'/>
       <arg name='sax' type='xmlSAXHandlerPtr' info='a SAX handler'/>
       <arg name='user_data' type='void *' info='The user data returned on SAX callbacks'/>
@@ -13528,7 +13439,7 @@ Could we use @subtypes for this?'/>
       <info>Save a subtree starting at the node parameter to a saving context TODO: The function is not fully implemented yet as it does not return the byte count but 0 instead</info>
       <return type='long' info='the number of byte written or -1 in case of error'/>
       <arg name='ctxt' type='xmlSaveCtxtPtr' info='a document saving context'/>
-      <arg name='cur' type='xmlNodePtr' info=''/>
+      <arg name='cur' type='xmlNodePtr' info='the top node of the subtree to save'/>
     </function>
     <function name='xmlSaveUri' file='uri' module='uri'>
       <info>Save the URI as an escaped string</info>
@@ -13552,7 +13463,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSchemaCleanupTypes' file='xmlschemastypes' module='xmlschemastypes'>
       <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
-      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have call cleanup functions at all.  Cleanup the default XML Schemas type library</info>
+      <info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don&apos;t have to call cleanup functions at all.  Cleanup the default XML Schemas type library</info>
       <return type='void'/>
     </function>
     <function name='xmlSchemaCollapseString' file='xmlschemastypes' module='xmlschemastypes'>
@@ -13699,7 +13610,7 @@ Could we use @subtypes for this?'/>
     <function name='xmlSchemaInitTypes' file='xmlschemastypes' module='xmlschemastypes'>
       <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
       <info>Initialize the default XML Schemas type library</info>
-      <return type='void'/>
+      <return type='int' info='0 on success, -1 on error.'/>
     </function>
     <function name='xmlSchemaIsBuiltInTypeFacet' file='xmlschemastypes' module='xmlschemastypes'>
       <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
@@ -14195,7 +14106,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlSetupParserForBuffer' file='parser' module='parser'>
       <cond>defined(LIBXML_SAX1_ENABLED)</cond>
-      <info>Setup the parser context to parse a new buffer; Clears any prior contents from the parser context. The buffer parameter must not be NULL, but the filename parameter can be</info>
+      <info>DEPRECATED: Don&apos;t use.  Setup the parser context to parse a new buffer; Clears any prior contents from the parser context. The buffer parameter must not be NULL, but the filename parameter can be</info>
       <return type='void'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
       <arg name='buffer' type='const xmlChar *' info='a xmlChar * buffer'/>
@@ -14335,7 +14246,7 @@ Could we use @subtypes for this?'/>
       <arg name='node2' type='xmlNodePtr' info='unused'/>
     </function>
     <function name='xmlSkipBlankChars' file='parserInternals' module='parser'>
-      <info>skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.</info>
+      <info>DEPRECATED: Internal function, do not use.  skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.</info>
       <return type='int' info='the number of space chars skipped'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the XML parser context'/>
     </function>
@@ -14486,14 +14397,14 @@ Could we use @subtypes for this?'/>
       <arg name='streamCtxt' type='xmlStreamCtxtPtr' info='the stream context'/>
     </function>
     <function name='xmlStringCurrentChar' file='parserInternals' module='parserInternals'>
-      <info>The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer.</info>
+      <info>DEPRECATED: Internal function, do not use.  The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer.</info>
       <return type='int' info='the current char value and its length'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the XML parser context'/>
       <arg name='cur' type='const xmlChar *' info='pointer to the beginning of the char'/>
       <arg name='len' type='int *' info='pointer to the length of the char read'/>
     </function>
     <function name='xmlStringDecodeEntities' file='parserInternals' module='parser'>
-      <info>Takes a entity string content and process to do the adequate substitutions.  [67] Reference ::= EntityRef | CharRef  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Takes a entity string content and process to do the adequate substitutions.  [67] Reference ::= EntityRef | CharRef  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;</info>
       <return type='xmlChar *' info='A newly allocated string with the substitution done. The caller must deallocate it !'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
       <arg name='str' type='const xmlChar *' info='the input string'/>
@@ -14509,7 +14420,7 @@ Could we use @subtypes for this?'/>
       <arg name='value' type='const xmlChar *' info='the value of the attribute'/>
     </function>
     <function name='xmlStringLenDecodeEntities' file='parserInternals' module='parser'>
-      <info>Takes a entity string content and process to do the adequate substitutions.  [67] Reference ::= EntityRef | CharRef  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Takes a entity string content and process to do the adequate substitutions.  [67] Reference ::= EntityRef | CharRef  [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;</info>
       <return type='xmlChar *' info='A newly allocated string with the substitution done. The caller must deallocate it !'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
       <arg name='str' type='const xmlChar *' info='the input string'/>
@@ -14582,28 +14493,28 @@ Could we use @subtypes for this?'/>
       <info>Signature of the function to use when there is an error and the module handles the new error reporting mechanism.</info>
       <return type='void'/>
       <arg name='userData' type='void *' info='user provided data for the error callback'/>
-      <arg name='error' type='xmlErrorPtr' info='the error being raised.'/>
+      <arg name='error' type='const xmlError *' info='the error being raised.'/>
     </functype>
     <function name='xmlSubstituteEntitiesDefault' file='parser' module='parserInternals'>
-      <info>Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output. This function has to be used to change the default parser behavior SAX::substituteEntities() has to be used for changing that on a file by file basis.</info>
+      <info>DEPRECATED: Use the modern options API with XML_PARSE_NOENT.  Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output. This function has to be used to change the default parser behavior SAX::substituteEntities() has to be used for changing that on a file by file basis.</info>
       <return type='int' info='the last value for 0 for no substitution, 1 for substitution.'/>
       <arg name='val' type='int' info='int 0 or 1'/>
     </function>
     <function name='xmlSwitchEncoding' file='parserInternals' module='parserInternals'>
-      <info>change the input functions when discovering the character encoding of a given entity.</info>
+      <info>Use encoding specified by enum to decode input data.  This function can be used to enforce the encoding of chunks passed to xmlParseChunk.</info>
       <return type='int' info='0 in case of success, -1 otherwise'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
       <arg name='enc' type='xmlCharEncoding' info='the encoding value (number)'/>
     </function>
     <function name='xmlSwitchInputEncoding' file='parserInternals' module='parserInternals'>
-      <info>DEPRECATED: Use xmlSwitchToEncoding  change the input functions when discovering the character encoding of a given entity.</info>
+      <info>DEPRECATED: Internal function, don&apos;t use.  Use encoding handler to decode input data.</info>
       <return type='int' info='0 in case of success, -1 otherwise'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
       <arg name='input' type='xmlParserInputPtr' info='the input stream'/>
       <arg name='handler' type='xmlCharEncodingHandlerPtr' info='the encoding handler'/>
     </function>
     <function name='xmlSwitchToEncoding' file='parserInternals' module='parserInternals'>
-      <info>change the input functions when discovering the character encoding of a given entity.</info>
+      <info>Use encoding handler to decode input data.  This function can be used to enforce the encoding of chunks passed to xmlParseChunk.</info>
       <return type='int' info='0 in case of success, -1 otherwise'/>
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
       <arg name='handler' type='xmlCharEncodingHandlerPtr' info='the encoding handler'/>
@@ -15038,6 +14949,13 @@ Could we use @subtypes for this?'/>
       <arg name='f' type='xmlTextReaderErrorFunc' info='the callback function to call on error and warnings'/>
       <arg name='arg' type='void *' info='a user argument to pass to the callback function'/>
     </function>
+    <function name='xmlTextReaderSetMaxAmplification' file='xmlreader' module='xmlreader'>
+      <cond>defined(LIBXML_READER_ENABLED)</cond>
+      <info>Set the maximum amplification factor. See xmlCtxtSetMaxAmplification.</info>
+      <return type='void'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='maxAmpl' type='unsigned' info='maximum amplification factor'/>
+    </function>
     <function name='xmlTextReaderSetParserProp' file='xmlreader' module='xmlreader'>
       <cond>defined(LIBXML_READER_ENABLED)</cond>
       <info>Change the parser processing behaviour by changing some of its internal properties. Note that some properties can only be changed before any read has been done.</info>
@@ -15687,99 +15605,102 @@ Could we use @subtypes for this?'/>
       <arg name='format' type='const char *' info='format string (see printf)'/>
       <arg name='argptr' type='va_list' info='pointer to the first member of the variable argument list.'/>
     </function>
-    <function name='xmlThrDefBufferAllocScheme' file='globals' module='globals'>
+    <function name='xmlThrDefBufferAllocScheme' file='tree' module='globals'>
       <info></info>
       <return type='xmlBufferAllocationScheme' info=''/>
       <arg name='v' type='xmlBufferAllocationScheme' info=''/>
     </function>
-    <function name='xmlThrDefDefaultBufferSize' file='globals' module='globals'>
+    <function name='xmlThrDefDefaultBufferSize' file='tree' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefDeregisterNodeDefault' file='globals' module='globals'>
+    <function name='xmlThrDefDeregisterNodeDefault' file='tree' module='globals'>
       <info></info>
       <return type='xmlDeregisterNodeFunc' info=''/>
       <arg name='func' type='xmlDeregisterNodeFunc' info=''/>
     </function>
-    <function name='xmlThrDefDoValidityCheckingDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefDoValidityCheckingDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefGetWarningsDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefGetWarningsDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefIndentTreeOutput' file='globals' module='globals'>
+    <function name='xmlThrDefIndentTreeOutput' file='xmlsave' module='globals'>
+      <cond>defined(LIBXML_OUTPUT_ENABLED)</cond>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefKeepBlanksDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefKeepBlanksDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefLineNumbersDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefLineNumbersDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefLoadExtDtdDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefLoadExtDtdDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefOutputBufferCreateFilenameDefault' file='globals' module='globals'>
+    <function name='xmlThrDefOutputBufferCreateFilenameDefault' file='xmlIO' module='globals'>
       <info></info>
       <return type='xmlOutputBufferCreateFilenameFunc' info=''/>
       <arg name='func' type='xmlOutputBufferCreateFilenameFunc' info=''/>
     </function>
-    <function name='xmlThrDefParserDebugEntities' file='globals' module='globals'>
+    <function name='xmlThrDefParserDebugEntities' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefParserInputBufferCreateFilenameDefault' file='globals' module='globals'>
+    <function name='xmlThrDefParserInputBufferCreateFilenameDefault' file='xmlIO' module='globals'>
       <info></info>
       <return type='xmlParserInputBufferCreateFilenameFunc' info=''/>
       <arg name='func' type='xmlParserInputBufferCreateFilenameFunc' info=''/>
     </function>
-    <function name='xmlThrDefPedanticParserDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefPedanticParserDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefRegisterNodeDefault' file='globals' module='globals'>
+    <function name='xmlThrDefRegisterNodeDefault' file='tree' module='globals'>
       <info></info>
       <return type='xmlRegisterNodeFunc' info=''/>
       <arg name='func' type='xmlRegisterNodeFunc' info=''/>
     </function>
-    <function name='xmlThrDefSaveNoEmptyTags' file='globals' module='globals'>
+    <function name='xmlThrDefSaveNoEmptyTags' file='xmlsave' module='globals'>
+      <cond>defined(LIBXML_OUTPUT_ENABLED)</cond>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefSetGenericErrorFunc' file='globals' module='globals'>
+    <function name='xmlThrDefSetGenericErrorFunc' file='xmlerror' module='globals'>
       <info></info>
       <return type='void'/>
       <arg name='ctx' type='void *' info=''/>
       <arg name='handler' type='xmlGenericErrorFunc' info=''/>
     </function>
-    <function name='xmlThrDefSetStructuredErrorFunc' file='globals' module='globals'>
+    <function name='xmlThrDefSetStructuredErrorFunc' file='xmlerror' module='globals'>
       <info></info>
       <return type='void'/>
       <arg name='ctx' type='void *' info=''/>
       <arg name='handler' type='xmlStructuredErrorFunc' info=''/>
     </function>
-    <function name='xmlThrDefSubstituteEntitiesDefaultValue' file='globals' module='globals'>
+    <function name='xmlThrDefSubstituteEntitiesDefaultValue' file='parser' module='globals'>
       <info></info>
       <return type='int' info=''/>
       <arg name='v' type='int' info=''/>
     </function>
-    <function name='xmlThrDefTreeIndentString' file='globals' module='globals'>
+    <function name='xmlThrDefTreeIndentString' file='xmlsave' module='globals'>
+      <cond>defined(LIBXML_OUTPUT_ENABLED)</cond>
       <info></info>
       <return type='const char *' info=''/>
       <arg name='v' type='const char *' info=''/>
@@ -16788,7 +16709,7 @@ Could we use @subtypes for this?'/>
       <arg name='str' type='const xmlChar *' info='the string of the URI to escape'/>
     </function>
     <function name='xmlURIEscapeStr' file='uri' module='uri'>
-      <info>This routine escapes a string to hex, ignoring reserved characters (a-z) and the characters in the exception list.</info>
+      <info>This routine escapes a string to hex, ignoring reserved characters (a-z, A-Z, 0-9, &quot;@-_.!~*&apos;()&quot;) and the characters in the exception list.</info>
       <return type='xmlChar *' info='a new escaped string or NULL in case of error.'/>
       <arg name='str' type='const xmlChar *' info='string to escape'/>
       <arg name='list' type='const xmlChar *' info='exception list string of chars not to escape'/>
@@ -16965,7 +16886,7 @@ Could we use @subtypes for this?'/>
       <return type='int' info='1 if valid or 0 otherwise'/>
       <arg name='ctxt' type='xmlValidCtxtPtr' info='the validation context'/>
       <arg name='doc' type='xmlDocPtr' info='a document instance'/>
-      <arg name='elem' type='xmlNodePtr' info='an element instance'/>
+      <arg name='root' type='xmlNodePtr' info='an element instance'/>
     </function>
     <function name='xmlValidateElementDecl' file='valid' module='valid'>
       <cond>defined(LIBXML_VALID_ENABLED)</cond>
@@ -16976,7 +16897,6 @@ Could we use @subtypes for this?'/>
       <arg name='elem' type='xmlElementPtr' info='an element definition'/>
     </function>
     <function name='xmlValidateNCName' file='tree' module='tree'>
-      <cond>defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)</cond>
       <info>Check that a value conforms to the lexical space of NCName</info>
       <return type='int' info='0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.'/>
       <arg name='value' type='const xmlChar *' info='the value to check'/>
@@ -17586,7 +17506,7 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlXPathInit' file='xpath' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)</cond>
-      <info>DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.  Initialize the XPath environment</info>
+      <info>DEPRECATED: Alias for xmlInitParser.</info>
       <return type='void'/>
     </function>
     <function name='xmlXPathIntersection' file='xpathInternals' module='xpath'>
@@ -17598,13 +17518,13 @@ Could we use @subtypes for this?'/>
     </function>
     <function name='xmlXPathIsInf' file='xpath' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)</cond>
-      <info></info>
+      <info>Checks whether a double is an infinity.</info>
       <return type='int' info='1 if the value is +Infinite, -1 if -Infinite, 0 otherwise'/>
       <arg name='val' type='double' info='a double value'/>
     </function>
     <function name='xmlXPathIsNaN' file='xpath' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)</cond>
-      <info></info>
+      <info>Checks whether a double is a NaN.</info>
       <return type='int' info='1 if the value is a NaN, 0 otherwise'/>
       <arg name='val' type='double' info='a double value'/>
     </function>
@@ -17887,7 +17807,7 @@ Could we use @subtypes for this?'/>
     <function name='xmlXPathNodeSetMerge' file='xpathInternals' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
       <info>Merges two nodesets, all nodes from @val2 are added to @val1 if @val1 is NULL, a new set is created and copied from @val2</info>
-      <return type='xmlNodeSetPtr' info='@val1 once extended or NULL in case of error.'/>
+      <return type='xmlNodeSetPtr' info='@val1 once extended or NULL in case of error.  Frees @val1 in case of error.'/>
       <arg name='val1' type='xmlNodeSetPtr' info='the first NodeSet or NULL'/>
       <arg name='val2' type='xmlNodeSetPtr' info='the second NodeSet'/>
     </function>
@@ -18248,13 +18168,13 @@ Could we use @subtypes for this?'/>
     <function name='xmlXPathWrapNodeSet' file='xpathInternals' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
       <info>Wrap the Nodeset @val in a new xmlXPathObjectPtr</info>
-      <return type='xmlXPathObjectPtr' info='the newly created object.'/>
+      <return type='xmlXPathObjectPtr' info='the newly created object.  In case of error the node set is destroyed and NULL is returned.'/>
       <arg name='val' type='xmlNodeSetPtr' info='the NodePtr value'/>
     </function>
     <function name='xmlXPathWrapString' file='xpathInternals' module='xpath'>
       <cond>defined(LIBXML_XPATH_ENABLED)</cond>
       <info>Wraps the @val string into an XPath object.</info>
-      <return type='xmlXPathObjectPtr' info='the newly created object.'/>
+      <return type='xmlXPathObjectPtr' info='the newly created object.  Frees @val in case of error.'/>
       <arg name='val' type='xmlChar *' info='the xmlChar * value'/>
     </function>
     <function name='xmlXPatherror' file='xpathInternals' module='xpath'>
diff --git a/doc/symbols.xml b/doc/symbols.xml
deleted file mode 100644 (file)
index 2b667e0..0000000
+++ /dev/null
@@ -1,1774 +0,0 @@
-<!-- This file describes all the exported entry points from the
-     library, groupped by release with the first release being 2.4.30
-     Add new exported entry points at the end, this will be used to
-     generate libxml2.syms the definition of exported symbols from
-     shared libraries
-  -->
-<symbols>
-  <release version="2.4.30">
-    <symbol file="debugXML">xmlBoolToText</symbol>
-    <symbol file="debugXML">xmlDebugDumpAttr</symbol>
-    <symbol file="debugXML">xmlDebugDumpAttrList</symbol>
-    <symbol file="debugXML">xmlDebugDumpDTD</symbol>
-    <symbol file="debugXML">xmlDebugDumpDocument</symbol>
-    <symbol file="debugXML">xmlDebugDumpDocumentHead</symbol>
-    <symbol file="debugXML">xmlDebugDumpEntities</symbol>
-    <symbol file="debugXML">xmlDebugDumpNode</symbol>
-    <symbol file="debugXML">xmlDebugDumpNodeList</symbol>
-    <symbol file="debugXML">xmlDebugDumpOneNode</symbol>
-    <symbol file="debugXML">xmlDebugDumpString</symbol>
-    <symbol file="debugXML">xmlLsCountNode</symbol>
-    <symbol file="debugXML">xmlLsOneNode</symbol>
-    <symbol file="debugXML">xmlShell</symbol>
-    <symbol file="debugXML">xmlShellBase</symbol>
-    <symbol file="debugXML">xmlShellCat</symbol>
-    <symbol file="debugXML">xmlShellDir</symbol>
-    <symbol file="debugXML">xmlShellDu</symbol>
-    <symbol file="debugXML">xmlShellList</symbol>
-    <symbol file="debugXML">xmlShellLoad</symbol>
-    <symbol file="debugXML">xmlShellPrintNode</symbol>
-    <symbol file="debugXML">xmlShellPrintXPathError</symbol>
-    <symbol file="debugXML">xmlShellPrintXPathResult</symbol>
-    <symbol file="debugXML">xmlShellPwd</symbol>
-    <symbol file="debugXML">xmlShellSave</symbol>
-    <symbol file="debugXML">xmlShellValidate</symbol>
-    <symbol file="debugXML">xmlShellWrite</symbol>
-    <symbol file="xpointer">xmlXPtrBuildNodeList</symbol>
-    <symbol file="xpointer">xmlXPtrEval</symbol>
-    <symbol file="xpointer">xmlXPtrEvalRangePredicate</symbol>
-    <symbol file="xpointer">xmlXPtrFreeLocationSet</symbol>
-    <symbol file="xpointer">xmlXPtrLocationSetAdd</symbol>
-    <symbol file="xpointer">xmlXPtrLocationSetCreate</symbol>
-    <symbol file="xpointer">xmlXPtrLocationSetDel</symbol>
-    <symbol file="xpointer">xmlXPtrLocationSetMerge</symbol>
-    <symbol file="xpointer">xmlXPtrLocationSetRemove</symbol>
-    <symbol file="xpointer">xmlXPtrNewCollapsedRange</symbol>
-    <symbol file="xpointer">xmlXPtrNewContext</symbol>
-    <symbol file="xpointer">xmlXPtrNewLocationSetNodeSet</symbol>
-    <symbol file="xpointer">xmlXPtrNewLocationSetNodes</symbol>
-    <symbol file="xpointer">xmlXPtrNewRange</symbol>
-    <symbol file="xpointer">xmlXPtrNewRangeNodeObject</symbol>
-    <symbol file="xpointer">xmlXPtrNewRangeNodePoint</symbol>
-    <symbol file="xpointer">xmlXPtrNewRangeNodes</symbol>
-    <symbol file="xpointer">xmlXPtrNewRangePointNode</symbol>
-    <symbol file="xpointer">xmlXPtrNewRangePoints</symbol>
-    <symbol file="xpointer">xmlXPtrRangeToFunction</symbol>
-    <symbol file="xpointer">xmlXPtrWrapLocationSet</symbol>
-    <symbol file="SAX">attribute</symbol>
-    <symbol file="SAX">attributeDecl</symbol>
-    <symbol file="SAX">cdataBlock</symbol>
-    <symbol file="SAX">characters</symbol>
-    <symbol file="SAX">checkNamespace</symbol>
-    <symbol file="SAX">comment</symbol>
-    <symbol file="SAX2" removed="2.10.0">docbDefaultSAXHandlerInit</symbol>
-    <symbol file="SAX">elementDecl</symbol>
-    <symbol file="SAX">endDocument</symbol>
-    <symbol file="SAX">endElement</symbol>
-    <symbol file="SAX">entityDecl</symbol>
-    <symbol file="SAX">externalSubset</symbol>
-    <symbol file="SAX">getColumnNumber</symbol>
-    <symbol file="SAX">getEntity</symbol>
-    <symbol file="SAX">getLineNumber</symbol>
-    <symbol file="SAX">getNamespace</symbol>
-    <symbol file="SAX">getParameterEntity</symbol>
-    <symbol file="SAX">getPublicId</symbol>
-    <symbol file="SAX">getSystemId</symbol>
-    <symbol file="SAX">globalNamespace</symbol>
-    <symbol file="SAX">hasExternalSubset</symbol>
-    <symbol file="SAX">hasInternalSubset</symbol>
-    <symbol file="SAX2">htmlDefaultSAXHandlerInit</symbol>
-    <symbol file="SAX">ignorableWhitespace</symbol>
-    <symbol file="SAX" removed="2.10.0">initdocbDefaultSAXHandler</symbol>
-    <symbol file="SAX">inithtmlDefaultSAXHandler</symbol>
-    <symbol file="SAX">initxmlDefaultSAXHandler</symbol>
-    <symbol file="SAX">internalSubset</symbol>
-    <symbol file="SAX">isStandalone</symbol>
-    <symbol file="SAX">namespaceDecl</symbol>
-    <symbol file="SAX">notationDecl</symbol>
-    <symbol file="SAX">processingInstruction</symbol>
-    <symbol file="SAX">reference</symbol>
-    <symbol file="SAX">resolveEntity</symbol>
-    <symbol file="SAX">setDocumentLocator</symbol>
-    <symbol file="SAX">setNamespace</symbol>
-    <symbol file="SAX">startDocument</symbol>
-    <symbol file="SAX">startElement</symbol>
-    <symbol file="SAX">unparsedEntityDecl</symbol>
-    <symbol file="SAX2">xmlDefaultSAXHandlerInit</symbol>
-    <symbol file="parserInternals">htmlCreateFileParserCtxt</symbol>
-    <symbol file="parserInternals">htmlInitAutoClose</symbol>
-    <symbol file="parserInternals">inputPop</symbol>
-    <symbol file="parserInternals">inputPush</symbol>
-    <symbol file="parserInternals">namePop</symbol>
-    <symbol file="parserInternals">namePush</symbol>
-    <symbol file="parserInternals">nodePop</symbol>
-    <symbol file="parserInternals">nodePush</symbol>
-    <symbol file="parserInternals">xmlCheckLanguageID</symbol>
-    <symbol file="parserInternals">xmlCopyChar</symbol>
-    <symbol file="parserInternals">xmlCopyCharMultiByte</symbol>
-    <symbol file="parserInternals">xmlCreateEntityParserCtxt</symbol>
-    <symbol file="parserInternals">xmlCreateFileParserCtxt</symbol>
-    <symbol file="parserInternals">xmlCreateMemoryParserCtxt</symbol>
-    <symbol file="parserInternals">xmlCurrentChar</symbol>
-    <symbol file="parserInternals">xmlDecodeEntities</symbol>
-    <symbol file="parserInternals">xmlFreeInputStream</symbol>
-    <symbol file="parserInternals">xmlHandleEntity</symbol>
-    <symbol file="chvalid">xmlIsBaseChar</symbol>
-    <symbol file="chvalid">xmlIsBlank</symbol>
-    <symbol file="chvalid">xmlIsChar</symbol>
-    <symbol file="chvalid">xmlIsCombining</symbol>
-    <symbol file="chvalid">xmlIsDigit</symbol>
-    <symbol file="chvalid">xmlIsExtender</symbol>
-    <symbol file="chvalid">xmlIsIdeographic</symbol>
-    <symbol file="parserInternals">xmlIsLetter</symbol>
-    <symbol file="chvalid">xmlIsPubidChar</symbol>
-    <symbol file="parserInternals">xmlNamespaceParseNCName</symbol>
-    <symbol file="parserInternals">xmlNamespaceParseNSDef</symbol>
-    <symbol file="parserInternals">xmlNamespaceParseQName</symbol>
-    <symbol file="parserInternals">xmlNewEntityInputStream</symbol>
-    <symbol file="parserInternals">xmlNewInputFromFile</symbol>
-    <symbol file="parserInternals">xmlNewInputStream</symbol>
-    <symbol file="parser">xmlNewParserCtxt</symbol>
-    <symbol file="parserInternals">xmlNewStringInputStream</symbol>
-    <symbol file="parserInternals">xmlNextChar</symbol>
-    <symbol file="parserInternals">xmlParseAttValue</symbol>
-    <symbol file="parserInternals">xmlParseAttribute</symbol>
-    <symbol file="parserInternals">xmlParseAttributeListDecl</symbol>
-    <symbol file="parserInternals">xmlParseAttributeType</symbol>
-    <symbol file="parserInternals">xmlParseCDSect</symbol>
-    <symbol file="parserInternals">xmlParseCharData</symbol>
-    <symbol file="parserInternals">xmlParseCharRef</symbol>
-    <symbol file="parserInternals">xmlParseComment</symbol>
-    <symbol file="parserInternals">xmlParseContent</symbol>
-    <symbol file="parserInternals">xmlParseDefaultDecl</symbol>
-    <symbol file="parserInternals">xmlParseDocTypeDecl</symbol>
-    <symbol file="parserInternals">xmlParseElement</symbol>
-    <symbol file="parserInternals">xmlParseElementChildrenContentDecl</symbol>
-    <symbol file="parserInternals">xmlParseElementContentDecl</symbol>
-    <symbol file="parserInternals">xmlParseElementDecl</symbol>
-    <symbol file="parserInternals">xmlParseElementMixedContentDecl</symbol>
-    <symbol file="parserInternals">xmlParseEncName</symbol>
-    <symbol file="parserInternals">xmlParseEncodingDecl</symbol>
-    <symbol file="parserInternals">xmlParseEndTag</symbol>
-    <symbol file="parserInternals">xmlParseEntityDecl</symbol>
-    <symbol file="parserInternals">xmlParseEntityRef</symbol>
-    <symbol file="parserInternals">xmlParseEntityValue</symbol>
-    <symbol file="parserInternals">xmlParseEnumeratedType</symbol>
-    <symbol file="parserInternals">xmlParseEnumerationType</symbol>
-    <symbol file="parserInternals">xmlParseExternalID</symbol>
-    <symbol file="parserInternals">xmlParseExternalSubset</symbol>
-    <symbol file="parserInternals">xmlParseMarkupDecl</symbol>
-    <symbol file="parserInternals">xmlParseMisc</symbol>
-    <symbol file="parserInternals">xmlParseName</symbol>
-    <symbol file="parserInternals">xmlParseNamespace</symbol>
-    <symbol file="parserInternals">xmlParseNmtoken</symbol>
-    <symbol file="parserInternals">xmlParseNotationDecl</symbol>
-    <symbol file="parserInternals">xmlParseNotationType</symbol>
-    <symbol file="parserInternals">xmlParsePEReference</symbol>
-    <symbol file="parserInternals">xmlParsePI</symbol>
-    <symbol file="parserInternals">xmlParsePITarget</symbol>
-    <symbol file="parserInternals">xmlParsePubidLiteral</symbol>
-    <symbol file="parserInternals">xmlParseQuotedString</symbol>
-    <symbol file="parserInternals">xmlParseReference</symbol>
-    <symbol file="parserInternals">xmlParseSDDecl</symbol>
-    <symbol file="parserInternals">xmlParseStartTag</symbol>
-    <symbol file="parserInternals">xmlParseSystemLiteral</symbol>
-    <symbol file="parserInternals">xmlParseTextDecl</symbol>
-    <symbol file="parserInternals">xmlParseVersionInfo</symbol>
-    <symbol file="parserInternals">xmlParseVersionNum</symbol>
-    <symbol file="parserInternals">xmlParseXMLDecl</symbol>
-    <symbol file="parserInternals">xmlParserHandlePEReference</symbol>
-    <symbol file="parserInternals">xmlParserHandleReference</symbol>
-    <symbol file="parserInternals">xmlParserInputShrink</symbol>
-    <symbol file="parserInternals">xmlPopInput</symbol>
-    <symbol file="parserInternals">xmlPushInput</symbol>
-    <symbol file="parserInternals">xmlScanName</symbol>
-    <symbol file="parserInternals">xmlSetEntityReferenceFunc</symbol>
-    <symbol file="parserInternals">xmlSkipBlankChars</symbol>
-    <symbol file="parserInternals">xmlSplitQName</symbol>
-    <symbol file="parserInternals">xmlStringComment</symbol>
-    <symbol file="parserInternals">xmlStringCurrentChar</symbol>
-    <symbol file="parserInternals">xmlStringDecodeEntities</symbol>
-    <symbol file="parserInternals">xmlStringText</symbol>
-    <symbol file="parserInternals">xmlStringTextNoenc</symbol>
-    <symbol file="parserInternals">xmlSwitchEncoding</symbol>
-    <symbol file="parserInternals">xmlSwitchToEncoding</symbol>
-    <symbol file="c14n">xmlC14NDocDumpMemory</symbol>
-    <symbol file="c14n">xmlC14NDocSave</symbol>
-    <symbol file="c14n">xmlC14NDocSaveTo</symbol>
-    <symbol file="c14n">xmlC14NExecute</symbol>
-    <symbol file="catalog">xmlACatalogAdd</symbol>
-    <symbol file="catalog">xmlACatalogDump</symbol>
-    <symbol file="catalog">xmlACatalogRemove</symbol>
-    <symbol file="catalog">xmlACatalogResolve</symbol>
-    <symbol file="catalog">xmlACatalogResolvePublic</symbol>
-    <symbol file="catalog">xmlACatalogResolveSystem</symbol>
-    <symbol file="catalog">xmlACatalogResolveURI</symbol>
-    <symbol file="catalog">xmlCatalogAdd</symbol>
-    <symbol file="catalog">xmlCatalogAddLocal</symbol>
-    <symbol file="catalog">xmlCatalogCleanup</symbol>
-    <symbol file="catalog">xmlCatalogConvert</symbol>
-    <symbol file="catalog">xmlCatalogDump</symbol>
-    <symbol file="catalog">xmlCatalogFreeLocal</symbol>
-    <symbol file="catalog">xmlCatalogGetDefaults</symbol>
-    <symbol file="catalog">xmlCatalogGetPublic</symbol>
-    <symbol file="catalog">xmlCatalogGetSystem</symbol>
-    <symbol file="catalog">xmlCatalogIsEmpty</symbol>
-    <symbol file="catalog">xmlCatalogLocalResolve</symbol>
-    <symbol file="catalog">xmlCatalogLocalResolveURI</symbol>
-    <symbol file="catalog">xmlCatalogRemove</symbol>
-    <symbol file="catalog">xmlCatalogResolve</symbol>
-    <symbol file="catalog">xmlCatalogResolvePublic</symbol>
-    <symbol file="catalog">xmlCatalogResolveSystem</symbol>
-    <symbol file="catalog">xmlCatalogResolveURI</symbol>
-    <symbol file="catalog">xmlCatalogSetDebug</symbol>
-    <symbol file="catalog">xmlCatalogSetDefaultPrefer</symbol>
-    <symbol file="catalog">xmlCatalogSetDefaults</symbol>
-    <symbol file="catalog">xmlConvertSGMLCatalog</symbol>
-    <symbol file="catalog">xmlFreeCatalog</symbol>
-    <symbol file="catalog">xmlInitializeCatalog</symbol>
-    <symbol file="catalog">xmlLoadACatalog</symbol>
-    <symbol file="catalog">xmlLoadCatalog</symbol>
-    <symbol file="catalog">xmlLoadCatalogs</symbol>
-    <symbol file="catalog">xmlLoadSGMLSuperCatalog</symbol>
-    <symbol file="catalog">xmlNewCatalog</symbol>
-    <symbol file="catalog">xmlParseCatalogFile</symbol>
-    <symbol file="xpathInternals">valuePop</symbol>
-    <symbol file="xpathInternals">valuePush</symbol>
-    <symbol file="xpathInternals">xmlXPathAddValues</symbol>
-    <symbol file="xpathInternals">xmlXPathBooleanFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathCeilingFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathCompareValues</symbol>
-    <symbol file="xpathInternals">xmlXPathConcatFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathContainsFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathCountFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathDebugDumpCompExpr</symbol>
-    <symbol file="xpathInternals">xmlXPathDebugDumpObject</symbol>
-    <symbol file="xpathInternals">xmlXPathDifference</symbol>
-    <symbol file="xpathInternals">xmlXPathDistinct</symbol>
-    <symbol file="xpathInternals">xmlXPathDistinctSorted</symbol>
-    <symbol file="xpathInternals">xmlXPathDivValues</symbol>
-    <symbol file="xpathInternals">xmlXPathEqualValues</symbol>
-    <symbol file="xpathInternals">xmlXPathEvalExpr</symbol>
-    <symbol file="xpathInternals">xmlXPathEvaluatePredicateResult</symbol>
-    <symbol file="xpathInternals">xmlXPathFalseFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathFloorFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathFreeParserContext</symbol>
-    <symbol file="xpathInternals">xmlXPathFunctionLookup</symbol>
-    <symbol file="xpathInternals">xmlXPathFunctionLookupNS</symbol>
-    <symbol file="xpathInternals">xmlXPathHasSameNodes</symbol>
-    <symbol file="xpathInternals">xmlXPathIdFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathIntersection</symbol>
-    <symbol file="xpathInternals">xmlXPathIsNodeType</symbol>
-    <symbol file="xpathInternals">xmlXPathLangFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathLastFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathLeading</symbol>
-    <symbol file="xpathInternals">xmlXPathLeadingSorted</symbol>
-    <symbol file="xpathInternals">xmlXPathLocalNameFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathModValues</symbol>
-    <symbol file="xpathInternals">xmlXPathMultValues</symbol>
-    <symbol file="xpathInternals">xmlXPathNamespaceURIFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathNewBoolean</symbol>
-    <symbol file="xpathInternals">xmlXPathNewCString</symbol>
-    <symbol file="xpathInternals">xmlXPathNewFloat</symbol>
-    <symbol file="xpathInternals">xmlXPathNewNodeSet</symbol>
-    <symbol file="xpathInternals">xmlXPathNewNodeSetList</symbol>
-    <symbol file="xpathInternals">xmlXPathNewParserContext</symbol>
-    <symbol file="xpathInternals">xmlXPathNewString</symbol>
-    <symbol file="xpathInternals">xmlXPathNewValueTree</symbol>
-    <symbol file="xpathInternals">xmlXPathNextAncestor</symbol>
-    <symbol file="xpathInternals">xmlXPathNextAncestorOrSelf</symbol>
-    <symbol file="xpathInternals">xmlXPathNextAttribute</symbol>
-    <symbol file="xpathInternals">xmlXPathNextChild</symbol>
-    <symbol file="xpathInternals">xmlXPathNextDescendant</symbol>
-    <symbol file="xpathInternals">xmlXPathNextDescendantOrSelf</symbol>
-    <symbol file="xpathInternals">xmlXPathNextFollowing</symbol>
-    <symbol file="xpathInternals">xmlXPathNextFollowingSibling</symbol>
-    <symbol file="xpathInternals">xmlXPathNextNamespace</symbol>
-    <symbol file="xpathInternals">xmlXPathNextParent</symbol>
-    <symbol file="xpathInternals">xmlXPathNextPreceding</symbol>
-    <symbol file="xpathInternals">xmlXPathNextPrecedingSibling</symbol>
-    <symbol file="xpathInternals">xmlXPathNextSelf</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeLeading</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeLeadingSorted</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetAdd</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetAddNs</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetAddUnique</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetContains</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetDel</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetFreeNs</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetMerge</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetRemove</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeSetSort</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeTrailing</symbol>
-    <symbol file="xpathInternals">xmlXPathNodeTrailingSorted</symbol>
-    <symbol file="xpathInternals">xmlXPathNormalizeFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathNotEqualValues</symbol>
-    <symbol file="xpathInternals">xmlXPathNotFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathNsLookup</symbol>
-    <symbol file="xpathInternals">xmlXPathNumberFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathParseNCName</symbol>
-    <symbol file="xpathInternals">xmlXPathParseName</symbol>
-    <symbol file="xpathInternals">xmlXPathPopBoolean</symbol>
-    <symbol file="xpathInternals">xmlXPathPopExternal</symbol>
-    <symbol file="xpathInternals">xmlXPathPopNodeSet</symbol>
-    <symbol file="xpathInternals">xmlXPathPopNumber</symbol>
-    <symbol file="xpathInternals">xmlXPathPopString</symbol>
-    <symbol file="xpathInternals">xmlXPathPositionFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterAllFunctions</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterFunc</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterFuncLookup</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterFuncNS</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterNs</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterVariable</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterVariableLookup</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisterVariableNS</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisteredFuncsCleanup</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisteredNsCleanup</symbol>
-    <symbol file="xpathInternals">xmlXPathRegisteredVariablesCleanup</symbol>
-    <symbol file="xpathInternals">xmlXPathRoot</symbol>
-    <symbol file="xpathInternals">xmlXPathRoundFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathStartsWithFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathStringEvalNumber</symbol>
-    <symbol file="xpathInternals">xmlXPathStringFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathStringLengthFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathSubValues</symbol>
-    <symbol file="xpathInternals">xmlXPathSubstringAfterFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathSubstringBeforeFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathSubstringFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathSumFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathTrailing</symbol>
-    <symbol file="xpathInternals">xmlXPathTrailingSorted</symbol>
-    <symbol file="xpathInternals">xmlXPathTranslateFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathTrueFunction</symbol>
-    <symbol file="xpathInternals">xmlXPathValueFlipSign</symbol>
-    <symbol file="xpathInternals">xmlXPathVariableLookup</symbol>
-    <symbol file="xpathInternals">xmlXPathVariableLookupNS</symbol>
-    <symbol file="xpathInternals">xmlXPathWrapCString</symbol>
-    <symbol file="xpathInternals">xmlXPathWrapExternal</symbol>
-    <symbol file="xpathInternals">xmlXPathWrapNodeSet</symbol>
-    <symbol file="xpathInternals">xmlXPathWrapString</symbol>
-    <symbol file="xpathInternals">xmlXPatherror</symbol>
-    <symbol file="xmlautomata">xmlAutomataCompile</symbol>
-    <symbol file="xmlautomata">xmlAutomataGetInitState</symbol>
-    <symbol file="xmlautomata">xmlAutomataIsDeterminist</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewAllTrans</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewCountTrans</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewCountedTrans</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewCounter</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewCounterTrans</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewEpsilon</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewOnceTrans</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewState</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewTransition</symbol>
-    <symbol file="xmlautomata">xmlAutomataSetFinalState</symbol>
-    <symbol file="xmlautomata">xmlFreeAutomata</symbol>
-    <symbol file="xmlautomata">xmlNewAutomata</symbol>
-    <symbol file="HTMLtree">htmlDocContentDumpFormatOutput</symbol>
-    <symbol file="HTMLtree">htmlDocContentDumpOutput</symbol>
-    <symbol file="HTMLtree">htmlDocDump</symbol>
-    <symbol file="HTMLtree">htmlDocDumpMemory</symbol>
-    <symbol file="HTMLtree">htmlGetMetaEncoding</symbol>
-    <symbol file="HTMLtree">htmlIsBooleanAttr</symbol>
-    <symbol file="HTMLtree">htmlNewDoc</symbol>
-    <symbol file="HTMLtree">htmlNewDocNoDtD</symbol>
-    <symbol file="HTMLtree">htmlNodeDump</symbol>
-    <symbol file="HTMLtree">htmlNodeDumpFile</symbol>
-    <symbol file="HTMLtree">htmlNodeDumpFileFormat</symbol>
-    <symbol file="HTMLtree">htmlNodeDumpFormatOutput</symbol>
-    <symbol file="HTMLtree">htmlNodeDumpOutput</symbol>
-    <symbol file="HTMLtree">htmlSaveFile</symbol>
-    <symbol file="HTMLtree">htmlSaveFileEnc</symbol>
-    <symbol file="HTMLtree">htmlSaveFileFormat</symbol>
-    <symbol file="HTMLtree">htmlSetMetaEncoding</symbol>
-    <symbol file="nanoftp">xmlNanoFTPCheckResponse</symbol>
-    <symbol file="nanoftp">xmlNanoFTPCleanup</symbol>
-    <symbol file="nanoftp">xmlNanoFTPClose</symbol>
-    <symbol file="nanoftp">xmlNanoFTPCloseConnection</symbol>
-    <symbol file="nanoftp">xmlNanoFTPConnect</symbol>
-    <symbol file="nanoftp">xmlNanoFTPConnectTo</symbol>
-    <symbol file="nanoftp">xmlNanoFTPCwd</symbol>
-    <symbol file="nanoftp">xmlNanoFTPFreeCtxt</symbol>
-    <symbol file="nanoftp">xmlNanoFTPGet</symbol>
-    <symbol file="nanoftp">xmlNanoFTPGetConnection</symbol>
-    <symbol file="nanoftp">xmlNanoFTPGetResponse</symbol>
-    <symbol file="nanoftp">xmlNanoFTPGetSocket</symbol>
-    <symbol file="nanoftp">xmlNanoFTPInit</symbol>
-    <symbol file="nanoftp">xmlNanoFTPList</symbol>
-    <symbol file="nanoftp">xmlNanoFTPNewCtxt</symbol>
-    <symbol file="nanoftp">xmlNanoFTPOpen</symbol>
-    <symbol file="nanoftp">xmlNanoFTPProxy</symbol>
-    <symbol file="nanoftp">xmlNanoFTPQuit</symbol>
-    <symbol file="nanoftp">xmlNanoFTPRead</symbol>
-    <symbol file="nanoftp">xmlNanoFTPScanProxy</symbol>
-    <symbol file="nanoftp">xmlNanoFTPUpdateURL</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbCreateFileParserCtxt</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbCreatePushParserCtxt</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbEncodeEntities</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbFreeParserCtxt</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbParseChunk</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbParseDoc</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbParseDocument</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbParseFile</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbSAXParseDoc</symbol>
-    <symbol file="DOCBparser" removed="2.10.0">docbSAXParseFile</symbol>
-    <symbol file="xpath">xmlXPathCastBooleanToNumber</symbol>
-    <symbol file="xpath">xmlXPathCastBooleanToString</symbol>
-    <symbol file="xpath">xmlXPathCastNodeSetToBoolean</symbol>
-    <symbol file="xpath">xmlXPathCastNodeSetToNumber</symbol>
-    <symbol file="xpath">xmlXPathCastNodeSetToString</symbol>
-    <symbol file="xpath">xmlXPathCastNodeToNumber</symbol>
-    <symbol file="xpath">xmlXPathCastNodeToString</symbol>
-    <symbol file="xpath">xmlXPathCastNumberToBoolean</symbol>
-    <symbol file="xpath">xmlXPathCastNumberToString</symbol>
-    <symbol file="xpath">xmlXPathCastStringToBoolean</symbol>
-    <symbol file="xpath">xmlXPathCastStringToNumber</symbol>
-    <symbol file="xpath">xmlXPathCastToBoolean</symbol>
-    <symbol file="xpath">xmlXPathCastToNumber</symbol>
-    <symbol file="xpath">xmlXPathCastToString</symbol>
-    <symbol file="xpath">xmlXPathCmpNodes</symbol>
-    <symbol file="xpath">xmlXPathCompile</symbol>
-    <symbol file="xpath">xmlXPathCompiledEval</symbol>
-    <symbol file="xpath">xmlXPathConvertBoolean</symbol>
-    <symbol file="xpath">xmlXPathConvertNumber</symbol>
-    <symbol file="xpath">xmlXPathConvertString</symbol>
-    <symbol file="xpath">xmlXPathEval</symbol>
-    <symbol file="xpath">xmlXPathEvalExpression</symbol>
-    <symbol file="xpath">xmlXPathEvalPredicate</symbol>
-    <symbol file="xpath">xmlXPathFreeCompExpr</symbol>
-    <symbol file="xpath">xmlXPathFreeContext</symbol>
-    <symbol file="xpath">xmlXPathFreeNodeSet</symbol>
-    <symbol file="xpath">xmlXPathFreeNodeSetList</symbol>
-    <symbol file="xpath">xmlXPathFreeObject</symbol>
-    <symbol file="xpath">xmlXPathInit</symbol>
-    <symbol file="xpath">xmlXPathIsInf</symbol>
-    <symbol file="xpath">xmlXPathIsNaN</symbol>
-    <symbol file="xpath">xmlXPathNAN</symbol>
-    <symbol file="xpath">xmlXPathNINF</symbol>
-    <symbol file="xpath">xmlXPathNewContext</symbol>
-    <symbol file="xpath">xmlXPathNodeSetCreate</symbol>
-    <symbol file="xpath">xmlXPathObjectCopy</symbol>
-    <symbol file="xpath">xmlXPathPINF</symbol>
-    <symbol file="xlink">xlinkGetDefaultDetect</symbol>
-    <symbol file="xlink">xlinkGetDefaultHandler</symbol>
-    <symbol file="xlink">xlinkIsLink</symbol>
-    <symbol file="xlink">xlinkSetDefaultDetect</symbol>
-    <symbol file="xlink">xlinkSetDefaultHandler</symbol>
-    <symbol file="entities">xmlAddDocEntity</symbol>
-    <symbol file="entities">xmlAddDtdEntity</symbol>
-    <symbol file="entities">xmlCleanupPredefinedEntities</symbol>
-    <symbol file="entities">xmlCopyEntitiesTable</symbol>
-    <symbol file="entities">xmlCreateEntitiesTable</symbol>
-    <symbol file="entities">xmlDumpEntitiesTable</symbol>
-    <symbol file="entities">xmlDumpEntityDecl</symbol>
-    <symbol file="entities">xmlEncodeEntities</symbol>
-    <symbol file="entities">xmlEncodeEntitiesReentrant</symbol>
-    <symbol file="entities">xmlEncodeSpecialChars</symbol>
-    <symbol file="entities">xmlFreeEntitiesTable</symbol>
-    <symbol file="entities">xmlGetDocEntity</symbol>
-    <symbol file="entities">xmlGetDtdEntity</symbol>
-    <symbol file="entities">xmlGetParameterEntity</symbol>
-    <symbol file="entities">xmlGetPredefinedEntity</symbol>
-    <symbol file="entities">xmlInitializePredefinedEntities</symbol>
-    <symbol file="xinclude">xmlXIncludeProcess</symbol>
-    <symbol file="list">xmlLinkGetData</symbol>
-    <symbol file="list">xmlListAppend</symbol>
-    <symbol file="list">xmlListClear</symbol>
-    <symbol file="list">xmlListCopy</symbol>
-    <symbol file="list">xmlListCreate</symbol>
-    <symbol file="list">xmlListDelete</symbol>
-    <symbol file="list">xmlListDup</symbol>
-    <symbol file="list">xmlListEmpty</symbol>
-    <symbol file="list">xmlListEnd</symbol>
-    <symbol file="list">xmlListFront</symbol>
-    <symbol file="list">xmlListInsert</symbol>
-    <symbol file="list">xmlListMerge</symbol>
-    <symbol file="list">xmlListPopBack</symbol>
-    <symbol file="list">xmlListPopFront</symbol>
-    <symbol file="list">xmlListPushBack</symbol>
-    <symbol file="list">xmlListPushFront</symbol>
-    <symbol file="list">xmlListRemoveAll</symbol>
-    <symbol file="list">xmlListRemoveFirst</symbol>
-    <symbol file="list">xmlListRemoveLast</symbol>
-    <symbol file="list">xmlListReverse</symbol>
-    <symbol file="list">xmlListReverseSearch</symbol>
-    <symbol file="list">xmlListReverseWalk</symbol>
-    <symbol file="list">xmlListSearch</symbol>
-    <symbol file="list">xmlListSize</symbol>
-    <symbol file="list">xmlListSort</symbol>
-    <symbol file="list">xmlListWalk</symbol>
-    <symbol file="xmlmemory">xmlInitMemory</symbol>
-    <symbol file="xmlmemory">xmlMallocLoc</symbol>
-    <symbol file="xmlmemory">xmlMemDisplay</symbol>
-    <symbol file="xmlmemory">xmlMemFree</symbol>
-    <symbol file="xmlmemory">xmlMemGet</symbol>
-    <symbol file="xmlmemory">xmlMemMalloc</symbol>
-    <symbol file="xmlmemory">xmlMemRealloc</symbol>
-    <symbol file="xmlmemory">xmlMemSetup</symbol>
-    <symbol file="xmlmemory">xmlMemShow</symbol>
-    <symbol file="xmlmemory">xmlMemStrdupLoc</symbol>
-    <symbol file="xmlmemory">xmlMemUsed</symbol>
-    <symbol file="xmlmemory">xmlMemoryDump</symbol>
-    <symbol file="xmlmemory">xmlMemoryStrdup</symbol>
-    <symbol file="xmlmemory">xmlReallocLoc</symbol>
-    <symbol file="xmlIO">xmlAllocOutputBuffer</symbol>
-    <symbol file="xmlIO">xmlAllocParserInputBuffer</symbol>
-    <symbol file="xmlIO">xmlCheckFilename</symbol>
-    <symbol file="xmlIO">xmlCleanupInputCallbacks</symbol>
-    <symbol file="xmlIO">xmlCleanupOutputCallbacks</symbol>
-    <symbol file="xmlIO">xmlFileClose</symbol>
-    <symbol file="xmlIO">xmlFileMatch</symbol>
-    <symbol file="xmlIO">xmlFileOpen</symbol>
-    <symbol file="xmlIO">xmlFileRead</symbol>
-    <symbol file="xmlIO">xmlFreeParserInputBuffer</symbol>
-    <symbol file="xmlIO">xmlIOFTPClose</symbol>
-    <symbol file="xmlIO">xmlIOFTPMatch</symbol>
-    <symbol file="xmlIO">xmlIOFTPOpen</symbol>
-    <symbol file="xmlIO">xmlIOFTPRead</symbol>
-    <symbol file="xmlIO">xmlIOHTTPClose</symbol>
-    <symbol file="xmlIO">xmlIOHTTPMatch</symbol>
-    <symbol file="xmlIO">xmlIOHTTPOpen</symbol>
-    <symbol file="xmlIO">xmlIOHTTPOpenW</symbol>
-    <symbol file="xmlIO">xmlIOHTTPRead</symbol>
-    <symbol file="xmlIO">xmlNoNetExternalEntityLoader</symbol>
-    <symbol file="xmlIO">xmlNormalizeWindowsPath</symbol>
-    <symbol file="xmlIO">xmlOutputBufferClose</symbol>
-    <symbol file="xmlIO">xmlOutputBufferCreateFd</symbol>
-    <symbol file="xmlIO">xmlOutputBufferCreateFile</symbol>
-    <symbol file="xmlIO">xmlOutputBufferCreateFilename</symbol>
-    <symbol file="xmlIO">xmlOutputBufferCreateIO</symbol>
-    <symbol file="xmlIO">xmlOutputBufferFlush</symbol>
-    <symbol file="xmlIO">xmlOutputBufferWrite</symbol>
-    <symbol file="xmlIO">xmlOutputBufferWriteString</symbol>
-    <symbol file="xmlIO">xmlParserGetDirectory</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateFd</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateFile</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateFilename</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateIO</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateMem</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferGrow</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferPush</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferRead</symbol>
-    <symbol file="xmlIO">xmlRegisterDefaultInputCallbacks</symbol>
-    <symbol file="xmlIO">xmlRegisterDefaultOutputCallbacks</symbol>
-    <symbol file="xmlIO">xmlRegisterHTTPPostCallbacks</symbol>
-    <symbol file="xmlIO">xmlRegisterInputCallbacks</symbol>
-    <symbol file="xmlIO">xmlRegisterOutputCallbacks</symbol>
-    <symbol file="xmlversion">xmlCheckVersion</symbol>
-    <symbol file="valid">xmlAddAttributeDecl</symbol>
-    <symbol file="valid">xmlAddElementDecl</symbol>
-    <symbol file="valid">xmlAddID</symbol>
-    <symbol file="valid">xmlAddNotationDecl</symbol>
-    <symbol file="valid">xmlAddRef</symbol>
-    <symbol file="valid">xmlCopyAttributeTable</symbol>
-    <symbol file="valid">xmlCopyElementContent</symbol>
-    <symbol file="valid">xmlCopyElementTable</symbol>
-    <symbol file="valid">xmlCopyEnumeration</symbol>
-    <symbol file="valid">xmlCopyNotationTable</symbol>
-    <symbol file="valid">xmlCreateEnumeration</symbol>
-    <symbol file="valid">xmlDumpAttributeDecl</symbol>
-    <symbol file="valid">xmlDumpAttributeTable</symbol>
-    <symbol file="valid">xmlDumpElementDecl</symbol>
-    <symbol file="valid">xmlDumpElementTable</symbol>
-    <symbol file="valid">xmlDumpNotationDecl</symbol>
-    <symbol file="valid">xmlDumpNotationTable</symbol>
-    <symbol file="valid">xmlFreeAttributeTable</symbol>
-    <symbol file="valid">xmlFreeElementContent</symbol>
-    <symbol file="valid">xmlFreeElementTable</symbol>
-    <symbol file="valid">xmlFreeEnumeration</symbol>
-    <symbol file="valid">xmlFreeIDTable</symbol>
-    <symbol file="valid">xmlFreeNotationTable</symbol>
-    <symbol file="valid">xmlFreeRefTable</symbol>
-    <symbol file="valid">xmlGetDtdAttrDesc</symbol>
-    <symbol file="valid">xmlGetDtdElementDesc</symbol>
-    <symbol file="valid">xmlGetDtdNotationDesc</symbol>
-    <symbol file="valid">xmlGetDtdQAttrDesc</symbol>
-    <symbol file="valid">xmlGetDtdQElementDesc</symbol>
-    <symbol file="valid">xmlGetID</symbol>
-    <symbol file="valid">xmlGetRefs</symbol>
-    <symbol file="valid">xmlIsID</symbol>
-    <symbol file="valid">xmlIsMixedElement</symbol>
-    <symbol file="valid">xmlIsRef</symbol>
-    <symbol file="valid">xmlNewElementContent</symbol>
-    <symbol file="valid">xmlRemoveID</symbol>
-    <symbol file="valid">xmlRemoveRef</symbol>
-    <symbol file="valid">xmlSnprintfElementContent</symbol>
-    <symbol file="tree">xmlSplitQName2</symbol>
-    <symbol file="valid">xmlSprintfElementContent</symbol>
-    <symbol file="valid">xmlValidBuildContentModel</symbol>
-    <symbol file="valid">xmlValidCtxtNormalizeAttributeValue</symbol>
-    <symbol file="valid">xmlValidGetPotentialChildren</symbol>
-    <symbol file="valid">xmlValidGetValidElements</symbol>
-    <symbol file="valid">xmlValidNormalizeAttributeValue</symbol>
-    <symbol file="valid">xmlValidateAttributeDecl</symbol>
-    <symbol file="valid">xmlValidateAttributeValue</symbol>
-    <symbol file="valid">xmlValidateDocument</symbol>
-    <symbol file="valid">xmlValidateDocumentFinal</symbol>
-    <symbol file="valid">xmlValidateDtd</symbol>
-    <symbol file="valid">xmlValidateDtdFinal</symbol>
-    <symbol file="valid">xmlValidateElement</symbol>
-    <symbol file="valid">xmlValidateElementDecl</symbol>
-    <symbol file="valid">xmlValidateNameValue</symbol>
-    <symbol file="valid">xmlValidateNamesValue</symbol>
-    <symbol file="valid">xmlValidateNmtokenValue</symbol>
-    <symbol file="valid">xmlValidateNmtokensValue</symbol>
-    <symbol file="valid">xmlValidateNotationDecl</symbol>
-    <symbol file="valid">xmlValidateNotationUse</symbol>
-    <symbol file="valid">xmlValidateOneAttribute</symbol>
-    <symbol file="valid">xmlValidateOneElement</symbol>
-    <symbol file="valid">xmlValidateOneNamespace</symbol>
-    <symbol file="valid">xmlValidateRoot</symbol>
-    <symbol file="HTMLparser">UTF8ToHtml</symbol>
-    <symbol file="HTMLparser">htmlAutoCloseTag</symbol>
-    <symbol file="HTMLparser">htmlCreatePushParserCtxt</symbol>
-    <symbol file="HTMLparser">htmlEncodeEntities</symbol>
-    <symbol file="HTMLparser">htmlEntityLookup</symbol>
-    <symbol file="HTMLparser">htmlEntityValueLookup</symbol>
-    <symbol file="HTMLparser">htmlFreeParserCtxt</symbol>
-    <symbol file="HTMLparser">htmlHandleOmittedElem</symbol>
-    <symbol file="HTMLparser">htmlIsAutoClosed</symbol>
-    <symbol file="HTMLparser">htmlIsScriptAttribute</symbol>
-    <symbol file="HTMLparser">htmlParseCharRef</symbol>
-    <symbol file="HTMLparser">htmlParseChunk</symbol>
-    <symbol file="HTMLparser">htmlParseDoc</symbol>
-    <symbol file="HTMLparser">htmlParseDocument</symbol>
-    <symbol file="HTMLparser">htmlParseElement</symbol>
-    <symbol file="HTMLparser">htmlParseEntityRef</symbol>
-    <symbol file="HTMLparser">htmlParseFile</symbol>
-    <symbol file="HTMLparser">htmlSAXParseDoc</symbol>
-    <symbol file="HTMLparser">htmlSAXParseFile</symbol>
-    <symbol file="HTMLparser">htmlTagLookup</symbol>
-    <symbol file="xmlstring">xmlCharStrdup</symbol>
-    <symbol file="xmlstring">xmlCharStrndup</symbol>
-    <symbol file="parser">xmlCleanupParser</symbol>
-    <symbol file="parser">xmlClearNodeInfoSeq</symbol>
-    <symbol file="parser">xmlClearParserCtxt</symbol>
-    <symbol file="parser">xmlCreateDocParserCtxt</symbol>
-    <symbol file="parser">xmlCreateIOParserCtxt</symbol>
-    <symbol file="parser">xmlCreatePushParserCtxt</symbol>
-    <symbol file="parser">xmlFreeParserCtxt</symbol>
-    <symbol file="parser">xmlGetExternalEntityLoader</symbol>
-    <symbol file="parser">xmlGetFeature</symbol>
-    <symbol file="parser">xmlGetFeaturesList</symbol>
-    <symbol file="globals">xmlGetWarningsDefaultValue</symbol>
-    <symbol file="parser">xmlIOParseDTD</symbol>
-    <symbol file="parser">xmlInitNodeInfoSeq</symbol>
-    <symbol file="parser">xmlInitParser</symbol>
-    <symbol file="parser">xmlInitParserCtxt</symbol>
-    <symbol file="parser">xmlKeepBlanksDefault</symbol>
-    <symbol file="parser">xmlLineNumbersDefault</symbol>
-    <symbol file="parser">xmlLoadExternalEntity</symbol>
-    <symbol file="parser">xmlNewIOInputStream</symbol>
-    <symbol file="parser">xmlParseBalancedChunkMemory</symbol>
-    <symbol file="parser">xmlParseBalancedChunkMemoryRecover</symbol>
-    <symbol file="parser">xmlParseChunk</symbol>
-    <symbol file="parser">xmlParseCtxtExternalEntity</symbol>
-    <symbol file="parser">xmlParseDTD</symbol>
-    <symbol file="parser">xmlParseDoc</symbol>
-    <symbol file="parser">xmlParseDocument</symbol>
-    <symbol file="parser">xmlParseEntity</symbol>
-    <symbol file="parser">xmlParseExtParsedEnt</symbol>
-    <symbol file="parser">xmlParseExternalEntity</symbol>
-    <symbol file="parser">xmlParseFile</symbol>
-    <symbol file="parser">xmlParseMemory</symbol>
-    <symbol file="parser">xmlParserAddNodeInfo</symbol>
-    <symbol file="parser">xmlParserFindNodeInfo</symbol>
-    <symbol file="parser">xmlParserFindNodeInfoIndex</symbol>
-    <symbol file="parser">xmlParserInputGrow</symbol>
-    <symbol file="parser">xmlParserInputRead</symbol>
-    <symbol file="parser">xmlPedanticParserDefault</symbol>
-    <symbol file="parser">xmlRecoverDoc</symbol>
-    <symbol file="parser">xmlRecoverFile</symbol>
-    <symbol file="parser">xmlRecoverMemory</symbol>
-    <symbol file="parser">xmlSAXParseDTD</symbol>
-    <symbol file="parser">xmlSAXParseDoc</symbol>
-    <symbol file="parser">xmlSAXParseEntity</symbol>
-    <symbol file="parser">xmlSAXParseFile</symbol>
-    <symbol file="parser">xmlSAXParseFileWithData</symbol>
-    <symbol file="parser">xmlSAXParseMemory</symbol>
-    <symbol file="parser">xmlSAXParseMemoryWithData</symbol>
-    <symbol file="parser">xmlSAXUserParseFile</symbol>
-    <symbol file="parser">xmlSAXUserParseMemory</symbol>
-    <symbol file="parser">xmlSetExternalEntityLoader</symbol>
-    <symbol file="parser">xmlSetFeature</symbol>
-    <symbol file="parser">xmlSetupParserForBuffer</symbol>
-    <symbol file="parser">xmlStopParser</symbol>
-    <symbol file="xmlstring">xmlStrEqual</symbol>
-    <symbol file="xmlstring">xmlStrcasecmp</symbol>
-    <symbol file="xmlstring">xmlStrcasestr</symbol>
-    <symbol file="xmlstring">xmlStrcat</symbol>
-    <symbol file="xmlstring">xmlStrchr</symbol>
-    <symbol file="xmlstring">xmlStrcmp</symbol>
-    <symbol file="xmlstring">xmlStrdup</symbol>
-    <symbol file="xmlstring">xmlStrlen</symbol>
-    <symbol file="xmlstring">xmlStrncasecmp</symbol>
-    <symbol file="xmlstring">xmlStrncat</symbol>
-    <symbol file="xmlstring">xmlStrncmp</symbol>
-    <symbol file="xmlstring">xmlStrndup</symbol>
-    <symbol file="xmlstring">xmlStrstr</symbol>
-    <symbol file="xmlstring">xmlStrsub</symbol>
-    <symbol file="parser">xmlSubstituteEntitiesDefault</symbol>
-    <symbol file="xmlreader">xmlFreeTextReader</symbol>
-    <symbol file="xmlreader">xmlNewTextReader</symbol>
-    <symbol file="xmlreader">xmlNewTextReaderFilename</symbol>
-    <symbol file="xmlreader">xmlTextReaderAttributeCount</symbol>
-    <symbol file="xmlreader">xmlTextReaderBaseUri</symbol>
-    <symbol file="xmlreader">xmlTextReaderDepth</symbol>
-    <symbol file="xmlreader">xmlTextReaderHasAttributes</symbol>
-    <symbol file="xmlreader">xmlTextReaderHasValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderIsDefault</symbol>
-    <symbol file="xmlreader">xmlTextReaderIsEmptyElement</symbol>
-    <symbol file="xmlreader">xmlTextReaderLocalName</symbol>
-    <symbol file="xmlreader">xmlTextReaderName</symbol>
-    <symbol file="xmlreader">xmlTextReaderNamespaceUri</symbol>
-    <symbol file="xmlreader">xmlTextReaderNodeType</symbol>
-    <symbol file="xmlreader">xmlTextReaderPrefix</symbol>
-    <symbol file="xmlreader">xmlTextReaderQuoteChar</symbol>
-    <symbol file="xmlreader">xmlTextReaderRead</symbol>
-    <symbol file="xmlreader">xmlTextReaderValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderXmlLang</symbol>
-    <symbol file="globals" removed="2.10.0">docbDefaultSAXHandler</symbol>
-    <symbol file="globals">htmlDefaultSAXHandler</symbol>
-    <symbol file="globals">xmlDefaultSAXHandler</symbol>
-    <symbol file="globals">xmlDefaultSAXLocator</symbol>
-    <symbol file="globals">xmlDoValidityCheckingDefaultValue</symbol>
-    <symbol file="globals">xmlFree</symbol>
-    <symbol file="globals">xmlGenericError</symbol>
-    <symbol file="globals">xmlGenericErrorContext</symbol>
-    <symbol file="globals">xmlInitializeGlobalState</symbol>
-    <symbol file="globals">xmlKeepBlanksDefaultValue</symbol>
-    <symbol file="globals">xmlLineNumbersDefaultValue</symbol>
-    <symbol file="globals">xmlLoadExtDtdDefaultValue</symbol>
-    <symbol file="globals">xmlMalloc</symbol>
-    <symbol file="globals">xmlMemStrdup</symbol>
-    <symbol file="globals">xmlParserDebugEntities</symbol>
-    <symbol file="globals">xmlParserVersion</symbol>
-    <symbol file="globals">xmlPedanticParserDefaultValue</symbol>
-    <symbol file="globals">xmlRealloc</symbol>
-    <symbol file="globals">xmlSaveNoEmptyTags</symbol>
-    <symbol file="globals">xmlSubstituteEntitiesDefaultValue</symbol>
-    <symbol file="globals">xmlTreeIndentString</symbol>
-    <symbol file="threads">xmlCleanupThreads</symbol>
-    <symbol file="threads">xmlFreeMutex</symbol>
-    <symbol file="threads">xmlFreeRMutex</symbol>
-    <symbol file="threads">xmlGetGlobalState</symbol>
-    <symbol file="threads">xmlGetThreadId</symbol>
-    <symbol file="threads">xmlInitThreads</symbol>
-    <symbol file="threads">xmlIsMainThread</symbol>
-    <symbol file="threads">xmlLockLibrary</symbol>
-    <symbol file="threads">xmlMutexLock</symbol>
-    <symbol file="threads">xmlMutexUnlock</symbol>
-    <symbol file="threads">xmlNewMutex</symbol>
-    <symbol file="threads">xmlNewRMutex</symbol>
-    <symbol file="threads">xmlRMutexLock</symbol>
-    <symbol file="threads">xmlRMutexUnlock</symbol>
-    <symbol file="threads">xmlUnlockLibrary</symbol>
-    <symbol file="hash">xmlHashAddEntry</symbol>
-    <symbol file="hash">xmlHashAddEntry2</symbol>
-    <symbol file="hash">xmlHashAddEntry3</symbol>
-    <symbol file="hash">xmlHashCopy</symbol>
-    <symbol file="hash">xmlHashCreate</symbol>
-    <symbol file="hash">xmlHashFree</symbol>
-    <symbol file="hash">xmlHashLookup</symbol>
-    <symbol file="hash">xmlHashLookup2</symbol>
-    <symbol file="hash">xmlHashLookup3</symbol>
-    <symbol file="hash">xmlHashRemoveEntry</symbol>
-    <symbol file="hash">xmlHashRemoveEntry2</symbol>
-    <symbol file="hash">xmlHashRemoveEntry3</symbol>
-    <symbol file="hash">xmlHashScan</symbol>
-    <symbol file="hash">xmlHashScan3</symbol>
-    <symbol file="hash">xmlHashScanFull</symbol>
-    <symbol file="hash">xmlHashScanFull3</symbol>
-    <symbol file="hash">xmlHashSize</symbol>
-    <symbol file="hash">xmlHashUpdateEntry</symbol>
-    <symbol file="hash">xmlHashUpdateEntry2</symbol>
-    <symbol file="hash">xmlHashUpdateEntry3</symbol>
-    <symbol file="xmlerror">initGenericErrorDefaultFunc</symbol>
-    <symbol file="xmlerror">xmlParserError</symbol>
-    <symbol file="xmlerror">xmlParserPrintFileContext</symbol>
-    <symbol file="xmlerror">xmlParserPrintFileInfo</symbol>
-    <symbol file="xmlerror">xmlParserValidityError</symbol>
-    <symbol file="xmlerror">xmlParserValidityWarning</symbol>
-    <symbol file="xmlerror">xmlParserWarning</symbol>
-    <symbol file="xmlerror">xmlSetGenericErrorFunc</symbol>
-    <symbol file="globals">oldXMLWDcompatibility</symbol>
-    <symbol file="tree">xmlAddChild</symbol>
-    <symbol file="tree">xmlAddChildList</symbol>
-    <symbol file="tree">xmlAddNextSibling</symbol>
-    <symbol file="tree">xmlAddPrevSibling</symbol>
-    <symbol file="tree">xmlAddSibling</symbol>
-    <symbol file="tree">xmlBufferAdd</symbol>
-    <symbol file="tree">xmlBufferAddHead</symbol>
-    <symbol file="globals">xmlBufferAllocScheme</symbol>
-    <symbol file="tree">xmlBufferCCat</symbol>
-    <symbol file="tree">xmlBufferCat</symbol>
-    <symbol file="tree">xmlBufferContent</symbol>
-    <symbol file="tree">xmlBufferCreate</symbol>
-    <symbol file="tree">xmlBufferCreateSize</symbol>
-    <symbol file="tree">xmlBufferDump</symbol>
-    <symbol file="tree">xmlBufferEmpty</symbol>
-    <symbol file="tree">xmlBufferFree</symbol>
-    <symbol file="tree">xmlBufferGrow</symbol>
-    <symbol file="tree">xmlBufferLength</symbol>
-    <symbol file="tree">xmlBufferResize</symbol>
-    <symbol file="tree">xmlBufferSetAllocationScheme</symbol>
-    <symbol file="tree">xmlBufferShrink</symbol>
-    <symbol file="tree">xmlBufferWriteCHAR</symbol>
-    <symbol file="tree">xmlBufferWriteChar</symbol>
-    <symbol file="tree">xmlBufferWriteQuotedString</symbol>
-    <symbol file="tree">xmlCopyDoc</symbol>
-    <symbol file="tree">xmlCopyDtd</symbol>
-    <symbol file="tree">xmlCopyNamespace</symbol>
-    <symbol file="tree">xmlCopyNamespaceList</symbol>
-    <symbol file="tree">xmlCopyNode</symbol>
-    <symbol file="tree">xmlCopyNodeList</symbol>
-    <symbol file="tree">xmlCopyProp</symbol>
-    <symbol file="tree">xmlCopyPropList</symbol>
-    <symbol file="tree">xmlCreateIntSubset</symbol>
-    <symbol file="globals">xmlDefaultBufferSize</symbol>
-    <symbol file="tree">xmlDocCopyNode</symbol>
-    <symbol file="tree">xmlDocDump</symbol>
-    <symbol file="tree">xmlDocDumpFormatMemory</symbol>
-    <symbol file="tree">xmlDocDumpFormatMemoryEnc</symbol>
-    <symbol file="tree">xmlDocDumpMemory</symbol>
-    <symbol file="tree">xmlDocDumpMemoryEnc</symbol>
-    <symbol file="tree">xmlDocFormatDump</symbol>
-    <symbol file="tree">xmlDocGetRootElement</symbol>
-    <symbol file="tree">xmlDocSetRootElement</symbol>
-    <symbol file="tree">xmlElemDump</symbol>
-    <symbol file="tree">xmlFreeDoc</symbol>
-    <symbol file="tree">xmlFreeDtd</symbol>
-    <symbol file="tree">xmlFreeNode</symbol>
-    <symbol file="tree">xmlFreeNodeList</symbol>
-    <symbol file="tree">xmlFreeNs</symbol>
-    <symbol file="tree">xmlFreeNsList</symbol>
-    <symbol file="tree">xmlFreeProp</symbol>
-    <symbol file="tree">xmlFreePropList</symbol>
-    <symbol file="tree">xmlGetBufferAllocationScheme</symbol>
-    <symbol file="tree">xmlGetCompressMode</symbol>
-    <symbol file="tree">xmlGetDocCompressMode</symbol>
-    <symbol file="tree">xmlGetIntSubset</symbol>
-    <symbol file="tree">xmlGetLastChild</symbol>
-    <symbol file="tree">xmlGetLineNo</symbol>
-    <symbol file="tree">xmlGetNodePath</symbol>
-    <symbol file="tree">xmlGetNsList</symbol>
-    <symbol file="tree">xmlGetNsProp</symbol>
-    <symbol file="tree">xmlGetProp</symbol>
-    <symbol file="tree">xmlHasNsProp</symbol>
-    <symbol file="tree">xmlHasProp</symbol>
-    <symbol file="globals">xmlIndentTreeOutput</symbol>
-    <symbol file="tree">xmlIsBlankNode</symbol>
-    <symbol file="tree">xmlIsXHTML</symbol>
-    <symbol file="tree">xmlNewCDataBlock</symbol>
-    <symbol file="tree">xmlNewCharRef</symbol>
-    <symbol file="tree">xmlNewChild</symbol>
-    <symbol file="tree">xmlNewComment</symbol>
-    <symbol file="tree">xmlNewDoc</symbol>
-    <symbol file="tree">xmlNewDocComment</symbol>
-    <symbol file="tree">xmlNewDocFragment</symbol>
-    <symbol file="tree">xmlNewDocNode</symbol>
-    <symbol file="tree">xmlNewDocNodeEatName</symbol>
-    <symbol file="tree">xmlNewDocProp</symbol>
-    <symbol file="tree">xmlNewDocRawNode</symbol>
-    <symbol file="tree">xmlNewDocText</symbol>
-    <symbol file="tree">xmlNewDocTextLen</symbol>
-    <symbol file="tree">xmlNewDtd</symbol>
-    <symbol file="tree">xmlNewGlobalNs</symbol>
-    <symbol file="tree">xmlNewNode</symbol>
-    <symbol file="tree">xmlNewNodeEatName</symbol>
-    <symbol file="tree">xmlNewNs</symbol>
-    <symbol file="tree">xmlNewNsProp</symbol>
-    <symbol file="tree">xmlNewNsPropEatName</symbol>
-    <symbol file="tree">xmlNewPI</symbol>
-    <symbol file="tree">xmlNewProp</symbol>
-    <symbol file="tree">xmlNewReference</symbol>
-    <symbol file="tree">xmlNewText</symbol>
-    <symbol file="tree">xmlNewTextChild</symbol>
-    <symbol file="tree">xmlNewTextLen</symbol>
-    <symbol file="tree">xmlNodeAddContent</symbol>
-    <symbol file="tree">xmlNodeAddContentLen</symbol>
-    <symbol file="tree">xmlNodeDump</symbol>
-    <symbol file="tree">xmlNodeDumpOutput</symbol>
-    <symbol file="tree">xmlNodeGetBase</symbol>
-    <symbol file="tree">xmlNodeGetContent</symbol>
-    <symbol file="tree">xmlNodeGetLang</symbol>
-    <symbol file="tree">xmlNodeGetSpacePreserve</symbol>
-    <symbol file="tree">xmlNodeIsText</symbol>
-    <symbol file="tree">xmlNodeListGetRawString</symbol>
-    <symbol file="tree">xmlNodeListGetString</symbol>
-    <symbol file="tree">xmlNodeSetBase</symbol>
-    <symbol file="tree">xmlNodeSetContent</symbol>
-    <symbol file="tree">xmlNodeSetContentLen</symbol>
-    <symbol file="tree">xmlNodeSetLang</symbol>
-    <symbol file="tree">xmlNodeSetName</symbol>
-    <symbol file="tree">xmlNodeSetSpacePreserve</symbol>
-    <symbol file="tree">xmlReconciliateNs</symbol>
-    <symbol file="tree">xmlRemoveProp</symbol>
-    <symbol file="tree">xmlReplaceNode</symbol>
-    <symbol file="tree">xmlSaveFile</symbol>
-    <symbol file="tree">xmlSaveFileEnc</symbol>
-    <symbol file="tree">xmlSaveFileTo</symbol>
-    <symbol file="tree">xmlSaveFormatFile</symbol>
-    <symbol file="tree">xmlSaveFormatFileEnc</symbol>
-    <symbol file="tree">xmlSaveFormatFileTo</symbol>
-    <symbol file="tree">xmlSearchNs</symbol>
-    <symbol file="tree">xmlSearchNsByHref</symbol>
-    <symbol file="tree">xmlSetBufferAllocationScheme</symbol>
-    <symbol file="tree">xmlSetCompressMode</symbol>
-    <symbol file="tree">xmlSetDocCompressMode</symbol>
-    <symbol file="tree">xmlSetListDoc</symbol>
-    <symbol file="tree">xmlSetNs</symbol>
-    <symbol file="tree">xmlSetNsProp</symbol>
-    <symbol file="tree">xmlSetProp</symbol>
-    <symbol file="tree">xmlSetTreeDoc</symbol>
-    <symbol file="tree">xmlStringGetNodeList</symbol>
-    <symbol file="tree">xmlStringLenGetNodeList</symbol>
-    <symbol file="tree">xmlTextConcat</symbol>
-    <symbol file="tree">xmlTextMerge</symbol>
-    <symbol file="tree">xmlUnlinkNode</symbol>
-    <symbol file="tree">xmlUnsetNsProp</symbol>
-    <symbol file="tree">xmlUnsetProp</symbol>
-    <symbol file="xmlregexp">xmlRegExecPushString</symbol>
-    <symbol file="xmlregexp">xmlRegFreeExecCtxt</symbol>
-    <symbol file="xmlregexp">xmlRegFreeRegexp</symbol>
-    <symbol file="xmlregexp">xmlRegNewExecCtxt</symbol>
-    <symbol file="xmlregexp">xmlRegexpCompile</symbol>
-    <symbol file="xmlregexp">xmlRegexpExec</symbol>
-    <symbol file="xmlregexp">xmlRegexpIsDeterminist</symbol>
-    <symbol file="xmlregexp">xmlRegexpPrint</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPAuthHeader</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPCleanup</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPClose</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPFetch</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPInit</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPMethod</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPMethodRedir</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPOpen</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPOpenRedir</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPRead</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPReturnCode</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPSave</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPScanProxy</symbol>
-    <symbol file="xmlunicode">xmlUCSIsAlphabeticPresentationForms</symbol>
-    <symbol file="xmlunicode">xmlUCSIsArabic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsArabicPresentationFormsA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsArabicPresentationFormsB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsArmenian</symbol>
-    <symbol file="xmlunicode">xmlUCSIsArrows</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBasicLatin</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBengali</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBlock</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBlockElements</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBopomofo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBopomofoExtended</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBoxDrawing</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBraillePatterns</symbol>
-    <symbol file="xmlunicode">xmlUCSIsByzantineMusicalSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKCompatibility</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKCompatibilityForms</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKCompatibilityIdeographs</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKCompatibilityIdeographsSupplement</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKRadicalsSupplement</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKSymbolsandPunctuation</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKUnifiedIdeographs</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKUnifiedIdeographsExtensionA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCJKUnifiedIdeographsExtensionB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCat</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatC</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatCc</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatCf</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatCo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatCs</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatL</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatLl</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatLm</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatLo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatLt</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatLu</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatM</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatMc</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatMe</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatMn</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatN</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatNd</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatNl</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatNo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatP</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPc</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPd</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPe</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPf</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPi</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatPs</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatS</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatSc</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatSk</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatSm</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatSo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatZ</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatZl</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatZp</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCatZs</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCherokee</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCombiningDiacriticalMarks</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCombiningHalfMarks</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCombiningMarksforSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsControlPictures</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCurrencySymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCyrillic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsDeseret</symbol>
-    <symbol file="xmlunicode">xmlUCSIsDevanagari</symbol>
-    <symbol file="xmlunicode">xmlUCSIsDingbats</symbol>
-    <symbol file="xmlunicode">xmlUCSIsEnclosedAlphanumerics</symbol>
-    <symbol file="xmlunicode">xmlUCSIsEnclosedCJKLettersandMonths</symbol>
-    <symbol file="xmlunicode">xmlUCSIsEthiopic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGeneralPunctuation</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGeometricShapes</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGeorgian</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGothic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGreek</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGreekExtended</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGujarati</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGurmukhi</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHalfwidthandFullwidthForms</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHangulCompatibilityJamo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHangulJamo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHangulSyllables</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHebrew</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHighPrivateUseSurrogates</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHighSurrogates</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHiragana</symbol>
-    <symbol file="xmlunicode">xmlUCSIsIPAExtensions</symbol>
-    <symbol file="xmlunicode">xmlUCSIsIdeographicDescriptionCharacters</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKanbun</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKangxiRadicals</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKannada</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKatakana</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKhmer</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLao</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLatin1Supplement</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLatinExtendedA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLatinExtendedAdditional</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLatinExtendedB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLetterlikeSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLowSurrogates</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMalayalam</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMathematicalAlphanumericSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMathematicalOperators</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMiscellaneousSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMiscellaneousTechnical</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMongolian</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMusicalSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMyanmar</symbol>
-    <symbol file="xmlunicode">xmlUCSIsNumberForms</symbol>
-    <symbol file="xmlunicode">xmlUCSIsOgham</symbol>
-    <symbol file="xmlunicode">xmlUCSIsOldItalic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsOpticalCharacterRecognition</symbol>
-    <symbol file="xmlunicode">xmlUCSIsOriya</symbol>
-    <symbol file="xmlunicode">xmlUCSIsPrivateUse</symbol>
-    <symbol file="xmlunicode">xmlUCSIsRunic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSinhala</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSmallFormVariants</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSpacingModifierLetters</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSpecials</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSuperscriptsandSubscripts</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSyriac</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTags</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTamil</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTelugu</symbol>
-    <symbol file="xmlunicode">xmlUCSIsThaana</symbol>
-    <symbol file="xmlunicode">xmlUCSIsThai</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTibetan</symbol>
-    <symbol file="xmlunicode">xmlUCSIsUnifiedCanadianAboriginalSyllabics</symbol>
-    <symbol file="xmlunicode">xmlUCSIsYiRadicals</symbol>
-    <symbol file="xmlunicode">xmlUCSIsYiSyllables</symbol>
-    <symbol file="uri">xmlBuildURI</symbol>
-    <symbol file="uri">xmlCreateURI</symbol>
-    <symbol file="uri">xmlFreeURI</symbol>
-    <symbol file="uri">xmlNormalizeURIPath</symbol>
-    <symbol file="uri">xmlParseURI</symbol>
-    <symbol file="uri">xmlParseURIReference</symbol>
-    <symbol file="uri">xmlPrintURI</symbol>
-    <symbol file="uri">xmlSaveUri</symbol>
-    <symbol file="uri">xmlURIEscape</symbol>
-    <symbol file="uri">xmlURIEscapeStr</symbol>
-    <symbol file="uri">xmlURIUnescapeString</symbol>
-    <symbol file="encoding">UTF8Toisolat1</symbol>
-    <symbol file="encoding">isolat1ToUTF8</symbol>
-    <symbol file="encoding">xmlAddEncodingAlias</symbol>
-    <symbol file="encoding">xmlCharEncCloseFunc</symbol>
-    <symbol file="encoding">xmlCharEncFirstLine</symbol>
-    <symbol file="encoding">xmlCharEncInFunc</symbol>
-    <symbol file="encoding">xmlCharEncOutFunc</symbol>
-    <symbol file="xmlstring">xmlCheckUTF8</symbol>
-    <symbol file="encoding">xmlCleanupCharEncodingHandlers</symbol>
-    <symbol file="encoding">xmlCleanupEncodingAliases</symbol>
-    <symbol file="encoding">xmlDelEncodingAlias</symbol>
-    <symbol file="encoding">xmlDetectCharEncoding</symbol>
-    <symbol file="encoding">xmlFindCharEncodingHandler</symbol>
-    <symbol file="encoding">xmlGetCharEncodingHandler</symbol>
-    <symbol file="encoding">xmlGetCharEncodingName</symbol>
-    <symbol file="encoding">xmlGetEncodingAlias</symbol>
-    <symbol file="xmlstring">xmlGetUTF8Char</symbol>
-    <symbol file="encoding">xmlInitCharEncodingHandlers</symbol>
-    <symbol file="encoding">xmlNewCharEncodingHandler</symbol>
-    <symbol file="encoding">xmlParseCharEncoding</symbol>
-    <symbol file="encoding">xmlRegisterCharEncodingHandler</symbol>
-    <symbol file="xmlstring">xmlUTF8Strlen</symbol>
-    <symbol file="xmlstring">xmlUTF8Strloc</symbol>
-    <symbol file="xmlstring">xmlUTF8Strndup</symbol>
-    <symbol file="xmlstring">xmlUTF8Strpos</symbol>
-    <symbol file="xmlstring">xmlUTF8Strsize</symbol>
-    <symbol file="xmlstring">xmlUTF8Strsub</symbol>
-  </release>
-  <release version="2.5.0">
-    <symbol file="globals">xmlDeregisterNodeDefault</symbol>
-    <symbol file="globals">xmlDeregisterNodeDefaultValue</symbol>
-    <symbol file="globals">xmlRegisterNodeDefault</symbol>
-    <symbol file="globals">xmlRegisterNodeDefaultValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderClose</symbol>
-    <symbol file="xmlreader">xmlTextReaderCurrentDoc</symbol>
-    <symbol file="xmlreader">xmlTextReaderCurrentNode</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetAttributeNo</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetAttributeNs</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetAttribute</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetParserProp</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetRemainder</symbol>
-    <symbol file="xmlreader">xmlTextReaderLookupNamespace</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToAttributeNo</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToAttributeNs</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToAttribute</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToElement</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToFirstAttribute</symbol>
-    <symbol file="xmlreader">xmlTextReaderMoveToNextAttribute</symbol>
-    <symbol file="xmlreader">xmlTextReaderNormalization</symbol>
-    <symbol file="xmlreader">xmlTextReaderReadAttributeValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderReadInnerXml</symbol>
-    <symbol file="xmlreader">xmlTextReaderReadOuterXml</symbol>
-    <symbol file="xmlreader">xmlTextReaderReadState</symbol>
-    <symbol file="xmlreader">xmlTextReaderReadString</symbol>
-    <symbol file="xmlreader">xmlTextReaderSetParserProp</symbol>
-    <symbol file="valid">xmlValidatePopElement</symbol>
-    <symbol file="valid">xmlValidatePushCData</symbol>
-    <symbol file="valid">xmlValidatePushElement</symbol>
-  </release>
-  <release version="2.5.2">
-    <symbol file="tree">xmlGetNoNsProp</symbol>
-    <symbol file="HTMLparser">htmlAttrAllowed</symbol>
-    <symbol file="HTMLparser">htmlElementAllowedHere</symbol>
-    <symbol file="HTMLparser">htmlElementStatusHere</symbol>
-    <symbol file="HTMLparser">htmlNodeStatus</symbol>
-    <symbol file="relaxng">xmlRelaxNGCleanupTypes</symbol>
-    <symbol file="relaxng">xmlRelaxNGDump</symbol>
-    <symbol file="relaxng">xmlRelaxNGFreeParserCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGFree</symbol>
-    <symbol file="relaxng">xmlRelaxNGFreeValidCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGNewMemParserCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGNewParserCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGNewValidCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGParse</symbol>
-    <symbol file="relaxng">xmlRelaxNGSetParserErrors</symbol>
-    <symbol file="relaxng">xmlRelaxNGSetValidErrors</symbol>
-    <symbol file="relaxng">xmlRelaxNGValidateDoc</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetErrorHandler</symbol>
-    <symbol file="xmlreader">xmlTextReaderLocatorBaseURI</symbol>
-    <symbol file="xmlreader">xmlTextReaderLocatorLineNumber</symbol>
-    <symbol file="xmlreader">xmlTextReaderSetErrorHandler</symbol>
-    <symbol removed="2.5.5" file="relaxng">xmlRelaxNGValidateStream</symbol>
-  </release>
-  <release version="2.5.4">
-    <symbol file="uri">xmlCanonicPath</symbol>
-    <symbol file="relaxng">xmlRelaxNGDumpTree</symbol>
-    <symbol file="tree">xmlValidateName</symbol>
-    <symbol file="tree">xmlValidateNCName</symbol>
-    <symbol file="tree">xmlValidateNMToken</symbol>
-    <symbol file="tree">xmlValidateQName</symbol>
-  </release>
-  <release version="2.5.5">
-    <symbol file="nanoftp">xmlNanoFTPDele</symbol>
-  </release>
-  <release version="2.5.6">
-    <symbol file="xpath">xmlXPathOrderDocElems</symbol>
-  </release>
-  <release version="2.5.7">
-    <symbol file="HTMLparser">htmlCreateMemoryParserCtxt</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewTransition2</symbol>
-    <symbol file="tree">xmlBuildQName</symbol>
-    <symbol file="xmlmemory">xmlGcMemGet</symbol>
-    <symbol file="xmlmemory">xmlGcMemSetup</symbol>
-    <symbol file="globals">xmlMallocAtomic</symbol>
-    <symbol file="xmlregexp">xmlRegExecPushString2</symbol>
-    <symbol file="relaxng">xmlRelaxNGNewDocParserCtxt</symbol>
-    <symbol file="relaxng">xmlRelaxNGValidateFullElement</symbol>
-    <symbol file="relaxng">xmlRelaxNGValidatePopElement</symbol>
-    <symbol file="relaxng">xmlRelaxNGValidatePushCData</symbol>
-    <symbol file="relaxng">xmlRelaxNGValidatePushElement</symbol>
-    <symbol file="xmlreader">xmlTextReaderExpand</symbol>
-    <symbol file="xmlreader">xmlTextReaderIsValid</symbol>
-    <symbol file="xmlreader">xmlTextReaderNext</symbol>
-    <symbol file="xmlreader">xmlTextReaderRelaxNGSetSchema</symbol>
-    <symbol file="xmlreader">xmlTextReaderRelaxNGValidate</symbol>
-  </release>
-  <release version="2.5.8">
-    <symbol file="globals">xmlCleanupGlobals</symbol>
-    <symbol file="globals">xmlInitGlobals</symbol>
-    <symbol file="valid">xmlFreeValidCtxt</symbol>
-    <symbol file="valid">xmlNewValidCtxt</symbol>
-    <symbol file="schemasInternals">xmlSchemaFreeType</symbol>
-    <symbol file="xmlschemas">xmlSchemaDump</symbol>
-    <symbol file="xmlschemas">xmlSchemaFreeParserCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaFreeValidCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaFree</symbol>
-    <symbol file="xmlschemas">xmlSchemaNewMemParserCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaNewParserCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaNewValidCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaParse</symbol>
-    <symbol file="xmlschemas">xmlSchemaSetParserErrors</symbol>
-    <symbol file="xmlschemas">xmlSchemaSetValidErrors</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateDoc</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateStream</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCheckFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCleanupTypes</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCompareValues</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaFreeFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaFreeValue</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetPredefinedType</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaInitTypes</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaNewFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidateFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidatePredefinedType</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValPredefTypeNode</symbol>
-    <symbol file="globals">xmlThrDefBufferAllocScheme</symbol>
-    <symbol file="globals">xmlThrDefDefaultBufferSize</symbol>
-    <symbol file="globals">xmlThrDefDeregisterNodeDefault</symbol>
-    <symbol file="globals">xmlThrDefDoValidityCheckingDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefGetWarningsDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefIndentTreeOutput</symbol>
-    <symbol file="globals">xmlThrDefKeepBlanksDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefLineNumbersDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefLoadExtDtdDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefParserDebugEntities</symbol>
-    <symbol file="globals">xmlThrDefPedanticParserDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefRegisterNodeDefault</symbol>
-    <symbol file="globals">xmlThrDefSaveNoEmptyTags</symbol>
-    <symbol file="globals">xmlThrDefSetGenericErrorFunc</symbol>
-    <symbol file="globals">xmlThrDefSubstituteEntitiesDefaultValue</symbol>
-    <symbol file="globals">xmlThrDefTreeIndentString</symbol>
-  </release>
-  <release version="2.5.9">
-    <symbol file="xmlmemory">xmlMallocAtomicLoc</symbol>
-    <symbol file="relaxng">xmlRelaxNGGetParserErrors</symbol>
-    <symbol file="relaxng">xmlRelaxNGGetValidErrors</symbol>
-    <symbol file="tree">xmlSplitQName3</symbol>
-    <symbol file="xmlstring">xmlUTF8Charcmp</symbol>
-    <symbol file="xmlstring">xmlUTF8Size</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessTree</symbol>
-  </release>
-  <release version="2.6.0">
-    <symbol file="SAX2">xmlSAX2AttributeDecl</symbol>
-    <symbol file="SAX2">xmlSAX2CDataBlock</symbol>
-    <symbol file="SAX2">xmlSAX2Characters</symbol>
-    <symbol file="SAX2">xmlSAX2Comment</symbol>
-    <symbol file="SAX2">xmlSAX2ElementDecl</symbol>
-    <symbol file="SAX2">xmlSAX2EndDocument</symbol>
-    <symbol file="SAX2">xmlSAX2EndElementNs</symbol>
-    <symbol file="SAX2">xmlSAX2EndElement</symbol>
-    <symbol file="SAX2">xmlSAX2EntityDecl</symbol>
-    <symbol file="SAX2">xmlSAX2ExternalSubset</symbol>
-    <symbol file="SAX2">xmlSAX2GetColumnNumber</symbol>
-    <symbol file="SAX2">xmlSAX2GetEntity</symbol>
-    <symbol file="SAX2">xmlSAX2GetLineNumber</symbol>
-    <symbol file="SAX2">xmlSAX2GetParameterEntity</symbol>
-    <symbol file="SAX2">xmlSAX2GetPublicId</symbol>
-    <symbol file="SAX2">xmlSAX2GetSystemId</symbol>
-    <symbol file="SAX2">xmlSAX2HasExternalSubset</symbol>
-    <symbol file="SAX2">xmlSAX2HasInternalSubset</symbol>
-    <symbol file="SAX2">xmlSAX2IgnorableWhitespace</symbol>
-    <symbol file="SAX2">xmlSAX2InitDefaultSAXHandler</symbol>
-    <symbol file="SAX2" removed="2.10.0">xmlSAX2InitDocbDefaultSAXHandler</symbol>
-    <symbol file="SAX2">xmlSAX2InitHtmlDefaultSAXHandler</symbol>
-    <symbol file="SAX2">xmlSAX2InternalSubset</symbol>
-    <symbol file="SAX2">xmlSAX2IsStandalone</symbol>
-    <symbol file="SAX2">xmlSAX2NotationDecl</symbol>
-    <symbol file="SAX2">xmlSAX2ProcessingInstruction</symbol>
-    <symbol file="SAX2">xmlSAX2Reference</symbol>
-    <symbol file="SAX2">xmlSAX2ResolveEntity</symbol>
-    <symbol file="SAX2">xmlSAX2SetDocumentLocator</symbol>
-    <symbol file="SAX2">xmlSAX2StartDocument</symbol>
-    <symbol file="SAX2">xmlSAX2StartElementNs</symbol>
-    <symbol file="SAX2">xmlSAX2StartElement</symbol>
-    <symbol file="SAX2">xmlSAX2UnparsedEntityDecl</symbol>
-    <symbol file="SAX2">xmlSAXDefaultVersion</symbol>
-    <symbol file="SAX2">xmlSAXVersion</symbol>
-    <symbol file="HTMLparser">htmlCtxtReadDoc</symbol>
-    <symbol file="HTMLparser">htmlCtxtReadFd</symbol>
-    <symbol file="HTMLparser">htmlCtxtReadFile</symbol>
-    <symbol file="HTMLparser">htmlCtxtReadIO</symbol>
-    <symbol file="HTMLparser">htmlCtxtReadMemory</symbol>
-    <symbol file="HTMLparser">htmlCtxtReset</symbol>
-    <symbol file="HTMLparser">htmlCtxtUseOptions</symbol>
-    <symbol file="HTMLparser">htmlReadDoc</symbol>
-    <symbol file="HTMLparser">htmlReadFd</symbol>
-    <symbol file="HTMLparser">htmlReadFile</symbol>
-    <symbol file="HTMLparser">htmlReadIO</symbol>
-    <symbol file="HTMLparser">htmlReadMemory</symbol>
-    <symbol file="tree">xmlBufferCreateStatic</symbol>
-    <symbol file="chvalid">xmlCharInRange</symbol>
-    <symbol file="xmlIO">xmlCheckHTTPInput</symbol>
-    <symbol file="xmlerror">xmlCopyError</symbol>
-    <symbol file="xmlerror">xmlCtxtGetLastError</symbol>
-    <symbol file="xmlerror">xmlGetLastError</symbol>
-    <symbol file="xmlerror">xmlResetError</symbol>
-    <symbol file="xmlerror">xmlResetLastError</symbol>
-    <symbol file="xmlerror">xmlSetStructuredErrorFunc</symbol>
-    <symbol file="parser">xmlCtxtReadDoc</symbol>
-    <symbol file="parser">xmlCtxtReadFd</symbol>
-    <symbol file="parser">xmlCtxtReadFile</symbol>
-    <symbol file="parser">xmlCtxtReadIO</symbol>
-    <symbol file="parser">xmlCtxtReadMemory</symbol>
-    <symbol file="xmlerror">xmlCtxtResetLastError</symbol>
-    <symbol file="parser">xmlCtxtReset</symbol>
-    <symbol file="parser">xmlCtxtUseOptions</symbol>
-    <symbol file="parser">xmlReadDoc</symbol>
-    <symbol file="parser">xmlReadFd</symbol>
-    <symbol file="parser">xmlReadFile</symbol>
-    <symbol file="parser">xmlReadIO</symbol>
-    <symbol file="parser">xmlReadMemory</symbol>
-    <symbol file="xmlstring">xmlStrPrintf</symbol>
-    <symbol file="xmlstring">xmlStrQEqual</symbol>
-    <symbol file="dict">xmlDictCreate</symbol>
-    <symbol file="dict">xmlDictFree</symbol>
-    <symbol file="dict">xmlDictLookup</symbol>
-    <symbol file="dict">xmlDictOwns</symbol>
-    <symbol file="dict">xmlDictQLookup</symbol>
-    <symbol file="dict">xmlDictReference</symbol>
-    <symbol file="dict">xmlDictSize</symbol>
-    <symbol file="parserInternals">xmlErrMemory</symbol>
-    <symbol file="parserInternals">xmlParserMaxDepth</symbol>
-    <symbol file="parserInternals">xmlStringLenDecodeEntities</symbol>
-    <symbol file="parserInternals">xmlSwitchInputEncoding</symbol>
-    <symbol file="xmlwriter">xmlFreeTextWriter</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriterFilename</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriterMemory</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriter</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndAttribute</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndCDATA</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndDocument</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndDTD</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndPI</symbol>
-    <symbol file="xmlwriter">xmlTextWriterFlush</symbol>
-    <symbol file="xmlwriter">xmlTextWriterFullEndElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartAttributeNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartAttribute</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartCDATA</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartDocument</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartDTDAttlist</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartDTDElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartDTDEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartDTD</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartElementNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartPI</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteAttributeNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteAttribute</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteBase64</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteBinHex</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteCDATA</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteComment</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDAttlist</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDExternalEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDInternalEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDNotation</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTD</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteElementNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatAttributeNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatAttribute</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatCDATA</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatComment</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatDTDAttlist</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatDTDElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatDTDInternalEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatDTD</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatElementNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatPI</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatRaw</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteFormatString</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWritePI</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteRawLen</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteRaw</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteString</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatAttributeNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatAttribute</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatCDATA</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatComment</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatDTDAttlist</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatDTDElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatDTDInternalEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatDTD</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatElementNS</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatPI</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatRaw</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteVFormatString</symbol>
-    <symbol file="hash">xmlHashQLookup2</symbol>
-    <symbol file="hash">xmlHashQLookup3</symbol>
-    <symbol file="hash">xmlHashQLookup</symbol>
-    <symbol file="chvalid">xmlIsBaseCharGroup</symbol>
-    <symbol file="chvalid">xmlIsCharGroup</symbol>
-    <symbol file="chvalid">xmlIsCombiningGroup</symbol>
-    <symbol file="chvalid">xmlIsDigitGroup</symbol>
-    <symbol file="chvalid">xmlIsExtenderGroup</symbol>
-    <symbol file="chvalid">xmlIsIdeographicGroup</symbol>
-    <symbol file="chvalid">xmlIsPubidChar_tab</symbol>
-    <symbol file="globals">xmlLastError</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPEncoding</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPMimeType</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPRedir</symbol>
-    <symbol file="tree">xmlNodeBufGetContent</symbol>
-    <symbol file="xmlIO">xmlParserInputBufferCreateStatic</symbol>
-    <symbol file="xmlreader">xmlReaderForDoc</symbol>
-    <symbol file="xmlreader">xmlReaderForFd</symbol>
-    <symbol file="xmlreader">xmlReaderForFile</symbol>
-    <symbol file="xmlreader">xmlReaderForIO</symbol>
-    <symbol file="xmlreader">xmlReaderForMemory</symbol>
-    <symbol file="xmlreader">xmlReaderNewDoc</symbol>
-    <symbol file="xmlreader">xmlReaderNewFd</symbol>
-    <symbol file="xmlreader">xmlReaderNewFile</symbol>
-    <symbol file="xmlreader">xmlReaderNewIO</symbol>
-    <symbol file="xmlreader">xmlReaderNewMemory</symbol>
-    <symbol file="xmlreader">xmlReaderNewWalker</symbol>
-    <symbol file="xmlreader">xmlReaderWalker</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstBaseUri</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstLocalName</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstNamespaceUri</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstName</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstPrefix</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstString</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstXmlLang</symbol>
-    <symbol file="xmlreader">xmlTextReaderNextSibling</symbol>
-    <symbol file="xmlreader">xmlTextReaderPreserve</symbol>
-    <symbol file="globals">xmlStructuredError</symbol>
-    <symbol file="globals">xmlThrDefSetStructuredErrorFunc</symbol>
-    <symbol file="xpathInternals">xmlXPathErr</symbol>
-    <symbol removed="2.6.10" file="SAX2">xmlSAX2CheckNamespace</symbol>
-    <symbol removed="2.6.10" file="SAX2">xmlSAX2GetNamespace</symbol>
-    <symbol removed="2.6.10" file="SAX2">xmlSAX2GlobalNamespace</symbol>
-    <symbol removed="2.6.10" file="SAX2">xmlSAX2NamespaceDecl</symbol>
-    <symbol removed="2.6.10" file="SAX2">xmlSAX2SetNamespace</symbol>
-  </release>
-  <release version="2.6.1">
-    <symbol file="parser">xmlCtxtResetPush</symbol>
-  </release>
-  <release version="2.6.2">
-    <symbol file="parserInternals">xmlCreateURLParserCtxt</symbol>
-    <symbol file="xmlschemas">xmlSchemaNewDocParserCtxt</symbol>
-    <symbol file="xmlstring">xmlStrVPrintf</symbol>
-    <symbol file="xinclude">xmlXIncludeFreeContext</symbol>
-    <symbol file="xinclude">xmlXIncludeNewContext</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessNode</symbol>
-  </release>
-  <release version="2.6.3">
-    <symbol file="pattern">xmlFreePatternList</symbol>
-    <symbol file="pattern">xmlFreePattern</symbol>
-    <symbol file="pattern">xmlPatterncompile</symbol>
-    <symbol file="pattern">xmlPatternMatch</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriterDoc</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriterPushParser</symbol>
-    <symbol file="xmlwriter">xmlNewTextWriterTree</symbol>
-    <symbol file="xmlreader">xmlTextReaderPreservePattern</symbol>
-    <symbol file="xmlunicode">xmlUCSIsAegeanNumbers</symbol>
-    <symbol file="xmlunicode">xmlUCSIsBuhid</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCombiningDiacriticalMarksforSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCypriotSyllabary</symbol>
-    <symbol file="xmlunicode">xmlUCSIsCyrillicSupplement</symbol>
-    <symbol file="xmlunicode">xmlUCSIsGreekandCoptic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsHanunoo</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKatakanaPhoneticExtensions</symbol>
-    <symbol file="xmlunicode">xmlUCSIsKhmerSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLimbu</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLinearBIdeograms</symbol>
-    <symbol file="xmlunicode">xmlUCSIsLinearBSyllabary</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMiscellaneousMathematicalSymbolsA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMiscellaneousMathematicalSymbolsB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsMiscellaneousSymbolsandArrows</symbol>
-    <symbol file="xmlunicode">xmlUCSIsOsmanya</symbol>
-    <symbol file="xmlunicode">xmlUCSIsPhoneticExtensions</symbol>
-    <symbol file="xmlunicode">xmlUCSIsPrivateUseArea</symbol>
-    <symbol file="xmlunicode">xmlUCSIsShavian</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSupplementalArrowsA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSupplementalArrowsB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSupplementalMathematicalOperators</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSupplementaryPrivateUseAreaA</symbol>
-    <symbol file="xmlunicode">xmlUCSIsSupplementaryPrivateUseAreaB</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTagalog</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTagbanwa</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTaiLe</symbol>
-    <symbol file="xmlunicode">xmlUCSIsTaiXuanJingSymbols</symbol>
-    <symbol file="xmlunicode">xmlUCSIsUgaritic</symbol>
-    <symbol file="xmlunicode">xmlUCSIsVariationSelectorsSupplement</symbol>
-    <symbol file="xmlunicode">xmlUCSIsVariationSelectors</symbol>
-    <symbol file="xmlunicode">xmlUCSIsYijingHexagramSymbols</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessFlags</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessTreeFlags</symbol>
-    <symbol file="xinclude">xmlXIncludeSetFlags</symbol>
-  </release>
-  <release version="2.6.5">
-    <symbol file="xmlmemory">xmlCleanupMemory</symbol>
-    <symbol file="dict">xmlDictCreateSub</symbol>
-    <symbol file="relaxng">xmlRelaxParserSetFlag</symbol>
-    <symbol file="xmlstring">xmlStrncatNew</symbol>
-    <symbol file="xmlwriter">xmlTextWriterSetIndentString</symbol>
-    <symbol file="xmlwriter">xmlTextWriterSetIndent</symbol>
-    <symbol file="xpath">xmlXPathCtxtCompile</symbol>
-  </release>
-  <release version="2.6.6">
-    <symbol file="tree">xmlAttrSerializeTxtContent</symbol>
-    <symbol file="parser">xmlByteConsumed</symbol>
-    <symbol file="xmlreader">xmlTextReaderSetStructuredErrorHandler</symbol>
-  </release>
-  <release version="2.6.7">
-    <symbol file="xmlwriter">xmlTextWriterEndComment</symbol>
-    <symbol file="xmlwriter">xmlTextWriterStartComment</symbol>
-  </release>
-  <release version="2.6.8">
-    <symbol file="xmlsave">xmlSaveClose</symbol>
-    <symbol file="xmlsave">xmlSaveDoc</symbol>
-    <symbol file="xmlsave">xmlSaveFlush</symbol>
-    <symbol file="xmlsave">xmlSaveToFd</symbol>
-    <symbol file="xmlsave">xmlSaveToFilename</symbol>
-    <symbol file="xmlsave">xmlSaveToIO</symbol>
-    <symbol file="xmlsave">xmlSaveTree</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndDTDAttlist</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndDTDElement</symbol>
-    <symbol file="xmlwriter">xmlTextWriterEndDTDEntity</symbol>
-    <symbol file="xmlwriter">xmlTextWriterWriteDTDExternalEntityContents</symbol>
-  </release>
-  <release version="2.6.10">
-    <symbol file="xmlIO">xmlOutputBufferWriteEscape</symbol>
-    <symbol file="xmlIO">xmlPopInputCallbacks</symbol>
-    <symbol file="xmlsave">xmlSaveSetAttrEscape</symbol>
-    <symbol file="xmlsave">xmlSaveSetEscape</symbol>
-  </release>
-  <release version="2.6.11">
-    <symbol file="uri">xmlBuildRelativeURI</symbol>
-    <symbol file="globals">xmlOutputBufferCreateFilenameDefault</symbol>
-    <symbol file="globals">xmlOutputBufferCreateFilenameValue</symbol>
-    <symbol file="globals">xmlParserInputBufferCreateFilenameDefault</symbol>
-    <symbol file="globals">xmlParserInputBufferCreateFilenameValue</symbol>
-    <symbol file="globals">xmlThrDefOutputBufferCreateFilenameDefault</symbol>
-    <symbol file="globals">xmlThrDefParserInputBufferCreateFilenameDefault</symbol>
-    <symbol file="schemasInternals">xmlSchemaFreeWildcard</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCollapseString</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetBuiltInListSimpleTypeItemType</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetBuiltInType</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaIsBuiltInTypeFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidateListSimpleTypeFacet</symbol>
-  </release>
-  <release version="2.6.12">
-    <symbol file="parser">xmlParseInNodeContext</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetFacetValueAsULong</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidateLengthFacet</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValPredefTypeNodeNoNorm</symbol>
-    <symbol file="xmlschemas">xmlSchemaGetParserErrors</symbol>
-    <symbol file="xmlschemas">xmlSchemaGetValidErrors</symbol>
-  </release>
-  <release version="2.6.14">
-    <symbol file="xmlautomata">xmlAutomataNewCountTrans2</symbol>
-    <symbol file="xmlautomata">xmlAutomataNewOnceTrans2</symbol>
-    <symbol file="nanohttp">xmlNanoHTTPContentLength</symbol>
-    <symbol file="xmlschemas">xmlSchemaSetValidOptions</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateOneElement</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidCtxtGetOptions</symbol>
-  </release>
-  <release version="2.6.15">
-    <symbol file="debugXML">xmlDebugCheckDocument</symbol>
-    <symbol file="tree">xmlDocCopyNodeList</symbol>
-    <symbol file="tree">xmlNewDocPI</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstEncoding</symbol>
-    <symbol file="xmlreader">xmlTextReaderConstXmlVersion</symbol>
-    <symbol file="xmlreader">xmlTextReaderIsNamespaceDecl</symbol>
-    <symbol file="xmlreader">xmlTextReaderStandalone</symbol>
-  </release>
-  <release version="2.6.16">
-    <symbol file="xmlmemory">xmlMemBlocks</symbol>
-    <symbol file="relaxng">xmlRelaxNGInitTypes</symbol>
-  </release>
-  <release version="2.6.17">
-    <symbol file="dict">xmlDictExists</symbol>
-    <symbol file="xmlmodule">xmlModuleClose</symbol>
-    <symbol file="xmlmodule">xmlModuleFree</symbol>
-    <symbol file="xmlmodule">xmlModuleOpen</symbol>
-    <symbol file="xmlmodule">xmlModuleSymbol</symbol>
-    <symbol file="xmlregexp">xmlRegExecErrInfo</symbol>
-    <symbol file="xmlregexp">xmlRegExecNextValues</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaWhiteSpaceReplace</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetParserColumnNumber</symbol>
-    <symbol file="xmlreader">xmlTextReaderGetParserLineNumber</symbol>
-  </release>
-  <release version="2.6.18">
-    <symbol file="valid">xmlCopyDocElementContent</symbol>
-    <symbol file="valid">xmlFreeDocElementContent</symbol>
-    <symbol file="valid">xmlNewDocElementContent</symbol>
-    <symbol file="dict">xmlDictCleanup</symbol>
-    <symbol file="hash">xmlHashCreateDict</symbol>
-    <symbol file="pattern">xmlFreeStreamCtxt</symbol>
-    <symbol file="pattern">xmlPatternFromRoot</symbol>
-    <symbol file="pattern">xmlPatternGetStreamCtxt</symbol>
-    <symbol file="pattern">xmlPatternMaxDepth</symbol>
-    <symbol file="pattern">xmlPatternStreamable</symbol>
-    <symbol file="pattern">xmlStreamPop</symbol>
-    <symbol file="pattern">xmlStreamPushAttr</symbol>
-    <symbol file="pattern">xmlStreamPush</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCompareValuesWhtsp</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaCopyValue</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetCanonValue</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaNewNOTATIONValue</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaNewStringValue</symbol>
-    <symbol file="xmlreader">xmlTextReaderByteConsumed</symbol>
-  </release>
-  <release version="2.6.19">
-    <symbol file="xmlschemastypes">xmlSchemaGetValType</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidateFacetWhtsp</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValidateLengthFacetWhtsp</symbol>
-  </release>
-  <release version="2.6.20">
-    <symbol file="tree">xmlDOMWrapAdoptNode</symbol>
-    <symbol file="tree">xmlDOMWrapFreeCtxt</symbol>
-    <symbol file="tree">xmlDOMWrapNewCtxt</symbol>
-    <symbol file="tree">xmlDOMWrapReconcileNamespaces</symbol>
-    <symbol file="tree">xmlDOMWrapRemoveNode</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaGetCanonValueWhtsp</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaNewQNameValue</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValueAppend</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValueGetAsBoolean</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValueGetAsString</symbol>
-    <symbol file="xmlschemastypes">xmlSchemaValueGetNext</symbol>
-    <symbol file="xmlschemas">xmlSchemaIsValid</symbol>
-    <symbol file="xmlschemas">xmlSchemaSAXPlug</symbol>
-    <symbol file="xmlschemas">xmlSchemaSAXUnplug</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateFile</symbol>
-    <symbol file="xmlreader">xmlTextReaderSchemaValidate</symbol>
-    <symbol file="xmlreader">xmlTextReaderSetSchema</symbol>
-  </release>
-  <release version="2.6.21">
-    <symbol file="xmlautomata">xmlAutomataNewNegTrans</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">emptyExp</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">forbiddenExp</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpCtxtNbCons</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpCtxtNbNodes</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpDump</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpExpDerive</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpFreeCtxt</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpFree</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpGetLanguage</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpGetStart</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpIsNillable</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpMaxToken</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpNewAtom</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpNewCtxt</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpNewOr</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpNewRange</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpNewSeq</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpParse</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpRef</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpStringDerive</symbol>
-    <symbol removed="2.9.10" file="xmlregexp">xmlExpSubsume</symbol>
-    <symbol file="parser">xmlHasFeature</symbol>
-    <symbol file="uri">xmlParseURIRaw</symbol>
-    <symbol file="pattern">xmlPatternMinDepth</symbol>
-    <symbol file="relaxng">xmlRelaxNGSetValidStructuredErrors</symbol>
-    <symbol file="xmlschemas">xmlSchemaSetValidStructuredErrors</symbol>
-    <symbol file="schematron">xmlSchematronFreeParserCtxt</symbol>
-    <symbol file="schematron">xmlSchematronFree</symbol>
-    <symbol file="schematron">xmlSchematronFreeValidCtxt</symbol>
-    <symbol file="schematron">xmlSchematronNewDocParserCtxt</symbol>
-    <symbol file="schematron">xmlSchematronNewMemParserCtxt</symbol>
-    <symbol file="schematron">xmlSchematronNewParserCtxt</symbol>
-    <symbol file="schematron">xmlSchematronNewValidCtxt</symbol>
-    <symbol file="schematron">xmlSchematronParse</symbol>
-    <symbol file="schematron">xmlSchematronValidateDoc</symbol>
-  </release>
-  <release version="2.6.23">
-    <symbol file="HTMLtree">htmlDocDumpMemoryFormat</symbol>
-    <symbol file="xmlIO">xmlOutputBufferCreateBuffer</symbol>
-    <symbol file="xmlsave" comment="suppressed in 2.6.11, readded in 2.6.23">xmlSaveToBuffer</symbol>
-    <symbol file="xmlschemas">xmlSchemaSetParserStructuredErrors</symbol>
-    <symbol file="pattern">xmlStreamPushNode</symbol>
-    <symbol file="pattern">xmlStreamWantsAnyNode</symbol>
-    <symbol file="xmlreader">xmlTextReaderSchemaValidateCtxt</symbol>
-  </release>
-  <release version="2.6.24">
-    <symbol file="tree">xmlDOMWrapCloneNode</symbol>
-    <symbol file="relaxng">xmlRelaxNGSetParserStructuredErrors</symbol>
-  </release>
-  <release version="2.6.25">
-    <symbol file="xpath">xmlXPathContextSetCache</symbol>
-  </release>
-  <release version="2.6.27">
-    <symbol file="HTMLparser">htmlNewParserCtxt</symbol>
-    <symbol file="uri">xmlPathToURI</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessFlagsData</symbol>
-    <symbol file="xpath">xmlXPathCompiledEvalToBoolean</symbol>
-  </release>
-  <release version="2.6.28">
-    <symbol file="xmlreader">xmlTextReaderSetup</symbol>
-  </release>
-  <release version="2.6.29">
-    <symbol file="threads">xmlDllMain</symbol>
-  </release>
-  <release version="2.6.32">
-    <symbol file="schematron">xmlSchematronSetValidStructuredErrors</symbol>
-  </release>
-  <release version="2.7.0">
-    <symbol file="xmlmemory">xmlMemDisplayLast</symbol>
-    <symbol file="entities">xmlNewEntity</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidCtxtGetParserCtxt</symbol>
-  </release>
-  <release version="2.7.3">
-    <symbol file="tree">xmlChildElementCount</symbol>
-    <symbol file="tree">xmlFirstElementChild</symbol>
-    <symbol file="tree">xmlLastElementChild</symbol>
-    <symbol file="tree">xmlNextElementSibling</symbol>
-    <symbol file="tree">xmlPreviousElementSibling</symbol>
-  </release>
-  <release version="2.7.4">
-    <symbol file="globals">xmlStructuredErrorContext</symbol>
-    <symbol file="xinclude">xmlXIncludeProcessTreeFlagsData</symbol>
-  </release>
-  <release version="2.8.0">
-    <symbol file="xmlreader">xmlTextReaderRelaxNGValidateCtxt</symbol>
-    <symbol file="tree">xmlBufferDetach</symbol>
-    <symbol file="dict">xmlInitializeDict</symbol>
-  </release>
-  <release version="2.9.0">
-    <symbol file="tree">xmlBufContent</symbol>
-    <symbol file="tree">xmlBufEnd</symbol>
-    <symbol file="tree">xmlBufGetNodeContent</symbol>
-    <symbol file="tree">xmlBufNodeDump</symbol>
-    <symbol file="tree">xmlBufShrink</symbol>
-    <symbol file="tree">xmlBufUse</symbol>
-    <symbol file="dict">xmlDictGetUsage</symbol>
-    <symbol file="dict">xmlDictSetLimit</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateSetFilename</symbol>
-    <symbol file="xmlschemas">xmlSchemaValidateSetLocator</symbol>
-    <symbol file="xmlIO">xmlOutputBufferGetContent</symbol>
-    <symbol file="xmlIO">xmlOutputBufferGetSize</symbol>
-    <symbol file="xmlwriter">xmlTextWriterSetQuoteChar</symbol>
-  </release>
-  <release version="2.9.1">
-    <symbol file="xpath">xmlXPathNodeEval</symbol>
-    <symbol file="xpath">xmlXPathSetContextNode</symbol>
-  </release>
-  <release version="2.9.8">
-    <symbol file="hash">xmlHashDefaultDeallocator</symbol>
-  </release>
-  <release version="2.9.11">
-    <symbol file="xmlIO">xmlPopOutputCallbacks</symbol>
-  </release>
-</symbols>
diff --git a/doc/syms.xsl b/doc/syms.xsl
deleted file mode 100644 (file)
index ebca88f..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0">
-  <xsl:output method="text" encoding="UTF-8"/>
-
-  <xsl:variable name="api" select="document('libxml2-api.xml')"/>
-
-  <xsl:template match="/">
-    <xsl:text>#
-# Officially exported symbols, for which header
-# file definitions are installed in /usr/include/libxml2
-#
-# Automatically generated from symbols.xml and syms.xsl
-#
-# Versions here are *fixed* to match the libxml2 version
-# at which the symbol was introduced. This ensures that
-# a new client app requiring symbol foo() can't accidentally
-# run with old libxml2.so not providing foo() - the global
-# soname version info can't enforce this since we never
-# change the soname
-#
-
-</xsl:text>
-    <xsl:apply-templates select="/symbols/release"/>
-  </xsl:template>
-
-  <xsl:template match="release">
-    <xsl:variable name="prev"
-                  select="preceding-sibling::release[position()=1]"/>
-    <xsl:text>LIBXML2_</xsl:text>
-    <xsl:value-of select="string(@version)"/>
-    <xsl:text> {
-    global:
-</xsl:text>
-    <xsl:for-each select="symbol">
-      <xsl:if test="string(preceding-sibling::symbol[position()=1]/@file) != string(@file)">
-        <xsl:text>
-# </xsl:text>
-        <xsl:value-of select="@file"/>
-        <xsl:text>
-</xsl:text>
-      </xsl:if>
-
-      <xsl:apply-templates select="."/>
-    </xsl:for-each>
-
-    <xsl:text>} </xsl:text>
-    <xsl:if test="$prev">
-      <xsl:text>LIBXML2_</xsl:text>
-      <xsl:value-of select="$prev/@version"/>
-    </xsl:if>
-    <xsl:text>;
-
-</xsl:text>
-  </xsl:template>
-
-  <xsl:template match="symbol">
-    <xsl:variable name="name" select="string(.)"/>
-    <xsl:variable name="file" select="string(@file)"/>
-    <xsl:choose>
-      <xsl:when test="@removed">
-        <xsl:text># </xsl:text>
-        <xsl:value-of select="$name"/>
-        <xsl:text>; removed in </xsl:text>
-        <xsl:value-of select="@removed"/>
-        <xsl:text>
-</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-        <!-- make sure we can find that symbol exported from the API list -->
-        <xsl:variable name="def"
-            select="$api/api/files/file[@name = $file]/exports[@symbol = $name]"/>
-        <xsl:if test="string($def/@symbol) != $name">
-          <xsl:message terminate="yes">
-            <xsl:text>Failed to find definition in libxml2-api.xml:</xsl:text>
-            <xsl:value-of select="$name"/>
-          </xsl:message>
-        </xsl:if>
-
-        <xsl:text>  </xsl:text>
-        <xsl:value-of select="$name"/>
-        <xsl:text>;</xsl:text>
-        <xsl:if test="$def/@type = 'variable'">
-          <xsl:text> # variable</xsl:text>
-        </xsl:if>
-        <xsl:if test="@comment">
-          <xsl:text># </xsl:text>
-          <xsl:value-of select="@comment"/>
-          <xsl:text>
-</xsl:text>
-        </xsl:if>
-        <xsl:text>
-</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-</xsl:stylesheet>
-
index 5605bea..0e1c1af 100644 (file)
@@ -1,13 +1,13 @@
 '\" t
 .\"     Title: xmlcatalog
 .\"    Author: John Fleck <jfleck@inkstain.net>
-.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 08/17/2022
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
+.\"      Date: 11/04/2023
 .\"    Manual: xmlcatalog Manual
 .\"    Source: libxml2
 .\"  Language: English
 .\"
-.TH "XMLCATALOG" "1" "08/17/2022" "libxml2" "xmlcatalog Manual"
+.TH "XMLCATALOG" "1" "11/04/2023" "libxml2" "xmlcatalog Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
 xmlcatalog \- Command line tool to parse and manipulate XML or SGML catalog files\&.
 .SH "SYNOPSIS"
 .HP \w'\fBxmlcatalog\fR\ 'u
-\fBxmlcatalog\fR [\fB\-\-sgml\fR | \fB\-\-shell\fR | \fB\-\-create\fR | \fB\-\-del\ \fR\fB\fIVALUE(S)\fR\fR | [\ \fB\-\-add\ \fR\fB\fITYPE\fR\fR\fB\ \fR\fB\fIORIG\fR\fR\fB\ \fR\fB\fIREPLACE\fR\fR\fB\ \fR\ |\ \fB\-\-add\ \fR\fB\fIFILENAME\fR\fR] | \fB\-\-noout\fR | \fB\-\-no\-super\-update\fR | [\fB\-v\fR\ |\ \fB\-\-verbose\fR]] {\fICATALOGFILE\fR} {\fIENTITIES\fR...}
+\fBxmlcatalog\fR [\fB\-\-sgml\fR | \fB\-\-shell\fR | \fB\-\-convert\fR | \fB\-\-create\fR | \fB\-\-del\ \fR\fB\fIVALUE(S)\fR\fR | [\ \fB\-\-add\ \fR\fB\fITYPE\fR\fR\fB\ \fR\fB\fIORIG\fR\fR\fB\ \fR\fB\fIREPLACE\fR\fR\fB\ \fR\ |\ \fB\-\-add\ \fR\fB\fIFILENAME\fR\fR] | \fB\-\-noout\fR | \fB\-\-no\-super\-update\fR | [\fB\-v\fR\ |\ \fB\-\-verbose\fR]] {\fICATALOGFILE\fR} {\fIENTITIES\fR...}
 .SH "DESCRIPTION"
 .PP
 \fBxmlcatalog\fR
@@ -91,6 +91,11 @@ SGML
 catalog files\&.
 .RE
 .PP
+\fB\-\-convert\fR
+.RS 4
+Convert SGML catalog to XML\&.
+.RE
+.PP
 \fB\-\-create\fR
 .RS 4
 Create a new
@@ -245,9 +250,10 @@ Execute a Formal Public Identifier lookup of the catalog entry for
 XML
 catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
 \fBXML_CATALOG_FILES\fR
-environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default
+environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog from
 /etc/xml/catalog
-catalog\&.
+or, more specifically,
+${sysconfdir}/xml/catalog\&.
 .RE
 .SH "DIAGNOSTICS"
 .PP
index ae2ebab..01ff864 100644 (file)
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212; 
-               Command line tool to parse and manipulate <acronym class="acronym">XML</acronym>
-               or <acronym class="acronym">SGML</acronym> catalog files.
-       </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmlcatalog</code>  [ <code class="option">--sgml</code>  |   <code class="option">--shell</code>  |   <code class="option">--create</code>  |   <code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code>  |   
-                       [ 
-                                       <code class="option">--add
-                                        <em class="replaceable"><code>TYPE</code></em>
-                                        <em class="replaceable"><code>ORIG</code></em>
-                                        <em class="replaceable"><code>REPLACE</code></em>
-                                       </code>
-                                 |   <code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code> ]            
-                 |   <code class="option">--noout</code>  |   <code class="option">--no-super-update</code>  |   
-                       [ <code class="option">-v</code>  |   <code class="option">--verbose</code> ]
-                ] {<em class="replaceable"><code>CATALOGFILE</code></em>} {<em class="replaceable"><code>ENTITIES</code></em>...}</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
-               <span class="command"><strong>xmlcatalog</strong></span> is a command line application allowing users to monitor and
-               manipulate <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> catalogs. It
-               is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.
-       </p><p>
-               Its functions can be invoked from a single command from the command line,
-               or it can perform multiple functions in interactive mode. It can operate
-               on both <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> files.
-       </p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
-               <span class="command"><strong>xmlcatalog</strong></span> accepts the following options (in alphabetical order):
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
-               <code class="option">--add
-                <em class="replaceable"><code>TYPE</code></em>
-                <em class="replaceable"><code>ORIG</code></em>
-                <em class="replaceable"><code>REPLACE</code></em>
-               </code>
-       </span></dt><dd><p>
-                       Add an entry to <code class="filename">CATALOGFILE</code>. <em class="replaceable"><code>TYPE</code></em>
-                       indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
-                       reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
-                       is the <acronym class="acronym">URI</acronym> of the replacement entity to be
-                       used. The <code class="option">--add</code> option will not overwrite
-                       <code class="filename">CATALOGFILE</code>, outputting
-                       to <code class="filename">stdout</code>, unless
-                       <code class="option">--noout</code> is used. The <code class="option">--add</code> will
-                       always take three parameters even if some of the <acronym class="acronym">XML</acronym>
-                       catalog constructs will have only a single argument.
-               </p></dd><dt><span class="term"><code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code></span></dt><dd><p>
-                       If the <code class="option">--add</code> option is used following
-                       the <code class="option">--sgml</code> option, only a single argument,
-                       a <em class="replaceable"><code>FILENAME</code></em>, is used. This is used to add
-                       the name of a catalog file to an <acronym class="acronym">SGML</acronym> supercatalog,
-                       a file that contains references to other included <acronym class="acronym">SGML</acronym>
-                       catalog files.
-               </p></dd><dt><span class="term"><code class="option">--create</code></span></dt><dd><p>
-                       Create a new <acronym class="acronym">XML</acronym> catalog. Outputs
-                       to <code class="filename">stdout</code>,
-                       ignoring <em class="replaceable"><code>filename</code></em> unless <code class="option">--noout</code> is
-                       used, in which case it creates a new catalog
-                       file <em class="replaceable"><code>filename</code></em>.
-               </p></dd><dt><span class="term"><code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
-                       Remove entries from <em class="replaceable"><code>CATALOGFILE</code></em>
-                       matching <em class="replaceable"><code>VALUE(S)</code></em>. The <code class="option">--del</code>
-                       option will not overwrite <em class="replaceable"><code>CATALOGFILE</code></em>,
-                       outputting to <code class="filename">stdout</code>,
-                       unless <code class="option">--noout</code> is used.
-               </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
-                       Save output to the named file rather than outputting
-                       to <code class="filename">stdout</code>.
-               </p></dd><dt><span class="term"><code class="option">--no-super-update</code></span></dt><dd><p>
-                       Do not update the <acronym class="acronym">SGML</acronym> super catalog.
-               </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
-                       Run a shell allowing interactive queries on catalog
-                       file <em class="replaceable"><code>CATALOGFILE</code></em>. For the set of available
-                       commands see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>.
-               </p></dd><dt><span class="term"><code class="option">--sgml</code></span></dt><dd><p>
-                       Uses <acronym class="acronym">SGML</acronym> super catalogs for <code class="option">--add</code>
-                       and <code class="option">--del</code> options.
-               </p></dd><dt><span class="term"><code class="option">-v</code>, </span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>Output debugging information.</p></dd></dl></div><p>
-               Invoking <span class="command"><strong>xmlcatalog</strong></span> non-interactively without a designated action
-               (imposed with options like <code class="option">--add</code>) will result in a lookup
-               of the catalog entry for <em class="replaceable"><code>ENTITIES</code></em> in the
-               catalog denoted with <em class="replaceable"><code>CATALOGFILE</code></em>. The
-               corresponding entries will be output to the command line. This mode of
-               operation, together with <code class="option">--shell</code> mode and non-modifying
-               (i.e. without <code class="option">--noout</code>) direct actions, allows for
-               a special shortcut of the void <em class="replaceable"><code>CATALOGFILE</code></em>
-               specification (possibly expressed as "" in the shell
-               environment) appointing the default system catalog. That simplifies the
-               handling when its exact location is irrelevant but the respective built-in
-               still needs to be consulted.
-       </p></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
-               Invoking <span class="command"><strong>xmlcatalog</strong></span> with
-               the <code class="option">--shell <em class="replaceable"><code>CATALOGFILE</code></em></code> option opens
-               a command line shell allowing interactive access to the catalog file
-               identified by <em class="replaceable"><code>CATALOGFILE</code></em>. Invoking the shell
-               provides a command line prompt after which the following commands (described in
-               alphabetical order) can be entered.
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
-               <code class="option">add
-                <em class="replaceable"><code>TYPE</code></em>
-                <em class="replaceable"><code>ORIG</code></em>
-                <em class="replaceable"><code>REPLACE</code></em>
-               </code>
-       </span></dt><dd><p>
-                       Add an entry to the catalog file. <em class="replaceable"><code>TYPE</code></em>
-                       indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
-                       reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
-                       is the <acronym class="acronym">URI</acronym> of the replacement entity to be
-                       used. The <code class="option">--add</code> option will not overwrite
-                       <code class="filename">CATALOGFILE</code>, outputting
-                       to <code class="filename">stdout</code>, unless
-                       <code class="option">--noout</code> is used. The <code class="option">--add</code> will
-                       always take three parameters even if some of the <acronym class="acronym">XML</acronym>
-                       catalog constructs will have only a single argument.
-               </p></dd><dt><span class="term"><code class="option">debug</code></span></dt><dd><p>
-                       Print debugging statements showing the steps <span class="command"><strong>xmlcatalog</strong></span> is executing.
-               </p></dd><dt><span class="term"><code class="option">del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
-                       Remove the catalog entry corresponding to <em class="replaceable"><code>VALUE(S)</code></em>.
-               </p></dd><dt><span class="term"><code class="option">dump</code></span></dt><dd><p>Print the current catalog.</p></dd><dt><span class="term"><code class="option">exit</code></span></dt><dd><p>Quit the shell.</p></dd><dt><span class="term"><code class="option">public <em class="replaceable"><code>PUBLIC-ID</code></em></code></span></dt><dd><p>
-                       Execute a Formal Public Identifier lookup of the catalog entry
-                       for <em class="replaceable"><code>PUBLIC-ID</code></em>. The corresponding entry will be
-                       output to the command line.
-               </p></dd><dt><span class="term"><code class="option">quiet</code></span></dt><dd><p>Stop printing debugging statements.</p></dd><dt><span class="term"><code class="option">system <em class="replaceable"><code>SYSTEM-ID</code></em></code></span></dt><dd><p>
-                       Execute a Formal Public Identifier lookup of the catalog entry
-                       for <em class="replaceable"><code>SYSTEM-ID</code></em>. The corresponding entry will be
-                       output to the command line.
-               </p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
-                       list of catalogs. Use percent-encoding to escape spaces or other characters.
-                       An empty variable should deactivate loading the default <code class="filename">/etc/xml/catalog</code> catalog.
-               </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
-               <span class="command"><strong>xmlcatalog</strong></span> return codes provide information that can be used when
-               calling it from scripts.
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Failed to remove an entry from the catalog</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Failed to save to the catalog, check file permissions</p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Failed to add an entry to the catalog</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Failed to look up an entry in the catalog</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
-       </p><p>
-               More information can be found at
-               </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
-                               </p></li><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> catalog support web page
-                                       at <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support" target="_top">https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support</a>
-                               </p></li><li class="listitem"><p>James Clark's <acronym class="acronym">SGML</acronym> catalog
-                                       page <a class="ulink" href="http://www.jclark.com/sp/catalog.htm" target="_top">http://www.jclark.com/sp/catalog.htm</a>
-                               </p></li><li class="listitem"><p><acronym class="acronym">OASIS</acronym> <acronym class="acronym">XML</acronym> catalog specification
-                                       <a class="ulink" href="http://www.oasis-open.org/committees/entity/spec.html" target="_top">http://www.oasis-open.org/committees/entity/spec.html</a>
-                               </p></li></ul></div><p>
-       </p></div></div></body></html>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212; 
+        Command line tool to parse and manipulate <acronym class="acronym">XML</acronym>
+        or <acronym class="acronym">SGML</acronym> catalog files.
+    </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmlcatalog</code>  [ <code class="option">--sgml</code>  |   <code class="option">--shell</code>  |   <code class="option">--convert</code>  |   <code class="option">--create</code>  |   <code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code>  |   
+            [ 
+                    <code class="option">--add
+                     <em class="replaceable"><code>TYPE</code></em>
+                     <em class="replaceable"><code>ORIG</code></em>
+                     <em class="replaceable"><code>REPLACE</code></em>
+                    </code>
+                  |   <code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code> ]
+          |   <code class="option">--noout</code>  |   <code class="option">--no-super-update</code>  |   
+            [ <code class="option">-v</code>  |   <code class="option">--verbose</code> ]
+         ] {<em class="replaceable"><code>CATALOGFILE</code></em>} {<em class="replaceable"><code>ENTITIES</code></em>...}</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
+        <span class="command"><strong>xmlcatalog</strong></span> is a command line application allowing users to monitor and
+        manipulate <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> catalogs. It
+        is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.
+    </p><p>
+        Its functions can be invoked from a single command from the command line,
+        or it can perform multiple functions in interactive mode. It can operate
+        on both <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> files.
+    </p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
+        <span class="command"><strong>xmlcatalog</strong></span> accepts the following options (in alphabetical order):
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
+                <code class="option">--add
+                 <em class="replaceable"><code>TYPE</code></em>
+                 <em class="replaceable"><code>ORIG</code></em>
+                 <em class="replaceable"><code>REPLACE</code></em>
+                </code>
+            </span></dt><dd><p>
+                    Add an entry to <code class="filename">CATALOGFILE</code>. <em class="replaceable"><code>TYPE</code></em>
+                    indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
+                    reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
+                    is the <acronym class="acronym">URI</acronym> of the replacement entity to be
+                    used. The <code class="option">--add</code> option will not overwrite
+                    <code class="filename">CATALOGFILE</code>, outputting
+                    to <code class="filename">stdout</code>, unless
+                    <code class="option">--noout</code> is used. The <code class="option">--add</code> will
+                    always take three parameters even if some of the <acronym class="acronym">XML</acronym>
+                    catalog constructs will have only a single argument.
+                </p></dd><dt><span class="term"><code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code></span></dt><dd><p>
+                    If the <code class="option">--add</code> option is used following
+                    the <code class="option">--sgml</code> option, only a single argument,
+                    a <em class="replaceable"><code>FILENAME</code></em>, is used. This is used to add
+                    the name of a catalog file to an <acronym class="acronym">SGML</acronym> supercatalog,
+                    a file that contains references to other included <acronym class="acronym">SGML</acronym>
+                    catalog files.
+                </p></dd><dt><span class="term"><code class="option">--convert</code></span></dt><dd><p>
+                    Convert SGML catalog to XML.
+                </p></dd><dt><span class="term"><code class="option">--create</code></span></dt><dd><p>
+                    Create a new <acronym class="acronym">XML</acronym> catalog. Outputs
+                    to <code class="filename">stdout</code>,
+                    ignoring <em class="replaceable"><code>filename</code></em> unless <code class="option">--noout</code> is
+                    used, in which case it creates a new catalog
+                    file <em class="replaceable"><code>filename</code></em>.
+                </p></dd><dt><span class="term"><code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
+                    Remove entries from <em class="replaceable"><code>CATALOGFILE</code></em>
+                    matching <em class="replaceable"><code>VALUE(S)</code></em>. The <code class="option">--del</code>
+                    option will not overwrite <em class="replaceable"><code>CATALOGFILE</code></em>,
+                    outputting to <code class="filename">stdout</code>,
+                    unless <code class="option">--noout</code> is used.
+                </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
+                    Save output to the named file rather than outputting
+                    to <code class="filename">stdout</code>.
+                </p></dd><dt><span class="term"><code class="option">--no-super-update</code></span></dt><dd><p>
+                    Do not update the <acronym class="acronym">SGML</acronym> super catalog.
+                </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
+                    Run a shell allowing interactive queries on catalog
+                    file <em class="replaceable"><code>CATALOGFILE</code></em>. For the set of available
+                    commands see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>.
+                </p></dd><dt><span class="term"><code class="option">--sgml</code></span></dt><dd><p>
+                    Uses <acronym class="acronym">SGML</acronym> super catalogs for <code class="option">--add</code>
+                    and <code class="option">--del</code> options.
+                </p></dd><dt><span class="term"><code class="option">-v</code>, </span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>Output debugging information.</p></dd></dl></div><p>
+        Invoking <span class="command"><strong>xmlcatalog</strong></span> non-interactively without a designated action
+        (imposed with options like <code class="option">--add</code>) will result in a lookup
+        of the catalog entry for <em class="replaceable"><code>ENTITIES</code></em> in the
+        catalog denoted with <em class="replaceable"><code>CATALOGFILE</code></em>. The
+        corresponding entries will be output to the command line. This mode of
+        operation, together with <code class="option">--shell</code> mode and non-modifying
+        (i.e. without <code class="option">--noout</code>) direct actions, allows for
+        a special shortcut of the void <em class="replaceable"><code>CATALOGFILE</code></em>
+        specification (possibly expressed as "" in the shell
+        environment) appointing the default system catalog. That simplifies the
+        handling when its exact location is irrelevant but the respective built-in
+        still needs to be consulted.
+    </p></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
+        Invoking <span class="command"><strong>xmlcatalog</strong></span> with
+        the <code class="option">--shell <em class="replaceable"><code>CATALOGFILE</code></em></code> option opens
+        a command line shell allowing interactive access to the catalog file
+        identified by <em class="replaceable"><code>CATALOGFILE</code></em>. Invoking the shell
+        provides a command line prompt after which the following commands (described in
+        alphabetical order) can be entered.
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
+                <code class="option">add
+                 <em class="replaceable"><code>TYPE</code></em>
+                 <em class="replaceable"><code>ORIG</code></em>
+                 <em class="replaceable"><code>REPLACE</code></em>
+                </code>
+            </span></dt><dd><p>
+                    Add an entry to the catalog file. <em class="replaceable"><code>TYPE</code></em>
+                    indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
+                    reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
+                    is the <acronym class="acronym">URI</acronym> of the replacement entity to be
+                    used. The <code class="option">--add</code> option will not overwrite
+                    <code class="filename">CATALOGFILE</code>, outputting
+                    to <code class="filename">stdout</code>, unless
+                    <code class="option">--noout</code> is used. The <code class="option">--add</code> will
+                    always take three parameters even if some of the <acronym class="acronym">XML</acronym>
+                    catalog constructs will have only a single argument.
+                </p></dd><dt><span class="term"><code class="option">debug</code></span></dt><dd><p>
+                    Print debugging statements showing the steps <span class="command"><strong>xmlcatalog</strong></span> is executing.
+                </p></dd><dt><span class="term"><code class="option">del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
+                    Remove the catalog entry corresponding to <em class="replaceable"><code>VALUE(S)</code></em>.
+                </p></dd><dt><span class="term"><code class="option">dump</code></span></dt><dd><p>Print the current catalog.</p></dd><dt><span class="term"><code class="option">exit</code></span></dt><dd><p>Quit the shell.</p></dd><dt><span class="term"><code class="option">public <em class="replaceable"><code>PUBLIC-ID</code></em></code></span></dt><dd><p>
+                    Execute a Formal Public Identifier lookup of the catalog entry
+                    for <em class="replaceable"><code>PUBLIC-ID</code></em>. The corresponding entry will be
+                    output to the command line.
+                </p></dd><dt><span class="term"><code class="option">quiet</code></span></dt><dd><p>Stop printing debugging statements.</p></dd><dt><span class="term"><code class="option">system <em class="replaceable"><code>SYSTEM-ID</code></em></code></span></dt><dd><p>
+                    Execute a Formal Public Identifier lookup of the catalog entry
+                    for <em class="replaceable"><code>SYSTEM-ID</code></em>. The corresponding entry will be
+                    output to the command line.
+                </p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
+                    list of catalogs. Use percent-encoding to escape spaces or other characters.
+                    An empty variable should deactivate loading the default catalog from
+                    <code class="filename">/etc/xml/catalog</code> or, more specifically,
+                    <code class="filename">${sysconfdir}/xml/catalog</code>.
+                </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
+        <span class="command"><strong>xmlcatalog</strong></span> return codes provide information that can be used when
+        calling it from scripts.
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Failed to remove an entry from the catalog</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Failed to save to the catalog, check file permissions</p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Failed to add an entry to the catalog</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Failed to look up an entry in the catalog</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
+    </p><p>
+        More information can be found at
+        </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
+                </p></li><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> catalog support web page
+                    at <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support" target="_top">https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support</a>
+                </p></li><li class="listitem"><p>James Clark's <acronym class="acronym">SGML</acronym> catalog
+                    page <a class="ulink" href="http://www.jclark.com/sp/catalog.htm" target="_top">http://www.jclark.com/sp/catalog.htm</a>
+                </p></li><li class="listitem"><p><acronym class="acronym">OASIS</acronym> <acronym class="acronym">XML</acronym> catalog specification
+                    <a class="ulink" href="http://www.oasis-open.org/committees/entity/spec.html" target="_top">http://www.oasis-open.org/committees/entity/spec.html</a>
+                </p></li></ul></div><p>
+    </p></div></div></body></html>
index 5d94b3b..bd3f682 100644 (file)
 <refentry>
 
 <refentryinfo>
-       <title>xmlcatalog Manual</title>
-       <productname>libxml2</productname>
-       <copyright>
-               <year>2001</year>
-               <year>2004</year>
-       </copyright>
-       <author>
-               <firstname>John</firstname>
-               <surname>Fleck</surname>
-               <affiliation>
-                       <address>
-                               <email>jfleck@inkstain.net</email>
-                       </address>
-               </affiliation>
-       </author>
-       <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
-       <!-- <releaseinfo>This is release 0.3 of the xmlcatalog Manual.</releaseinfo> -->
-       <!-- <edition>0.3</edition> -->
+    <title>xmlcatalog Manual</title>
+    <productname>libxml2</productname>
+    <copyright>
+        <year>2001</year>
+        <year>2004</year>
+    </copyright>
+    <author>
+        <firstname>John</firstname>
+        <surname>Fleck</surname>
+        <affiliation>
+            <address>
+                <email>jfleck@inkstain.net</email>
+            </address>
+        </affiliation>
+    </author>
+    <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
+    <!-- <releaseinfo>This is release 0.3 of the xmlcatalog Manual.</releaseinfo> -->
+    <!-- <edition>0.3</edition> -->
 </refentryinfo>
 
 <refmeta>
-       <refentrytitle>xmlcatalog</refentrytitle>
-       <manvolnum>1</manvolnum>
+    <refentrytitle>xmlcatalog</refentrytitle>
+    <manvolnum>1</manvolnum>
 </refmeta>
 
 <refnamediv>
-       <refname>xmlcatalog</refname>
-       <refpurpose>
-               Command line tool to parse and manipulate <acronym>XML</acronym>
-               or <acronym>SGML</acronym> catalog files.
-       </refpurpose>
+    <refname>xmlcatalog</refname>
+    <refpurpose>
+        Command line tool to parse and manipulate <acronym>XML</acronym>
+        or <acronym>SGML</acronym> catalog files.
+    </refpurpose>
 </refnamediv>
 
 <refsynopsisdiv>
-       <cmdsynopsis>
-       <command>xmlcatalog</command>
-       <group choice="opt">
-               <arg choice="plain"><option>--sgml</option></arg>
-               <arg choice="plain"><option>--shell</option></arg>
-               <arg choice="plain"><option>--create</option></arg>
-               <arg choice="plain"><option>--del <replaceable>VALUE(S)</replaceable></option></arg>
-               <arg choice="plain">
-                       <group choice="opt">
-                               <arg choice="plain">
-                                       <option>--add
-                                        <replaceable>TYPE</replaceable>
-                                        <replaceable>ORIG</replaceable>
-                                        <replaceable>REPLACE</replaceable>
-                                       </option>
-                               </arg>
-                               <arg choice="plain"><option>--add <replaceable>FILENAME</replaceable></option></arg>
-                       </group>                
-               </arg>
-               <arg choice="plain"><option>--noout</option></arg>
-               <arg choice="plain"><option>--no-super-update</option></arg>
-               <arg choice="plain">
-                       <group choice="opt">
-                               <arg choice="plain"><option>-v</option></arg>
-                               <arg choice="plain"><option>--verbose</option></arg>
-                       </group>
-               </arg>
-       </group>
-       <arg choice="req" rep="norepeat"><replaceable>CATALOGFILE</replaceable></arg>
-       <arg choice="req" rep="repeat"><replaceable>ENTITIES</replaceable></arg>
-       </cmdsynopsis>
+    <cmdsynopsis>
+    <command>xmlcatalog</command>
+    <group choice="opt">
+        <arg choice="plain"><option>--sgml</option></arg>
+        <arg choice="plain"><option>--shell</option></arg>
+        <arg choice="plain"><option>--convert</option></arg>
+        <arg choice="plain"><option>--create</option></arg>
+        <arg choice="plain"><option>--del <replaceable>VALUE(S)</replaceable></option></arg>
+        <arg choice="plain">
+            <group choice="opt">
+                <arg choice="plain">
+                    <option>--add
+                     <replaceable>TYPE</replaceable>
+                     <replaceable>ORIG</replaceable>
+                     <replaceable>REPLACE</replaceable>
+                    </option>
+                </arg>
+                <arg choice="plain"><option>--add <replaceable>FILENAME</replaceable></option></arg>
+            </group>
+        </arg>
+        <arg choice="plain"><option>--noout</option></arg>
+        <arg choice="plain"><option>--no-super-update</option></arg>
+        <arg choice="plain">
+            <group choice="opt">
+                <arg choice="plain"><option>-v</option></arg>
+                <arg choice="plain"><option>--verbose</option></arg>
+            </group>
+        </arg>
+    </group>
+    <arg choice="req" rep="norepeat"><replaceable>CATALOGFILE</replaceable></arg>
+    <arg choice="req" rep="repeat"><replaceable>ENTITIES</replaceable></arg>
+    </cmdsynopsis>
 </refsynopsisdiv>
 
 <refsect1 id="description">
-       <title>DESCRIPTION</title>
-       <para>
-               &xmlcatalog; is a command line application allowing users to monitor and
-               manipulate <acronym>XML</acronym> and <acronym>SGML</acronym> catalogs. It
-               is included in <citerefentry>
-                       <refentrytitle>libxml</refentrytitle>
-                       <manvolnum>3</manvolnum>
-               </citerefentry>.
-       </para>
-       <para>
-               Its functions can be invoked from a single command from the command line,
-               or it can perform multiple functions in interactive mode. It can operate
-               on both <acronym>XML</acronym> and <acronym>SGML</acronym> files.
-       </para>
+    <title>DESCRIPTION</title>
+    <para>
+        &xmlcatalog; is a command line application allowing users to monitor and
+        manipulate <acronym>XML</acronym> and <acronym>SGML</acronym> catalogs. It
+        is included in <citerefentry>
+            <refentrytitle>libxml</refentrytitle>
+            <manvolnum>3</manvolnum>
+        </citerefentry>.
+    </para>
+    <para>
+        Its functions can be invoked from a single command from the command line,
+        or it can perform multiple functions in interactive mode. It can operate
+        on both <acronym>XML</acronym> and <acronym>SGML</acronym> files.
+    </para>
 </refsect1>
 
 <refsect1 id="options">
-       <title>OPTIONS</title>
-       <para>
-               &xmlcatalog; accepts the following options (in alphabetical order):
-       </para>
-       
-       <variablelist>
-
-               <varlistentry>
-       <term>
-               <option>--add
-                <replaceable>TYPE</replaceable>
-                <replaceable>ORIG</replaceable>
-                <replaceable>REPLACE</replaceable>
-               </option>
-       </term>
-       <listitem>
-               <para>
-                       Add an entry to <filename>CATALOGFILE</filename>. <replaceable>TYPE</replaceable>
-                       indicates the type of entry. Possible types are: <simplelist type="inline">
-                               <member><parameter>public</parameter></member>
-                               <member><parameter>system</parameter></member>
-                               <member><parameter>uri</parameter></member>
-                               <member><parameter>rewriteSystem</parameter></member>
-                               <member><parameter>rewriteURI</parameter></member>
-                               <member><parameter>delegatePublic</parameter></member>
-                               <member><parameter>delegateSystem</parameter></member>
-                               <member><parameter>delegateURI</parameter></member>
-                               <member><parameter>nextCatalog</parameter></member>
-                       </simplelist>. <replaceable>ORIG</replaceable> is the original
-                       reference to be replaced, and <replaceable>REPLACE</replaceable>
-                       is the <acronym>URI</acronym> of the replacement entity to be
-                       used. The <option>--add</option> option will not overwrite
-                       <filename>CATALOGFILE</filename>, outputting
-                       to <filename class="devicefile">stdout</filename>, unless
-                       <option>--noout</option> is used. The <option>--add</option> will
-                       always take three parameters even if some of the <acronym>XML</acronym>
-                       catalog constructs will have only a single argument.
-               </para>
-               <!--
-                       FIXME - Is my list of possible types correct? Are SGML types the same?
-               -->
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--add <replaceable>FILENAME</replaceable></option></term>
-       <listitem>
-               <para>
-                       If the <option>--add</option> option is used following
-                       the <option>--sgml</option> option, only a single argument,
-                       a <replaceable>FILENAME</replaceable>, is used. This is used to add
-                       the name of a catalog file to an <acronym>SGML</acronym> supercatalog,
-                       a file that contains references to other included <acronym>SGML</acronym>
-                       catalog files.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--create</option></term>
-       <listitem>
-               <para>
-                       Create a new <acronym>XML</acronym> catalog. Outputs
-                       to <filename class="devicefile">stdout</filename>,
-                       ignoring <replaceable>filename</replaceable> unless <option>--noout</option> is
-                       used, in which case it creates a new catalog
-                       file <replaceable>filename</replaceable>.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--del <replaceable>VALUE(S)</replaceable></option></term>
-       <listitem>
-               <para>
-                       Remove entries from <replaceable>CATALOGFILE</replaceable>
-                       matching <replaceable>VALUE(S)</replaceable>. The <option>--del</option>
-                       option will not overwrite <replaceable>CATALOGFILE</replaceable>,
-                       outputting to <filename class="devicefile">stdout</filename>,
-                       unless <option>--noout</option> is used.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>--noout</option></term>
-       <listitem>
-               <para>
-                       Save output to the named file rather than outputting
-                       to <filename class="devicefile">stdout</filename>.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>--no-super-update</option></term>
-       <listitem>
-               <para>
-                       Do not update the <acronym>SGML</acronym> super catalog.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>--shell</option></term>
-       <listitem>
-               <para>
-                       Run a shell allowing interactive queries on catalog
-                       file <replaceable>CATALOGFILE</replaceable>. For the set of available
-                       commands see <xref linkend="shell"/>.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>--sgml</option></term>
-       <listitem>
-               <para>
-                       Uses <acronym>SGML</acronym> super catalogs for <option>--add</option>
-                       and <option>--del</option> options.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>-v</option></term>
-       <term><option>--verbose</option></term>
-       <listitem>
-               <para>Output debugging information.</para>
-       </listitem>
-               </varlistentry>
-       
-       </variablelist>
-
-       <para>
-               Invoking &xmlcatalog; non-interactively without a designated action
-               (imposed with options like <option>--add</option>) will result in a lookup
-               of the catalog entry for <replaceable>ENTITIES</replaceable> in the
-               catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
-               corresponding entries will be output to the command line. This mode of
-               operation, together with <option>--shell</option> mode and non-modifying
-               (i.e. without <option>--noout</option>) direct actions, allows for
-               a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
-               specification (possibly expressed as &quot;&quot; in the shell
-               environment) appointing the default system catalog. That simplifies the
-               handling when its exact location is irrelevant but the respective built-in
-               still needs to be consulted.
-       </para>
+    <title>OPTIONS</title>
+    <para>
+        &xmlcatalog; accepts the following options (in alphabetical order):
+    </para>
+
+    <variablelist>
+
+        <varlistentry>
+            <term>
+                <option>--add
+                 <replaceable>TYPE</replaceable>
+                 <replaceable>ORIG</replaceable>
+                 <replaceable>REPLACE</replaceable>
+                </option>
+            </term>
+            <listitem>
+                <para>
+                    Add an entry to <filename>CATALOGFILE</filename>. <replaceable>TYPE</replaceable>
+                    indicates the type of entry. Possible types are: <simplelist type="inline">
+                        <member><parameter>public</parameter></member>
+                        <member><parameter>system</parameter></member>
+                        <member><parameter>uri</parameter></member>
+                        <member><parameter>rewriteSystem</parameter></member>
+                        <member><parameter>rewriteURI</parameter></member>
+                        <member><parameter>delegatePublic</parameter></member>
+                        <member><parameter>delegateSystem</parameter></member>
+                        <member><parameter>delegateURI</parameter></member>
+                        <member><parameter>nextCatalog</parameter></member>
+                    </simplelist>. <replaceable>ORIG</replaceable> is the original
+                    reference to be replaced, and <replaceable>REPLACE</replaceable>
+                    is the <acronym>URI</acronym> of the replacement entity to be
+                    used. The <option>--add</option> option will not overwrite
+                    <filename>CATALOGFILE</filename>, outputting
+                    to <filename class="devicefile">stdout</filename>, unless
+                    <option>--noout</option> is used. The <option>--add</option> will
+                    always take three parameters even if some of the <acronym>XML</acronym>
+                    catalog constructs will have only a single argument.
+                </para>
+                <!--
+                    FIXME - Is my list of possible types correct? Are SGML types the same?
+                -->
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--add <replaceable>FILENAME</replaceable></option></term>
+            <listitem>
+                <para>
+                    If the <option>--add</option> option is used following
+                    the <option>--sgml</option> option, only a single argument,
+                    a <replaceable>FILENAME</replaceable>, is used. This is used to add
+                    the name of a catalog file to an <acronym>SGML</acronym> supercatalog,
+                    a file that contains references to other included <acronym>SGML</acronym>
+                    catalog files.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--convert</option></term>
+            <listitem>
+                <para>
+                    Convert SGML catalog to XML.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--create</option></term>
+            <listitem>
+                <para>
+                    Create a new <acronym>XML</acronym> catalog. Outputs
+                    to <filename class="devicefile">stdout</filename>,
+                    ignoring <replaceable>filename</replaceable> unless <option>--noout</option> is
+                    used, in which case it creates a new catalog
+                    file <replaceable>filename</replaceable>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--del <replaceable>VALUE(S)</replaceable></option></term>
+            <listitem>
+                <para>
+                    Remove entries from <replaceable>CATALOGFILE</replaceable>
+                    matching <replaceable>VALUE(S)</replaceable>. The <option>--del</option>
+                    option will not overwrite <replaceable>CATALOGFILE</replaceable>,
+                    outputting to <filename class="devicefile">stdout</filename>,
+                    unless <option>--noout</option> is used.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--noout</option></term>
+            <listitem>
+                <para>
+                    Save output to the named file rather than outputting
+                    to <filename class="devicefile">stdout</filename>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--no-super-update</option></term>
+            <listitem>
+                <para>
+                    Do not update the <acronym>SGML</acronym> super catalog.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--shell</option></term>
+            <listitem>
+                <para>
+                    Run a shell allowing interactive queries on catalog
+                    file <replaceable>CATALOGFILE</replaceable>. For the set of available
+                    commands see <xref linkend="shell"/>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--sgml</option></term>
+            <listitem>
+                <para>
+                    Uses <acronym>SGML</acronym> super catalogs for <option>--add</option>
+                    and <option>--del</option> options.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>-v</option></term>
+            <term><option>--verbose</option></term>
+            <listitem>
+                <para>Output debugging information.</para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
+
+    <para>
+        Invoking &xmlcatalog; non-interactively without a designated action
+        (imposed with options like <option>--add</option>) will result in a lookup
+        of the catalog entry for <replaceable>ENTITIES</replaceable> in the
+        catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
+        corresponding entries will be output to the command line. This mode of
+        operation, together with <option>--shell</option> mode and non-modifying
+        (i.e. without <option>--noout</option>) direct actions, allows for
+        a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
+        specification (possibly expressed as &quot;&quot; in the shell
+        environment) appointing the default system catalog. That simplifies the
+        handling when its exact location is irrelevant but the respective built-in
+        still needs to be consulted.
+    </para>
 </refsect1>
 
 <refsect1 id="shell">
-       <title>SHELL COMMANDS</title>
-       <para>
-               Invoking &xmlcatalog; with
-               the <option>--shell <replaceable>CATALOGFILE</replaceable></option> option opens
-               a command line shell allowing interactive access to the catalog file
-               identified by <replaceable>CATALOGFILE</replaceable>. Invoking the shell
-               provides a command line prompt after which the following commands (described in
-               alphabetical order) can be entered.
-       </para>
-       
-       <variablelist>
-
-               <varlistentry>
-       <term>
-               <option>add
-                <replaceable>TYPE</replaceable>
-                <replaceable>ORIG</replaceable>
-                <replaceable>REPLACE</replaceable>
-               </option>
-       </term>
-       <listitem>
-               <para>
-                       Add an entry to the catalog file. <replaceable>TYPE</replaceable>
-                       indicates the type of entry. Possible types are: <simplelist type="inline">
-                               <member><parameter>public</parameter></member>
-                               <member><parameter>system</parameter></member>
-                               <member><parameter>uri</parameter></member>
-                               <member><parameter>rewriteSystem</parameter></member>
-                               <member><parameter>rewriteURI</parameter></member>
-                               <member><parameter>delegatePublic</parameter></member>
-                               <member><parameter>delegateSystem</parameter></member>
-                               <member><parameter>delegateURI</parameter></member>
-                               <member><parameter>nextCatalog</parameter></member>
-                       </simplelist>. <replaceable>ORIG</replaceable> is the original
-                       reference to be replaced, and <replaceable>REPLACE</replaceable>
-                       is the <acronym>URI</acronym> of the replacement entity to be
-                       used. The <option>--add</option> option will not overwrite
-                       <filename>CATALOGFILE</filename>, outputting
-                       to <filename class="devicefile">stdout</filename>, unless
-                       <option>--noout</option> is used. The <option>--add</option> will
-                       always take three parameters even if some of the <acronym>XML</acronym>
-                       catalog constructs will have only a single argument.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>debug</option></term>
-       <listitem>
-               <para>
-                       Print debugging statements showing the steps &xmlcatalog; is executing.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>del <replaceable>VALUE(S)</replaceable></option></term>
-       <listitem>
-               <para>
-                       Remove the catalog entry corresponding to <replaceable>VALUE(S)</replaceable>.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>dump</option></term>
-       <listitem>
-               <para>Print the current catalog.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>exit</option></term>
-       <listitem>
-               <para>Quit the shell.</para>
-       </listitem>
-               </varlistentry>
-       
-               <varlistentry>
-       <term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
-       <listitem>
-               <para>
-                       Execute a Formal Public Identifier lookup of the catalog entry
-                       for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
-                       output to the command line.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>quiet</option></term>
-       <listitem>
-               <para>Stop printing debugging statements.</para>
-       </listitem>
-               </varlistentry>
-               
-               <varlistentry>
-       <term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
-       <listitem>
-               <para>
-                       Execute a Formal Public Identifier lookup of the catalog entry
-                       for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
-                       output to the command line.
-               </para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist>
+    <title>SHELL COMMANDS</title>
+    <para>
+        Invoking &xmlcatalog; with
+        the <option>--shell <replaceable>CATALOGFILE</replaceable></option> option opens
+        a command line shell allowing interactive access to the catalog file
+        identified by <replaceable>CATALOGFILE</replaceable>. Invoking the shell
+        provides a command line prompt after which the following commands (described in
+        alphabetical order) can be entered.
+    </para>
+
+    <variablelist>
+
+        <varlistentry>
+            <term>
+                <option>add
+                 <replaceable>TYPE</replaceable>
+                 <replaceable>ORIG</replaceable>
+                 <replaceable>REPLACE</replaceable>
+                </option>
+            </term>
+            <listitem>
+                <para>
+                    Add an entry to the catalog file. <replaceable>TYPE</replaceable>
+                    indicates the type of entry. Possible types are: <simplelist type="inline">
+                        <member><parameter>public</parameter></member>
+                        <member><parameter>system</parameter></member>
+                        <member><parameter>uri</parameter></member>
+                        <member><parameter>rewriteSystem</parameter></member>
+                        <member><parameter>rewriteURI</parameter></member>
+                        <member><parameter>delegatePublic</parameter></member>
+                        <member><parameter>delegateSystem</parameter></member>
+                        <member><parameter>delegateURI</parameter></member>
+                        <member><parameter>nextCatalog</parameter></member>
+                    </simplelist>. <replaceable>ORIG</replaceable> is the original
+                    reference to be replaced, and <replaceable>REPLACE</replaceable>
+                    is the <acronym>URI</acronym> of the replacement entity to be
+                    used. The <option>--add</option> option will not overwrite
+                    <filename>CATALOGFILE</filename>, outputting
+                    to <filename class="devicefile">stdout</filename>, unless
+                    <option>--noout</option> is used. The <option>--add</option> will
+                    always take three parameters even if some of the <acronym>XML</acronym>
+                    catalog constructs will have only a single argument.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>debug</option></term>
+            <listitem>
+                <para>
+                    Print debugging statements showing the steps &xmlcatalog; is executing.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>del <replaceable>VALUE(S)</replaceable></option></term>
+            <listitem>
+                <para>
+                    Remove the catalog entry corresponding to <replaceable>VALUE(S)</replaceable>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>dump</option></term>
+            <listitem>
+                <para>Print the current catalog.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>exit</option></term>
+            <listitem>
+                <para>Quit the shell.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
+            <listitem>
+                <para>
+                    Execute a Formal Public Identifier lookup of the catalog entry
+                    for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
+                    output to the command line.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>quiet</option></term>
+            <listitem>
+                <para>Stop printing debugging statements.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
+            <listitem>
+                <para>
+                    Execute a Formal Public Identifier lookup of the catalog entry
+                    for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
+                    output to the command line.
+                </para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="environment">
-       <title>ENVIRONMENT</title>
-       <variablelist>
-
-               <varlistentry>
-       <term><envar>XML_CATALOG_FILES</envar></term>
-       <listitem>
-               <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
-                       list of catalogs. Use percent-encoding to escape spaces or other characters.
-                       An empty variable should deactivate loading the default <filename>/etc/xml/catalog</filename> catalog.
-               </para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist> 
+    <title>ENVIRONMENT</title>
+    <variablelist>
+
+        <varlistentry>
+            <term><envar>XML_CATALOG_FILES</envar></term>
+            <listitem>
+                <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
+                    list of catalogs. Use percent-encoding to escape spaces or other characters.
+                    An empty variable should deactivate loading the default catalog from
+                    <filename>/etc/xml/catalog</filename> or, more specifically,
+                    <filename>${sysconfdir}/xml/catalog</filename>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="diagnostics">
-       <title>DIAGNOSTICS</title>
-       <para>
-               &xmlcatalog; return codes provide information that can be used when
-               calling it from scripts.
-       </para>
-       <variablelist>
-
-               <varlistentry>
-       <term><errorcode>0</errorcode></term>
-       <listitem>
-               <para>No error</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>1</errorcode></term>
-       <listitem>
-               <para>Failed to remove an entry from the catalog</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>2</errorcode></term>
-       <listitem>
-               <para>Failed to save to the catalog, check file permissions</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>3</errorcode></term>
-       <listitem>
-               <para>Failed to add an entry to the catalog</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>4</errorcode></term>
-       <listitem>
-               <para>Failed to look up an entry in the catalog</para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist>
+    <title>DIAGNOSTICS</title>
+    <para>
+        &xmlcatalog; return codes provide information that can be used when
+        calling it from scripts.
+    </para>
+    <variablelist>
+
+        <varlistentry>
+            <term><errorcode>0</errorcode></term>
+            <listitem>
+                <para>No error</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>1</errorcode></term>
+            <listitem>
+                <para>Failed to remove an entry from the catalog</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>2</errorcode></term>
+            <listitem>
+                <para>Failed to save to the catalog, check file permissions</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>3</errorcode></term>
+            <listitem>
+                <para>Failed to add an entry to the catalog</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>4</errorcode></term>
+            <listitem>
+                <para>Failed to look up an entry in the catalog</para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="seealso">
-       <title>SEE ALSO</title>
-       <para><citerefentry>
-                       <refentrytitle>libxml</refentrytitle>
-                       <manvolnum>3</manvolnum>
-               </citerefentry>
-       </para>
-       <para>
-               More information can be found at
-               <itemizedlist>
-                       <listitem>
-                               <para><citerefentry>
-                                               <refentrytitle>libxml</refentrytitle>
-                                               <manvolnum>3</manvolnum>
-                                       </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
-                               </para>
-                       </listitem>
-                       <listitem>
-                               <para><citerefentry>
-                                               <refentrytitle>libxml</refentrytitle>
-                                               <manvolnum>3</manvolnum>
-                                       </citerefentry> catalog support web page
-                                       at <ulink url="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support"/>
-                               </para>
-                       </listitem>
-                       <listitem>
-                               <para>James Clark's <acronym>SGML</acronym> catalog
-                                       page <ulink url="http://www.jclark.com/sp/catalog.htm"/>
-                               </para>
-                       </listitem>
-                       <listitem>
-                               <para><acronym>OASIS</acronym> <acronym>XML</acronym> catalog specification
-                                       <ulink url="http://www.oasis-open.org/committees/entity/spec.html"/>
-                               </para>
-                       </listitem>
-               </itemizedlist>
-       </para>
+    <title>SEE ALSO</title>
+    <para><citerefentry>
+            <refentrytitle>libxml</refentrytitle>
+            <manvolnum>3</manvolnum>
+        </citerefentry>
+    </para>
+    <para>
+        More information can be found at
+        <itemizedlist>
+            <listitem>
+                <para><citerefentry>
+                        <refentrytitle>libxml</refentrytitle>
+                        <manvolnum>3</manvolnum>
+                    </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
+                </para>
+            </listitem>
+            <listitem>
+                <para><citerefentry>
+                        <refentrytitle>libxml</refentrytitle>
+                        <manvolnum>3</manvolnum>
+                    </citerefentry> catalog support web page
+                    at <ulink url="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support"/>
+                </para>
+            </listitem>
+            <listitem>
+                <para>James Clark's <acronym>SGML</acronym> catalog
+                    page <ulink url="http://www.jclark.com/sp/catalog.htm"/>
+                </para>
+            </listitem>
+            <listitem>
+                <para><acronym>OASIS</acronym> <acronym>XML</acronym> catalog specification
+                    <ulink url="http://www.oasis-open.org/committees/entity/spec.html"/>
+                </para>
+            </listitem>
+        </itemizedlist>
+    </para>
 </refsect1>
 
 </refentry>
index 512dfd6..538bf4b 100644 (file)
@@ -1,13 +1,13 @@
 '\" t
 .\"     Title: xmllint
 .\"    Author: John Fleck <jfleck@inkstain.net>
-.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 08/17/2022
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
+.\"      Date: 11/04/2023
 .\"    Manual: xmllint Manual
 .\"    Source: libxml2
 .\"  Language: English
 .\"
-.TH "XMLLINT" "1" "08/17/2022" "libxml2" "xmllint Manual"
+.TH "XMLLINT" "1" "11/04/2023" "libxml2" "xmllint Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
 xmllint \- command line XML tool
 .SH "SYNOPSIS"
 .HP \w'\fBxmllint\fR\ 'u
-\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR] {\fIXML\-FILE(S)\fR... | \-}
+\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-quiet\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-nodict\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-max\-ampl\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR | \fB\-\-pedantic\fR] {\fIXML\-FILE(S)\fR... | \-}
 .HP \w'\fBxmllint\fR\ 'u
 \fBxmllint\fR \fB\-\-help\fR
 .SH "DESCRIPTION"
@@ -72,6 +72,8 @@ catalog(s) from
 XML
 catalogs starting from
 /etc/xml/catalog
+or, more specifically,
+${sysconfdir}/xml/catalog
 are used by default\&.
 .RE
 .PP
@@ -197,6 +199,11 @@ Display all the documents loaded during the processing to
 stderr\&.
 .RE
 .PP
+\fB\-\-max\-ampl \fR\fB\fIINTEGER\fR\fR
+.RS 4
+Set the maximum amplification factor which protects against exponential entity expansion ("billion laughs")\&. The default value is 5\&. Documents making heavy use of entity expansion may require a higher value\&.
+.RE
+.PP
 \fB\-\-maxmem \fR\fB\fINNBYTES\fR\fR
 .RS 4
 Test the parser memory support\&.
@@ -226,6 +233,11 @@ Do not use any catalogs\&.
 Substitute CDATA section by equivalent text nodes\&.
 .RE
 .PP
+\fB\-\-nodict\fR
+.RS 4
+Don\*(Aqt use dictionaries (parser option XML_PARSE_NODICT)\&. Only for debugging\&.
+.RE
+.PP
 \fB\-\-noent\fR
 .RS 4
 Substitute entity values for entity references\&. By default,
@@ -291,6 +303,11 @@ DTDs or entities\&. Enclose space\-separated lists by quotation marks\&.
 Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser\&. It allows to select some nodes in the document based on an XPath (subset) expression\&. Used for debugging\&.
 .RE
 .PP
+\fB\-\-pedantic\fR
+.RS 4
+Enable additional warnings\&.
+.RE
+.PP
 \fB\-\-postvalid\fR
 .RS 4
 Validate after parsing has completed\&.
@@ -301,6 +318,11 @@ Validate after parsing has completed\&.
 Use the push mode of the parser\&.
 .RE
 .PP
+\fB\-\-quiet\fR
+.RS 4
+Don\*(Aqt print informational messages to stderr\&.
+.RE
+.PP
 \fB\-\-recover\fR
 .RS 4
 Output any parsable portions of an invalid document\&.
@@ -501,9 +523,7 @@ Write the current node to the given filename\&.
 SGML
 catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
 \fBSGML_CATALOG_FILES\fR
-environment variable to a list of catalogs\&. An empty one should deactivate loading the default
-/etc/sgml/catalog
-catalog\&.
+environment variable to a list of catalogs\&. An empty one should deactivate loading the default catalog\&.
 .RE
 .PP
 \fBXML_CATALOG_FILES\fR
@@ -511,9 +531,7 @@ catalog\&.
 XML
 catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
 \fBXML_CATALOG_FILES\fR
-environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default
-/etc/xml/catalog
-catalog\&.
+environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog\&.
 .RE
 .PP
 \fBXML_DEBUG_CATALOG\fR
index 8d4400f..e128c39 100644 (file)
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code>  [ <code class="option">--version</code>  |   <code class="option">--debug</code>  |   <code class="option">--shell</code>  |   <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code>  |   <code class="option">--debugent</code>  |   <code class="option">--copy</code>  |   <code class="option">--recover</code>  |   <code class="option">--noent</code>  |   <code class="option">--noout</code>  |   <code class="option">--nonet</code>  |   <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code>  |   <code class="option">--load-trace</code>  |   <code class="option">--htmlout</code>  |   <code class="option">--nowrap</code>  |   <code class="option">--valid</code>  |   <code class="option">--postvalid</code>  |   <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code>  |   <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code>  |   <code class="option">--timing</code>  |   <code class="option">--output <em class="replaceable"><code>FILE</code></em></code>  |   <code class="option">--repeat</code>  |   <code class="option">--insert</code>  |   <code class="option">--compress</code>  |   <code class="option">--html</code>  |   <code class="option">--xmlout</code>  |   <code class="option">--push</code>  |   <code class="option">--memory</code>  |   <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code>  |   <code class="option">--nowarning</code>  |   <code class="option">--noblanks</code>  |   <code class="option">--nocdata</code>  |   <code class="option">--format</code>  |   <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code>  |   <code class="option">--dropdtd</code>  |   <code class="option">--nsclean</code>  |   <code class="option">--testIO</code>  |   <code class="option">--catalogs</code>  |   <code class="option">--nocatalogs</code>  |   <code class="option">--auto</code>  |   <code class="option">--xinclude</code>  |   <code class="option">--noxincludenode</code>  |   <code class="option">--loaddtd</code>  |   <code class="option">--dtdattr</code>  |   <code class="option">--stream</code>  |   <code class="option">--walker</code>  |   <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code>  |   <code class="option">--chkregister</code>  |   <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--c14n</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>...  |   - }</p></div><div class="cmdsynopsis"><p><code class="command">xmllint</code>   <code class="option">--help</code> </p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
-               The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
-               specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
-               (or the standard input if the filename provided
-               is <span class="bold"><strong>-</strong></span> ). It prints various types of
-               output, depending upon the options selected. It is useful for detecting
-               errors both in <acronym class="acronym">XML</acronym> code and in
-               the <acronym class="acronym">XML</acronym> parser itself.
-       </p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
-               <span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
-                       Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
-                       Otherwise <acronym class="acronym">XML</acronym> catalogs starting
-                       from <code class="filename">/etc/xml/catalog</code> are used by default.
-               </p></dd><dt><span class="term"><code class="option">--chkregister</code></span></dt><dd><p>
-                       Turn on node registration. Useful for developers testing <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> node tracking code.
-               </p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
-                       Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
-               </p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code></span></dt><dd><p>
-                       Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
-                       serialize the result of parsing to <code class="filename">stdout</code>.
-                       It keeps comments in the result.
-               </p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
-                       Use the <acronym class="acronym">DTD</acronym> specified by
-                       an <em class="replaceable"><code>URL</code></em> for validation.
-               </p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
-                       Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
-                       Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
-                       will require a catalog exporting that Formal Public Identifier to work.
-               </p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
-                       Parse a file and output an annotated tree of the
-                       in-memory version of the document.
-               </p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
-                       Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
-                       inherited attributes.
-               </p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
-                       Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
-                       environment variable controls the indentation. The default value is two
-                       spaces "  ").
-               </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd><p>Print out a short usage summary for <span class="command"><strong>xmllint</strong></span>.</p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
-                       Output results as an <acronym class="acronym">HTML</acronym> file. This
-                       causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
-                       tags surrounding the result tree output so the results can be
-                       displayed/viewed in a browser.
-               </p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
-                       Display all the documents loaded during the processing
-                       to <code class="filename">stderr</code>.
-               </p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
-                       Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
-                       is the maximum number of bytes the library is allowed to allocate.
-                       This can also be used to make sure batch processing
-                       of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
-                       of the server running them.
-               </p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
-                       Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
-                       leaves entity references in place.
-               </p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
-                       Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
-               </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
-                       Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
-               </p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
-                       Do XInclude processing but do not generate XInclude start and end nodes.
-               </p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
-                       Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
-                       Usually the programs build a tree and save it
-                       on <code class="filename">stdout</code>, with this option
-                       the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
-               </p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
-                       Use the (space- or colon-separated) list of filesystem paths specified
-                       by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
-                       entities. Enclose space-separated lists by quotation marks.
-               </p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
-                       Used to exercise the pattern recognition engine, which can be used
-                       with the reader interface to the parser. It allows to select some
-                       nodes in the document based on an XPath (subset) expression. Used
-                       for debugging.
-               </p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
-                       Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
-                       for validation.
-               </p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
-                       Use a W3C <acronym class="acronym">XML</acronym> Schema file
-                       named <em class="replaceable"><code>SCHEMA</code></em> for validation.
-               </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
-                       Run a navigating shell. Details on available commands in shell mode
-                       are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>).
-               </p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
-                       Run an XPath expression given as argument and print the
-                       result. In case of a nodeset result, each node in the
-                       node set is serialized in full in the output. In case
-                       of an empty node set the "XPath set is empty" result
-                       will be shown and an error exit code will be returned.
-               </p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
-                       Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
-                       with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
-                       for validation of files that are too large to be held in memory.
-               </p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
-                       Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
-                       various steps.
-               </p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
-                       Determine if the document is a valid instance of the included
-                       Document Type Definition (<acronym class="acronym">DTD</acronym>).
-                       A <acronym class="acronym">DTD</acronym> to be validated against also can be
-                       specified at the command line using the <code class="option">--dtdvalid</code>
-                       option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
-                       document is well-formed.
-               </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
-                       Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
-               </p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
-                       Test the walker module, which is a reader interface but for a
-                       document tree, instead of using the reader <acronym class="acronym">API</acronym> on
-                       an unparsed document it works on an existing in-memory tree. Used for
-                       debugging.
-               </p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
-                       Used in conjunction with <code class="option">--html</code>. Usually
-                       when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
-                       the <acronym class="acronym">HTML</acronym> serializer. But with this option the
-                       resulting document is saved with the <acronym class="acronym">XML</acronym>
-                       serializer. This is primarily used to
-                       generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
-               </p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
-               <span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
-               the <code class="option">--shell</code> command. Available commands in shell mode
-               include (in alphabetical order):
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
-                       Change the current node to the given path (if unique) or root if no
-                       argument is given.
-               </p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
-                       Dumps information about the node (namespace, attributes, content).
-               </p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
-                       Show the structure of the subtree under the given path or the current node.
-               </p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>free</strong></span></span></dt><dd><p>Display memory usage.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
-                       Save the current document to the given filename or to the original name.
-               </p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
-                       of catalogs. An empty one should deactivate loading the
-                       default <code class="filename">/etc/sgml/catalog</code> catalog.
-               </p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
-                       list of catalogs. Use percent-encoding to escape spaces or other characters.
-                       An empty variable should deactivate loading the default <code class="filename">/etc/xml/catalog</code> catalog.
-               </p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
-                       to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
-                       command outputs debugging information related to catalog operations.
-               </p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
-                       controls the indentation. The default value is two spaces "  ".
-               </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
-               <span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
-               calling it from scripts.
-       </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
-                       Error in pattern (generated when <code class="option">--pattern</code> option is used)
-               </p></dd><dt><span class="term"><span class="errorcode">8</span></span></dt><dd><p>
-                       Error in Reader registration (generated
-                       when <code class="option">--chkregister</code> option is used)
-               </p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd><dt><span class="term"><span class="errorcode">10</span></span></dt><dd><p>XPath evaluation error</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
-       </p><p>
-               More information can be found at
-               </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
-                               </p></li></ul></div><p>
-       </p></div></div></body></html>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code>  [ <code class="option">--version</code>  |   <code class="option">--debug</code>  |   <code class="option">--quiet</code>  |   <code class="option">--shell</code>  |   <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code>  |   <code class="option">--debugent</code>  |   <code class="option">--copy</code>  |   <code class="option">--recover</code>  |   <code class="option">--nodict</code>  |   <code class="option">--noent</code>  |   <code class="option">--noout</code>  |   <code class="option">--nonet</code>  |   <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code>  |   <code class="option">--load-trace</code>  |   <code class="option">--htmlout</code>  |   <code class="option">--nowrap</code>  |   <code class="option">--valid</code>  |   <code class="option">--postvalid</code>  |   <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code>  |   <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code>  |   <code class="option">--timing</code>  |   <code class="option">--output <em class="replaceable"><code>FILE</code></em></code>  |   <code class="option">--repeat</code>  |   <code class="option">--insert</code>  |   <code class="option">--compress</code>  |   <code class="option">--html</code>  |   <code class="option">--xmlout</code>  |   <code class="option">--push</code>  |   <code class="option">--memory</code>  |   <code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code>  |   <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code>  |   <code class="option">--nowarning</code>  |   <code class="option">--noblanks</code>  |   <code class="option">--nocdata</code>  |   <code class="option">--format</code>  |   <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code>  |   <code class="option">--dropdtd</code>  |   <code class="option">--nsclean</code>  |   <code class="option">--testIO</code>  |   <code class="option">--catalogs</code>  |   <code class="option">--nocatalogs</code>  |   <code class="option">--auto</code>  |   <code class="option">--xinclude</code>  |   <code class="option">--noxincludenode</code>  |   <code class="option">--loaddtd</code>  |   <code class="option">--dtdattr</code>  |   <code class="option">--stream</code>  |   <code class="option">--walker</code>  |   <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code>  |   <code class="option">--chkregister</code>  |   <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code>  |   <code class="option">--c14n</code>  |   <code class="option">--pedantic</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>...  |   - }</p></div><div class="cmdsynopsis"><p><code class="command">xmllint</code>   <code class="option">--help</code> </p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
+        The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
+        specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
+        (or the standard input if the filename provided
+        is <span class="bold"><strong>-</strong></span> ). It prints various types of
+        output, depending upon the options selected. It is useful for detecting
+        errors both in <acronym class="acronym">XML</acronym> code and in
+        the <acronym class="acronym">XML</acronym> parser itself.
+    </p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
+        <span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
+                    Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
+                    Otherwise <acronym class="acronym">XML</acronym> catalogs starting
+                    from <code class="filename">/etc/xml/catalog</code> or, more specifically,
+                    <code class="filename">${sysconfdir}/xml/catalog</code> are used by default.
+                </p></dd><dt><span class="term"><code class="option">--chkregister</code></span></dt><dd><p>
+                    Turn on node registration. Useful for developers testing <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> node tracking code.
+                </p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
+                    Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
+                </p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code></span></dt><dd><p>
+                    Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
+                    serialize the result of parsing to <code class="filename">stdout</code>.
+                    It keeps comments in the result.
+                </p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
+                    Use the <acronym class="acronym">DTD</acronym> specified by
+                    an <em class="replaceable"><code>URL</code></em> for validation.
+                </p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
+                    Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
+                    Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
+                    will require a catalog exporting that Formal Public Identifier to work.
+                </p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
+                    Parse a file and output an annotated tree of the
+                    in-memory version of the document.
+                </p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
+                    Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
+                    inherited attributes.
+                </p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
+                    Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
+                    environment variable controls the indentation. The default value is two
+                    spaces "  ").
+                </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd><p>Print out a short usage summary for <span class="command"><strong>xmllint</strong></span>.</p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
+                    Output results as an <acronym class="acronym">HTML</acronym> file. This
+                    causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
+                    tags surrounding the result tree output so the results can be
+                    displayed/viewed in a browser.
+                </p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
+                    Display all the documents loaded during the processing
+                    to <code class="filename">stderr</code>.
+                </p></dd><dt><span class="term"><code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code></span></dt><dd><p>
+                    Set the maximum amplification factor which protects against
+                    exponential entity expansion ("billion laughs"). The default value
+                    is 5. Documents making heavy use of entity expansion may require a
+                    higher value.
+                </p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
+                    Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
+                    is the maximum number of bytes the library is allowed to allocate.
+                    This can also be used to make sure batch processing
+                    of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
+                    of the server running them.
+                </p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--nodict</code></span></dt><dd><p>
+                    Don't use dictionaries (parser option XML_PARSE_NODICT).
+                    Only for debugging.
+                </p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
+                    Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
+                    leaves entity references in place.
+                </p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
+                    Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
+                </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
+                    Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
+                </p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
+                    Do XInclude processing but do not generate XInclude start and end nodes.
+                </p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
+                    Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
+                    Usually the programs build a tree and save it
+                    on <code class="filename">stdout</code>, with this option
+                    the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
+                </p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
+                    Use the (space- or colon-separated) list of filesystem paths specified
+                    by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
+                    entities. Enclose space-separated lists by quotation marks.
+                </p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
+                    Used to exercise the pattern recognition engine, which can be used
+                    with the reader interface to the parser. It allows to select some
+                    nodes in the document based on an XPath (subset) expression. Used
+                    for debugging.
+                </p></dd><dt><span class="term"><code class="option">--pedantic</code></span></dt><dd><p>Enable additional warnings.</p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--quiet</code></span></dt><dd><p>Don't print informational messages to stderr.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
+                    Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
+                    for validation.
+                </p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
+                    Use a W3C <acronym class="acronym">XML</acronym> Schema file
+                    named <em class="replaceable"><code>SCHEMA</code></em> for validation.
+                </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
+                    Run a navigating shell. Details on available commands in shell mode
+                    are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>).
+                </p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
+                    Run an XPath expression given as argument and print the
+                    result. In case of a nodeset result, each node in the
+                    node set is serialized in full in the output. In case
+                    of an empty node set the "XPath set is empty" result
+                    will be shown and an error exit code will be returned.
+                </p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
+                    Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
+                    with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
+                    for validation of files that are too large to be held in memory.
+                </p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
+                    Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
+                    various steps.
+                </p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
+                    Determine if the document is a valid instance of the included
+                    Document Type Definition (<acronym class="acronym">DTD</acronym>).
+                    A <acronym class="acronym">DTD</acronym> to be validated against also can be
+                    specified at the command line using the <code class="option">--dtdvalid</code>
+                    option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
+                    document is well-formed.
+                </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
+                    Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
+                </p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
+                    Test the walker module, which is a reader interface but for a
+                    document tree, instead of using the reader <acronym class="acronym">API</acronym> on
+                    an unparsed document it works on an existing in-memory tree. Used for
+                    debugging.
+                </p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
+                    Used in conjunction with <code class="option">--html</code>. Usually
+                    when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
+                    the <acronym class="acronym">HTML</acronym> serializer. But with this option the
+                    resulting document is saved with the <acronym class="acronym">XML</acronym>
+                    serializer. This is primarily used to
+                    generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
+                </p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
+        <span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
+        the <code class="option">--shell</code> command. Available commands in shell mode
+        include (in alphabetical order):
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+                    Change the current node to the given path (if unique) or root if no
+                    argument is given.
+                </p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+                    Dumps information about the node (namespace, attributes, content).
+                </p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
+                    Show the structure of the subtree under the given path or the current node.
+                </p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>free</strong></span></span></dt><dd><p>Display memory usage.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
+                    Save the current document to the given filename or to the original name.
+                </p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
+                    of catalogs. An empty one should deactivate loading the
+                    default catalog.
+                </p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
+                    list of catalogs. Use percent-encoding to escape spaces or other characters.
+                    An empty variable should deactivate loading the default catalog.
+                </p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
+                    to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
+                    command outputs debugging information related to catalog operations.
+                </p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
+                    controls the indentation. The default value is two spaces "  ".
+                </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
+        <span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
+        calling it from scripts.
+    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
+                    Error in pattern (generated when <code class="option">--pattern</code> option is used)
+                </p></dd><dt><span class="term"><span class="errorcode">8</span></span></dt><dd><p>
+                    Error in Reader registration (generated
+                    when <code class="option">--chkregister</code> option is used)
+                </p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd><dt><span class="term"><span class="errorcode">10</span></span></dt><dd><p>XPath evaluation error</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
+    </p><p>
+        More information can be found at
+        </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
+                </p></li></ul></div><p>
+    </p></div></div></body></html>
index 73b325a..b81da3a 100644 (file)
    href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
     "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
-    
+
     <!ENTITY xmllint "<command>xmllint</command>">
 ]>
 
 <refentry>
 
 <refentryinfo>
-       <title>xmllint Manual</title>
-       <productname>libxml2</productname>
-       <copyright>
-               <year>2001</year>
-               <year>2004</year>
-       </copyright>
-       <authorgroup>
-               <author>
-                       <firstname>John</firstname>
-                       <surname>Fleck</surname>
-                       <affiliation>
-                               <address>
-                                       <email>jfleck@inkstain.net</email>
-                               </address>
-                       </affiliation>
-               </author>
-               <author>
-                       <firstname>Ziying</firstname>
-                       <surname>Sherwin</surname>
-                       <affiliation>
-                               <address>
-                                       <email>sherwin@nlm.nih.gov</email>
-                               </address>
-                       </affiliation>
-               </author>
-               <author>
-                       <firstname>Heiko</firstname>
-                       <surname>Rupp</surname>
-                       <affiliation>
-                               <address>
-                                       <email>hwr@pilhuhn.de</email>
-                               </address>
-                       </affiliation>
-               </author>
-       </authorgroup>
-       <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
-       <!-- <releaseinfo>This is release 0.5 of the xmllint Manual.</releaseinfo> -->
-       <!-- <edition>0.5</edition> -->
+    <title>xmllint Manual</title>
+    <productname>libxml2</productname>
+    <copyright>
+        <year>2001</year>
+        <year>2004</year>
+    </copyright>
+    <authorgroup>
+        <author>
+            <firstname>John</firstname>
+            <surname>Fleck</surname>
+            <affiliation>
+                <address>
+                    <email>jfleck@inkstain.net</email>
+                </address>
+            </affiliation>
+        </author>
+        <author>
+            <firstname>Ziying</firstname>
+            <surname>Sherwin</surname>
+            <affiliation>
+                <address>
+                    <email>sherwin@nlm.nih.gov</email>
+                </address>
+            </affiliation>
+        </author>
+        <author>
+            <firstname>Heiko</firstname>
+            <surname>Rupp</surname>
+            <affiliation>
+                <address>
+                    <email>hwr@pilhuhn.de</email>
+                </address>
+            </affiliation>
+        </author>
+    </authorgroup>
+    <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
+    <!-- <releaseinfo>This is release 0.5 of the xmllint Manual.</releaseinfo> -->
+    <!-- <edition>0.5</edition> -->
 </refentryinfo>
 
 <refmeta>
-       <refentrytitle>xmllint</refentrytitle>
-       <manvolnum>1</manvolnum>
+    <refentrytitle>xmllint</refentrytitle>
+    <manvolnum>1</manvolnum>
 </refmeta>
 
 <refnamediv>
-       <refname>xmllint</refname>
-       <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
+    <refname>xmllint</refname>
+    <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
 </refnamediv>
 
 <refsynopsisdiv>
-       <cmdsynopsis>
-       <command>xmllint</command>
-               <group choice="opt">
-                       <arg choice="plain"><option>--version</option></arg>
-                       <arg choice="plain"><option>--debug</option></arg>
-                       <arg choice="plain"><option>--shell</option></arg>
-                       <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
-                       <arg choice="plain"><option>--debugent</option></arg>
-                       <arg choice="plain"><option>--copy</option></arg>
-                       <arg choice="plain"><option>--recover</option></arg>
-                       <arg choice="plain"><option>--noent</option></arg>
-                       <arg choice="plain"><option>--noout</option></arg>
-                       <arg choice="plain"><option>--nonet</option></arg>
-                       <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
-                       <arg choice="plain"><option>--load-trace</option></arg>
-                       <arg choice="plain"><option>--htmlout</option></arg>
-                       <arg choice="plain"><option>--nowrap</option></arg>
-                       <arg choice="plain"><option>--valid</option></arg>
-                       <arg choice="plain"><option>--postvalid</option></arg>
-                       <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
-                       <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
-                       <arg choice="plain"><option>--timing</option></arg>
-                       <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
-                       <arg choice="plain"><option>--repeat</option></arg>
-                       <arg choice="plain"><option>--insert</option></arg>
-                       <arg choice="plain"><option>--compress</option></arg>
-                       <arg choice="plain"><option>--html</option></arg>
-                       <arg choice="plain"><option>--xmlout</option></arg>
-                       <arg choice="plain"><option>--push</option></arg>
-                       <arg choice="plain"><option>--memory</option></arg>
-                       <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
-                       <arg choice="plain"><option>--nowarning</option></arg>
-                       <arg choice="plain"><option>--noblanks</option></arg>
-                       <arg choice="plain"><option>--nocdata</option></arg>
-                       <arg choice="plain"><option>--format</option></arg>
-                       <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
-                       <arg choice="plain"><option>--dropdtd</option></arg>
-                       <arg choice="plain"><option>--nsclean</option></arg>
-                       <arg choice="plain"><option>--testIO</option></arg>
-                       <arg choice="plain"><option>--catalogs</option></arg>
-                       <arg choice="plain"><option>--nocatalogs</option></arg>
-                       <arg choice="plain"><option>--auto</option></arg>
-                       <arg choice="plain"><option>--xinclude</option></arg>
-                       <arg choice="plain"><option>--noxincludenode</option></arg>
-                       <arg choice="plain"><option>--loaddtd</option></arg>
-                       <arg choice="plain"><option>--dtdattr</option></arg>
-                       <arg choice="plain"><option>--stream</option></arg>
-                       <arg choice="plain"><option>--walker</option></arg>
-                       <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
-                       <arg choice="plain"><option>--chkregister</option></arg>
-                       <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
-                       <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
-                       <arg choice="plain"><option>--c14n</option></arg>
-               </group>
-               <group choice="req">
-                       <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
-                       <arg choice="plain" rep="norepeat">-</arg>
-               </group>
-       </cmdsynopsis>
-       <cmdsynopsis>
-               <command>xmllint</command>
-               <arg choice="plain"><option>--help</option></arg>
-       </cmdsynopsis>
+    <cmdsynopsis>
+    <command>xmllint</command>
+        <group choice="opt">
+            <arg choice="plain"><option>--version</option></arg>
+            <arg choice="plain"><option>--debug</option></arg>
+            <arg choice="plain"><option>--quiet</option></arg>
+            <arg choice="plain"><option>--shell</option></arg>
+            <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
+            <arg choice="plain"><option>--debugent</option></arg>
+            <arg choice="plain"><option>--copy</option></arg>
+            <arg choice="plain"><option>--recover</option></arg>
+            <arg choice="plain"><option>--nodict</option></arg>
+            <arg choice="plain"><option>--noent</option></arg>
+            <arg choice="plain"><option>--noout</option></arg>
+            <arg choice="plain"><option>--nonet</option></arg>
+            <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
+            <arg choice="plain"><option>--load-trace</option></arg>
+            <arg choice="plain"><option>--htmlout</option></arg>
+            <arg choice="plain"><option>--nowrap</option></arg>
+            <arg choice="plain"><option>--valid</option></arg>
+            <arg choice="plain"><option>--postvalid</option></arg>
+            <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
+            <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
+            <arg choice="plain"><option>--timing</option></arg>
+            <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
+            <arg choice="plain"><option>--repeat</option></arg>
+            <arg choice="plain"><option>--insert</option></arg>
+            <arg choice="plain"><option>--compress</option></arg>
+            <arg choice="plain"><option>--html</option></arg>
+            <arg choice="plain"><option>--xmlout</option></arg>
+            <arg choice="plain"><option>--push</option></arg>
+            <arg choice="plain"><option>--memory</option></arg>
+            <arg choice="plain"><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></arg>
+            <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
+            <arg choice="plain"><option>--nowarning</option></arg>
+            <arg choice="plain"><option>--noblanks</option></arg>
+            <arg choice="plain"><option>--nocdata</option></arg>
+            <arg choice="plain"><option>--format</option></arg>
+            <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
+            <arg choice="plain"><option>--dropdtd</option></arg>
+            <arg choice="plain"><option>--nsclean</option></arg>
+            <arg choice="plain"><option>--testIO</option></arg>
+            <arg choice="plain"><option>--catalogs</option></arg>
+            <arg choice="plain"><option>--nocatalogs</option></arg>
+            <arg choice="plain"><option>--auto</option></arg>
+            <arg choice="plain"><option>--xinclude</option></arg>
+            <arg choice="plain"><option>--noxincludenode</option></arg>
+            <arg choice="plain"><option>--loaddtd</option></arg>
+            <arg choice="plain"><option>--dtdattr</option></arg>
+            <arg choice="plain"><option>--stream</option></arg>
+            <arg choice="plain"><option>--walker</option></arg>
+            <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
+            <arg choice="plain"><option>--chkregister</option></arg>
+            <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
+            <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
+            <arg choice="plain"><option>--c14n</option></arg>
+            <arg choice="plain"><option>--pedantic</option></arg>
+        </group>
+        <group choice="req">
+            <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
+            <arg choice="plain" rep="norepeat">-</arg>
+        </group>
+    </cmdsynopsis>
+    <cmdsynopsis>
+        <command>xmllint</command>
+        <arg choice="plain"><option>--help</option></arg>
+    </cmdsynopsis>
 </refsynopsisdiv>
 
 <refsect1 id="description">
-       <title>DESCRIPTION</title>
-       <para>
-               The &xmllint; program parses one or more <acronym>XML</acronym> files,
-               specified on the command line as <replaceable>XML-FILE</replaceable>
-               (or the standard input if the filename provided
-               is <emphasis role="bold">-</emphasis> ). It prints various types of
-               output, depending upon the options selected. It is useful for detecting
-               errors both in <acronym>XML</acronym> code and in
-               the <acronym>XML</acronym> parser itself.
-       </para>
-       <para>&xmllint; is included in <citerefentry>
-               <refentrytitle>libxml</refentrytitle>
-               <manvolnum>3</manvolnum>
-       </citerefentry>.</para>
+    <title>DESCRIPTION</title>
+    <para>
+        The &xmllint; program parses one or more <acronym>XML</acronym> files,
+        specified on the command line as <replaceable>XML-FILE</replaceable>
+        (or the standard input if the filename provided
+        is <emphasis role="bold">-</emphasis> ). It prints various types of
+        output, depending upon the options selected. It is useful for detecting
+        errors both in <acronym>XML</acronym> code and in
+        the <acronym>XML</acronym> parser itself.
+    </para>
+    <para>&xmllint; is included in <citerefentry>
+        <refentrytitle>libxml</refentrytitle>
+        <manvolnum>3</manvolnum>
+    </citerefentry>.</para>
 </refsect1>
 
 <refsect1 id="options">
-       <title>OPTIONS</title>
-       <para>
-               &xmllint; accepts the following options (in alphabetical order):
-       </para>
-
-       <variablelist>
-
-               <varlistentry>
-       <term><option>--auto</option></term>
-       <listitem>
-               <para>Generate a small document for testing purposes.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--catalogs</option></term>
-       <listitem>
-               <para>
-                       Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
-                       Otherwise <acronym>XML</acronym> catalogs starting
-                       from <filename>/etc/xml/catalog</filename> are used by default.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--chkregister</option></term>
-       <listitem>
-               <para>
-                       Turn on node registration. Useful for developers testing <citerefentry>
-               <refentrytitle>libxml</refentrytitle>
-               <manvolnum>3</manvolnum>
-       </citerefentry> node tracking code.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--compress</option></term>
-       <listitem>
-               <para>
-                       Turn on <citerefentry>
-               <refentrytitle>gzip</refentrytitle>
-               <manvolnum>1</manvolnum>
-       </citerefentry> compression of output.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--copy</option></term>
-       <listitem>
-               <para>Test the internal copy implementation.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--c14n</option></term>
-       <listitem>
-               <para>
-                       Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
-                       serialize the result of parsing to <filename class="devicefile">stdout</filename>.
-                       It keeps comments in the result.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
-       <listitem>
-               <para>
-                       Use the <acronym>DTD</acronym> specified by
-                       an <replaceable>URL</replaceable> for validation.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
-       <listitem>
-               <para>
-                       Use the <acronym>DTD</acronym> specified by a Formal Public
-                       Identifier <replaceable>FPI</replaceable> for validation, note that this
-                       will require a catalog exporting that Formal Public Identifier to work.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--debug</option></term>
-       <listitem>
-               <para>
-                       Parse a file and output an annotated tree of the
-                       in-memory version of the document.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--debugent</option></term>
-       <listitem>
-               <para>Debug the entities defined in the document.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--dropdtd</option></term>
-       <listitem>
-               <para>Remove <acronym>DTD</acronym> from output.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--dtdattr</option></term>
-       <listitem>
-               <para>
-                       Fetch external <acronym>DTD</acronym> and populate the tree with
-                       inherited attributes.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
-       <listitem>
-               <para>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--format</option></term>
-       <listitem>
-               <para>
-                       Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
-                       environment variable controls the indentation. The default value is two
-                       spaces &quot;  &quot;).
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--help</option></term>
-       <listitem>
-               <para>Print out a short usage summary for &xmllint;.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--html</option></term>
-       <listitem>
-               <para>Use the <acronym>HTML</acronym> parser.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--htmlout</option></term>
-       <listitem>
-               <para>
-                       Output results as an <acronym>HTML</acronym> file. This
-                       causes &xmllint; to output the necessary <acronym>HTML</acronym>
-                       tags surrounding the result tree output so the results can be
-                       displayed/viewed in a browser.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--insert</option></term>
-       <listitem>
-               <para>Test for valid insertions.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--loaddtd</option></term>
-       <listitem>
-               <para>Fetch an external <acronym>DTD</acronym>.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--load-trace</option></term>
-       <listitem>
-               <para>
-                       Display all the documents loaded during the processing
-                       to <filename class="devicefile">stderr</filename>.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
-       <listitem>
-               <para>
-                       Test the parser memory support. <replaceable>NNBYTES</replaceable>
-                       is the maximum number of bytes the library is allowed to allocate.
-                       This can also be used to make sure batch processing
-                       of <acronym>XML</acronym> files will not exhaust the virtual memory
-                       of the server running them.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--memory</option></term>
-       <listitem>
-               <para>Parse from memory.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--noblanks</option></term>
-       <listitem>
-               <para>Drop ignorable blank spaces.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nocatalogs</option></term>
-       <listitem>
-               <para>Do not use any catalogs.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nocdata</option></term>
-       <listitem>
-               <para>Substitute CDATA section by equivalent text nodes.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--noent</option></term>
-       <listitem>
-               <para>
-                       Substitute entity values for entity references. By default, &xmllint;
-                       leaves entity references in place.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nonet</option></term>
-       <listitem>
-               <para>
-                       Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--noout</option></term>
-       <listitem>
-               <para>
-                       Suppress output. By default, &xmllint; outputs the result tree.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nowarning</option></term>
-       <listitem>
-               <para>Do not emit warnings from the parser and/or validator.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nowrap</option></term>
-       <listitem>
-               <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--noxincludenode</option></term>
-       <listitem>
-               <para>
-                       Do XInclude processing but do not generate XInclude start and end nodes.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--nsclean</option></term>
-       <listitem>
-               <para>Remove redundant namespace declarations.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
-       <listitem>
-               <para>
-                       Define a file path where &xmllint; will save the result of parsing.
-                       Usually the programs build a tree and save it
-                       on <filename class="devicefile">stdout</filename>, with this option
-                       the result <acronym>XML</acronym> instance will be saved onto a file.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
-       <listitem>
-               <para>
-                       Use the (space- or colon-separated) list of filesystem paths specified
-                       by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
-                       entities. Enclose space-separated lists by quotation marks.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
-       <listitem>
-               <para>
-                       Used to exercise the pattern recognition engine, which can be used
-                       with the reader interface to the parser. It allows to select some
-                       nodes in the document based on an XPath (subset) expression. Used
-                       for debugging.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--postvalid</option></term>
-       <listitem>
-               <para>Validate after parsing has completed.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--push</option></term>
-       <listitem>
-               <para>Use the push mode of the parser.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--recover</option></term>
-       <listitem>
-               <para>Output any parsable portions of an invalid document.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
-       <listitem>
-               <para>
-                       Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
-                       for validation.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--repeat</option></term>
-       <listitem>
-               <para>Repeat 100 times, for timing or profiling.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
-       <listitem>
-               <para>
-                       Use a W3C <acronym>XML</acronym> Schema file
-                       named <replaceable>SCHEMA</replaceable> for validation.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--shell</option></term>
-       <listitem>
-               <para>
-                       Run a navigating shell. Details on available commands in shell mode
-                       are below (see <xref linkend="shell"/>).
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></term>
-       <listitem>
-               <para>
-                       Run an XPath expression given as argument and print the
-                       result. In case of a nodeset result, each node in the
-                       node set is serialized in full in the output. In case
-                       of an empty node set the "XPath set is empty" result
-                       will be shown and an error exit code will be returned.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--stream</option></term>
-       <listitem>
-               <para>
-                       Use streaming <acronym>API</acronym> - useful when used in combination
-                       with <option>--relaxng</option> or <option>--valid</option> options
-                       for validation of files that are too large to be held in memory.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--testIO</option></term>
-       <listitem>
-               <para>Test user input/output support.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--timing</option></term>
-       <listitem>
-               <para>
-                       Output information about the time it takes &xmllint; to perform the
-                       various steps.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--valid</option></term>
-       <listitem>
-               <para>
-                       Determine if the document is a valid instance of the included
-                       Document Type Definition (<acronym>DTD</acronym>).
-                       A <acronym>DTD</acronym> to be validated against also can be
-                       specified at the command line using the <option>--dtdvalid</option>
-                       option. By default, &xmllint; also checks to determine if the
-                       document is well-formed.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--version</option></term>
-       <listitem>
-               <para>
-                       Display the version of <citerefentry>
-               <refentrytitle>libxml</refentrytitle>
-               <manvolnum>3</manvolnum>
-       </citerefentry> used.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--walker</option></term>
-       <listitem>
-               <para>
-                       Test the walker module, which is a reader interface but for a
-                       document tree, instead of using the reader <acronym>API</acronym> on
-                       an unparsed document it works on an existing in-memory tree. Used for
-                       debugging.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--xinclude</option></term>
-       <listitem>
-               <para>Do XInclude processing.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>--xmlout</option></term>
-       <listitem>
-               <para>
-                       Used in conjunction with <option>--html</option>. Usually
-                       when <acronym>HTML</acronym> is parsed the document is saved with
-                       the <acronym>HTML</acronym> serializer. But with this option the
-                       resulting document is saved with the <acronym>XML</acronym>
-                       serializer. This is primarily used to
-                       generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
-               </para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist>
+    <title>OPTIONS</title>
+    <para>
+        &xmllint; accepts the following options (in alphabetical order):
+    </para>
+
+    <variablelist>
+
+        <varlistentry>
+            <term><option>--auto</option></term>
+            <listitem>
+                <para>Generate a small document for testing purposes.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--catalogs</option></term>
+            <listitem>
+                <para>
+                    Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
+                    Otherwise <acronym>XML</acronym> catalogs starting
+                    from <filename>/etc/xml/catalog</filename> or, more specifically,
+                    <filename>${sysconfdir}/xml/catalog</filename> are used by default.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--chkregister</option></term>
+            <listitem>
+                <para>
+                    Turn on node registration. Useful for developers testing <citerefentry>
+                <refentrytitle>libxml</refentrytitle>
+                <manvolnum>3</manvolnum>
+            </citerefentry> node tracking code.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--compress</option></term>
+            <listitem>
+                <para>
+                    Turn on <citerefentry>
+                <refentrytitle>gzip</refentrytitle>
+                <manvolnum>1</manvolnum>
+            </citerefentry> compression of output.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--copy</option></term>
+            <listitem>
+                <para>Test the internal copy implementation.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--c14n</option></term>
+            <listitem>
+                <para>
+                    Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
+                    serialize the result of parsing to <filename class="devicefile">stdout</filename>.
+                    It keeps comments in the result.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
+            <listitem>
+                <para>
+                    Use the <acronym>DTD</acronym> specified by
+                    an <replaceable>URL</replaceable> for validation.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
+            <listitem>
+                <para>
+                    Use the <acronym>DTD</acronym> specified by a Formal Public
+                    Identifier <replaceable>FPI</replaceable> for validation, note that this
+                    will require a catalog exporting that Formal Public Identifier to work.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--debug</option></term>
+            <listitem>
+                <para>
+                    Parse a file and output an annotated tree of the
+                    in-memory version of the document.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--debugent</option></term>
+            <listitem>
+                <para>Debug the entities defined in the document.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--dropdtd</option></term>
+            <listitem>
+                <para>Remove <acronym>DTD</acronym> from output.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--dtdattr</option></term>
+            <listitem>
+                <para>
+                    Fetch external <acronym>DTD</acronym> and populate the tree with
+                    inherited attributes.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
+            <listitem>
+                <para>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--format</option></term>
+            <listitem>
+                <para>
+                    Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
+                    environment variable controls the indentation. The default value is two
+                    spaces &quot;  &quot;).
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--help</option></term>
+            <listitem>
+                <para>Print out a short usage summary for &xmllint;.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--html</option></term>
+            <listitem>
+                <para>Use the <acronym>HTML</acronym> parser.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--htmlout</option></term>
+            <listitem>
+                <para>
+                    Output results as an <acronym>HTML</acronym> file. This
+                    causes &xmllint; to output the necessary <acronym>HTML</acronym>
+                    tags surrounding the result tree output so the results can be
+                    displayed/viewed in a browser.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--insert</option></term>
+            <listitem>
+                <para>Test for valid insertions.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--loaddtd</option></term>
+            <listitem>
+                <para>Fetch an external <acronym>DTD</acronym>.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--load-trace</option></term>
+            <listitem>
+                <para>
+                    Display all the documents loaded during the processing
+                    to <filename class="devicefile">stderr</filename>.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></term>
+            <listitem>
+                <para>
+                    Set the maximum amplification factor which protects against
+                    exponential entity expansion ("billion laughs"). The default value
+                    is 5. Documents making heavy use of entity expansion may require a
+                    higher value.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
+            <listitem>
+                <para>
+                    Test the parser memory support. <replaceable>NNBYTES</replaceable>
+                    is the maximum number of bytes the library is allowed to allocate.
+                    This can also be used to make sure batch processing
+                    of <acronym>XML</acronym> files will not exhaust the virtual memory
+                    of the server running them.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--memory</option></term>
+            <listitem>
+                <para>Parse from memory.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--noblanks</option></term>
+            <listitem>
+                <para>Drop ignorable blank spaces.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nocatalogs</option></term>
+            <listitem>
+                <para>Do not use any catalogs.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nocdata</option></term>
+            <listitem>
+                <para>Substitute CDATA section by equivalent text nodes.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nodict</option></term>
+            <listitem>
+                <para>
+                    Don't use dictionaries (parser option XML_PARSE_NODICT).
+                    Only for debugging.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--noent</option></term>
+            <listitem>
+                <para>
+                    Substitute entity values for entity references. By default, &xmllint;
+                    leaves entity references in place.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nonet</option></term>
+            <listitem>
+                <para>
+                    Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--noout</option></term>
+            <listitem>
+                <para>
+                    Suppress output. By default, &xmllint; outputs the result tree.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nowarning</option></term>
+            <listitem>
+                <para>Do not emit warnings from the parser and/or validator.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nowrap</option></term>
+            <listitem>
+                <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--noxincludenode</option></term>
+            <listitem>
+                <para>
+                    Do XInclude processing but do not generate XInclude start and end nodes.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--nsclean</option></term>
+            <listitem>
+                <para>Remove redundant namespace declarations.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
+            <listitem>
+                <para>
+                    Define a file path where &xmllint; will save the result of parsing.
+                    Usually the programs build a tree and save it
+                    on <filename class="devicefile">stdout</filename>, with this option
+                    the result <acronym>XML</acronym> instance will be saved onto a file.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
+            <listitem>
+                <para>
+                    Use the (space- or colon-separated) list of filesystem paths specified
+                    by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
+                    entities. Enclose space-separated lists by quotation marks.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
+            <listitem>
+                <para>
+                    Used to exercise the pattern recognition engine, which can be used
+                    with the reader interface to the parser. It allows to select some
+                    nodes in the document based on an XPath (subset) expression. Used
+                    for debugging.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--pedantic</option></term>
+            <listitem>
+                <para>Enable additional warnings.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--postvalid</option></term>
+            <listitem>
+                <para>Validate after parsing has completed.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--push</option></term>
+            <listitem>
+                <para>Use the push mode of the parser.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--quiet</option></term>
+            <listitem>
+                <para>Don't print informational messages to stderr.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--recover</option></term>
+            <listitem>
+                <para>Output any parsable portions of an invalid document.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
+            <listitem>
+                <para>
+                    Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
+                    for validation.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--repeat</option></term>
+            <listitem>
+                <para>Repeat 100 times, for timing or profiling.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
+            <listitem>
+                <para>
+                    Use a W3C <acronym>XML</acronym> Schema file
+                    named <replaceable>SCHEMA</replaceable> for validation.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--shell</option></term>
+            <listitem>
+                <para>
+                    Run a navigating shell. Details on available commands in shell mode
+                    are below (see <xref linkend="shell"/>).
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></term>
+            <listitem>
+                <para>
+                    Run an XPath expression given as argument and print the
+                    result. In case of a nodeset result, each node in the
+                    node set is serialized in full in the output. In case
+                    of an empty node set the "XPath set is empty" result
+                    will be shown and an error exit code will be returned.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--stream</option></term>
+            <listitem>
+                <para>
+                    Use streaming <acronym>API</acronym> - useful when used in combination
+                    with <option>--relaxng</option> or <option>--valid</option> options
+                    for validation of files that are too large to be held in memory.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--testIO</option></term>
+            <listitem>
+                <para>Test user input/output support.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--timing</option></term>
+            <listitem>
+                <para>
+                    Output information about the time it takes &xmllint; to perform the
+                    various steps.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--valid</option></term>
+            <listitem>
+                <para>
+                    Determine if the document is a valid instance of the included
+                    Document Type Definition (<acronym>DTD</acronym>).
+                    A <acronym>DTD</acronym> to be validated against also can be
+                    specified at the command line using the <option>--dtdvalid</option>
+                    option. By default, &xmllint; also checks to determine if the
+                    document is well-formed.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--version</option></term>
+            <listitem>
+                <para>
+                    Display the version of <citerefentry>
+                <refentrytitle>libxml</refentrytitle>
+                <manvolnum>3</manvolnum>
+            </citerefentry> used.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--walker</option></term>
+            <listitem>
+                <para>
+                    Test the walker module, which is a reader interface but for a
+                    document tree, instead of using the reader <acronym>API</acronym> on
+                    an unparsed document it works on an existing in-memory tree. Used for
+                    debugging.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--xinclude</option></term>
+            <listitem>
+                <para>Do XInclude processing.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>--xmlout</option></term>
+            <listitem>
+                <para>
+                    Used in conjunction with <option>--html</option>. Usually
+                    when <acronym>HTML</acronym> is parsed the document is saved with
+                    the <acronym>HTML</acronym> serializer. But with this option the
+                    resulting document is saved with the <acronym>XML</acronym>
+                    serializer. This is primarily used to
+                    generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
+                </para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="shell">
-       <title>SHELL COMMANDS</title>
-       <para>
-               &xmllint; offers an interactive shell mode invoked with
-               the <option>--shell</option> command. Available commands in shell mode
-               include (in alphabetical order):
-       </para>
-       <variablelist>
-
-               <varlistentry>
-       <term><command>base</command></term>
-       <listitem>
-               <para>Display <acronym>XML</acronym> base of the node.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>bye</command></term>
-       <listitem>
-               <para>Leave the shell.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>cat <replaceable>NODE</replaceable></command></term>
-       <listitem>
-               <para>Display the given node or the current one.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>cd <replaceable>PATH</replaceable></command></term>
-       <listitem>
-               <para>
-                       Change the current node to the given path (if unique) or root if no
-                       argument is given.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>dir <replaceable>PATH</replaceable></command></term>
-       <listitem>
-               <para>
-                       Dumps information about the node (namespace, attributes, content).
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>du <replaceable>PATH</replaceable></command></term>
-       <listitem>
-               <para>
-                       Show the structure of the subtree under the given path or the current node.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>exit</command></term>
-       <listitem>
-               <para>Leave the shell.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>help</command></term>
-       <listitem>
-               <para>Show this help.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>free</command></term>
-       <listitem>
-               <para>Display memory usage.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>load <replaceable>FILENAME</replaceable></command></term>
-       <listitem>
-               <para>Load a new document with the given filename.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>ls <replaceable>PATH</replaceable></command></term>
-       <listitem>
-               <para>List contents of the given path or the current directory.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>pwd</command></term>
-       <listitem>
-               <para>Display the path to the current node.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>quit</command></term>
-       <listitem>
-               <para>Leave the shell.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>save <replaceable>FILENAME</replaceable></command></term>
-       <listitem>
-               <para>
-                       Save the current document to the given filename or to the original name.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><option>validate</option></term>
-       <listitem>
-               <para>Check the document for errors.</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><command>write <replaceable>FILENAME</replaceable></command></term>
-       <listitem>
-               <para>Write the current node to the given filename.</para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist>
+    <title>SHELL COMMANDS</title>
+    <para>
+        &xmllint; offers an interactive shell mode invoked with
+        the <option>--shell</option> command. Available commands in shell mode
+        include (in alphabetical order):
+    </para>
+    <variablelist>
+
+        <varlistentry>
+            <term><command>base</command></term>
+            <listitem>
+                <para>Display <acronym>XML</acronym> base of the node.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>bye</command></term>
+            <listitem>
+                <para>Leave the shell.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>cat <replaceable>NODE</replaceable></command></term>
+            <listitem>
+                <para>Display the given node or the current one.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>cd <replaceable>PATH</replaceable></command></term>
+            <listitem>
+                <para>
+                    Change the current node to the given path (if unique) or root if no
+                    argument is given.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>dir <replaceable>PATH</replaceable></command></term>
+            <listitem>
+                <para>
+                    Dumps information about the node (namespace, attributes, content).
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>du <replaceable>PATH</replaceable></command></term>
+            <listitem>
+                <para>
+                    Show the structure of the subtree under the given path or the current node.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>exit</command></term>
+            <listitem>
+                <para>Leave the shell.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>help</command></term>
+            <listitem>
+                <para>Show this help.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>free</command></term>
+            <listitem>
+                <para>Display memory usage.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>load <replaceable>FILENAME</replaceable></command></term>
+            <listitem>
+                <para>Load a new document with the given filename.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>ls <replaceable>PATH</replaceable></command></term>
+            <listitem>
+                <para>List contents of the given path or the current directory.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>pwd</command></term>
+            <listitem>
+                <para>Display the path to the current node.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>quit</command></term>
+            <listitem>
+                <para>Leave the shell.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>save <replaceable>FILENAME</replaceable></command></term>
+            <listitem>
+                <para>
+                    Save the current document to the given filename or to the original name.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><option>validate</option></term>
+            <listitem>
+                <para>Check the document for errors.</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><command>write <replaceable>FILENAME</replaceable></command></term>
+            <listitem>
+                <para>Write the current node to the given filename.</para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="environment">
-       <title>ENVIRONMENT</title>
-       <variablelist>
-
-               <varlistentry>
-       <term><envar>SGML_CATALOG_FILES</envar></term>
-       <listitem>
-               <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
-                       of catalogs. An empty one should deactivate loading the
-                       default <filename>/etc/sgml/catalog</filename> catalog.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><envar>XML_CATALOG_FILES</envar></term>
-       <listitem>
-               <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
-                       queries to the user's own set of catalogs. This can be done by setting
-                       the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
-                       list of catalogs. Use percent-encoding to escape spaces or other characters.
-                       An empty variable should deactivate loading the default <filename>/etc/xml/catalog</filename> catalog.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><envar>XML_DEBUG_CATALOG</envar></term>
-       <listitem>
-               <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
-                       to <parameter>non-zero</parameter> using the <command>export</command>
-                       command outputs debugging information related to catalog operations.
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><envar>XMLLINT_INDENT</envar></term>
-       <listitem>
-               <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
-                       controls the indentation. The default value is two spaces &quot;  &quot;.
-               </para>
-       </listitem>
-               </varlistentry>
-               
-       </variablelist>
+    <title>ENVIRONMENT</title>
+    <variablelist>
+
+        <varlistentry>
+            <term><envar>SGML_CATALOG_FILES</envar></term>
+            <listitem>
+                <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
+                    of catalogs. An empty one should deactivate loading the
+                    default catalog.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><envar>XML_CATALOG_FILES</envar></term>
+            <listitem>
+                <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
+                    queries to the user's own set of catalogs. This can be done by setting
+                    the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
+                    list of catalogs. Use percent-encoding to escape spaces or other characters.
+                    An empty variable should deactivate loading the default catalog.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><envar>XML_DEBUG_CATALOG</envar></term>
+            <listitem>
+                <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
+                    to <parameter>non-zero</parameter> using the <command>export</command>
+                    command outputs debugging information related to catalog operations.
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><envar>XMLLINT_INDENT</envar></term>
+            <listitem>
+                <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
+                    controls the indentation. The default value is two spaces &quot;  &quot;.
+                </para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="diagnostics">
-       <title>DIAGNOSTICS</title>
-       <para>
-               &xmllint; return codes provide information that can be used when
-               calling it from scripts.
-       </para>
-       <!-- better use segmentedlist element later,
-            which is currently only supported in snapshots -->
-       <variablelist>
-
-               <varlistentry>
-       <term><errorcode>0</errorcode></term>
-       <listitem>
-               <para>No error</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>1</errorcode></term>
-       <listitem>
-               <para>Unclassified</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>2</errorcode></term>
-       <listitem>
-               <para>Error in <acronym>DTD</acronym></para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>3</errorcode></term>
-       <listitem>
-               <para>Validation error</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>4</errorcode></term>
-       <listitem>
-               <para>Validation error</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>5</errorcode></term>
-       <listitem>
-               <para>Error in schema compilation</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>6</errorcode></term>
-       <listitem>
-               <para>Error writing output</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>7</errorcode></term>
-       <listitem>
-               <para>
-                       Error in pattern (generated when <option>--pattern</option> option is used)
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>8</errorcode></term>
-       <listitem>
-               <para>
-                       Error in Reader registration (generated
-                       when <option>--chkregister</option> option is used)
-               </para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>9</errorcode></term>
-       <listitem>
-               <para>Out of memory error</para>
-       </listitem>
-               </varlistentry>
-
-               <varlistentry>
-       <term><errorcode>10</errorcode></term>
-       <listitem>
-               <para>XPath evaluation error</para>
-       </listitem>
-               </varlistentry>
-
-       </variablelist>
+    <title>DIAGNOSTICS</title>
+    <para>
+        &xmllint; return codes provide information that can be used when
+        calling it from scripts.
+    </para>
+    <!-- better use segmentedlist element later,
+         which is currently only supported in snapshots -->
+    <variablelist>
+
+        <varlistentry>
+            <term><errorcode>0</errorcode></term>
+            <listitem>
+                <para>No error</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>1</errorcode></term>
+            <listitem>
+                <para>Unclassified</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>2</errorcode></term>
+            <listitem>
+                <para>Error in <acronym>DTD</acronym></para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>3</errorcode></term>
+            <listitem>
+                <para>Validation error</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>4</errorcode></term>
+            <listitem>
+                <para>Validation error</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>5</errorcode></term>
+            <listitem>
+                <para>Error in schema compilation</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>6</errorcode></term>
+            <listitem>
+                <para>Error writing output</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>7</errorcode></term>
+            <listitem>
+                <para>
+                    Error in pattern (generated when <option>--pattern</option> option is used)
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>8</errorcode></term>
+            <listitem>
+                <para>
+                    Error in Reader registration (generated
+                    when <option>--chkregister</option> option is used)
+                </para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>9</errorcode></term>
+            <listitem>
+                <para>Out of memory error</para>
+            </listitem>
+        </varlistentry>
+
+        <varlistentry>
+            <term><errorcode>10</errorcode></term>
+            <listitem>
+                <para>XPath evaluation error</para>
+            </listitem>
+        </varlistentry>
+
+    </variablelist>
 </refsect1>
 
 <refsect1 id="seealso">
-       <title>SEE ALSO</title>
-       <para><citerefentry>
-                       <refentrytitle>libxml</refentrytitle>
-                       <manvolnum>3</manvolnum>
-               </citerefentry>
-       </para>
-       <para>
-               More information can be found at
-               <itemizedlist>
-                       <listitem>
-                               <para><citerefentry>
-                                               <refentrytitle>libxml</refentrytitle>
-                                               <manvolnum>3</manvolnum>
-                                       </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
-                               </para>
-                       </listitem>
-               </itemizedlist>
-       </para>
+    <title>SEE ALSO</title>
+    <para><citerefentry>
+            <refentrytitle>libxml</refentrytitle>
+            <manvolnum>3</manvolnum>
+        </citerefentry>
+    </para>
+    <para>
+        More information can be found at
+        <itemizedlist>
+            <listitem>
+                <para><citerefentry>
+                        <refentrytitle>libxml</refentrytitle>
+                        <manvolnum>3</manvolnum>
+                    </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
+                </para>
+            </listitem>
+        </itemizedlist>
+    </para>
 </refsect1>
 
 </refentry>
diff --git a/enc.h b/enc.h
deleted file mode 100644 (file)
index a69a5d0..0000000
--- a/enc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Summary: Internal Interfaces for encoding in libxml2
- * Description: this module describes a few interfaces which were
- *              added along with the API changes in 2.9.0
- *              those are private routines at this point
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-#ifndef __XML_ENC_H__
-#define __XML_ENC_H__
-
-#include <libxml/tree.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
-                           xmlBufferPtr in, int len);
-int xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len);
-int xmlCharEncInput(xmlParserInputBufferPtr input, int flush);
-int xmlCharEncOutput(xmlOutputBufferPtr output, int init);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __XML_ENC_H__ */
-
-
index 5465359..bc2772d 100644 (file)
 
 #include <libxml/encoding.h>
 #include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
 #ifdef LIBXML_HTML_ENABLED
 #include <libxml/HTMLparser.h>
 #endif
-#include <libxml/globals.h>
 #include <libxml/xmlerror.h>
 
-#include "buf.h"
-#include "enc.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
 
 #ifdef LIBXML_ICU_ENABLED
 #include <unicode/ucnv.h>
@@ -57,9 +58,6 @@ struct _uconv_t {
 };
 #endif
 
-static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
-static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
-
 typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias;
 typedef xmlCharEncodingAlias *xmlCharEncodingAliasPtr;
 struct _xmlCharEncodingAlias {
@@ -71,45 +69,8 @@ static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL;
 static int xmlCharEncodingAliasesNb = 0;
 static int xmlCharEncodingAliasesMax = 0;
 
-#if defined(LIBXML_ICONV_ENABLED) || defined(LIBXML_ICU_ENABLED)
-#if 0
-#define DEBUG_ENCODING  /* Define this to get encoding traces */
-#endif
-#else
-#ifdef LIBXML_ISO8859X_ENABLED
-static void xmlRegisterCharEncodingHandlersISO8859x (void);
-#endif
-#endif
-
 static int xmlLittleEndian = 1;
 
-/**
- * xmlEncodingErrMemory:
- * @extra:  extra information
- *
- * Handle an out of memory condition
- */
-static void
-xmlEncodingErrMemory(const char *extra)
-{
-    __xmlSimpleError(XML_FROM_I18N, XML_ERR_NO_MEMORY, NULL, NULL, extra);
-}
-
-/**
- * xmlErrEncoding:
- * @error:  the error number
- * @msg:  the error message
- *
- * n encoding error
- */
-static void LIBXML_ATTR_FORMAT(2,0)
-xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
-{
-    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
-                    XML_FROM_I18N, error, XML_ERR_FATAL,
-                    NULL, 0, val, NULL, NULL, 0, 0, msg, val);
-}
-
 #ifdef LIBXML_ICU_ENABLED
 static uconv_t*
 openIcuConverter(const char* name, int toUnicode)
@@ -176,7 +137,9 @@ closeIcuConverter(uconv_t *conv)
  *
  * Take a block of ASCII chars in and try to convert it to an UTF-8
  * block of chars out.
- * Returns 0 if success, or -1 otherwise
+ *
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
  *     if the return value is positive, else unpredictable.
  * The value of @outlen after return is the number of octets produced.
@@ -202,7 +165,7 @@ asciiToUTF8(unsigned char* out, int *outlen,
        } else {
            *outlen = out - outstart;
            *inlen = processed - base;
-           return(-1);
+           return(XML_ENC_ERR_INPUT);
        }
 
        processed = (const unsigned char*) in;
@@ -223,7 +186,8 @@ asciiToUTF8(unsigned char* out, int *outlen,
  * Take a block of UTF-8 chars in and try to convert it to an ASCII
  * block of chars out.
  *
- * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
  *     if the return value is positive, else unpredictable.
  * The value of @outlen after return is the number of octets produced.
@@ -239,7 +203,8 @@ UTF8Toascii(unsigned char* out, int *outlen,
     unsigned int c, d;
     int trailing;
 
-    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
+    if ((out == NULL) || (outlen == NULL) || (inlen == NULL))
+        return(XML_ENC_ERR_INTERNAL);
     if (in == NULL) {
         /*
         * initialization nothing to do
@@ -257,7 +222,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
            /* trailing byte in leading position */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
         } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
         else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
         else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
@@ -265,7 +230,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
            /* no chance for this in Ascii */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
        }
 
        if (inend - in < trailing) {
@@ -288,7 +253,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
            /* no chance for this in Ascii */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
        }
        processed = in;
     }
@@ -307,7 +272,9 @@ UTF8Toascii(unsigned char* out, int *outlen,
  *
  * Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8
  * block of chars out.
- * Returns the number of bytes written if success, or -1 otherwise
+ *
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
  *     if the return value is positive, else unpredictable.
  * The value of @outlen after return is the number of octets produced.
@@ -322,7 +289,7 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
     const unsigned char* instop;
 
     if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
-       return(-1);
+       return(XML_ENC_ERR_INTERNAL);
 
     outend = out + *outlen;
     inend = in + (*inlen);
@@ -356,7 +323,8 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
  *
  * No op copy operation for UTF8 handling.
  *
- * Returns the number of bytes written, or -1 if lack of space.
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  *     The value of *inlen after return is the number of octets consumed
  *     if the return value is positive, else unpredictable.
  */
@@ -367,7 +335,7 @@ UTF8ToUTF8(unsigned char* out, int *outlen,
     int len;
 
     if ((out == NULL) || (outlen == NULL) || (inlenb == NULL))
-       return(-1);
+       return(XML_ENC_ERR_INTERNAL);
     if (inb == NULL) {
         /* inb == NULL means output is initialized. */
         *outlen = 0;
@@ -380,7 +348,7 @@ UTF8ToUTF8(unsigned char* out, int *outlen,
        len = *outlen;
     }
     if (len < 0)
-       return(-1);
+       return(XML_ENC_ERR_INTERNAL);
 
     /*
      * FIXME: Conversion functions must assure valid UTF-8, so we have
@@ -406,8 +374,8 @@ UTF8ToUTF8(unsigned char* out, int *outlen,
  * Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1
  * block of chars out.
  *
- * Returns the number of bytes written if success, -2 if the transcoding fails,
-           or -1 otherwise
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
  *     if the return value is positive, else unpredictable.
  * The value of @outlen after return is the number of octets produced.
@@ -423,7 +391,8 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
     unsigned int c, d;
     int trailing;
 
-    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
+    if ((out == NULL) || (outlen == NULL) || (inlen == NULL))
+        return(XML_ENC_ERR_INTERNAL);
     if (in == NULL) {
         /*
         * initialization nothing to do
@@ -441,7 +410,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
            /* trailing byte in leading position */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
         } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
         else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
         else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
@@ -449,7 +418,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
            /* no chance for this in IsoLat1 */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
        }
 
        if (inend - in < trailing) {
@@ -462,7 +431,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
            if (((d= *in++) & 0xC0) != 0x80) {
                *outlen = out - outstart;
                *inlen = processed - instart;
-               return(-2);
+               return(XML_ENC_ERR_INPUT);
            }
            c <<= 6;
            c |= d & 0x3F;
@@ -477,7 +446,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
            /* no chance for this in IsoLat1 */
            *outlen = out - outstart;
            *inlen = processed - instart;
-           return(-2);
+           return(XML_ENC_ERR_INPUT);
        }
        processed = in;
     }
@@ -499,10 +468,10 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
  * is the same between the native type of this machine and the
  * inputed one.
  *
- * Returns the number of bytes written, or -1 if lack of space, or -2
- *     if the transcoding fails (if *in is not a valid utf16 string)
- *     The value of *inlen after return is the number of octets consumed
- *     if the return value is positive, else unpredictable.
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
+ * The value of *inlen after return is the number of octets consumed
+ * if the return value is positive, else unpredictable.
  */
 static int
 UTF16LEToUTF8(unsigned char* out, int *outlen,
@@ -511,7 +480,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
     unsigned char* outstart = out;
     const unsigned char* processed = inb;
     unsigned char* outend;
-    unsigned short* in = (unsigned short*) inb;
+    unsigned short* in = (unsigned short *) (void *) inb;
     unsigned short* inend;
     unsigned int c, d, inlen;
     unsigned char *tmp;
@@ -532,7 +501,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
        } else {
            tmp = (unsigned char *) in;
            c = *tmp++;
-           c = c | (((unsigned int)*tmp) << 8);
+           c = c | (*tmp << 8);
            in++;
        }
         if ((c & 0xFC00) == 0xD800) {    /* surrogates */
@@ -544,7 +513,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
            } else {
                tmp = (unsigned char *) in;
                d = *tmp++;
-               d = d | (((unsigned int)*tmp) << 8);
+               d = d | (*tmp << 8);
                in++;
            }
             if ((d & 0xFC00) == 0xDC00) {
@@ -556,7 +525,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
             else {
                *outlen = out - outstart;
                *inlenb = processed - inb;
-               return(-2);
+               return(XML_ENC_ERR_INPUT);
            }
         }
 
@@ -591,14 +560,13 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
  * Take a block of UTF-8 chars in and try to convert it to an UTF-16LE
  * block of chars out.
  *
- * Returns the number of bytes written, or -1 if lack of space, or -2
- *     if the transcoding failed.
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 static int
 UTF8ToUTF16LE(unsigned char* outb, int *outlen,
             const unsigned char* in, int *inlen)
 {
-    unsigned short* out = (unsigned short*) outb;
+    unsigned short* out = (unsigned short *) (void *) outb;
     const unsigned char* processed = in;
     const unsigned char *const instart = in;
     unsigned short* outstart= out;
@@ -610,7 +578,8 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
     unsigned short tmp1, tmp2;
 
     /* UTF16LE encoding has no BOM */
-    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
+    if ((out == NULL) || (outlen == NULL) || (inlen == NULL))
+        return(XML_ENC_ERR_INTERNAL);
     if (in == NULL) {
        *outlen = 0;
        *inlen = 0;
@@ -625,7 +594,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
           /* trailing byte in leading position */
          *outlen = (out - outstart) * 2;
          *inlen = processed - instart;
-         return(-2);
+         return(XML_ENC_ERR_INPUT);
       } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
       else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
       else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
@@ -633,7 +602,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
        /* no chance for this in UTF-16 */
        *outlen = (out - outstart) * 2;
        *inlen = processed - instart;
-       return(-2);
+       return(XML_ENC_ERR_INPUT);
       }
 
       if (inend - in < trailing) {
@@ -655,7 +624,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
                *out++ = c;
            } else {
                tmp = (unsigned char *) out;
-               *tmp = c ;
+               *tmp = (unsigned char) c; /* Explicit truncation */
                *(tmp + 1) = c >> 8 ;
                out++;
            }
@@ -670,13 +639,13 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
            } else {
                tmp1 = 0xD800 | (c >> 10);
                tmp = (unsigned char *) out;
-               *tmp = (unsigned char) tmp1;
+               *tmp = (unsigned char) tmp1; /* Explicit truncation */
                *(tmp + 1) = tmp1 >> 8;
                out++;
 
                tmp2 = 0xDC00 | (c & 0x03FF);
                tmp = (unsigned char *) out;
-               *tmp  = (unsigned char) tmp2;
+               *tmp  = (unsigned char) tmp2; /* Explicit truncation */
                *(tmp + 1) = tmp2 >> 8;
                out++;
            }
@@ -700,8 +669,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
  * Take a block of UTF-8 chars in and try to convert it to an UTF-16
  * block of chars out.
  *
- * Returns the number of bytes written, or -1 if lack of space, or -2
- *     if the transcoding failed.
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 static int
 UTF8ToUTF16(unsigned char* outb, int *outlen,
@@ -716,10 +684,6 @@ UTF8ToUTF16(unsigned char* outb, int *outlen,
            outb[1] = 0xFE;
            *outlen = 2;
            *inlen = 0;
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                   "Added FFFE Byte Order Mark\n");
-#endif
            return(2);
        }
        *outlen = 0;
@@ -742,10 +706,10 @@ UTF8ToUTF16(unsigned char* outb, int *outlen,
  * is the same between the native type of this machine and the
  * inputed one.
  *
- * Returns the number of bytes written, or -1 if lack of space, or -2
- *     if the transcoding fails (if *in is not a valid utf16 string)
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of *inlen after return is the number of octets consumed
- *     if the return value is positive, else unpredictable.
+ * if the return value is positive, else unpredictable.
  */
 static int
 UTF16BEToUTF8(unsigned char* out, int *outlen,
@@ -754,7 +718,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
     unsigned char* outstart = out;
     const unsigned char* processed = inb;
     unsigned char* outend;
-    unsigned short* in = (unsigned short*) inb;
+    unsigned short* in = (unsigned short *) (void *) inb;
     unsigned short* inend;
     unsigned int c, d, inlen;
     unsigned char *tmp;
@@ -773,7 +737,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
        if (xmlLittleEndian) {
            tmp = (unsigned char *) in;
            c = *tmp++;
-           c = (c << 8) | (unsigned int) *tmp;
+           c = (c << 8) | *tmp;
            in++;
        } else {
            c= *in++;
@@ -785,7 +749,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
            if (xmlLittleEndian) {
                tmp = (unsigned char *) in;
                d = *tmp++;
-               d = (d << 8) | (unsigned int) *tmp;
+               d = (d << 8) | *tmp;
                in++;
            } else {
                d= *in++;
@@ -799,7 +763,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
             else {
                *outlen = out - outstart;
                *inlenb = processed - inb;
-               return(-2);
+               return(XML_ENC_ERR_INPUT);
            }
         }
 
@@ -834,14 +798,13 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
  * Take a block of UTF-8 chars in and try to convert it to an UTF-16BE
  * block of chars out.
  *
- * Returns the number of byte written, or -1 by lack of space, or -2
- *     if the transcoding failed.
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 static int
 UTF8ToUTF16BE(unsigned char* outb, int *outlen,
             const unsigned char* in, int *inlen)
 {
-    unsigned short* out = (unsigned short*) outb;
+    unsigned short* out = (unsigned short *) (void *) outb;
     const unsigned char* processed = in;
     const unsigned char *const instart = in;
     unsigned short* outstart= out;
@@ -853,7 +816,8 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
     unsigned short tmp1, tmp2;
 
     /* UTF-16BE has no BOM */
-    if ((outb == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
+    if ((outb == NULL) || (outlen == NULL) || (inlen == NULL))
+        return(XML_ENC_ERR_INTERNAL);
     if (in == NULL) {
        *outlen = 0;
        *inlen = 0;
@@ -868,7 +832,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
           /* trailing byte in leading position */
          *outlen = out - outstart;
          *inlen = processed - instart;
-         return(-2);
+         return(XML_ENC_ERR_INPUT);
       } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
       else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
       else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
@@ -876,7 +840,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
           /* no chance for this in UTF-16 */
          *outlen = out - outstart;
          *inlen = processed - instart;
-         return(-2);
+         return(XML_ENC_ERR_INPUT);
       }
 
       if (inend - in < trailing) {
@@ -895,7 +859,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
            if (xmlLittleEndian) {
                tmp = (unsigned char *) out;
                *tmp = c >> 8;
-               *(tmp + 1) = c;
+               *(tmp + 1) = (unsigned char) c; /* Explicit truncation */
                out++;
            } else {
                *out++ = c;
@@ -908,13 +872,13 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
                tmp1 = 0xD800 | (c >> 10);
                tmp = (unsigned char *) out;
                *tmp = tmp1 >> 8;
-               *(tmp + 1) = (unsigned char) tmp1;
+               *(tmp + 1) = (unsigned char) tmp1; /* Explicit truncation */
                out++;
 
                tmp2 = 0xDC00 | (c & 0x03FF);
                tmp = (unsigned char *) out;
                *tmp = tmp2 >> 8;
-               *(tmp + 1) = (unsigned char) tmp2;
+               *(tmp + 1) = (unsigned char) tmp2; /* Explicit truncation */
                out++;
            } else {
                *out++ = 0xD800 | (c >> 10);
@@ -1047,7 +1011,7 @@ xmlGetEncodingAlias(const char *alias) {
        return(NULL);
 
     for (i = 0;i < 99;i++) {
-        upper[i] = toupper(alias[i]);
+        upper[i] = (char) toupper((unsigned char) alias[i]);
        if (upper[i] == 0) break;
     }
     upper[i] = 0;
@@ -1077,29 +1041,32 @@ int
 xmlAddEncodingAlias(const char *name, const char *alias) {
     int i;
     char upper[100];
+    char *nameCopy, *aliasCopy;
 
     if ((name == NULL) || (alias == NULL))
        return(-1);
 
     for (i = 0;i < 99;i++) {
-        upper[i] = toupper(alias[i]);
+        upper[i] = (char) toupper((unsigned char) alias[i]);
        if (upper[i] == 0) break;
     }
     upper[i] = 0;
 
-    if (xmlCharEncodingAliases == NULL) {
-       xmlCharEncodingAliasesNb = 0;
-       xmlCharEncodingAliasesMax = 20;
-       xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
-             xmlMalloc(xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
-       if (xmlCharEncodingAliases == NULL)
-           return(-1);
-    } else if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
-       xmlCharEncodingAliasesMax *= 2;
-       xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
-             xmlRealloc(xmlCharEncodingAliases,
-                        xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
+    if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
+        xmlCharEncodingAliasPtr tmp;
+        size_t newSize = xmlCharEncodingAliasesMax ?
+                         xmlCharEncodingAliasesMax * 2 :
+                         20;
+
+        tmp = (xmlCharEncodingAliasPtr)
+              xmlRealloc(xmlCharEncodingAliases,
+                         newSize * sizeof(xmlCharEncodingAlias));
+        if (tmp == NULL)
+            return(-1);
+        xmlCharEncodingAliases = tmp;
+        xmlCharEncodingAliasesMax = newSize;
     }
+
     /*
      * Walk down the list looking for a definition of the alias
      */
@@ -1108,16 +1075,27 @@ xmlAddEncodingAlias(const char *name, const char *alias) {
            /*
             * Replace the definition.
             */
+           nameCopy = xmlMemStrdup(name);
+            if (nameCopy == NULL)
+                return(-1);
            xmlFree((char *) xmlCharEncodingAliases[i].name);
-           xmlCharEncodingAliases[i].name = xmlMemStrdup(name);
+           xmlCharEncodingAliases[i].name = nameCopy;
            return(0);
        }
     }
     /*
      * Add the definition
      */
-    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].name = xmlMemStrdup(name);
-    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].alias = xmlMemStrdup(upper);
+    nameCopy = xmlMemStrdup(name);
+    if (nameCopy == NULL)
+        return(-1);
+    aliasCopy = xmlMemStrdup(upper);
+    if (aliasCopy == NULL) {
+        xmlFree(nameCopy);
+        return(-1);
+    }
+    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].name = nameCopy;
+    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].alias = aliasCopy;
     xmlCharEncodingAliasesNb++;
     return(0);
 }
@@ -1184,7 +1162,7 @@ xmlParseCharEncoding(const char* name)
        name = alias;
 
     for (i = 0;i < 499;i++) {
-        upper[i] = toupper(name[i]);
+        upper[i] = (char) toupper((unsigned char) name[i]);
        if (upper[i] == 0) break;
     }
     upper[i] = 0;
@@ -1233,9 +1211,6 @@ xmlParseCharEncoding(const char* name)
     if (!strcmp(upper, "SHIFT_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
     if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
 
-#ifdef DEBUG_ENCODING
-    xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
-#endif
     return(XML_CHAR_ENCODING_ERROR);
 }
 
@@ -1311,19 +1286,100 @@ xmlGetCharEncodingName(xmlCharEncoding enc) {
  *                                                                     *
  ************************************************************************/
 
+#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED) && \
+    defined(LIBXML_ISO8859X_ENABLED)
+
+#define DECLARE_ISO_FUNCS(n) \
+    static int ISO8859_##n##ToUTF8(unsigned char* out, int *outlen, \
+                                   const unsigned char* in, int *inlen); \
+    static int UTF8ToISO8859_##n(unsigned char* out, int *outlen, \
+                                 const unsigned char* in, int *inlen);
+
+/** DOC_DISABLE */
+DECLARE_ISO_FUNCS(2)
+DECLARE_ISO_FUNCS(3)
+DECLARE_ISO_FUNCS(4)
+DECLARE_ISO_FUNCS(5)
+DECLARE_ISO_FUNCS(6)
+DECLARE_ISO_FUNCS(7)
+DECLARE_ISO_FUNCS(8)
+DECLARE_ISO_FUNCS(9)
+DECLARE_ISO_FUNCS(10)
+DECLARE_ISO_FUNCS(11)
+DECLARE_ISO_FUNCS(13)
+DECLARE_ISO_FUNCS(14)
+DECLARE_ISO_FUNCS(15)
+DECLARE_ISO_FUNCS(16)
+/** DOC_ENABLE */
+
+#endif /* LIBXML_ISO8859X_ENABLED */
+
+#ifdef LIBXML_ICONV_ENABLED
+  #define EMPTY_ICONV , (iconv_t) 0, (iconv_t) 0
+#else
+  #define EMPTY_ICONV
+#endif
+
+#ifdef LIBXML_ICU_ENABLED
+  #define EMPTY_UCONV , NULL, NULL
+#else
+  #define EMPTY_UCONV
+#endif
+
+#define MAKE_HANDLER(name, in, out) \
+    { (char *) name, in, out EMPTY_ICONV EMPTY_UCONV }
+
+static const xmlCharEncodingHandler defaultHandlers[] = {
+    MAKE_HANDLER("UTF-8", UTF8ToUTF8, UTF8ToUTF8)
+#ifdef LIBXML_OUTPUT_ENABLED
+    ,MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE)
+    ,MAKE_HANDLER("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE)
+    ,MAKE_HANDLER("UTF-16", UTF16LEToUTF8, UTF8ToUTF16)
+    ,MAKE_HANDLER("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1)
+    ,MAKE_HANDLER("ASCII", asciiToUTF8, UTF8Toascii)
+    ,MAKE_HANDLER("US-ASCII", asciiToUTF8, UTF8Toascii)
+#ifdef LIBXML_HTML_ENABLED
+    ,MAKE_HANDLER("HTML", NULL, UTF8ToHtml)
+#endif
+#else
+    ,MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, NULL)
+    ,MAKE_HANDLER("UTF-16BE", UTF16BEToUTF8, NULL)
+    ,MAKE_HANDLER("UTF-16", UTF16LEToUTF8, NULL)
+    ,MAKE_HANDLER("ISO-8859-1", isolat1ToUTF8, NULL)
+    ,MAKE_HANDLER("ASCII", asciiToUTF8, NULL)
+    ,MAKE_HANDLER("US-ASCII", asciiToUTF8, NULL)
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED) && \
+    defined(LIBXML_ISO8859X_ENABLED)
+    ,MAKE_HANDLER("ISO-8859-2", ISO8859_2ToUTF8, UTF8ToISO8859_2)
+    ,MAKE_HANDLER("ISO-8859-3", ISO8859_3ToUTF8, UTF8ToISO8859_3)
+    ,MAKE_HANDLER("ISO-8859-4", ISO8859_4ToUTF8, UTF8ToISO8859_4)
+    ,MAKE_HANDLER("ISO-8859-5", ISO8859_5ToUTF8, UTF8ToISO8859_5)
+    ,MAKE_HANDLER("ISO-8859-6", ISO8859_6ToUTF8, UTF8ToISO8859_6)
+    ,MAKE_HANDLER("ISO-8859-7", ISO8859_7ToUTF8, UTF8ToISO8859_7)
+    ,MAKE_HANDLER("ISO-8859-8", ISO8859_8ToUTF8, UTF8ToISO8859_8)
+    ,MAKE_HANDLER("ISO-8859-9", ISO8859_9ToUTF8, UTF8ToISO8859_9)
+    ,MAKE_HANDLER("ISO-8859-10", ISO8859_10ToUTF8, UTF8ToISO8859_10)
+    ,MAKE_HANDLER("ISO-8859-11", ISO8859_11ToUTF8, UTF8ToISO8859_11)
+    ,MAKE_HANDLER("ISO-8859-13", ISO8859_13ToUTF8, UTF8ToISO8859_13)
+    ,MAKE_HANDLER("ISO-8859-14", ISO8859_14ToUTF8, UTF8ToISO8859_14)
+    ,MAKE_HANDLER("ISO-8859-15", ISO8859_15ToUTF8, UTF8ToISO8859_15)
+    ,MAKE_HANDLER("ISO-8859-16", ISO8859_16ToUTF8, UTF8ToISO8859_16)
+#endif
+};
+
+#define NUM_DEFAULT_HANDLERS \
+    (sizeof(defaultHandlers) / sizeof(defaultHandlers[0]))
+
+static const xmlCharEncodingHandler *xmlUTF16LEHandler = &defaultHandlers[1];
+static const xmlCharEncodingHandler *xmlUTF16BEHandler = &defaultHandlers[2];
 
 /* the size should be growable, but it's not a big deal ... */
 #define MAX_ENCODING_HANDLERS 50
 static xmlCharEncodingHandlerPtr *handlers = NULL;
 static int nbCharEncodingHandler = 0;
 
-/*
- * The default is UTF-8 for XML, that's also the default used for the
- * parser internals, so the default encoding handler is NULL
- */
-
-static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
-
 /**
  * xmlNewCharEncodingHandler:
  * @name:  the encoding name, in UTF-8 format (ASCII actually)
@@ -1354,21 +1410,16 @@ xmlNewCharEncodingHandler(const char *name,
     /*
      * Keep only the uppercase version of the encoding.
      */
-    if (name == NULL) {
-        xmlEncodingErr(XML_I18N_NO_NAME,
-                      "xmlNewCharEncodingHandler : no name !\n", NULL);
+    if (name == NULL)
        return(NULL);
-    }
     for (i = 0;i < 499;i++) {
-        upper[i] = toupper(name[i]);
+        upper[i] = (char) toupper((unsigned char) name[i]);
        if (upper[i] == 0) break;
     }
     upper[i] = 0;
     up = xmlMemStrdup(upper);
-    if (up == NULL) {
-        xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
+    if (up == NULL)
        return(NULL);
-    }
 
     /*
      * allocate and fill-up an handler block.
@@ -1377,7 +1428,6 @@ xmlNewCharEncodingHandler(const char *name,
               xmlMalloc(sizeof(xmlCharEncodingHandler));
     if (handler == NULL) {
         xmlFree(up);
-        xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
        return(NULL);
     }
     memset(handler, 0, sizeof(xmlCharEncodingHandler));
@@ -1398,74 +1448,31 @@ xmlNewCharEncodingHandler(const char *name,
      * registers and returns the handler.
      */
     xmlRegisterCharEncodingHandler(handler);
-#ifdef DEBUG_ENCODING
-    xmlGenericError(xmlGenericErrorContext,
-           "Registered encoding handler for %s\n", name);
-#endif
     return(handler);
 }
 
 /**
  * xmlInitCharEncodingHandlers:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
- *
- * Initialize the char encoding support, it registers the default
- * encoding supported.
- * NOTE: while public, this function usually doesn't need to be called
- *       in normal processing.
+ * DEPRECATED: Alias for xmlInitParser.
  */
 void
 xmlInitCharEncodingHandlers(void) {
+    xmlInitParser();
+}
+
+/**
+ * xmlInitEncodingInternal:
+ *
+ * Initialize the char encoding support.
+ */
+void
+xmlInitEncodingInternal(void) {
     unsigned short int tst = 0x1234;
     unsigned char *ptr = (unsigned char *) &tst;
 
-    if (handlers != NULL) return;
-
-    handlers = (xmlCharEncodingHandlerPtr *)
-        xmlMalloc(MAX_ENCODING_HANDLERS * sizeof(xmlCharEncodingHandlerPtr));
-
     if (*ptr == 0x12) xmlLittleEndian = 0;
-    else if (*ptr == 0x34) xmlLittleEndian = 1;
-    else {
-        xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
-                      "Odd problem at endianness detection\n", NULL);
-    }
-
-    if (handlers == NULL) {
-        xmlEncodingErrMemory("xmlInitCharEncodingHandlers : out of memory !\n");
-       return;
-    }
-    xmlNewCharEncodingHandler("UTF-8", UTF8ToUTF8, UTF8ToUTF8);
-#ifdef LIBXML_OUTPUT_ENABLED
-    xmlUTF16LEHandler =
-          xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
-    xmlUTF16BEHandler =
-          xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
-    xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
-    xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
-    xmlNewCharEncodingHandler("ASCII", asciiToUTF8, UTF8Toascii);
-    xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, UTF8Toascii);
-#ifdef LIBXML_HTML_ENABLED
-    xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
-#endif
-#else
-    xmlUTF16LEHandler =
-          xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, NULL);
-    xmlUTF16BEHandler =
-          xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, NULL);
-    xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, NULL);
-    xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, NULL);
-    xmlNewCharEncodingHandler("ASCII", asciiToUTF8, NULL);
-    xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, NULL);
-#endif /* LIBXML_OUTPUT_ENABLED */
-#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
-#ifdef LIBXML_ISO8859X_ENABLED
-    xmlRegisterCharEncodingHandlersISO8859x ();
-#endif
-#endif
-
+    else xmlLittleEndian = 1;
 }
 
 /**
@@ -1496,7 +1503,6 @@ xmlCleanupCharEncodingHandlers(void) {
     xmlFree(handlers);
     handlers = NULL;
     nbCharEncodingHandler = 0;
-    xmlDefaultCharEncodingHandler = NULL;
 }
 
 /**
@@ -1507,19 +1513,16 @@ xmlCleanupCharEncodingHandlers(void) {
  */
 void
 xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
-    if (handlers == NULL) xmlInitCharEncodingHandlers();
-    if ((handler == NULL) || (handlers == NULL)) {
-        xmlEncodingErr(XML_I18N_NO_HANDLER,
-               "xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
-        goto free_handler;
+    if (handler == NULL)
+        return;
+    if (handlers == NULL) {
+        handlers = xmlMalloc(MAX_ENCODING_HANDLERS * sizeof(handlers[0]));
+        if (handlers == NULL)
+            goto free_handler;
     }
 
-    if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
-        xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
-       "xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
-                      "MAX_ENCODING_HANDLERS");
+    if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS)
         goto free_handler;
-    }
     handlers[nbCharEncodingHandler++] = handler;
     return;
 
@@ -1544,7 +1547,6 @@ xmlCharEncodingHandlerPtr
 xmlGetCharEncodingHandler(xmlCharEncoding enc) {
     xmlCharEncodingHandlerPtr handler;
 
-    if (handlers == NULL) xmlInitCharEncodingHandlers();
     switch (enc) {
         case XML_CHAR_ENCODING_ERROR:
            return(NULL);
@@ -1553,9 +1555,9 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
         case XML_CHAR_ENCODING_UTF8:
            return(NULL);
         case XML_CHAR_ENCODING_UTF16LE:
-           return(xmlUTF16LEHandler);
+           return((xmlCharEncodingHandlerPtr) xmlUTF16LEHandler);
         case XML_CHAR_ENCODING_UTF16BE:
-           return(xmlUTF16BEHandler);
+           return((xmlCharEncodingHandlerPtr) xmlUTF16BEHandler);
         case XML_CHAR_ENCODING_EBCDIC:
             handler = xmlFindCharEncodingHandler("EBCDIC");
             if (handler != NULL) return(handler);
@@ -1659,10 +1661,6 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
            break;
     }
 
-#ifdef DEBUG_ENCODING
-    xmlGenericError(xmlGenericErrorContext,
-           "No handler found for encoding %d\n", enc);
-#endif
     return(NULL);
 }
 
@@ -1670,7 +1668,8 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
  * xmlFindCharEncodingHandler:
  * @name:  a string describing the char encoding.
  *
- * Search in the registered set the handler able to read/write that encoding.
+ * Search in the registered set the handler able to read/write that encoding
+ * or create a new one.
  *
  * Returns the handler or NULL if not found
  */
@@ -1690,9 +1689,8 @@ xmlFindCharEncodingHandler(const char *name) {
     char upper[100];
     int i;
 
-    if (handlers == NULL) xmlInitCharEncodingHandlers();
-    if (name == NULL) return(xmlDefaultCharEncodingHandler);
-    if (name[0] == 0) return(xmlDefaultCharEncodingHandler);
+    if (name == NULL) return(NULL);
+    if (name[0] == 0) return(NULL);
 
     /*
      * Do the alias resolution
@@ -1706,18 +1704,19 @@ xmlFindCharEncodingHandler(const char *name) {
      * Check first for directly registered encoding names
      */
     for (i = 0;i < 99;i++) {
-        upper[i] = toupper(name[i]);
+        upper[i] = (char) toupper((unsigned char) name[i]);
        if (upper[i] == 0) break;
     }
     upper[i] = 0;
 
+    for (i = 0; i < (int) NUM_DEFAULT_HANDLERS; i++) {
+        if (strcmp(upper, defaultHandlers[i].name) == 0)
+            return((xmlCharEncodingHandlerPtr) &defaultHandlers[i]);
+    }
+
     if (handlers != NULL) {
         for (i = 0;i < nbCharEncodingHandler; i++) {
             if (!strcmp(upper, handlers[i]->name)) {
-#ifdef DEBUG_ENCODING
-                xmlGenericError(xmlGenericErrorContext,
-                        "Found registered handler for encoding %s\n", name);
-#endif
                 return(handlers[i]);
             }
         }
@@ -1743,18 +1742,18 @@ xmlFindCharEncodingHandler(const char *name) {
            }
             memset(enc, 0, sizeof(xmlCharEncodingHandler));
            enc->name = xmlMemStrdup(name);
+            if (enc->name == NULL) {
+                xmlFree(enc);
+                iconv_close(icv_in);
+                iconv_close(icv_out);
+                return(NULL);
+            }
            enc->input = NULL;
            enc->output = NULL;
            enc->iconv_in = icv_in;
            enc->iconv_out = icv_out;
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                   "Found iconv handler for encoding %s\n", name);
-#endif
            return enc;
     } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
-           xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
-                   "iconv : problems with filters for '%s'\n", name);
            if (icv_in != (iconv_t) -1)
                iconv_close(icv_in);
            else
@@ -1775,28 +1774,23 @@ xmlFindCharEncodingHandler(const char *name) {
            }
             memset(encu, 0, sizeof(xmlCharEncodingHandler));
            encu->name = xmlMemStrdup(name);
+            if (encu->name == NULL) {
+                xmlFree(encu);
+                closeIcuConverter(ucv_in);
+                closeIcuConverter(ucv_out);
+                return(NULL);
+            }
            encu->input = NULL;
            encu->output = NULL;
            encu->uconv_in = ucv_in;
            encu->uconv_out = ucv_out;
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                   "Found ICU converter handler for encoding %s\n", name);
-#endif
            return encu;
     } else if (ucv_in != NULL || ucv_out != NULL) {
             closeIcuConverter(ucv_in);
             closeIcuConverter(ucv_out);
-           xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
-                   "ICU converter : problems with filters for '%s'\n", name);
     }
 #endif /* LIBXML_ICU_ENABLED */
 
-#ifdef DEBUG_ENCODING
-    xmlGenericError(xmlGenericErrorContext,
-           "No handler found for encoding %s\n", name);
-#endif
-
     /*
      * Fallback using the canonical names
      */
@@ -1828,11 +1822,7 @@ xmlFindCharEncodingHandler(const char *name) {
  * @in:  a pointer to an array of input bytes
  * @inlen:  the length of @in
  *
- * Returns 0 if success, or
- *     -1 by lack of space, or
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- *     -3 if there the last byte can't form a single output char.
+ * Returns an XML_ENC_ERR code.
  *
  * The value of @inlen after return is the number of octets consumed
  *     as the return value is positive, else unpredictable.
@@ -1848,7 +1838,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
 
     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
         if (outlen != NULL) *outlen = 0;
-        return(-1);
+        return(XML_ENC_ERR_INTERNAL);
     }
     icv_inlen = *inlen;
     icv_outlen = *outlen;
@@ -1858,27 +1848,16 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
     ret = iconv(cd, (void *) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
     *inlen -= icv_inlen;
     *outlen -= icv_outlen;
-    if ((icv_inlen != 0) || (ret == (size_t) -1)) {
-#ifdef EILSEQ
-        if (errno == EILSEQ) {
-            return -2;
-        } else
-#endif
-#ifdef E2BIG
-        if (errno == E2BIG) {
-            return -1;
-        } else
-#endif
-#ifdef EINVAL
-        if (errno == EINVAL) {
-            return -3;
-        } else
-#endif
-        {
-            return -3;
-        }
+    if (ret == (size_t) -1) {
+        if (errno == EILSEQ)
+            return(XML_ENC_ERR_INPUT);
+        if (errno == E2BIG)
+            return(XML_ENC_ERR_SPACE);
+        if (errno == EINVAL)
+            return(XML_ENC_ERR_PARTIAL);
+        return(XML_ENC_ERR_INTERNAL);
     }
-    return 0;
+    return(XML_ENC_ERR_SUCCESS);
 }
 #endif /* LIBXML_ICONV_ENABLED */
 
@@ -1897,13 +1876,8 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
  * @outlen:  the length of @out
  * @in:  a pointer to an array of input bytes
  * @inlen:  the length of @in
- * @flush: if true, indicates end of input
  *
- * Returns 0 if success, or
- *     -1 by lack of space, or
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- *     -3 if there the last byte can't form a single output char.
+ * Returns an XML_ENC_ERR code.
  *
  * The value of @inlen after return is the number of octets consumed
  *     as the return value is positive, else unpredictable.
@@ -1911,42 +1885,53 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
  */
 static int
 xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
-                const unsigned char *in, int *inlen, int flush) {
+                const unsigned char *in, int *inlen) {
     const char *ucv_in = (const char *) in;
     char *ucv_out = (char *) out;
     UErrorCode err = U_ZERO_ERROR;
 
     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
         if (outlen != NULL) *outlen = 0;
-        return(-1);
+        return(XML_ENC_ERR_INTERNAL);
     }
 
+    /*
+     * Note that the ICU API is stateful. It can always consume a certain
+     * amount of input even if the output buffer would overflow. The
+     * remaining input must be processed by calling ucnv_convertEx with a
+     * possibly empty input buffer.
+     *
+     * ucnv_convertEx is always called with reset and flush set to 0,
+     * so we don't mess up the state. This should never generate
+     * U_TRUNCATED_CHAR_FOUND errors.
+     *
+     * This also means that ICU xmlCharEncodingHandlers should never be
+     * reused. It would be a lot nicer if there was a way to emulate the
+     * stateless iconv API.
+     */
     if (toUnicode) {
         /* encoding => UTF-16 => UTF-8 */
         ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
                        &ucv_in, ucv_in + *inlen, cd->pivot_buf,
                        &cd->pivot_source, &cd->pivot_target,
-                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
+                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err);
     } else {
         /* UTF-8 => UTF-16 => encoding */
         ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
                        &ucv_in, ucv_in + *inlen, cd->pivot_buf,
                        &cd->pivot_source, &cd->pivot_target,
-                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
+                       cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err);
     }
     *inlen = ucv_in - (const char*) in;
     *outlen = ucv_out - (char *) out;
     if (U_SUCCESS(err)) {
-        /* reset pivot buf if this is the last call for input (flush==TRUE) */
-        if (flush)
-            cd->pivot_source = cd->pivot_target = cd->pivot_buf;
-        return 0;
+        return(XML_ENC_ERR_SUCCESS);
     }
     if (err == U_BUFFER_OVERFLOW_ERROR)
-        return -1;
+        return(XML_ENC_ERR_SPACE);
     if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
-        return -2;
-    return -3;
+        return(XML_ENC_ERR_INPUT);
+    return(XML_ENC_ERR_PARTIAL);
 }
 #endif /* LIBXML_ICU_ENABLED */
 
@@ -1957,34 +1942,69 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
  ************************************************************************/
 
 /**
+ * xmlEncConvertError:
+ * @code:  XML_ENC_ERR code
+ *
+ * Convert XML_ENC_ERR to libxml2 error codes.
+ */
+static int
+xmlEncConvertError(int code) {
+    int ret;
+
+    switch (code) {
+        case XML_ENC_ERR_SUCCESS:
+            ret = XML_ERR_OK;
+            break;
+        case XML_ENC_ERR_INPUT:
+            ret = XML_ERR_INVALID_ENCODING;
+            break;
+        case XML_ENC_ERR_MEMORY:
+            ret = XML_ERR_NO_MEMORY;
+            break;
+        default:
+            ret = XML_ERR_INTERNAL_ERROR;
+            break;
+    }
+
+    return(ret);
+}
+
+/**
  * xmlEncInputChunk:
  * @handler:  encoding handler
  * @out:  a pointer to an array of bytes to store the result
  * @outlen:  the length of @out
  * @in:  a pointer to an array of input bytes
  * @inlen:  the length of @in
- * @flush:  flush (ICU-related)
- *
- * Returns 0 if success, or
- *     -1 by lack of space, or
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- *     -3 if there the last byte can't form a single output char.
  *
  * The value of @inlen after return is the number of octets consumed
  *     as the return value is 0, else unpredictable.
  * The value of @outlen after return is the number of octets produced.
+ *
+ * Returns an XML_ENC_ERR code.
  */
-static int
+int
 xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
-                 int *outlen, const unsigned char *in, int *inlen, int flush) {
+                 int *outlen, const unsigned char *in, int *inlen) {
     int ret;
-    (void)flush;
 
     if (handler->input != NULL) {
+        int oldinlen = *inlen;
+
         ret = handler->input(out, outlen, in, inlen);
-        if (ret > 0)
-           ret = 0;
+        if (ret >= 0) {
+            /*
+             * The built-in converters don't signal XML_ENC_ERR_SPACE.
+             */
+            if (*inlen < oldinlen) {
+                if (*outlen > 0)
+                    ret = XML_ENC_ERR_SPACE;
+                else
+                    ret = XML_ENC_ERR_PARTIAL;
+            } else {
+                ret = XML_ENC_ERR_SUCCESS;
+            }
+        }
     }
 #ifdef LIBXML_ICONV_ENABLED
     else if (handler->iconv_in != NULL) {
@@ -1993,16 +2013,19 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
     else if (handler->uconv_in != NULL) {
-        ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen,
-                              flush);
+        ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen);
     }
 #endif /* LIBXML_ICU_ENABLED */
     else {
         *outlen = 0;
         *inlen = 0;
-        ret = -2;
+        ret = XML_ENC_ERR_INTERNAL;
     }
 
+    /* Ignore partial errors when reading. */
+    if (ret == XML_ENC_ERR_PARTIAL)
+        ret = XML_ENC_ERR_SUCCESS;
+
     return(ret);
 }
 
@@ -2014,12 +2037,7 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
  * @in:  a pointer to an array of input bytes
  * @inlen:  the length of @in
  *
- * Returns 0 if success, or
- *     -1 by lack of space, or
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- *     -3 if there the last byte can't form a single output char.
- *     -4 if no output function was found.
+ * Returns an XML_ENC_ERR code.
  *
  * The value of @inlen after return is the number of octets consumed
  *     as the return value is 0, else unpredictable.
@@ -2031,9 +2049,22 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
     int ret;
 
     if (handler->output != NULL) {
+        int oldinlen = *inlen;
+
         ret = handler->output(out, outlen, in, inlen);
-        if (ret > 0)
-           ret = 0;
+        if (ret >= 0) {
+            /*
+             * The built-in converters don't signal XML_ENC_ERR_SPACE.
+             */
+            if (*inlen < oldinlen) {
+                if (*outlen > 0)
+                    ret = XML_ENC_ERR_SPACE;
+                else
+                    ret = XML_ENC_ERR_PARTIAL;
+            } else {
+                ret = XML_ENC_ERR_SUCCESS;
+            }
+        }
     }
 #ifdef LIBXML_ICONV_ENABLED
     else if (handler->iconv_out != NULL) {
@@ -2042,328 +2073,109 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
     else if (handler->uconv_out != NULL) {
-        ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen,
-                              1);
+        ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen);
     }
 #endif /* LIBXML_ICU_ENABLED */
     else {
         *outlen = 0;
         *inlen = 0;
-        ret = -4;
+        ret = XML_ENC_ERR_INTERNAL;
     }
 
-    return(ret);
-}
-
-/**
- * xmlCharEncFirstLineInt:
- * @handler:   char encoding transformation data structure
- * @out:  an xmlBuffer for the output.
- * @in:  an xmlBuffer for the input
- * @len:  number of bytes to convert for the first line, or -1
- *
- * Front-end for the encoding handler input function, but handle only
- * the very first line, i.e. limit itself to 45 chars.
- *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- */
-int
-xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
-                       xmlBufferPtr in, int len) {
-    int ret;
-    int written;
-    int toconv;
-
-    if (handler == NULL) return(-1);
-    if (out == NULL) return(-1);
-    if (in == NULL) return(-1);
-
-    /* calculate space available */
-    written = out->size - out->use - 1; /* count '\0' */
-    toconv = in->use;
-    /*
-     * 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
-     * The actual value depending on guessed encoding is passed as @len
-     * if provided
-     */
-    if (len >= 0) {
-        if (toconv > len)
-            toconv = len;
-    } else {
-        if (toconv > 180)
-            toconv = 180;
-    }
-    if (toconv * 2 >= written) {
-        xmlBufferGrow(out, toconv * 2);
-       written = out->size - out->use - 1;
-    }
+    /* We shouldn't generate partial sequences when writing. */
+    if (ret == XML_ENC_ERR_PARTIAL)
+        ret = XML_ENC_ERR_INTERNAL;
 
-    ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
-                           in->content, &toconv, 0);
-    xmlBufferShrink(in, toconv);
-    out->use += written;
-    out->content[out->use] = 0;
-    if (ret == -1) ret = -3;
-
-#ifdef DEBUG_ENCODING
-    switch (ret) {
-        case 0:
-           xmlGenericError(xmlGenericErrorContext,
-                   "converted %d bytes to %d bytes of input\n",
-                   toconv, written);
-           break;
-        case -1:
-           xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
-                   toconv, written, in->use);
-           break;
-        case -2:
-           xmlGenericError(xmlGenericErrorContext,
-                   "input conversion failed due to input error\n");
-           break;
-        case -3:
-           xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
-                   toconv, written, in->use);
-           break;
-       default:
-           xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
-    }
-#endif /* DEBUG_ENCODING */
-    /*
-     * Ignore when input buffer is not on a boundary
-     */
-    if (ret == -3) ret = 0;
-    if (ret == -1) ret = 0;
-    return(written ? written : ret);
+    return(ret);
 }
 
 /**
  * xmlCharEncFirstLine:
- * @handler:   char encoding transformation data structure
+ * @handler:   char encoding transformation data structure
  * @out:  an xmlBuffer for the output.
  * @in:  an xmlBuffer for the input
  *
- * Front-end for the encoding handler input function, but handle only
- * the very first line, i.e. limit itself to 45 chars.
+ * DEPERECATED: Don't use.
  *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 int
 xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
-                 xmlBufferPtr in) {
-    return(xmlCharEncFirstLineInt(handler, out, in, -1));
+                    xmlBufferPtr in) {
+    return(xmlCharEncInFunc(handler, out, in));
 }
 
 /**
- * xmlCharEncFirstLineInput:
+ * xmlCharEncInput:
  * @input: a parser input buffer
- * @len:  number of bytes to convert for the first line, or -1
  *
- * Front-end for the encoding handler input function, but handle only
- * the very first line. Point is that this is based on autodetection
- * of the encoding and once that first line is converted we may find
- * out that a different decoder is needed to process the input.
+ * Generic front-end for the encoding handler on parser input
  *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 int
-xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
+xmlCharEncInput(xmlParserInputBufferPtr input)
 {
     int ret;
-    size_t written;
+    size_t avail;
     size_t toconv;
     int c_in;
     int c_out;
     xmlBufPtr in;
     xmlBufPtr out;
+    const xmlChar *inData;
+    size_t inTotal = 0;
 
     if ((input == NULL) || (input->encoder == NULL) ||
         (input->buffer == NULL) || (input->raw == NULL))
-        return (-1);
+        return(XML_ENC_ERR_INTERNAL);
     out = input->buffer;
     in = input->raw;
 
     toconv = xmlBufUse(in);
     if (toconv == 0)
         return (0);
-    written = xmlBufAvail(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
-     * The actual value depending on guessed encoding is passed as @len
-     * if provided
-     */
-    if (len >= 0) {
-        if (toconv > (unsigned int) len)
-            toconv = len;
-    } else {
-        if (toconv > 180)
-            toconv = 180;
-    }
-    if (toconv * 2 >= written) {
-        xmlBufGrow(out, toconv * 2);
-        written = xmlBufAvail(out);
-    }
-    if (written > 360)
-        written = 360;
-
-    c_in = toconv;
-    c_out = written;
-    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
-                           xmlBufContent(in), &c_in, 0);
-    xmlBufShrink(in, c_in);
-    xmlBufAddLen(out, c_out);
-    if (ret == -1)
-        ret = -3;
-
-    switch (ret) {
-        case 0:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                            "converted %d bytes to %d bytes of input\n",
-                            c_in, c_out);
-#endif
-            break;
-        case -1:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                         "converted %d bytes to %d bytes of input, %d left\n",
-                            c_in, c_out, (int)xmlBufUse(in));
-#endif
-            break;
-        case -3:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                        "converted %d bytes to %d bytes of input, %d left\n",
-                            c_in, c_out, (int)xmlBufUse(in));
-#endif
-            break;
-        case -2: {
-            char buf[50];
-            const xmlChar *content = xmlBufContent(in);
-
-           snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
-                    content[0], content[1],
-                    content[2], content[3]);
-           buf[49] = 0;
-           xmlEncodingErr(XML_I18N_CONV_FAILED,
-                   "input conversion failed due to input error, bytes %s\n",
-                          buf);
+    inData = xmlBufContent(in);
+    inTotal = 0;
+
+    do {
+        c_in = toconv > INT_MAX / 2 ? INT_MAX / 2 : toconv;
+
+        avail = xmlBufAvail(out);
+        if (avail > INT_MAX)
+            avail = INT_MAX;
+        if (avail < 4096) {
+            if (xmlBufGrow(out, 4096) < 0) {
+                input->error = XML_ERR_NO_MEMORY;
+                return(XML_ENC_ERR_MEMORY);
+            }
+            avail = xmlBufAvail(out);
         }
-    }
-    /*
-     * Ignore when input buffer is not on a boundary
-     */
-    if (ret == -3) ret = 0;
-    if (ret == -1) ret = 0;
-    return(c_out ? c_out : ret);
-}
 
-/**
- * xmlCharEncInput:
- * @input: a parser input buffer
- * @flush: try to flush all the raw buffer
- *
- * Generic front-end for the encoding handler on parser input
- *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
- */
-int
-xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
-{
-    int ret;
-    size_t written;
-    size_t toconv;
-    int c_in;
-    int c_out;
-    xmlBufPtr in;
-    xmlBufPtr out;
+        c_in = toconv;
+        c_out = avail;
+        ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
+                               inData, &c_in);
+        inTotal += c_in;
+        inData += c_in;
+        toconv -= c_in;
+        xmlBufAddLen(out, c_out);
+    } while (ret == XML_ENC_ERR_SPACE);
 
-    if ((input == NULL) || (input->encoder == NULL) ||
-        (input->buffer == NULL) || (input->raw == NULL))
-        return (-1);
-    out = input->buffer;
-    in = input->raw;
+    xmlBufShrink(in, inTotal);
 
-    toconv = xmlBufUse(in);
-    if (toconv == 0)
-        return (0);
-    if ((toconv > 64 * 1024) && (flush == 0))
-        toconv = 64 * 1024;
-    written = xmlBufAvail(out);
-    if (toconv * 2 >= written) {
-        xmlBufGrow(out, toconv * 2);
-        written = xmlBufAvail(out);
-    }
-    if ((written > 128 * 1024) && (flush == 0))
-        written = 128 * 1024;
+    if (input->rawconsumed > ULONG_MAX - (unsigned long)c_in)
+        input->rawconsumed = ULONG_MAX;
+    else
+        input->rawconsumed += c_in;
 
-    c_in = toconv;
-    c_out = written;
-    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
-                           xmlBufContent(in), &c_in, flush);
-    xmlBufShrink(in, c_in);
-    xmlBufAddLen(out, c_out);
-    if (ret == -1)
-        ret = -3;
-
-    switch (ret) {
-        case 0:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                            "converted %d bytes to %d bytes of input\n",
-                            c_in, c_out);
-#endif
-            break;
-        case -1:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                         "converted %d bytes to %d bytes of input, %d left\n",
-                            c_in, c_out, (int)xmlBufUse(in));
-#endif
-            break;
-        case -3:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                        "converted %d bytes to %d bytes of input, %d left\n",
-                            c_in, c_out, (int)xmlBufUse(in));
-#endif
-            break;
-        case -2: {
-            char buf[50];
-            const xmlChar *content = xmlBufContent(in);
-
-           snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
-                    content[0], content[1],
-                    content[2], content[3]);
-           buf[49] = 0;
-           xmlEncodingErr(XML_I18N_CONV_FAILED,
-                   "input conversion failed due to input error, bytes %s\n",
-                          buf);
-        }
+    if ((c_out == 0) && (ret != 0)) {
+        if (input->error == 0)
+            input->error = xmlEncConvertError(ret);
+        return(ret);
     }
-    /*
-     * Ignore when input buffer is not on a boundary
-     */
-    if (ret == -3)
-        ret = 0;
-    return (c_out? c_out : ret);
+
+    return (c_out);
 }
 
 /**
@@ -2374,10 +2186,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
  *
  * Generic front-end for the encoding handler input function
  *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 int
 xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
@@ -2388,11 +2197,11 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
     int toconv;
 
     if (handler == NULL)
-        return (-1);
+        return(XML_ENC_ERR_INTERNAL);
     if (out == NULL)
-        return (-1);
+        return(XML_ENC_ERR_INTERNAL);
     if (in == NULL)
-        return (-1);
+        return(XML_ENC_ERR_INTERNAL);
 
     toconv = in->use;
     if (toconv == 0)
@@ -2403,52 +2212,11 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
         written = out->size - out->use - 1;
     }
     ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
-                           in->content, &toconv, 1);
+                           in->content, &toconv);
     xmlBufferShrink(in, toconv);
     out->use += written;
     out->content[out->use] = 0;
-    if (ret == -1)
-        ret = -3;
-
-    switch (ret) {
-        case 0:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                            "converted %d bytes to %d bytes of input\n",
-                            toconv, written);
-#endif
-            break;
-        case -1:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                         "converted %d bytes to %d bytes of input, %d left\n",
-                            toconv, written, in->use);
-#endif
-            break;
-        case -3:
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                        "converted %d bytes to %d bytes of input, %d left\n",
-                            toconv, written, in->use);
-#endif
-            break;
-        case -2: {
-            char buf[50];
-
-           snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
-                    in->content[0], in->content[1],
-                    in->content[2], in->content[3]);
-           buf[49] = 0;
-           xmlEncodingErr(XML_I18N_CONV_FAILED,
-                   "input conversion failed due to input error, bytes %s\n",
-                          buf);
-        }
-    }
-    /*
-     * Ignore when input buffer is not on a boundary
-     */
-    if (ret == -3)
-        ret = 0;
+
     return (written? written : ret);
 }
 
@@ -2465,10 +2233,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
  * In case of UTF8 sequence conversion errors for the given encoder,
  * the content will be automatically remapped to a CharRef sequence.
  *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 int
 xmlCharEncOutput(xmlOutputBufferPtr output, int init)
@@ -2484,7 +2249,7 @@ xmlCharEncOutput(xmlOutputBufferPtr output, int init)
 
     if ((output == NULL) || (output->encoder == NULL) ||
         (output->buffer == NULL) || (output->conv == NULL))
-        return (-1);
+        return(XML_ENC_ERR_INTERNAL);
     out = output->conv;
     in = output->buffer;
 
@@ -2502,10 +2267,6 @@ retry:
         xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
                           NULL, &c_in);
         xmlBufAddLen(out, c_out);
-#ifdef DEBUG_ENCODING
-       xmlGenericError(xmlGenericErrorContext,
-               "initialized encoder\n");
-#endif
         return(c_out);
     }
 
@@ -2513,8 +2274,6 @@ retry:
      * Conversion itself.
      */
     toconv = xmlBufUse(in);
-    if (toconv == 0)
-        return (writtentot);
     if (toconv > 64 * 1024)
         toconv = 64 * 1024;
     if (toconv * 4 >= written) {
@@ -2531,95 +2290,54 @@ retry:
     xmlBufShrink(in, c_in);
     xmlBufAddLen(out, c_out);
     writtentot += c_out;
-    if (ret == -1) {
-        if (c_out > 0) {
-            /* Can be a limitation of iconv or uconv */
-            goto retry;
-        }
-        ret = -3;
-    }
+
+    if (ret == XML_ENC_ERR_SPACE)
+        goto retry;
 
     /*
      * Attempt to handle error cases
      */
-    switch (ret) {
-        case 0:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,
-                   "converted %d bytes to %d bytes of output\n",
-                   c_in, c_out);
-#endif
-           break;
-        case -1:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,
-                   "output conversion failed by lack of space\n");
-#endif
-           break;
-        case -3:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
-                   c_in, c_out, (int) xmlBufUse(in));
-#endif
-           break;
-        case -4:
-            xmlEncodingErr(XML_I18N_NO_OUTPUT,
-                           "xmlCharEncOutFunc: no output function !\n", NULL);
-            ret = -1;
-            break;
-        case -2: {
-           xmlChar charref[20];
-           int len = (int) xmlBufUse(in);
-            xmlChar *content = xmlBufContent(in);
-           int cur, charrefLen;
-
-           cur = xmlGetUTF8Char(content, &len);
-           if (cur <= 0)
-                break;
+    if (ret == XML_ENC_ERR_INPUT) {
+        xmlChar charref[20];
+        int len = xmlBufUse(in);
+        xmlChar *content = xmlBufContent(in);
+        int cur, charrefLen;
 
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                    "handling output conversion error\n");
-            xmlGenericError(xmlGenericErrorContext,
-                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-                    content[0], content[1],
-                    content[2], content[3]);
-#endif
-            /*
-             * Removes the UTF8 sequence, and replace it by a charref
-             * and continue the transcoding phase, hoping the error
-             * did not mangle the encoder state.
-             */
-            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
-                             "&#%d;", cur);
-            xmlBufShrink(in, len);
-            xmlBufGrow(out, charrefLen * 4);
-            c_out = xmlBufAvail(out);
-            c_in = charrefLen;
-            ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
-                                    charref, &c_in);
-
-           if ((ret < 0) || (c_in != charrefLen)) {
-               char buf[50];
-
-               snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
-                        content[0], content[1],
-                        content[2], content[3]);
-               buf[49] = 0;
-               xmlEncodingErr(XML_I18N_CONV_FAILED,
-                   "output conversion failed due to conv error, bytes %s\n",
-                              buf);
-               if (xmlBufGetAllocationScheme(in) != XML_BUFFER_ALLOC_IMMUTABLE)
-                   content[0] = ' ';
-                break;
-           }
+        cur = xmlGetUTF8Char(content, &len);
+        if (cur <= 0)
+            goto error;
 
-            xmlBufAddLen(out, c_out);
-            writtentot += c_out;
-            goto retry;
-       }
+        /*
+         * Removes the UTF8 sequence, and replace it by a charref
+         * and continue the transcoding phase, hoping the error
+         * did not mangle the encoder state.
+         */
+        charrefLen = snprintf((char *) &charref[0], sizeof(charref),
+                         "&#%d;", cur);
+        xmlBufShrink(in, len);
+        xmlBufGrow(out, charrefLen * 4);
+        c_out = xmlBufAvail(out);
+        c_in = charrefLen;
+        ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
+                                charref, &c_in);
+        if ((ret < 0) || (c_in != charrefLen)) {
+            ret = XML_ENC_ERR_INTERNAL;
+            goto error;
+        }
+
+        xmlBufAddLen(out, c_out);
+        writtentot += c_out;
+        goto retry;
     }
-    return(writtentot ? writtentot : ret);
+
+error:
+    if ((writtentot <= 0) && (ret != 0)) {
+        if (output->error == 0)
+            output->error = xmlEncConvertError(ret);
+        return(ret);
+    }
+
+    return(writtentot);
 }
 #endif
 
@@ -2636,10 +2354,7 @@ retry:
  * In case of UTF8 sequence conversion errors for the given encoder,
  * the content will be automatically remapped to a CharRef sequence.
  *
- * Returns the number of byte written if success, or
- *     -1 general error
- *     -2 if the transcoding fails (for *in is not valid utf8 string or
- *        the result of transformation can't fit into the encoding we want), or
+ * Returns the number of bytes written or an XML_ENC_ERR code.
  */
 int
 xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
@@ -2649,8 +2364,8 @@ xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
     int writtentot = 0;
     int toconv;
 
-    if (handler == NULL) return(-1);
-    if (out == NULL) return(-1);
+    if (handler == NULL) return(XML_ENC_ERR_INTERNAL);
+    if (out == NULL) return(XML_ENC_ERR_INTERNAL);
 
 retry:
 
@@ -2669,10 +2384,6 @@ retry:
                           NULL, &toconv);
         out->use += written;
         out->content[out->use] = 0;
-#ifdef DEBUG_ENCODING
-       xmlGenericError(xmlGenericErrorContext,
-               "initialized encoder\n");
-#endif
         return(0);
     }
 
@@ -2680,8 +2391,6 @@ retry:
      * Conversion itself.
      */
     toconv = in->use;
-    if (toconv == 0)
-       return(0);
     if (toconv * 4 >= written) {
         xmlBufferGrow(out, toconv * 4);
        written = out->size - out->use - 1;
@@ -2692,94 +2401,43 @@ retry:
     out->use += written;
     writtentot += written;
     out->content[out->use] = 0;
-    if (ret == -1) {
-        if (written > 0) {
-            /* Can be a limitation of iconv or uconv */
-            goto retry;
-        }
-        ret = -3;
-    }
+
+    if (ret == XML_ENC_ERR_SPACE)
+        goto retry;
 
     /*
      * Attempt to handle error cases
      */
-    switch (ret) {
-        case 0:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,
-                   "converted %d bytes to %d bytes of output\n",
-                   toconv, written);
-#endif
-           break;
-        case -1:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,
-                   "output conversion failed by lack of space\n");
-#endif
-           break;
-        case -3:
-#ifdef DEBUG_ENCODING
-           xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
-                   toconv, written, in->use);
-#endif
-           break;
-        case -4:
-           xmlEncodingErr(XML_I18N_NO_OUTPUT,
-                          "xmlCharEncOutFunc: no output function !\n", NULL);
-           ret = -1;
-            break;
-        case -2: {
-           xmlChar charref[20];
-           int len = in->use;
-           const xmlChar *utf = (const xmlChar *) in->content;
-           int cur, charrefLen;
-
-           cur = xmlGetUTF8Char(utf, &len);
-           if (cur <= 0)
-                break;
+    if (ret == XML_ENC_ERR_INPUT) {
+        xmlChar charref[20];
+        int len = in->use;
+        const xmlChar *utf = (const xmlChar *) in->content;
+        int cur, charrefLen;
 
-#ifdef DEBUG_ENCODING
-            xmlGenericError(xmlGenericErrorContext,
-                    "handling output conversion error\n");
-            xmlGenericError(xmlGenericErrorContext,
-                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-                    in->content[0], in->content[1],
-                    in->content[2], in->content[3]);
-#endif
-            /*
-             * Removes the UTF8 sequence, and replace it by a charref
-             * and continue the transcoding phase, hoping the error
-             * did not mangle the encoder state.
-             */
-            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
-                             "&#%d;", cur);
-            xmlBufferShrink(in, len);
-            xmlBufferGrow(out, charrefLen * 4);
-           written = out->size - out->use - 1;
-            toconv = charrefLen;
-            ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
-                                    charref, &toconv);
-
-           if ((ret < 0) || (toconv != charrefLen)) {
-               char buf[50];
-
-               snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
-                        in->content[0], in->content[1],
-                        in->content[2], in->content[3]);
-               buf[49] = 0;
-               xmlEncodingErr(XML_I18N_CONV_FAILED,
-                   "output conversion failed due to conv error, bytes %s\n",
-                              buf);
-               if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
-                   in->content[0] = ' ';
-               break;
-           }
+        cur = xmlGetUTF8Char(utf, &len);
+        if (cur <= 0)
+            return(ret);
 
-            out->use += written;
-            writtentot += written;
-            out->content[out->use] = 0;
-            goto retry;
-       }
+        /*
+         * Removes the UTF8 sequence, and replace it by a charref
+         * and continue the transcoding phase, hoping the error
+         * did not mangle the encoder state.
+         */
+        charrefLen = snprintf((char *) &charref[0], sizeof(charref),
+                         "&#%d;", cur);
+        xmlBufferShrink(in, len);
+        xmlBufferGrow(out, charrefLen * 4);
+        written = out->size - out->use - 1;
+        toconv = charrefLen;
+        ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
+                                charref, &toconv);
+        if ((ret < 0) || (toconv != charrefLen))
+            return(XML_ENC_ERR_INTERNAL);
+
+        out->use += written;
+        writtentot += written;
+        out->content[out->use] = 0;
+        goto retry;
     }
     return(writtentot ? writtentot : ret);
 }
@@ -2796,19 +2454,19 @@ int
 xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
     int ret = 0;
     int tofree = 0;
-    int i, handler_in_list = 0;
-
-    /* Avoid unused variable warning if features are disabled. */
-    (void) handler_in_list;
+    int i = 0;
 
     if (handler == NULL) return(-1);
-    if (handler->name == NULL) return(-1);
+
+    for (i = 0; i < (int) NUM_DEFAULT_HANDLERS; i++) {
+        if (handler == &defaultHandlers[i])
+            return(0);
+    }
+
     if (handlers != NULL) {
         for (i = 0;i < nbCharEncodingHandler; i++) {
-            if (handler == handlers[i]) {
-               handler_in_list = 1;
-               break;
-           }
+            if (handler == handlers[i])
+                return(0);
        }
     }
 #ifdef LIBXML_ICONV_ENABLED
@@ -2816,8 +2474,7 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
      * Iconv handlers can be used only once, free the whole block.
      * and the associated icon resources.
      */
-    if ((handler_in_list == 0) &&
-        ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
+    if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
         tofree = 1;
        if (handler->iconv_out != NULL) {
            if (iconv_close(handler->iconv_out))
@@ -2832,8 +2489,7 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
     }
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
-    if ((handler_in_list == 0) &&
-        ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
+    if ((handler->uconv_out != NULL) || (handler->uconv_in != NULL)) {
         tofree = 1;
        if (handler->uconv_out != NULL) {
            closeIcuConverter(handler->uconv_out);
@@ -2852,14 +2508,6 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
         handler->name = NULL;
         xmlFree(handler);
     }
-#ifdef DEBUG_ENCODING
-    if (ret)
-        xmlGenericError(xmlGenericErrorContext,
-               "failed to close the encoding handler\n");
-    else
-        xmlGenericError(xmlGenericErrorContext,
-               "closed the encoding handler\n");
-#endif
 
     return(ret);
 }
@@ -2905,15 +2553,11 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
                 written = 32000;
                 ret = xmlEncOutputChunk(handler, &convbuf[0], &written,
                                         cur, &toconv);
-                if (ret < 0) {
-                    if (written > 0)
-                        ret = -2;
-                    else
-                        return(-1);
-                }
+                if ((ret != XML_ENC_ERR_SUCCESS) && (ret != XML_ENC_ERR_SPACE))
+                    return(-1);
                 unused += written;
                 cur += toconv;
-            } while (ret == -2);
+            } while (ret == XML_ENC_ERR_SPACE);
        }
        if (in->buf->rawconsumed < unused)
            return(-1);
@@ -2936,9 +2580,10 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
  * Take a block of UTF-8 chars in and try to convert it to an ISO 8859-*
  * block of chars out.
  *
- * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
- *     as the return value is positive, else unpredictable.
+ * as the return value is positive, else unpredictable.
  * The value of @outlen after return is the number of octets consumed.
  */
 static int
@@ -2952,7 +2597,7 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
 
     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
         (xlattable == NULL))
-       return(-1);
+       return(XML_ENC_ERR_INTERNAL);
     if (in == NULL) {
         /*
         * initialization nothing to do
@@ -2970,21 +2615,21 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
             /* trailing byte in leading position */
             *outlen = out - outstart;
             *inlen = processed - instart;
-            return(-2);
+            return(XML_ENC_ERR_INPUT);
         } else if (d < 0xE0) {
             unsigned char c;
             if (!(in < inend)) {
                 /* trailing byte not in input buffer */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-3);
+                return(XML_ENC_ERR_PARTIAL);
             }
             c = *in++;
             if ((c & 0xC0) != 0x80) {
                 /* not a trailing byte */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-2);
+                return(XML_ENC_ERR_INPUT);
             }
             c = c & 0x3F;
             d = d & 0x1F;
@@ -2993,7 +2638,7 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
                 /* not in character set */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-2);
+                return(XML_ENC_ERR_INPUT);
             }
             *out++ = d;
         } else if (d < 0xF0) {
@@ -3003,21 +2648,21 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
                 /* trailing bytes not in input buffer */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-3);
+                return(XML_ENC_ERR_PARTIAL);
             }
             c1 = *in++;
             if ((c1 & 0xC0) != 0x80) {
                 /* not a trailing byte (c1) */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-2);
+                return(XML_ENC_ERR_INPUT);
             }
             c2 = *in++;
             if ((c2 & 0xC0) != 0x80) {
                 /* not a trailing byte (c2) */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-2);
+                return(XML_ENC_ERR_INPUT);
             }
             c1 = c1 & 0x3F;
             c2 = c2 & 0x3F;
@@ -3028,14 +2673,14 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
                 /* not in character set */
                 *outlen = out - outstart;
                 *inlen = processed - instart;
-                return(-2);
+                return(XML_ENC_ERR_INPUT);
             }
             *out++ = d;
         } else {
             /* cannot transcode >= U+010000 */
             *outlen = out - outstart;
             *inlen = processed - instart;
-            return(-2);
+            return(XML_ENC_ERR_INPUT);
         }
         processed = in;
     }
@@ -3053,7 +2698,9 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
  *
  * Take a block of ISO 8859-* chars in and try to convert it to an UTF-8
  * block of chars out.
- * Returns 0 if success, or -1 otherwise
+ *
+ * Returns the number of bytes written or an XML_ENC_ERR code.
+ *
  * The value of @inlen after return is the number of octets consumed
  * The value of @outlen after return is the number of octets produced.
  */
@@ -3070,7 +2717,7 @@ ISO8859xToUTF8(unsigned char* out, int *outlen,
 
     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
         (in == NULL) || (unicodetable == NULL))
-       return(-1);
+       return(XML_ENC_ERR_INTERNAL);
     outend = out + *outlen;
     inend = in + *inlen;
     instop = inend;
@@ -3082,7 +2729,7 @@ ISO8859xToUTF8(unsigned char* out, int *outlen,
                 /* undefined code point */
                 *outlen = out - outstart;
                 *inlen = in - instart;
-                return (-1);
+                return(XML_ENC_ERR_INPUT);
             }
             if (c < 0x800) {
                 *out++ = ((c >>  6) & 0x1F) | 0xC0;
@@ -3972,24 +3619,6 @@ static int UTF8ToISO8859_16 (unsigned char* out, int *outlen,
     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_16);
 }
 
-static void
-xmlRegisterCharEncodingHandlersISO8859x (void) {
-    xmlNewCharEncodingHandler ("ISO-8859-2", ISO8859_2ToUTF8, UTF8ToISO8859_2);
-    xmlNewCharEncodingHandler ("ISO-8859-3", ISO8859_3ToUTF8, UTF8ToISO8859_3);
-    xmlNewCharEncodingHandler ("ISO-8859-4", ISO8859_4ToUTF8, UTF8ToISO8859_4);
-    xmlNewCharEncodingHandler ("ISO-8859-5", ISO8859_5ToUTF8, UTF8ToISO8859_5);
-    xmlNewCharEncodingHandler ("ISO-8859-6", ISO8859_6ToUTF8, UTF8ToISO8859_6);
-    xmlNewCharEncodingHandler ("ISO-8859-7", ISO8859_7ToUTF8, UTF8ToISO8859_7);
-    xmlNewCharEncodingHandler ("ISO-8859-8", ISO8859_8ToUTF8, UTF8ToISO8859_8);
-    xmlNewCharEncodingHandler ("ISO-8859-9", ISO8859_9ToUTF8, UTF8ToISO8859_9);
-    xmlNewCharEncodingHandler ("ISO-8859-10", ISO8859_10ToUTF8, UTF8ToISO8859_10);
-    xmlNewCharEncodingHandler ("ISO-8859-11", ISO8859_11ToUTF8, UTF8ToISO8859_11);
-    xmlNewCharEncodingHandler ("ISO-8859-13", ISO8859_13ToUTF8, UTF8ToISO8859_13);
-    xmlNewCharEncodingHandler ("ISO-8859-14", ISO8859_14ToUTF8, UTF8ToISO8859_14);
-    xmlNewCharEncodingHandler ("ISO-8859-15", ISO8859_15ToUTF8, UTF8ToISO8859_15);
-    xmlNewCharEncodingHandler ("ISO-8859-16", ISO8859_16ToUTF8, UTF8ToISO8859_16);
-}
-
 #endif
 #endif
 
index 8443551..aec5144 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlerror.h>
-#include <libxml/globals.h>
 #include <libxml/dict.h>
 
-#include "save.h"
+#include "private/entities.h"
+#include "private/error.h"
 
 /*
  * The XML predefined entities.
@@ -37,35 +37,35 @@ static xmlEntity xmlEntityLt = {
     NULL, NULL, NULL, NULL, NULL, NULL,
     BAD_CAST "<", BAD_CAST "<", 1,
     XML_INTERNAL_PREDEFINED_ENTITY,
-    NULL, NULL, NULL, NULL, 0, 1
+    NULL, NULL, NULL, NULL, 0, 0, 0
 };
 static xmlEntity xmlEntityGt = {
     NULL, XML_ENTITY_DECL, BAD_CAST "gt",
     NULL, NULL, NULL, NULL, NULL, NULL,
     BAD_CAST ">", BAD_CAST ">", 1,
     XML_INTERNAL_PREDEFINED_ENTITY,
-    NULL, NULL, NULL, NULL, 0, 1
+    NULL, NULL, NULL, NULL, 0, 0, 0
 };
 static xmlEntity xmlEntityAmp = {
     NULL, XML_ENTITY_DECL, BAD_CAST "amp",
     NULL, NULL, NULL, NULL, NULL, NULL,
     BAD_CAST "&", BAD_CAST "&", 1,
     XML_INTERNAL_PREDEFINED_ENTITY,
-    NULL, NULL, NULL, NULL, 0, 1
+    NULL, NULL, NULL, NULL, 0, 0, 0
 };
 static xmlEntity xmlEntityQuot = {
     NULL, XML_ENTITY_DECL, BAD_CAST "quot",
     NULL, NULL, NULL, NULL, NULL, NULL,
     BAD_CAST "\"", BAD_CAST "\"", 1,
     XML_INTERNAL_PREDEFINED_ENTITY,
-    NULL, NULL, NULL, NULL, 0, 1
+    NULL, NULL, NULL, NULL, 0, 0, 0
 };
 static xmlEntity xmlEntityApos = {
     NULL, XML_ENTITY_DECL, BAD_CAST "apos",
     NULL, NULL, NULL, NULL, NULL, NULL,
     BAD_CAST "'", BAD_CAST "'", 1,
     XML_INTERNAL_PREDEFINED_ENTITY,
-    NULL, NULL, NULL, NULL, 0, 1
+    NULL, NULL, NULL, NULL, 0, 0, 0
 };
 
 /**
@@ -113,7 +113,7 @@ xmlEntitiesWarn(xmlParserErrors code, const char *msg, const xmlChar *str1)
 /*
  * xmlFreeEntity : clean-up an entity record.
  */
-static void
+void
 xmlFreeEntity(xmlEntityPtr entity)
 {
     xmlDictPtr dict = NULL;
@@ -128,36 +128,19 @@ xmlFreeEntity(xmlEntityPtr entity)
     if ((entity->children) && (entity->owner == 1) &&
         (entity == (xmlEntityPtr) entity->children->parent))
         xmlFreeNodeList(entity->children);
-    if (dict != NULL) {
-        if ((entity->name != NULL) && (!xmlDictOwns(dict, entity->name)))
-            xmlFree((char *) entity->name);
-        if ((entity->ExternalID != NULL) &&
-           (!xmlDictOwns(dict, entity->ExternalID)))
-            xmlFree((char *) entity->ExternalID);
-        if ((entity->SystemID != NULL) &&
-           (!xmlDictOwns(dict, entity->SystemID)))
-            xmlFree((char *) entity->SystemID);
-        if ((entity->URI != NULL) && (!xmlDictOwns(dict, entity->URI)))
-            xmlFree((char *) entity->URI);
-        if ((entity->content != NULL)
-            && (!xmlDictOwns(dict, entity->content)))
-            xmlFree((char *) entity->content);
-        if ((entity->orig != NULL) && (!xmlDictOwns(dict, entity->orig)))
-            xmlFree((char *) entity->orig);
-    } else {
-        if (entity->name != NULL)
-            xmlFree((char *) entity->name);
-        if (entity->ExternalID != NULL)
-            xmlFree((char *) entity->ExternalID);
-        if (entity->SystemID != NULL)
-            xmlFree((char *) entity->SystemID);
-        if (entity->URI != NULL)
-            xmlFree((char *) entity->URI);
-        if (entity->content != NULL)
-            xmlFree((char *) entity->content);
-        if (entity->orig != NULL)
-            xmlFree((char *) entity->orig);
-    }
+    if ((entity->name != NULL) &&
+        ((dict == NULL) || (!xmlDictOwns(dict, entity->name))))
+        xmlFree((char *) entity->name);
+    if (entity->ExternalID != NULL)
+        xmlFree((char *) entity->ExternalID);
+    if (entity->SystemID != NULL)
+        xmlFree((char *) entity->SystemID);
+    if (entity->URI != NULL)
+        xmlFree((char *) entity->URI);
+    if (entity->content != NULL)
+        xmlFree((char *) entity->content);
+    if (entity->orig != NULL)
+        xmlFree((char *) entity->orig);
     xmlFree(entity);
 }
 
@@ -179,7 +162,6 @@ xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
     }
     memset(ret, 0, sizeof(xmlEntity));
     ret->type = XML_ENTITY_DECL;
-    ret->checked = 0;
 
     /*
      * fill the structure.
@@ -193,18 +175,12 @@ xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
            ret->SystemID = xmlStrdup(SystemID);
     } else {
         ret->name = xmlDictLookup(dict, name, -1);
-       if (ExternalID != NULL)
-           ret->ExternalID = xmlDictLookup(dict, ExternalID, -1);
-       if (SystemID != NULL)
-           ret->SystemID = xmlDictLookup(dict, SystemID, -1);
+       ret->ExternalID = xmlStrdup(ExternalID);
+       ret->SystemID = xmlStrdup(SystemID);
     }
     if (content != NULL) {
         ret->length = xmlStrlen(content);
-       if ((dict != NULL) && (ret->length < 5))
-           ret->content = (xmlChar *)
-                          xmlDictLookup(dict, content, ret->length);
-       else
-           ret->content = xmlStrndup(content, ret->length);
+       ret->content = xmlStrndup(content, ret->length);
      } else {
         ret->length = 0;
         ret->content = NULL;
@@ -627,7 +603,7 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
      * allocate an translation buffer.
      */
     buffer_size = 1000;
-    buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
+    buffer = (xmlChar *) xmlMalloc(buffer_size);
     if (buffer == NULL) {
         xmlEntitiesErrMemory("xmlEncodeEntities: malloc failed");
        return(NULL);
@@ -741,8 +717,6 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
                    (((cur[0] & 0xF8) == 0xF8))) {
                    xmlEntitiesErr(XML_CHECK_NOT_UTF8,
                            "xmlEncodeEntities: input not UTF-8");
-                   if (doc != NULL)
-                       doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
                    snprintf(buf, sizeof(buf), "&#%d;", *cur);
                    buf[sizeof(buf) - 1] = 0;
                    ptr = buf;
@@ -774,8 +748,6 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
                if ((l == 1) || (!IS_CHAR(val))) {
                    xmlEntitiesErr(XML_ERR_INVALID_CHAR,
                        "xmlEncodeEntities: char out of range\n");
-                   if (doc != NULL)
-                       doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
                    snprintf(buf, sizeof(buf), "&#%d;", *cur);
                    buf[sizeof(buf) - 1] = 0;
                    ptr = buf;
@@ -867,7 +839,7 @@ xmlEncodeSpecialChars(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlChar *input)
      * allocate an translation buffer.
      */
     buffer_size = 1000;
-    buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
+    buffer = (xmlChar *) xmlMalloc(buffer_size);
     if (buffer == NULL) {
         xmlEntitiesErrMemory("xmlEncodeSpecialChars: malloc failed");
        return(NULL);
@@ -1033,7 +1005,6 @@ xmlCopyEntitiesTable(xmlEntitiesTablePtr table) {
  */
 static void
 xmlDumpEntityContent(xmlBufferPtr buf, const xmlChar *content) {
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
     if (xmlStrchr(content, '%')) {
         const xmlChar * base, *cur;
 
diff --git a/error.c b/error.c
index 5f42ead..c87cf2a 100644 (file)
--- a/error.c
+++ b/error.c
 #include <libxml/parser.h>
 #include <libxml/xmlerror.h>
 #include <libxml/xmlmemory.h>
-#include <libxml/globals.h>
 
-void XMLCDECL xmlGenericErrorDefaultFunc       (void *ctx ATTRIBUTE_UNUSED,
-                                const char *msg,
-                                ...) LIBXML_ATTR_FORMAT(2,3);
+#include "private/error.h"
+
+#define XML_MAX_ERRORS 100
 
 #define XML_GET_VAR_STR(msg, str) {                            \
     int       size, prev_size = -1;                            \
@@ -67,7 +66,7 @@ void XMLCDECL xmlGenericErrorDefaultFunc      (void *ctx ATTRIBUTE_UNUSED,
  *
  * Default handler for out of context error messages.
  */
-void XMLCDECL
+void
 xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
 
@@ -83,6 +82,8 @@ xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
  * initGenericErrorDefaultFunc:
  * @handler:  the handler
  *
+ * DEPRECATED: Use xmlSetGenericErrorFunc.
+ *
  * Set or reset (if NULL) the default handler for generic errors
  * to the builtin error function.
  */
@@ -163,7 +164,7 @@ xmlParserPrintFileInfo(xmlParserInputPtr input) {
 }
 
 /**
- * xmlParserPrintFileContext:
+ * xmlParserPrintFileContextInternal:
  * @input:  an xmlParserInputPtr input
  *
  * Displays current context within the input content for error tracking
@@ -172,7 +173,7 @@ xmlParserPrintFileInfo(xmlParserInputPtr input) {
 static void
 xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
                xmlGenericErrorFunc channel, void *data ) {
-    const xmlChar *cur, *base;
+    const xmlChar *cur, *base, *start;
     unsigned int n, col;       /* GCC warns if signed, because compared with sizeof() */
     xmlChar  content[81]; /* space for 80 chars + line terminator */
     xmlChar *ctnt;
@@ -188,22 +189,35 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
     }
     n = 0;
     /* search backwards for beginning-of-line (to max buff size) */
-    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
-          (*(cur) != '\n') && (*(cur) != '\r'))
+    while ((n < sizeof(content) - 1) && (cur > base) &&
+          (*cur != '\n') && (*cur != '\r')) {
         cur--;
-    if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
+        n++;
+    }
+    if ((n > 0) && ((*cur == '\n') || (*cur == '\r'))) {
+        cur++;
+    } else {
+        /* skip over continuation bytes */
+        while ((cur < input->cur) && ((*cur & 0xC0) == 0x80))
+            cur++;
+    }
     /* calculate the error position in terms of the current position */
     col = input->cur - cur;
     /* search forward for end-of-line (to max buff size) */
     n = 0;
-    ctnt = content;
+    start = cur;
     /* copy selected text to our buffer */
-    while ((*cur != 0) && (*(cur) != '\n') &&
-          (*(cur) != '\r') && (n < sizeof(content)-1)) {
-               *ctnt++ = *cur++;
-       n++;
+    while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r')) {
+        int len = input->end - cur;
+        int c = xmlGetUTF8Char(cur, &len);
+
+        if ((c < 0) || (n + len > sizeof(content)-1))
+            break;
+        cur += len;
+       n += len;
     }
-    *ctnt = 0;
+    memcpy(content, start, n);
+    content[n] = 0;
     /* print out the selected text */
     channel(data ,"%s\n", content);
     /* create blank line with problem pointer */
@@ -451,7 +465,7 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
  * then forward the error message down the parser or generic
  * error callback handler
  */
-void XMLCDECL
+void
 __xmlRaiseError(xmlStructuredErrorFunc schannel,
               xmlGenericErrorFunc channel, void *data, void *ctx,
               void *nod, int domain, int code, xmlErrorLevel level,
@@ -474,12 +488,25 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
         (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
        (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
        ctxt = (xmlParserCtxtPtr) ctx;
-       if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
-           (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
-           (ctxt->sax->serror != NULL)) {
-           schannel = ctxt->sax->serror;
-           data = ctxt->userData;
-       }
+
+        if (ctxt != NULL) {
+            if (level == XML_ERR_WARNING) {
+                if (ctxt->nbWarnings >= XML_MAX_ERRORS)
+                    return;
+                ctxt->nbWarnings += 1;
+            } else {
+                if (ctxt->nbErrors >= XML_MAX_ERRORS)
+                    return;
+                ctxt->nbErrors += 1;
+            }
+
+            if ((schannel == NULL) && (ctxt->sax != NULL) &&
+                (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
+                (ctxt->sax->serror != NULL)) {
+                schannel = ctxt->sax->serror;
+                data = ctxt->userData;
+            }
+        }
     }
     /*
      * Check if structured error handler set
@@ -677,7 +704,7 @@ __xmlSimpleError(int domain, int code, xmlNodePtr node,
  * Display and format an error messages, gives file, line, position and
  * extra parameters.
  */
-void XMLCDECL
+void
 xmlParserError(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -720,7 +747,7 @@ xmlParserError(void *ctx, const char *msg, ...)
  * Display and format a warning messages, gives file, line, position and
  * extra parameters.
  */
-void XMLCDECL
+void
 xmlParserWarning(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -769,7 +796,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
  * Display and format an validity error messages, gives file,
  * line, position and extra parameters.
  */
-void XMLCDECL
+void
 xmlParserValidityError(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -813,7 +840,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
  * Display and format a validity warning messages, gives file, line,
  * position and extra parameters.
  */
-void XMLCDECL
+void
 xmlParserValidityWarning(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -853,9 +880,9 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
  * Get the last global error registered. This is per thread if compiled
  * with thread support.
  *
- * Returns NULL if no error occurred or a pointer to the error
+ * Returns a pointer to the error
  */
-xmlErrorPtr
+const xmlError *
 xmlGetLastError(void)
 {
     if (xmlLastError.code == XML_ERR_OK)
@@ -912,7 +939,7 @@ xmlResetLastError(void)
  *
  * Returns NULL if no error occurred or a pointer to the error
  */
-xmlErrorPtr
+const xmlError *
 xmlCtxtGetLastError(void *ctx)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -954,7 +981,7 @@ xmlCtxtResetLastError(void *ctx)
  * Returns 0 in case of success and -1 in case of error.
  */
 int
-xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
+xmlCopyError(const xmlError *from, xmlErrorPtr to) {
     char *message, *file, *str1, *str2, *str3;
 
     if ((from == NULL) || (to == NULL))
index d092c12..926cab0 100644 (file)
@@ -184,18 +184,11 @@ parseGjobFile(char *filename ATTRIBUTE_UNUSED) {
     xmlNsPtr ns;
     xmlNodePtr cur;
 
-#ifdef LIBXML_SAX1_ENABLED
     /*
      * build an XML tree from a the file;
      */
-    doc = xmlParseFile(filename);
+    doc = xmlReadFile(filename, NULL, XML_PARSE_NOBLANKS);
     if (doc == NULL) return(NULL);
-#else
-    /*
-     * the library has been compiled without some of the old interfaces
-     */
-    return(NULL);
-#endif /* LIBXML_SAX1_ENABLED */
 
     /*
      * Check the document is of the right kind
@@ -291,7 +284,6 @@ int main(int argc, char **argv) {
 
     /* COMPAT: Do not generate nodes for formatting spaces */
     LIBXML_TEST_VERSION
-    xmlKeepBlanksDefault(0);
 
     for (i = 1; i < argc ; i++) {
        cur = parseGjobFile(argv[i]);
index 9a5f72a..0406fc5 100644 (file)
@@ -6,5 +6,7 @@ schema
 seed/
 testFuzzer
 uri
+valid
+xinclude
 xml
 xpath
index 6d59816..e49ca05 100644 (file)
@@ -1,5 +1,5 @@
 AUTOMAKE_OPTIONS = -Wno-syntax
-EXTRA_PROGRAMS = genSeed html regexp schema uri xml xpath
+EXTRA_PROGRAMS = genSeed html regexp schema uri valid xinclude xml xpath
 check_PROGRAMS = testFuzzer
 EXTRA_DIST = html.dict regexp.dict schema.dict xml.dict xpath.dict \
             static_seed/uri static_seed/regexp fuzz.h
@@ -15,11 +15,11 @@ XML_SEED_CORPUS_SRC = \
     '$(top_srcdir)/test/errors/*.xml' \
     '$(top_srcdir)/test/errors10/*.xml' \
     '$(top_srcdir)/test/namespaces/*' \
+    '$(top_srcdir)/test/recurse/*.xml' \
     '$(top_srcdir)/test/SVG/*.xml' \
     '$(top_srcdir)/test/valid/*.xml' \
     '$(top_srcdir)/test/VC/*' \
     '$(top_srcdir)/test/VCM/*' \
-    '$(top_srcdir)/test/XInclude/docs/*' \
     '$(top_srcdir)/test/xmlid/*'
 
 testFuzzer_SOURCES = testFuzzer.c fuzz.c
@@ -27,7 +27,7 @@ testFuzzer_SOURCES = testFuzzer.c fuzz.c
 .PHONY: corpus clean-corpus
 
 corpus: seed/html.stamp seed/regexp.stamp seed/schema.stamp seed/uri.stamp \
-    seed/xml.stamp seed/xpath.stamp
+    seed/valid.stamp seed/xinclude.stamp seed/xml.stamp seed/xpath.stamp
 
 check-local: corpus
        ./testFuzzer$(EXEEXT)
@@ -49,7 +49,7 @@ seed/xml.stamp: genSeed$(EXEEXT)
        @touch seed/xml.stamp
 
 xml_SOURCES = xml.c fuzz.c
-xml_LDFLAGS = -fsanitize=fuzzer
+xml_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
 fuzz-xml: xml$(EXEEXT) seed/xml.stamp
        @mkdir -p corpus/xml
@@ -57,8 +57,49 @@ fuzz-xml: xml$(EXEEXT) seed/xml.stamp
            -dict=xml.dict \
            -max_len=$(XML_MAX_LEN) \
            -timeout=20 \
+           -rss_limit_mb=4096 \
            corpus/xml seed/xml
 
+# DTD validation fuzzer
+
+seed/valid.stamp: genSeed$(EXEEXT)
+       @mkdir -p seed/valid
+       ./genSeed$(EXEEXT) valid $(XML_SEED_CORPUS_SRC)
+       @touch seed/valid.stamp
+
+valid_SOURCES = valid.c fuzz.c
+valid_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
+
+fuzz-valid: valid$(EXEEXT) seed/valid.stamp
+       @mkdir -p corpus/valid
+       ./valid$(EXEEXT) \
+           -dict=xml.dict \
+           -max_len=$(XML_MAX_LEN) \
+           -timeout=20 \
+           -rss_limit_mb=4096 \
+           corpus/valid seed/valid
+
+# XInclude fuzzer
+
+seed/xinclude.stamp: genSeed$(EXEEXT)
+       @mkdir -p seed/xinclude
+       ./genSeed$(EXEEXT) xinclude \
+           '$(top_srcdir)/test/XInclude/docs/*' \
+           '$(top_srcdir)/test/XInclude/without-reader/*'
+       @touch seed/xinclude.stamp
+
+xinclude_SOURCES = xinclude.c fuzz.c
+xinclude_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
+
+fuzz-xinclude: xinclude$(EXEEXT) seed/xinclude.stamp
+       @mkdir -p corpus/xinclude
+       ./xinclude$(EXEEXT) \
+           -dict=xml.dict \
+           -max_len=$(XML_MAX_LEN) \
+           -timeout=20 \
+           -rss_limit_mb=4096 \
+           corpus/xinclude seed/xinclude
+
 # HTML fuzzer
 
 seed/html.stamp: genSeed$(EXEEXT)
@@ -67,7 +108,7 @@ seed/html.stamp: genSeed$(EXEEXT)
        @touch seed/html.stamp
 
 html_SOURCES = html.c fuzz.c
-html_LDFLAGS = -fsanitize=fuzzer
+html_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
 fuzz-html: html$(EXEEXT) seed/html.stamp
        @mkdir -p corpus/html
@@ -75,6 +116,7 @@ fuzz-html: html$(EXEEXT) seed/html.stamp
            -dict=html.dict \
            -max_len=1000000 \
            -timeout=10 \
+           -rss_limit_mb=4096 \
            corpus/html seed/html
 
 # Regexp fuzzer
@@ -85,9 +127,9 @@ seed/regexp.stamp:
        @touch seed/regexp.stamp
 
 regexp_SOURCES = regexp.c fuzz.c
-regexp_LDFLAGS = -fsanitize=fuzzer
+regexp_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
-fuzz-regexp: regexp$(EXEEXT)
+fuzz-regexp: regexp$(EXEEXT) seed/regexp.stamp
        @mkdir -p corpus/regexp
        ./regexp$(EXEEXT) \
            -dict=regexp.dict \
@@ -103,9 +145,9 @@ seed/uri.stamp:
        @touch seed/uri.stamp
 
 uri_SOURCES = uri.c fuzz.c
-uri_LDFLAGS = -fsanitize=fuzzer
+uri_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
-fuzz-uri: uri$(EXEEXT)
+fuzz-uri: uri$(EXEEXT) seed/uri.stamp
        @mkdir -p corpus/uri
        ./uri$(EXEEXT) \
            -max_len=10000 \
@@ -120,7 +162,7 @@ seed/schema.stamp: genSeed$(EXEEXT)
        @touch seed/schema.stamp
 
 schema_SOURCES = schema.c fuzz.c
-schema_LDFLAGS = -fsanitize=fuzzer
+schema_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
 fuzz-schema: schema$(EXEEXT) seed/schema.stamp
        @mkdir -p corpus/schema
@@ -128,6 +170,7 @@ fuzz-schema: schema$(EXEEXT) seed/schema.stamp
            -dict=schema.dict \
            -max_len=$(XML_MAX_LEN) \
            -timeout=20 \
+           -rss_limit_mb=4096 \
            corpus/schema seed/schema
 
 # XPath fuzzer
@@ -138,7 +181,7 @@ seed/xpath.stamp: genSeed$(EXEEXT)
        @touch seed/xpath.stamp
 
 xpath_SOURCES = xpath.c fuzz.c
-xpath_LDFLAGS = -fsanitize=fuzzer
+xpath_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
 
 fuzz-xpath: xpath$(EXEEXT) seed/xpath.stamp
        @mkdir -p corpus/xpath
@@ -146,5 +189,6 @@ fuzz-xpath: xpath$(EXEEXT) seed/xpath.stamp
            -dict=xpath.dict \
            -max_len=10000 \
            -timeout=20 \
+           -rss_limit_mb=4096 \
            corpus/xpath seed/xpath
 
index be2f065..5ace93d 100644 (file)
@@ -42,6 +42,10 @@ static struct {
     xmlFuzzEntityInfo *mainEntity;
 } fuzzData;
 
+size_t fuzzNumAllocs;
+size_t fuzzMaxAllocs;
+int fuzzAllocFailed;
+
 /**
  * xmlFuzzErrorFunc:
  *
@@ -52,6 +56,66 @@ xmlFuzzErrorFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
                  ...) {
 }
 
+/*
+ * Malloc failure injection.
+ *
+ * Quick tip to debug complicated issues: Increase MALLOC_OFFSET until
+ * the crash disappears (or a different issue is triggered). Then set
+ * the offset to the highest value that produces a crash and set
+ * MALLOC_ABORT to 1 to see which failed memory allocation causes the
+ * issue.
+ */
+
+#define XML_FUZZ_MALLOC_OFFSET  0
+#define XML_FUZZ_MALLOC_ABORT   0
+
+static void *
+xmlFuzzMalloc(size_t size) {
+    if (fuzzMaxAllocs > 0) {
+        if (fuzzNumAllocs >= fuzzMaxAllocs - 1) {
+#if XML_FUZZ_MALLOC_ABORT
+            abort();
+#endif
+            fuzzAllocFailed = 1;
+            return(NULL);
+        }
+        fuzzNumAllocs += 1;
+    }
+    return malloc(size);
+}
+
+static void *
+xmlFuzzRealloc(void *ptr, size_t size) {
+    if (fuzzMaxAllocs > 0) {
+        if (fuzzNumAllocs >= fuzzMaxAllocs - 1) {
+#if XML_FUZZ_MALLOC_ABORT
+            abort();
+#endif
+            fuzzAllocFailed = 1;
+            return(NULL);
+        }
+        fuzzNumAllocs += 1;
+    }
+    return realloc(ptr, size);
+}
+
+void
+xmlFuzzMemSetup(void) {
+    xmlMemSetup(free, xmlFuzzMalloc, xmlFuzzRealloc, xmlMemStrdup);
+}
+
+void
+xmlFuzzMemSetLimit(size_t limit) {
+    fuzzNumAllocs = 0;
+    fuzzMaxAllocs = limit ? limit + XML_FUZZ_MALLOC_OFFSET : 0;
+    fuzzAllocFailed = 0;
+}
+
+int
+xmlFuzzMallocFailed(void) {
+    return fuzzAllocFailed;
+}
+
 /**
  * xmlFuzzDataInit:
  *
@@ -84,20 +148,45 @@ xmlFuzzDataCleanup(void) {
 }
 
 /**
+ * xmlFuzzWriteInt:
+ * @out:  output file
+ * @v:  integer to write
+ * @size:  size of integer in bytes
+ *
+ * Write an integer to the fuzz data.
+ */
+void
+xmlFuzzWriteInt(FILE *out, size_t v, int size) {
+    int shift;
+
+    while (size > (int) sizeof(size_t)) {
+        putc(0, out);
+        size--;
+    }
+
+    shift = size * 8;
+    while (shift > 0) {
+        shift -= 8;
+        putc((v >> shift) & 255, out);
+    }
+}
+
+/**
  * xmlFuzzReadInt:
- * @size:  size of string in bytes
+ * @size:  size of integer in bytes
  *
  * Read an integer from the fuzz data.
  */
-int
-xmlFuzzReadInt() {
-    int ret;
+size_t
+xmlFuzzReadInt(int size) {
+    size_t ret = 0;
 
-    if (fuzzData.remaining < sizeof(int))
-        return(0);
-    memcpy(&ret, fuzzData.ptr, sizeof(int));
-    fuzzData.ptr += sizeof(int);
-    fuzzData.remaining -= sizeof(int);
+    while ((size > 0) && (fuzzData.remaining > 0)) {
+        unsigned char c = (unsigned char) *fuzzData.ptr++;
+        fuzzData.remaining--;
+        ret = (ret << 8) | c;
+        size--;
+    }
 
     return ret;
 }
@@ -166,7 +255,8 @@ xmlFuzzReadString(size_t *size) {
             if (c2 == '\n') {
                 fuzzData.ptr++;
                 fuzzData.remaining--;
-                *size = fuzzData.outPtr - out;
+                if (size != NULL)
+                    *size = fuzzData.outPtr - out;
                 *fuzzData.outPtr++ = '\0';
                 return(out);
             }
@@ -180,12 +270,14 @@ xmlFuzzReadString(size_t *size) {
     }
 
     if (fuzzData.outPtr > out) {
-        *size = fuzzData.outPtr - out;
+        if (size != NULL)
+            *size = fuzzData.outPtr - out;
         *fuzzData.outPtr++ = '\0';
         return(out);
     }
 
-    *size = 0;
+    if (size != NULL)
+        *size = 0;
     return(NULL);
 }
 
@@ -201,10 +293,10 @@ xmlFuzzReadEntities(void) {
 
     while (1) {
         const char *url, *entity;
-        size_t urlSize, entitySize;
+        size_t entitySize;
         xmlFuzzEntityInfo *entityInfo;
-        
-        url = xmlFuzzReadString(&urlSize);
+
+        url = xmlFuzzReadString(NULL);
         if (url == NULL) break;
 
         entity = xmlFuzzReadString(&entitySize);
@@ -271,7 +363,9 @@ xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED,
         return(NULL);
 
     input = xmlNewInputStream(ctxt);
-    input->filename = NULL;
+    if (input == NULL)
+        return(NULL);
+    input->filename = (char *) xmlCharStrdup(URL);
     input->buf = xmlParserInputBufferCreateMem(entity->data, entity->size,
                                                XML_CHAR_ENCODING_NONE);
     if (input->buf == NULL) {
@@ -279,52 +373,11 @@ xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED,
         return(NULL);
     }
     input->base = input->cur = xmlBufContent(input->buf->buffer);
-    input->end = input->base + entity->size;
+    input->end = input->base + xmlBufUse(input->buf->buffer);
 
     return input;
 }
 
-/**
- * xmlFuzzExtractStrings:
- *
- * Extract C strings from input data. Use exact-size allocations to detect
- * potential memory errors.
- */
-size_t
-xmlFuzzExtractStrings(const char *data, size_t size, char **strings,
-                      size_t numStrings) {
-    const char *start = data;
-    const char *end = data + size;
-    size_t i = 0, ret;
-
-    while (i < numStrings) {
-        size_t strSize = end - start;
-        const char *zero = memchr(start, 0, strSize);
-
-        if (zero != NULL)
-            strSize = zero - start;
-
-        strings[i] = xmlMalloc(strSize + 1);
-        memcpy(strings[i], start, strSize);
-        strings[i][strSize] = '\0';
-
-        i++;
-        if (zero != NULL)
-            start = zero + 1;
-        else
-            break;
-    }
-
-    ret = i;
-
-    while (i < numStrings) {
-        strings[i] = NULL;
-        i++;
-    }
-
-    return(ret);
-}
-
 char *
 xmlSlurpFile(const char *path, size_t *sizeRet) {
     FILE *file;
index a51b398..feafe11 100644 (file)
@@ -15,7 +15,7 @@
 extern "C" {
 #endif
 
-#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_HTML_ENABLED)
   #define HAVE_HTML_FUZZER
 #endif
 #if defined(LIBXML_REGEXP_ENABLED)
@@ -27,12 +27,16 @@ extern "C" {
 #if 1
   #define HAVE_URI_FUZZER
 #endif
-#if defined(LIBXML_OUTPUT_ENABLED) && \
-    defined(LIBXML_READER_ENABLED) && \
-    defined(LIBXML_XINCLUDE_ENABLED)
+#if defined(LIBXML_VALID_ENABLED)
+  #define HAVE_VALID_FUZZER
+#endif
+#if defined(LIBXML_XINCLUDE_ENABLED)
+  #define HAVE_XINCLUDE_FUZZER
+#endif
+#if 1
   #define HAVE_XML_FUZZER
 #endif
-#if defined(LIBXML_XPATH_ENABLED)
+#if defined(LIBXML_XPTR_ENABLED)
   #define HAVE_XPATH_FUZZER
 #endif
 
@@ -47,13 +51,25 @@ xmlFuzzErrorFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
                  ...);
 
 void
+xmlFuzzMemSetup(void);
+
+void
+xmlFuzzMemSetLimit(size_t limit);
+
+int
+xmlFuzzMallocFailed(void);
+
+void
 xmlFuzzDataInit(const char *data, size_t size);
 
 void
 xmlFuzzDataCleanup(void);
 
-int
-xmlFuzzReadInt(void);
+void
+xmlFuzzWriteInt(FILE *out, size_t v, int size);
+
+size_t
+xmlFuzzReadInt(int size);
 
 const char *
 xmlFuzzReadRemaining(size_t *size);
@@ -76,10 +92,6 @@ xmlFuzzMainEntity(size_t *size);
 xmlParserInputPtr
 xmlFuzzEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt);
 
-size_t
-xmlFuzzExtractStrings(const char *data, size_t size, char **strings,
-                      size_t numStrings);
-
 char *
 xmlSlurpFile(const char *path, size_t *size);
 
index 01f0656..a315472 100644 (file)
@@ -43,6 +43,8 @@ static struct {
     char cwd[PATH_SIZE];
 } globalData;
 
+#if defined(HAVE_SCHEMA_FUZZER) || \
+    defined(HAVE_XML_FUZZER)
 /*
  * A custom entity loader that writes all external DTDs or entities to a
  * single file in the format expected by xmlFuzzEntityLoader.
@@ -80,7 +82,8 @@ fuzzEntityRecorder(const char *URL, const char *ID,
 
     xmlFreeInputStream(in);
 
-    xmlHashAddEntry(globalData.entities, (const xmlChar *) URL, NULL);
+    xmlHashAddEntry(globalData.entities, (const xmlChar *) URL,
+                    globalData.entities);
 
     return(xmlNoNetExternalEntityLoader(URL, ID, ctxt));
 }
@@ -94,13 +97,14 @@ fuzzRecorderInit(FILE *out) {
 }
 
 static void
-fuzzRecorderCleanup() {
+fuzzRecorderCleanup(void) {
     xmlSetExternalEntityLoader(globalData.oldLoader);
-    xmlHashFree(globalData.entities, xmlHashDefaultDeallocator);
+    xmlHashFree(globalData.entities, NULL);
     globalData.out = NULL;
     globalData.entities = NULL;
     globalData.oldLoader = NULL;
 }
+#endif
 
 #ifdef HAVE_XML_FUZZER
 static int
@@ -108,12 +112,17 @@ processXml(const char *docFile, FILE *out) {
     int opts = XML_PARSE_NOENT | XML_PARSE_DTDLOAD;
     xmlDocPtr doc;
 
-    fwrite(&opts, sizeof(opts), 1, out);
+    /* Parser options. */
+    xmlFuzzWriteInt(out, opts, 4);
+    /* Max allocations. */
+    xmlFuzzWriteInt(out, 0, 4);
 
     fuzzRecorderInit(out);
 
     doc = xmlReadFile(docFile, NULL, opts);
+#ifdef LIBXML_XINCLUDE_ENABLED
     xmlXIncludeProcessFlags(doc, opts);
+#endif
     xmlFreeDoc(doc);
 
     fuzzRecorderCleanup();
@@ -128,9 +137,11 @@ processHtml(const char *docFile, FILE *out) {
     char buf[SEED_BUF_SIZE];
     FILE *file;
     size_t size;
-    int opts = 0;
 
-    fwrite(&opts, sizeof(opts), 1, out);
+    /* Parser options. */
+    xmlFuzzWriteInt(out, 0, 4);
+    /* Max allocations. */
+    xmlFuzzWriteInt(out, 0, 4);
 
     /* Copy file */
     file = fopen(docFile, "rb");
@@ -155,6 +166,9 @@ processSchema(const char *docFile, FILE *out) {
     xmlSchemaPtr schema;
     xmlSchemaParserCtxtPtr pctxt;
 
+    /* Max allocations. */
+    xmlFuzzWriteInt(out, 0, 4);
+
     fuzzRecorderInit(out);
 
     pctxt = xmlSchemaNewParserCtxt(docFile);
@@ -169,11 +183,15 @@ processSchema(const char *docFile, FILE *out) {
 }
 #endif
 
+#if defined(HAVE_HTML_FUZZER) || \
+    defined(HAVE_SCHEMA_FUZZER) || \
+    defined(HAVE_XML_FUZZER)
 static int
 processPattern(const char *pattern) {
     glob_t globbuf;
     int ret = 0;
-    int res, i;
+    int res;
+    size_t i;
 
     res = glob(pattern, 0, NULL, &globbuf);
     if (res == GLOB_NOMATCH)
@@ -245,6 +263,7 @@ error:
     globfree(&globbuf);
     return(ret);
 }
+#endif
 
 #ifdef HAVE_XPATH_FUZZER
 static int
@@ -282,7 +301,7 @@ processXPath(const char *testDir, const char *prefix, const char *name,
             continue;
         }
 
-        while (fgets(expr, EXPR_SIZE, in) > 0) {
+        while (fgets(expr, EXPR_SIZE, in) != NULL) {
             char outPath[PATH_SIZE];
             FILE *out;
             int j;
@@ -304,6 +323,9 @@ processXPath(const char *testDir, const char *prefix, const char *name,
                 continue;
             }
 
+            /* Max allocations. */
+            xmlFuzzWriteInt(out, 0, 4);
+
             if (xptr) {
                 xmlFuzzWriteString(out, expr);
             } else {
@@ -328,7 +350,7 @@ processXPath(const char *testDir, const char *prefix, const char *name,
     return(ret);
 }
 
-int
+static int
 processXPathDir(const char *testDir) {
     char pattern[PATH_SIZE];
     glob_t globbuf;
@@ -379,7 +401,6 @@ main(int argc, const char **argv) {
     mainFunc processArg = NULL;
     const char *fuzzer;
     int ret = 0;
-    int xpath = 0;
     int i;
 
     if (argc < 3) {
@@ -400,6 +421,16 @@ main(int argc, const char **argv) {
         processArg = processPattern;
         globalData.processFile = processSchema;
 #endif
+    } else if (strcmp(fuzzer, "valid") == 0) {
+#ifdef HAVE_VALID_FUZZER
+        processArg = processPattern;
+        globalData.processFile = processXml;
+#endif
+    } else if (strcmp(fuzzer, "xinclude") == 0) {
+#ifdef HAVE_XINCLUDE_FUZZER
+        processArg = processPattern;
+        globalData.processFile = processXml;
+#endif
     } else if (strcmp(fuzzer, "xml") == 0) {
 #ifdef HAVE_XML_FUZZER
         processArg = processPattern;
index 116b3df..aa8d9d9 100644 (file)
@@ -12,6 +12,7 @@
 int
 LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
                      char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
     xmlInitParser();
 #ifdef LIBXML_CATALOG_ENABLED
     xmlInitializeCatalog();
@@ -23,16 +24,14 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
 
 int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
-    static const size_t maxChunkSize = 128;
     htmlDocPtr doc;
-    htmlParserCtxtPtr ctxt;
-    xmlOutputBufferPtr out;
     const char *docBuffer;
-    size_t docSize, consumed, chunkSize;
-    int opts, outSize;
+    size_t maxAlloc, docSize;
+    int opts;
 
     xmlFuzzDataInit(data, size);
-    opts = xmlFuzzReadInt();
+    opts = (int) xmlFuzzReadInt(4);
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
 
     docBuffer = xmlFuzzReadRemaining(&docSize);
     if (docBuffer == NULL) {
@@ -42,38 +41,58 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
 
     /* Pull parser */
 
+    xmlFuzzMemSetLimit(maxAlloc);
     doc = htmlReadMemory(docBuffer, docSize, NULL, NULL, opts);
 
-    /*
-     * Also test the serializer. Call htmlDocContentDumpOutput with our
-     * own buffer to avoid encoding the output. The HTML encoding is
-     * excruciatingly slow (see htmlEntityValueLookup).
-     */
-    out = xmlAllocOutputBuffer(NULL);
-    htmlDocContentDumpOutput(out, doc, NULL);
-    xmlOutputBufferClose(out);
+#ifdef LIBXML_OUTPUT_ENABLED
+    {
+        xmlOutputBufferPtr out;
+
+        /*
+         * Also test the serializer. Call htmlDocContentDumpOutput with our
+         * own buffer to avoid encoding the output. The HTML encoding is
+         * excruciatingly slow (see htmlEntityValueLookup).
+         */
+        out = xmlAllocOutputBuffer(NULL);
+        htmlDocContentDumpOutput(out, doc, NULL);
+        xmlOutputBufferClose(out);
+    }
+#endif
 
     xmlFreeDoc(doc);
 
     /* Push parser */
 
-    ctxt = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL,
-                                    XML_CHAR_ENCODING_NONE);
-    htmlCtxtUseOptions(ctxt, opts);
-
-    for (consumed = 0; consumed < docSize; consumed += chunkSize) {
-        chunkSize = docSize - consumed;
-        if (chunkSize > maxChunkSize)
-            chunkSize = maxChunkSize;
-        htmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
+#ifdef LIBXML_PUSH_ENABLED
+    {
+        static const size_t maxChunkSize = 128;
+        xmlParserCtxtPtr ctxt;
+        size_t consumed, chunkSize;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        ctxt = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL,
+                                        XML_CHAR_ENCODING_NONE);
+
+        if (ctxt != NULL) {
+            htmlCtxtUseOptions(ctxt, opts);
+
+            for (consumed = 0; consumed < docSize; consumed += chunkSize) {
+                chunkSize = docSize - consumed;
+                if (chunkSize > maxChunkSize)
+                    chunkSize = maxChunkSize;
+                htmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
+            }
+
+            htmlParseChunk(ctxt, NULL, 0, 1);
+            xmlFreeDoc(ctxt->myDoc);
+            htmlFreeParserCtxt(ctxt);
+        }
     }
-
-    htmlParseChunk(ctxt, NULL, 0, 1);
-    xmlFreeDoc(ctxt->myDoc);
-    htmlFreeParserCtxt(ctxt);
+#endif
 
     /* Cleanup */
 
+    xmlFuzzMemSetLimit(0);
     xmlFuzzDataCleanup();
     xmlResetLastError();
 
index af1210a..35f2e58 100644 (file)
@@ -4,12 +4,15 @@
  * See Copyright for the status of this software.
  */
 
+#include <stdio.h>
+#include <stdlib.h>
 #include <libxml/xmlregexp.h>
 #include "fuzz.h"
 
 int
 LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
                      char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
     xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
 
     return 0;
@@ -18,28 +21,30 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
 int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
     xmlRegexpPtr regexp;
-    char *str[2] = { NULL, NULL };
-    size_t numStrings;
+    size_t maxAlloc;
+    const char *str1;
 
     if (size > 200)
         return(0);
 
-    numStrings = xmlFuzzExtractStrings(data, size, str, 2);
+    xmlFuzzDataInit(data, size);
+    maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
+    str1 = xmlFuzzReadString(NULL);
 
-    /* CUR_SCHAR doesn't handle invalid UTF-8 and may cause infinite loops. */
-    if (xmlCheckUTF8(BAD_CAST str[0]) != 0) {
-        regexp = xmlRegexpCompile(BAD_CAST str[0]);
-        /* xmlRegexpExec has pathological performance in too many cases. */
+    xmlFuzzMemSetLimit(maxAlloc);
+    regexp = xmlRegexpCompile(BAD_CAST str1);
+    if (xmlFuzzMallocFailed() && regexp != NULL) {
+        fprintf(stderr, "malloc failure not reported\n");
+        abort();
+    }
+    /* xmlRegexpExec has pathological performance in too many cases. */
 #if 0
-        if ((regexp != NULL) && (numStrings >= 2)) {
-            xmlRegexpExec(regexp, BAD_CAST str[1]);
-        }
+    xmlRegexpExec(regexp, BAD_CAST str2);
 #endif
-        xmlRegFreeRegexp(regexp);
-    }
+    xmlRegFreeRegexp(regexp);
 
-    xmlFree(str[0]);
-    xmlFree(str[1]);
+    xmlFuzzMemSetLimit(0);
+    xmlFuzzDataCleanup();
     xmlResetLastError();
 
     return 0;
index 689bffe..04e92f9 100644 (file)
@@ -11,6 +11,7 @@
 int
 LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
                      char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
     xmlInitParser();
 #ifdef LIBXML_CATALOG_ENABLED
     xmlInitializeCatalog();
@@ -24,18 +25,23 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
 int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
     xmlSchemaParserCtxtPtr pctxt;
+    size_t maxAlloc;
 
     if (size > 50000)
         return(0);
 
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
+
     xmlFuzzDataInit(data, size);
     xmlFuzzReadEntities();
 
+    xmlFuzzMemSetLimit(maxAlloc);
     pctxt = xmlSchemaNewParserCtxt(xmlFuzzMainUrl());
     xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL);
     xmlSchemaFree(xmlSchemaParse(pctxt));
     xmlSchemaFreeParserCtxt(pctxt);
 
+    xmlFuzzMemSetLimit(0);
     xmlFuzzDataCleanup();
     xmlResetLastError();
 
index ded775e..2a61d0d 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-1 and b/fuzz/static_seed/regexp/branch-1 differ
index 6700d77..a867afe 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-10 and b/fuzz/static_seed/regexp/branch-10 differ
index d83f918..cf22034 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-11 and b/fuzz/static_seed/regexp/branch-11 differ
index b44dba5..1dd06d5 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-12 and b/fuzz/static_seed/regexp/branch-12 differ
index 64e50a0..d3033d2 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-13 and b/fuzz/static_seed/regexp/branch-13 differ
index 8293d81..cd27911 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-2 and b/fuzz/static_seed/regexp/branch-2 differ
index 696af9b..64437c8 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-3 and b/fuzz/static_seed/regexp/branch-3 differ
index 8317998..556bba2 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-4 and b/fuzz/static_seed/regexp/branch-4 differ
index 6b6db8b..cdf9098 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-5 and b/fuzz/static_seed/regexp/branch-5 differ
index 4f47790..f68f552 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-6 and b/fuzz/static_seed/regexp/branch-6 differ
index 6334f72..a7e8e91 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-7 and b/fuzz/static_seed/regexp/branch-7 differ
index f77a8f4..0637a69 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-8 and b/fuzz/static_seed/regexp/branch-8 differ
index acd0eec..6cbd35e 100644 (file)
Binary files a/fuzz/static_seed/regexp/branch-9 and b/fuzz/static_seed/regexp/branch-9 differ
index 9f0a504..742782c 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-1 and b/fuzz/static_seed/regexp/bug316338-1 differ
index 60685bb..09eaccc 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-10 and b/fuzz/static_seed/regexp/bug316338-10 differ
index 72a7956..991d19a 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-11 and b/fuzz/static_seed/regexp/bug316338-11 differ
index 85416ee..dd43da8 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-12 and b/fuzz/static_seed/regexp/bug316338-12 differ
index c91d4fe..8b7bc0c 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-13 and b/fuzz/static_seed/regexp/bug316338-13 differ
index a164b42..4cd8318 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-14 and b/fuzz/static_seed/regexp/bug316338-14 differ
index 750c76d..456dda7 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-15 and b/fuzz/static_seed/regexp/bug316338-15 differ
index 23c5d23..94a4810 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-16 and b/fuzz/static_seed/regexp/bug316338-16 differ
index 5468d06..6dd04e3 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-2 and b/fuzz/static_seed/regexp/bug316338-2 differ
index 76e1e0b..5be0b2d 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-3 and b/fuzz/static_seed/regexp/bug316338-3 differ
index e0f65a4..e7d786c 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-4 and b/fuzz/static_seed/regexp/bug316338-4 differ
index fcfaa97..e06cf23 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-5 and b/fuzz/static_seed/regexp/bug316338-5 differ
index ce00a15..c65a26e 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-6 and b/fuzz/static_seed/regexp/bug316338-6 differ
index 127fe1f..8d0ec0f 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-7 and b/fuzz/static_seed/regexp/bug316338-7 differ
index fe8bb8b..a17aac4 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-8 and b/fuzz/static_seed/regexp/bug316338-8 differ
index 3d56e5d..3c37fb4 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug316338-9 and b/fuzz/static_seed/regexp/bug316338-9 differ
index 4426933..9b6a838 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-1 and b/fuzz/static_seed/regexp/bug420596-1 differ
index 474d2b6..f3ee539 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-2 and b/fuzz/static_seed/regexp/bug420596-2 differ
index 09c75cb..590bad9 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-3 and b/fuzz/static_seed/regexp/bug420596-3 differ
index 65d561e..233a92b 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-4 and b/fuzz/static_seed/regexp/bug420596-4 differ
index b678580..ca35ec2 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-5 and b/fuzz/static_seed/regexp/bug420596-5 differ
index 3a05d82..d433d91 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-6 and b/fuzz/static_seed/regexp/bug420596-6 differ
index 88e1660..80d821e 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-7 and b/fuzz/static_seed/regexp/bug420596-7 differ
index 4575a92..17456c9 100644 (file)
Binary files a/fuzz/static_seed/regexp/bug420596-8 and b/fuzz/static_seed/regexp/bug420596-8 differ
index 5acbf86..edcb943 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-1 and b/fuzz/static_seed/regexp/content-1 differ
index f131454..f0cd363 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-10 and b/fuzz/static_seed/regexp/content-10 differ
index 4e6b663..d9f4a93 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-2 and b/fuzz/static_seed/regexp/content-2 differ
index b13fc8d..309c920 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-3 and b/fuzz/static_seed/regexp/content-3 differ
index 47c5d6d..20ffbb7 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-4 and b/fuzz/static_seed/regexp/content-4 differ
index f93860e..faa7b53 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-5 and b/fuzz/static_seed/regexp/content-5 differ
index e5c6e14..98ef3aa 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-6 and b/fuzz/static_seed/regexp/content-6 differ
index 4868dd2..b0d17af 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-7 and b/fuzz/static_seed/regexp/content-7 differ
index a3a87d0..51aeb7b 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-8 and b/fuzz/static_seed/regexp/content-8 differ
index 91f0d9e..589d928 100644 (file)
Binary files a/fuzz/static_seed/regexp/content-9 and b/fuzz/static_seed/regexp/content-9 differ
index ba00382..9959fb4 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-1 and b/fuzz/static_seed/regexp/hard-1 differ
index 7db28fa..36db287 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-10 and b/fuzz/static_seed/regexp/hard-10 differ
index ed38b91..17016bd 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-2 and b/fuzz/static_seed/regexp/hard-2 differ
index 7b16da0..f3f1c0b 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-3 and b/fuzz/static_seed/regexp/hard-3 differ
index 2ece886..13bcd77 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-4 and b/fuzz/static_seed/regexp/hard-4 differ
index 870a3ec..41e5310 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-5 and b/fuzz/static_seed/regexp/hard-5 differ
index 06aa7d0..d55d808 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-6 and b/fuzz/static_seed/regexp/hard-6 differ
index 50a9ec3..0dfd684 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-7 and b/fuzz/static_seed/regexp/hard-7 differ
index 0991129..8159843 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-8 and b/fuzz/static_seed/regexp/hard-8 differ
index 5bd1d89..a4e9ece 100644 (file)
Binary files a/fuzz/static_seed/regexp/hard-9 and b/fuzz/static_seed/regexp/hard-9 differ
index 608eb9a..6d43f81 100644 (file)
Binary files a/fuzz/static_seed/regexp/ncname-1 and b/fuzz/static_seed/regexp/ncname-1 differ
index cfb9b96..bb9ff54 100644 (file)
Binary files a/fuzz/static_seed/regexp/ncname-2 and b/fuzz/static_seed/regexp/ncname-2 differ
index 07a6a08..605ccc5 100644 (file)
Binary files a/fuzz/static_seed/regexp/ncname-3 and b/fuzz/static_seed/regexp/ncname-3 differ
index 87e937f..facf97d 100644 (file)
Binary files a/fuzz/static_seed/regexp/ncname-4 and b/fuzz/static_seed/regexp/ncname-4 differ
index ad29456..ad22334 100644 (file)
Binary files a/fuzz/static_seed/regexp/ncname-5 and b/fuzz/static_seed/regexp/ncname-5 differ
index 71448f2..2c4bb3d 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-1 and b/fuzz/static_seed/regexp/ranges-1 differ
index 91aed3c..61c3d3d 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-10 and b/fuzz/static_seed/regexp/ranges-10 differ
index 76eb5de..6133262 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-11 and b/fuzz/static_seed/regexp/ranges-11 differ
index 9c3bc66..4b6be37 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-12 and b/fuzz/static_seed/regexp/ranges-12 differ
index 9369f7a..f766e22 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-2 and b/fuzz/static_seed/regexp/ranges-2 differ
index 58a3a08..7c03f87 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-3 and b/fuzz/static_seed/regexp/ranges-3 differ
index da7e9da..08a0a9a 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-4 and b/fuzz/static_seed/regexp/ranges-4 differ
index 83ad4a8..ce3f25a 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-5 and b/fuzz/static_seed/regexp/ranges-5 differ
index 3bc9758..523b637 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-6 and b/fuzz/static_seed/regexp/ranges-6 differ
index fa89038..091ff05 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-7 and b/fuzz/static_seed/regexp/ranges-7 differ
index 96f0bb6..210f709 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-8 and b/fuzz/static_seed/regexp/ranges-8 differ
index 8e3fc43..7da8a2a 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges-9 and b/fuzz/static_seed/regexp/ranges-9 differ
index 044a8eb..003c2c5 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-1 and b/fuzz/static_seed/regexp/ranges2-1 differ
index 19e2aa2..261bf56 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-10 and b/fuzz/static_seed/regexp/ranges2-10 differ
index 89be181..c6c5bd0 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-11 and b/fuzz/static_seed/regexp/ranges2-11 differ
index 42ebdd3..0a729f2 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-12 and b/fuzz/static_seed/regexp/ranges2-12 differ
index 026f7b8..9fc2ce1 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-2 and b/fuzz/static_seed/regexp/ranges2-2 differ
index 83e78a9..08a3963 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-3 and b/fuzz/static_seed/regexp/ranges2-3 differ
index 847b4e8..c965555 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-4 and b/fuzz/static_seed/regexp/ranges2-4 differ
index 349168d..2e65f5d 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-5 and b/fuzz/static_seed/regexp/ranges2-5 differ
index 5d2a407..4990264 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-6 and b/fuzz/static_seed/regexp/ranges2-6 differ
index 74fbafb..5f3e2c3 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-7 and b/fuzz/static_seed/regexp/ranges2-7 differ
index 125bfa9..9b384e5 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-8 and b/fuzz/static_seed/regexp/ranges2-8 differ
index f2cf128..e08ad99 100644 (file)
Binary files a/fuzz/static_seed/regexp/ranges2-9 and b/fuzz/static_seed/regexp/ranges2-9 differ
index 3bc1792..20e37e0 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-1 and b/fuzz/static_seed/regexp/xpath-1 differ
index e4f4b0c..1bdb0a8 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-10 and b/fuzz/static_seed/regexp/xpath-10 differ
index 318e0cc..5e26ec2 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-11 and b/fuzz/static_seed/regexp/xpath-11 differ
index f204295..e044486 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-12 and b/fuzz/static_seed/regexp/xpath-12 differ
index 70fccd5..9cb2874 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-13 and b/fuzz/static_seed/regexp/xpath-13 differ
index 357ce2b..3b9003f 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-14 and b/fuzz/static_seed/regexp/xpath-14 differ
index 2a10a83..64b071e 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-15 and b/fuzz/static_seed/regexp/xpath-15 differ
index 1f3089f..44b612b 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-16 and b/fuzz/static_seed/regexp/xpath-16 differ
index a9d542f..0370668 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-17 and b/fuzz/static_seed/regexp/xpath-17 differ
index 651eb9d..0351911 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-18 and b/fuzz/static_seed/regexp/xpath-18 differ
index fefea8f..f4a153c 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-19 and b/fuzz/static_seed/regexp/xpath-19 differ
index 81e5fba..0a8bae7 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-2 and b/fuzz/static_seed/regexp/xpath-2 differ
index 1f3089f..44b612b 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-20 and b/fuzz/static_seed/regexp/xpath-20 differ
index 706a702..2d6c7df 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-21 and b/fuzz/static_seed/regexp/xpath-21 differ
index a246f84..1e8db88 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-22 and b/fuzz/static_seed/regexp/xpath-22 differ
index 02753be..233f27e 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-23 and b/fuzz/static_seed/regexp/xpath-23 differ
index 331105c..c970a5e 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-24 and b/fuzz/static_seed/regexp/xpath-24 differ
index ce3da44..649e8f4 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-25 and b/fuzz/static_seed/regexp/xpath-25 differ
index b3bf8c2..13f6f24 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-26 and b/fuzz/static_seed/regexp/xpath-26 differ
index 74bbe46..3fea5c9 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-27 and b/fuzz/static_seed/regexp/xpath-27 differ
index b38a709..8d28581 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-28 and b/fuzz/static_seed/regexp/xpath-28 differ
index 104d4e5..a62aafe 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-29 and b/fuzz/static_seed/regexp/xpath-29 differ
index 6d7be85..40bba5a 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-3 and b/fuzz/static_seed/regexp/xpath-3 differ
index b681ff1..60105af 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-30 and b/fuzz/static_seed/regexp/xpath-30 differ
index cd87b0e..f7d319d 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-31 and b/fuzz/static_seed/regexp/xpath-31 differ
index c5cac32..b3708da 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-32 and b/fuzz/static_seed/regexp/xpath-32 differ
index 89e3fcd..4ad749f 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-33 and b/fuzz/static_seed/regexp/xpath-33 differ
index b65a3d6..c3e184c 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-34 and b/fuzz/static_seed/regexp/xpath-34 differ
index 252a70c..41ec109 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-35 and b/fuzz/static_seed/regexp/xpath-35 differ
index 30718c5..d8c875e 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-4 and b/fuzz/static_seed/regexp/xpath-4 differ
index 06ad88e..1e282d0 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-5 and b/fuzz/static_seed/regexp/xpath-5 differ
index 6678772..52405e4 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-6 and b/fuzz/static_seed/regexp/xpath-6 differ
index e69ad85..81ebb61 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-7 and b/fuzz/static_seed/regexp/xpath-7 differ
index a8120cc..9132035 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-8 and b/fuzz/static_seed/regexp/xpath-8 differ
index c037ce7..fb88269 100644 (file)
Binary files a/fuzz/static_seed/regexp/xpath-9 and b/fuzz/static_seed/regexp/xpath-9 differ
index 945c9b4..6cac6b0 100644 (file)
Binary files a/fuzz/static_seed/uri/dot and b/fuzz/static_seed/uri/dot differ
index 808e58a..833329f 100644 (file)
Binary files a/fuzz/static_seed/uri/full and b/fuzz/static_seed/uri/full differ
index b0c7ffb..119379d 100644 (file)
 #include "fuzz.h"
 
 #ifdef HAVE_HTML_FUZZER
-  #define LLVMFuzzerInitialize fuzzHtmlInit
-  #define LLVMFuzzerTestOneInput fuzzHtml
-  #include "html.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzHtmlInit(int *argc, char ***argv);
+int fuzzHtml(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzHtmlInit
+#define LLVMFuzzerTestOneInput fuzzHtml
+#include "html.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 #ifdef HAVE_REGEXP_FUZZER
-  #define LLVMFuzzerInitialize fuzzRegexpInit
-  #define LLVMFuzzerTestOneInput fuzzRegexp
-  #include "regexp.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzRegexpInit(int *argc, char ***argv);
+int fuzzRegexp(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzRegexpInit
+#define LLVMFuzzerTestOneInput fuzzRegexp
+#include "regexp.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 #ifdef HAVE_SCHEMA_FUZZER
-  #define LLVMFuzzerInitialize fuzzSchemaInit
-  #define LLVMFuzzerTestOneInput fuzzSchema
-  #include "schema.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzSchemaInit(int *argc, char ***argv);
+int fuzzSchema(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzSchemaInit
+#define LLVMFuzzerTestOneInput fuzzSchema
+#include "schema.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 #ifdef HAVE_URI_FUZZER
-  #define LLVMFuzzerInitialize fuzzUriInit
-  #define LLVMFuzzerTestOneInput fuzzUri
-  #include "uri.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzUriInit(int *argc, char ***argv);
+int fuzzUri(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzUriInit
+#define LLVMFuzzerTestOneInput fuzzUri
+#include "uri.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
+#endif
+
+#ifdef HAVE_VALID_FUZZER
+int fuzzValidInit(int *argc, char ***argv);
+int fuzzValid(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzValidInit
+#define LLVMFuzzerTestOneInput fuzzValid
+#include "valid.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
+#endif
+
+#ifdef HAVE_XINCLUDE_FUZZER
+int fuzzXIncludeInit(int *argc, char ***argv);
+int fuzzXInclude(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzXIncludeInit
+#define LLVMFuzzerTestOneInput fuzzXInclude
+#include "xinclude.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 #ifdef HAVE_XML_FUZZER
-  #define LLVMFuzzerInitialize fuzzXmlInit
-  #define LLVMFuzzerTestOneInput fuzzXml
-  #include "xml.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzXmlInit(int *argc, char ***argv);
+int fuzzXml(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzXmlInit
+#define LLVMFuzzerTestOneInput fuzzXml
+#include "xml.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 #ifdef HAVE_XPATH_FUZZER
-  #define LLVMFuzzerInitialize fuzzXPathInit
-  #define LLVMFuzzerTestOneInput fuzzXPath
-  #include "xpath.c"
-  #undef LLVMFuzzerInitialize
-  #undef LLVMFuzzerTestOneInput
+int fuzzXPathInit(int *argc, char ***argv);
+int fuzzXPath(const char *data, size_t size);
+#define LLVMFuzzerInitialize fuzzXPathInit
+#define LLVMFuzzerTestOneInput fuzzXPath
+#include "xpath.c"
+#undef LLVMFuzzerInitialize
+#undef LLVMFuzzerTestOneInput
 #endif
 
 typedef int
@@ -71,7 +103,7 @@ static int
 testFuzzer(initFunc init, fuzzFunc fuzz, const char *pattern) {
     glob_t globbuf;
     int ret = -1;
-    int i;
+    size_t i;
 
     if (glob(pattern, 0, NULL, &globbuf) != 0) {
         fprintf(stderr, "pattern %s matches no files\n", pattern);
@@ -105,7 +137,7 @@ error:
 
 #ifdef HAVE_XML_FUZZER
 static int
-testEntityLoader() {
+testEntityLoader(void) {
     static const char data[] =
         "doc.xml\\\n"
         "<!DOCTYPE doc SYSTEM \"doc.dtd\">\n"
@@ -115,14 +147,9 @@ testEntityLoader() {
         "<!ENTITY ent SYSTEM \"ent.txt\">\\\n"
         "ent.txt\\\n"
         "Hello, world!\\\n";
-    static xmlChar expected[] =
-        "<?xml version=\"1.0\"?>\n"
-        "<!DOCTYPE doc SYSTEM \"doc.dtd\">\n"
-        "<doc>Hello, world!</doc>\n";
     const char *docBuffer;
     size_t docSize;
     xmlDocPtr doc;
-    xmlChar *out;
     int ret = 0;
 
     xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
@@ -133,13 +160,23 @@ testEntityLoader() {
     doc = xmlReadMemory(docBuffer, docSize, NULL, NULL,
                         XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
 
-    xmlDocDumpMemory(doc, &out, NULL);
-    if (xmlStrcmp(out, expected) != 0) {
-        fprintf(stderr, "Expected:\n%sGot:\n%s", expected, out);
-        ret = 1;
+#ifdef LIBXML_OUTPUT_ENABLED
+    {
+        static xmlChar expected[] =
+            "<?xml version=\"1.0\"?>\n"
+            "<!DOCTYPE doc SYSTEM \"doc.dtd\">\n"
+            "<doc>Hello, world!</doc>\n";
+        xmlChar *out;
+
+        xmlDocDumpMemory(doc, &out, NULL);
+        if (xmlStrcmp(out, expected) != 0) {
+            fprintf(stderr, "Expected:\n%sGot:\n%s", expected, out);
+            ret = 1;
+        }
+        xmlFree(out);
     }
+#endif
 
-    xmlFree(out);
     xmlFreeDoc(doc);
     xmlFuzzDataCleanup();
 
@@ -148,7 +185,7 @@ testEntityLoader() {
 #endif
 
 int
-main() {
+main(void) {
     int ret = 0;
 
 #ifdef HAVE_XML_FUZZER
@@ -168,7 +205,15 @@ main() {
         ret = 1;
 #endif
 #ifdef HAVE_URI_FUZZER
-    if (testFuzzer(NULL, fuzzUri, "seed/uri/*") != 0)
+    if (testFuzzer(fuzzUriInit, fuzzUri, "seed/uri/*") != 0)
+        ret = 1;
+#endif
+#ifdef HAVE_VALID_FUZZER
+    if (testFuzzer(fuzzValidInit, fuzzValid, "seed/valid/*") != 0)
+        ret = 1;
+#endif
+#ifdef HAVE_XINCLUDE_FUZZER
+    if (testFuzzer(fuzzXIncludeInit, fuzzXInclude, "seed/xinclude/*") != 0)
         ret = 1;
 #endif
 #ifdef HAVE_XML_FUZZER
index 5e4c099..5bc279f 100644 (file)
@@ -8,40 +8,54 @@
 #include "fuzz.h"
 
 int
+LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
+                     char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
+    xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
+
+    return 0;
+}
+
+int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
     xmlURIPtr uri;
-    char *str[2] = { NULL, NULL };
-    size_t numStrings;
+    size_t maxAlloc;
+    const char *str1, *str2;
+    char *copy;
 
     if (size > 10000)
         return(0);
 
-    numStrings = xmlFuzzExtractStrings(data, size, str, 2);
+    xmlFuzzDataInit(data, size);
+    maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
+    str1 = xmlFuzzReadString(NULL);
+    str2 = xmlFuzzReadString(NULL);
+
+    xmlFuzzMemSetLimit(maxAlloc);
 
-    uri = xmlParseURI(str[0]);
+    uri = xmlParseURI(str1);
     xmlFree(xmlSaveUri(uri));
     xmlFreeURI(uri);
 
-    uri = xmlParseURIRaw(str[0], 1);
+    uri = xmlParseURIRaw(str1, 1);
     xmlFree(xmlSaveUri(uri));
     xmlFreeURI(uri);
 
-    xmlFree(xmlURIUnescapeString(str[0], -1, NULL));
-    xmlFree(xmlURIEscape(BAD_CAST str[0]));
-    xmlFree(xmlCanonicPath(BAD_CAST str[0]));
-    xmlFree(xmlPathToURI(BAD_CAST str[0]));
+    xmlFree(xmlURIUnescapeString(str1, -1, NULL));
+    xmlFree(xmlURIEscape(BAD_CAST str1));
+    xmlFree(xmlCanonicPath(BAD_CAST str1));
+    xmlFree(xmlPathToURI(BAD_CAST str1));
 
-    if (numStrings >= 2) {
-        xmlFree(xmlBuildURI(BAD_CAST str[1], BAD_CAST str[0]));
-        xmlFree(xmlBuildRelativeURI(BAD_CAST str[1], BAD_CAST str[0]));
-        xmlFree(xmlURIEscapeStr(BAD_CAST str[0], BAD_CAST str[1]));
-    }
+    xmlFree(xmlBuildURI(BAD_CAST str2, BAD_CAST str1));
+    xmlFree(xmlBuildRelativeURI(BAD_CAST str2, BAD_CAST str1));
+    xmlFree(xmlURIEscapeStr(BAD_CAST str1, BAD_CAST str2));
 
-    /* Modifies string, so must come last. */
-    xmlNormalizeURIPath(str[0]);
+    copy = (char *) xmlCharStrdup(str1);
+    xmlNormalizeURIPath(copy);
+    xmlFree(copy);
 
-    xmlFree(str[0]);
-    xmlFree(str[1]);
+    xmlFuzzMemSetLimit(0);
+    xmlFuzzDataCleanup();
 
     return 0;
 }
diff --git a/fuzz/valid.c b/fuzz/valid.c
new file mode 100644 (file)
index 0000000..264e903
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * valid.c: a libFuzzer target to test DTD validation.
+ *
+ * See Copyright for the status of this software.
+ */
+
+#include <libxml/catalog.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xmlreader.h>
+#include "fuzz.h"
+
+int
+LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
+                     char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
+    xmlInitParser();
+#ifdef LIBXML_CATALOG_ENABLED
+    xmlInitializeCatalog();
+#endif
+    xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
+    xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
+
+    return 0;
+}
+
+int
+LLVMFuzzerTestOneInput(const char *data, size_t size) {
+    xmlDocPtr doc;
+    xmlValidCtxtPtr vctxt;
+    const char *docBuffer, *docUrl;
+    size_t maxAlloc, docSize;
+    int opts;
+
+    xmlFuzzDataInit(data, size);
+    opts = (int) xmlFuzzReadInt(4);
+    opts &= ~XML_PARSE_XINCLUDE;
+    opts |= XML_PARSE_DTDVALID;
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
+
+    xmlFuzzReadEntities();
+    docBuffer = xmlFuzzMainEntity(&docSize);
+    docUrl = xmlFuzzMainUrl();
+    if (docBuffer == NULL)
+        goto exit;
+
+    /* Pull parser */
+
+    xmlFuzzMemSetLimit(maxAlloc);
+    doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
+    xmlFreeDoc(doc);
+
+    /* Post validation */
+
+    xmlFuzzMemSetLimit(maxAlloc);
+    doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts & ~XML_PARSE_DTDVALID);
+    vctxt = xmlNewValidCtxt();
+    xmlValidateDocument(vctxt, doc);
+    xmlFreeValidCtxt(vctxt);
+    xmlFreeDoc(doc);
+
+    /* Push parser */
+
+#ifdef LIBXML_PUSH_ENABLED
+    {
+        static const size_t maxChunkSize = 128;
+        xmlParserCtxtPtr ctxt;
+        size_t consumed, chunkSize;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl);
+        if (ctxt == NULL)
+            goto exit;
+        xmlCtxtUseOptions(ctxt, opts);
+
+        for (consumed = 0; consumed < docSize; consumed += chunkSize) {
+            chunkSize = docSize - consumed;
+            if (chunkSize > maxChunkSize)
+                chunkSize = maxChunkSize;
+            xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
+        }
+
+        xmlParseChunk(ctxt, NULL, 0, 1);
+        xmlFreeDoc(ctxt->myDoc);
+        xmlFreeParserCtxt(ctxt);
+    }
+#endif
+
+    /* Reader */
+
+#ifdef LIBXML_READER_ENABLED
+    {
+        xmlTextReaderPtr reader;
+        int j;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
+        if (reader == NULL)
+            goto exit;
+        while (xmlTextReaderRead(reader) == 1) {
+            if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
+                int i, n = xmlTextReaderAttributeCount(reader);
+                for (i=0; i<n; i++) {
+                    xmlTextReaderMoveToAttributeNo(reader, i);
+                    while (xmlTextReaderReadAttributeValue(reader) == 1);
+                }
+            }
+        }
+        for (j = 0; j < 10; j++)
+            xmlTextReaderRead(reader);
+        xmlFreeTextReader(reader);
+    }
+#endif
+
+exit:
+    xmlFuzzMemSetLimit(0);
+    xmlFuzzDataCleanup();
+    xmlResetLastError();
+    return(0);
+}
+
diff --git a/fuzz/valid.options b/fuzz/valid.options
new file mode 100644 (file)
index 0000000..dda14e0
--- /dev/null
@@ -0,0 +1,3 @@
+[libfuzzer]
+dict = xml.dict
+timeout = 20
diff --git a/fuzz/xinclude.c b/fuzz/xinclude.c
new file mode 100644 (file)
index 0000000..3789ca5
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * xinclude.c: a libFuzzer target to test the XInclude engine.
+ *
+ * See Copyright for the status of this software.
+ */
+
+#include <libxml/catalog.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xinclude.h>
+#include <libxml/xmlreader.h>
+#include "fuzz.h"
+
+int
+LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
+                     char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
+    xmlInitParser();
+#ifdef LIBXML_CATALOG_ENABLED
+    xmlInitializeCatalog();
+#endif
+    xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
+    xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
+
+    return 0;
+}
+
+int
+LLVMFuzzerTestOneInput(const char *data, size_t size) {
+    xmlDocPtr doc;
+    const char *docBuffer, *docUrl;
+    size_t maxAlloc, docSize;
+    int opts;
+
+    xmlFuzzDataInit(data, size);
+    opts = (int) xmlFuzzReadInt(4);
+    opts |= XML_PARSE_XINCLUDE;
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
+
+    xmlFuzzReadEntities();
+    docBuffer = xmlFuzzMainEntity(&docSize);
+    docUrl = xmlFuzzMainUrl();
+    if (docBuffer == NULL)
+        goto exit;
+
+    /* Pull parser */
+
+    xmlFuzzMemSetLimit(maxAlloc);
+    doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
+    xmlXIncludeProcessFlags(doc, opts);
+    xmlFreeDoc(doc);
+
+    /* Reader */
+
+#ifdef LIBXML_READER_ENABLED
+    {
+        xmlTextReaderPtr reader;
+        int j;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
+        if (reader == NULL)
+            goto exit;
+        while (xmlTextReaderRead(reader) == 1) {
+            if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
+                int i, n = xmlTextReaderAttributeCount(reader);
+                for (i=0; i<n; i++) {
+                    xmlTextReaderMoveToAttributeNo(reader, i);
+                    while (xmlTextReaderReadAttributeValue(reader) == 1);
+                }
+            }
+        }
+        for (j = 0; j < 10; j++)
+            xmlTextReaderRead(reader);
+        xmlFreeTextReader(reader);
+    }
+#endif
+
+exit:
+    xmlFuzzMemSetLimit(0);
+    xmlFuzzDataCleanup();
+    xmlResetLastError();
+    return(0);
+}
+
diff --git a/fuzz/xinclude.options b/fuzz/xinclude.options
new file mode 100644 (file)
index 0000000..dda14e0
--- /dev/null
@@ -0,0 +1,3 @@
+[libfuzzer]
+dict = xml.dict
+timeout = 20
index 8b4c4ef..bbe05c9 100644 (file)
@@ -8,13 +8,13 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xmlerror.h>
-#include <libxml/xinclude.h>
 #include <libxml/xmlreader.h>
 #include "fuzz.h"
 
 int
 LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
                      char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
     xmlInitParser();
 #ifdef LIBXML_CATALOG_ENABLED
     xmlInitializeCatalog();
@@ -27,22 +27,20 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
 
 int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
-    static const size_t maxChunkSize = 128;
     xmlDocPtr doc;
-    xmlParserCtxtPtr ctxt;
-    xmlTextReaderPtr reader;
-    xmlChar *out;
     const char *docBuffer, *docUrl;
-    size_t maxSize, docSize, consumed, chunkSize;
-    int opts, outSize;
+    size_t maxAlloc, docSize;
+    int opts;
 
     xmlFuzzDataInit(data, size);
-    opts = xmlFuzzReadInt();
-
-    /* Lower maximum size when processing entities for now. */
-    maxSize = opts & XML_PARSE_NOENT ? 50000 : 500000;
-    if (size > maxSize)
-        goto exit;
+    opts = (int) xmlFuzzReadInt(4);
+    /*
+     * Disable options that are known to cause timeouts
+     */
+    opts &= ~XML_PARSE_XINCLUDE &
+            ~XML_PARSE_DTDVALID &
+            ~XML_PARSE_SAX1;
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
 
     xmlFuzzReadEntities();
     docBuffer = xmlFuzzMainEntity(&docSize);
@@ -52,51 +50,77 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
 
     /* Pull parser */
 
+    xmlFuzzMemSetLimit(maxAlloc);
     doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
-    if (opts & XML_PARSE_XINCLUDE)
-        xmlXIncludeProcessFlags(doc, opts);
-    /* Also test the serializer. */
-    xmlDocDumpMemory(doc, &out, &outSize);
-    xmlFree(out);
+
+#ifdef LIBXML_OUTPUT_ENABLED
+    {
+        xmlChar *out;
+        int outSize;
+
+        /* Also test the serializer. */
+        xmlDocDumpMemory(doc, &out, &outSize);
+        xmlFree(out);
+    }
+#endif
+
     xmlFreeDoc(doc);
 
     /* Push parser */
 
-    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl);
-    if (ctxt == NULL)
-        goto exit;
-    xmlCtxtUseOptions(ctxt, opts);
+#ifdef LIBXML_PUSH_ENABLED
+    {
+        static const size_t maxChunkSize = 128;
+        xmlParserCtxtPtr ctxt;
+        size_t consumed, chunkSize;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl);
+        if (ctxt == NULL)
+            goto exit;
+        xmlCtxtUseOptions(ctxt, opts);
+
+        for (consumed = 0; consumed < docSize; consumed += chunkSize) {
+            chunkSize = docSize - consumed;
+            if (chunkSize > maxChunkSize)
+                chunkSize = maxChunkSize;
+            xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
+        }
 
-    for (consumed = 0; consumed < docSize; consumed += chunkSize) {
-        chunkSize = docSize - consumed;
-        if (chunkSize > maxChunkSize)
-            chunkSize = maxChunkSize;
-        xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
+        xmlParseChunk(ctxt, NULL, 0, 1);
+        xmlFreeDoc(ctxt->myDoc);
+        xmlFreeParserCtxt(ctxt);
     }
-
-    xmlParseChunk(ctxt, NULL, 0, 1);
-    if (opts & XML_PARSE_XINCLUDE)
-        xmlXIncludeProcessFlags(ctxt->myDoc, opts);
-    xmlFreeDoc(ctxt->myDoc);
-    xmlFreeParserCtxt(ctxt);
+#endif
 
     /* Reader */
 
-    reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
-    if (reader == NULL)
-        goto exit;
-    while (xmlTextReaderRead(reader) == 1) {
-        if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
-            int i, n = xmlTextReaderAttributeCount(reader);
-            for (i=0; i<n; i++) {
-                xmlTextReaderMoveToAttributeNo(reader, i);
-                while (xmlTextReaderReadAttributeValue(reader) == 1);
+#ifdef LIBXML_READER_ENABLED
+    {
+        xmlTextReaderPtr reader;
+        int j;
+
+        xmlFuzzMemSetLimit(maxAlloc);
+        reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
+        if (reader == NULL)
+            goto exit;
+        while (xmlTextReaderRead(reader) == 1) {
+            if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
+                int i, n = xmlTextReaderAttributeCount(reader);
+                for (i=0; i<n; i++) {
+                    xmlTextReaderMoveToAttributeNo(reader, i);
+                    while (xmlTextReaderReadAttributeValue(reader) == 1);
+                }
             }
         }
+        for (j = 0; j < 10; j++)
+            xmlTextReaderRead(reader);
+        xmlFreeTextReader(reader);
     }
-    xmlFreeTextReader(reader);
+#endif
 
 exit:
+    xmlFuzzMemSetLimit(0);
     xmlFuzzDataCleanup();
     xmlResetLastError();
     return(0);
index 47652bd..a5eb70b 100644 (file)
@@ -11,6 +11,7 @@
 int
 LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
                      char ***argv ATTRIBUTE_UNUSED) {
+    xmlFuzzMemSetup();
     xmlInitParser();
     xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
 
@@ -21,28 +22,36 @@ int
 LLVMFuzzerTestOneInput(const char *data, size_t size) {
     xmlDocPtr doc;
     const char *expr, *xml;
-    size_t exprSize, xmlSize;
+    size_t maxAlloc, exprSize, xmlSize;
 
     if (size > 10000)
         return(0);
 
     xmlFuzzDataInit(data, size);
 
+    maxAlloc = xmlFuzzReadInt(4) % (size + 1);
     expr = xmlFuzzReadString(&exprSize);
     xml = xmlFuzzReadString(&xmlSize);
 
     /* Recovery mode allows more input to be fuzzed. */
     doc = xmlReadMemory(xml, xmlSize, NULL, NULL, XML_PARSE_RECOVER);
     if (doc != NULL) {
-        xmlXPathContextPtr xpctxt = xmlXPathNewContext(doc);
+        xmlXPathContextPtr xpctxt;
 
-        /* Operation limit to avoid timeout */
-        xpctxt->opLimit = 500000;
+        xmlFuzzMemSetLimit(maxAlloc);
 
-        xmlXPathFreeObject(xmlXPtrEval(BAD_CAST expr, xpctxt));
-        xmlXPathFreeContext(xpctxt);
+        xpctxt = xmlXPathNewContext(doc);
+        if (xpctxt != NULL) {
+            /* Operation limit to avoid timeout */
+            xpctxt->opLimit = 500000;
+
+            xmlXPathFreeObject(xmlXPtrEval(BAD_CAST expr, xpctxt));
+            xmlXPathFreeContext(xpctxt);
+        }
+
+        xmlFuzzMemSetLimit(0);
+        xmlFreeDoc(doc);
     }
-    xmlFreeDoc(doc);
 
     xmlFuzzDataCleanup();
     xmlResetLastError();
index c6252fc..4e229d1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Portions of this script have been (shamelessly) stolen from the
 # prior work of Daniel Veillard (genUnicode.py)
@@ -16,7 +16,6 @@
 #
 
 import sys
-import string
 import time
 
 #
@@ -28,21 +27,21 @@ def makeRange(lst):
     ret = []
     pos = 0
     while pos < len(lst):
-       try:            # index generates exception if not present
-           s = lst[pos:].index(1)      # look for start of next range
-       except:
-           break                       # if no more, finished
-       pos += s                        # pointer to start of possible range
-       try:
-           e = lst[pos:].index(0)      # look for end of range
-           e += pos
-       except:                         # if no end, set to end of list
-           e = len(lst)
-       ret.append((pos, e-1))          # append range tuple to list
-       pos = e + 1                     # ready to check for next range
+        try:            # index generates exception if not present
+            s = lst[pos:].index(1)      # look for start of next range
+        except:
+            break                       # if no more, finished
+        pos += s                        # pointer to start of possible range
+        try:
+            e = lst[pos:].index(0)      # look for end of range
+            e += pos
+        except:                         # if no end, set to end of list
+            e = len(lst)
+        ret.append((pos, e-1))          # append range tuple to list
+        pos = e + 1                     # ready to check for next range
     return ret
 
-sources = "chvalid.def"                        # input filename
+sources = "chvalid.def"                 # input filename
 
 # minTableSize gives the minimum number of ranges which must be present
 # before a 256-byte lookup table is produced.  If there are less than this
@@ -57,13 +56,13 @@ state = 0
 try:
     defines = open("chvalid.def", "r")
 except:
-    print "Missing chvalid.def, aborting ..."
+    print("Missing chvalid.def, aborting ...")
     sys.exit(1)
 
 #
 # The lines in the .def file have three types:-
 #   name:   Defines a new function block
-#   ur:            Defines individual or ranges of unicode values
+#   ur:     Defines individual or ranges of unicode values
 #   end:    Indicates the end of the function block
 #
 # These lines are processed below.
@@ -72,111 +71,111 @@ for line in defines.readlines():
     # ignore blank lines, or lines beginning with '#'
     if line[0] == '#':
         continue
-    line = string.strip(line)
+    line = line.strip()
     if line == '':
         continue
     # split line into space-separated fields, then split on type
     try:
-        fields = string.split(line, ' ')
-       #
-       # name line:
-       #   validate any previous function block already ended
-       #   validate this function not already defined
-       #   initialize an entry in the function dicitonary
-       #       including a mask table with no values yet defined
-       #
-       if fields[0] == 'name':
-           name = fields[1]
-           if state != 0:
-               print "'name' %s found before previous name" \
-                     "completed" % (fields[1])
-               continue
-           state = 1
-           if Functs.has_key(name):
-               print "name '%s' already present - may give" \
-                     " wrong results" % (name)
-           else:
-               # dict entry with two list elements (chdata, rangedata)
-               Functs[name] = [ [], [] ]
-               for v in range(256):
-                   Functs[name][0].append(0)
-       #
-       # end line:
-       #   validate there was a preceding function name line
-       #   set state to show no current function active
-       #
-       elif fields[0] == 'end':
-           if state == 0:
-               print "'end' found outside of function block"
-               continue
-           state = 0
-
-       #
-       # ur line:
-       #   validate function has been defined
-       #   process remaining fields on the line, which may be either
-       #       individual unicode values or ranges of values
-       #
-       elif fields[0] == 'ur':
-           if state != 1:
-               raise ValidationError, "'ur' found outside of 'name' block"
-           for el in fields[1:]:
-               pos = string.find(el, '..')
-               # pos <=0 means not a range, so must be individual value
-               if pos <= 0:
-                   # cheap handling of hex or decimal values
-                   if el[0:2] == '0x':
-                       value = int(el[2:],16)
-                   elif el[0] == "'":
-                       value = ord(el[1])
-                   else:
-                       value = int(el)
-                   if ((value < 0) | (value > 0x1fffff)):
-                       raise ValidationError, 'Illegal value (%s) in ch for'\
-                               ' name %s' % (el,name)
-                   # for ur we have only ranges (makes things simpler),
-                   # so convert val to range
-                   currange = (value, value)
-               # pos > 0 means this is a range, so isolate/validate
-               # the interval
-               else:
-                   # split the range into it's first-val, last-val
-                   (first, last) = string.split(el, "..")
-                   # convert values from text into binary
-                   if first[0:2] == '0x':      
-                       start = int(first[2:],16)
-                   elif first[0] == "'":
-                       start = ord(first[1])
-                   else:
-                       start = int(first)
-                   if last[0:2] == '0x':
-                       end = int(last[2:],16)
-                   elif last[0] == "'":
-                       end = ord(last[1])
-                   else:
-                       end = int(last)
-                   if (start < 0) | (end > 0x1fffff) | (start > end):
-                       raise ValidationError, "Invalid range '%s'" % el
-                   currange = (start, end)
-               # common path - 'currange' has the range, now take care of it
-               # We split on single-byte values vs. multibyte
-               if currange[1] < 0x100: # single-byte
-                   for ch in range(currange[0],currange[1]+1):
-                       # validate that value not previously defined
-                       if Functs[name][0][ch]:
-                           msg = "Duplicate ch value '%s' for name '%s'" % (el, name)
-                           raise ValidationError, msg
-                       Functs[name][0][ch] = 1
-               else:                   # multi-byte
-                   if currange in Functs[name][1]:
-                       raise ValidationError, "range already defined in" \
-                               " function"
-                   else:
-                       Functs[name][1].append(currange)
+        fields = line.split(' ')
+        #
+        # name line:
+        #   validate any previous function block already ended
+        #   validate this function not already defined
+        #   initialize an entry in the function dicitonary
+        #       including a mask table with no values yet defined
+        #
+        if fields[0] == 'name':
+            name = fields[1]
+            if state != 0:
+                print("'name' %s found before previous name" \
+                      "completed" % (fields[1]))
+                continue
+            state = 1
+            if name in Functs:
+                print("name '%s' already present - may give" \
+                      " wrong results" % (name))
+            else:
+                # dict entry with two list elements (chdata, rangedata)
+                Functs[name] = [ [], [] ]
+                for v in range(256):
+                    Functs[name][0].append(0)
+        #
+        # end line:
+        #   validate there was a preceding function name line
+        #   set state to show no current function active
+        #
+        elif fields[0] == 'end':
+            if state == 0:
+                print("'end' found outside of function block")
+                continue
+            state = 0
+
+        #
+        # ur line:
+        #   validate function has been defined
+        #   process remaining fields on the line, which may be either
+        #       individual unicode values or ranges of values
+        #
+        elif fields[0] == 'ur':
+            if state != 1:
+                raise Exception("'ur' found outside of 'name' block")
+            for el in fields[1:]:
+                pos = el.find('..')
+                # pos <=0 means not a range, so must be individual value
+                if pos <= 0:
+                    # cheap handling of hex or decimal values
+                    if el[0:2] == '0x':
+                        value = int(el[2:],16)
+                    elif el[0] == "'":
+                        value = ord(el[1])
+                    else:
+                        value = int(el)
+                    if ((value < 0) | (value > 0x1fffff)):
+                        raise Exception('Illegal value (%s) in ch for'\
+                                ' name %s' % (el,name))
+                    # for ur we have only ranges (makes things simpler),
+                    # so convert val to range
+                    currange = (value, value)
+                # pos > 0 means this is a range, so isolate/validate
+                # the interval
+                else:
+                    # split the range into it's first-val, last-val
+                    (first, last) = el.split("..")
+                    # convert values from text into binary
+                    if first[0:2] == '0x':
+                        start = int(first[2:],16)
+                    elif first[0] == "'":
+                        start = ord(first[1])
+                    else:
+                        start = int(first)
+                    if last[0:2] == '0x':
+                        end = int(last[2:],16)
+                    elif last[0] == "'":
+                        end = ord(last[1])
+                    else:
+                        end = int(last)
+                    if (start < 0) | (end > 0x1fffff) | (start > end):
+                        raise Exception("Invalid range '%s'" % el)
+                    currange = (start, end)
+                # common path - 'currange' has the range, now take care of it
+                # We split on single-byte values vs. multibyte
+                if currange[1] < 0x100: # single-byte
+                    for ch in range(currange[0],currange[1]+1):
+                        # validate that value not previously defined
+                        if Functs[name][0][ch]:
+                            msg = "Duplicate ch value '%s' for name '%s'" % (el, name)
+                            raise Exception(msg)
+                        Functs[name][0][ch] = 1
+                else:                   # multi-byte
+                    if currange in Functs[name][1]:
+                        raise Exception("range already defined in" \
+                                " function")
+                    else:
+                        Functs[name][1].append(currange)
 
     except:
-       print "Failed to process line: %s" % (line)
-       raise
+        print("Failed to process line: %s" % (line))
+        raise
 #
 # At this point, the entire definition file has been processed.  Now we
 # enter the output phase, where we generate the two files chvalid.c and'
@@ -194,13 +193,13 @@ for line in defines.readlines():
 try:
     header = open("include/libxml/chvalid.h", "w")
 except:
-    print "Failed to open include/libxml/chvalid.h"
+    print("Failed to open include/libxml/chvalid.h")
     sys.exit(1)
 
 try:
     output = open("chvalid.c", "w")
 except:
-    print "Failed to open chvalid.c"
+    print("Failed to open chvalid.c")
     sys.exit(1)
 
 date = time.asctime(time.localtime(time.time()))
@@ -236,37 +235,37 @@ extern "C" {
 typedef struct _xmlChSRange xmlChSRange;
 typedef xmlChSRange *xmlChSRangePtr;
 struct _xmlChSRange {
-    unsigned short     low;
-    unsigned short     high;
+    unsigned short\tlow;
+    unsigned short\thigh;
 };
 
 typedef struct _xmlChLRange xmlChLRange;
 typedef xmlChLRange *xmlChLRangePtr;
 struct _xmlChLRange {
-    unsigned int       low;
-    unsigned int       high;
+    unsigned int\tlow;
+    unsigned int\thigh;
 };
 
 typedef struct _xmlChRangeGroup xmlChRangeGroup;
 typedef xmlChRangeGroup *xmlChRangeGroupPtr;
 struct _xmlChRangeGroup {
-    int                        nbShortRange;
-    int                        nbLongRange;
-    const xmlChSRange  *shortRange;    /* points to an array of ranges */
-    const xmlChLRange  *longRange;
+    int\t\t\tnbShortRange;
+    int\t\t\tnbLongRange;
+    const xmlChSRange\t*shortRange;\t/* points to an array of ranges */
+    const xmlChLRange\t*longRange;
 };
 
 /**
  * Range checking routine
  */
-XMLPUBFUN int XMLCALL
-               xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
+XMLPUBFUN int
+\t\txmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
 
 """ % (date, sources));
 output.write(
 """/*
- * chvalid.c:  this module implements the character range
- *             validation APIs
+ * chvalid.c:\tthis module implements the character range
+ *\t\tvalidation APIs
  *
  * This file is automatically generated from the cvs source
  * definition files using the genChRanges.py Python script
@@ -280,6 +279,8 @@ output.write(
 #include "libxml.h"
 #include <libxml/chvalid.h>
 
+#include <stddef.h>
+
 /*
  * The initial tables ({func_name}_tab) are used to validate whether a
  * single-byte character is within the specified group.  Each table
@@ -299,8 +300,7 @@ output.write(
 # compares, otherwise we output a 256-byte table and a macro to use it.
 #
 
-fkeys = Functs.keys()  # Dictionary of all defined functions
-fkeys.sort()           # Put some order to our output
+fkeys = sorted(Functs.keys())
 
 for f in fkeys:
 
@@ -308,12 +308,12 @@ for f in fkeys:
 # If the total number of such ranges is less than minTableSize, we generate
 # an inline macro for direct comparisons; if greater, we generate a lookup
 # table.
-    if max(Functs[f][0]) > 0:  # only check if at least one entry
+    if max(Functs[f][0]) > 0:   # only check if at least one entry
         rangeTable = makeRange(Functs[f][0])
-       numRanges = len(rangeTable)
-       if numRanges >= minTableSize:   # table is worthwhile
-           header.write("XMLPUBVAR const unsigned char %s_tab[256];\n" % f)
-           header.write("""
+        numRanges = len(rangeTable)
+        if numRanges >= minTableSize:   # table is worthwhile
+            header.write("XMLPUBVAR const unsigned char %s_tab[256];\n" % f)
+            header.write("""
 /**
  * %s_ch:
  * @c: char to validate
@@ -321,29 +321,29 @@ for f in fkeys:
  * Automatically generated by genChRanges.py
  */
 """ % f)
-           header.write("#define %s_ch(c)\t(%s_tab[(c)])\n" % (f, f))
-
-           # write the constant data to the code file
-           output.write("const unsigned char %s_tab[256] = {\n" % f)
-           pline = "   "
-           for n in range(255):
-               pline += " 0x%02x," % Functs[f][0][n]
-               if len(pline) > 72:
-                   output.write(pline + "\n")
-                   pline = "   "
-           output.write(pline + " 0x%02x };\n\n" % Functs[f][0][255])
-
-       else:           # inline check is used
-           # first another little optimisation - if space is present,
-           # put it at the front of the list so it is checked first
-           try:
-               ix = rangeTable.remove((0x20, 0x20))
-               rangeTable.insert(0, (0x20, 0x20))
-           except:
-               pass
-           firstFlag = 1
-           
-           header.write("""
+            header.write("#define %s_ch(c)\t(%s_tab[(c)])\n" % (f, f))
+
+            # write the constant data to the code file
+            output.write("const unsigned char %s_tab[256] = {\n" % f)
+            pline = "   "
+            for n in range(255):
+                pline += " 0x%02x," % Functs[f][0][n]
+                if len(pline) > 72:
+                    output.write(pline + "\n")
+                    pline = "   "
+            output.write(pline + " 0x%02x };\n\n" % Functs[f][0][255])
+
+        else:           # inline check is used
+            # first another little optimisation - if space is present,
+            # put it at the front of the list so it is checked first
+            try:
+                ix = rangeTable.remove((0x20, 0x20))
+                rangeTable.insert(0, (0x20, 0x20))
+            except:
+                pass
+            firstFlag = 1
+
+            header.write("""
 /**
  * %s_ch:
  * @c: char to validate
@@ -351,32 +351,32 @@ for f in fkeys:
  * Automatically generated by genChRanges.py
  */
 """ % f)
-           # okay, I'm tired of the messy lineup - let's automate it!
-           pline = "#define %s_ch(c)" % f
-           # 'ntab' is number of tabs needed to position to col. 33 from name end
-           ntab = 4 - (len(pline)) / 8
-           if ntab < 0:
-               ntab = 0
-           just = ""
-           for i in range(ntab):
-               just += "\t"
-           pline = pline + just + "("
-           for rg in rangeTable:
-               if not firstFlag:
-                   pline += " || \\\n\t\t\t\t "
-               else:
-                   firstFlag = 0
-               if rg[0] == rg[1]:              # single value - check equal
-                   pline += "((c) == 0x%x)" % rg[0]
-               else:                           # value range
-               # since we are doing char, also change range ending in 0xff
-                   if rg[1] != 0xff:
-                       pline += "((0x%x <= (c)) &&" % rg[0]
-                       pline += " ((c) <= 0x%x))" % rg[1]
-                   else:
-                       pline += " (0x%x <= (c))" % rg[0]
-           pline += ")\n"
-           header.write(pline)
+            # okay, I'm tired of the messy lineup - let's automate it!
+            pline = "#define %s_ch(c)" % f
+            # 'ntab' is number of tabs needed to position to col. 33 from name end
+            ntab = 4 - (len(pline)) // 8
+            if ntab < 0:
+                ntab = 0
+            just = ""
+            for i in range(ntab):
+                just += "\t"
+            pline = pline + just + "("
+            for rg in rangeTable:
+                if not firstFlag:
+                    pline += " || \\\n\t\t\t\t "
+                else:
+                    firstFlag = 0
+                if rg[0] == rg[1]:              # single value - check equal
+                    pline += "((c) == 0x%x)" % rg[0]
+                else:                           # value range
+                # since we are doing char, also change range ending in 0xff
+                    if rg[1] != 0xff:
+                        pline += "((0x%x <= (c)) &&" % rg[0]
+                        pline += " ((c) <= 0x%x))" % rg[1]
+                    else:
+                        pline += " (0x%x <= (c))" % rg[0]
+            pline += ")\n"
+            header.write(pline)
 
     header.write("""
 /**
@@ -387,44 +387,44 @@ for f in fkeys:
  */
 """ % f)
     pline = "#define %sQ(c)" % f
-    ntab = 4 - (len(pline)) / 8
+    ntab = 4 - (len(pline)) // 8
     if ntab < 0:
-       ntab = 0
+        ntab = 0
     just = ""
     for i in range(ntab):
-       just += "\t"
+        just += "\t"
     header.write(pline + just + "(((c) < 0x100) ? \\\n\t\t\t\t ")
     if max(Functs[f][0]) > 0:
-       header.write("%s_ch((c)) :" % f)
+        header.write("%s_ch((c)) :" % f)
     else:
-       header.write("0 :")
+        header.write("0 :")
 
     # if no ranges defined, value invalid if >= 0x100
     numRanges = len(Functs[f][1])
     if numRanges == 0:
-       header.write(" 0)\n\n")
+        header.write(" 0)\n\n")
     else:
-       if numRanges >= minTableSize:
-           header.write(" \\\n\t\t\t\t xmlCharInRange((c), &%sGroup))\n\n"  % f)
-       else:           # if < minTableSize, generate inline code
-           firstFlag = 1
-           for rg in Functs[f][1]:
-               if not firstFlag:
-                   pline += " || \\\n\t\t\t\t "
-               else:
-                   firstFlag = 0
-                   pline = "\\\n\t\t\t\t("
-               if rg[0] == rg[1]:              # single value - check equal
-                   pline += "((c) == 0x%x)" % rg[0]
-               else:                           # value range
-                   pline += "((0x%x <= (c)) &&" % rg[0]
-                   pline += " ((c) <= 0x%x))" % rg[1]
-           pline += "))\n\n"
-           header.write(pline)
+        if numRanges >= minTableSize:
+            header.write(" \\\n\t\t\t\t xmlCharInRange((c), &%sGroup))\n\n"  % f)
+        else:           # if < minTableSize, generate inline code
+            firstFlag = 1
+            for rg in Functs[f][1]:
+                if not firstFlag:
+                    pline += " || \\\n\t\t\t\t "
+                else:
+                    firstFlag = 0
+                    pline = "\\\n\t\t\t\t("
+                if rg[0] == rg[1]:              # single value - check equal
+                    pline += "((c) == 0x%x)" % rg[0]
+                else:                           # value range
+                    pline += "((0x%x <= (c)) &&" % rg[0]
+                    pline += " ((c) <= 0x%x))" % rg[1]
+            pline += "))\n\n"
+            header.write(pline)
 
 
     if len(Functs[f][1]) > 0:
-       header.write("XMLPUBVAR const xmlChRangeGroup %sGroup;\n" % f)
+        header.write("XMLPUBVAR const xmlChRangeGroup %sGroup;\n" % f)
 
 
 #
@@ -432,49 +432,49 @@ for f in fkeys:
 #
 
 for f in fkeys:
-    if len(Functs[f][1]) > 0:  # only generate if unicode ranges present
-       rangeTable = Functs[f][1]
-       rangeTable.sort()       # ascending tuple sequence
-       numShort = 0
-       numLong  = 0
-       for rg in rangeTable:
-           if rg[1] < 0x10000: # if short value
-               if numShort == 0:       # first occurrence
-                   pline = "static const xmlChSRange %s_srng[] = {" % f
-               else:
-                   pline += ","
-               numShort += 1
-               if len(pline) > 60:
-                   output.write(pline + "\n")
-                   pline = "    "
+    if len(Functs[f][1]) > 0:   # only generate if unicode ranges present
+        rangeTable = Functs[f][1]
+        rangeTable.sort()       # ascending tuple sequence
+        numShort = 0
+        numLong  = 0
+        for rg in rangeTable:
+            if rg[1] < 0x10000: # if short value
+                if numShort == 0:       # first occurrence
+                    pline = "static const xmlChSRange %s_srng[] = {" % f
+                else:
+                    pline += ","
+                numShort += 1
+                if len(pline) > 60:
+                    output.write(pline + "\n")
+                    pline = "    "
                 else:
                     pline += " "
-               pline += "{0x%x, 0x%x}" % (rg[0], rg[1])
-           else:               # if long value
-               if numLong == 0:        # first occurrence
-                   if numShort > 0:    # if there were shorts, finish them off
-                       output.write(pline + "};\n")
-                   pline = "static const xmlChLRange %s_lrng[] = { " % f
-               else:
-                   pline += ", "
-               numLong += 1
-               if len(pline) > 60:
-                   output.write(pline + "\n")
-                   pline = "    "
-               pline += "{0x%x, 0x%x}" % (rg[0], rg[1])
-       output.write(pline + "};\n")    # finish off last group
-
-       pline = "const xmlChRangeGroup %sGroup =\n\t{%d, %d, " % (f, numShort, numLong)
-       if numShort > 0:
-           pline += "%s_srng" % f
-       else:
-           pline += "(xmlChSRangePtr)0"
-       if numLong > 0:
-           pline += ", %s_lrng" % f
-       else:
-           pline += ", (xmlChLRangePtr)0"
-       
-       output.write(pline + "};\n\n")
+                pline += "{0x%x, 0x%x}" % (rg[0], rg[1])
+            else:               # if long value
+                if numLong == 0:        # first occurrence
+                    if numShort > 0:    # if there were shorts, finish them off
+                        output.write(pline + "};\n")
+                    pline = "static const xmlChLRange %s_lrng[] = { " % f
+                else:
+                    pline += ", "
+                numLong += 1
+                if len(pline) > 60:
+                    output.write(pline + "\n")
+                    pline = "    "
+                pline += "{0x%x, 0x%x}" % (rg[0], rg[1])
+        output.write(pline + "};\n")    # finish off last group
+
+        pline = "const xmlChRangeGroup %sGroup =\n\t{%d, %d, " % (f, numShort, numLong)
+        if numShort > 0:
+            pline += "%s_srng" % f
+        else:
+            pline += "(xmlChSRangePtr)0"
+        if numLong > 0:
+            pline += ", %s_lrng" % f
+        else:
+            pline += ", (xmlChLRangePtr)0"
+
+        output.write(pline + "};\n\n")
 
 output.write(
 """
@@ -495,43 +495,43 @@ xmlCharInRange (unsigned int val, const xmlChRangeGroup *rptr) {
     const xmlChLRange *lptr;
 
     if (rptr == NULL) return(0);
-    if (val < 0x10000) {       /* is val in 'short' or 'long'  array? */
-       if (rptr->nbShortRange == 0)
-           return 0;
-       low = 0;
-       high = rptr->nbShortRange - 1;
-       sptr = rptr->shortRange;
-       while (low <= high) {
-           mid = (low + high) / 2;
-           if ((unsigned short) val < sptr[mid].low) {
-               high = mid - 1;
-           } else {
-               if ((unsigned short) val > sptr[mid].high) {
-                   low = mid + 1;
-               } else {
-                   return 1;
-               }
-           }
-       }
+    if (val < 0x10000) {\t/* is val in 'short' or 'long'  array? */
+\tif (rptr->nbShortRange == 0)
+\t    return 0;
+\tlow = 0;
+\thigh = rptr->nbShortRange - 1;
+\tsptr = rptr->shortRange;
+\twhile (low <= high) {
+\t    mid = (low + high) / 2;
+\t    if ((unsigned short) val < sptr[mid].low) {
+\t\thigh = mid - 1;
+\t    } else {
+\t\tif ((unsigned short) val > sptr[mid].high) {
+\t\t    low = mid + 1;
+\t\t} else {
+\t\t    return 1;
+\t\t}
+\t    }
+\t}
     } else {
-       if (rptr->nbLongRange == 0) {
-           return 0;
-       }
-       low = 0;
-       high = rptr->nbLongRange - 1;
-       lptr = rptr->longRange;
-       while (low <= high) {
-           mid = (low + high) / 2;
-           if (val < lptr[mid].low) {
-               high = mid - 1;
-           } else {
-               if (val > lptr[mid].high) {
-                   low = mid + 1;
-               } else {
-                   return 1;
-               }
-           }
-       }
+\tif (rptr->nbLongRange == 0) {
+\t    return 0;
+\t}
+\tlow = 0;
+\thigh = rptr->nbLongRange - 1;
+\tlptr = rptr->longRange;
+\twhile (low <= high) {
+\t    mid = (low + high) / 2;
+\t    if (val < lptr[mid].low) {
+\t\thigh = mid - 1;
+\t    } else {
+\t\tif (val > lptr[mid].high) {
+\t\t    low = mid + 1;
+\t\t} else {
+\t\t    return 1;
+\t\t}
+\t    }
+\t}
     }
     return 0;
 }
@@ -559,7 +559,7 @@ for f in fkeys:
  */
 """)
     output.write("int\n%s(unsigned int ch) {\n    return(%sQ(ch));\n}\n\n" % (f,f))
-    header.write("XMLPUBFUN int XMLCALL\n\t\t%s(unsigned int ch);\n" % f);
+    header.write("XMLPUBFUN int\n\t\t%s(unsigned int ch);\n" % f);
 #
 # Run complete - write trailers and close the output files
 #
index ebf48e6..c6e13a8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Original script modified in November 2003 to take advantage of
 # the character-validation range routines, and updated to the
@@ -373,7 +373,7 @@ static xmlIntFunc
 
 for block in bkeys:
     name = block.replace('-', '')
-    header.write("XMLPUBFUN int XMLCALL xmlUCSIs%s\t(int code);\n" % name)
+    header.write("XMLPUBFUN int xmlUCSIs%s\t(int code);\n" % name)
     output.write("/**\n * xmlUCSIs%s:\n * @code: UCS code point\n" % (name))
     output.write(" *\n * Check whether the character is part of %s UCS Block\n"%
                  (block))
@@ -388,7 +388,7 @@ for block in bkeys:
         output.write("((code >= %s) && (code <= %s))" % (start, end))
     output.write(");\n}\n\n")
 
-header.write("\nXMLPUBFUN int XMLCALL xmlUCSIsBlock\t(int code, const char *block);\n\n")
+header.write("\nXMLPUBFUN int xmlUCSIsBlock\t(int code, const char *block);\n\n")
 output.write(
 """/**
  * xmlUCSIsBlock:
@@ -413,7 +413,7 @@ xmlUCSIsBlock(int code, const char *block) {
 
 for name in ckeys:
     ranges = Categories[name]
-    header.write("XMLPUBFUN int XMLCALL xmlUCSIsCat%s\t(int code);\n" % name)
+    header.write("XMLPUBFUN int xmlUCSIsCat%s\t(int code);\n" % name)
     output.write("/**\n * xmlUCSIsCat%s:\n * @code: UCS code point\n" % (name))
     output.write(" *\n * Check whether the character is part of %s UCS Category\n"%
                  (name))
@@ -438,7 +438,7 @@ for name in ckeys:
                          hex(begin), hex(end)))
     output.write(");\n}\n\n")
 
-header.write("\nXMLPUBFUN int XMLCALL xmlUCSIsCat\t(int code, const char *cat);\n")
+header.write("\nXMLPUBFUN int xmlUCSIsCat\t(int code, const char *cat);\n")
 output.write(
 """/**
  * xmlUCSIsCat:
index 172ed7e..16c0e37 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # generate a tester program for the API
 #
@@ -205,6 +205,10 @@ extra_pre_call = {
 """,
    "xmlParserInputBufferCreateFd":
        "if (fd >= 0) fd = -1;",
+   "xmlSAXDefaultVersion": """
+        {
+            int original_version = xmlSAXDefaultVersion(2);
+""",
 }
 extra_post_call = {
    "xmlAddChild": 
@@ -261,7 +265,10 @@ extra_post_call = {
    "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
    "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
    "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}",
-   "xmlBufferSetAllocationScheme": "if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;}"
+   "xmlSAXDefaultVersion": """
+            (void)xmlSAXDefaultVersion(original_version);
+        }
+""",
 }
 
 modules = []
@@ -800,9 +807,9 @@ test_%s(void) {
                 if btype == "const_char_ptr" or btype == "const_xmlChar_ptr":
                     test.write(
                         "        if ((%s != NULL) &&\n"
-                        "            (%s > (int) strlen((const char *) %s) + 1))\n"
-                        "            continue;\n"
-                        % (bnam, nam, bnam))
+                        "            (%s > xmlStrlen(BAD_CAST %s)))\n"
+                        "            %s = 0;\n"
+                        % (bnam, nam, bnam, nam))
                     break
         i = i + 1;
 
diff --git a/global.data b/global.data
deleted file mode 100644 (file)
index 519519a..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#type,name,array?,threadGlobalDefault accessor?
-int,oldXMLWDcompatibility,,
-xmlBufferAllocationScheme,xmlBufferAllocScheme,,1
-int,xmlDefaultBufferSize,,1
-xmlSAXHandlerV1,xmlDefaultSAXHandler,,
-xmlSAXLocator,xmlDefaultSAXLocator,,
-int,xmlDoValidityCheckingDefaultValue,,1
-xmlGenericErrorFunc,xmlGenericError,,
-xmlStructuredErrorFunc,xmlStructuredError,,
-void *,xmlGenericErrorContext,,
-void *,xmlStructuredErrorContext,,
-int,xmlGetWarningsDefaultValue,,1
-int,xmlIndentTreeOutput,,1
-const char *,xmlTreeIndentString,,1
-int,xmlKeepBlanksDefaultValue,,1
-int,xmlLineNumbersDefaultValue,,1
-int,xmlLoadExtDtdDefaultValue,,1
-int,xmlParserDebugEntities,,1
-const char *,xmlParserVersion,,
-int,xmlPedanticParserDefaultValue,,1
-int,xmlSaveNoEmptyTags,,1
-#const xmlChar,xmlStringComment,[],1
-#const xmlChar,xmlStringText,[],1
-#const xmlChar,xmlStringTextNoenc,[],1
-int,xmlSubstituteEntitiesDefaultValue,,1
-xmlRegisterNodeFunc,xmlRegisterNodeDefaultValue,,
-xmlDeregisterNodeFunc,xmlDeregisterNodeDefaultValue,,
-xmlParserInputBufferCreateFilenameFunc,xmlParserInputBufferCreateFilenameValue,,
-xmlOutputBufferCreateFilenameFunc,xmlOutputBufferCreateFilenameValue,,
index a15ac30..7ed67d7 100644 (file)
--- a/globals.c
+++ b/globals.c
@@ -2,9 +2,6 @@
  * globals.c: definition and handling of the set of global variables
  *            of the library
  *
- * The bottom of this file is automatically generated by build_glob.py
- * based on the description file global.data
- *
  * See Copyright for the status of this software.
  *
  * Gary Pennington <Gary.Pennington@uk.sun.com>
 #define IN_LIBXML
 #include "libxml.h"
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#define XML_GLOBALS_NO_REDEFINITION
 #include <libxml/globals.h>
+#include <libxml/xmlerror.h>
 #include <libxml/xmlmemory.h>
+#include <libxml/xmlIO.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/parser.h>
 #include <libxml/threads.h>
+#include <libxml/tree.h>
+#include <libxml/SAX.h>
+#include <libxml/SAX2.h>
 
-/* #define DEBUG_GLOBALS */
+#include "private/error.h"
+#include "private/globals.h"
+#include "private/threads.h"
+#include "private/tree.h"
+
+/*
+ * Thread-local storage emulation.
+ *
+ * This works by replacing a global variable
+ *
+ *     extern xmlError xmlLastError;
+ *
+ * with a macro that calls a function returning a pointer to the global in
+ * thread-local storage:
+ *
+ *     xmlError *__xmlLastError(void);
+ *     #define xmlError (*__xmlLastError());
+ *
+ * The code can operate in a multitude of ways depending on the environment.
+ * First we support POSIX and Windows threads. Then we support both thread-local
+ * storage provided by the compiler and older methods like thread-specific data
+ * (pthreads) or TlsAlloc (Windows).
+ *
+ * To clean up thread-local storage, we use thread-specific data on POSIX.
+ * On Windows, we either use DllMain when compiling a DLL or a registered wait
+ * function for static builds.
+ */
 
 /*
  * Helpful Macro
  */
 #ifdef LIBXML_THREAD_ENABLED
-#define IS_MAIN_THREAD (xmlIsMainThread())
+#define IS_MAIN_THREAD (xmlIsMainThreadInternal())
 #else
 #define IS_MAIN_THREAD 1
 #endif
 
+#define XML_DECLARE_MEMBER(name, type, attrs) \
+  type gs_##name;
+
+struct _xmlGlobalState {
+    int initialized;
+
+#if defined(HAVE_WIN32_THREADS) && \
+    defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
+    void *threadHandle;
+    void *waitHandle;
+#endif
+
+#define XML_OP XML_DECLARE_MEMBER
+XML_GLOBALS_ALLOC
+XML_GLOBALS_ERROR
+XML_GLOBALS_HTML
+XML_GLOBALS_IO
+XML_GLOBALS_PARSER
+XML_GLOBALS_TREE
+#undef XML_OP
+};
+
+static int parserInitialized;
+
 /*
  * Mutex to protect "ForNewThreads" variables
  */
-static xmlMutexPtr xmlThrDefMutex = NULL;
+static xmlMutex xmlThrDefMutex;
 
-/**
- * xmlInitGlobals:
- *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
+#ifdef LIBXML_THREAD_ENABLED
+
+/*
+ * On Darwin, thread-local storage destructors seem to be run before
+ * pthread thread-specific data destructors. This causes ASan to
+ * report a use-after-free.
  *
- * Additional initialisation for multi-threading
+ * On Windows, we can't use TLS in static builds. The RegisterWait
+ * callback would run after TLS was deallocated.
  */
-void xmlInitGlobals(void)
-{
-    if (xmlThrDefMutex == NULL)
-        xmlThrDefMutex = xmlNewMutex();
-}
+#if defined(XML_THREAD_LOCAL) && \
+    !defined(__APPLE__) && \
+    (!defined(HAVE_WIN32_THREADS) || \
+     !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#define USE_TLS
+#endif
+
+#ifdef USE_TLS
+static XML_THREAD_LOCAL xmlGlobalState globalState;
+#endif
+
+#ifdef HAVE_POSIX_THREADS
+
+/*
+ * Weak symbol hack, see threads.c
+ */
+#if defined(__GNUC__) && \
+    defined(__GLIBC__) && \
+    __GLIBC__ * 100 + __GLIBC_MINOR__ < 234
+
+#pragma weak pthread_getspecific
+#pragma weak pthread_setspecific
+#pragma weak pthread_key_create
+#pragma weak pthread_key_delete
+#pragma weak pthread_equal
+#pragma weak pthread_self
+
+#define XML_PTHREAD_WEAK
+
+static int libxml_is_threaded = -1;
+
+#endif
+
+/*
+ * On POSIX, we need thread-specific data even with thread-local storage
+ * to destroy indirect references from global state (xmlLastError) at
+ * thread exit.
+ */
+static pthread_key_t globalkey;
+static pthread_t mainthread;
+
+#elif defined HAVE_WIN32_THREADS
+
+#ifndef USE_TLS
+static DWORD globalkey = TLS_OUT_OF_INDEXES;
+#endif
+static DWORD mainthread;
+
+#endif /* HAVE_WIN32_THREADS */
+
+static void
+xmlFreeGlobalState(void *state);
+
+#endif /* LIBXML_THREAD_ENABLED */
 
 /************************************************************************
  *                                                                     *
@@ -60,13 +167,8 @@ void xmlInitGlobals(void)
 /*
  * Memory allocation routines
  */
-#undef xmlFree
-#undef xmlMalloc
-#undef xmlMallocAtomic
-#undef xmlMemStrdup
-#undef xmlRealloc
 
-#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
+#if defined(DEBUG_MEMORY_LOCATION)
 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
@@ -131,50 +233,13 @@ xmlPosixStrdup(const char *cur) {
  * Returns the copy of the string or NULL in case of error
  */
 xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
-#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
-
-#include <libxml/threads.h>
-#include <libxml/globals.h>
-#include <libxml/SAX.h>
-
-#undef htmlDefaultSAXHandler
-#undef oldXMLWDcompatibility
-#undef xmlBufferAllocScheme
-#undef xmlDefaultBufferSize
-#undef xmlDefaultSAXHandler
-#undef xmlDefaultSAXLocator
-#undef xmlDoValidityCheckingDefaultValue
-#undef xmlGenericError
-#undef xmlStructuredError
-#undef xmlGenericErrorContext
-#undef xmlStructuredErrorContext
-#undef xmlGetWarningsDefaultValue
-#undef xmlIndentTreeOutput
-#undef  xmlTreeIndentString
-#undef xmlKeepBlanksDefaultValue
-#undef xmlLineNumbersDefaultValue
-#undef xmlLoadExtDtdDefaultValue
-#undef xmlParserDebugEntities
-#undef xmlParserVersion
-#undef xmlPedanticParserDefaultValue
-#undef xmlSaveNoEmptyTags
-#undef xmlSubstituteEntitiesDefaultValue
-#undef xmlRegisterNodeDefaultValue
-#undef xmlDeregisterNodeDefaultValue
-#undef xmlLastError
-
-#undef  xmlParserInputBufferCreateFilenameValue
-#undef  xmlOutputBufferCreateFilenameValue
-/**
- * xmlParserVersion:
- *
- * Constant string describing the internal version of the library
- */
-const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
+#endif /* DEBUG_MEMORY_LOCATION */
 
 /**
  * xmlBufferAllocScheme:
  *
+ * DEPRECATED: Don't use.
+ *
  * Global setting, default allocation policy for buffers, default is
  * XML_BUFFER_ALLOC_EXACT
  */
@@ -183,6 +248,8 @@ static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_E
 /**
  * xmlDefaultBufferSize:
  *
+ * DEPRECATED: Don't use.
+ *
  * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
  */
 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
@@ -201,6 +268,8 @@ int oldXMLWDcompatibility = 0; /* DEPRECATED */
 /**
  * xmlParserDebugEntities:
  *
+ * DEPRECATED: Don't use
+ *
  * Global setting, asking the parser to print out debugging information.
  * while handling entities.
  * Disabled by default
@@ -210,6 +279,8 @@ static int xmlParserDebugEntitiesThrDef = 0;
 /**
  * xmlDoValidityCheckingDefaultValue:
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_DTDVALID.
+ *
  * Global setting, indicate that the parser should work in validating mode.
  * Disabled by default.
  */
@@ -218,7 +289,9 @@ static int xmlDoValidityCheckingDefaultValueThrDef = 0;
 /**
  * xmlGetWarningsDefaultValue:
  *
- * Global setting, indicate that the parser should provide warnings.
+ * DEPRECATED: Don't use
+ *
+ * Global setting, indicate that the DTD validation should provide warnings.
  * Activated by default.
  */
 int xmlGetWarningsDefaultValue = 1;
@@ -226,6 +299,8 @@ static int xmlGetWarningsDefaultValueThrDef = 1;
 /**
  * xmlLoadExtDtdDefaultValue:
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_DTDLOAD.
+ *
  * Global setting, indicate that the parser should load DTD while not
  * validating.
  * Disabled by default.
@@ -235,6 +310,8 @@ static int xmlLoadExtDtdDefaultValueThrDef = 0;
 /**
  * xmlPedanticParserDefaultValue:
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_PEDANTIC.
+ *
  * Global setting, indicate that the parser be pedantic
  * Disabled by default.
  */
@@ -243,6 +320,8 @@ static int xmlPedanticParserDefaultValueThrDef = 0;
 /**
  * xmlLineNumbersDefaultValue:
  *
+ * DEPRECATED: The modern options API always enables line numbers.
+ *
  * Global setting, indicate that the parser should store the line number
  * in the content field of elements in the DOM tree.
  * Disabled by default since this may not be safe for old classes of
@@ -253,6 +332,8 @@ static int xmlLineNumbersDefaultValueThrDef = 0;
 /**
  * xmlKeepBlanksDefaultValue:
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_NOBLANKS.
+ *
  * Global setting, indicate that the parser should keep all blanks
  * nodes found in the content
  * Activated by default, this is actually needed to have the parser
@@ -264,6 +345,8 @@ static int xmlKeepBlanksDefaultValueThrDef = 1;
 /**
  * xmlSubstituteEntitiesDefaultValue:
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_NOENT.
+ *
  * Global setting, indicate that the parser should not generate entity
  * references but replace them with the actual content of the entity
  * Disabled by default, this should be activated when using XPath since
@@ -273,26 +356,38 @@ static int xmlKeepBlanksDefaultValueThrDef = 1;
 int xmlSubstituteEntitiesDefaultValue = 0;
 static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
 
+/**
+ * xmlRegisterNodeDefaultValue:
+ *
+ * DEPRECATED: Don't use
+ */
 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
+
+/**
+ * xmlDeregisterNodeDefaultValue:
+ *
+ * DEPRECATED: Don't use
+ */
 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
 
+/**
+ * xmlParserInputBufferCreateFilenameValue:
+ *
+ * DEPRECATED: Don't use
+ */
 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
 static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
 
+/**
+ * xmlOutputBufferCreateFilenameValue:
+ *
+ * DEPRECATED: Don't use
+ */
 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
 static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
 
-/*
- * Error handling
- */
-
-/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
-/* Must initialize xmlGenericError in xmlInitParser */
-void XMLCDECL xmlGenericErrorDefaultFunc       (void *ctx ATTRIBUTE_UNUSED,
-                                const char *msg,
-                                ...);
 /**
  * xmlGenericError:
  *
@@ -323,6 +418,7 @@ void *xmlStructuredErrorContext = NULL;
 static void *xmlStructuredErrorContextThrDef = NULL;
 xmlError xmlLastError;
 
+#ifdef LIBXML_OUTPUT_ENABLED
 /*
  * output defaults
  */
@@ -353,11 +449,15 @@ static const char *xmlTreeIndentStringThrDef = "  ";
  */
 int xmlSaveNoEmptyTags = 0;
 static int xmlSaveNoEmptyTagsThrDef = 0;
+#endif /* LIBXML_OUTPUT_ENABLED */
 
 #ifdef LIBXML_SAX1_ENABLED
 /**
  * xmlDefaultSAXHandler:
  *
+ * DEPRECATED: This handler is unused and will be removed from future
+ * versions.
+ *
  * Default SAX version1 handler for XML, builds the DOM tree
  */
 xmlSAXHandlerV1 xmlDefaultSAXHandler = {
@@ -388,13 +488,15 @@ xmlSAXHandlerV1 xmlDefaultSAXHandler = {
     xmlSAX2GetParameterEntity,
     xmlSAX2CDataBlock,
     xmlSAX2ExternalSubset,
-    0,
+    1,
 };
 #endif /* LIBXML_SAX1_ENABLED */
 
 /**
  * xmlDefaultSAXLocator:
  *
+ * DEPRECATED: Don't use
+ *
  * The default SAX Locator
  * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
  */
@@ -405,10 +507,13 @@ xmlSAXLocator xmlDefaultSAXLocator = {
     xmlSAX2GetColumnNumber
 };
 
-#ifdef LIBXML_HTML_ENABLED
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_SAX1_ENABLED)
 /**
  * htmlDefaultSAXHandler:
  *
+ * DEPRECATED: This handler is unused and will be removed from future
+ * versions.
+ *
  * Default old SAX v1 handler for HTML, builds the DOM tree
  */
 xmlSAXHandlerV1 htmlDefaultSAXHandler = {
@@ -436,644 +541,669 @@ xmlSAXHandlerV1 htmlDefaultSAXHandler = {
     xmlParserWarning,
     xmlParserError,
     xmlParserError,
-    xmlSAX2GetParameterEntity,
+    NULL,
     xmlSAX2CDataBlock,
     NULL,
-    0,
+    1,
 };
 #endif /* LIBXML_HTML_ENABLED */
 
+/************************************************************************
+ *                                                                     *
+ *                     Per thread global state handling                *
+ *                                                                     *
+ ************************************************************************/
+
 /**
- * xmlInitializeGlobalState:
- * @gs: a pointer to a newly allocated global state
+ * xmlInitGlobals:
  *
- * xmlInitializeGlobalState() initialize a global state with all the
- * default values of the library.
+ * DEPRECATED: Alias for xmlInitParser.
  */
-void
-xmlInitializeGlobalState(xmlGlobalStatePtr gs)
-{
-#ifdef DEBUG_GLOBALS
-    fprintf(stderr, "Initializing globals at %lu for thread %d\n",
-           (unsigned long) gs, xmlGetThreadId());
-#endif
-
-    /*
-     * Perform initialization as required by libxml
-     */
-    if (xmlThrDefMutex == NULL)
-        xmlInitGlobals();
-
-    xmlMutexLock(xmlThrDefMutex);
+void xmlInitGlobals(void) {
+    xmlInitParser();
+}
 
-#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
-    inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
+/**
+ * xmlInitGlobalsInternal:
+ *
+ * Additional initialisation for multi-threading
+ */
+void xmlInitGlobalsInternal(void) {
+    xmlInitMutex(&xmlThrDefMutex);
+
+#ifdef HAVE_POSIX_THREADS
+#ifdef XML_PTHREAD_WEAK
+    if (libxml_is_threaded == -1)
+        libxml_is_threaded =
+            (pthread_getspecific != NULL) &&
+            (pthread_setspecific != NULL) &&
+            (pthread_key_create != NULL) &&
+            (pthread_key_delete != NULL) &&
+            /*
+             * pthread_equal can be inline, resuting in -Waddress warnings.
+             * Let's assume it's available if all the other functions are.
+             */
+            /* (pthread_equal != NULL) && */
+            (pthread_self != NULL);
+    if (libxml_is_threaded == 0)
+        return;
+#endif /* XML_PTHREAD_WEAK */
+    pthread_key_create(&globalkey, xmlFreeGlobalState);
+    mainthread = pthread_self();
+#elif defined(HAVE_WIN32_THREADS)
+#ifndef USE_TLS
+    globalkey = TlsAlloc();
 #endif
-
-    gs->oldXMLWDcompatibility = 0;
-    gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
-    gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
-#if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
-    initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
-#endif /* LIBXML_SAX1_ENABLED */
-    gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
-    gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
-    gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
-    gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
-    gs->xmlDoValidityCheckingDefaultValue =
-         xmlDoValidityCheckingDefaultValueThrDef;
-#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
-    gs->xmlFree = (xmlFreeFunc) xmlMemFree;
-    gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
-    gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
-    gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
-    gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
-#else
-    gs->xmlFree = (xmlFreeFunc) free;
-    gs->xmlMalloc = (xmlMallocFunc) malloc;
-    gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
-    gs->xmlRealloc = (xmlReallocFunc) realloc;
-    gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
+    mainthread = GetCurrentThreadId();
 #endif
-    gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
-    gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
-    gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
-    gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
-    gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
-    gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
-    gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
-    gs->xmlParserVersion = LIBXML_VERSION_STRING;
-    gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
-    gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
-    gs->xmlSubstituteEntitiesDefaultValue =
-        xmlSubstituteEntitiesDefaultValueThrDef;
-
-    gs->xmlGenericError = xmlGenericErrorThrDef;
-    gs->xmlStructuredError = xmlStructuredErrorThrDef;
-    gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
-    gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
-    gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
-    gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
-
-       gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
-       gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
-    memset(&gs->xmlLastError, 0, sizeof(xmlError));
-
-    xmlMutexUnlock(xmlThrDefMutex);
 }
 
 /**
  * xmlCleanupGlobals:
  *
- * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * DEPRECATED: This function is a no-op. Call xmlCleanupParser
  * to free global state but see the warnings there. xmlCleanupParser
  * should be only called once at program exit. In most cases, you don't
  * have call cleanup functions at all.
+ */
+void xmlCleanupGlobals(void) {
+}
+
+/**
+ * xmlCleanupGlobalsInternal:
  *
  * Additional cleanup for multi-threading
  */
-void xmlCleanupGlobals(void)
-{
+void xmlCleanupGlobalsInternal(void) {
     xmlResetError(&xmlLastError);
 
-    if (xmlThrDefMutex != NULL) {
-       xmlFreeMutex(xmlThrDefMutex);
-       xmlThrDefMutex = NULL;
+    xmlCleanupMutex(&xmlThrDefMutex);
+
+#ifdef HAVE_POSIX_THREADS
+#ifdef XML_PTHREAD_WEAK
+    if (libxml_is_threaded == 0)
+        return;
+#endif /* XML_PTHREAD_WEAK */
+    pthread_key_delete(globalkey);
+#elif defined(HAVE_WIN32_THREADS)
+#ifndef USE_TLS
+    if (globalkey != TLS_OUT_OF_INDEXES) {
+        TlsFree(globalkey);
+        globalkey = TLS_OUT_OF_INDEXES;
     }
-    __xmlGlobalInitMutexDestroy();
+#endif
+#endif
+
+    parserInitialized = 0;
 }
 
 /**
- * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
- *               those are really internal work
+ * xmlInitializeGlobalState:
+ * @gs: a pointer to a newly allocated global state
+ *
+ * DEPRECATED: No-op.
  */
 void
-xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
-    xmlMutexLock(xmlThrDefMutex);
-    xmlGenericErrorContextThrDef = ctx;
-    if (handler != NULL)
-       xmlGenericErrorThrDef = handler;
-    else
-       xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
-    xmlMutexUnlock(xmlThrDefMutex);
-}
-
-void
-xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
-    xmlMutexLock(xmlThrDefMutex);
-    xmlStructuredErrorContextThrDef = ctx;
-    xmlStructuredErrorThrDef = handler;
-    xmlMutexUnlock(xmlThrDefMutex);
+xmlInitializeGlobalState(xmlGlobalStatePtr gs ATTRIBUTE_UNUSED)
+{
 }
 
 /**
- * xmlRegisterNodeDefault:
- * @func: function pointer to the new RegisterNodeFunc
+ * xmlGetGlobalState:
  *
- * Registers a callback for node creation
+ * DEPRECATED
  *
- * Returns the old value of the registration function
+ * Returns NULL.
  */
-xmlRegisterNodeFunc
-xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
+xmlGlobalStatePtr
+xmlGetGlobalState(void)
 {
-    xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
-
-    __xmlRegisterCallbacks = 1;
-    xmlRegisterNodeDefaultValue = func;
-    return(old);
+    return(NULL);
 }
 
-xmlRegisterNodeFunc
-xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
-{
-    xmlRegisterNodeFunc old;
-
-    xmlMutexLock(xmlThrDefMutex);
-    old = xmlRegisterNodeDefaultValueThrDef;
-
-    __xmlRegisterCallbacks = 1;
-    xmlRegisterNodeDefaultValueThrDef = func;
-    xmlMutexUnlock(xmlThrDefMutex);
+static int
+xmlIsMainThreadInternal(void) {
+    if (parserInitialized == 0) {
+        xmlInitParser();
+        parserInitialized = 1;
+    }
 
-    return(old);
+#ifdef HAVE_POSIX_THREADS
+#ifdef XML_PTHREAD_WEAK
+    if (libxml_is_threaded == 0)
+        return (1);
+#endif
+    return (pthread_equal(mainthread, pthread_self()));
+#elif defined HAVE_WIN32_THREADS
+    return (mainthread == GetCurrentThreadId());
+#else
+    return (1);
+#endif
 }
 
 /**
- * xmlDeregisterNodeDefault:
- * @func: function pointer to the new DeregisterNodeFunc
+ * xmlIsMainThread:
+ *
+ * DEPRECATED: Internal function, do not use.
  *
- * Registers a callback for node destruction
+ * Check whether the current thread is the main thread.
  *
- * Returns the previous value of the deregistration function
+ * Returns 1 if the current thread is the main thread, 0 otherwise
  */
-xmlDeregisterNodeFunc
-xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
-{
-    xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
-
-    __xmlRegisterCallbacks = 1;
-    xmlDeregisterNodeDefaultValue = func;
-    return(old);
+int
+xmlIsMainThread(void) {
+    return(xmlIsMainThreadInternal());
 }
 
-xmlDeregisterNodeFunc
-xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
+#ifdef LIBXML_THREAD_ENABLED
+
+static void
+xmlFreeGlobalState(void *state)
 {
-    xmlDeregisterNodeFunc old;
+    xmlGlobalState *gs = (xmlGlobalState *) state;
 
-    xmlMutexLock(xmlThrDefMutex);
-    old = xmlDeregisterNodeDefaultValueThrDef;
+    /*
+     * Free any memory allocated in the thread's xmlLastError. If it
+     * weren't for this indirect allocation, we wouldn't need
+     * a destructor with thread-local storage at all!
+     *
+     * It would be nice if we could make xmlLastError a special error
+     * type which uses statically allocated, fixed-size buffers.
+     * But the xmlError struct is fully public and widely used,
+     * so changes are dangerous.
+     */
+    xmlResetError(&(gs->gs_xmlLastError));
+#ifndef USE_TLS
+    free(state);
+#endif
+}
 
-    __xmlRegisterCallbacks = 1;
-    xmlDeregisterNodeDefaultValueThrDef = func;
-    xmlMutexUnlock(xmlThrDefMutex);
+#if defined(HAVE_WIN32_THREADS) && \
+    defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
+static void WINAPI
+xmlGlobalStateDtor(void *ctxt, unsigned char timedOut ATTRIBUTE_UNUSED) {
+    xmlGlobalStatePtr gs = ctxt;
 
-    return(old);
+    UnregisterWait(gs->waitHandle);
+    CloseHandle(gs->threadHandle);
+    xmlFreeGlobalState(gs);
 }
 
-xmlParserInputBufferCreateFilenameFunc
-xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
-{
-    xmlParserInputBufferCreateFilenameFunc old;
+static int
+xmlRegisterGlobalStateDtor(xmlGlobalState *gs) {
+    void *processHandle = GetCurrentProcess();
+    void *threadHandle;
+    void *waitHandle;
 
-    xmlMutexLock(xmlThrDefMutex);
-    old = xmlParserInputBufferCreateFilenameValueThrDef;
-    if (old == NULL) {
-               old = __xmlParserInputBufferCreateFilename;
-       }
+    if (DuplicateHandle(processHandle, GetCurrentThread(), processHandle,
+                &threadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) == 0) {
+        return(-1);
+    }
 
-    xmlParserInputBufferCreateFilenameValueThrDef = func;
-    xmlMutexUnlock(xmlThrDefMutex);
+    if (RegisterWaitForSingleObject(&waitHandle, threadHandle,
+                xmlGlobalStateDtor, gs, INFINITE, WT_EXECUTEONLYONCE) == 0) {
+        CloseHandle(threadHandle);
+        return(-1);
+    }
 
-    return(old);
+    gs->threadHandle = threadHandle;
+    gs->waitHandle = waitHandle;
+    return(0);
 }
+#endif /* LIBXML_STATIC */
 
-xmlOutputBufferCreateFilenameFunc
-xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
-{
-    xmlOutputBufferCreateFilenameFunc old;
+static void
+xmlInitGlobalState(xmlGlobalStatePtr gs) {
+    xmlMutexLock(&xmlThrDefMutex);
 
-    xmlMutexLock(xmlThrDefMutex);
-    old = xmlOutputBufferCreateFilenameValueThrDef;
-#ifdef LIBXML_OUTPUT_ENABLED
-    if (old == NULL) {
-               old = __xmlOutputBufferCreateFilename;
-       }
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
+    inithtmlDefaultSAXHandler(&gs->gs_htmlDefaultSAXHandler);
 #endif
-    xmlOutputBufferCreateFilenameValueThrDef = func;
-    xmlMutexUnlock(xmlThrDefMutex);
 
-    return(old);
-}
+    gs->gs_oldXMLWDcompatibility = 0;
+    gs->gs_xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
+    gs->gs_xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
+#if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
+    initxmlDefaultSAXHandler(&gs->gs_xmlDefaultSAXHandler, 1);
+#endif /* LIBXML_SAX1_ENABLED */
+    gs->gs_xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
+    gs->gs_xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
+    gs->gs_xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
+    gs->gs_xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
+    gs->gs_xmlDoValidityCheckingDefaultValue =
+         xmlDoValidityCheckingDefaultValueThrDef;
+#ifdef LIBXML_THREAD_ALLOC_ENABLED
+#ifdef DEBUG_MEMORY_LOCATION
+    gs->gs_xmlFree = xmlMemFree;
+    gs->gs_xmlMalloc = xmlMemMalloc;
+    gs->gs_xmlMallocAtomic = xmlMemMalloc;
+    gs->gs_xmlRealloc = xmlMemRealloc;
+    gs->gs_xmlMemStrdup = xmlMemoryStrdup;
+#else
+    gs->gs_xmlFree = free;
+    gs->gs_xmlMalloc = malloc;
+    gs->gs_xmlMallocAtomic = malloc;
+    gs->gs_xmlRealloc = realloc;
+    gs->gs_xmlMemStrdup = xmlPosixStrdup;
+#endif
+#endif
+    gs->gs_xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
+#ifdef LIBXML_OUTPUT_ENABLED
+    gs->gs_xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
+    gs->gs_xmlTreeIndentString = xmlTreeIndentStringThrDef;
+    gs->gs_xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
+#endif
+    gs->gs_xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
+    gs->gs_xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
+    gs->gs_xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
+    gs->gs_xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
+    gs->gs_xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
+    gs->gs_xmlSubstituteEntitiesDefaultValue =
+        xmlSubstituteEntitiesDefaultValueThrDef;
 
-#ifdef LIBXML_HTML_ENABLED
-#undef htmlDefaultSAXHandler
-xmlSAXHandlerV1 *
-__htmlDefaultSAXHandler(void) {
-    if (IS_MAIN_THREAD)
-       return (&htmlDefaultSAXHandler);
-    else
-       return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
-}
+    gs->gs_xmlGenericError = xmlGenericErrorThrDef;
+    gs->gs_xmlStructuredError = xmlStructuredErrorThrDef;
+    gs->gs_xmlGenericErrorContext = xmlGenericErrorContextThrDef;
+    gs->gs_xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
+    gs->gs_xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
+    gs->gs_xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
+
+    gs->gs_xmlParserInputBufferCreateFilenameValue =
+        xmlParserInputBufferCreateFilenameValueThrDef;
+    gs->gs_xmlOutputBufferCreateFilenameValue =
+        xmlOutputBufferCreateFilenameValueThrDef;
+    memset(&gs->gs_xmlLastError, 0, sizeof(xmlError));
+
+    xmlMutexUnlock(&xmlThrDefMutex);
+
+#ifdef HAVE_POSIX_THREADS
+    pthread_setspecific(globalkey, gs);
+#elif defined HAVE_WIN32_THREADS
+#ifndef USE_TLS
+    TlsSetValue(globalkey, gs);
+#endif
+#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
+    xmlRegisterGlobalStateDtor(gs);
+#endif
 #endif
 
-#undef xmlLastError
-xmlError *
-__xmlLastError(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlLastError);
-    else
-       return (&xmlGetGlobalState()->xmlLastError);
+    gs->initialized = 1;
 }
 
-/*
- * The following memory routines were apparently lost at some point,
- * and were re-inserted at this point on June 10, 2004.  Hope it's
- * the right place for them :-)
+#ifndef USE_TLS
+/**
+ * xmlNewGlobalState:
+ *
+ * xmlNewGlobalState() allocates a global state. This structure is used to
+ * hold all data for use by a thread when supporting backwards compatibility
+ * of libxml2 to pre-thread-safe behaviour.
+ *
+ * Returns the newly allocated xmlGlobalStatePtr or NULL in case of error
  */
-#if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
-#undef xmlMalloc
-xmlMallocFunc *
-__xmlMalloc(void){
-    if (IS_MAIN_THREAD)
-        return (&xmlMalloc);
-    else
-       return (&xmlGetGlobalState()->xmlMalloc);
-}
+static xmlGlobalStatePtr
+xmlNewGlobalState(int allowFailure)
+{
+    xmlGlobalState *gs;
+
+    gs = malloc(sizeof(xmlGlobalState));
+    if (gs == NULL) {
+        if (allowFailure)
+            return(NULL);
+
+        /*
+         * If an application didn't call xmlCheckThreadLocalStorage to make
+         * sure that global state could be allocated, it's too late to
+         * handle the error.
+         */
+        fprintf(stderr, "libxml2: Failed to allocate globals for thread\n"
+                        "libxml2: See xmlCheckThreadLocalStorage\n");
+        abort();
+    }
 
-#undef xmlMallocAtomic
-xmlMallocFunc *
-__xmlMallocAtomic(void){
-    if (IS_MAIN_THREAD)
-        return (&xmlMallocAtomic);
-    else
-        return (&xmlGetGlobalState()->xmlMallocAtomic);
+    memset(gs, 0, sizeof(xmlGlobalState));
+    xmlInitGlobalState(gs);
+    return (gs);
 }
+#endif
 
-#undef xmlRealloc
-xmlReallocFunc *
-__xmlRealloc(void){
-    if (IS_MAIN_THREAD)
-        return (&xmlRealloc);
-    else
-        return (&xmlGetGlobalState()->xmlRealloc);
-}
+static xmlGlobalStatePtr
+xmlGetThreadLocalStorage(int allowFailure) {
+    xmlGlobalState *gs;
+
+    (void) allowFailure;
+
+#ifdef USE_TLS
+    gs = &globalState;
+    if (gs->initialized == 0)
+        xmlInitGlobalState(gs);
+#elif defined(HAVE_POSIX_THREADS)
+    gs = (xmlGlobalState *) pthread_getspecific(globalkey);
+    if (gs == NULL)
+        gs = xmlNewGlobalState(allowFailure);
+#elif defined(HAVE_WIN32_THREADS)
+    gs = (xmlGlobalState *) TlsGetValue(globalkey);
+    if (gs == NULL)
+        gs = xmlNewGlobalState(allowFailure);
+#else
+    gs = NULL;
+#endif
 
-#undef xmlFree
-xmlFreeFunc *
-__xmlFree(void){
-    if (IS_MAIN_THREAD)
-        return (&xmlFree);
-    else
-        return (&xmlGetGlobalState()->xmlFree);
+    return(gs);
 }
 
-xmlStrdupFunc *
-__xmlMemStrdup(void){
-    if (IS_MAIN_THREAD)
-        return (&xmlMemStrdup);
-    else
-        return (&xmlGetGlobalState()->xmlMemStrdup);
+/* Define thread-local storage accessors with macro magic */
+
+#define XML_DEFINE_GLOBAL_WRAPPER(name, type, attrs) \
+    type *__##name(void) { \
+        if (IS_MAIN_THREAD) \
+            return (&name); \
+        else \
+            return (&xmlGetThreadLocalStorage(0)->gs_##name); \
+    }
+
+#define XML_OP XML_DEFINE_GLOBAL_WRAPPER
+XML_GLOBALS_ALLOC
+XML_GLOBALS_ERROR
+XML_GLOBALS_HTML
+XML_GLOBALS_IO
+XML_GLOBALS_PARSER
+XML_GLOBALS_TREE
+#undef XML_OP
+
+/* For backward compatibility */
+
+const char *const *
+__xmlParserVersion(void) {
+    return &xmlParserVersion;
 }
 
-#endif
+#endif /* LIBXML_THREAD_ENABLED */
 
-/*
- * Everything starting from the line below is
- * Automatically generated by build_glob.py.
- * Do not modify the previous line.
+/**
+ * xmlCheckThreadLocalStorage:
+ *
+ * Check whether thread-local storage could be allocated.
+ *
+ * In cross-platform code running in multithreaded environments, this
+ * function should be called once in each thread before calling other
+ * library functions to make sure that thread-local storage was
+ * allocated properly.
+ *
+ * Returns 0 on success or -1 if a memory allocation failed. A failed
+ * allocation signals a typically fatal and irrecoverable out-of-memory
+ * situation. Don't call any library functions in this case.
+ *
+ * This function never fails if the library is compiled with support
+ * for thread-local storage.
+ *
+ * This function never fails for the "main" thread which is the first
+ * thread calling xmlInitParser.
+ *
+ * Available since v2.12.0.
  */
+int
+xmlCheckThreadLocalStorage(void) {
+#if defined(LIBXML_THREAD_ENABLED) && !defined(USE_TLS)
+    if ((!xmlIsMainThreadInternal()) && (xmlGetThreadLocalStorage(1) == NULL))
+        return(-1);
+#endif
+    return(0);
+}
 
+/**
+ * DllMain:
+ * @hinstDLL: handle to DLL instance
+ * @fdwReason: Reason code for entry
+ * @lpvReserved: generic pointer (depends upon reason code)
+ *
+ * Entry point for Windows library. It is being used to free thread-specific
+ * storage.
+ *
+ * Returns TRUE always
+ */
+#if defined(HAVE_WIN32_THREADS) && \
+    (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#if defined(LIBXML_STATIC_FOR_DLL)
+int
+xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason,
+           ATTRIBUTE_UNUSED void *lpvReserved)
+#else
+/* declare to avoid "no previous prototype for 'DllMain'" warning */
+/* Note that we do NOT want to include this function declaration in
+   a public header because it's meant to be called by Windows itself,
+   not a program that uses this library.  This also has to be exported. */
+
+XMLPUBFUN BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved);
+
+BOOL WINAPI
+DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
+        ATTRIBUTE_UNUSED LPVOID lpvReserved)
+#endif
+{
+    switch (fdwReason) {
+        case DLL_THREAD_DETACH:
+#ifdef USE_TLS
+            xmlFreeGlobalState(&globalState);
+#else
+            if (globalkey != TLS_OUT_OF_INDEXES) {
+                xmlGlobalState *globalval;
+
+                globalval = (xmlGlobalState *) TlsGetValue(globalkey);
+                if (globalval) {
+                    xmlFreeGlobalState(globalval);
+                    TlsSetValue(globalkey, NULL);
+                }
+            }
+#endif
+            break;
+    }
+    return TRUE;
+}
+#endif
 
-#undef oldXMLWDcompatibility
-int *
-__oldXMLWDcompatibility(void) {
-    if (IS_MAIN_THREAD)
-       return (&oldXMLWDcompatibility);
+void
+xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
+    xmlMutexLock(&xmlThrDefMutex);
+    xmlGenericErrorContextThrDef = ctx;
+    if (handler != NULL)
+       xmlGenericErrorThrDef = handler;
     else
-       return (&xmlGetGlobalState()->oldXMLWDcompatibility);
+       xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
+    xmlMutexUnlock(&xmlThrDefMutex);
 }
 
-#undef xmlBufferAllocScheme
-xmlBufferAllocationScheme *
-__xmlBufferAllocScheme(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlBufferAllocScheme);
-    else
-       return (&xmlGetGlobalState()->xmlBufferAllocScheme);
+void
+xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
+    xmlMutexLock(&xmlThrDefMutex);
+    xmlStructuredErrorContextThrDef = ctx;
+    xmlStructuredErrorThrDef = handler;
+    xmlMutexUnlock(&xmlThrDefMutex);
 }
+
 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
     xmlBufferAllocationScheme ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlBufferAllocSchemeThrDef;
     xmlBufferAllocSchemeThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlDefaultBufferSize
-int *
-__xmlDefaultBufferSize(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlDefaultBufferSize);
-    else
-       return (&xmlGetGlobalState()->xmlDefaultBufferSize);
-}
 int xmlThrDefDefaultBufferSize(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlDefaultBufferSizeThrDef;
     xmlDefaultBufferSizeThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#ifdef LIBXML_SAX1_ENABLED
-#undef xmlDefaultSAXHandler
-xmlSAXHandlerV1 *
-__xmlDefaultSAXHandler(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlDefaultSAXHandler);
-    else
-       return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
-}
-#endif /* LIBXML_SAX1_ENABLED */
-
-#undef xmlDefaultSAXLocator
-xmlSAXLocator *
-__xmlDefaultSAXLocator(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlDefaultSAXLocator);
-    else
-       return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
-}
-
-#undef xmlDoValidityCheckingDefaultValue
-int *
-__xmlDoValidityCheckingDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlDoValidityCheckingDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
-}
 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlDoValidityCheckingDefaultValueThrDef;
     xmlDoValidityCheckingDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlGenericError
-xmlGenericErrorFunc *
-__xmlGenericError(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlGenericError);
-    else
-       return (&xmlGetGlobalState()->xmlGenericError);
-}
-
-#undef xmlStructuredError
-xmlStructuredErrorFunc *
-__xmlStructuredError(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlStructuredError);
-    else
-       return (&xmlGetGlobalState()->xmlStructuredError);
-}
-
-#undef xmlGenericErrorContext
-void * *
-__xmlGenericErrorContext(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlGenericErrorContext);
-    else
-       return (&xmlGetGlobalState()->xmlGenericErrorContext);
-}
-
-#undef xmlStructuredErrorContext
-void * *
-__xmlStructuredErrorContext(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlStructuredErrorContext);
-    else
-       return (&xmlGetGlobalState()->xmlStructuredErrorContext);
-}
-
-#undef xmlGetWarningsDefaultValue
-int *
-__xmlGetWarningsDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlGetWarningsDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
-}
 int xmlThrDefGetWarningsDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlGetWarningsDefaultValueThrDef;
     xmlGetWarningsDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlIndentTreeOutput
-int *
-__xmlIndentTreeOutput(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlIndentTreeOutput);
-    else
-       return (&xmlGetGlobalState()->xmlIndentTreeOutput);
-}
+#ifdef LIBXML_OUTPUT_ENABLED
 int xmlThrDefIndentTreeOutput(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlIndentTreeOutputThrDef;
     xmlIndentTreeOutputThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlTreeIndentString
-const char * *
-__xmlTreeIndentString(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlTreeIndentString);
-    else
-       return (&xmlGetGlobalState()->xmlTreeIndentString);
-}
 const char * xmlThrDefTreeIndentString(const char * v) {
     const char * ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlTreeIndentStringThrDef;
     xmlTreeIndentStringThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlKeepBlanksDefaultValue
-int *
-__xmlKeepBlanksDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlKeepBlanksDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
+int xmlThrDefSaveNoEmptyTags(int v) {
+    int ret;
+    xmlMutexLock(&xmlThrDefMutex);
+    ret = xmlSaveNoEmptyTagsThrDef;
+    xmlSaveNoEmptyTagsThrDef = v;
+    xmlMutexUnlock(&xmlThrDefMutex);
+    return ret;
 }
+#endif
+
 int xmlThrDefKeepBlanksDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlKeepBlanksDefaultValueThrDef;
     xmlKeepBlanksDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlLineNumbersDefaultValue
-int *
-__xmlLineNumbersDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlLineNumbersDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
-}
 int xmlThrDefLineNumbersDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlLineNumbersDefaultValueThrDef;
     xmlLineNumbersDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlLoadExtDtdDefaultValue
-int *
-__xmlLoadExtDtdDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlLoadExtDtdDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
-}
 int xmlThrDefLoadExtDtdDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlLoadExtDtdDefaultValueThrDef;
     xmlLoadExtDtdDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlParserDebugEntities
-int *
-__xmlParserDebugEntities(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlParserDebugEntities);
-    else
-       return (&xmlGetGlobalState()->xmlParserDebugEntities);
-}
 int xmlThrDefParserDebugEntities(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlParserDebugEntitiesThrDef;
     xmlParserDebugEntitiesThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlParserVersion
-const char * *
-__xmlParserVersion(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlParserVersion);
-    else
-       return (&xmlGetGlobalState()->xmlParserVersion);
-}
-
-#undef xmlPedanticParserDefaultValue
-int *
-__xmlPedanticParserDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlPedanticParserDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
-}
 int xmlThrDefPedanticParserDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlPedanticParserDefaultValueThrDef;
     xmlPedanticParserDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
-    return ret;
-}
-
-#undef xmlSaveNoEmptyTags
-int *
-__xmlSaveNoEmptyTags(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlSaveNoEmptyTags);
-    else
-       return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
-}
-int xmlThrDefSaveNoEmptyTags(int v) {
-    int ret;
-    xmlMutexLock(xmlThrDefMutex);
-    ret = xmlSaveNoEmptyTagsThrDef;
-    xmlSaveNoEmptyTagsThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlSubstituteEntitiesDefaultValue
-int *
-__xmlSubstituteEntitiesDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlSubstituteEntitiesDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
-}
 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
     int ret;
-    xmlMutexLock(xmlThrDefMutex);
+    xmlMutexLock(&xmlThrDefMutex);
     ret = xmlSubstituteEntitiesDefaultValueThrDef;
     xmlSubstituteEntitiesDefaultValueThrDef = v;
-    xmlMutexUnlock(xmlThrDefMutex);
+    xmlMutexUnlock(&xmlThrDefMutex);
     return ret;
 }
 
-#undef xmlRegisterNodeDefaultValue
-xmlRegisterNodeFunc *
-__xmlRegisterNodeDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlRegisterNodeDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
+xmlRegisterNodeFunc
+xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
+{
+    xmlRegisterNodeFunc old;
+
+    xmlMutexLock(&xmlThrDefMutex);
+    old = xmlRegisterNodeDefaultValueThrDef;
+
+    __xmlRegisterCallbacks = 1;
+    xmlRegisterNodeDefaultValueThrDef = func;
+    xmlMutexUnlock(&xmlThrDefMutex);
+
+    return(old);
 }
 
-#undef xmlDeregisterNodeDefaultValue
-xmlDeregisterNodeFunc *
-__xmlDeregisterNodeDefaultValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlDeregisterNodeDefaultValue);
-    else
-       return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
+xmlDeregisterNodeFunc
+xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
+{
+    xmlDeregisterNodeFunc old;
+
+    xmlMutexLock(&xmlThrDefMutex);
+    old = xmlDeregisterNodeDefaultValueThrDef;
+
+    __xmlRegisterCallbacks = 1;
+    xmlDeregisterNodeDefaultValueThrDef = func;
+    xmlMutexUnlock(&xmlThrDefMutex);
+
+    return(old);
 }
 
-#undef xmlParserInputBufferCreateFilenameValue
-xmlParserInputBufferCreateFilenameFunc *
-__xmlParserInputBufferCreateFilenameValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlParserInputBufferCreateFilenameValue);
-    else
-       return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
+xmlParserInputBufferCreateFilenameFunc
+xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
+{
+    xmlParserInputBufferCreateFilenameFunc old;
+
+    xmlMutexLock(&xmlThrDefMutex);
+    old = xmlParserInputBufferCreateFilenameValueThrDef;
+    if (old == NULL) {
+               old = __xmlParserInputBufferCreateFilename;
+       }
+
+    xmlParserInputBufferCreateFilenameValueThrDef = func;
+    xmlMutexUnlock(&xmlThrDefMutex);
+
+    return(old);
 }
 
-#undef xmlOutputBufferCreateFilenameValue
-xmlOutputBufferCreateFilenameFunc *
-__xmlOutputBufferCreateFilenameValue(void) {
-    if (IS_MAIN_THREAD)
-       return (&xmlOutputBufferCreateFilenameValue);
-    else
-       return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
+xmlOutputBufferCreateFilenameFunc
+xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
+{
+    xmlOutputBufferCreateFilenameFunc old;
+
+    xmlMutexLock(&xmlThrDefMutex);
+    old = xmlOutputBufferCreateFilenameValueThrDef;
+#ifdef LIBXML_OUTPUT_ENABLED
+    if (old == NULL) {
+               old = __xmlOutputBufferCreateFilename;
+       }
+#endif
+    xmlOutputBufferCreateFilenameValueThrDef = func;
+    xmlMutexUnlock(&xmlThrDefMutex);
+
+    return(old);
 }
 
diff --git a/hash.c b/hash.c
index 894174f..38341d7 100644 (file)
--- a/hash.c
+++ b/hash.c
 /*
- * hash.c: chained hash tables
+ * hash.c: hash tables
  *
- * Reference: Your favorite introductory book on algorithms
+ * Hash table with open addressing, linear probing and
+ * Robin Hood reordering.
  *
- * Copyright (C) 2000,2012 Bjorn Reese and Daniel Veillard.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
- * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
- *
- * Author: breese@users.sourceforge.net
+ * See Copyright for the status of this software.
  */
 
 #define IN_LIBXML
 #include "libxml.h"
 
 #include <string.h>
-#include <stdlib.h>
-#include <time.h>
-
-/*
- * Following http://www.ocert.org/advisories/ocert-2011-003.html
- * it seems that having hash randomization might be a good idea
- * when using XML with untrusted data
- */
-#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
-#define HASH_RANDOMIZATION
-#endif
+#include <limits.h>
 
 #include <libxml/parser.h>
 #include <libxml/hash.h>
+#include <libxml/dict.h>
 #include <libxml/xmlmemory.h>
-#include <libxml/xmlerror.h>
-#include <libxml/globals.h>
+#include <libxml/xmlstring.h>
 
-#define MAX_HASH_LEN 8
+#include "private/dict.h"
+
+#ifndef SIZE_MAX
+  #define SIZE_MAX ((size_t) -1)
+#endif
 
-/* #define DEBUG_GROW */
+#define MAX_FILL_NUM 7
+#define MAX_FILL_DENOM 8
+#define MIN_HASH_SIZE 8
+#define MAX_HASH_SIZE (1u << 31)
 
 /*
  * A single entry in the hash table
  */
-typedef struct _xmlHashEntry xmlHashEntry;
-typedef xmlHashEntry *xmlHashEntryPtr;
-struct _xmlHashEntry {
-    struct _xmlHashEntry *next;
-    xmlChar *name;
-    xmlChar *name2;
-    xmlChar *name3;
+typedef struct {
+    unsigned hashValue; /* 0 means unoccupied, occupied entries have the
+                         * MAX_HASH_SIZE bit set to 1 */
+    xmlChar *key;
+    xmlChar *key2; /* TODO: Don't allocate possibly empty keys */
+    xmlChar *key3;
     void *payload;
-    int valid;
-};
+} xmlHashEntry;
 
 /*
  * The entire hash table
  */
 struct _xmlHashTable {
-    struct _xmlHashEntry *table;
-    int size;
-    int nbElems;
+    xmlHashEntry *table;
+    unsigned size; /* power of two */
+    unsigned nbElems;
     xmlDictPtr dict;
-#ifdef HASH_RANDOMIZATION
-    int random_seed;
-#endif
+    unsigned randomSeed;
 };
 
-/*
- * xmlHashComputeKey:
- * Calculate the hash key
- */
-#ifdef __clang__
-ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
-#endif
-static unsigned long
-xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
-                 const xmlChar *name2, const xmlChar *name3) {
-    unsigned long value = 0L;
-    unsigned long ch;
-
-#ifdef HASH_RANDOMIZATION
-    value = table->random_seed;
-#endif
-    if (name != NULL) {
-       value += 30 * (*name);
-       while ((ch = *name++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+static int
+xmlHashGrow(xmlHashTablePtr hash, unsigned size);
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+xmlHashValue(unsigned seed, const xmlChar *key, const xmlChar *key2,
+             const xmlChar *key3, size_t *lengths) {
+    unsigned h1, h2;
+    size_t i;
+
+    HASH_INIT(h1, h2, seed);
+
+    for (i = 0; key[i] != 0; i++) {
+        HASH_UPDATE(h1, h2, key[i]);
     }
-    value = value ^ ((value << 5) + (value >> 3));
-    if (name2 != NULL) {
-       while ((ch = *name2++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+    if (lengths)
+        lengths[0] = i;
+
+    HASH_UPDATE(h1, h2, 0);
+
+    if (key2 != NULL) {
+        for (i = 0; key2[i] != 0; i++) {
+            HASH_UPDATE(h1, h2, key2[i]);
+        }
+        if (lengths)
+            lengths[1] = i;
     }
-    value = value ^ ((value << 5) + (value >> 3));
-    if (name3 != NULL) {
-       while ((ch = *name3++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+
+    HASH_UPDATE(h1, h2, 0);
+
+    if (key3 != NULL) {
+        for (i = 0; key3[i] != 0; i++) {
+            HASH_UPDATE(h1, h2, key3[i]);
+        }
+        if (lengths)
+            lengths[2] = i;
     }
-    return (value % table->size);
+
+    HASH_FINISH(h1, h2);
+
+    return(h2);
 }
 
-#ifdef __clang__
-ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
-#endif
-static unsigned long
-xmlHashComputeQKey(xmlHashTablePtr table,
-                  const xmlChar *prefix, const xmlChar *name,
-                  const xmlChar *prefix2, const xmlChar *name2,
-                  const xmlChar *prefix3, const xmlChar *name3) {
-    unsigned long value = 0L;
-    unsigned long ch;
-
-#ifdef HASH_RANDOMIZATION
-    value = table->random_seed;
-#endif
-    if (prefix != NULL)
-       value += 30 * (*prefix);
-    else
-       value += 30 * (*name);
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+xmlHashQNameValue(unsigned seed,
+                  const xmlChar *prefix, const xmlChar *name,
+                  const xmlChar *prefix2, const xmlChar *name2,
+                  const xmlChar *prefix3, const xmlChar *name3) {
+    unsigned h1, h2, ch;
+
+    HASH_INIT(h1, h2, seed);
 
     if (prefix != NULL) {
-       while ((ch = *prefix++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
-       value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':');
+        while ((ch = *prefix++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
+        HASH_UPDATE(h1, h2, ':');
     }
     if (name != NULL) {
-       while ((ch = *name++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+        while ((ch = *name++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
     }
-    value = value ^ ((value << 5) + (value >> 3));
+    HASH_UPDATE(h1, h2, 0);
     if (prefix2 != NULL) {
-       while ((ch = *prefix2++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
-       value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':');
+        while ((ch = *prefix2++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
+        HASH_UPDATE(h1, h2, ':');
     }
     if (name2 != NULL) {
-       while ((ch = *name2++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+        while ((ch = *name2++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
     }
-    value = value ^ ((value << 5) + (value >> 3));
+    HASH_UPDATE(h1, h2, 0);
     if (prefix3 != NULL) {
-       while ((ch = *prefix3++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
-       value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':');
+        while ((ch = *prefix3++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
+        HASH_UPDATE(h1, h2, ':');
     }
     if (name3 != NULL) {
-       while ((ch = *name3++) != 0) {
-           value = value ^ ((value << 5) + (value >> 3) + ch);
-       }
+        while ((ch = *name3++) != 0) {
+            HASH_UPDATE(h1, h2, ch);
+        }
     }
-    return (value % table->size);
+
+    HASH_FINISH(h1, h2);
+
+    return(h2);
 }
 
 /**
  * xmlHashCreate:
- * @size: the size of the hash table
+ * @size: initial size of the hash table
  *
- * Create a new xmlHashTablePtr.
+ * Create a new hash table. Set size to zero if the number of entries
+ * can't be estimated.
  *
- * Returns the newly created object, or NULL if an error occurred.
+ * Returns the newly created object, or NULL if a memory allocation failed.
  */
 xmlHashTablePtr
 xmlHashCreate(int size) {
-    xmlHashTablePtr table;
-
-    if (size <= 0)
-        size = 256;
-
-    table = xmlMalloc(sizeof(xmlHashTable));
-    if (table) {
-        table->dict = NULL;
-        table->size = size;
-       table->nbElems = 0;
-        table->table = xmlMalloc(size * sizeof(xmlHashEntry));
-        if (table->table) {
-           memset(table->table, 0, size * sizeof(xmlHashEntry));
-#ifdef HASH_RANDOMIZATION
-            table->random_seed = __xmlRandom();
+    xmlHashTablePtr hash;
+
+    xmlInitParser();
+
+    hash = xmlMalloc(sizeof(*hash));
+    if (hash == NULL)
+        return(NULL);
+    hash->dict = NULL;
+    hash->size = 0;
+    hash->table = NULL;
+    hash->nbElems = 0;
+    hash->randomSeed = xmlRandom();
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    hash->randomSeed = 0;
 #endif
-           return(table);
+
+    /*
+     * Unless a larger size is passed, the backing table is created
+     * lazily with MIN_HASH_SIZE capacity. In practice, there are many
+     * hash tables which are never filled.
+     */
+    if (size > MIN_HASH_SIZE) {
+        unsigned newSize = MIN_HASH_SIZE * 2;
+
+        while ((newSize < (unsigned) size) && (newSize < MAX_HASH_SIZE))
+            newSize *= 2;
+
+        if (xmlHashGrow(hash, newSize) != 0) {
+            xmlFree(hash);
+            return(NULL);
         }
-        xmlFree(table);
     }
-    return(NULL);
+
+    return(hash);
 }
 
 /**
@@ -202,938 +199,1017 @@ xmlHashCreate(int size) {
  * @size: the size of the hash table
  * @dict: a dictionary to use for the hash
  *
- * Create a new xmlHashTablePtr which will use @dict as the internal dictionary
+ * Create a new hash table backed by a dictionary. This can reduce
+ * resource usage considerably if most keys passed to API functions
+ * originate from this dictionary.
  *
- * Returns the newly created object, or NULL if an error occurred.
+ * Returns the newly created object, or NULL if a memory allocation failed.
  */
 xmlHashTablePtr
 xmlHashCreateDict(int size, xmlDictPtr dict) {
-    xmlHashTablePtr table;
+    xmlHashTablePtr hash;
+
+    hash = xmlHashCreate(size);
+    if (hash != NULL) {
+        hash->dict = dict;
+        xmlDictReference(dict);
+    }
+    return(hash);
+}
+
+/**
+ * xmlHashFree:
+ * @hash: hash table
+ * @dealloc: deallocator function or NULL
+ *
+ * Free the hash and its contents. The payload is deallocated with
+ * @dealloc if provided.
+ */
+void
+xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc) {
+    if (hash == NULL)
+        return;
+
+    if (hash->table) {
+        const xmlHashEntry *end = &hash->table[hash->size];
+        const xmlHashEntry *entry;
+
+        for (entry = hash->table; entry < end; entry++) {
+            if (entry->hashValue == 0)
+                continue;
+            if ((dealloc != NULL) && (entry->payload != NULL))
+                dealloc(entry->payload, entry->key);
+            if (hash->dict == NULL) {
+                if (entry->key)
+                    xmlFree(entry->key);
+                if (entry->key2)
+                    xmlFree(entry->key2);
+                if (entry->key3)
+                    xmlFree(entry->key3);
+            }
+        }
+
+        xmlFree(hash->table);
+    }
+
+    if (hash->dict)
+        xmlDictFree(hash->dict);
 
-    table = xmlHashCreate(size);
-    if (table != NULL) {
-        table->dict = dict;
-       xmlDictReference(dict);
+    xmlFree(hash);
+}
+
+/**
+ * xmlFastStrEqual:
+ * @s1: string
+ * @s2: string
+ *
+ * Compare two strings for equality, allowing NULL values.
+ */
+static int
+xmlFastStrEqual(const xmlChar *s1, const xmlChar *s2) {
+    if (s1 == NULL)
+        return(s2 == NULL);
+    else
+        return((s2 != NULL) &&
+               (strcmp((const char *) s1, (const char *) s2) == 0));
+}
+
+/**
+ * xmlHashFindEntry:
+ * @hash: hash table, non-NULL, size > 0
+ * @key: first string key, non-NULL
+ * @key2: second string key
+ * @key3: third string key
+ * @hashValue: valid hash value of keys
+ * @pfound: result of search
+ *
+ * Try to find a matching hash table entry. If an entry was found, set
+ * @found to 1 and return the entry. Otherwise, set @found to 0 and return
+ * the location where a new entry should be inserted.
+ */
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static xmlHashEntry *
+xmlHashFindEntry(const xmlHashTable *hash, const xmlChar *key,
+                 const xmlChar *key2, const xmlChar *key3,
+                 unsigned hashValue, int *pfound) {
+    xmlHashEntry *entry;
+    unsigned mask, pos, displ;
+    int found = 0;
+
+    mask = hash->size - 1;
+    pos = hashValue & mask;
+    entry = &hash->table[pos];
+
+    if (entry->hashValue != 0) {
+        /*
+         * Robin hood hashing: abort if the displacement of the entry
+         * is smaller than the displacement of the key we look for.
+         * This also stops at the correct position when inserting.
+         */
+        displ = 0;
+        hashValue |= MAX_HASH_SIZE;
+
+        do {
+            if (entry->hashValue == hashValue) {
+                if (hash->dict) {
+                    if ((entry->key == key) &&
+                        (entry->key2 == key2) &&
+                        (entry->key3 == key3)) {
+                        found = 1;
+                        break;
+                    }
+                }
+                if ((strcmp((const char *) entry->key,
+                            (const char *) key) == 0) &&
+                    (xmlFastStrEqual(entry->key2, key2)) &&
+                    (xmlFastStrEqual(entry->key3, key3))) {
+                    found = 1;
+                    break;
+                }
+            }
+
+            displ++;
+            pos++;
+            entry++;
+            if ((pos & mask) == 0)
+                entry = hash->table;
+        } while ((entry->hashValue != 0) &&
+                 (((pos - entry->hashValue) & mask) >= displ));
     }
-    return(table);
+
+    *pfound = found;
+    return(entry);
 }
 
 /**
  * xmlHashGrow:
- * @table: the hash table
- * @size: the new size of the hash table
+ * @hash: hash table
+ * @size: new size of the hash table
  *
- * resize the hash table
+ * Resize the hash table.
  *
- * Returns 0 in case of success, -1 in case of failure
+ * Returns 0 in case of success, -1 if a memory allocation failed.
  */
 static int
-xmlHashGrow(xmlHashTablePtr table, int size) {
-    unsigned long key;
-    int oldsize, i;
-    xmlHashEntryPtr iter, next;
-    struct _xmlHashEntry *oldtable;
-#ifdef DEBUG_GROW
-    unsigned long nbElem = 0;
-#endif
+xmlHashGrow(xmlHashTablePtr hash, unsigned size) {
+    const xmlHashEntry *oldentry, *oldend, *end;
+    xmlHashEntry *table;
+    unsigned oldsize, i;
 
+    /* Add 0 to avoid spurious -Wtype-limits warning on 64-bit GCC */
+    if ((size_t) size + 0 > SIZE_MAX / sizeof(table[0]))
+        return(-1);
+    table = xmlMalloc(size * sizeof(table[0]));
     if (table == NULL)
-       return(-1);
-    if (size < 8)
         return(-1);
-    if (size > 8 * 2048)
-       return(-1);
+    memset(table, 0, size * sizeof(table[0]));
 
-    oldsize = table->size;
-    oldtable = table->table;
-    if (oldtable == NULL)
-        return(-1);
+    oldsize = hash->size;
+    if (oldsize == 0)
+        goto done;
 
-    table->table = xmlMalloc(size * sizeof(xmlHashEntry));
-    if (table->table == NULL) {
-       table->table = oldtable;
-       return(-1);
-    }
-    memset(table->table, 0, size * sizeof(xmlHashEntry));
-    table->size = size;
-
-    /* If the two loops are merged, there would be situations where
-       a new entry needs to allocated and data copied into it from
-       the main table. So instead, we run through the array twice, first
-       copying all the elements in the main array (where we can't get
-       conflicts) and then the rest, so we only free (and don't allocate)
-    */
-    for (i = 0; i < oldsize; i++) {
-       if (oldtable[i].valid == 0)
-           continue;
-       key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,
-                               oldtable[i].name3);
-       memcpy(&(table->table[key]), &(oldtable[i]), sizeof(xmlHashEntry));
-       table->table[key].next = NULL;
+    oldend = &hash->table[oldsize];
+    end = &table[size];
+
+    /*
+     * Robin Hood sorting order is maintained if we
+     *
+     * - compute hash indices with modulo
+     * - resize by an integer factor
+     * - start to copy from the beginning of a probe sequence
+     */
+    oldentry = hash->table;
+    while (oldentry->hashValue != 0) {
+        if (++oldentry >= oldend)
+            oldentry = hash->table;
     }
 
     for (i = 0; i < oldsize; i++) {
-       iter = oldtable[i].next;
-       while (iter) {
-           next = iter->next;
-
-           /*
-            * put back the entry in the new table
-            */
-
-           key = xmlHashComputeKey(table, iter->name, iter->name2,
-                                   iter->name3);
-           if (table->table[key].valid == 0) {
-               memcpy(&(table->table[key]), iter, sizeof(xmlHashEntry));
-               table->table[key].next = NULL;
-               xmlFree(iter);
-           } else {
-               iter->next = table->table[key].next;
-               table->table[key].next = iter;
-           }
-
-#ifdef DEBUG_GROW
-           nbElem++;
-#endif
+        if (oldentry->hashValue != 0) {
+            xmlHashEntry *entry = &table[oldentry->hashValue & (size - 1)];
+
+            while (entry->hashValue != 0) {
+                if (++entry >= end)
+                    entry = table;
+            }
+            *entry = *oldentry;
+        }
 
-           iter = next;
-       }
+        if (++oldentry >= oldend)
+            oldentry = hash->table;
     }
 
-    xmlFree(oldtable);
+    xmlFree(hash->table);
 
-#ifdef DEBUG_GROW
-    xmlGenericError(xmlGenericErrorContext,
-           "xmlHashGrow : from %d to %d, %d elems\n", oldsize, size, nbElem);
-#endif
+done:
+    hash->table = table;
+    hash->size = size;
 
     return(0);
 }
 
 /**
- * xmlHashFree:
- * @table: the hash table
- * @f:  the deallocator function for items in the hash
+ * xmlHashUpdateInternal:
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @key3: third string key
+ * @payload: pointer to the payload
+ * @dealloc: deallocator function for replaced item or NULL
+ * @update: whether existing entries should be updated
  *
- * Free the hash @table and its contents. The userdata is
- * deallocated with @f if provided.
+ * Internal function to add or update hash entries.
  */
-void
-xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
-    int i;
-    xmlHashEntryPtr iter;
-    xmlHashEntryPtr next;
-    int inside_table = 0;
-    int nbElems;
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static int
+xmlHashUpdateInternal(xmlHashTablePtr hash, const xmlChar *key,
+                      const xmlChar *key2, const xmlChar *key3,
+                      void *payload, xmlHashDeallocator dealloc, int update) {
+    xmlChar *copy, *copy2, *copy3;
+    xmlHashEntry *entry = NULL;
+    size_t lengths[3];
+    unsigned hashValue;
+    int found = 0;
+
+    if ((hash == NULL) || (key == NULL))
+        return(-1);
 
-    if (table == NULL)
-       return;
-    if (table->table) {
-       nbElems = table->nbElems;
-       for(i = 0; (i < table->size) && (nbElems > 0); i++) {
-           iter = &(table->table[i]);
-           if (iter->valid == 0)
-               continue;
-           inside_table = 1;
-           while (iter) {
-               next = iter->next;
-               if ((f != NULL) && (iter->payload != NULL))
-                   f(iter->payload, iter->name);
-               if (table->dict == NULL) {
-                   if (iter->name)
-                       xmlFree(iter->name);
-                   if (iter->name2)
-                       xmlFree(iter->name2);
-                   if (iter->name3)
-                       xmlFree(iter->name3);
-               }
-               iter->payload = NULL;
-               if (!inside_table)
-                   xmlFree(iter);
-               nbElems--;
-               inside_table = 0;
-               iter = next;
-           }
-       }
-       xmlFree(table->table);
+    /*
+     * Check for an existing entry
+     */
+    hashValue = xmlHashValue(hash->randomSeed, key, key2, key3, lengths);
+    if (hash->size > 0)
+        entry = xmlHashFindEntry(hash, key, key2, key3, hashValue, &found);
+    if (found) {
+        if (update) {
+            if (dealloc)
+                dealloc(entry->payload, entry->key);
+            entry->payload = payload;
+            return(0);
+        } else {
+            /*
+             * xmlHashAddEntry found an existing entry.
+             *
+             * TODO: We should return a different error code here to
+             * distinguish from malloc failures.
+             */
+            return(-1);
+        }
     }
-    if (table->dict)
-        xmlDictFree(table->dict);
-    xmlFree(table);
+
+    /*
+     * Grow the hash table if needed
+     */
+    if (hash->nbElems + 1 > hash->size / MAX_FILL_DENOM * MAX_FILL_NUM) {
+        unsigned newSize, mask, displ, pos;
+
+        if (hash->size == 0) {
+            newSize = MIN_HASH_SIZE;
+        } else {
+            /* This guarantees that nbElems < INT_MAX */
+            if (hash->size >= MAX_HASH_SIZE)
+                return(-1);
+            newSize = hash->size * 2;
+        }
+        if (xmlHashGrow(hash, newSize) != 0)
+            return(-1);
+
+        /*
+         * Find new entry
+         */
+        mask = hash->size - 1;
+        displ = 0;
+        pos = hashValue & mask;
+        entry = &hash->table[pos];
+
+        if (entry->hashValue != 0) {
+            do {
+                displ++;
+                pos++;
+                entry++;
+                if ((pos & mask) == 0)
+                    entry = hash->table;
+            } while ((entry->hashValue != 0) &&
+                     ((pos - entry->hashValue) & mask) >= displ);
+        }
+    }
+
+    /*
+     * Copy keys
+     */
+    if (hash->dict != NULL) {
+        if (xmlDictOwns(hash->dict, key)) {
+            copy = (xmlChar *) key;
+        } else {
+            copy = (xmlChar *) xmlDictLookup(hash->dict, key, -1);
+            if (copy == NULL)
+                return(-1);
+        }
+
+        if ((key2 == NULL) || (xmlDictOwns(hash->dict, key2))) {
+            copy2 = (xmlChar *) key2;
+        } else {
+            copy2 = (xmlChar *) xmlDictLookup(hash->dict, key2, -1);
+            if (copy2 == NULL)
+                return(-1);
+        }
+        if ((key3 == NULL) || (xmlDictOwns(hash->dict, key3))) {
+            copy3 = (xmlChar *) key3;
+        } else {
+            copy3 = (xmlChar *) xmlDictLookup(hash->dict, key3, -1);
+            if (copy3 == NULL)
+                return(-1);
+        }
+    } else {
+        copy = xmlMalloc(lengths[0] + 1);
+        if (copy == NULL)
+            return(-1);
+        memcpy(copy, key, lengths[0] + 1);
+
+        if (key2 != NULL) {
+            copy2 = xmlMalloc(lengths[1] + 1);
+            if (copy2 == NULL) {
+                xmlFree(copy);
+                return(-1);
+            }
+            memcpy(copy2, key2, lengths[1] + 1);
+        } else {
+            copy2 = NULL;
+        }
+
+        if (key3 != NULL) {
+            copy3 = xmlMalloc(lengths[2] + 1);
+            if (copy3 == NULL) {
+                xmlFree(copy);
+                xmlFree(copy2);
+                return(-1);
+            }
+            memcpy(copy3, key3, lengths[2] + 1);
+        } else {
+            copy3 = NULL;
+        }
+    }
+
+    /*
+     * Shift the remainder of the probe sequence to the right
+     */
+    if (entry->hashValue != 0) {
+        const xmlHashEntry *end = &hash->table[hash->size];
+        const xmlHashEntry *cur = entry;
+
+        do {
+            cur++;
+            if (cur >= end)
+                cur = hash->table;
+        } while (cur->hashValue != 0);
+
+        if (cur < entry) {
+            /*
+             * If we traversed the end of the buffer, handle the part
+             * at the start of the buffer.
+             */
+            memmove(&hash->table[1], hash->table,
+                    (char *) cur - (char *) hash->table);
+            cur = end - 1;
+            hash->table[0] = *cur;
+        }
+
+        memmove(&entry[1], entry, (char *) cur - (char *) entry);
+    }
+
+    /*
+     * Populate entry
+     */
+    entry->key = copy;
+    entry->key2 = copy2;
+    entry->key3 = copy3;
+    entry->payload = payload;
+    /* OR with MAX_HASH_SIZE to make sure that the value is non-zero */
+    entry->hashValue = hashValue | MAX_HASH_SIZE;
+
+    hash->nbElems++;
+
+    return(0);
 }
 
 /**
  * xmlHashDefaultDeallocator:
- * @entry: the hash table entry
- * @name: the entry's name
+ * @entry: hash table entry
+ * @key: the entry's string key
  *
  * Free a hash table entry with xmlFree.
  */
 void
-xmlHashDefaultDeallocator(void *entry, const xmlChar *name ATTRIBUTE_UNUSED) {
+xmlHashDefaultDeallocator(void *entry, const xmlChar *key ATTRIBUTE_UNUSED) {
     xmlFree(entry);
 }
 
 /**
  * xmlHashAddEntry:
- * @table: the hash table
- * @name: the name of the userdata
- * @userdata: a pointer to the userdata
+ * @hash: hash table
+ * @key: string key
+ * @payload: pointer to the payload
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the @name. Duplicate names generate errors.
+ * Add a hash table entry. If an entry with this key already exists,
+ * payload will not be updated and -1 is returned. This return value
+ * can't be distinguished from out-of-memory errors, so this function
+ * should be used with care.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * Returns 0 on success and -1 in case of error.
  */
 int
-xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) {
-    return(xmlHashAddEntry3(table, name, NULL, NULL, userdata));
+xmlHashAddEntry(xmlHashTablePtr hash, const xmlChar *key, void *payload) {
+    return(xmlHashUpdateInternal(hash, key, NULL, NULL, payload, NULL, 0));
 }
 
 /**
  * xmlHashAddEntry2:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @userdata: a pointer to the userdata
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @payload: pointer to the payload
+ *
+ * Add a hash table entry with two strings as key.
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the (@name, @name2) tuple. Duplicate tuples generate errors.
+ * See xmlHashAddEntry.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * Returns 0 on success and -1 in case of error.
  */
 int
-xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name,
-               const xmlChar *name2, void *userdata) {
-    return(xmlHashAddEntry3(table, name, name2, NULL, userdata));
+xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key,
+                 const xmlChar *key2, void *payload) {
+    return(xmlHashUpdateInternal(hash, key, key2, NULL, payload, NULL, 0));
 }
 
 /**
- * xmlHashUpdateEntry:
- * @table: the hash table
- * @name: the name of the userdata
- * @userdata: a pointer to the userdata
- * @f: the deallocator function for replaced item (if any)
+ * xmlHashAddEntry3:
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @key3: third string key
+ * @payload: pointer to the payload
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the @name. Existing entry for this @name will be removed
- * and freed with @f if found.
+ * Add a hash table entry with three strings as key.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * See xmlHashAddEntry.
+ *
+ * Returns 0 on success and -1 in case of error.
  */
 int
-xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name,
-                  void *userdata, xmlHashDeallocator f) {
-    return(xmlHashUpdateEntry3(table, name, NULL, NULL, userdata, f));
+xmlHashAddEntry3(xmlHashTablePtr hash, const xmlChar *key,
+                 const xmlChar *key2, const xmlChar *key3,
+                 void *payload) {
+    return(xmlHashUpdateInternal(hash, key, key2, key3, payload, NULL, 0));
 }
 
 /**
- * xmlHashUpdateEntry2:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @userdata: a pointer to the userdata
- * @f: the deallocator function for replaced item (if any)
+ * xmlHashUpdateEntry:
+ * @hash: hash table
+ * @key: string key
+ * @payload: pointer to the payload
+ * @dealloc: deallocator function for replaced item or NULL
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the (@name, @name2) tuple. Existing entry for this tuple will
- * be removed and freed with @f if found.
+ * Add a hash table entry. If an entry with this key already exists,
+ * the old payload will be freed and updated with the new value.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * Returns 0 in case of success, -1 if a memory allocation failed.
  */
 int
-xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name,
-                  const xmlChar *name2, void *userdata,
-                  xmlHashDeallocator f) {
-    return(xmlHashUpdateEntry3(table, name, name2, NULL, userdata, f));
+xmlHashUpdateEntry(xmlHashTablePtr hash, const xmlChar *key,
+                   void *payload, xmlHashDeallocator dealloc) {
+    return(xmlHashUpdateInternal(hash, key, NULL, NULL, payload,
+                                 dealloc, 1));
 }
 
 /**
- * xmlHashLookup:
- * @table: the hash table
- * @name: the name of the userdata
+ * xmlHashUpdateEntry2:
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @payload: pointer to the payload
+ * @dealloc: deallocator function for replaced item or NULL
+ *
+ * Add a hash table entry with two strings as key.
  *
- * Find the userdata specified by the @name.
+ * See xmlHashUpdateEntry.
  *
- * Returns the pointer to the userdata
+ * Returns 0 on success and -1 in case of error.
  */
-void *
-xmlHashLookup(xmlHashTablePtr table, const xmlChar *name) {
-    return(xmlHashLookup3(table, name, NULL, NULL));
+int
+xmlHashUpdateEntry2(xmlHashTablePtr hash, const xmlChar *key,
+                   const xmlChar *key2, void *payload,
+                   xmlHashDeallocator dealloc) {
+    return(xmlHashUpdateInternal(hash, key, key2, NULL, payload,
+                                 dealloc, 1));
 }
 
 /**
- * xmlHashLookup2:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
+ * xmlHashUpdateEntry3:
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @key3: third string key
+ * @payload: pointer to the payload
+ * @dealloc: deallocator function for replaced item or NULL
  *
- * Find the userdata specified by the (@name, @name2) tuple.
+ * Add a hash table entry with three strings as key.
  *
- * Returns the pointer to the userdata
+ * See xmlHashUpdateEntry.
+ *
+ * Returns 0 on success and -1 in case of error.
  */
-void *
-xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name,
-             const xmlChar *name2) {
-    return(xmlHashLookup3(table, name, name2, NULL));
+int
+xmlHashUpdateEntry3(xmlHashTablePtr hash, const xmlChar *key,
+                   const xmlChar *key2, const xmlChar *key3,
+                   void *payload, xmlHashDeallocator dealloc) {
+    return(xmlHashUpdateInternal(hash, key, key2, key3, payload,
+                                 dealloc, 1));
 }
 
 /**
- * xmlHashQLookup:
- * @table: the hash table
- * @prefix: the prefix of the userdata
- * @name: the name of the userdata
+ * xmlHashLookup:
+ * @hash: hash table
+ * @key: string key
  *
- * Find the userdata specified by the QName @prefix:@name/@name.
+ * Find the entry specified by @key.
  *
- * Returns the pointer to the userdata
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
 void *
-xmlHashQLookup(xmlHashTablePtr table, const xmlChar *prefix,
-               const xmlChar *name) {
-    return(xmlHashQLookup3(table, prefix, name, NULL, NULL, NULL, NULL));
+xmlHashLookup(xmlHashTablePtr hash, const xmlChar *key) {
+    return(xmlHashLookup3(hash, key, NULL, NULL));
 }
 
 /**
- * xmlHashQLookup2:
- * @table: the hash table
- * @prefix: the prefix of the userdata
- * @name: the name of the userdata
- * @prefix2: the second prefix of the userdata
- * @name2: a second name of the userdata
+ * xmlHashLookup2:
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
  *
- * Find the userdata specified by the QNames tuple
+ * Find the payload specified by the (@key, @key2) tuple.
  *
- * Returns the pointer to the userdata
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
 void *
-xmlHashQLookup2(xmlHashTablePtr table, const xmlChar *prefix,
-                const xmlChar *name, const xmlChar *prefix2,
-               const xmlChar *name2) {
-    return(xmlHashQLookup3(table, prefix, name, prefix2, name2, NULL, NULL));
+xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key,
+              const xmlChar *key2) {
+    return(xmlHashLookup3(hash, key, key2, NULL));
 }
 
 /**
- * xmlHashAddEntry3:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @name3: a third name of the userdata
- * @userdata: a pointer to the userdata
+ * xmlHashQLookup:
+ * @hash: hash table
+ * @prefix: prefix of the string key
+ * @name: local name of the string key
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the tuple (@name, @name2, @name3). Duplicate entries generate
- * errors.
+ * Find the payload specified by the QName @prefix:@name or @name.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
-int
-xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,
-                const xmlChar *name2, const xmlChar *name3,
-                void *userdata) {
-    unsigned long key, len = 0;
-    xmlHashEntryPtr entry;
-    xmlHashEntryPtr insert;
-
-    if ((table == NULL) || (name == NULL))
-       return(-1);
-
-    /*
-     * If using a dict internalize if needed
-     */
-    if (table->dict) {
-        if (!xmlDictOwns(table->dict, name)) {
-           name = xmlDictLookup(table->dict, name, -1);
-           if (name == NULL)
-               return(-1);
-       }
-        if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
-           name2 = xmlDictLookup(table->dict, name2, -1);
-           if (name2 == NULL)
-               return(-1);
-       }
-        if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
-           name3 = xmlDictLookup(table->dict, name3, -1);
-           if (name3 == NULL)
-               return(-1);
-       }
-    }
-
-    /*
-     * Check for duplicate and insertion location.
-     */
-    key = xmlHashComputeKey(table, name, name2, name3);
-    if (table->table[key].valid == 0) {
-       insert = NULL;
-    } else {
-        if (table->dict) {
-           for (insert = &(table->table[key]); insert->next != NULL;
-                insert = insert->next) {
-               if ((insert->name == name) &&
-                   (insert->name2 == name2) &&
-                   (insert->name3 == name3))
-                   return(-1);
-               len++;
-           }
-           if ((insert->name == name) &&
-               (insert->name2 == name2) &&
-               (insert->name3 == name3))
-               return(-1);
-       } else {
-           for (insert = &(table->table[key]); insert->next != NULL;
-                insert = insert->next) {
-               if ((xmlStrEqual(insert->name, name)) &&
-                   (xmlStrEqual(insert->name2, name2)) &&
-                   (xmlStrEqual(insert->name3, name3)))
-                   return(-1);
-               len++;
-           }
-           if ((xmlStrEqual(insert->name, name)) &&
-               (xmlStrEqual(insert->name2, name2)) &&
-               (xmlStrEqual(insert->name3, name3)))
-               return(-1);
-       }
-    }
-
-    if (insert == NULL) {
-       entry = &(table->table[key]);
-    } else {
-       entry = xmlMalloc(sizeof(xmlHashEntry));
-       if (entry == NULL)
-            return(-1);
-    }
-
-    if (table->dict != NULL) {
-        entry->name = (xmlChar *) name;
-        entry->name2 = (xmlChar *) name2;
-        entry->name3 = (xmlChar *) name3;
-    } else {
-       entry->name = xmlStrdup(name);
-       entry->name2 = xmlStrdup(name2);
-       entry->name3 = xmlStrdup(name3);
-    }
-    entry->payload = userdata;
-    entry->next = NULL;
-    entry->valid = 1;
-
-
-    if (insert != NULL)
-       insert->next = entry;
-
-    table->nbElems++;
-
-    if (len > MAX_HASH_LEN)
-       xmlHashGrow(table, MAX_HASH_LEN * table->size);
-
-    return(0);
+void *
+xmlHashQLookup(xmlHashTablePtr hash, const xmlChar *prefix,
+               const xmlChar *name) {
+    return(xmlHashQLookup3(hash, prefix, name, NULL, NULL, NULL, NULL));
 }
 
 /**
- * xmlHashUpdateEntry3:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @name3: a third name of the userdata
- * @userdata: a pointer to the userdata
- * @f: the deallocator function for replaced item (if any)
+ * xmlHashQLookup2:
+ * @hash: hash table
+ * @prefix: first prefix
+ * @name: first local name
+ * @prefix2: second prefix
+ * @name2: second local name
  *
- * Add the @userdata to the hash @table. This can later be retrieved
- * by using the tuple (@name, @name2, @name3). Existing entry for this tuple
- * will be removed and freed with @f if found.
+ * Find the payload specified by the QNames tuple.
  *
- * Returns 0 the addition succeeded and -1 in case of error.
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
-int
-xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name,
-                  const xmlChar *name2, const xmlChar *name3,
-                  void *userdata, xmlHashDeallocator f) {
-    unsigned long key;
-    xmlHashEntryPtr entry;
-    xmlHashEntryPtr insert;
-
-    if ((table == NULL) || name == NULL)
-       return(-1);
-
-    /*
-     * If using a dict internalize if needed
-     */
-    if (table->dict) {
-        if (!xmlDictOwns(table->dict, name)) {
-           name = xmlDictLookup(table->dict, name, -1);
-           if (name == NULL)
-               return(-1);
-       }
-        if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
-           name2 = xmlDictLookup(table->dict, name2, -1);
-           if (name2 == NULL)
-               return(-1);
-       }
-        if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
-           name3 = xmlDictLookup(table->dict, name3, -1);
-           if (name3 == NULL)
-               return(-1);
-       }
-    }
-
-    /*
-     * Check for duplicate and insertion location.
-     */
-    key = xmlHashComputeKey(table, name, name2, name3);
-    if (table->table[key].valid == 0) {
-       insert = NULL;
-    } else {
-        if (table ->dict) {
-           for (insert = &(table->table[key]); insert->next != NULL;
-                insert = insert->next) {
-               if ((insert->name == name) &&
-                   (insert->name2 == name2) &&
-                   (insert->name3 == name3)) {
-                   if (f)
-                       f(insert->payload, insert->name);
-                   insert->payload = userdata;
-                   return(0);
-               }
-           }
-           if ((insert->name == name) &&
-               (insert->name2 == name2) &&
-               (insert->name3 == name3)) {
-               if (f)
-                   f(insert->payload, insert->name);
-               insert->payload = userdata;
-               return(0);
-           }
-       } else {
-           for (insert = &(table->table[key]); insert->next != NULL;
-                insert = insert->next) {
-               if ((xmlStrEqual(insert->name, name)) &&
-                   (xmlStrEqual(insert->name2, name2)) &&
-                   (xmlStrEqual(insert->name3, name3))) {
-                   if (f)
-                       f(insert->payload, insert->name);
-                   insert->payload = userdata;
-                   return(0);
-               }
-           }
-           if ((xmlStrEqual(insert->name, name)) &&
-               (xmlStrEqual(insert->name2, name2)) &&
-               (xmlStrEqual(insert->name3, name3))) {
-               if (f)
-                   f(insert->payload, insert->name);
-               insert->payload = userdata;
-               return(0);
-           }
-       }
-    }
-
-    if (insert == NULL) {
-       entry =  &(table->table[key]);
-    } else {
-       entry = xmlMalloc(sizeof(xmlHashEntry));
-       if (entry == NULL)
-            return(-1);
-    }
-
-    if (table->dict != NULL) {
-        entry->name = (xmlChar *) name;
-        entry->name2 = (xmlChar *) name2;
-        entry->name3 = (xmlChar *) name3;
-    } else {
-       entry->name = xmlStrdup(name);
-       entry->name2 = xmlStrdup(name2);
-       entry->name3 = xmlStrdup(name3);
-    }
-    entry->payload = userdata;
-    entry->next = NULL;
-    entry->valid = 1;
-    table->nbElems++;
-
-
-    if (insert != NULL) {
-       insert->next = entry;
-    }
-    return(0);
+void *
+xmlHashQLookup2(xmlHashTablePtr hash, const xmlChar *prefix,
+                const xmlChar *name, const xmlChar *prefix2,
+                const xmlChar *name2) {
+    return(xmlHashQLookup3(hash, prefix, name, prefix2, name2, NULL, NULL));
 }
 
 /**
  * xmlHashLookup3:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @name3: a third name of the userdata
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @key3: third string key
  *
- * Find the userdata specified by the (@name, @name2, @name3) tuple.
+ * Find the payload specified by the (@key, @key2, @key3) tuple.
  *
- * Returns the a pointer to the userdata
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
 void *
-xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
-              const xmlChar *name2, const xmlChar *name3) {
-    unsigned long key;
-    xmlHashEntryPtr entry;
+xmlHashLookup3(xmlHashTablePtr hash, const xmlChar *key,
+               const xmlChar *key2, const xmlChar *key3) {
+    const xmlHashEntry *entry;
+    unsigned hashValue;
+    int found;
 
-    if (table == NULL)
-       return(NULL);
-    if (name == NULL)
-       return(NULL);
-    key = xmlHashComputeKey(table, name, name2, name3);
-    if (table->table[key].valid == 0)
-       return(NULL);
-    if (table->dict) {
-       for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
-           if ((entry->name == name) &&
-               (entry->name2 == name2) &&
-               (entry->name3 == name3))
-               return(entry->payload);
-       }
-    }
-    for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
-       if ((xmlStrEqual(entry->name, name)) &&
-           (xmlStrEqual(entry->name2, name2)) &&
-           (xmlStrEqual(entry->name3, name3)))
-           return(entry->payload);
-    }
+    if ((hash == NULL) || (hash->size == 0) || (key == NULL))
+        return(NULL);
+    hashValue = xmlHashValue(hash->randomSeed, key, key2, key3, NULL);
+    entry = xmlHashFindEntry(hash, key, key2, key3, hashValue, &found);
+    if (found)
+        return(entry->payload);
     return(NULL);
 }
 
 /**
  * xmlHashQLookup3:
- * @table: the hash table
- * @prefix: the prefix of the userdata
- * @name: the name of the userdata
- * @prefix2: the second prefix of the userdata
- * @name2: a second name of the userdata
- * @prefix3: the third prefix of the userdata
- * @name3: a third name of the userdata
+ * @hash: hash table
+ * @prefix: first prefix
+ * @name: first local name
+ * @prefix2: second prefix
+ * @name2: second local name
+ * @prefix3: third prefix
+ * @name3: third local name
  *
- * Find the userdata specified by the (@name, @name2, @name3) tuple.
+ * Find the payload specified by the QNames tuple.
  *
- * Returns the a pointer to the userdata
+ * Returns a pointer to the payload or NULL if no entry was found.
  */
+ATTRIBUTE_NO_SANITIZE_INTEGER
 void *
-xmlHashQLookup3(xmlHashTablePtr table,
+xmlHashQLookup3(xmlHashTablePtr hash,
                 const xmlChar *prefix, const xmlChar *name,
-               const xmlChar *prefix2, const xmlChar *name2,
-               const xmlChar *prefix3, const xmlChar *name3) {
-    unsigned long key;
-    xmlHashEntryPtr entry;
+                const xmlChar *prefix2, const xmlChar *name2,
+                const xmlChar *prefix3, const xmlChar *name3) {
+    const xmlHashEntry *entry;
+    unsigned hashValue, mask, pos, displ;
 
-    if (table == NULL)
-       return(NULL);
-    if (name == NULL)
-       return(NULL);
-    key = xmlHashComputeQKey(table, prefix, name, prefix2,
-                             name2, prefix3, name3);
-    if (table->table[key].valid == 0)
-       return(NULL);
-    for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
-       if ((xmlStrQEqual(prefix, name, entry->name)) &&
-           (xmlStrQEqual(prefix2, name2, entry->name2)) &&
-           (xmlStrQEqual(prefix3, name3, entry->name3)))
-           return(entry->payload);
+    if ((hash == NULL) || (hash->size == 0) || (name == NULL))
+        return(NULL);
+
+    hashValue = xmlHashQNameValue(hash->randomSeed, prefix, name, prefix2,
+                                  name2, prefix3, name3);
+    mask = hash->size - 1;
+    pos = hashValue & mask;
+    entry = &hash->table[pos];
+
+    if (entry->hashValue != 0) {
+        displ = 0;
+        hashValue |= MAX_HASH_SIZE;
+
+        do {
+            if ((hashValue == entry->hashValue) &&
+                (xmlStrQEqual(prefix, name, entry->key)) &&
+                (xmlStrQEqual(prefix2, name2, entry->key2)) &&
+                (xmlStrQEqual(prefix3, name3, entry->key3)))
+                return(entry->payload);
+
+            displ++;
+            pos++;
+            entry++;
+            if ((pos & mask) == 0)
+                entry = hash->table;
+        } while ((entry->hashValue != 0) &&
+                 (((pos - entry->hashValue) & mask) >= displ));
     }
+
     return(NULL);
 }
 
 typedef struct {
-    xmlHashScanner hashscanner;
+    xmlHashScanner scan;
     void *data;
 } stubData;
 
 static void
-stubHashScannerFull (void *payload, void *data, const xmlChar *name,
-                     const xmlChar *name2 ATTRIBUTE_UNUSED,
-                    const xmlChar *name3 ATTRIBUTE_UNUSED) {
-    stubData *stubdata = (stubData *) data;
-    stubdata->hashscanner (payload, stubdata->data, (xmlChar *) name);
+stubHashScannerFull(void *payload, void *data, const xmlChar *key,
+                    const xmlChar *key2 ATTRIBUTE_UNUSED,
+                    const xmlChar *key3 ATTRIBUTE_UNUSED) {
+    stubData *sdata = (stubData *) data;
+    sdata->scan(payload, sdata->data, key);
 }
 
 /**
  * xmlHashScan:
- * @table: the hash table
- * @f:  the scanner function for items in the hash
- * @data:  extra data passed to f
+ * @hash: hash table
+ * @scan: scanner function for items in the hash
+ * @data: extra data passed to @scan
  *
- * Scan the hash @table and applied @f to each value.
+ * Scan the hash @table and apply @scan to each value.
  */
 void
-xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
-    stubData stubdata;
-    stubdata.data = data;
-    stubdata.hashscanner = f;
-    xmlHashScanFull (table, stubHashScannerFull, &stubdata);
+xmlHashScan(xmlHashTablePtr hash, xmlHashScanner scan, void *data) {
+    stubData sdata;
+    sdata.data = data;
+    sdata.scan = scan;
+    xmlHashScanFull(hash, stubHashScannerFull, &sdata);
 }
 
 /**
  * xmlHashScanFull:
- * @table: the hash table
- * @f:  the scanner function for items in the hash
- * @data:  extra data passed to f
+ * @hash: hash table
+ * @scan: scanner function for items in the hash
+ * @data: extra data passed to @scan
  *
- * Scan the hash @table and applied @f to each value.
+ * Scan the hash @table and apply @scan to each value.
  */
 void
-xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
-    int i, nb;
-    xmlHashEntryPtr iter;
-    xmlHashEntryPtr next;
+xmlHashScanFull(xmlHashTablePtr hash, xmlHashScannerFull scan, void *data) {
+    const xmlHashEntry *entry, *end;
+    xmlHashEntry old;
+    unsigned i;
 
-    if (table == NULL)
-       return;
-    if (f == NULL)
-       return;
-
-    if (table->table) {
-       for(i = 0; i < table->size; i++) {
-           if (table->table[i].valid == 0)
-               continue;
-           iter = &(table->table[i]);
-           while (iter) {
-               next = iter->next;
-                nb = table->nbElems;
-               if ((f != NULL) && (iter->payload != NULL))
-                   f(iter->payload, data, iter->name,
-                     iter->name2, iter->name3);
-                if (nb != table->nbElems) {
-                    /* table was modified by the callback, be careful */
-                    if (iter == &(table->table[i])) {
-                        if (table->table[i].valid == 0)
-                            iter = NULL;
-                        if (table->table[i].next != next)
-                           iter = &(table->table[i]);
-                    } else
-                       iter = next;
-                } else
-                   iter = next;
-           }
-       }
+    if ((hash == NULL) || (hash->size == 0) || (scan == NULL))
+        return;
+
+    /*
+     * We must handle the case that a scanned entry is removed when executing
+     * the callback (xmlCleanSpecialAttr and possibly other places).
+     *
+     * Find the start of a probe sequence to avoid scanning entries twice if
+     * a deletion happens.
+     */
+    entry = hash->table;
+    end = &hash->table[hash->size];
+    while (entry->hashValue != 0) {
+        if (++entry >= end)
+            entry = hash->table;
+    }
+
+    for (i = 0; i < hash->size; i++) {
+        if ((entry->hashValue != 0) && (entry->payload != NULL)) {
+            /*
+             * Make sure to rescan after a possible deletion.
+             */
+            do {
+                old = *entry;
+                scan(entry->payload, data, entry->key, entry->key2, entry->key3);
+            } while ((entry->hashValue != 0) &&
+                     (entry->payload != NULL) &&
+                     ((entry->key != old.key) ||
+                      (entry->key2 != old.key2) ||
+                      (entry->key3 != old.key3)));
+        }
+        if (++entry >= end)
+            entry = hash->table;
     }
 }
 
 /**
  * xmlHashScan3:
- * @table: the hash table
- * @name: the name of the userdata or NULL
- * @name2: a second name of the userdata or NULL
- * @name3: a third name of the userdata or NULL
- * @f:  the scanner function for items in the hash
- * @data:  extra data passed to f
+ * @hash: hash table
+ * @key: first string key or NULL
+ * @key2: second string key or NULL
+ * @key3: third string key or NULL
+ * @scan: scanner function for items in the hash
+ * @data: extra data passed to @scan
  *
- * Scan the hash @table and applied @f to each value matching
- * (@name, @name2, @name3) tuple. If one of the names is null,
+ * Scan the hash @table and apply @scan to each value matching
+ * (@key, @key2, @key3) tuple. If one of the keys is null,
  * the comparison is considered to match.
  */
 void
-xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
-            const xmlChar *name2, const xmlChar *name3,
-            xmlHashScanner f, void *data) {
-    stubData stubdata;
-    stubdata.data = data;
-    stubdata.hashscanner = f;
-    xmlHashScanFull3(table, name, name2, name3, stubHashScannerFull,
-                     &stubdata);
+xmlHashScan3(xmlHashTablePtr hash, const xmlChar *key,
+             const xmlChar *key2, const xmlChar *key3,
+             xmlHashScanner scan, void *data) {
+    stubData sdata;
+    sdata.data = data;
+    sdata.scan = scan;
+    xmlHashScanFull3(hash, key, key2, key3, stubHashScannerFull, &sdata);
 }
 
 /**
  * xmlHashScanFull3:
- * @table: the hash table
- * @name: the name of the userdata or NULL
- * @name2: a second name of the userdata or NULL
- * @name3: a third name of the userdata or NULL
- * @f:  the scanner function for items in the hash
- * @data:  extra data passed to f
+ * @hash: hash table
+ * @key: first string key or NULL
+ * @key2: second string key or NULL
+ * @key3: third string key or NULL
+ * @scan: scanner function for items in the hash
+ * @data: extra data passed to @scan
  *
- * Scan the hash @table and applied @f to each value matching
- * (@name, @name2, @name3) tuple. If one of the names is null,
+ * Scan the hash @table and apply @scan to each value matching
+ * (@key, @key2, @key3) tuple. If one of the keys is null,
  * the comparison is considered to match.
  */
 void
-xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
-                const xmlChar *name2, const xmlChar *name3,
-                xmlHashScannerFull f, void *data) {
-    int i;
-    xmlHashEntryPtr iter;
-    xmlHashEntryPtr next;
+xmlHashScanFull3(xmlHashTablePtr hash, const xmlChar *key,
+                 const xmlChar *key2, const xmlChar *key3,
+                 xmlHashScannerFull scan, void *data) {
+    const xmlHashEntry *entry, *end;
+    xmlHashEntry old;
+    unsigned i;
 
-    if (table == NULL)
-       return;
-    if (f == NULL)
-       return;
-
-    if (table->table) {
-       for(i = 0; i < table->size; i++) {
-           if (table->table[i].valid == 0)
-               continue;
-           iter = &(table->table[i]);
-           while (iter) {
-               next = iter->next;
-               if (((name == NULL) || (xmlStrEqual(name, iter->name))) &&
-                   ((name2 == NULL) || (xmlStrEqual(name2, iter->name2))) &&
-                   ((name3 == NULL) || (xmlStrEqual(name3, iter->name3))) &&
-                   (iter->payload != NULL)) {
-                   f(iter->payload, data, iter->name,
-                     iter->name2, iter->name3);
-               }
-               iter = next;
-           }
-       }
+    if ((hash == NULL) || (hash->size == 0) || (scan == NULL))
+        return;
+
+    /*
+     * We must handle the case that a scanned entry is removed when executing
+     * the callback (xmlCleanSpecialAttr and possibly other places).
+     *
+     * Find the start of a probe sequence to avoid scanning entries twice if
+     * a deletion happens.
+     */
+    entry = hash->table;
+    end = &hash->table[hash->size];
+    while (entry->hashValue != 0) {
+        if (++entry >= end)
+            entry = hash->table;
+    }
+
+    for (i = 0; i < hash->size; i++) {
+        if ((entry->hashValue != 0) && (entry->payload != NULL)) {
+            /*
+             * Make sure to rescan after a possible deletion.
+             */
+            do {
+                if (((key != NULL) && (strcmp((const char *) key,
+                                              (const char *) entry->key) != 0)) ||
+                    ((key2 != NULL) && (!xmlFastStrEqual(key2, entry->key2))) ||
+                    ((key3 != NULL) && (!xmlFastStrEqual(key3, entry->key3))))
+                    break;
+                old = *entry;
+                scan(entry->payload, data, entry->key, entry->key2, entry->key3);
+            } while ((entry->hashValue != 0) &&
+                     (entry->payload != NULL) &&
+                     ((entry->key != old.key) ||
+                      (entry->key2 != old.key2) ||
+                      (entry->key3 != old.key3)));
+        }
+        if (++entry >= end)
+            entry = hash->table;
     }
 }
 
 /**
  * xmlHashCopy:
- * @table: the hash table
- * @f:  the copier function for items in the hash
+ * @hash: hash table
+ * @copy: copier function for items in the hash
  *
- * Scan the hash @table and applied @f to each value.
+ * Copy the hash @table using @copy to copy payloads.
  *
- * Returns the new table or NULL in case of error.
+ * Returns the new table or NULL if a memory allocation failed.
  */
 xmlHashTablePtr
-xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
-    int i;
-    xmlHashEntryPtr iter;
-    xmlHashEntryPtr next;
+xmlHashCopy(xmlHashTablePtr hash, xmlHashCopier copy) {
+    const xmlHashEntry *entry, *end;
     xmlHashTablePtr ret;
 
-    if (table == NULL)
-       return(NULL);
-    if (f == NULL)
-       return(NULL);
+    if ((hash == NULL) || (copy == NULL))
+        return(NULL);
 
-    ret = xmlHashCreate(table->size);
+    ret = xmlHashCreate(hash->size);
     if (ret == NULL)
         return(NULL);
 
-    if (table->table) {
-       for(i = 0; i < table->size; i++) {
-           if (table->table[i].valid == 0)
-               continue;
-           iter = &(table->table[i]);
-           while (iter) {
-               next = iter->next;
-               xmlHashAddEntry3(ret, iter->name, iter->name2,
-                                iter->name3, f(iter->payload, iter->name));
-               iter = next;
-           }
-       }
+    if (hash->size == 0)
+        return(ret);
+
+    end = &hash->table[hash->size];
+
+    for (entry = hash->table; entry < end; entry++) {
+        if (entry->hashValue != 0)
+            xmlHashAddEntry3(ret, entry->key, entry->key2, entry->key3,
+                             copy(entry->payload, entry->key));
     }
-    ret->nbElems = table->nbElems;
+
     return(ret);
 }
 
 /**
  * xmlHashSize:
- * @table: the hash table
+ * @hash: hash table
  *
- * Query the number of elements installed in the hash @table.
+ * Query the number of elements in the hash table.
  *
  * Returns the number of elements in the hash table or
- * -1 in case of error
+ * -1 in case of error.
  */
 int
-xmlHashSize(xmlHashTablePtr table) {
-    if (table == NULL)
-       return(-1);
-    return(table->nbElems);
+xmlHashSize(xmlHashTablePtr hash) {
+    if (hash == NULL)
+        return(-1);
+    return(hash->nbElems);
 }
 
 /**
  * xmlHashRemoveEntry:
- * @table: the hash table
- * @name: the name of the userdata
- * @f: the deallocator function for removed item (if any)
+ * @hash: hash table
+ * @key: string key
+ * @dealloc: deallocator function for removed item or NULL
  *
- * Find the userdata specified by the @name and remove
- * it from the hash @table. Existing userdata for this tuple will be removed
- * and freed with @f.
+ * Find the entry specified by the @key and remove it from the hash table.
+ * Payload will be freed with @dealloc.
  *
- * Returns 0 if the removal succeeded and -1 in case of error or not found.
+ * Returns 0 on success and -1 if no entry was found.
  */
-int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
-                      xmlHashDeallocator f) {
-    return(xmlHashRemoveEntry3(table, name, NULL, NULL, f));
+int xmlHashRemoveEntry(xmlHashTablePtr hash, const xmlChar *key,
+                       xmlHashDeallocator dealloc) {
+    return(xmlHashRemoveEntry3(hash, key, NULL, NULL, dealloc));
 }
 
 /**
  * xmlHashRemoveEntry2:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @f: the deallocator function for removed item (if any)
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @dealloc: deallocator function for removed item or NULL
+ *
+ * Remove an entry with two strings as key.
  *
- * Find the userdata specified by the (@name, @name2) tuple and remove
- * it from the hash @table. Existing userdata for this tuple will be removed
- * and freed with @f.
+ * See xmlHashRemoveEntry.
  *
- * Returns 0 if the removal succeeded and -1 in case of error or not found.
+ * Returns 0 on success and -1 in case of error.
  */
 int
-xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
-                       const xmlChar *name2, xmlHashDeallocator f) {
-    return(xmlHashRemoveEntry3(table, name, name2, NULL, f));
+xmlHashRemoveEntry2(xmlHashTablePtr hash, const xmlChar *key,
+                    const xmlChar *key2, xmlHashDeallocator dealloc) {
+    return(xmlHashRemoveEntry3(hash, key, key2, NULL, dealloc));
 }
 
 /**
  * xmlHashRemoveEntry3:
- * @table: the hash table
- * @name: the name of the userdata
- * @name2: a second name of the userdata
- * @name3: a third name of the userdata
- * @f: the deallocator function for removed item (if any)
+ * @hash: hash table
+ * @key: first string key
+ * @key2: second string key
+ * @key3: third string key
+ * @dealloc: deallocator function for removed item or NULL
  *
- * Find the userdata specified by the (@name, @name2, @name3) tuple and remove
- * it from the hash @table. Existing userdata for this tuple will be removed
- * and freed with @f.
+ * Remove an entry with three strings as key.
  *
- * Returns 0 if the removal succeeded and -1 in case of error or not found.
+ * See xmlHashRemoveEntry.
+ *
+ * Returns 0 on success and -1 in case of error.
  */
+ATTRIBUTE_NO_SANITIZE_INTEGER
 int
-xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
-    const xmlChar *name2, const xmlChar *name3, xmlHashDeallocator f) {
-    unsigned long key;
-    xmlHashEntryPtr entry;
-    xmlHashEntryPtr prev = NULL;
-
-    if (table == NULL || name == NULL)
+xmlHashRemoveEntry3(xmlHashTablePtr hash, const xmlChar *key,
+                    const xmlChar *key2, const xmlChar *key3,
+                    xmlHashDeallocator dealloc) {
+    xmlHashEntry *entry, *cur, *next;
+    unsigned hashValue, mask, pos, nextpos;
+    int found;
+
+    if ((hash == NULL) || (hash->size == 0) || (key == NULL))
         return(-1);
 
-    key = xmlHashComputeKey(table, name, name2, name3);
-    if (table->table[key].valid == 0) {
-        return(-1);
-    } else {
-        for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
-            if (xmlStrEqual(entry->name, name) &&
-                    xmlStrEqual(entry->name2, name2) &&
-                    xmlStrEqual(entry->name3, name3)) {
-                if ((f != NULL) && (entry->payload != NULL))
-                    f(entry->payload, entry->name);
-                entry->payload = NULL;
-               if (table->dict == NULL) {
-                   if(entry->name)
-                       xmlFree(entry->name);
-                   if(entry->name2)
-                       xmlFree(entry->name2);
-                   if(entry->name3)
-                       xmlFree(entry->name3);
-               }
-                if(prev) {
-                    prev->next = entry->next;
-                   xmlFree(entry);
-               } else {
-                   if (entry->next == NULL) {
-                       entry->valid = 0;
-                   } else {
-                       entry = entry->next;
-                       memcpy(&(table->table[key]), entry, sizeof(xmlHashEntry));
-                       xmlFree(entry);
-                   }
-               }
-                table->nbElems--;
-                return(0);
-            }
-            prev = entry;
-        }
+    hashValue = xmlHashValue(hash->randomSeed, key, key2, key3, NULL);
+    entry = xmlHashFindEntry(hash, key, key2, key3, hashValue, &found);
+    if (!found)
         return(-1);
+
+    if ((dealloc != NULL) && (entry->payload != NULL))
+        dealloc(entry->payload, entry->key);
+    if (hash->dict == NULL) {
+        if (entry->key)
+            xmlFree(entry->key);
+        if (entry->key2)
+            xmlFree(entry->key2);
+        if (entry->key3)
+            xmlFree(entry->key3);
     }
+
+    /*
+     * Find end of probe sequence. Entries at their initial probe
+     * position start a new sequence.
+     */
+    mask = hash->size - 1;
+    pos = entry - hash->table;
+    cur = entry;
+
+    while (1) {
+        nextpos = pos + 1;
+        next = cur + 1;
+        if ((nextpos & mask) == 0)
+            next = hash->table;
+
+        if ((next->hashValue == 0) ||
+            (((next->hashValue - nextpos) & mask) == 0))
+            break;
+
+        cur = next;
+        pos = nextpos;
+    }
+
+    /*
+     * Backward shift
+     */
+    next = entry + 1;
+
+    if (cur < entry) {
+        xmlHashEntry *end = &hash->table[hash->size];
+
+        memmove(entry, next, (char *) end - (char *) next);
+        entry = hash->table;
+        end[-1] = *entry;
+        next = entry + 1;
+    }
+
+    memmove(entry, next, (char *) cur - (char *) entry);
+
+    /*
+     * Update entry
+     */
+    cur->hashValue = 0;
+
+    hash->nbElems--;
+
+    return(0);
 }
 
index 7dbfaa5..2603acc 100644 (file)
@@ -1,5 +1,5 @@
 ## Process this file with automake to produce Makefile.in
-SUBDIRS=libxml
+SUBDIRS=libxml private
 
 EXTRA_DIST = win32config.h wsockcompat.h
 
index 1d4fec2..e16d774 100644 (file)
@@ -80,90 +80,121 @@ struct _htmlEntityDesc {
     const char *desc;   /* the description */
 };
 
+/** DOC_DISABLE */
+#ifdef LIBXML_SAX1_ENABLED
+  #define XML_GLOBALS_HTML \
+    XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
+#else
+  #define XML_GLOBALS_HTML
+#endif
+
+#define XML_OP XML_DECLARE_GLOBAL
+XML_GLOBALS_HTML
+#undef XML_OP
+
+#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+  #define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
+#endif
+/** DOC_ENABLE */
+
 /*
  * There is only few public functions.
  */
-XMLPUBFUN const htmlElemDesc * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
+                       htmlInitAutoClose       (void);
+XMLPUBFUN const htmlElemDesc *
                        htmlTagLookup   (const xmlChar *tag);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XMLPUBFUN const htmlEntityDesc *
                        htmlEntityLookup(const xmlChar *name);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XMLPUBFUN const htmlEntityDesc *
                        htmlEntityValueLookup(unsigned int value);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlIsAutoClosed(htmlDocPtr doc,
                                         htmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlAutoCloseTag(htmlDocPtr doc,
                                         const xmlChar *name,
                                         htmlNodePtr elem);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const htmlEntityDesc *
                        htmlParseEntityRef(htmlParserCtxtPtr ctxt,
                                         const xmlChar **str);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        htmlParseCharRef(htmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        htmlParseElement(htmlParserCtxtPtr ctxt);
 
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr
                        htmlNewParserCtxt(void);
+XMLPUBFUN htmlParserCtxtPtr
+                       htmlNewSAXParserCtxt(const htmlSAXHandler *sax,
+                                            void *userData);
 
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr
                        htmlCreateMemoryParserCtxt(const char *buffer,
                                                   int size);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlParseDocument(htmlParserCtxtPtr ctxt);
-XMLPUBFUN htmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN htmlDocPtr
                        htmlSAXParseDoc (const xmlChar *cur,
                                         const char *encoding,
                                         htmlSAXHandlerPtr sax,
                                         void *userData);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                        htmlParseDoc    (const xmlChar *cur,
                                         const char *encoding);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr
+                       htmlCreateFileParserCtxt(const char *filename,
+                                                const char *encoding);
+XML_DEPRECATED
+XMLPUBFUN htmlDocPtr
                        htmlSAXParseFile(const char *filename,
                                         const char *encoding,
                                         htmlSAXHandlerPtr sax,
                                         void *userData);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                        htmlParseFile   (const char *filename,
                                         const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        UTF8ToHtml      (unsigned char *out,
                                         int *outlen,
                                         const unsigned char *in,
                                         int *inlen);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlEncodeEntities(unsigned char *out,
                                         int *outlen,
                                         const unsigned char *in,
                                         int *inlen, int quoteChar);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlIsScriptAttribute(const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlHandleOmittedElem(int val);
 
 #ifdef LIBXML_PUSH_ENABLED
 /**
  * Interfaces for the Push mode.
  */
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr
                        htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
                                                 void *user_data,
                                                 const char *chunk,
                                                 int size,
                                                 const char *filename,
                                                 xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        htmlParseChunk          (htmlParserCtxtPtr ctxt,
                                                 const char *chunk,
                                                 int size,
                                                 int terminate);
 #endif /* LIBXML_PUSH_ENABLED */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        htmlFreeParserCtxt      (htmlParserCtxtPtr ctxt);
 
 /*
@@ -188,63 +219,63 @@ typedef enum {
     HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
 } htmlParserOption;
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlCtxtReset           (htmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlCtxtUseOptions      (htmlParserCtxtPtr ctxt,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlReadDoc             (const xmlChar *cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlReadFile            (const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlReadMemory          (const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlReadFd              (int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlReadIO              (xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
                                         void *ioctx,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlCtxtReadDoc         (xmlParserCtxtPtr ctxt,
                                         const xmlChar *cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlCtxtReadFile                (xmlParserCtxtPtr ctxt,
                                         const char *filename,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlCtxtReadMemory              (xmlParserCtxtPtr ctxt,
                                         const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlCtxtReadFd          (xmlParserCtxtPtr ctxt,
                                         int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlCtxtReadIO          (xmlParserCtxtPtr ctxt,
                                         xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
@@ -266,10 +297,10 @@ typedef enum {
 /* Using htmlElemDesc rather than name here, to emphasise the fact
    that otherwise there's a lookup overhead
 */
-XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;
-XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;
-XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;
-XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ;
+XMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;
+XMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;
+XMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;
+XMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;
 /**
  * htmlDefaultSubelement:
  * @elt: HTML element
@@ -302,5 +333,11 @@ XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ;
 }
 #endif
 
+#else /* LIBXML_HTML_ENABLED */
+
+/** DOC_DISABLE */
+#define XML_GLOBALS_HTML
+/** DOC_ENABLE */
+
 #endif /* LIBXML_HTML_ENABLED */
 #endif /* __HTML_PARSER_H__ */
index c0e1103..8e1ba90 100644 (file)
@@ -59,73 +59,73 @@ extern "C" {
  */
 #define HTML_PI_NODE           XML_PI_NODE
 
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlNewDoc              (const xmlChar *URI,
                                         const xmlChar *ExternalID);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr
                htmlNewDocNoDtD         (const xmlChar *URI,
                                         const xmlChar *ExternalID);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                htmlGetMetaEncoding     (htmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlSetMetaEncoding     (htmlDocPtr doc,
                                         const xmlChar *encoding);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlDocDumpMemory       (xmlDocPtr cur,
                                         xmlChar **mem,
                                         int *size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlDocDumpMemoryFormat (xmlDocPtr cur,
                                         xmlChar **mem,
                                         int *size,
                                         int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlDocDump             (FILE *f,
                                         xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlSaveFile            (const char *filename,
                                         xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlNodeDump            (xmlBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlNodeDumpFile        (FILE *out,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlNodeDumpFileFormat  (FILE *out,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
                                         const char *encoding,
                                         int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlSaveFileEnc         (const char *filename,
                                         xmlDocPtr cur,
                                         const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlSaveFileFormat      (const char *filename,
                                         xmlDocPtr cur,
                                         const char *encoding,
                                         int format);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
                                         const char *encoding,
                                         int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
                                         xmlDocPtr cur,
                                         const char *encoding);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,
                                         xmlDocPtr cur,
                                         const char *encoding,
                                         int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlNodeDumpOutput      (xmlOutputBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
@@ -133,7 +133,7 @@ XMLPUBFUN void XMLCALL
 
 #endif /* LIBXML_OUTPUT_ENABLED */
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                htmlIsBooleanAttr       (const xmlChar *name);
 
 
index fa50568..eea1057 100644 (file)
@@ -12,8 +12,6 @@
 #ifndef __XML_SAX_H__
 #define __XML_SAX_H__
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <libxml/xmlversion.h>
 #include <libxml/parser.h>
 
 extern "C" {
 #endif
 XML_DEPRECATED
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                getPublicId                     (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                getSystemId                     (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                setDocumentLocator              (void *ctx,
                                                 xmlSAXLocatorPtr loc);
 
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                getLineNumber                   (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                getColumnNumber                 (void *ctx);
 
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                isStandalone                    (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                hasInternalSubset               (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                hasExternalSubset               (void *ctx);
 
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                internalSubset                  (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                externalSubset                  (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID);
 XML_DEPRECATED
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                getEntity                       (void *ctx,
                                                 const xmlChar *name);
 XML_DEPRECATED
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                getParameterEntity              (void *ctx,
                                                 const xmlChar *name);
 XML_DEPRECATED
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                resolveEntity                   (void *ctx,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId);
 
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                entityDecl                      (void *ctx,
                                                 const xmlChar *name,
                                                 int type,
@@ -85,7 +83,7 @@ XMLPUBFUN void XMLCALL
                                                 const xmlChar *systemId,
                                                 xmlChar *content);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                attributeDecl                   (void *ctx,
                                                 const xmlChar *elem,
                                                 const xmlChar *fullname,
@@ -94,19 +92,19 @@ XMLPUBFUN void XMLCALL
                                                 const xmlChar *defaultValue,
                                                 xmlEnumerationPtr tree);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                elementDecl                     (void *ctx,
                                                 const xmlChar *name,
                                                 int type,
                                                 xmlElementContentPtr content);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                notationDecl                    (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                unparsedEntityDecl              (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *publicId,
@@ -114,83 +112,83 @@ XMLPUBFUN void XMLCALL
                                                 const xmlChar *notationName);
 
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                startDocument                   (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                endDocument                     (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                attribute                       (void *ctx,
                                                 const xmlChar *fullname,
                                                 const xmlChar *value);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                startElement                    (void *ctx,
                                                 const xmlChar *fullname,
                                                 const xmlChar **atts);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                endElement                      (void *ctx,
                                                 const xmlChar *name);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                reference                       (void *ctx,
                                                 const xmlChar *name);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                characters                      (void *ctx,
                                                 const xmlChar *ch,
                                                 int len);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                ignorableWhitespace             (void *ctx,
                                                 const xmlChar *ch,
                                                 int len);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                processingInstruction           (void *ctx,
                                                 const xmlChar *target,
                                                 const xmlChar *data);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                globalNamespace                 (void *ctx,
                                                 const xmlChar *href,
                                                 const xmlChar *prefix);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                setNamespace                    (void *ctx,
                                                 const xmlChar *name);
 XML_DEPRECATED
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                getNamespace                    (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                checkNamespace                  (void *ctx,
                                                 xmlChar *nameSpace);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                namespaceDecl                   (void *ctx,
                                                 const xmlChar *href,
                                                 const xmlChar *prefix);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                comment                         (void *ctx,
                                                 const xmlChar *value);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                cdataBlock                      (void *ctx,
                                                 const xmlChar *value,
                                                 int len);
 
 #ifdef LIBXML_SAX1_ENABLED
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                initxmlDefaultSAXHandler        (xmlSAXHandlerV1 *hdlr,
                                                 int warning);
 #ifdef LIBXML_HTML_ENABLED
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                inithtmlDefaultSAXHandler       (xmlSAXHandlerV1 *hdlr);
 #endif
 #endif /* LIBXML_SAX1_ENABLED */
index 8e9b0b9..4c4ecce 100644 (file)
 #ifndef __XML_SAX2_H__
 #define __XML_SAX2_H__
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <libxml/xmlversion.h>
 #include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlSAX2GetPublicId              (void *ctx);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlSAX2GetSystemId              (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2SetDocumentLocator       (void *ctx,
                                                 xmlSAXLocatorPtr loc);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAX2GetLineNumber            (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAX2GetColumnNumber          (void *ctx);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAX2IsStandalone             (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAX2HasInternalSubset        (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAX2HasExternalSubset        (void *ctx);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2InternalSubset           (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2ExternalSubset           (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                xmlSAX2GetEntity                (void *ctx,
                                                 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                xmlSAX2GetParameterEntity       (void *ctx,
                                                 const xmlChar *name);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                xmlSAX2ResolveEntity            (void *ctx,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2EntityDecl               (void *ctx,
                                                 const xmlChar *name,
                                                 int type,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId,
                                                 xmlChar *content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2AttributeDecl            (void *ctx,
                                                 const xmlChar *elem,
                                                 const xmlChar *fullname,
@@ -76,38 +74,38 @@ XMLPUBFUN void XMLCALL
                                                 int def,
                                                 const xmlChar *defaultValue,
                                                 xmlEnumerationPtr tree);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2ElementDecl              (void *ctx,
                                                 const xmlChar *name,
                                                 int type,
                                                 xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2NotationDecl             (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2UnparsedEntityDecl       (void *ctx,
                                                 const xmlChar *name,
                                                 const xmlChar *publicId,
                                                 const xmlChar *systemId,
                                                 const xmlChar *notationName);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2StartDocument            (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2EndDocument              (void *ctx);
 #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
     defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2StartElement             (void *ctx,
                                                 const xmlChar *fullname,
                                                 const xmlChar **atts);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2EndElement               (void *ctx,
                                                 const xmlChar *name);
 #endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2StartElementNs           (void *ctx,
                                                 const xmlChar *localname,
                                                 const xmlChar *prefix,
@@ -117,54 +115,55 @@ XMLPUBFUN void XMLCALL
                                                 int nb_attributes,
                                                 int nb_defaulted,
                                                 const xmlChar **attributes);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2EndElementNs             (void *ctx,
                                                 const xmlChar *localname,
                                                 const xmlChar *prefix,
                                                 const xmlChar *URI);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2Reference                (void *ctx,
                                                 const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2Characters               (void *ctx,
                                                 const xmlChar *ch,
                                                 int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2IgnorableWhitespace      (void *ctx,
                                                 const xmlChar *ch,
                                                 int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2ProcessingInstruction    (void *ctx,
                                                 const xmlChar *target,
                                                 const xmlChar *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2Comment                  (void *ctx,
                                                 const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2CDataBlock               (void *ctx,
                                                 const xmlChar *value,
                                                 int len);
 
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlSAXDefaultVersion            (int version);
 #endif /* LIBXML_SAX1_ENABLED */
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSAXVersion                   (xmlSAXHandler *hdlr,
                                                 int version);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2InitDefaultSAXHandler    (xmlSAXHandler *hdlr,
                                                 int warning);
 #ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                htmlDefaultSAXHandlerInit       (void);
 #endif
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDefaultSAXHandlerInit        (void);
 #ifdef __cplusplus
 }
index af93de6..f9bdf9b 100644 (file)
@@ -20,7 +20,6 @@
 #include <libxml/xmlversion.h>
 
 #ifdef LIBXML_C14N_ENABLED
-#ifdef LIBXML_OUTPUT_ENABLED
 
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
@@ -66,7 +65,7 @@ typedef enum {
     XML_C14N_1_1            = 2     /* C14N 1.1 spec */
 } xmlC14NMode;
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlC14NDocSaveTo        (xmlDocPtr doc,
                                         xmlNodeSetPtr nodes,
                                         int mode, /* a xmlC14NMode */
@@ -74,7 +73,7 @@ XMLPUBFUN int XMLCALL
                                         int with_comments,
                                         xmlOutputBufferPtr buf);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlC14NDocDumpMemory    (xmlDocPtr doc,
                                         xmlNodeSetPtr nodes,
                                         int mode, /* a xmlC14NMode */
@@ -82,7 +81,7 @@ XMLPUBFUN int XMLCALL
                                         int with_comments,
                                         xmlChar **doc_txt_ptr);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlC14NDocSave          (xmlDocPtr doc,
                                         xmlNodeSetPtr nodes,
                                         int mode, /* a xmlC14NMode */
@@ -109,7 +108,7 @@ typedef int (*xmlC14NIsVisibleCallback)     (void* user_data,
                                         xmlNodePtr node,
                                         xmlNodePtr parent);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlC14NExecute          (xmlDocPtr doc,
                                         xmlC14NIsVisibleCallback is_visible_callback,
                                         void* user_data,
@@ -122,7 +121,6 @@ XMLPUBFUN int XMLCALL
 }
 #endif /* __cplusplus */
 
-#endif /* LIBXML_OUTPUT_ENABLED */
 #endif /* LIBXML_C14N_ENABLED */
 #endif /* __XML_C14N_H__ */
 
index 26b178d..02fa7ab 100644 (file)
@@ -66,113 +66,113 @@ typedef xmlCatalog *xmlCatalogPtr;
 /*
  * Operations on a given catalog.
  */
-XMLPUBFUN xmlCatalogPtr XMLCALL
+XMLPUBFUN xmlCatalogPtr
                xmlNewCatalog           (int sgml);
-XMLPUBFUN xmlCatalogPtr XMLCALL
+XMLPUBFUN xmlCatalogPtr
                xmlLoadACatalog         (const char *filename);
-XMLPUBFUN xmlCatalogPtr XMLCALL
+XMLPUBFUN xmlCatalogPtr
                xmlLoadSGMLSuperCatalog (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlConvertSGMLCatalog   (xmlCatalogPtr catal);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlACatalogAdd          (xmlCatalogPtr catal,
                                         const xmlChar *type,
                                         const xmlChar *orig,
                                         const xmlChar *replace);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlACatalogRemove       (xmlCatalogPtr catal,
                                         const xmlChar *value);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlACatalogResolve      (xmlCatalogPtr catal,
                                         const xmlChar *pubID,
                                         const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlACatalogResolveSystem(xmlCatalogPtr catal,
                                         const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlACatalogResolvePublic(xmlCatalogPtr catal,
                                         const xmlChar *pubID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlACatalogResolveURI   (xmlCatalogPtr catal,
                                         const xmlChar *URI);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlACatalogDump         (xmlCatalogPtr catal,
                                         FILE *out);
 #endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeCatalog          (xmlCatalogPtr catal);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCatalogIsEmpty       (xmlCatalogPtr catal);
 
 /*
  * Global operations.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlInitializeCatalog    (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlLoadCatalog          (const char *filename);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlLoadCatalogs         (const char *paths);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCatalogCleanup       (void);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCatalogDump          (FILE *out);
 #endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogResolve       (const xmlChar *pubID,
                                         const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogResolveSystem (const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogResolvePublic (const xmlChar *pubID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogResolveURI    (const xmlChar *URI);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCatalogAdd           (const xmlChar *type,
                                         const xmlChar *orig,
                                         const xmlChar *replace);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCatalogRemove        (const xmlChar *value);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlParseCatalogFile     (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCatalogConvert       (void);
 
 /*
  * Strictly minimal interfaces for per-document catalogs used
  * by the parser.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCatalogFreeLocal     (void *catalogs);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
                xmlCatalogAddLocal      (void *catalogs,
                                         const xmlChar *URL);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogLocalResolve  (void *catalogs,
                                         const xmlChar *pubID,
                                         const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlCatalogLocalResolveURI(void *catalogs,
                                         const xmlChar *URI);
 /*
  * Preference settings.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCatalogSetDebug      (int level);
-XMLPUBFUN xmlCatalogPrefer XMLCALL
+XMLPUBFUN xmlCatalogPrefer
                xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCatalogSetDefaults   (xmlCatalogAllow allow);
-XMLPUBFUN xmlCatalogAllow XMLCALL
+XMLPUBFUN xmlCatalogAllow
                xmlCatalogGetDefaults   (void);
 
 
 /* DEPRECATED interfaces */
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlCatalogGetSystem     (const xmlChar *sysID);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlCatalogGetPublic     (const xmlChar *pubID);
 
 #ifdef __cplusplus
index fb43016..8225c95 100644 (file)
@@ -51,7 +51,7 @@ struct _xmlChRangeGroup {
 /**
  * Range checking routine
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
 
 
@@ -207,21 +207,21 @@ XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
 #define xmlIsPubidCharQ(c)     (((c) < 0x100) ? \
                                 xmlIsPubidChar_ch((c)) : 0)
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsBaseChar(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsBlank(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsChar(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsCombining(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsDigit(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsExtender(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsIdeographic(unsigned int ch);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsPubidChar(unsigned int ch);
 
 #ifdef __cplusplus
index 5b3be13..8274687 100644 (file)
@@ -25,39 +25,39 @@ extern "C" {
 /*
  * The standard Dump routines.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpString      (FILE *output,
                                 const xmlChar *str);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpAttr        (FILE *output,
                                 xmlAttrPtr attr,
                                 int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpAttrList    (FILE *output,
                                 xmlAttrPtr attr,
                                 int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpOneNode     (FILE *output,
                                 xmlNodePtr node,
                                 int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpNode        (FILE *output,
                                 xmlNodePtr node,
                                 int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpNodeList    (FILE *output,
                                 xmlNodePtr node,
                                 int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpDocumentHead(FILE *output,
                                 xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpDocument    (FILE *output,
                                 xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpDTD         (FILE *output,
                                 xmlDtdPtr dtd);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlDebugDumpEntities    (FILE *output,
                                 xmlDocPtr doc);
 
@@ -67,7 +67,7 @@ XMLPUBFUN void XMLCALL
  *                                                             *
  ****************************************************************/
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlDebugCheckDocument   (FILE * output,
                                 xmlDocPtr doc);
 
@@ -77,12 +77,12 @@ XMLPUBFUN int XMLCALL
  *                                                             *
  ****************************************************************/
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlLsOneNode            (FILE *output, xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlLsCountNode          (xmlNodePtr node);
 
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlBoolToText           (int boolval);
 
 /****************************************************************
@@ -136,63 +136,63 @@ typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
                             xmlNodePtr node,
                             xmlNodePtr node2);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlShellPrintXPathError (int errorType,
                                 const char *arg);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlShellPrintXPathResult(xmlXPathObjectPtr list);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellList            (xmlShellCtxtPtr ctxt,
                                 char *arg,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellBase            (xmlShellCtxtPtr ctxt,
                                 char *arg,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellDir             (xmlShellCtxtPtr ctxt,
                                 char *arg,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellLoad            (xmlShellCtxtPtr ctxt,
                                 char *filename,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlShellPrintNode       (xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellCat             (xmlShellCtxtPtr ctxt,
                                 char *arg,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellWrite           (xmlShellCtxtPtr ctxt,
                                 char *filename,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellSave            (xmlShellCtxtPtr ctxt,
                                 char *filename,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
 #endif /* LIBXML_OUTPUT_ENABLED */
 #ifdef LIBXML_VALID_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellValidate        (xmlShellCtxtPtr ctxt,
                                 char *dtd,
                                 xmlNodePtr node,
                                 xmlNodePtr node2);
 #endif /* LIBXML_VALID_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellDu              (xmlShellCtxtPtr ctxt,
                                 char *arg,
                                 xmlNodePtr tree,
                                 xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlShellPwd             (xmlShellCtxtPtr ctxt,
                                 char *buffer,
                                 xmlNodePtr node,
@@ -201,7 +201,7 @@ XMLPUBFUN int XMLCALL
 /*
  * The Shell interface.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlShell                (xmlDocPtr doc,
                                 char *filename,
                                 xmlShellReadlineFunc input,
index 91f74d1..22aa3d9 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <stddef.h>
 #include <libxml/xmlversion.h>
+#include <libxml/xmlstring.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -28,51 +29,51 @@ typedef xmlDict *xmlDictPtr;
  * Initializer
  */
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL  xmlInitializeDict(void);
+XMLPUBFUN int  xmlInitializeDict(void);
 
 /*
  * Constructor and destructor.
  */
-XMLPUBFUN xmlDictPtr XMLCALL
+XMLPUBFUN xmlDictPtr
                        xmlDictCreate   (void);
-XMLPUBFUN size_t XMLCALL
+XMLPUBFUN size_t
                        xmlDictSetLimit (xmlDictPtr dict,
                                          size_t limit);
-XMLPUBFUN size_t XMLCALL
+XMLPUBFUN size_t
                        xmlDictGetUsage (xmlDictPtr dict);
-XMLPUBFUN xmlDictPtr XMLCALL
+XMLPUBFUN xmlDictPtr
                        xmlDictCreateSub(xmlDictPtr sub);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlDictReference(xmlDictPtr dict);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlDictFree     (xmlDictPtr dict);
 
 /*
  * Lookup of entry in the dictionary.
  */
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                        xmlDictLookup   (xmlDictPtr dict,
                                         const xmlChar *name,
                                         int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                        xmlDictExists   (xmlDictPtr dict,
                                         const xmlChar *name,
                                         int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                        xmlDictQLookup  (xmlDictPtr dict,
                                         const xmlChar *prefix,
                                         const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlDictOwns     (xmlDictPtr dict,
                                         const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlDictSize     (xmlDictPtr dict);
 
 /*
  * Cleanup function
  */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                         xmlDictCleanup  (void);
 
 #ifdef __cplusplus
index 381e188..8594cff 100644 (file)
 extern "C" {
 #endif
 
+typedef enum {
+    XML_ENC_ERR_SUCCESS     =  0,
+    XML_ENC_ERR_SPACE       = -1,
+    XML_ENC_ERR_INPUT       = -2,
+    XML_ENC_ERR_PARTIAL     = -3,
+    XML_ENC_ERR_INTERNAL    = -4,
+    XML_ENC_ERR_MEMORY      = -5
+} xmlCharEncError;
+
 /*
  * xmlCharEncoding:
  *
@@ -142,30 +151,22 @@ struct _xmlCharEncodingHandler {
 #endif /* LIBXML_ICU_ENABLED */
 };
 
-#ifdef __cplusplus
-}
-#endif
-#include <libxml/tree.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*
  * Interfaces for encoding handlers.
  */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlInitCharEncodingHandlers     (void);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlCleanupCharEncodingHandlers  (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlRegisterCharEncodingHandler  (xmlCharEncodingHandlerPtr handler);
-XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+XMLPUBFUN xmlCharEncodingHandlerPtr
        xmlGetCharEncodingHandler       (xmlCharEncoding enc);
-XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+XMLPUBFUN xmlCharEncodingHandlerPtr
        xmlFindCharEncodingHandler      (const char *name);
-XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+XMLPUBFUN xmlCharEncodingHandlerPtr
        xmlNewCharEncodingHandler       (const char *name,
                                         xmlCharEncodingInputFunc input,
                                         xmlCharEncodingOutputFunc output);
@@ -173,54 +174,56 @@ XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
 /*
  * Interfaces for encoding names and aliases.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlAddEncodingAlias             (const char *name,
                                         const char *alias);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlDelEncodingAlias             (const char *alias);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlGetEncodingAlias             (const char *alias);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlCleanupEncodingAliases       (void);
-XMLPUBFUN xmlCharEncoding XMLCALL
+XMLPUBFUN xmlCharEncoding
        xmlParseCharEncoding            (const char *name);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlGetCharEncodingName          (xmlCharEncoding enc);
 
 /*
  * Interfaces directly used by the parsers.
  */
-XMLPUBFUN xmlCharEncoding XMLCALL
+XMLPUBFUN xmlCharEncoding
        xmlDetectCharEncoding           (const unsigned char *in,
                                         int len);
 
-XMLPUBFUN int XMLCALL
+struct _xmlBuffer;
+XMLPUBFUN int
        xmlCharEncOutFunc               (xmlCharEncodingHandler *handler,
-                                        xmlBufferPtr out,
-                                        xmlBufferPtr in);
+                                        struct _xmlBuffer *out,
+                                        struct _xmlBuffer *in);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlCharEncInFunc                (xmlCharEncodingHandler *handler,
-                                        xmlBufferPtr out,
-                                        xmlBufferPtr in);
-XMLPUBFUN int XMLCALL
+                                        struct _xmlBuffer *out,
+                                        struct _xmlBuffer *in);
+XML_DEPRECATED
+XMLPUBFUN int
        xmlCharEncFirstLine             (xmlCharEncodingHandler *handler,
-                                        xmlBufferPtr out,
-                                        xmlBufferPtr in);
-XMLPUBFUN int XMLCALL
+                                        struct _xmlBuffer *out,
+                                        struct _xmlBuffer *in);
+XMLPUBFUN int
        xmlCharEncCloseFunc             (xmlCharEncodingHandler *handler);
 
 /*
  * Export a few useful functions
  */
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        UTF8Toisolat1                   (unsigned char *out,
                                         int *outlen,
                                         const unsigned char *in,
                                         int *inlen);
 #endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        isolat1ToUTF8                   (unsigned char *out,
                                         int *outlen,
                                         const unsigned char *in,
index 2b60d9e..f679375 100644 (file)
@@ -12,7 +12,9 @@
 #define __XML_ENTITIES_H__
 
 #include <libxml/xmlversion.h>
+#define XML_TREE_INTERNALS
 #include <libxml/tree.h>
+#undef XML_TREE_INTERNALS
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,10 +58,8 @@ struct _xmlEntity {
     struct _xmlEntity     *nexte;      /* unused */
     const xmlChar           *URI;      /* the full URI as computed */
     int                    owner;      /* does the entity own the childrens */
-    int                         checked;       /* was the entity content checked */
-                                       /* this is also used to count entities
-                                        * references done from that entity
-                                        * and if it contains '<' */
+    int                    flags;       /* various flags */
+    unsigned long   expandedSize;       /* expanded size */
 };
 
 /*
@@ -76,72 +76,74 @@ typedef xmlEntitiesTable *xmlEntitiesTablePtr;
 
 #ifdef LIBXML_LEGACY_ENABLED
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlInitializePredefinedEntities (void);
 #endif /* LIBXML_LEGACY_ENABLED */
 
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlNewEntity            (xmlDocPtr doc,
                                                 const xmlChar *name,
                                                 int type,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID,
                                                 const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN void
+                       xmlFreeEntity           (xmlEntityPtr entity);
+XMLPUBFUN xmlEntityPtr
                        xmlAddDocEntity         (xmlDocPtr doc,
                                                 const xmlChar *name,
                                                 int type,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID,
                                                 const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlAddDtdEntity         (xmlDocPtr doc,
                                                 const xmlChar *name,
                                                 int type,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID,
                                                 const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlGetPredefinedEntity  (const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlGetDocEntity         (const xmlDoc *doc,
                                                 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlGetDtdEntity         (xmlDocPtr doc,
                                                 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr
                        xmlGetParameterEntity   (xmlDocPtr doc,
                                                 const xmlChar *name);
 #ifdef LIBXML_LEGACY_ENABLED
 XML_DEPRECATED
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                        xmlEncodeEntities       (xmlDocPtr doc,
                                                 const xmlChar *input);
 #endif /* LIBXML_LEGACY_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlEncodeEntitiesReentrant(xmlDocPtr doc,
                                                 const xmlChar *input);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlEncodeSpecialChars   (const xmlDoc *doc,
                                                 const xmlChar *input);
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+XMLPUBFUN xmlEntitiesTablePtr
                        xmlCreateEntitiesTable  (void);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+XMLPUBFUN xmlEntitiesTablePtr
                        xmlCopyEntitiesTable    (xmlEntitiesTablePtr table);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeEntitiesTable    (xmlEntitiesTablePtr table);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlDumpEntitiesTable    (xmlBufferPtr buf,
                                                 xmlEntitiesTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlDumpEntityDecl       (xmlBufferPtr buf,
                                                 xmlEntityPtr ent);
 #endif /* LIBXML_OUTPUT_ENABLED */
 #ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlCleanupPredefinedEntities(void);
 #endif /* LIBXML_LEGACY_ENABLED */
 
index d57ccb0..92f4131 100644 (file)
 /*
  * Summary: interface for all global variables of the library
- * Description: all the global variables and thread handling for
- *              those variables is handled by this module.
- *
- * The bottom of this file is automatically generated by build_glob.py
- * based on the description file global.data
+ * Description: Deprecated, don't use
  *
  * Copy: See Copyright for the status of this software.
- *
- * Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard
  */
 
 #ifndef __XML_GLOBALS_H
 #define __XML_GLOBALS_H
 
 #include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-#include <libxml/xmlerror.h>
-#include <libxml/SAX2.h>
-#include <libxml/xmlmemory.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-XML_DEPRECATED
-XMLPUBFUN void XMLCALL xmlInitGlobals(void);
-XML_DEPRECATED
-XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
-
-/**
- * xmlParserInputBufferCreateFilenameFunc:
- * @URI: the URI to read from
- * @enc: the requested source encoding
- *
- * Signature for the function doing the lookup for a suitable input method
- * corresponding to an URI.
- *
- * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
- *         method was found.
- */
-typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
-                                                                          xmlCharEncoding enc);
-
-
-/**
- * xmlOutputBufferCreateFilenameFunc:
- * @URI: the URI to write to
- * @enc: the requested target encoding
- *
- * Signature for the function doing the lookup for a suitable output method
- * corresponding to an URI.
- *
- * Returns the new xmlOutputBufferPtr in case of success or NULL if no
- *         method was found.
- */
-typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
-                                                                xmlCharEncodingHandlerPtr encoder,
-                                                                int compression);
-
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
-XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
-XMLPUBFUN xmlOutputBufferCreateFilenameFunc
-XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);
 
 /*
- * Externally global symbols which need to be protected for backwards
- * compatibility support.
- */
-
-#undef htmlDefaultSAXHandler
-#undef oldXMLWDcompatibility
-#undef xmlBufferAllocScheme
-#undef xmlDefaultBufferSize
-#undef xmlDefaultSAXHandler
-#undef xmlDefaultSAXLocator
-#undef xmlDoValidityCheckingDefaultValue
-#undef xmlFree
-#undef xmlGenericError
-#undef xmlStructuredError
-#undef xmlGenericErrorContext
-#undef xmlStructuredErrorContext
-#undef xmlGetWarningsDefaultValue
-#undef xmlIndentTreeOutput
-#undef  xmlTreeIndentString
-#undef xmlKeepBlanksDefaultValue
-#undef xmlLineNumbersDefaultValue
-#undef xmlLoadExtDtdDefaultValue
-#undef xmlMalloc
-#undef xmlMallocAtomic
-#undef xmlMemStrdup
-#undef xmlParserDebugEntities
-#undef xmlParserVersion
-#undef xmlPedanticParserDefaultValue
-#undef xmlRealloc
-#undef xmlSaveNoEmptyTags
-#undef xmlSubstituteEntitiesDefaultValue
-#undef  xmlRegisterNodeDefaultValue
-#undef  xmlDeregisterNodeDefaultValue
-#undef  xmlLastError
-#undef  xmlParserInputBufferCreateFilenameValue
-#undef  xmlOutputBufferCreateFilenameValue
-
-/**
- * xmlRegisterNodeFunc:
- * @node: the current node
- *
- * Signature for the registration callback of a created node
- */
-typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
-/**
- * xmlDeregisterNodeFunc:
- * @node: the current node
+ * This file was required to access global variables until version v2.12.0.
  *
- * Signature for the deregistration callback of a discarded node
+ * These includes are for backward compatibility.
  */
-typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
-
-typedef struct _xmlGlobalState xmlGlobalState;
-typedef xmlGlobalState *xmlGlobalStatePtr;
-struct _xmlGlobalState
-{
-       const char *xmlParserVersion;
-
-       xmlSAXLocator xmlDefaultSAXLocator;
-       xmlSAXHandlerV1 xmlDefaultSAXHandler;
-       xmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */
-       xmlSAXHandlerV1 htmlDefaultSAXHandler;
-
-       xmlFreeFunc xmlFree;
-       xmlMallocFunc xmlMalloc;
-       xmlStrdupFunc xmlMemStrdup;
-       xmlReallocFunc xmlRealloc;
-
-       xmlGenericErrorFunc xmlGenericError;
-       xmlStructuredErrorFunc xmlStructuredError;
-       void *xmlGenericErrorContext;
-
-       int oldXMLWDcompatibility;
-
-       xmlBufferAllocationScheme xmlBufferAllocScheme;
-       int xmlDefaultBufferSize;
-
-       int xmlSubstituteEntitiesDefaultValue;
-       int xmlDoValidityCheckingDefaultValue;
-       int xmlGetWarningsDefaultValue;
-       int xmlKeepBlanksDefaultValue;
-       int xmlLineNumbersDefaultValue;
-       int xmlLoadExtDtdDefaultValue;
-       int xmlParserDebugEntities;
-       int xmlPedanticParserDefaultValue;
-
-       int xmlSaveNoEmptyTags;
-       int xmlIndentTreeOutput;
-       const char *xmlTreeIndentString;
-
-       xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
-       xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
-
-       xmlMallocFunc xmlMallocAtomic;
-       xmlError xmlLastError;
-
-       xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
-       xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
-
-       void *xmlStructuredErrorContext;
-};
-
-#ifdef __cplusplus
-}
-#endif
+#include <libxml/HTMLparser.h>
+#include <libxml/parser.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xmlIO.h>
+#include <libxml/xmlsave.h>
 #include <libxml/threads.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs);
-
-XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
-
-XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
-
-XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
-XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
-XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
-XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
-
-XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
-       xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
-       xmlThrDefParserInputBufferCreateFilenameDefault(
-                               xmlParserInputBufferCreateFilenameFunc func);
-
-/** DOC_DISABLE */
-/*
- * In general the memory allocation entry points are not kept
- * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
- *    - xmlMalloc
- *    - xmlMallocAtomic
- *    - xmlRealloc
- *    - xmlMemStrdup
- *    - xmlFree
- */
-
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-#ifdef LIBXML_THREAD_ENABLED
-XMLPUBFUN  xmlMallocFunc * XMLCALL __xmlMalloc(void);
-#define xmlMalloc \
-(*(__xmlMalloc()))
-#else
-XMLPUBVAR xmlMallocFunc xmlMalloc;
-#endif
-
-#ifdef LIBXML_THREAD_ENABLED
-XMLPUBFUN  xmlMallocFunc * XMLCALL __xmlMallocAtomic(void);
-#define xmlMallocAtomic \
-(*(__xmlMallocAtomic()))
-#else
-XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
-#endif
-
-#ifdef LIBXML_THREAD_ENABLED
-XMLPUBFUN  xmlReallocFunc * XMLCALL __xmlRealloc(void);
-#define xmlRealloc \
-(*(__xmlRealloc()))
-#else
-XMLPUBVAR xmlReallocFunc xmlRealloc;
-#endif
-
-#ifdef LIBXML_THREAD_ENABLED
-XMLPUBFUN  xmlFreeFunc * XMLCALL __xmlFree(void);
-#define xmlFree \
-(*(__xmlFree()))
-#else
-XMLPUBVAR xmlFreeFunc xmlFree;
-#endif
-
-#ifdef LIBXML_THREAD_ENABLED
-XMLPUBFUN  xmlStrdupFunc * XMLCALL __xmlMemStrdup(void);
-#define xmlMemStrdup \
-(*(__xmlMemStrdup()))
-#else
-XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
-#endif
-
-#else /* !LIBXML_THREAD_ALLOC_ENABLED */
-XMLPUBVAR xmlMallocFunc xmlMalloc;
-XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
-XMLPUBVAR xmlReallocFunc xmlRealloc;
-XMLPUBVAR xmlFreeFunc xmlFree;
-XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
-#endif /* LIBXML_THREAD_ALLOC_ENABLED */
-
-#ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define htmlDefaultSAXHandler \
-(*(__htmlDefaultSAXHandler()))
-#else
-XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
-#endif
-#endif
-
-XMLPUBFUN xmlError * XMLCALL __xmlLastError(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlLastError \
-(*(__xmlLastError()))
-#else
-XMLPUBVAR xmlError xmlLastError;
-#endif
-
-/*
- * Everything starting from the line below is
- * Automatically generated by build_glob.py.
- * Do not modify the previous line.
- */
-
-
-XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define oldXMLWDcompatibility \
-(*(__oldXMLWDcompatibility()))
-#else
-XMLPUBVAR int oldXMLWDcompatibility;
-#endif
-
-XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlBufferAllocScheme \
-(*(__xmlBufferAllocScheme()))
-#else
-XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
-#endif
-XMLPUBFUN xmlBufferAllocationScheme XMLCALL
-       xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
-
-XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlDefaultBufferSize \
-(*(__xmlDefaultBufferSize()))
-#else
-XMLPUBVAR int xmlDefaultBufferSize;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v);
-
-XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlDefaultSAXHandler \
-(*(__xmlDefaultSAXHandler()))
-#else
-XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
-#endif
-
-XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlDefaultSAXLocator \
-(*(__xmlDefaultSAXLocator()))
-#else
-XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;
-#endif
-
-XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlDoValidityCheckingDefaultValue \
-(*(__xmlDoValidityCheckingDefaultValue()))
-#else
-XMLPUBVAR int xmlDoValidityCheckingDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v);
-
-XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlGenericError \
-(*(__xmlGenericError()))
-#else
-XMLPUBVAR xmlGenericErrorFunc xmlGenericError;
-#endif
-
-XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlStructuredError \
-(*(__xmlStructuredError()))
-#else
-XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;
-#endif
-
-XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlGenericErrorContext \
-(*(__xmlGenericErrorContext()))
-#else
-XMLPUBVAR void * xmlGenericErrorContext;
-#endif
-
-XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlStructuredErrorContext \
-(*(__xmlStructuredErrorContext()))
-#else
-XMLPUBVAR void * xmlStructuredErrorContext;
-#endif
-
-XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlGetWarningsDefaultValue \
-(*(__xmlGetWarningsDefaultValue()))
-#else
-XMLPUBVAR int xmlGetWarningsDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v);
-
-XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlIndentTreeOutput \
-(*(__xmlIndentTreeOutput()))
-#else
-XMLPUBVAR int xmlIndentTreeOutput;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v);
-
-XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlTreeIndentString \
-(*(__xmlTreeIndentString()))
-#else
-XMLPUBVAR const char * xmlTreeIndentString;
-#endif
-XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v);
-
-XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlKeepBlanksDefaultValue \
-(*(__xmlKeepBlanksDefaultValue()))
-#else
-XMLPUBVAR int xmlKeepBlanksDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v);
-
-XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlLineNumbersDefaultValue \
-(*(__xmlLineNumbersDefaultValue()))
-#else
-XMLPUBVAR int xmlLineNumbersDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v);
-
-XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlLoadExtDtdDefaultValue \
-(*(__xmlLoadExtDtdDefaultValue()))
-#else
-XMLPUBVAR int xmlLoadExtDtdDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v);
-
-XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlParserDebugEntities \
-(*(__xmlParserDebugEntities()))
-#else
-XMLPUBVAR int xmlParserDebugEntities;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v);
-
-XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlParserVersion \
-(*(__xmlParserVersion()))
-#else
-XMLPUBVAR const char * xmlParserVersion;
-#endif
-
-XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlPedanticParserDefaultValue \
-(*(__xmlPedanticParserDefaultValue()))
-#else
-XMLPUBVAR int xmlPedanticParserDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v);
-
-XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlSaveNoEmptyTags \
-(*(__xmlSaveNoEmptyTags()))
-#else
-XMLPUBVAR int xmlSaveNoEmptyTags;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v);
-
-XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlSubstituteEntitiesDefaultValue \
-(*(__xmlSubstituteEntitiesDefaultValue()))
-#else
-XMLPUBVAR int xmlSubstituteEntitiesDefaultValue;
-#endif
-XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v);
-
-XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlRegisterNodeDefaultValue \
-(*(__xmlRegisterNodeDefaultValue()))
-#else
-XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
-#endif
-
-XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlDeregisterNodeDefaultValue \
-(*(__xmlDeregisterNodeDefaultValue()))
-#else
-XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
-#endif
-
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \
-                               __xmlParserInputBufferCreateFilenameValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlParserInputBufferCreateFilenameValue \
-(*(__xmlParserInputBufferCreateFilenameValue()))
-#else
-XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
-#endif
+typedef struct _xmlGlobalState xmlGlobalState;
+typedef xmlGlobalState *xmlGlobalStatePtr;
 
-XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
-#ifdef LIBXML_THREAD_ENABLED
-#define xmlOutputBufferCreateFilenameValue \
-(*(__xmlOutputBufferCreateFilenameValue()))
-#else
-XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
-#endif
+XML_DEPRECATED XMLPUBFUN void
+xmlInitializeGlobalState(xmlGlobalStatePtr gs);
+XML_DEPRECATED XMLPUBFUN
+xmlGlobalStatePtr xmlGetGlobalState(void);
 
 #ifdef __cplusplus
 }
index b682b6b..f4af09e 100644 (file)
 #ifndef __XML_HASH_H__
 #define __XML_HASH_H__
 
+#include <libxml/xmlversion.h>
+#include <libxml/dict.h>
+#include <libxml/xmlstring.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -21,18 +25,6 @@ extern "C" {
 typedef struct _xmlHashTable xmlHashTable;
 typedef xmlHashTable *xmlHashTablePtr;
 
-#ifdef __cplusplus
-}
-#endif
-
-#include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-#include <libxml/dict.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*
  * Recent version of gcc produce a warning when a function pointer is assigned
  * to an object pointer, or vice versa.  The following macro is a dirty hack
@@ -55,7 +47,6 @@ extern "C" {
 
 #define XML_CAST_FPTR(fptr) fptr
 
-
 /*
  * function types:
  */
@@ -103,132 +94,137 @@ typedef void (*xmlHashScannerFull)(void *payload, void *data,
 /*
  * Constructor and destructor.
  */
-XMLPUBFUN xmlHashTablePtr XMLCALL
-                       xmlHashCreate   (int size);
-XMLPUBFUN xmlHashTablePtr XMLCALL
-                       xmlHashCreateDict(int size,
+XMLPUBFUN xmlHashTablePtr
+               xmlHashCreate           (int size);
+XMLPUBFUN xmlHashTablePtr
+               xmlHashCreateDict       (int size,
                                         xmlDictPtr dict);
-XMLPUBFUN void XMLCALL
-                       xmlHashFree     (xmlHashTablePtr table,
-                                        xmlHashDeallocator f);
-XMLPUBFUN void XMLCALL
-                       xmlHashDefaultDeallocator(void *entry,
+XMLPUBFUN void
+               xmlHashFree             (xmlHashTablePtr hash,
+                                        xmlHashDeallocator dealloc);
+XMLPUBFUN void
+               xmlHashDefaultDeallocator(void *entry,
                                         const xmlChar *name);
 
 /*
  * Add a new entry to the hash table.
  */
-XMLPUBFUN int XMLCALL
-                       xmlHashAddEntry (xmlHashTablePtr table,
+XMLPUBFUN int
+               xmlHashAddEntry         (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         void *userdata);
-XMLPUBFUN int XMLCALL
-                       xmlHashUpdateEntry(xmlHashTablePtr table,
+XMLPUBFUN int
+               xmlHashUpdateEntry      (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         void *userdata,
-                                        xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
-                       xmlHashAddEntry2(xmlHashTablePtr table,
+                                        xmlHashDeallocator dealloc);
+XMLPUBFUN int
+               xmlHashAddEntry2        (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         void *userdata);
-XMLPUBFUN int XMLCALL
-                       xmlHashUpdateEntry2(xmlHashTablePtr table,
+XMLPUBFUN int
+               xmlHashUpdateEntry2     (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         void *userdata,
-                                        xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
-                       xmlHashAddEntry3(xmlHashTablePtr table,
+                                        xmlHashDeallocator dealloc);
+XMLPUBFUN int
+               xmlHashAddEntry3        (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         const xmlChar *name3,
                                         void *userdata);
-XMLPUBFUN int XMLCALL
-                       xmlHashUpdateEntry3(xmlHashTablePtr table,
+XMLPUBFUN int
+               xmlHashUpdateEntry3     (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         const xmlChar *name3,
                                         void *userdata,
-                                        xmlHashDeallocator f);
+                                        xmlHashDeallocator dealloc);
 
 /*
  * Remove an entry from the hash table.
  */
-XMLPUBFUN int XMLCALL
-                       xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
-                           xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
-                       xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
-                            const xmlChar *name2, xmlHashDeallocator f);
-XMLPUBFUN int  XMLCALL
-                       xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
-                            const xmlChar *name2, const xmlChar *name3,
-                            xmlHashDeallocator f);
+XMLPUBFUN int
+               xmlHashRemoveEntry      (xmlHashTablePtr hash,
+                                        const xmlChar *name,
+                                        xmlHashDeallocator dealloc);
+XMLPUBFUN int
+               xmlHashRemoveEntry2     (xmlHashTablePtr hash,
+                                        const xmlChar *name,
+                                        const xmlChar *name2,
+                                        xmlHashDeallocator dealloc);
+XMLPUBFUN int 
+               xmlHashRemoveEntry3     (xmlHashTablePtr hash,
+                                        const xmlChar *name,
+                                        const xmlChar *name2,
+                                        const xmlChar *name3,
+                                        xmlHashDeallocator dealloc);
 
 /*
- * Retrieve the userdata.
+ * Retrieve the payload.
  */
-XMLPUBFUN void * XMLCALL
-                       xmlHashLookup   (xmlHashTablePtr table,
+XMLPUBFUN void *
+               xmlHashLookup           (xmlHashTablePtr hash,
                                         const xmlChar *name);
-XMLPUBFUN void * XMLCALL
-                       xmlHashLookup2  (xmlHashTablePtr table,
+XMLPUBFUN void *
+               xmlHashLookup2          (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2);
-XMLPUBFUN void * XMLCALL
-                       xmlHashLookup3  (xmlHashTablePtr table,
+XMLPUBFUN void *
+               xmlHashLookup3          (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         const xmlChar *name3);
-XMLPUBFUN void * XMLCALL
-                       xmlHashQLookup  (xmlHashTablePtr table,
-                                        const xmlChar *name,
-                                        const xmlChar *prefix);
-XMLPUBFUN void * XMLCALL
-                       xmlHashQLookup2 (xmlHashTablePtr table,
-                                        const xmlChar *name,
+XMLPUBFUN void *
+               xmlHashQLookup          (xmlHashTablePtr hash,
+                                        const xmlChar *prefix,
+                                        const xmlChar *name);
+XMLPUBFUN void *
+               xmlHashQLookup2         (xmlHashTablePtr hash,
                                         const xmlChar *prefix,
-                                        const xmlChar *name2,
-                                        const xmlChar *prefix2);
-XMLPUBFUN void * XMLCALL
-                       xmlHashQLookup3 (xmlHashTablePtr table,
                                         const xmlChar *name,
+                                        const xmlChar *prefix2,
+                                        const xmlChar *name2);
+XMLPUBFUN void *
+               xmlHashQLookup3         (xmlHashTablePtr hash,
                                         const xmlChar *prefix,
-                                        const xmlChar *name2,
+                                        const xmlChar *name,
                                         const xmlChar *prefix2,
-                                        const xmlChar *name3,
-                                        const xmlChar *prefix3);
+                                        const xmlChar *name2,
+                                        const xmlChar *prefix3,
+                                        const xmlChar *name3);
 
 /*
  * Helpers.
  */
-XMLPUBFUN xmlHashTablePtr XMLCALL
-                       xmlHashCopy     (xmlHashTablePtr table,
-                                        xmlHashCopier f);
-XMLPUBFUN int XMLCALL
-                       xmlHashSize     (xmlHashTablePtr table);
-XMLPUBFUN void XMLCALL
-                       xmlHashScan     (xmlHashTablePtr table,
-                                        xmlHashScanner f,
+XMLPUBFUN xmlHashTablePtr
+               xmlHashCopy             (xmlHashTablePtr hash,
+                                        xmlHashCopier copy);
+XMLPUBFUN int
+               xmlHashSize             (xmlHashTablePtr hash);
+XMLPUBFUN void
+               xmlHashScan             (xmlHashTablePtr hash,
+                                        xmlHashScanner scan,
                                         void *data);
-XMLPUBFUN void XMLCALL
-                       xmlHashScan3    (xmlHashTablePtr table,
+XMLPUBFUN void
+               xmlHashScan3            (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         const xmlChar *name3,
-                                        xmlHashScanner f,
+                                        xmlHashScanner scan,
                                         void *data);
-XMLPUBFUN void XMLCALL
-                       xmlHashScanFull (xmlHashTablePtr table,
-                                        xmlHashScannerFull f,
+XMLPUBFUN void
+               xmlHashScanFull         (xmlHashTablePtr hash,
+                                        xmlHashScannerFull scan,
                                         void *data);
-XMLPUBFUN void XMLCALL
-                       xmlHashScanFull3(xmlHashTablePtr table,
+XMLPUBFUN void
+               xmlHashScanFull3        (xmlHashTablePtr hash,
                                         const xmlChar *name,
                                         const xmlChar *name2,
                                         const xmlChar *name3,
-                                        xmlHashScannerFull f,
+                                        xmlHashScannerFull scan,
                                         void *data);
 #ifdef __cplusplus
 }
index 3211c75..5eab8f5 100644 (file)
@@ -52,79 +52,79 @@ typedef int  (*xmlListDataCompare) (const void *data0, const void *data1);
 typedef int (*xmlListWalker) (const void *data, void *user);
 
 /* Creation/Deletion */
-XMLPUBFUN xmlListPtr XMLCALL
+XMLPUBFUN xmlListPtr
                xmlListCreate           (xmlListDeallocator deallocator,
                                         xmlListDataCompare compare);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListDelete           (xmlListPtr l);
 
 /* Basic Operators */
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
                xmlListSearch           (xmlListPtr l,
                                         void *data);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
                xmlListReverseSearch    (xmlListPtr l,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListInsert           (xmlListPtr l,
                                         void *data) ;
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListAppend           (xmlListPtr l,
                                         void *data) ;
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListRemoveFirst      (xmlListPtr l,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListRemoveLast       (xmlListPtr l,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListRemoveAll        (xmlListPtr l,
                                         void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListClear            (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListEmpty            (xmlListPtr l);
-XMLPUBFUN xmlLinkPtr XMLCALL
+XMLPUBFUN xmlLinkPtr
                xmlListFront            (xmlListPtr l);
-XMLPUBFUN xmlLinkPtr XMLCALL
+XMLPUBFUN xmlLinkPtr
                xmlListEnd              (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListSize             (xmlListPtr l);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListPopFront         (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListPopBack          (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListPushFront        (xmlListPtr l,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListPushBack         (xmlListPtr l,
                                         void *data);
 
 /* Advanced Operators */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListReverse          (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListSort             (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListWalk             (xmlListPtr l,
                                         xmlListWalker walker,
                                         void *user);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListReverseWalk      (xmlListPtr l,
                                         xmlListWalker walker,
                                         void *user);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlListMerge            (xmlListPtr l1,
                                         xmlListPtr l2);
-XMLPUBFUN xmlListPtr XMLCALL
+XMLPUBFUN xmlListPtr
                xmlListDup              (const xmlListPtr old);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlListCopy             (xmlListPtr cur,
                                         const xmlListPtr old);
 /* Link operators */
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
                xmlLinkGetData          (xmlLinkPtr lk);
 
 /* xmlListUnique() */
index f39bde5..ed3ac4f 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <libxml/xmlversion.h>
 
-#ifdef LIBXML_FTP_ENABLED
+#if defined(LIBXML_FTP_ENABLED)
 
 /* Needed for portability to Windows 64 bits */
 #if defined(_WIN32)
@@ -80,52 +80,52 @@ typedef void (*ftpDataCallback) (void *userData,
  * Init
  */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoFTPInit          (void);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoFTPCleanup       (void);
 
 /*
  * Creating/freeing contexts.
  */
 XML_DEPRECATED
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoFTPNewCtxt       (const char *URL);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoFTPFreeCtxt      (void * ctx);
 XML_DEPRECATED
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoFTPConnectTo     (const char *server,
                                 int port);
 /*
  * Opening/closing session connections.
  */
 XML_DEPRECATED
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoFTPOpen          (const char *URL);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPConnect       (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPClose         (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPQuit          (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoFTPScanProxy     (const char *URL);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoFTPProxy         (const char *host,
                                 int port,
                                 const char *user,
                                 const char *passwd,
                                 int type);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPUpdateURL     (void *ctx,
                                 const char *URL);
 
@@ -133,48 +133,48 @@ XMLPUBFUN int XMLCALL
  * Rather internal commands.
  */
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPGetResponse   (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPCheckResponse (void *ctx);
 
 /*
  * CD/DIR/GET handlers.
  */
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPCwd           (void *ctx,
                                 const char *directory);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPDele          (void *ctx,
                                 const char *file);
 
 XML_DEPRECATED
-XMLPUBFUN SOCKET XMLCALL
+XMLPUBFUN SOCKET
        xmlNanoFTPGetConnection (void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPCloseConnection(void *ctx);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPList          (void *ctx,
                                 ftpListCallback callback,
                                 void *userData,
                                 const char *filename);
 XML_DEPRECATED
-XMLPUBFUN SOCKET XMLCALL
+XMLPUBFUN SOCKET
        xmlNanoFTPGetSocket     (void *ctx,
                                 const char *filename);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPGet           (void *ctx,
                                 ftpDataCallback callback,
                                 void *userData,
                                 const char *filename);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoFTPRead          (void *ctx,
                                 void *dest,
                                 int len);
@@ -182,5 +182,5 @@ XMLPUBFUN int XMLCALL
 #ifdef __cplusplus
 }
 #endif
-#endif /* LIBXML_FTP_ENABLED */
+#endif /* defined(LIBXML_FTP_ENABLED) || defined(LIBXML_LEGACY_ENABLED) */
 #endif /* __NANO_FTP_H__ */
index 22b8fb4..3b5e037 100644 (file)
 #ifdef __cplusplus
 extern "C" {
 #endif
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoHTTPInit         (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoHTTPCleanup      (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoHTTPScanProxy    (const char *URL);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoHTTPFetch        (const char *URL,
                                 const char *filename,
                                 char **contentType);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoHTTPMethod       (const char *URL,
                                 const char *method,
                                 const char *input,
                                 char **contentType,
                                 const char *headers,
                                 int   ilen);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoHTTPMethodRedir  (const char *URL,
                                 const char *method,
                                 const char *input,
@@ -43,35 +43,35 @@ XMLPUBFUN void * XMLCALL
                                 char **redir,
                                 const char *headers,
                                 int   ilen);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoHTTPOpen         (const char *URL,
                                 char **contentType);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlNanoHTTPOpenRedir    (const char *URL,
                                 char **contentType,
                                 char **redir);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoHTTPReturnCode   (void *ctx);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlNanoHTTPAuthHeader   (void *ctx);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlNanoHTTPRedir        (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoHTTPContentLength( void * ctx );
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlNanoHTTPEncoding     (void *ctx);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char *
        xmlNanoHTTPMimeType     (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoHTTPRead         (void *ctx,
                                 void *dest,
                                 int len);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlNanoHTTPSave         (void *ctxt,
                                 const char *filename);
 #endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlNanoHTTPClose        (void *ctx);
 #ifdef __cplusplus
 }
index 82c61d6..87aacef 100644 (file)
 #define __XML_PARSER_H__
 
 #include <libxml/xmlversion.h>
+#define XML_TREE_INTERNALS
 #include <libxml/tree.h>
+#undef XML_TREE_INTERNALS
 #include <libxml/dict.h>
 #include <libxml/hash.h>
 #include <libxml/valid.h>
 #include <libxml/entities.h>
 #include <libxml/xmlerror.h>
 #include <libxml/xmlstring.h>
+#include <libxml/xmlmemory.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlIO.h>
+/* for compatibility */
+#include <libxml/SAX2.h>
+#include <libxml/threads.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -61,17 +69,14 @@ struct _xmlParserInput {
     int length;                       /* length if known */
     int line;                         /* Current line */
     int col;                          /* Current column */
-    /*
-     * NOTE: consumed is only tested for equality in the parser code,
-     *       so even if there is an overflow this should not give troubles
-     *       for parsing very large instances.
-     */
     unsigned long consumed;           /* How many xmlChars already consumed */
     xmlParserInputDeallocate free;    /* function to deallocate the base */
-    const xmlChar *encoding;          /* the encoding string for entity */
+    const xmlChar *encoding;          /* unused */
     const xmlChar *version;           /* the version string for entity */
-    int standalone;                   /* Was that entity marked standalone */
+    int flags;                        /* Flags */
     int id;                           /* an unique identifier for the entity */
+    unsigned long parentConsumed;     /* consumed bytes from parents */
+    xmlEntityPtr entity;              /* entity, if any */
 };
 
 /**
@@ -125,7 +130,8 @@ typedef enum {
     XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
     XML_PARSER_EPILOG,         /* the Misc* after the last end tag */
     XML_PARSER_IGNORE,         /* within an IGNORED section */
-    XML_PARSER_PUBLIC_LITERAL  /* within a PUBLIC value */
+    XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */
+    XML_PARSER_XML_DECL         /* before XML decl (but after BOM) */
 } xmlParserInputState;
 
 /**
@@ -168,6 +174,8 @@ typedef enum {
 } xmlParserMode;
 
 typedef struct _xmlStartTag xmlStartTag;
+typedef struct _xmlParserNsData xmlParserNsData;
+typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
 
 /**
  * xmlParserCtxt:
@@ -248,8 +256,7 @@ struct _xmlParserCtxt {
 
     int                depth;         /* to prevent entity substitution loops */
     xmlParserInputPtr  entity;        /* used to check entities boundaries */
-    int                charset;       /* encoding of the in-memory content
-                                        actually an xmlCharEncoding */
+    int                charset;       /* unused */
     int                nodelen;       /* Those two fields are there to */
     int                nodemem;       /* Speed up large node parsing */
     int                pedantic;      /* signal pedantic warnings */
@@ -279,7 +286,7 @@ struct _xmlParserCtxt {
     int                nsNr;          /* the number of inherited namespaces */
     int                nsMax;         /* the size of the arrays */
     const xmlChar *   *nsTab;         /* the array of prefix/namespace name */
-    int               *attallocs;     /* which attribute were allocated */
+    unsigned          *attallocs;     /* which attribute were allocated */
     xmlStartTag       *pushTab;       /* array of data for push */
     xmlHashTablePtr    attsDefault;   /* defaulted attributes if any */
     xmlHashTablePtr    attsSpecial;   /* non-CDATA attributes if any */
@@ -300,7 +307,7 @@ struct _xmlParserCtxt {
      */
     xmlError          lastError;
     xmlParserMode     parseMode;    /* the parser mode */
-    unsigned long    nbentities;    /* number of entities references */
+    unsigned long    nbentities;    /* unused */
     unsigned long  sizeentities;    /* size of parsed entities */
 
     /* for use by HTML non-recursive parser */
@@ -311,6 +318,15 @@ struct _xmlParserCtxt {
 
     int                input_id;      /* we need to label inputs */
     unsigned long      sizeentcopy;   /* volume of entity copy */
+
+    int           endCheckState;    /* quote state for push parser */
+    unsigned short     nbErrors;    /* number of errors */
+    unsigned short   nbWarnings;    /* number of warnings */
+    unsigned            maxAmpl;    /* maximum amplification factor */
+
+    xmlParserNsData       *nsdb;    /* namespace database */
+    unsigned        attrHashMax;    /* allocated size */
+    xmlAttrHashBucket *attrHash;    /* atttribute hash table */
 };
 
 /**
@@ -605,7 +621,7 @@ typedef void (*cdataBlockSAXFunc) (
  *
  * Display and format a warning messages, callback.
  */
-typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
+typedef void (*warningSAXFunc) (void *ctx,
                                const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 /**
  * errorSAXFunc:
@@ -615,7 +631,7 @@ typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
  *
  * Display and format an error messages, callback.
  */
-typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
+typedef void (*errorSAXFunc) (void *ctx,
                                const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 /**
  * fatalErrorSAXFunc:
@@ -627,7 +643,7 @@ typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
  * Note: so far fatalError() SAX callbacks are not used, error()
  *       get all the callbacks for errors.
  */
-typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
+typedef void (*fatalErrorSAXFunc) (void *ctx,
                                const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 /**
  * isStandaloneSAXFunc:
@@ -731,6 +747,19 @@ struct _xmlSAXHandler {
     setDocumentLocatorSAXFunc setDocumentLocator;
     startDocumentSAXFunc startDocument;
     endDocumentSAXFunc endDocument;
+    /*
+     * `startElement` and `endElement` are only used by the legacy SAX1
+     * interface and should not be used in new software. If you really
+     * have to enable SAX1, the preferred way is set the `initialized`
+     * member to 1 instead of XML_SAX2_MAGIC.
+     *
+     * For backward compatibility, it's also possible to set the
+     * `startElementNs` and `endElementNs` handlers to NULL.
+     *
+     * You can also set the XML_PARSE_SAX1 parser option, but versions
+     * older than 2.12.0 will probably crash if this option is provided
+     * together with custom SAX callbacks.
+     */
     startElementSAXFunc startElement;
     endElementSAXFunc endElement;
     referenceSAXFunc reference;
@@ -744,8 +773,14 @@ struct _xmlSAXHandler {
     getParameterEntitySAXFunc getParameterEntity;
     cdataBlockSAXFunc cdataBlock;
     externalSubsetSAXFunc externalSubset;
+    /*
+     * `initialized` should always be set to XML_SAX2_MAGIC to enable the
+     * modern SAX2 interface.
+     */
     unsigned int initialized;
-    /* The following fields are extensions available only on version 2 */
+    /*
+     * The following members are only used by the SAX2 interface.
+     */
     void *_private;
     startElementNsSAX2Func startElementNs;
     endElementNsSAX2Func endElementNs;
@@ -803,34 +838,102 @@ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
                                         const char *ID,
                                         xmlParserCtxtPtr context);
 
-#ifdef __cplusplus
-}
+/*
+ * Variables
+ */
+
+XMLPUBVAR const char *const xmlParserVersion;
+#ifdef LIBXML_THREAD_ENABLED
+/* backward compatibility */
+XMLPUBFUN const char *const *__xmlParserVersion(void);
 #endif
 
-#include <libxml/encoding.h>
-#include <libxml/xmlIO.h>
-#include <libxml/globals.h>
+/** DOC_DISABLE */
+#define XML_GLOBALS_PARSER_CORE \
+  XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
+  XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
+  XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
+  XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
+  XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
+
+#ifdef LIBXML_OUTPUT_ENABLED
+  #define XML_GLOBALS_PARSER_OUTPUT \
+    XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
+    XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
+    XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
+#else
+  #define XML_GLOBALS_PARSER_OUTPUT
+#endif
 
-#ifdef __cplusplus
-extern "C" {
+#ifdef LIBXML_SAX1_ENABLED
+  #define XML_GLOBALS_PARSER_SAX1 \
+    XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
+#else
+  #define XML_GLOBALS_PARSER_SAX1
 #endif
 
+#define XML_GLOBALS_PARSER \
+  XML_GLOBALS_PARSER_CORE \
+  XML_GLOBALS_PARSER_OUTPUT \
+  XML_GLOBALS_PARSER_SAX1
+
+#define XML_OP XML_DECLARE_GLOBAL
+XML_GLOBALS_PARSER
+#undef XML_OP
+
+#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+  #define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
+  #define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
+  #define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
+  #define xmlDoValidityCheckingDefaultValue \
+    XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
+  #define xmlGetWarningsDefaultValue \
+    XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
+  #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
+  #define xmlLineNumbersDefaultValue \
+    XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
+  #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
+  #define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
+  #define xmlPedanticParserDefaultValue \
+    XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
+  #define xmlSubstituteEntitiesDefaultValue \
+    XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
+  #ifdef LIBXML_OUTPUT_ENABLED
+    #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
+    #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
+    #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
+  #endif
+#endif
+/** DOC_ENABLE */
 
 /*
  * Init/Cleanup
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlInitParser           (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCleanupParser        (void);
+XML_DEPRECATED
+XMLPUBFUN void
+               xmlInitGlobals          (void);
+XML_DEPRECATED
+XMLPUBFUN void
+               xmlCleanupGlobals       (void);
 
 /*
  * Input functions
  */
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlParserInputRead      (xmlParserInputPtr in,
                                         int len);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlParserInputGrow      (xmlParserInputPtr in,
                                         int len);
 
@@ -838,101 +941,130 @@ XMLPUBFUN int XMLCALL
  * Basic parsing Interfaces
  */
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlParseDoc             (const xmlChar *cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlParseFile            (const char *filename);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlParseMemory          (const char *buffer,
                                         int size);
 #endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED XMLPUBFUN int
                xmlSubstituteEntitiesDefault(int val);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefSubstituteEntitiesDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
                xmlKeepBlanksDefault    (int val);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED XMLPUBFUN int
+               xmlThrDefKeepBlanksDefaultValue(int v);
+XMLPUBFUN void
                xmlStopParser           (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED XMLPUBFUN int
                xmlPedanticParserDefault(int val);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefPedanticParserDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
                xmlLineNumbersDefault   (int val);
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefLineNumbersDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefDoValidityCheckingDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefGetWarningsDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefLoadExtDtdDefaultValue(int v);
+XML_DEPRECATED XMLPUBFUN int
+                xmlThrDefParserDebugEntities(int v);
 
 #ifdef LIBXML_SAX1_ENABLED
 /*
  * Recovery mode
  */
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlRecoverDoc           (const xmlChar *cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlRecoverMemory        (const char *buffer,
                                         int size);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlRecoverFile          (const char *filename);
 #endif /* LIBXML_SAX1_ENABLED */
 
 /*
  * Less common routines and SAX interfaces
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseDocument        (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseExtParsedEnt    (xmlParserCtxtPtr ctxt);
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlSAXUserParseFile     (xmlSAXHandlerPtr sax,
                                         void *user_data,
                                         const char *filename);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlSAXUserParseMemory   (xmlSAXHandlerPtr sax,
                                         void *user_data,
                                         const char *buffer,
                                         int size);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseDoc          (xmlSAXHandlerPtr sax,
                                         const xmlChar *cur,
                                         int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseMemory       (xmlSAXHandlerPtr sax,
                                         const char *buffer,
                                         int size,
                                         int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
                                         const char *buffer,
                                         int size,
                                         int recovery,
                                         void *data);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseFile         (xmlSAXHandlerPtr sax,
                                         const char *filename,
                                         int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
                                         const char *filename,
                                         int recovery,
                                         void *data);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlSAXParseEntity       (xmlSAXHandlerPtr sax,
                                         const char *filename);
-XMLPUBFUN xmlDocPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDocPtr
                xmlParseEntity          (const char *filename);
 #endif /* LIBXML_SAX1_ENABLED */
 
 #ifdef LIBXML_VALID_ENABLED
-XMLPUBFUN xmlDtdPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlDtdPtr
                xmlSAXParseDTD          (xmlSAXHandlerPtr sax,
                                         const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlParseDTD             (const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlIOParseDTD           (xmlSAXHandlerPtr sax,
                                         xmlParserInputBufferPtr input,
                                         xmlCharEncoding enc);
 #endif /* LIBXML_VALID_ENABLE */
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseBalancedChunkMemory(xmlDocPtr doc,
                                         xmlSAXHandlerPtr sax,
                                         void *user_data,
@@ -940,14 +1072,14 @@ XMLPUBFUN int XMLCALL
                                         const xmlChar *string,
                                         xmlNodePtr *lst);
 #endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN xmlParserErrors XMLCALL
+XMLPUBFUN xmlParserErrors
                xmlParseInNodeContext   (xmlNodePtr node,
                                         const char *data,
                                         int datalen,
                                         int options,
                                         xmlNodePtr *lst);
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
                      xmlSAXHandlerPtr sax,
                      void *user_data,
@@ -955,7 +1087,8 @@ XMLPUBFUN int XMLCALL
                      const xmlChar *string,
                      xmlNodePtr *lst,
                      int recover);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                xmlParseExternalEntity  (xmlDocPtr doc,
                                         xmlSAXHandlerPtr sax,
                                         void *user_data,
@@ -964,7 +1097,7 @@ XMLPUBFUN int XMLCALL
                                         const xmlChar *ID,
                                         xmlNodePtr *lst);
 #endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
                                         const xmlChar *URL,
                                         const xmlChar *ID,
@@ -973,21 +1106,25 @@ XMLPUBFUN int XMLCALL
 /*
  * Parser contexts handling.
  */
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                xmlNewParserCtxt        (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
+               xmlNewSAXParserCtxt     (const xmlSAXHandler *sax,
+                                        void *userData);
+XMLPUBFUN int
                xmlInitParserCtxt       (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlClearParserCtxt      (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeParserCtxt       (xmlParserCtxtPtr ctxt);
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
                                         const xmlChar* buffer,
                                         const char *filename);
 #endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                xmlCreateDocParserCtxt  (const xmlChar *cur);
 
 #ifdef LIBXML_LEGACY_ENABLED
@@ -995,16 +1132,16 @@ XMLPUBFUN xmlParserCtxtPtr XMLCALL
  * Reading/setting optional parsing features.
  */
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlGetFeaturesList      (int *len,
                                         const char **result);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlGetFeature           (xmlParserCtxtPtr ctxt,
                                         const char *name,
                                         void *result);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSetFeature           (xmlParserCtxtPtr ctxt,
                                         const char *name,
                                         void *value);
@@ -1014,13 +1151,13 @@ XMLPUBFUN int XMLCALL
 /*
  * Interfaces for the Push mode.
  */
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
                                         void *user_data,
                                         const char *chunk,
                                         int size,
                                         const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseChunk           (xmlParserCtxtPtr ctxt,
                                         const char *chunk,
                                         int size,
@@ -1031,7 +1168,7 @@ XMLPUBFUN int XMLCALL
  * Special I/O mode.
  */
 
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                xmlCreateIOParserCtxt   (xmlSAXHandlerPtr sax,
                                         void *user_data,
                                         xmlInputReadCallback   ioread,
@@ -1039,7 +1176,7 @@ XMLPUBFUN xmlParserCtxtPtr XMLCALL
                                         void *ioctx,
                                         xmlCharEncoding enc);
 
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                xmlNewIOInputStream     (xmlParserCtxtPtr ctxt,
                                         xmlParserInputBufferPtr input,
                                         xmlCharEncoding enc);
@@ -1047,17 +1184,17 @@ XMLPUBFUN xmlParserInputPtr XMLCALL
 /*
  * Node infos.
  */
-XMLPUBFUN const xmlParserNodeInfo* XMLCALL
+XMLPUBFUN const xmlParserNodeInfo*
                xmlParserFindNodeInfo   (const xmlParserCtxtPtr ctxt,
                                         const xmlNodePtr node);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlInitNodeInfoSeq      (xmlParserNodeInfoSeqPtr seq);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlClearNodeInfoSeq     (xmlParserNodeInfoSeqPtr seq);
-XMLPUBFUN unsigned long XMLCALL
+XMLPUBFUN unsigned long
                xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
                                          const xmlNodePtr node);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlParserAddNodeInfo    (xmlParserCtxtPtr ctxt,
                                         const xmlParserNodeInfoPtr info);
 
@@ -1065,11 +1202,11 @@ XMLPUBFUN void XMLCALL
  * External entities handling actually implemented in xmlIO.
  */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
-XMLPUBFUN xmlExternalEntityLoader XMLCALL
+XMLPUBFUN xmlExternalEntityLoader
                xmlGetExternalEntityLoader(void);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                xmlLoadExternalEntity   (const char *URL,
                                         const char *ID,
                                         xmlParserCtxtPtr ctxt);
@@ -1077,7 +1214,7 @@ XMLPUBFUN xmlParserInputPtr XMLCALL
 /*
  * Index lookup, actually implemented in the encoding module
  */
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                xmlByteConsumed         (xmlParserCtxtPtr ctxt);
 
 /*
@@ -1117,69 +1254,72 @@ typedef enum {
     XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
 } xmlParserOption;
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlCtxtReset            (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCtxtResetPush        (xmlParserCtxtPtr ctxt,
                                         const char *chunk,
                                         int size,
                                         const char *filename,
                                         const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlCtxtUseOptions       (xmlParserCtxtPtr ctxt,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN void
+               xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
+                                        unsigned maxAmpl);
+XMLPUBFUN xmlDocPtr
                xmlReadDoc              (const xmlChar *cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlReadFile             (const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlReadMemory           (const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlReadFd               (int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlReadIO               (xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
                                         void *ioctx,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCtxtReadDoc          (xmlParserCtxtPtr ctxt,
                                         const xmlChar *cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCtxtReadFile         (xmlParserCtxtPtr ctxt,
                                         const char *filename,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCtxtReadMemory               (xmlParserCtxtPtr ctxt,
                                         const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCtxtReadFd           (xmlParserCtxtPtr ctxt,
                                         int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCtxtReadIO           (xmlParserCtxtPtr ctxt,
                                         xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
@@ -1235,7 +1375,7 @@ typedef enum {
     XML_WITH_NONE = 99999 /* just to be sure of allocation size */
 } xmlFeature;
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlHasFeature           (xmlFeature feature);
 
 #ifdef __cplusplus
index 656ee46..017ed27 100644 (file)
@@ -16,6 +16,7 @@
 #include <libxml/parser.h>
 #include <libxml/HTMLparser.h>
 #include <libxml/chvalid.h>
+#include <libxml/SAX2.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -41,6 +42,13 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
 #define XML_MAX_TEXT_LENGTH 10000000
 
 /**
+ * XML_MAX_HUGE_LENGTH:
+ *
+ * Maximum size allowed when XML_PARSE_HUGE is set.
+ */
+#define XML_MAX_HUGE_LENGTH 1000000000
+
+/**
  * XML_MAX_NAME_LENGTH:
  *
  * Maximum size allowed for a markup identifier.
@@ -279,34 +287,6 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
 #define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)
 
 /**
- * SKIP_EOL:
- * @p:  and UTF8 string pointer
- *
- * Skips the end of line chars.
- */
-#define SKIP_EOL(p)                                                    \
-    if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; }                 \
-    if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
-
-/**
- * MOVETO_ENDTAG:
- * @p:  and UTF8 string pointer
- *
- * Skips to the next '>' char.
- */
-#define MOVETO_ENDTAG(p)                                               \
-    while ((*p) && (*(p) != '>')) (p)++
-
-/**
- * MOVETO_STARTTAG:
- * @p:  and UTF8 string pointer
- *
- * Skips to the next '<' char.
- */
-#define MOVETO_STARTTAG(p)                                             \
-    while ((*p) && (*(p) != '<')) (p)++
-
-/**
  * Global variables used for predefined strings.
  */
 XMLPUBVAR const xmlChar xmlStringText[];
@@ -316,71 +296,62 @@ XMLPUBVAR const xmlChar xmlStringComment[];
 /*
  * Function to finish the work of the macros where needed.
  */
-XMLPUBFUN int XMLCALL                   xmlIsLetter     (int c);
+XMLPUBFUN int                   xmlIsLetter     (int c);
 
 /**
  * Parser context.
  */
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                        xmlCreateFileParserCtxt (const char *filename);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                        xmlCreateURLParserCtxt  (const char *filename,
                                                 int options);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                        xmlCreateMemoryParserCtxt(const char *buffer,
                                                 int size);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
                        xmlCreateEntityParserCtxt(const xmlChar *URL,
                                                 const xmlChar *ID,
                                                 const xmlChar *base);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlSwitchEncoding       (xmlParserCtxtPtr ctxt,
                                                 xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlSwitchToEncoding     (xmlParserCtxtPtr ctxt,
                                         xmlCharEncodingHandlerPtr handler);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlSwitchInputEncoding  (xmlParserCtxtPtr ctxt,
                                                 xmlParserInputPtr input,
                                         xmlCharEncodingHandlerPtr handler);
 
-#ifdef IN_LIBXML
-/* internal error reporting */
-XMLPUBFUN void XMLCALL
-                       __xmlErrEncoding        (xmlParserCtxtPtr ctxt,
-                                                xmlParserErrors xmlerr,
-                                                const char *msg,
-                                                const xmlChar * str1,
-                                                const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0);
-#endif
-
 /**
  * Input Streams.
  */
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                        xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *buffer);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlParserInputPtr
                        xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
                                                 xmlEntityPtr entity);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPushInput            (xmlParserCtxtPtr ctxt,
                                                 xmlParserInputPtr input);
-XMLPUBFUN xmlChar XMLCALL
+XMLPUBFUN xmlChar
                        xmlPopInput             (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeInputStream      (xmlParserInputPtr input);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                        xmlNewInputFromFile     (xmlParserCtxtPtr ctxt,
                                                 const char *filename);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
                        xmlNewInputStream       (xmlParserCtxtPtr ctxt);
 
 /**
  * Namespaces.
  */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlSplitQName           (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *name,
                                                 xmlChar **prefix);
@@ -388,109 +359,151 @@ XMLPUBFUN xmlChar * XMLCALL
 /**
  * Generic production rules.
  */
-XMLPUBFUN const xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *
                        xmlParseName            (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseNmtoken         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseEntityValue     (xmlParserCtxtPtr ctxt,
                                                 xmlChar **orig);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseAttValue        (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseSystemLiteral   (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParsePubidLiteral    (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseCharData        (xmlParserCtxtPtr ctxt,
                                                 int cdata);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseExternalID      (xmlParserCtxtPtr ctxt,
                                                 xmlChar **publicID,
                                                 int strict);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseComment         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN const xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *
                        xmlParsePITarget        (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParsePI              (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseNotationDecl    (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseEntityDecl      (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseDefaultDecl     (xmlParserCtxtPtr ctxt,
                                                 xmlChar **value);
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlEnumerationPtr
                        xmlParseNotationType    (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlEnumerationPtr
                        xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseEnumeratedType  (xmlParserCtxtPtr ctxt,
                                                 xmlEnumerationPtr *tree);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseAttributeType   (xmlParserCtxtPtr ctxt,
                                                 xmlEnumerationPtr *tree);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlElementContentPtr
                        xmlParseElementMixedContentDecl
                                                (xmlParserCtxtPtr ctxt,
                                                 int inputchk);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlElementContentPtr
                        xmlParseElementChildrenContentDecl
                                                (xmlParserCtxtPtr ctxt,
                                                 int inputchk);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
                                                 const xmlChar *name,
                                                 xmlElementContentPtr *result);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseElementDecl     (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseMarkupDecl      (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseCharRef         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlEntityPtr
                        xmlParseEntityRef       (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseReference       (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParsePEReference     (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseDocTypeDecl     (xmlParserCtxtPtr ctxt);
 #ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN const xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *
                        xmlParseAttribute       (xmlParserCtxtPtr ctxt,
                                                 xmlChar **value);
-XMLPUBFUN const xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *
                        xmlParseStartTag        (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseEndTag          (xmlParserCtxtPtr ctxt);
 #endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseCDSect          (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlParseContent         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseElement         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseVersionNum      (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseVersionInfo     (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                        xmlParseEncName         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN const xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *
                        xmlParseEncodingDecl    (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlParseSDDecl          (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseXMLDecl         (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseTextDecl        (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XML_DEPRECATED
+XMLPUBFUN void
                        xmlParseMisc            (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlParseExternalSubset  (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *ExternalID,
                                                 const xmlChar *SystemID);
@@ -519,14 +532,16 @@ XMLPUBFUN void XMLCALL
  */
 #define XML_SUBSTITUTE_BOTH    3
 
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                xmlStringDecodeEntities         (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *str,
                                                 int what,
                                                 xmlChar end,
                                                 xmlChar  end2,
                                                 xmlChar end3);
-XMLPUBFUN xmlChar * XMLCALL
+XML_DEPRECATED
+XMLPUBFUN xmlChar *
                xmlStringLenDecodeEntities      (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *str,
                                                 int len,
@@ -538,48 +553,49 @@ XMLPUBFUN xmlChar * XMLCALL
 /*
  * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
  */
-XMLPUBFUN int XMLCALL                  nodePush                (xmlParserCtxtPtr ctxt,
+XML_DEPRECATED
+XMLPUBFUN int                  nodePush                (xmlParserCtxtPtr ctxt,
                                                 xmlNodePtr value);
-XMLPUBFUN xmlNodePtr XMLCALL           nodePop                 (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL                  inputPush               (xmlParserCtxtPtr ctxt,
+XML_DEPRECATED
+XMLPUBFUN xmlNodePtr           nodePop                 (xmlParserCtxtPtr ctxt);
+XMLPUBFUN int                  inputPush               (xmlParserCtxtPtr ctxt,
                                                 xmlParserInputPtr value);
-XMLPUBFUN xmlParserInputPtr XMLCALL    inputPop                (xmlParserCtxtPtr ctxt);
-XMLPUBFUN const xmlChar * XMLCALL      namePop                 (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL                  namePush                (xmlParserCtxtPtr ctxt,
+XMLPUBFUN xmlParserInputPtr    inputPop                (xmlParserCtxtPtr ctxt);
+XML_DEPRECATED
+XMLPUBFUN const xmlChar *      namePop                 (xmlParserCtxtPtr ctxt);
+XML_DEPRECATED
+XMLPUBFUN int                  namePush                (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *value);
 
 /*
  * other commodities shared between parser.c and parserInternals.
  */
-XMLPUBFUN int XMLCALL                  xmlSkipBlankChars       (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL                  xmlStringCurrentChar    (xmlParserCtxtPtr ctxt,
+XML_DEPRECATED
+XMLPUBFUN int                  xmlSkipBlankChars       (xmlParserCtxtPtr ctxt);
+XML_DEPRECATED
+XMLPUBFUN int                  xmlStringCurrentChar    (xmlParserCtxtPtr ctxt,
                                                 const xmlChar *cur,
                                                 int *len);
-XMLPUBFUN void XMLCALL                 xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL                  xmlCheckLanguageID      (const xmlChar *lang);
+XML_DEPRECATED
+XMLPUBFUN void                 xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
+XML_DEPRECATED
+XMLPUBFUN int                  xmlCheckLanguageID      (const xmlChar *lang);
 
 /*
  * Really core function shared with HTML parser.
  */
-XMLPUBFUN int XMLCALL                  xmlCurrentChar          (xmlParserCtxtPtr ctxt,
+XML_DEPRECATED
+XMLPUBFUN int                  xmlCurrentChar          (xmlParserCtxtPtr ctxt,
                                                 int *len);
-XMLPUBFUN int XMLCALL          xmlCopyCharMultiByte    (xmlChar *out,
+XMLPUBFUN int          xmlCopyCharMultiByte    (xmlChar *out,
                                                 int val);
-XMLPUBFUN int XMLCALL                  xmlCopyChar             (int len,
+XMLPUBFUN int                  xmlCopyChar             (int len,
                                                 xmlChar *out,
                                                 int val);
-XMLPUBFUN void XMLCALL                 xmlNextChar             (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL                 xmlParserInputShrink    (xmlParserInputPtr in);
-
-#ifdef LIBXML_HTML_ENABLED
-/*
- * Actually comes from the HTML parser but launched from the init stuff.
- */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL                 htmlInitAutoClose       (void);
-XMLPUBFUN htmlParserCtxtPtr XMLCALL    htmlCreateFileParserCtxt(const char *filename,
-                                                const char *encoding);
-#endif
+XMLPUBFUN void                 xmlNextChar             (xmlParserCtxtPtr ctxt);
+XML_DEPRECATED
+XMLPUBFUN void                 xmlParserInputShrink    (xmlParserInputPtr in);
 
 /*
  * Specific function to keep track of entities references
@@ -600,34 +616,34 @@ typedef   void    (*xmlEntityReferenceFunc)       (xmlEntityPtr ent,
                                                 xmlNodePtr lastNode);
 
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL         xmlSetEntityReferenceFunc       (xmlEntityReferenceFunc func);
+XMLPUBFUN void         xmlSetEntityReferenceFunc       (xmlEntityReferenceFunc func);
 
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlParseQuotedString    (xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                         xmlParseNamespace       (xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlNamespaceParseNSDef  (xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlScanName             (xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt);
+XMLPUBFUN void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlNamespaceParseQName  (xmlParserCtxtPtr ctxt,
                                                 xmlChar **prefix);
 /**
  * Entities
  */
 XML_DEPRECATED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlDecodeEntities               (xmlParserCtxtPtr ctxt,
                                                 int len,
                                                 int what,
@@ -635,21 +651,12 @@ XMLPUBFUN xmlChar * XMLCALL
                                                 xmlChar  end2,
                                                 xmlChar end3);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlHandleEntity         (xmlParserCtxtPtr ctxt,
                                                 xmlEntityPtr entity);
 
 #endif /* LIBXML_LEGACY_ENABLED */
 
-#ifdef IN_LIBXML
-/*
- * internal only
- */
-XMLPUBFUN void XMLCALL
-       xmlErrMemory            (xmlParserCtxtPtr ctxt,
-                                const char *extra);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
index 97d2cd2..72bf239 100644 (file)
@@ -43,18 +43,18 @@ typedef enum {
     XML_PATTERN_XSFIELD                = 1<<2  /* XPath subset for schema field */
 } xmlPatternFlags;
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreePattern          (xmlPatternPtr comp);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreePatternList      (xmlPatternPtr comp);
 
-XMLPUBFUN xmlPatternPtr XMLCALL
+XMLPUBFUN xmlPatternPtr
                        xmlPatterncompile       (const xmlChar *pattern,
                                                 xmlDict *dict,
                                                 int flags,
                                                 const xmlChar **namespaces);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPatternMatch         (xmlPatternPtr comp,
                                                 xmlNodePtr node);
 
@@ -62,34 +62,34 @@ XMLPUBFUN int XMLCALL
 typedef struct _xmlStreamCtxt xmlStreamCtxt;
 typedef xmlStreamCtxt *xmlStreamCtxtPtr;
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPatternStreamable    (xmlPatternPtr comp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPatternMaxDepth      (xmlPatternPtr comp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPatternMinDepth      (xmlPatternPtr comp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlPatternFromRoot      (xmlPatternPtr comp);
-XMLPUBFUN xmlStreamCtxtPtr XMLCALL
+XMLPUBFUN xmlStreamCtxtPtr
                        xmlPatternGetStreamCtxt (xmlPatternPtr comp);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeStreamCtxt       (xmlStreamCtxtPtr stream);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlStreamPushNode       (xmlStreamCtxtPtr stream,
                                                 const xmlChar *name,
                                                 const xmlChar *ns,
                                                 int nodeType);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlStreamPush           (xmlStreamCtxtPtr stream,
                                                 const xmlChar *name,
                                                 const xmlChar *ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlStreamPushAttr       (xmlStreamCtxtPtr stream,
                                                 const xmlChar *name,
                                                 const xmlChar *ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlStreamPop            (xmlStreamCtxtPtr stream);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlStreamWantsAnyNode   (xmlStreamCtxtPtr stream);
 #ifdef __cplusplus
 }
index 6369785..079b7f1 100644 (file)
@@ -11,8 +11,9 @@
 #define __XML_RELAX_NG__
 
 #include <libxml/xmlversion.h>
-#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
 #include <libxml/xmlstring.h>
+#include <libxml/tree.h>
 
 #ifdef LIBXML_SCHEMAS_ENABLED
 
@@ -32,7 +33,7 @@ typedef xmlRelaxNG *xmlRelaxNGPtr;
  *
  * Signature of an error callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx,
+typedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx,
                                                      const char *msg,
                                                      ...) LIBXML_ATTR_FORMAT(2,3);
 
@@ -44,7 +45,7 @@ typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx,
  *
  * Signature of a warning callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx,
+typedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx,
                                                        const char *msg,
                                                        ...) LIBXML_ATTR_FORMAT(2,3);
 
@@ -116,95 +117,95 @@ typedef enum {
     XML_RELAXNGP_CRNG = 2
 } xmlRelaxNGParserFlag;
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGInitTypes         (void);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGCleanupTypes      (void);
 
 /*
  * Interfaces for parsing.
  */
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr
                    xmlRelaxNGNewParserCtxt     (const char *URL);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr
                    xmlRelaxNGNewMemParserCtxt  (const char *buffer,
                                                 int size);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr
                    xmlRelaxNGNewDocParserCtxt  (xmlDocPtr doc);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxParserSetFlag       (xmlRelaxNGParserCtxtPtr ctxt,
                                                 int flag);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGFreeParserCtxt    (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc err,
                                         xmlRelaxNGValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc *err,
                                         xmlRelaxNGValidityWarningFunc *warn,
                                         void **ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGSetParserStructuredErrors(
                                         xmlRelaxNGParserCtxtPtr ctxt,
                                         xmlStructuredErrorFunc serror,
                                         void *ctx);
-XMLPUBFUN xmlRelaxNGPtr XMLCALL
+XMLPUBFUN xmlRelaxNGPtr
                    xmlRelaxNGParse             (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGFree              (xmlRelaxNGPtr schema);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGDump              (FILE *output,
                                         xmlRelaxNGPtr schema);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGDumpTree  (FILE * output,
                                         xmlRelaxNGPtr schema);
 #endif /* LIBXML_OUTPUT_ENABLED */
 /*
  * Interfaces for validating
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc err,
                                         xmlRelaxNGValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc *err,
                                         xmlRelaxNGValidityWarningFunc *warn,
                                         void **ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                          xmlStructuredErrorFunc serror, void *ctx);
-XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGValidCtxtPtr
                    xmlRelaxNGNewValidCtxt      (xmlRelaxNGPtr schema);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRelaxNGFreeValidCtxt     (xmlRelaxNGValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGValidateDoc       (xmlRelaxNGValidCtxtPtr ctxt,
                                                 xmlDocPtr doc);
 /*
  * Interfaces for progressive validation when possible
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGValidatePushElement       (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
                                         const xmlChar *data,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGValidatePopElement        (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRelaxNGValidateFullElement       (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
index c521d1c..e9d3b3c 100644 (file)
@@ -21,6 +21,7 @@
 #include <libxml/xmlregexp.h>
 #include <libxml/hash.h>
 #include <libxml/dict.h>
+#include <libxml/tree.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -947,8 +948,8 @@ struct _xmlSchema {
     void *volatiles; /* Obsolete */
 };
 
-XMLPUBFUN void XMLCALL         xmlSchemaFreeType        (xmlSchemaTypePtr type);
-XMLPUBFUN void XMLCALL         xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
+XMLPUBFUN void         xmlSchemaFreeType        (xmlSchemaTypePtr type);
+XMLPUBFUN void         xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
 
 #ifdef __cplusplus
 }
index c61e61b..8dd8d25 100644 (file)
@@ -15,6 +15,7 @@
 
 #ifdef LIBXML_SCHEMATRON_ENABLED
 
+#include <libxml/xmlerror.h>
 #include <libxml/tree.h>
 
 #ifdef __cplusplus
@@ -69,68 +70,68 @@ typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;
 /*
  * Interfaces for parsing.
  */
-XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronParserCtxtPtr
            xmlSchematronNewParserCtxt  (const char *URL);
-XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronParserCtxtPtr
            xmlSchematronNewMemParserCtxt(const char *buffer,
                                         int size);
-XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronParserCtxtPtr
            xmlSchematronNewDocParserCtxt(xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt);
 /*****
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,
                                         xmlSchematronValidityErrorFunc err,
                                         xmlSchematronValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt,
                                        xmlSchematronValidityErrorFunc * err,
                                        xmlSchematronValidityWarningFunc * warn,
                                        void **ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchematronIsValid    (xmlSchematronValidCtxtPtr ctxt);
  *****/
-XMLPUBFUN xmlSchematronPtr XMLCALL
+XMLPUBFUN xmlSchematronPtr
            xmlSchematronParse          (xmlSchematronParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronFree           (xmlSchematronPtr schema);
 /*
  * Interfaces for validating
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronSetValidStructuredErrors(
                                          xmlSchematronValidCtxtPtr ctxt,
                                          xmlStructuredErrorFunc serror,
                                          void *ctx);
 /******
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt,
                                         xmlSchematronValidityErrorFunc err,
                                         xmlSchematronValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt,
                                         xmlSchematronValidityErrorFunc *err,
                                         xmlSchematronValidityWarningFunc *warn,
                                         void **ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt,
                                         xmlNodePtr elem);
  *******/
 
-XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronValidCtxtPtr
            xmlSchematronNewValidCtxt   (xmlSchematronPtr schema,
                                         int options);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchematronFreeValidCtxt  (xmlSchematronValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchematronValidateDoc    (xmlSchematronValidCtxtPtr ctxt,
                                         xmlDocPtr instance);
 
index 6eedac1..8f4b6e1 100644 (file)
@@ -29,59 +29,55 @@ typedef xmlMutex *xmlMutexPtr;
 typedef struct _xmlRMutex xmlRMutex;
 typedef xmlRMutex *xmlRMutexPtr;
 
-#ifdef __cplusplus
-}
-#endif
-#include <libxml/globals.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-XMLPUBFUN xmlMutexPtr XMLCALL
+XMLPUBFUN int
+                       xmlCheckThreadLocalStorage(void);
+
+XMLPUBFUN xmlMutexPtr
                        xmlNewMutex     (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlMutexLock    (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlMutexUnlock  (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeMutex    (xmlMutexPtr tok);
 
-XMLPUBFUN xmlRMutexPtr XMLCALL
+XMLPUBFUN xmlRMutexPtr
                        xmlNewRMutex    (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlRMutexLock   (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlRMutexUnlock (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeRMutex   (xmlRMutexPtr tok);
 
 /*
  * Library wide APIs.
  */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlInitThreads  (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlLockLibrary  (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlUnlockLibrary(void);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlGetThreadId  (void);
-XMLPUBFUN int XMLCALL
+XML_DEPRECATED
+XMLPUBFUN int
                        xmlIsMainThread (void);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlCleanupThreads(void);
-XMLPUBFUN xmlGlobalStatePtr XMLCALL
-                       xmlGetGlobalState(void);
 
-#ifdef HAVE_PTHREAD_H
-#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
-#if defined(LIBXML_STATIC_FOR_DLL)
-int XMLCALL
+/** DOC_DISABLE */
+#if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \
+    defined(LIBXML_STATIC_FOR_DLL)
+int
 xmlDllMain(void *hinstDLL, unsigned long fdwReason,
            void *lpvReserved);
 #endif
-#endif
+/** DOC_ENABLE */
 
 #ifdef __cplusplus
 }
index 98e2087..a90a174 100644 (file)
@@ -9,6 +9,15 @@
  * Author: Daniel Veillard
  */
 
+#ifndef XML_TREE_INTERNALS
+
+/*
+ * Emulate circular dependency for backward compatibility
+ */
+#include <libxml/parser.h>
+
+#else /* XML_TREE_INTERNALS */
+
 #ifndef __XML_TREE_H__
 #define __XML_TREE_H__
 
@@ -16,6 +25,8 @@
 #include <limits.h>
 #include <libxml/xmlversion.h>
 #include <libxml/xmlstring.h>
+#include <libxml/xmlmemory.h>
+#include <libxml/xmlregexp.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -74,7 +85,7 @@ typedef xmlEntity *xmlEntityPtr;
 typedef enum {
     XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
     XML_BUFFER_ALLOC_EXACT,    /* grow only to the minimal size */
-    XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
+    XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer, deprecated */
     XML_BUFFER_ALLOC_IO,       /* special allocation scheme used for I/O */
     XML_BUFFER_ALLOC_HYBRID,   /* exact up to a threshold, and doubleit thereafter */
     XML_BUFFER_ALLOC_BOUNDED   /* limit the upper size of the buffer */
@@ -117,10 +128,10 @@ typedef xmlBuf *xmlBufPtr;
  * A few public routines for xmlBuf. As those are expected to be used
  * mostly internally the bulk of the routines are internal in buf.h
  */
-XMLPUBFUN xmlChar* XMLCALL       xmlBufContent (const xmlBuf* buf);
-XMLPUBFUN xmlChar* XMLCALL       xmlBufEnd      (xmlBufPtr buf);
-XMLPUBFUN size_t XMLCALL         xmlBufUse      (const xmlBufPtr buf);
-XMLPUBFUN size_t XMLCALL         xmlBufShrink  (xmlBufPtr buf, size_t len);
+XMLPUBFUN xmlChar*       xmlBufContent (const xmlBuf* buf);
+XMLPUBFUN xmlChar*       xmlBufEnd      (xmlBufPtr buf);
+XMLPUBFUN size_t         xmlBufUse      (const xmlBufPtr buf);
+XMLPUBFUN size_t         xmlBufShrink  (xmlBufPtr buf, size_t len);
 
 /*
  * LIBXML2_NEW_BUFFER:
@@ -180,8 +191,10 @@ typedef enum {
     /* XML_DOCB_DOCUMENT_NODE= 21 */ /* removed */
 } xmlElementType;
 
+/** DOC_DISABLE */
 /* For backward compatibility */
 #define XML_DOCB_DOCUMENT_NODE 21
+/** DOC_ENABLE */
 
 /**
  * xmlNotation:
@@ -327,14 +340,6 @@ typedef enum {
     XML_ELEMENT_TYPE_ELEMENT
 } xmlElementTypeVal;
 
-#ifdef __cplusplus
-}
-#endif
-#include <libxml/xmlregexp.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /**
  * xmlElement:
  *
@@ -571,12 +576,11 @@ struct _xmlDoc {
     struct _xmlDtd  *extSubset;        /* the document external subset */
     struct _xmlNs   *oldNs;    /* Global namespace, the old way */
     const xmlChar  *version;   /* the XML version string */
-    const xmlChar  *encoding;   /* external initial encoding, if any */
+    const xmlChar  *encoding;   /* actual encoding, if any */
     void           *ids;        /* Hash table for ID attributes if any */
     void           *refs;       /* Hash table for IDREFs attributes if any */
     const xmlChar  *URL;       /* The URI for that document */
-    int             charset;    /* Internal flag for charset handling,
-                                  actually an xmlCharEncoding */
+    int             charset;    /* unused */
     struct _xmlDict *dict;      /* dict used to allocate names or NULL */
     void           *psvi;      /* for type/PSVI information */
     int             parseFlags;        /* set of xmlParserOption used to parse the
@@ -629,6 +633,22 @@ struct _xmlDOMWrapCtxt {
 };
 
 /**
+ * xmlRegisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the registration callback of a created node
+ */
+typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
+
+/**
+ * xmlDeregisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the deregistration callback of a discarded node
+ */
+typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
+
+/**
  * xmlChildrenNode:
  *
  * Macro for compatibility naming layer with libxml1. Maps
@@ -652,40 +672,56 @@ struct _xmlDOMWrapCtxt {
  * Variables.
  */
 
+/** DOC_DISABLE */
+#define XML_GLOBALS_TREE \
+  XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
+  XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
+  XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
+  XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
+         XML_DEPRECATED)
+
+#define XML_OP XML_DECLARE_GLOBAL
+XML_GLOBALS_TREE
+#undef XML_OP
+
+#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+  #define xmlBufferAllocScheme XML_GLOBAL_MACRO(xmlBufferAllocScheme)
+  #define xmlDefaultBufferSize XML_GLOBAL_MACRO(xmlDefaultBufferSize)
+  #define xmlRegisterNodeDefaultValue \
+    XML_GLOBAL_MACRO(xmlRegisterNodeDefaultValue)
+  #define xmlDeregisterNodeDefaultValue \
+    XML_GLOBAL_MACRO(xmlDeregisterNodeDefaultValue)
+#endif
+/** DOC_ENABLE */
+
 /*
  * Some helper functions
  */
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
-    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \
-    defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \
-    defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \
-    defined(LIBXML_LEGACY_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNCName       (const xmlChar *value,
                                         int space);
-#endif
 
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateQName        (const xmlChar *value,
                                         int space);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateName         (const xmlChar *value,
                                         int space);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNMToken      (const xmlChar *value,
                                         int space);
 #endif
 
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlBuildQName           (const xmlChar *ncname,
                                         const xmlChar *prefix,
                                         xmlChar *memory,
                                         int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlSplitQName2          (const xmlChar *name,
                                         xmlChar **prefix);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlSplitQName3          (const xmlChar *name,
                                         int *len);
 
@@ -693,318 +729,318 @@ XMLPUBFUN const xmlChar * XMLCALL
  * Handling Buffers, the old ones see @xmlBuf for the new ones.
  */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
-XMLPUBFUN xmlBufferAllocationScheme XMLCALL
+XMLPUBFUN xmlBufferAllocationScheme
                xmlGetBufferAllocationScheme(void);
 
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr
                xmlBufferCreate         (void);
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr
                xmlBufferCreateSize     (size_t size);
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr
                xmlBufferCreateStatic   (void *mem,
                                         size_t size);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferResize         (xmlBufferPtr buf,
                                         unsigned int size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferFree           (xmlBufferPtr buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferDump           (FILE *file,
                                         xmlBufferPtr buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferAdd            (xmlBufferPtr buf,
                                         const xmlChar *str,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferAddHead        (xmlBufferPtr buf,
                                         const xmlChar *str,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferCat            (xmlBufferPtr buf,
                                         const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferCCat           (xmlBufferPtr buf,
                                         const char *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferShrink         (xmlBufferPtr buf,
                                         unsigned int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferGrow           (xmlBufferPtr buf,
                                         unsigned int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferEmpty          (xmlBufferPtr buf);
-XMLPUBFUN const xmlChar* XMLCALL
+XMLPUBFUN const xmlChar*
                xmlBufferContent        (const xmlBuffer *buf);
-XMLPUBFUN xmlChar* XMLCALL
+XMLPUBFUN xmlChar*
                xmlBufferDetach         (xmlBufferPtr buf);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferSetAllocationScheme(xmlBufferPtr buf,
                                         xmlBufferAllocationScheme scheme);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufferLength         (const xmlBuffer *buf);
 
 /*
  * Creating/freeing new structures.
  */
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlCreateIntSubset      (xmlDocPtr doc,
                                         const xmlChar *name,
                                         const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlNewDtd               (xmlDocPtr doc,
                                         const xmlChar *name,
                                         const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlGetIntSubset         (const xmlDoc *doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeDtd              (xmlDtdPtr cur);
 #ifdef LIBXML_LEGACY_ENABLED
 XML_DEPRECATED
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlNewGlobalNs          (xmlDocPtr doc,
                                         const xmlChar *href,
                                         const xmlChar *prefix);
 #endif /* LIBXML_LEGACY_ENABLED */
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlNewNs                (xmlNodePtr node,
                                         const xmlChar *href,
                                         const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeNs               (xmlNsPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeNsList           (xmlNsPtr cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlNewDoc               (const xmlChar *version);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeDoc              (xmlDocPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlNewDocProp           (xmlDocPtr doc,
                                         const xmlChar *name,
                                         const xmlChar *value);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
     defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlNewProp              (xmlNodePtr node,
                                         const xmlChar *name,
                                         const xmlChar *value);
 #endif
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlNewNsProp            (xmlNodePtr node,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *value);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlNewNsPropEatName     (xmlNodePtr node,
                                         xmlNsPtr ns,
                                         xmlChar *name,
                                         const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreePropList         (xmlAttrPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeProp             (xmlAttrPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlCopyProp             (xmlNodePtr target,
                                         xmlAttrPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlCopyPropList         (xmlNodePtr target,
                                         xmlAttrPtr cur);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr
                xmlCopyDtd              (xmlDtdPtr dtd);
 #endif /* LIBXML_TREE_ENABLED */
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                xmlCopyDoc              (xmlDocPtr doc,
                                         int recursive);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
 /*
  * Creating new nodes.
  */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocNode           (xmlDocPtr doc,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocNodeEatName    (xmlDocPtr doc,
                                         xmlNsPtr ns,
                                         xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewNode              (xmlNsPtr ns,
                                         const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewNodeEatName       (xmlNsPtr ns,
                                         xmlChar *name);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewChild             (xmlNodePtr parent,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *content);
 #endif
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocText           (const xmlDoc *doc,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewText              (const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocPI             (xmlDocPtr doc,
                                         const xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewPI                (const xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocTextLen        (xmlDocPtr doc,
                                         const xmlChar *content,
                                         int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewTextLen           (const xmlChar *content,
                                         int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocComment        (xmlDocPtr doc,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewComment           (const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewCDataBlock        (xmlDocPtr doc,
                                         const xmlChar *content,
                                         int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewCharRef           (xmlDocPtr doc,
                                         const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewReference         (const xmlDoc *doc,
                                         const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlCopyNode             (xmlNodePtr node,
                                         int recursive);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlDocCopyNode          (xmlNodePtr node,
                                         xmlDocPtr doc,
                                         int recursive);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlDocCopyNodeList      (xmlDocPtr doc,
                                         xmlNodePtr node);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlCopyNodeList         (xmlNodePtr node);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewTextChild         (xmlNodePtr parent,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocRawNode        (xmlDocPtr doc,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlNewDocFragment       (xmlDocPtr doc);
 #endif /* LIBXML_TREE_ENABLED */
 
 /*
  * Navigating.
  */
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                xmlGetLineNo            (const xmlNode *node);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlGetNodePath          (const xmlNode *node);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlDocGetRootElement    (const xmlDoc *doc);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlGetLastChild         (const xmlNode *parent);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlNodeIsText           (const xmlNode *node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsBlankNode          (const xmlNode *node);
 
 /*
  * Changing the structure.
  */
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlDocSetRootElement    (xmlDocPtr doc,
                                         xmlNodePtr root);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetName          (xmlNodePtr cur,
                                         const xmlChar *name);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlAddChild             (xmlNodePtr parent,
                                         xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlAddChildList         (xmlNodePtr parent,
                                         xmlNodePtr cur);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlReplaceNode          (xmlNodePtr old,
                                         xmlNodePtr cur);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
     defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlAddPrevSibling       (xmlNodePtr cur,
                                         xmlNodePtr elem);
 #endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlAddSibling           (xmlNodePtr cur,
                                         xmlNodePtr elem);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlAddNextSibling       (xmlNodePtr cur,
                                         xmlNodePtr elem);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlUnlinkNode           (xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlTextMerge            (xmlNodePtr first,
                                         xmlNodePtr second);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlTextConcat           (xmlNodePtr node,
                                         const xmlChar *content,
                                         int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeNodeList         (xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeNode             (xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetTreeDoc           (xmlNodePtr tree,
                                         xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetListDoc           (xmlNodePtr list,
                                         xmlDocPtr doc);
 /*
  * Namespaces.
  */
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlSearchNs             (xmlDocPtr doc,
                                         xmlNodePtr node,
                                         const xmlChar *nameSpace);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlSearchNsByHref       (xmlDocPtr doc,
                                         xmlNodePtr node,
                                         const xmlChar *href);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
     defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlNsPtr * XMLCALL
+XMLPUBFUN xmlNsPtr *
                xmlGetNsList            (const xmlDoc *doc,
                                         const xmlNode *node);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetNs                (xmlNodePtr node,
                                         xmlNsPtr ns);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlCopyNamespace        (xmlNsPtr cur);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr
                xmlCopyNamespaceList    (xmlNsPtr cur);
 
 /*
@@ -1012,94 +1048,94 @@ XMLPUBFUN xmlNsPtr XMLCALL
  */
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
     defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlSetProp              (xmlNodePtr node,
                                         const xmlChar *name,
                                         const xmlChar *value);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlSetNsProp            (xmlNodePtr node,
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *value);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
          defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlGetNoNsProp          (const xmlNode *node,
                                         const xmlChar *name);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlGetProp              (const xmlNode *node,
                                         const xmlChar *name);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlHasProp              (const xmlNode *node,
                                         const xmlChar *name);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlHasNsProp            (const xmlNode *node,
                                         const xmlChar *name,
                                         const xmlChar *nameSpace);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlGetNsProp            (const xmlNode *node,
                                         const xmlChar *name,
                                         const xmlChar *nameSpace);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlStringGetNodeList    (const xmlDoc *doc,
                                         const xmlChar *value);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                xmlStringLenGetNodeList (const xmlDoc *doc,
                                         const xmlChar *value,
                                         int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlNodeListGetString    (xmlDocPtr doc,
                                         const xmlNode *list,
                                         int inLine);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlNodeListGetRawString (const xmlDoc *doc,
                                         const xmlNode *list,
                                         int inLine);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetContent       (xmlNodePtr cur,
                                         const xmlChar *content);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetContentLen    (xmlNodePtr cur,
                                         const xmlChar *content,
                                         int len);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeAddContent       (xmlNodePtr cur,
                                         const xmlChar *content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeAddContentLen    (xmlNodePtr cur,
                                         const xmlChar *content,
                                         int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlNodeGetContent       (const xmlNode *cur);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlNodeBufGetContent    (xmlBufferPtr buffer,
                                         const xmlNode *cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlBufGetNodeContent    (xmlBufPtr buf,
                                         const xmlNode *cur);
 
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlNodeGetLang          (const xmlNode *cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlNodeGetSpacePreserve (const xmlNode *cur);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetLang          (xmlNodePtr cur,
                                         const xmlChar *lang);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetSpacePreserve (xmlNodePtr cur,
                                         int val);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlNodeGetBase          (const xmlDoc *doc,
                                         const xmlNode *cur);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeSetBase          (xmlNodePtr cur,
                                         const xmlChar *uri);
 #endif
@@ -1107,14 +1143,14 @@ XMLPUBFUN void XMLCALL
 /*
  * Removing content.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlRemoveProp           (xmlAttrPtr cur);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlUnsetNsProp          (xmlNodePtr node,
                                         xmlNsPtr ns,
                                         const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlUnsetProp            (xmlNodePtr node,
                                         const xmlChar *name);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
@@ -1122,13 +1158,13 @@ XMLPUBFUN int XMLCALL
 /*
  * Internal, don't use.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferWriteCHAR      (xmlBufferPtr buf,
                                         const xmlChar *string);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferWriteChar      (xmlBufferPtr buf,
                                         const char *string);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlBufferWriteQuotedString(xmlBufferPtr buf,
                                         const xmlChar *string);
 
@@ -1143,7 +1179,7 @@ XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,
 /*
  * Namespace handling.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReconciliateNs       (xmlDocPtr doc,
                                         xmlNodePtr tree);
 #endif
@@ -1152,67 +1188,67 @@ XMLPUBFUN int XMLCALL
 /*
  * Saving.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDocDumpFormatMemory  (xmlDocPtr cur,
                                         xmlChar **mem,
                                         int *size,
                                         int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDocDumpMemory        (xmlDocPtr cur,
                                         xmlChar **mem,
                                         int *size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDocDumpMemoryEnc     (xmlDocPtr out_doc,
                                         xmlChar **doc_txt_ptr,
                                         int * doc_txt_len,
                                         const char *txt_encoding);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
                                         xmlChar **doc_txt_ptr,
                                         int * doc_txt_len,
                                         const char *txt_encoding,
                                         int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlDocFormatDump        (FILE *f,
                                         xmlDocPtr cur,
                                         int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlDocDump              (FILE *f,
                                         xmlDocPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlElemDump             (FILE *f,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFile             (const char *filename,
                                         xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFormatFile       (const char *filename,
                                         xmlDocPtr cur,
                                         int format);
-XMLPUBFUN size_t XMLCALL
+XMLPUBFUN size_t
                xmlBufNodeDump          (xmlBufPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
                                         int level,
                                         int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlNodeDump             (xmlBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
                                         int level,
                                         int format);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFileTo           (xmlOutputBufferPtr buf,
                                         xmlDocPtr cur,
                                         const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFormatFileTo     (xmlOutputBufferPtr buf,
                                         xmlDocPtr cur,
                                         const char *encoding,
                                         int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlNodeDumpOutput       (xmlOutputBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,
@@ -1220,13 +1256,13 @@ XMLPUBFUN void XMLCALL
                                         int format,
                                         const char *encoding);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFormatFileEnc    (const char *filename,
                                         xmlDocPtr cur,
                                         const char *encoding,
                                         int format);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFileEnc          (const char *filename,
                                         xmlDocPtr cur,
                                         const char *encoding);
@@ -1235,47 +1271,47 @@ XMLPUBFUN int XMLCALL
 /*
  * XHTML
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsXHTML              (const xmlChar *systemID,
                                         const xmlChar *publicID);
 
 /*
  * Compression.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlGetDocCompressMode   (const xmlDoc *doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetDocCompressMode   (xmlDocPtr doc,
                                         int mode);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlGetCompressMode      (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSetCompressMode      (int mode);
 
 /*
 * DOM-wrapper helper functions.
 */
-XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL
+XMLPUBFUN xmlDOMWrapCtxtPtr
                xmlDOMWrapNewCtxt       (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDOMWrapFreeCtxt      (xmlDOMWrapCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt,
                                         xmlNodePtr elem,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlDOMWrapAdoptNode         (xmlDOMWrapCtxtPtr ctxt,
                                         xmlDocPtr sourceDoc,
                                         xmlNodePtr node,
                                         xmlDocPtr destDoc,
                                         xmlNodePtr destParent,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlDOMWrapRemoveNode        (xmlDOMWrapCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr node,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlDOMWrapCloneNode         (xmlDOMWrapCtxtPtr ctxt,
                                         xmlDocPtr sourceDoc,
                                         xmlNodePtr node,
@@ -1290,23 +1326,37 @@ XMLPUBFUN int XMLCALL
  * 5 interfaces from DOM ElementTraversal, but different in entities
  * traversal.
  */
-XMLPUBFUN unsigned long XMLCALL
+XMLPUBFUN unsigned long
             xmlChildElementCount        (xmlNodePtr parent);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
             xmlNextElementSibling       (xmlNodePtr node);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
             xmlFirstElementChild        (xmlNodePtr parent);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
             xmlLastElementChild         (xmlNodePtr parent);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
             xmlPreviousElementSibling   (xmlNodePtr node);
 #endif
+
+XMLPUBFUN xmlRegisterNodeFunc
+           xmlRegisterNodeDefault      (xmlRegisterNodeFunc func);
+XMLPUBFUN xmlDeregisterNodeFunc
+           xmlDeregisterNodeDefault    (xmlDeregisterNodeFunc func);
+XMLPUBFUN xmlRegisterNodeFunc
+            xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
+XMLPUBFUN xmlDeregisterNodeFunc
+            xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
+
+XML_DEPRECATED XMLPUBFUN xmlBufferAllocationScheme
+            xmlThrDefBufferAllocScheme  (xmlBufferAllocationScheme v);
+XML_DEPRECATED XMLPUBFUN int
+            xmlThrDefDefaultBufferSize  (int v);
+
 #ifdef __cplusplus
 }
 #endif
-#ifndef __XML_PARSER_H__
-#include <libxml/xmlmemory.h>
-#endif
 
 #endif /* __XML_TREE_H__ */
 
+#endif /* XML_TREE_INTERNALS */
+
index db48262..eb8631c 100644 (file)
@@ -11,8 +11,9 @@
 #ifndef __XML_URI_H__
 #define __XML_URI_H__
 
+#include <stdio.h>
 #include <libxml/xmlversion.h>
-#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,43 +50,43 @@ struct _xmlURI {
  * xmlChar *   xmlNodeGetBase  (xmlDocPtr doc,
  *                               xmlNodePtr cur);
  */
-XMLPUBFUN xmlURIPtr XMLCALL
+XMLPUBFUN xmlURIPtr
                xmlCreateURI            (void);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlBuildURI             (const xmlChar *URI,
                                         const xmlChar *base);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlBuildRelativeURI     (const xmlChar *URI,
                                         const xmlChar *base);
-XMLPUBFUN xmlURIPtr XMLCALL
+XMLPUBFUN xmlURIPtr
                xmlParseURI             (const char *str);
-XMLPUBFUN xmlURIPtr XMLCALL
+XMLPUBFUN xmlURIPtr
                xmlParseURIRaw          (const char *str,
                                         int raw);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlParseURIReference    (xmlURIPtr uri,
                                         const char *str);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlSaveUri              (xmlURIPtr uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlPrintURI             (FILE *stream,
                                         xmlURIPtr uri);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlURIEscapeStr         (const xmlChar *str,
                                         const xmlChar *list);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char *
                xmlURIUnescapeString    (const char *str,
                                         int len,
                                         char *target);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlNormalizeURIPath     (char *path);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlURIEscape            (const xmlChar *str);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeURI              (xmlURIPtr uri);
-XMLPUBFUN xmlChar* XMLCALL
+XMLPUBFUN xmlChar*
                xmlCanonicPath          (const xmlChar *path);
-XMLPUBFUN xmlChar* XMLCALL
+XMLPUBFUN xmlChar*
                xmlPathToURI            (const xmlChar *path);
 
 #ifdef __cplusplus
index 3eaf84a..3e04b55 100644 (file)
@@ -13,7 +13,9 @@
 
 #include <libxml/xmlversion.h>
 #include <libxml/xmlerror.h>
+#define XML_TREE_INTERNALS
 #include <libxml/tree.h>
+#undef XML_TREE_INTERNALS
 #include <libxml/list.h>
 #include <libxml/xmlautomata.h>
 #include <libxml/xmlregexp.h>
@@ -39,7 +41,7 @@ typedef xmlValidState *xmlValidStatePtr;
  * Callback called when a validity error is found. This is a message
  * oriented function similar to an *printf function.
  */
-typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
+typedef void (*xmlValidityErrorFunc) (void *ctx,
                             const char *msg,
                             ...) LIBXML_ATTR_FORMAT(2,3);
 
@@ -54,25 +56,10 @@ typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
  * Callback called when a validity warning is found. This is a message
  * oriented function similar to an *printf function.
  */
-typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
+typedef void (*xmlValidityWarningFunc) (void *ctx,
                               const char *msg,
                               ...) LIBXML_ATTR_FORMAT(2,3);
 
-#ifdef IN_LIBXML
-/**
- * XML_VCTXT_DTD_VALIDATED:
- *
- * Set after xmlValidateDtdFinal was called.
- */
-#define XML_VCTXT_DTD_VALIDATED (1u << 0)
-/**
- * XML_VCTXT_USE_PCTXT:
- *
- * Set if the validation context is part of a parser context.
- */
-#define XML_VCTXT_USE_PCTXT (1u << 1)
-#endif
-
 /*
  * xmlValidCtxt:
  * An xmlValidCtxt is used for error reporting when validating.
@@ -150,55 +137,55 @@ typedef struct _xmlHashTable xmlRefTable;
 typedef xmlRefTable *xmlRefTablePtr;
 
 /* Notation */
-XMLPUBFUN xmlNotationPtr XMLCALL
+XMLPUBFUN xmlNotationPtr
                xmlAddNotationDecl      (xmlValidCtxtPtr ctxt,
                                         xmlDtdPtr dtd,
                                         const xmlChar *name,
                                         const xmlChar *PublicID,
                                         const xmlChar *SystemID);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlNotationTablePtr XMLCALL
+XMLPUBFUN xmlNotationTablePtr
                xmlCopyNotationTable    (xmlNotationTablePtr table);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeNotationTable    (xmlNotationTablePtr table);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpNotationDecl     (xmlBufferPtr buf,
                                         xmlNotationPtr nota);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpNotationTable    (xmlBufferPtr buf,
                                         xmlNotationTablePtr table);
 #endif /* LIBXML_OUTPUT_ENABLED */
 
 /* Element Content */
 /* the non Doc version are being deprecated */
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr
                xmlNewElementContent    (const xmlChar *name,
                                         xmlElementContentType type);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr
                xmlCopyElementContent   (xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeElementContent   (xmlElementContentPtr cur);
 /* the new versions with doc argument */
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr
                xmlNewDocElementContent (xmlDocPtr doc,
                                         const xmlChar *name,
                                         xmlElementContentType type);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr
                xmlCopyDocElementContent(xmlDocPtr doc,
                                         xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeDocElementContent(xmlDocPtr doc,
                                         xmlElementContentPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSnprintfElementContent(char *buf,
                                         int size,
                                         xmlElementContentPtr content,
                                         int englob);
 #ifdef LIBXML_OUTPUT_ENABLED
 /* DEPRECATED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSprintfElementContent(char *buf,
                                         xmlElementContentPtr content,
                                         int englob);
@@ -206,39 +193,39 @@ XMLPUBFUN void XMLCALL
 /* DEPRECATED */
 
 /* Element */
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr
                xmlAddElementDecl       (xmlValidCtxtPtr ctxt,
                                         xmlDtdPtr dtd,
                                         const xmlChar *name,
                                         xmlElementTypeVal type,
                                         xmlElementContentPtr content);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlElementTablePtr XMLCALL
+XMLPUBFUN xmlElementTablePtr
                xmlCopyElementTable     (xmlElementTablePtr table);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeElementTable     (xmlElementTablePtr table);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpElementTable     (xmlBufferPtr buf,
                                         xmlElementTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpElementDecl      (xmlBufferPtr buf,
                                         xmlElementPtr elem);
 #endif /* LIBXML_OUTPUT_ENABLED */
 
 /* Enumeration */
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr
                xmlCreateEnumeration    (const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeEnumeration      (xmlEnumerationPtr cur);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr
                xmlCopyEnumeration      (xmlEnumerationPtr cur);
 #endif /* LIBXML_TREE_ENABLED */
 
 /* Attribute */
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr
                xmlAddAttributeDecl     (xmlValidCtxtPtr ctxt,
                                         xmlDtdPtr dtd,
                                         const xmlChar *elem,
@@ -249,60 +236,60 @@ XMLPUBFUN xmlAttributePtr XMLCALL
                                         const xmlChar *defaultValue,
                                         xmlEnumerationPtr tree);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlAttributeTablePtr XMLCALL
+XMLPUBFUN xmlAttributeTablePtr
                xmlCopyAttributeTable  (xmlAttributeTablePtr table);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeAttributeTable  (xmlAttributeTablePtr table);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpAttributeTable  (xmlBufferPtr buf,
                                        xmlAttributeTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlDumpAttributeDecl   (xmlBufferPtr buf,
                                        xmlAttributePtr attr);
 #endif /* LIBXML_OUTPUT_ENABLED */
 
 /* IDs */
-XMLPUBFUN xmlIDPtr XMLCALL
+XMLPUBFUN xmlIDPtr
                xmlAddID               (xmlValidCtxtPtr ctxt,
                                        xmlDocPtr doc,
                                        const xmlChar *value,
                                        xmlAttrPtr attr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeIDTable         (xmlIDTablePtr table);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr
                xmlGetID               (xmlDocPtr doc,
                                        const xmlChar *ID);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsID                (xmlDocPtr doc,
                                        xmlNodePtr elem,
                                        xmlAttrPtr attr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlRemoveID            (xmlDocPtr doc,
                                        xmlAttrPtr attr);
 
 /* IDREFs */
 XML_DEPRECATED
-XMLPUBFUN xmlRefPtr XMLCALL
+XMLPUBFUN xmlRefPtr
                xmlAddRef              (xmlValidCtxtPtr ctxt,
                                        xmlDocPtr doc,
                                        const xmlChar *value,
                                        xmlAttrPtr attr);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeRefTable        (xmlRefTablePtr table);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsRef               (xmlDocPtr doc,
                                        xmlNodePtr elem,
                                        xmlAttrPtr attr);
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlRemoveRef           (xmlDocPtr doc,
                                        xmlAttrPtr attr);
 XML_DEPRECATED
-XMLPUBFUN xmlListPtr XMLCALL
+XMLPUBFUN xmlListPtr
                xmlGetRefs             (xmlDocPtr doc,
                                        const xmlChar *ID);
 
@@ -311,146 +298,146 @@ XMLPUBFUN xmlListPtr XMLCALL
  */
 #ifdef LIBXML_VALID_ENABLED
 /* Allocate/Release Validation Contexts */
-XMLPUBFUN xmlValidCtxtPtr XMLCALL
+XMLPUBFUN xmlValidCtxtPtr
                xmlNewValidCtxt(void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlFreeValidCtxt(xmlValidCtxtPtr);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateRoot         (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateElementDecl  (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlElementPtr elem);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlValidNormalizeAttributeValue(xmlDocPtr doc,
                                         xmlNodePtr elem,
                                         const xmlChar *name,
                                         const xmlChar *value);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem,
                                         const xmlChar *name,
                                         const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlAttributePtr attr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateAttributeValue(xmlAttributeType type,
                                         const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNotationPtr nota);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateDtd          (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlDtdPtr dtd);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateDtdFinal     (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateDocument     (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateElement      (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateOneElement   (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr     elem,
                                         xmlAttrPtr attr,
                                         const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem,
                                         const xmlChar *prefix,
                                         xmlNsPtr ns,
                                         const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc);
 #endif /* LIBXML_VALID_ENABLED */
 
 #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNotationUse  (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         const xmlChar *notationName);
 #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlIsMixedElement       (xmlDocPtr doc,
                                         const xmlChar *name);
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr
                xmlGetDtdAttrDesc       (xmlDtdPtr dtd,
                                         const xmlChar *elem,
                                         const xmlChar *name);
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr
                xmlGetDtdQAttrDesc      (xmlDtdPtr dtd,
                                         const xmlChar *elem,
                                         const xmlChar *name,
                                         const xmlChar *prefix);
-XMLPUBFUN xmlNotationPtr XMLCALL
+XMLPUBFUN xmlNotationPtr
                xmlGetDtdNotationDesc   (xmlDtdPtr dtd,
                                         const xmlChar *name);
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr
                xmlGetDtdQElementDesc   (xmlDtdPtr dtd,
                                         const xmlChar *name,
                                         const xmlChar *prefix);
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr
                xmlGetDtdElementDesc    (xmlDtdPtr dtd,
                                         const xmlChar *name);
 
 #ifdef LIBXML_VALID_ENABLED
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidGetPotentialChildren(xmlElementContent *ctree,
                                         const xmlChar **names,
                                         int *len,
                                         int max);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidGetValidElements(xmlNode *prev,
                                         xmlNode *next,
                                         const xmlChar **names,
                                         int max);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNameValue    (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNamesValue   (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNmtokenValue (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidateNmtokensValue(const xmlChar *value);
 
 #ifdef LIBXML_REGEXP_ENABLED
 /*
  * Validation based on the regexp support
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
                                         xmlElementPtr elem);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidatePushElement  (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem,
                                         const xmlChar *qname);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidatePushCData    (xmlValidCtxtPtr ctxt,
                                         const xmlChar *data,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlValidatePopElement   (xmlValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem,
index 863ab25..e1d135b 100644 (file)
@@ -89,35 +89,35 @@ typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
 /*
  * standalone processing
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcess      (xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcessFlags (xmlDocPtr doc,
                                         int flags);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcessFlagsData(xmlDocPtr doc,
                                         int flags,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,
                                          int flags,
                                          void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcessTree  (xmlNodePtr tree);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
                                         int flags);
 /*
  * contextual processing
  */
-XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL
+XMLPUBFUN xmlXIncludeCtxtPtr
                xmlXIncludeNewContext   (xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeSetFlags     (xmlXIncludeCtxtPtr ctxt,
                                         int flags);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXIncludeFreeContext  (xmlXIncludeCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXIncludeProcessNode  (xmlXIncludeCtxtPtr ctxt,
                                         xmlNodePtr tree);
 #ifdef __cplusplus
index 04e4b32..1065736 100644 (file)
@@ -160,23 +160,23 @@ struct _xlinkHandler {
  * detection callbacks.
  */
 
-XMLPUBFUN xlinkNodeDetectFunc XMLCALL
+XMLPUBFUN xlinkNodeDetectFunc
                xlinkGetDefaultDetect   (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xlinkSetDefaultDetect   (xlinkNodeDetectFunc func);
 
 /*
  * Routines to set/get the default handlers.
  */
-XMLPUBFUN xlinkHandlerPtr XMLCALL
+XMLPUBFUN xlinkHandlerPtr
                xlinkGetDefaultHandler  (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xlinkSetDefaultHandler  (xlinkHandlerPtr handler);
 
 /*
  * Link detection module itself.
  */
-XMLPUBFUN xlinkType XMLCALL
+XMLPUBFUN xlinkType
                xlinkIsLink             (xmlDocPtr doc,
                                         xmlNodePtr node);
 
index 095b2f5..2487be3 100644 (file)
 
 #include <stdio.h>
 #include <libxml/xmlversion.h>
+#include <libxml/encoding.h>
+#define XML_TREE_INTERNALS
+#include <libxml/tree.h>
+#undef XML_TREE_INTERNALS
 
 #ifdef __cplusplus
 extern "C" {
@@ -31,7 +35,7 @@ extern "C" {
  *
  * Returns 1 if yes and 0 if another Input module should be used
  */
-typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
+typedef int (*xmlInputMatchCallback) (char const *filename);
 /**
  * xmlInputOpenCallback:
  * @filename: the filename or URI
@@ -40,7 +44,7 @@ typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
  *
  * Returns an Input context or NULL in case or error
  */
-typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
+typedef void * (*xmlInputOpenCallback) (char const *filename);
 /**
  * xmlInputReadCallback:
  * @context:  an Input context
@@ -51,7 +55,7 @@ typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
  *
  * Returns the number of bytes read or -1 in case of error
  */
-typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);
+typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
 /**
  * xmlInputCloseCallback:
  * @context:  an Input context
@@ -60,7 +64,7 @@ typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int
  *
  * Returns 0 or -1 in case of error
  */
-typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
+typedef int (*xmlInputCloseCallback) (void * context);
 
 #ifdef LIBXML_OUTPUT_ENABLED
 /*
@@ -77,7 +81,7 @@ typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
  *
  * Returns 1 if yes and 0 if another Output module should be used
  */
-typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
+typedef int (*xmlOutputMatchCallback) (char const *filename);
 /**
  * xmlOutputOpenCallback:
  * @filename: the filename or URI
@@ -86,7 +90,7 @@ typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
  *
  * Returns an Output context or NULL in case or error
  */
-typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
+typedef void * (*xmlOutputOpenCallback) (char const *filename);
 /**
  * xmlOutputWriteCallback:
  * @context:  an Output context
@@ -97,7 +101,7 @@ typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
  *
  * Returns the number of bytes written or -1 in case of error
  */
-typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,
+typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
                                        int len);
 /**
  * xmlOutputCloseCallback:
@@ -107,21 +111,38 @@ typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buff
  *
  * Returns 0 or -1 in case of error
  */
-typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);
+typedef int (*xmlOutputCloseCallback) (void * context);
 #endif /* LIBXML_OUTPUT_ENABLED */
 
-#ifdef __cplusplus
-}
-#endif
+/**
+ * xmlParserInputBufferCreateFilenameFunc:
+ * @URI: the URI to read from
+ * @enc: the requested source encoding
+ *
+ * Signature for the function doing the lookup for a suitable input method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
+ *         method was found.
+ */
+typedef xmlParserInputBufferPtr
+(*xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc);
 
-#include <libxml/globals.h>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/encoding.h>
+/**
+ * xmlOutputBufferCreateFilenameFunc:
+ * @URI: the URI to write to
+ * @enc: the requested target encoding
+ *
+ * Signature for the function doing the lookup for a suitable output method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlOutputBufferPtr in case of success or NULL if no
+ *         method was found.
+ */
+typedef xmlOutputBufferPtr
+(*xmlOutputBufferCreateFilenameFunc)(const char *URI,
+        xmlCharEncodingHandlerPtr encoder, int compression);
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 struct _xmlParserInputBuffer {
     void*                  context;
     xmlInputReadCallback   readcallback;
@@ -152,56 +173,75 @@ struct _xmlOutputBuffer {
 };
 #endif /* LIBXML_OUTPUT_ENABLED */
 
+/** DOC_DISABLE */
+#define XML_GLOBALS_IO \
+  XML_OP(xmlParserInputBufferCreateFilenameValue, \
+           xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
+  XML_OP(xmlOutputBufferCreateFilenameValue, \
+           xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
+
+#define XML_OP XML_DECLARE_GLOBAL
+XML_GLOBALS_IO
+#undef XML_OP
+
+#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+  #define xmlParserInputBufferCreateFilenameValue \
+    XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
+  #define xmlOutputBufferCreateFilenameValue \
+    XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
+#endif
+/** DOC_ENABLE */
+
 /*
  * Interfaces for input
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlCleanupInputCallbacks                (void);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlPopInputCallbacks                    (void);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlRegisterDefaultInputCallbacks        (void);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlAllocParserInputBuffer               (xmlCharEncoding enc);
 
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateFilename      (const char *URI,
                                                  xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateFile          (FILE *file,
                                                  xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateFd            (int fd,
                                                 xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateMem           (const char *mem, int size,
                                                 xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateStatic        (const char *mem, int size,
                                                 xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
        xmlParserInputBufferCreateIO            (xmlInputReadCallback   ioread,
                                                 xmlInputCloseCallback  ioclose,
                                                 void *ioctx,
                                                 xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlParserInputBufferRead                (xmlParserInputBufferPtr in,
                                                 int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlParserInputBufferGrow                (xmlParserInputBufferPtr in,
                                                 int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlParserInputBufferPush                (xmlParserInputBufferPtr in,
                                                 int len,
                                                 const char *buf);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlFreeParserInputBuffer                (xmlParserInputBufferPtr in);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char *
        xmlParserGetDirectory                   (const char *filename);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlRegisterInputCallbacks               (xmlInputMatchCallback matchFunc,
                                                 xmlInputOpenCallback openFunc,
                                                 xmlInputReadCallback readFunc,
@@ -215,62 +255,62 @@ xmlParserInputBufferPtr
 /*
  * Interfaces for output
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlCleanupOutputCallbacks               (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlPopOutputCallbacks                   (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlRegisterDefaultOutputCallbacks(void);
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlAllocOutputBuffer            (xmlCharEncodingHandlerPtr encoder);
 
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlOutputBufferCreateFilename   (const char *URI,
                                         xmlCharEncodingHandlerPtr encoder,
                                         int compression);
 
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlOutputBufferCreateFile       (FILE *file,
                                         xmlCharEncodingHandlerPtr encoder);
 
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlOutputBufferCreateBuffer     (xmlBufferPtr buffer,
                                         xmlCharEncodingHandlerPtr encoder);
 
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlOutputBufferCreateFd         (int fd,
                                         xmlCharEncodingHandlerPtr encoder);
 
-XMLPUBFUN xmlOutputBufferPtr XMLCALL
+XMLPUBFUN xmlOutputBufferPtr
        xmlOutputBufferCreateIO         (xmlOutputWriteCallback   iowrite,
                                         xmlOutputCloseCallback  ioclose,
                                         void *ioctx,
                                         xmlCharEncodingHandlerPtr encoder);
 
 /* Couple of APIs to get the output without digging into the buffers */
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
         xmlOutputBufferGetContent       (xmlOutputBufferPtr out);
-XMLPUBFUN size_t XMLCALL
+XMLPUBFUN size_t
         xmlOutputBufferGetSize          (xmlOutputBufferPtr out);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlOutputBufferWrite            (xmlOutputBufferPtr out,
                                         int len,
                                         const char *buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlOutputBufferWriteString      (xmlOutputBufferPtr out,
                                         const char *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlOutputBufferWriteEscape      (xmlOutputBufferPtr out,
                                         const xmlChar *str,
                                         xmlCharEncodingOutputFunc escaping);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlOutputBufferFlush            (xmlOutputBufferPtr out);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlOutputBufferClose            (xmlOutputBufferPtr out);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlRegisterOutputCallbacks      (xmlOutputMatchCallback matchFunc,
                                         xmlOutputOpenCallback openFunc,
                                         xmlOutputWriteCallback writeFunc,
@@ -283,20 +323,20 @@ xmlOutputBufferPtr
 
 #ifdef LIBXML_HTTP_ENABLED
 /*  This function only exists if HTTP support built into the library  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlRegisterHTTPPostCallbacks    (void );
 #endif /* LIBXML_HTTP_ENABLED */
 
 #endif /* LIBXML_OUTPUT_ENABLED */
 
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
        xmlCheckHTTPInput               (xmlParserCtxtPtr ctxt,
                                         xmlParserInputPtr ret);
 
 /*
  * A predefined entity loader disabling network accesses
  */
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr
        xmlNoNetExternalEntityLoader    (const char *URL,
                                         const char *ID,
                                         xmlParserCtxtPtr ctxt);
@@ -305,61 +345,74 @@ XMLPUBFUN xmlParserInputPtr XMLCALL
  * xmlNormalizeWindowsPath is obsolete, don't use it.
  * Check xmlCanonicPath in uri.h for a better alternative.
  */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
        xmlNormalizeWindowsPath         (const xmlChar *path);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlCheckFilename                (const char *path);
 /**
  * Default 'file://' protocol callbacks
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlFileMatch                    (const char *filename);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlFileOpen                     (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlFileRead                     (void * context,
                                         char * buffer,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlFileClose                    (void * context);
 
 /**
  * Default 'http://' protocol callbacks
  */
 #ifdef LIBXML_HTTP_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlIOHTTPMatch                  (const char *filename);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlIOHTTPOpen                   (const char *filename);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlIOHTTPOpenW                  (const char * post_uri,
                                         int   compression );
 #endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlIOHTTPRead                   (void * context,
                                         char * buffer,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlIOHTTPClose                  (void * context);
 #endif /* LIBXML_HTTP_ENABLED */
 
 /**
  * Default 'ftp://' protocol callbacks
  */
-#ifdef LIBXML_FTP_ENABLED
-XMLPUBFUN int XMLCALL
+#if defined(LIBXML_FTP_ENABLED)
+XMLPUBFUN int
        xmlIOFTPMatch                   (const char *filename);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlIOFTPOpen                    (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlIOFTPRead                    (void * context,
                                         char * buffer,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlIOFTPClose                   (void * context);
-#endif /* LIBXML_FTP_ENABLED */
+#endif /* defined(LIBXML_FTP_ENABLED) */
+
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
+       xmlParserInputBufferCreateFilenameDefault(
+               xmlParserInputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc
+       xmlOutputBufferCreateFilenameDefault(
+               xmlOutputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc
+       xmlThrDefOutputBufferCreateFilenameDefault(
+               xmlOutputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
+       xmlThrDefParserInputBufferCreateFilenameDefault(
+               xmlParserInputBufferCreateFilenameFunc func);
 
 #ifdef __cplusplus
 }
index bf1b131..ea38eb3 100644 (file)
 #define __XML_AUTOMATA_H__
 
 #include <libxml/xmlversion.h>
-#include <libxml/tree.h>
 
 #ifdef LIBXML_REGEXP_ENABLED
 #ifdef LIBXML_AUTOMATA_ENABLED
-#include <libxml/xmlregexp.h>
+
+#include <libxml/xmlstring.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -40,32 +40,32 @@ typedef xmlAutomataState *xmlAutomataStatePtr;
 /*
  * Building API
  */
-XMLPUBFUN xmlAutomataPtr XMLCALL
+XMLPUBFUN xmlAutomataPtr
                    xmlNewAutomata              (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlFreeAutomata             (xmlAutomataPtr am);
 
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataGetInitState     (xmlAutomataPtr am);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlAutomataSetFinalState    (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr state);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewState         (xmlAutomataPtr am);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewTransition    (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewTransition2   (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 const xmlChar *token2,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                     xmlAutomataNewNegTrans     (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
@@ -73,7 +73,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
                                                 const xmlChar *token2,
                                                 void *data);
 
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewCountTrans    (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
@@ -81,7 +81,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
                                                 int min,
                                                 int max,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewCountTrans2   (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
@@ -90,7 +90,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
                                                 int min,
                                                 int max,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewOnceTrans     (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
@@ -98,7 +98,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
                                                 int min,
                                                 int max,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewOnceTrans2    (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
@@ -107,33 +107,33 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
                                                 int min,
                                                 int max,
                                                 void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewAllTrans      (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int lax);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewEpsilon       (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewCountedTrans  (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr
                    xmlAutomataNewCounterTrans  (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlAutomataNewCounter       (xmlAutomataPtr am,
                                                 int min,
                                                 int max);
 
-XMLPUBFUN xmlRegexpPtr XMLCALL
+XMLPUBFUN struct _xmlRegexp *
                    xmlAutomataCompile          (xmlAutomataPtr am);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlAutomataIsDeterminist    (xmlAutomataPtr am);
 
 #ifdef __cplusplus
index ee95be9..1f0ab4a 100644 (file)
@@ -7,11 +7,11 @@
  * Author: Daniel Veillard
  */
 
-#include <libxml/parser.h>
-
 #ifndef __XML_ERROR_H__
 #define __XML_ERROR_H__
 
+#include <libxml/xmlversion.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -210,6 +210,7 @@ typedef enum {
     XML_ERR_NAME_TOO_LONG, /* 110 */
     XML_ERR_USER_STOP, /* 111 */
     XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */
+    XML_WAR_ENCODING_MISMATCH, /* 113 */
     XML_NS_ERR_XML_NAMESPACE = 200,
     XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
     XML_NS_ERR_QNAME, /* 202 */
@@ -844,7 +845,7 @@ typedef enum {
  * Signature of the function to use when there is an error and
  * no parsing or validity context available .
  */
-typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx,
+typedef void (*xmlGenericErrorFunc) (void *ctx,
                                 const char *msg,
                                 ...) LIBXML_ATTR_FORMAT(2,3);
 /**
@@ -855,92 +856,92 @@ typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx,
  * Signature of the function to use when there is an error and
  * the module handles the new error reporting mechanism.
  */
-typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);
+typedef void (*xmlStructuredErrorFunc) (void *userData, const xmlError *error);
+
+/** DOC_DISABLE */
+#define XML_GLOBALS_ERROR \
+  XML_OP(xmlLastError, xmlError, XML_DEPRECATED) \
+  XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_NO_ATTR) \
+  XML_OP(xmlGenericErrorContext, void *, XML_NO_ATTR) \
+  XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_NO_ATTR) \
+  XML_OP(xmlStructuredErrorContext, void *, XML_NO_ATTR)
+
+#define XML_OP XML_DECLARE_GLOBAL
+XML_GLOBALS_ERROR
+#undef XML_OP
+
+#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+  #define xmlLastError XML_GLOBAL_MACRO(xmlLastError)
+  #define xmlGenericError XML_GLOBAL_MACRO(xmlGenericError)
+  #define xmlGenericErrorContext XML_GLOBAL_MACRO(xmlGenericErrorContext)
+  #define xmlStructuredError XML_GLOBAL_MACRO(xmlStructuredError)
+  #define xmlStructuredErrorContext XML_GLOBAL_MACRO(xmlStructuredErrorContext)
+#endif
+/** DOC_ENABLE */
 
 /*
  * Use the following function to reset the two global variables
  * xmlGenericError and xmlGenericErrorContext.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
     xmlSetGenericErrorFunc     (void *ctx,
                                 xmlGenericErrorFunc handler);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
+    xmlThrDefSetGenericErrorFunc(void *ctx,
+                                 xmlGenericErrorFunc handler);
+XML_DEPRECATED
+XMLPUBFUN void
     initGenericErrorDefaultFunc        (xmlGenericErrorFunc *handler);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
     xmlSetStructuredErrorFunc  (void *ctx,
                                 xmlStructuredErrorFunc handler);
+XMLPUBFUN void
+    xmlThrDefSetStructuredErrorFunc(void *ctx,
+                                 xmlStructuredErrorFunc handler);
 /*
  * Default message routines used by SAX and Valid context for error
  * and warning reporting.
  */
-XMLPUBFUN void XMLCDECL
+XMLPUBFUN void
     xmlParserError             (void *ctx,
                                 const char *msg,
                                 ...) LIBXML_ATTR_FORMAT(2,3);
-XMLPUBFUN void XMLCDECL
+XMLPUBFUN void
     xmlParserWarning           (void *ctx,
                                 const char *msg,
                                 ...) LIBXML_ATTR_FORMAT(2,3);
-XMLPUBFUN void XMLCDECL
+XMLPUBFUN void
     xmlParserValidityError     (void *ctx,
                                 const char *msg,
                                 ...) LIBXML_ATTR_FORMAT(2,3);
-XMLPUBFUN void XMLCDECL
+XMLPUBFUN void
     xmlParserValidityWarning   (void *ctx,
                                 const char *msg,
                                 ...) LIBXML_ATTR_FORMAT(2,3);
-XMLPUBFUN void XMLCALL
-    xmlParserPrintFileInfo     (xmlParserInputPtr input);
-XMLPUBFUN void XMLCALL
-    xmlParserPrintFileContext  (xmlParserInputPtr input);
+struct _xmlParserInput;
+XMLPUBFUN void
+    xmlParserPrintFileInfo     (struct _xmlParserInput *input);
+XMLPUBFUN void
+    xmlParserPrintFileContext  (struct _xmlParserInput *input);
 
 /*
  * Extended error information routines
  */
-XMLPUBFUN xmlErrorPtr XMLCALL
+XMLPUBFUN const xmlError *
     xmlGetLastError            (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
     xmlResetLastError          (void);
-XMLPUBFUN xmlErrorPtr XMLCALL
+XMLPUBFUN const xmlError *
     xmlCtxtGetLastError                (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
     xmlCtxtResetLastError      (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
     xmlResetError              (xmlErrorPtr err);
-XMLPUBFUN int XMLCALL
-    xmlCopyError               (xmlErrorPtr from,
+XMLPUBFUN int
+    xmlCopyError               (const xmlError *from,
                                 xmlErrorPtr to);
 
-#ifdef IN_LIBXML
-/*
- * Internal callback reporting routine
- */
-XMLPUBFUN void XMLCALL
-    __xmlRaiseError            (xmlStructuredErrorFunc schannel,
-                                xmlGenericErrorFunc channel,
-                                void *data,
-                                 void *ctx,
-                                void *node,
-                                int domain,
-                                int code,
-                                xmlErrorLevel level,
-                                const char *file,
-                                int line,
-                                const char *str1,
-                                const char *str2,
-                                const char *str3,
-                                int int1,
-                                int col,
-                                const char *msg,
-                                ...) LIBXML_ATTR_FORMAT(16,17);
-XMLPUBFUN void XMLCALL
-    __xmlSimpleError           (int domain,
-                                int code,
-                                xmlNodePtr node,
-                                const char *msg,
-                                const char *extra) LIBXML_ATTR_FORMAT(4,0);
-#endif
 #ifdef __cplusplus
 }
 #endif
index aceede5..3b063e7 100644 (file)
@@ -8,50 +8,19 @@
 #ifndef __XML_EXPORTS_H__
 #define __XML_EXPORTS_H__
 
-#if defined(_WIN32) || defined(__CYGWIN__)
 /** DOC_DISABLE */
-
-#ifdef LIBXML_STATIC
-  #define XMLPUBLIC
-#elif defined(IN_LIBXML)
-  #define XMLPUBLIC __declspec(dllexport)
-#else
-  #define XMLPUBLIC __declspec(dllimport)
-#endif
-
-#if defined(LIBXML_FASTCALL)
-  #define XMLCALL __fastcall
-#else
-  #define XMLCALL __cdecl
-#endif
-#define XMLCDECL __cdecl
-
-/** DOC_ENABLE */
+#if defined(_WIN32) || defined(__CYGWIN__)
+  #ifdef LIBXML_STATIC
+    #define XMLPUBLIC
+  #elif defined(IN_LIBXML)
+    #define XMLPUBLIC __declspec(dllexport)
+  #else
+    #define XMLPUBLIC __declspec(dllimport)
+  #endif
 #else /* not Windows */
-
-/**
- * XMLPUBLIC:
- *
- * Macro which declares a public symbol
- */
-#define XMLPUBLIC
-
-/**
- * XMLCALL:
- *
- * Macro which declares the calling convention for exported functions
- */
-#define XMLCALL
-
-/**
- * XMLCDECL:
- *
- * Macro which declares the calling convention for exported functions that
- * use '...'.
- */
-#define XMLCDECL
-
+  #define XMLPUBLIC
 #endif /* platform switch */
+/** DOC_ENABLE */
 
 /*
  * XMLPUBFUN:
  */
 #define XMLPUBVAR XMLPUBLIC extern
 
+/** DOC_DISABLE */
 /* Compatibility */
+#define XMLCALL
+#define XMLCDECL
 #if !defined(LIBXML_DLL_IMPORT)
 #define LIBXML_DLL_IMPORT XMLPUBVAR
 #endif
+/** DOC_ENABLE */
 
 #endif /* __XML_EXPORTS_H__ */
 
index ae2a427..097e3c8 100644 (file)
 #include <stdio.h>
 #include <libxml/xmlversion.h>
 
-/**
- * DEBUG_MEMORY:
- *
- * DEBUG_MEMORY replaces the allocator with a collect and debug
- * shell to the libc allocator.
- * DEBUG_MEMORY should only be activated when debugging
- * libxml i.e. if libxml has been configured with --with-debug-mem too.
- */
-/* #define DEBUG_MEMORY_FREED */
-/* #define DEBUG_MEMORY_LOCATION */
-
-#ifdef DEBUG
-#ifndef DEBUG_MEMORY
-#define DEBUG_MEMORY
-#endif
-#endif
-
-/**
- * DEBUG_MEMORY_LOCATION:
- *
- * DEBUG_MEMORY_LOCATION should be activated only when debugging
- * libxml i.e. if libxml has been configured with --with-debug-mem too.
- */
-#ifdef DEBUG_MEMORY_LOCATION
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -54,7 +28,7 @@ extern "C" {
  *
  * Signature for a free() implementation.
  */
-typedef void (XMLCALL *xmlFreeFunc)(void *mem);
+typedef void (*xmlFreeFunc)(void *mem);
 /**
  * xmlMallocFunc:
  * @size:  the size requested in bytes
@@ -63,7 +37,7 @@ typedef void (XMLCALL *xmlFreeFunc)(void *mem);
  *
  * Returns a pointer to the newly allocated block or NULL in case of error.
  */
-typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size);
+typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) *xmlMallocFunc)(size_t size);
 
 /**
  * xmlReallocFunc:
@@ -74,7 +48,7 @@ typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size);
  *
  * Returns a pointer to the newly reallocated block or NULL in case of error.
  */
-typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size);
+typedef void *(*xmlReallocFunc)(void *mem, size_t size);
 
 /**
  * xmlStrdupFunc:
@@ -84,39 +58,67 @@ typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size);
  *
  * Returns the copy of the string or NULL in case of error.
  */
-typedef char *(XMLCALL *xmlStrdupFunc)(const char *str);
+typedef char *(*xmlStrdupFunc)(const char *str);
 
 /*
- * The 4 interfaces used for all memory handling within libxml.
-LIBXML_DLL_IMPORT xmlFreeFunc xmlFree;
-LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;
-LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;
-LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;
-LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;
- */
+ * In general the memory allocation entry points are not kept
+ * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
+ *    - xmlMalloc
+ *    - xmlMallocAtomic
+ *    - xmlRealloc
+ *    - xmlMemStrdup
+ *    - xmlFree
+ */
+/** DOC_DISABLE */
+#ifdef LIBXML_THREAD_ALLOC_ENABLED
+  #define XML_GLOBALS_ALLOC \
+    XML_OP(xmlMalloc, xmlMallocFunc, XML_NO_ATTR) \
+    XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_NO_ATTR) \
+    XML_OP(xmlRealloc, xmlReallocFunc, XML_NO_ATTR) \
+    XML_OP(xmlFree, xmlFreeFunc, XML_NO_ATTR) \
+    XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_NO_ATTR)
+  #define XML_OP XML_DECLARE_GLOBAL
+    XML_GLOBALS_ALLOC
+  #undef XML_OP
+  #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
+    #define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
+    #define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
+    #define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
+    #define xmlFree XML_GLOBAL_MACRO(xmlFree)
+    #define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
+  #endif
+#else
+  #define XML_GLOBALS_ALLOC
+/** DOC_ENABLE */
+  XMLPUBVAR xmlMallocFunc xmlMalloc;
+  XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
+  XMLPUBVAR xmlReallocFunc xmlRealloc;
+  XMLPUBVAR xmlFreeFunc xmlFree;
+  XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
+#endif
 
 /*
  * The way to overload the existing functions.
  * The xmlGc function have an extra entry for atomic block
  * allocations useful for garbage collected memory allocators
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlMemSetup     (xmlFreeFunc freeFunc,
                         xmlMallocFunc mallocFunc,
                         xmlReallocFunc reallocFunc,
                         xmlStrdupFunc strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlMemGet       (xmlFreeFunc *freeFunc,
                         xmlMallocFunc *mallocFunc,
                         xmlReallocFunc *reallocFunc,
                         xmlStrdupFunc *strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlGcMemSetup   (xmlFreeFunc freeFunc,
                         xmlMallocFunc mallocFunc,
                         xmlMallocFunc mallocAtomicFunc,
                         xmlReallocFunc reallocFunc,
                         xmlStrdupFunc strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlGcMemGet     (xmlFreeFunc *freeFunc,
                         xmlMallocFunc *mallocFunc,
                         xmlMallocFunc *mallocAtomicFunc,
@@ -127,48 +129,51 @@ XMLPUBFUN int XMLCALL
  * Initialization of the memory layer.
  */
 XML_DEPRECATED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlInitMemory   (void);
 
 /*
  * Cleanup of the memory layer.
  */
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                 xmlCleanupMemory        (void);
 /*
  * These are specific to the XML debug memory wrapper.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN size_t
+       xmlMemSize      (void *ptr);
+XMLPUBFUN int
        xmlMemUsed      (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
        xmlMemBlocks    (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlMemDisplay   (FILE *fp);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlMemDisplayLast(FILE *fp, long nbBytes);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlMemShow      (FILE *fp, int nr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlMemoryDump   (void);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlMemMalloc    (size_t size) LIBXML_ATTR_ALLOC_SIZE(1);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlMemRealloc   (void *ptr,size_t size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlMemFree      (void *ptr);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char *
        xmlMemoryStrdup (const char *str);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlMallocLoc    (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlReallocLoc   (void *ptr, size_t size, const char *file, int line);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
        xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char *
        xmlMemStrdupLoc (const char *str, const char *file, int line);
 
 
+/** DOC_DISABLE */
 #ifdef DEBUG_MEMORY_LOCATION
 /**
  * xmlMalloc:
@@ -210,17 +215,11 @@ XMLPUBFUN char * XMLCALL
 #define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
 
 #endif /* DEBUG_MEMORY_LOCATION */
+/** DOC_ENABLE */
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#ifndef __XML_GLOBALS_H
-#ifndef __XML_THREADS_H__
-#include <libxml/threads.h>
-#include <libxml/globals.h>
-#endif
-#endif
-
 #endif  /* __DEBUG_MEMORY_ALLOC__ */
 
index 9667820..279986c 100644 (file)
@@ -37,16 +37,16 @@ typedef enum {
     XML_MODULE_LOCAL= 2                /* local binding */
 } xmlModuleOption;
 
-XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen   (const char *filename,
+XMLPUBFUN xmlModulePtr xmlModuleOpen   (const char *filename,
                                                 int options);
 
-XMLPUBFUN int XMLCALL xmlModuleSymbol          (xmlModulePtr module,
+XMLPUBFUN int xmlModuleSymbol          (xmlModulePtr module,
                                                 const char* name,
                                                 void **result);
 
-XMLPUBFUN int XMLCALL xmlModuleClose           (xmlModulePtr module);
+XMLPUBFUN int xmlModuleClose           (xmlModulePtr module);
 
-XMLPUBFUN int XMLCALL xmlModuleFree            (xmlModulePtr module);
+XMLPUBFUN int xmlModuleFree            (xmlModulePtr module);
 
 #ifdef __cplusplus
 }
index e8a8bcc..b9f6989 100644 (file)
 
 #include <libxml/xmlversion.h>
 #include <libxml/tree.h>
+#include <libxml/xmlerror.h>
 #include <libxml/xmlIO.h>
 #ifdef LIBXML_SCHEMAS_ENABLED
 #include <libxml/relaxng.h>
 #include <libxml/xmlschemas.h>
 #endif
+/* for compatibility */
+#include <libxml/parser.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -108,239 +111,242 @@ typedef xmlTextReader *xmlTextReaderPtr;
 /*
  * Constructors & Destructor
  */
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                        xmlNewTextReader        (xmlParserInputBufferPtr input,
                                                 const char *URI);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                        xmlNewTextReaderFilename(const char *URI);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlFreeTextReader       (xmlTextReaderPtr reader);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlTextReaderSetup(xmlTextReaderPtr reader,
                    xmlParserInputBufferPtr input, const char *URL,
                    const char *encoding, int options);
+XMLPUBFUN void
+            xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,
+                   unsigned maxAmpl);
 
 /*
  * Iterators
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderRead       (xmlTextReaderPtr reader);
 
 #ifdef LIBXML_WRITER_ENABLED
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
 
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
 #endif
 
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderReadString (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
 
 /*
  * Attributes of the node
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderDepth      (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderHasValue(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderIsDefault  (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderNodeType   (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderQuoteChar  (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlTextReaderReadState  (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                         xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
 
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstBaseUri   (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstName      (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstPrefix    (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstXmlLang   (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstString    (xmlTextReaderPtr reader,
                                                 const xmlChar *str);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstValue     (xmlTextReaderPtr reader);
 
 /*
  * use the Const version of the routine for
  * better performance and simpler code
  */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderBaseUri    (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderLocalName  (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderName       (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderPrefix     (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderXmlLang    (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                        xmlTextReaderValue      (xmlTextReaderPtr reader);
 
 /*
  * Methods of the XmlTextReader
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderClose          (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
                                                 int no);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlTextReaderGetAttribute   (xmlTextReaderPtr reader,
                                                 const xmlChar *name);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
                                                 const xmlChar *localName,
                                                 const xmlChar *namespaceURI);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr
                    xmlTextReaderGetRemainder   (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
                                                 const xmlChar *prefix);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
                                                 int no);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
                                                 const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
                                                 const xmlChar *localName,
                                                 const xmlChar *namespaceURI);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderMoveToElement  (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderNormalization  (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstEncoding  (xmlTextReaderPtr reader);
 
 /*
  * Extensions
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderSetParserProp  (xmlTextReaderPtr reader,
                                                 int prop,
                                                 int value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderGetParserProp  (xmlTextReaderPtr reader,
                                                 int prop);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                    xmlTextReaderCurrentNode    (xmlTextReaderPtr reader);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
 
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                    xmlTextReaderPreserve       (xmlTextReaderPtr reader);
 #ifdef LIBXML_PATTERN_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
                                                 const xmlChar *pattern,
                                                 const xmlChar **namespaces);
 #endif /* LIBXML_PATTERN_ENABLED */
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr
                    xmlTextReaderCurrentDoc     (xmlTextReaderPtr reader);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                    xmlTextReaderExpand         (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderNext           (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderNextSibling    (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderIsValid        (xmlTextReaderPtr reader);
 #ifdef LIBXML_SCHEMAS_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
                                                 const char *rng);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
                                                 xmlRelaxNGValidCtxtPtr ctxt,
                                                 int options);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
                                                 xmlRelaxNGPtr schema);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
                                                 const char *xsd);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
                                                 xmlSchemaValidCtxtPtr ctxt,
                                                 int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderSetSchema      (xmlTextReaderPtr reader,
                                                 xmlSchemaPtr schema);
 #endif
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                    xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlTextReaderStandalone     (xmlTextReaderPtr reader);
 
 
 /*
  * Index lookup
  */
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                xmlTextReaderByteConsumed       (xmlTextReaderPtr reader);
 
 /*
  * New more complete APIs for simpler creation and reuse of readers
  */
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderWalker         (xmlDocPtr doc);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderForDoc         (const xmlChar * cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderForFile        (const char *filename,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderForMemory      (const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderForFd          (int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr
                xmlReaderForIO          (xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
                                         void *ioctx,
@@ -348,34 +354,34 @@ XMLPUBFUN xmlTextReaderPtr XMLCALL
                                         const char *encoding,
                                         int options);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewWalker      (xmlTextReaderPtr reader,
                                         xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewDoc         (xmlTextReaderPtr reader,
                                         const xmlChar * cur,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewFile        (xmlTextReaderPtr reader,
                                         const char *filename,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewMemory      (xmlTextReaderPtr reader,
                                         const char *buffer,
                                         int size,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewFd          (xmlTextReaderPtr reader,
                                         int fd,
                                         const char *URL,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlReaderNewIO          (xmlTextReaderPtr reader,
                                         xmlInputReadCallback ioread,
                                         xmlInputCloseCallback ioclose,
@@ -397,23 +403,23 @@ typedef void *  xmlTextReaderLocatorPtr;
  *
  * Signature of an error callback from a reader parser
  */
-typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
+typedef void (*xmlTextReaderErrorFunc)(void *arg,
                                               const char *msg,
                                               xmlParserSeverities severity,
                                               xmlTextReaderLocatorPtr locator);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
            xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
                                         xmlTextReaderErrorFunc f,
                                         void *arg);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
                                                   xmlStructuredErrorFunc f,
                                                   void *arg);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
                                         xmlTextReaderErrorFunc *f,
                                         void **arg);
index 7009645..2d66437 100644 (file)
@@ -11,7 +11,9 @@
 #ifndef __XML_REGEXP_H__
 #define __XML_REGEXP_H__
 
+#include <stdio.h>
 #include <libxml/xmlversion.h>
+#include <libxml/xmlstring.h>
 
 #ifdef LIBXML_REGEXP_ENABLED
 
@@ -36,28 +38,19 @@ typedef xmlRegexp *xmlRegexpPtr;
 typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
 typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
 
-#ifdef __cplusplus
-}
-#endif
-#include <libxml/tree.h>
-#include <libxml/dict.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*
  * The POSIX like API
  */
-XMLPUBFUN xmlRegexpPtr XMLCALL
+XMLPUBFUN xmlRegexpPtr
                    xmlRegexpCompile    (const xmlChar *regexp);
-XMLPUBFUN void XMLCALL                  xmlRegFreeRegexp(xmlRegexpPtr regexp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN void                  xmlRegFreeRegexp(xmlRegexpPtr regexp);
+XMLPUBFUN int
                    xmlRegexpExec       (xmlRegexpPtr comp,
                                         const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRegexpPrint      (FILE *output,
                                         xmlRegexpPtr regexp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRegexpIsDeterminist(xmlRegexpPtr comp);
 
 /**
@@ -77,29 +70,29 @@ typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
 /*
  * The progressive API
  */
-XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
+XMLPUBFUN xmlRegExecCtxtPtr
                    xmlRegNewExecCtxt   (xmlRegexpPtr comp,
                                         xmlRegExecCallbacks callback,
                                         void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlRegFreeExecCtxt  (xmlRegExecCtxtPtr exec);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRegExecPushString(xmlRegExecCtxtPtr exec,
                                         const xmlChar *value,
                                         void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
                                         const xmlChar *value,
                                         const xmlChar *value2,
                                         void *data);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
                                         int *nbval,
                                         int *nbneg,
                                         xmlChar **values,
                                         int *terminal);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlRegExecErrInfo   (xmlRegExecCtxtPtr exec,
                                         const xmlChar **string,
                                         int *nbval,
@@ -116,15 +109,15 @@ XMLPUBFUN int XMLCALL
 typedef struct _xmlExpCtxt xmlExpCtxt;
 typedef xmlExpCtxt *xmlExpCtxtPtr;
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlExpFreeCtxt  (xmlExpCtxtPtr ctxt);
-XMLPUBFUN xmlExpCtxtPtr XMLCALL
+XMLPUBFUN xmlExpCtxtPtr
                        xmlExpNewCtxt   (int maxNodes,
                                         xmlDictPtr dict);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
 
 /* Expressions are trees but the tree is opaque */
@@ -150,31 +143,31 @@ XMLPUBVAR xmlExpNodePtr emptyExp;
 /*
  * Expressions are reference counted internally
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlExpFree      (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlExpRef       (xmlExpNodePtr expr);
 
 /*
  * constructors can be either manual or from a string
  */
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpParse     (xmlExpCtxtPtr ctxt,
                                         const char *expr);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpNewAtom   (xmlExpCtxtPtr ctxt,
                                         const xmlChar *name,
                                         int len);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpNewOr     (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr left,
                                         xmlExpNodePtr right);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpNewSeq    (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr left,
                                         xmlExpNodePtr right);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpNewRange  (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr subset,
                                         int min,
@@ -182,34 +175,34 @@ XMLPUBFUN xmlExpNodePtr XMLCALL
 /*
  * The really interesting APIs
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpIsNillable(xmlExpNodePtr expr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpMaxToken  (xmlExpNodePtr expr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr,
                                         const xmlChar**langList,
                                         int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpGetStart  (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr,
                                         const xmlChar**tokList,
                                         int len);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpStringDerive(xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr,
                                         const xmlChar *str,
                                         int len);
-XMLPUBFUN xmlExpNodePtr XMLCALL
+XMLPUBFUN xmlExpNodePtr
                        xmlExpExpDerive (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr,
                                         xmlExpNodePtr sub);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                        xmlExpSubsume   (xmlExpCtxtPtr ctxt,
                                         xmlExpNodePtr expr,
                                         xmlExpNodePtr sub);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                        xmlExpDump      (xmlBufferPtr buf,
                                         xmlExpNodePtr expr);
 #endif /* LIBXML_EXPR_ENABLED */
index fb329b2..fbf293a 100644 (file)
@@ -41,47 +41,56 @@ typedef enum {
 typedef struct _xmlSaveCtxt xmlSaveCtxt;
 typedef xmlSaveCtxt *xmlSaveCtxtPtr;
 
-XMLPUBFUN xmlSaveCtxtPtr XMLCALL
+XMLPUBFUN xmlSaveCtxtPtr
                xmlSaveToFd             (int fd,
                                         const char *encoding,
                                         int options);
-XMLPUBFUN xmlSaveCtxtPtr XMLCALL
+XMLPUBFUN xmlSaveCtxtPtr
                xmlSaveToFilename       (const char *filename,
                                         const char *encoding,
                                         int options);
 
-XMLPUBFUN xmlSaveCtxtPtr XMLCALL
+XMLPUBFUN xmlSaveCtxtPtr
                xmlSaveToBuffer         (xmlBufferPtr buffer,
                                         const char *encoding,
                                         int options);
 
-XMLPUBFUN xmlSaveCtxtPtr XMLCALL
+XMLPUBFUN xmlSaveCtxtPtr
                xmlSaveToIO             (xmlOutputWriteCallback iowrite,
                                         xmlOutputCloseCallback ioclose,
                                         void *ioctx,
                                         const char *encoding,
                                         int options);
 
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                xmlSaveDoc              (xmlSaveCtxtPtr ctxt,
                                         xmlDocPtr doc);
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                xmlSaveTree             (xmlSaveCtxtPtr ctxt,
                                         xmlNodePtr node);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveFlush            (xmlSaveCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveClose            (xmlSaveCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveSetEscape        (xmlSaveCtxtPtr ctxt,
                                         xmlCharEncodingOutputFunc escape);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSaveSetAttrEscape    (xmlSaveCtxtPtr ctxt,
                                         xmlCharEncodingOutputFunc escape);
+
+XMLPUBFUN int
+                xmlThrDefIndentTreeOutput(int v);
+XMLPUBFUN const char *
+                xmlThrDefTreeIndentString(const char * v);
+XMLPUBFUN int
+                xmlThrDefSaveNoEmptyTags(int v);
+
 #ifdef __cplusplus
 }
 #endif
+
 #endif /* LIBXML_OUTPUT_ENABLED */
 #endif /* __XML_XMLSAVE_H__ */
 
index b90e9d1..c2af3d7 100644 (file)
 
 #ifdef LIBXML_SCHEMAS_ENABLED
 
+#include <stdio.h>
+#include <libxml/encoding.h>
 #include <libxml/tree.h>
+#include <libxml/xmlerror.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -92,7 +95,7 @@ typedef xmlSchema *xmlSchemaPtr;
  *
  * Signature of an error callback from an XSD validation
  */
-typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
+typedef void (*xmlSchemaValidityErrorFunc)
                  (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
 /**
@@ -103,7 +106,7 @@ typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
  *
  * Signature of a warning callback from an XSD validation
  */
-typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
+typedef void (*xmlSchemaValidityWarningFunc)
                  (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
 /**
@@ -128,95 +131,95 @@ typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
  * Returns: 0 in case of success and -1 in case of error
  */
 
-typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
+typedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,
                            const char **file, unsigned long *line);
 
 /*
  * Interfaces for parsing.
  */
-XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaParserCtxtPtr
            xmlSchemaNewParserCtxt      (const char *URL);
-XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaParserCtxtPtr
            xmlSchemaNewMemParserCtxt   (const char *buffer,
                                         int size);
-XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaParserCtxtPtr
            xmlSchemaNewDocParserCtxt   (xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaFreeParserCtxt     (xmlSchemaParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaSetParserErrors    (xmlSchemaParserCtxtPtr ctxt,
                                         xmlSchemaValidityErrorFunc err,
                                         xmlSchemaValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
                                         xmlStructuredErrorFunc serror,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
                                        xmlSchemaValidityErrorFunc * err,
                                        xmlSchemaValidityWarningFunc * warn,
                                        void **ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaIsValid        (xmlSchemaValidCtxtPtr ctxt);
 
-XMLPUBFUN xmlSchemaPtr XMLCALL
+XMLPUBFUN xmlSchemaPtr
            xmlSchemaParse              (xmlSchemaParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaFree               (xmlSchemaPtr schema);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaDump               (FILE *output,
                                         xmlSchemaPtr schema);
 #endif /* LIBXML_OUTPUT_ENABLED */
 /*
  * Interfaces for validating
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaSetValidErrors     (xmlSchemaValidCtxtPtr ctxt,
                                         xmlSchemaValidityErrorFunc err,
                                         xmlSchemaValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
                                         xmlStructuredErrorFunc serror,
                                         void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaGetValidErrors     (xmlSchemaValidCtxtPtr ctxt,
                                         xmlSchemaValidityErrorFunc *err,
                                         xmlSchemaValidityWarningFunc *warn,
                                         void **ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaSetValidOptions    (xmlSchemaValidCtxtPtr ctxt,
                                         int options);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
             xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
                                         const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
 
-XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaValidCtxtPtr
            xmlSchemaNewValidCtxt       (xmlSchemaPtr schema);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlSchemaFreeValidCtxt      (xmlSchemaValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaValidateDoc        (xmlSchemaValidCtxtPtr ctxt,
                                         xmlDocPtr instance);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaValidateStream     (xmlSchemaValidCtxtPtr ctxt,
                                         xmlParserInputBufferPtr input,
                                         xmlCharEncoding enc,
                                         xmlSAXHandlerPtr sax,
                                         void *user_data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
            xmlSchemaValidateFile       (xmlSchemaValidCtxtPtr ctxt,
                                         const char * filename,
                                         int options);
 
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr
            xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
 
 /*
@@ -225,15 +228,15 @@ XMLPUBFUN xmlParserCtxtPtr XMLCALL
 typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
 typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
 
-XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
+XMLPUBFUN xmlSchemaSAXPlugPtr
             xmlSchemaSAXPlug           (xmlSchemaValidCtxtPtr ctxt,
                                         xmlSAXHandlerPtr *sax,
                                         void **user_data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
             xmlSchemaSAXUnplug         (xmlSchemaSAXPlugPtr plug);
 
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
             xmlSchemaValidateSetLocator        (xmlSchemaValidCtxtPtr vctxt,
                                         xmlSchemaValidityLocatorFunc f,
                                         void *ctxt);
index 5d588f9..e2cde35 100644 (file)
@@ -30,118 +30,118 @@ typedef enum {
     XML_SCHEMA_WHITESPACE_COLLAPSE = 3
 } xmlSchemaWhitespaceValueType;
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN int
                xmlSchemaInitTypes              (void);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSchemaCleanupTypes           (void);
-XMLPUBFUN xmlSchemaTypePtr XMLCALL
+XMLPUBFUN xmlSchemaTypePtr
                xmlSchemaGetPredefinedType      (const xmlChar *name,
                                                 const xmlChar *ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr *val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValPredefTypeNode      (xmlSchemaTypePtr type,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr *val,
                                                 xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValidateFacet          (xmlSchemaTypePtr base,
                                                 xmlSchemaFacetPtr facet,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValidateFacetWhtsp     (xmlSchemaFacetPtr facet,
                                                 xmlSchemaWhitespaceValueType fws,
                                                 xmlSchemaValType valType,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr val,
                                                 xmlSchemaWhitespaceValueType ws);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSchemaFreeValue              (xmlSchemaValPtr val);
-XMLPUBFUN xmlSchemaFacetPtr XMLCALL
+XMLPUBFUN xmlSchemaFacetPtr
                xmlSchemaNewFacet               (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaCheckFacet             (xmlSchemaFacetPtr facet,
                                                 xmlSchemaTypePtr typeDecl,
                                                 xmlSchemaParserCtxtPtr ctxt,
                                                 const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlSchemaFreeFacet              (xmlSchemaFacetPtr facet);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaCompareValues          (xmlSchemaValPtr x,
                                                 xmlSchemaValPtr y);
-XMLPUBFUN xmlSchemaTypePtr XMLCALL
+XMLPUBFUN xmlSchemaTypePtr
     xmlSchemaGetBuiltInListSimpleTypeItemType  (xmlSchemaTypePtr type);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
     xmlSchemaValidateListSimpleTypeFacet       (xmlSchemaFacetPtr facet,
                                                 const xmlChar *value,
                                                 unsigned long actualLen,
                                                 unsigned long *expectedLen);
-XMLPUBFUN xmlSchemaTypePtr XMLCALL
+XMLPUBFUN xmlSchemaTypePtr
                xmlSchemaGetBuiltInType         (xmlSchemaValType type);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaIsBuiltInTypeFacet     (xmlSchemaTypePtr type,
                                                 int facetType);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlSchemaCollapseString         (const xmlChar *value);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlSchemaWhiteSpaceReplace      (const xmlChar *value);
-XMLPUBFUN unsigned long  XMLCALL
+XMLPUBFUN unsigned long 
                xmlSchemaGetFacetValueAsULong   (xmlSchemaFacetPtr facet);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValidateLengthFacet    (xmlSchemaTypePtr type,
                                                 xmlSchemaFacetPtr facet,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr val,
                                                 unsigned long *length);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,
                                                  xmlSchemaValType valType,
                                                  const xmlChar *value,
                                                  xmlSchemaValPtr val,
                                                  unsigned long *length,
                                                  xmlSchemaWhitespaceValueType ws);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,
                                                 const xmlChar *value,
                                                 xmlSchemaValPtr *val,
                                                 xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaGetCanonValue          (xmlSchemaValPtr val,
                                                 const xmlChar **retValue);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaGetCanonValueWhtsp     (xmlSchemaValPtr val,
                                                 const xmlChar **retValue,
                                                 xmlSchemaWhitespaceValueType ws);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValueAppend            (xmlSchemaValPtr prev,
                                                 xmlSchemaValPtr cur);
-XMLPUBFUN xmlSchemaValPtr XMLCALL
+XMLPUBFUN xmlSchemaValPtr
                xmlSchemaValueGetNext           (xmlSchemaValPtr cur);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlSchemaValueGetAsString       (xmlSchemaValPtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaValueGetAsBoolean      (xmlSchemaValPtr val);
-XMLPUBFUN xmlSchemaValPtr XMLCALL
+XMLPUBFUN xmlSchemaValPtr
                xmlSchemaNewStringValue         (xmlSchemaValType type,
                                                 const xmlChar *value);
-XMLPUBFUN xmlSchemaValPtr XMLCALL
+XMLPUBFUN xmlSchemaValPtr
                xmlSchemaNewNOTATIONValue       (const xmlChar *name,
                                                 const xmlChar *ns);
-XMLPUBFUN xmlSchemaValPtr XMLCALL
+XMLPUBFUN xmlSchemaValPtr
                xmlSchemaNewQNameValue          (const xmlChar *namespaceName,
                                                 const xmlChar *localName);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlSchemaCompareValuesWhtsp     (xmlSchemaValPtr x,
                                                 xmlSchemaWhitespaceValueType xws,
                                                 xmlSchemaValPtr y,
                                                 xmlSchemaWhitespaceValueType yws);
-XMLPUBFUN xmlSchemaValPtr XMLCALL
+XMLPUBFUN xmlSchemaValPtr
                xmlSchemaCopyValue              (xmlSchemaValPtr val);
-XMLPUBFUN xmlSchemaValType XMLCALL
+XMLPUBFUN xmlSchemaValType
                xmlSchemaGetValType             (xmlSchemaValPtr val);
 
 #ifdef __cplusplus
index 2d0b2d1..db11a0b 100644 (file)
@@ -37,100 +37,100 @@ typedef unsigned char xmlChar;
 /*
  * xmlChar handling
  */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrdup                (const xmlChar *cur);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrndup               (const xmlChar *cur,
                                          int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlCharStrndup           (const char *cur,
                                          int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlCharStrdup            (const char *cur);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrsub                (const xmlChar *str,
                                          int start,
                                          int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                 xmlStrchr                (const xmlChar *str,
                                          xmlChar val);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                 xmlStrstr                (const xmlChar *str,
                                          const xmlChar *val);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                 xmlStrcasestr            (const xmlChar *str,
                                          const xmlChar *val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrcmp                (const xmlChar *str1,
                                          const xmlChar *str2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrncmp               (const xmlChar *str1,
                                          const xmlChar *str2,
                                          int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrcasecmp            (const xmlChar *str1,
                                          const xmlChar *str2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrncasecmp           (const xmlChar *str1,
                                          const xmlChar *str2,
                                          int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrEqual              (const xmlChar *str1,
                                          const xmlChar *str2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrQEqual             (const xmlChar *pref,
                                          const xmlChar *name,
                                          const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrlen                (const xmlChar *str);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrcat                (xmlChar *cur,
                                          const xmlChar *add);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrncat               (xmlChar *cur,
                                          const xmlChar *add,
                                          int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                 xmlStrncatNew            (const xmlChar *str1,
                                          const xmlChar *str2,
                                          int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrPrintf             (xmlChar *buf,
                                          int len,
                                          const char *msg,
                                          ...) LIBXML_ATTR_FORMAT(3,4);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                 xmlStrVPrintf                (xmlChar *buf,
                                          int len,
                                          const char *msg,
                                          va_list ap) LIBXML_ATTR_FORMAT(3,0);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlGetUTF8Char                   (const unsigned char *utf,
                                          int *len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlCheckUTF8                     (const unsigned char *utf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlUTF8Strsize                   (const xmlChar *utf,
                                          int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
         xmlUTF8Strndup                   (const xmlChar *utf,
                                          int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
         xmlUTF8Strpos                    (const xmlChar *utf,
                                          int pos);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlUTF8Strloc                    (const xmlChar *utf,
                                          const xmlChar *utfchar);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
         xmlUTF8Strsub                    (const xmlChar *utf,
                                          int start,
                                          int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlUTF8Strlen                    (const xmlChar *utf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlUTF8Size                      (const xmlChar *utf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
         xmlUTF8Charcmp                   (const xmlChar *utf1,
                                          const xmlChar *utf2);
 
index 01ac8b6..2e50a49 100644 (file)
 extern "C" {
 #endif
 
-XMLPUBFUN int XMLCALL xmlUCSIsAegeanNumbers    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsAlphabeticPresentationForms      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsArabic   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsA (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsB (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsArmenian (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsArrows   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBasicLatin       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBengali  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBlockElements    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBopomofo (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBopomofoExtended (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBoxDrawing       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBraillePatterns  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsBuhid    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsByzantineMusicalSymbols  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibility (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityForms    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographs       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographsSupplement     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKRadicalsSupplement    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKSymbolsandPunctuation (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographs     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionA   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionB   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCherokee (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarks        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarksforSymbols      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCombiningHalfMarks       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCombiningMarksforSymbols (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsControlPictures  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCurrencySymbols  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCypriotSyllabary (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCyrillic (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCyrillicSupplement       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsDeseret  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsDevanagari       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsDingbats (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsEnclosedAlphanumerics    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsEnclosedCJKLettersandMonths      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsEthiopic (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGeneralPunctuation       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGeometricShapes  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGeorgian (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGothic   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGreek    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGreekExtended    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGreekandCoptic   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGujarati (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsGurmukhi (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHalfwidthandFullwidthForms       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHangulCompatibilityJamo  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHangulJamo       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHangulSyllables  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHanunoo  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHebrew   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHighPrivateUseSurrogates (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHighSurrogates   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsHiragana (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsIPAExtensions    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsIdeographicDescriptionCharacters (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKanbun   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKangxiRadicals   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKannada  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKatakana (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKatakanaPhoneticExtensions       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKhmer    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsKhmerSymbols     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLao      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLatin1Supplement (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedA   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedB   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedAdditional  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLetterlikeSymbols        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLimbu    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLinearBIdeograms (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLinearBSyllabary (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsLowSurrogates    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMalayalam        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMathematicalAlphanumericSymbols  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMathematicalOperators    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsA        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsB        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbols     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbolsandArrows    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousTechnical   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMongolian        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMusicalSymbols   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsMyanmar  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsNumberForms      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsOgham    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsOldItalic        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsOpticalCharacterRecognition      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsOriya    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsOsmanya  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsPhoneticExtensions       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsPrivateUse       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsPrivateUseArea   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsRunic    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsShavian  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSinhala  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSmallFormVariants        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSpacingModifierLetters   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSpecials (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSuperscriptsandSubscripts        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsA      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsB      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSupplementalMathematicalOperators        (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaA     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaB     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsSyriac   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTagalog  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTagbanwa (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTags     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTaiLe    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTaiXuanJingSymbols       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTamil    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTelugu   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsThaana   (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsThai     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsTibetan  (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsUgaritic (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsUnifiedCanadianAboriginalSyllabics       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectors       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectorsSupplement     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsYiRadicals       (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsYiSyllables      (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsYijingHexagramSymbols    (int code);
+XMLPUBFUN int xmlUCSIsAegeanNumbers    (int code);
+XMLPUBFUN int xmlUCSIsAlphabeticPresentationForms      (int code);
+XMLPUBFUN int xmlUCSIsArabic   (int code);
+XMLPUBFUN int xmlUCSIsArabicPresentationFormsA (int code);
+XMLPUBFUN int xmlUCSIsArabicPresentationFormsB (int code);
+XMLPUBFUN int xmlUCSIsArmenian (int code);
+XMLPUBFUN int xmlUCSIsArrows   (int code);
+XMLPUBFUN int xmlUCSIsBasicLatin       (int code);
+XMLPUBFUN int xmlUCSIsBengali  (int code);
+XMLPUBFUN int xmlUCSIsBlockElements    (int code);
+XMLPUBFUN int xmlUCSIsBopomofo (int code);
+XMLPUBFUN int xmlUCSIsBopomofoExtended (int code);
+XMLPUBFUN int xmlUCSIsBoxDrawing       (int code);
+XMLPUBFUN int xmlUCSIsBraillePatterns  (int code);
+XMLPUBFUN int xmlUCSIsBuhid    (int code);
+XMLPUBFUN int xmlUCSIsByzantineMusicalSymbols  (int code);
+XMLPUBFUN int xmlUCSIsCJKCompatibility (int code);
+XMLPUBFUN int xmlUCSIsCJKCompatibilityForms    (int code);
+XMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographs       (int code);
+XMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographsSupplement     (int code);
+XMLPUBFUN int xmlUCSIsCJKRadicalsSupplement    (int code);
+XMLPUBFUN int xmlUCSIsCJKSymbolsandPunctuation (int code);
+XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographs     (int code);
+XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionA   (int code);
+XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionB   (int code);
+XMLPUBFUN int xmlUCSIsCherokee (int code);
+XMLPUBFUN int xmlUCSIsCombiningDiacriticalMarks        (int code);
+XMLPUBFUN int xmlUCSIsCombiningDiacriticalMarksforSymbols      (int code);
+XMLPUBFUN int xmlUCSIsCombiningHalfMarks       (int code);
+XMLPUBFUN int xmlUCSIsCombiningMarksforSymbols (int code);
+XMLPUBFUN int xmlUCSIsControlPictures  (int code);
+XMLPUBFUN int xmlUCSIsCurrencySymbols  (int code);
+XMLPUBFUN int xmlUCSIsCypriotSyllabary (int code);
+XMLPUBFUN int xmlUCSIsCyrillic (int code);
+XMLPUBFUN int xmlUCSIsCyrillicSupplement       (int code);
+XMLPUBFUN int xmlUCSIsDeseret  (int code);
+XMLPUBFUN int xmlUCSIsDevanagari       (int code);
+XMLPUBFUN int xmlUCSIsDingbats (int code);
+XMLPUBFUN int xmlUCSIsEnclosedAlphanumerics    (int code);
+XMLPUBFUN int xmlUCSIsEnclosedCJKLettersandMonths      (int code);
+XMLPUBFUN int xmlUCSIsEthiopic (int code);
+XMLPUBFUN int xmlUCSIsGeneralPunctuation       (int code);
+XMLPUBFUN int xmlUCSIsGeometricShapes  (int code);
+XMLPUBFUN int xmlUCSIsGeorgian (int code);
+XMLPUBFUN int xmlUCSIsGothic   (int code);
+XMLPUBFUN int xmlUCSIsGreek    (int code);
+XMLPUBFUN int xmlUCSIsGreekExtended    (int code);
+XMLPUBFUN int xmlUCSIsGreekandCoptic   (int code);
+XMLPUBFUN int xmlUCSIsGujarati (int code);
+XMLPUBFUN int xmlUCSIsGurmukhi (int code);
+XMLPUBFUN int xmlUCSIsHalfwidthandFullwidthForms       (int code);
+XMLPUBFUN int xmlUCSIsHangulCompatibilityJamo  (int code);
+XMLPUBFUN int xmlUCSIsHangulJamo       (int code);
+XMLPUBFUN int xmlUCSIsHangulSyllables  (int code);
+XMLPUBFUN int xmlUCSIsHanunoo  (int code);
+XMLPUBFUN int xmlUCSIsHebrew   (int code);
+XMLPUBFUN int xmlUCSIsHighPrivateUseSurrogates (int code);
+XMLPUBFUN int xmlUCSIsHighSurrogates   (int code);
+XMLPUBFUN int xmlUCSIsHiragana (int code);
+XMLPUBFUN int xmlUCSIsIPAExtensions    (int code);
+XMLPUBFUN int xmlUCSIsIdeographicDescriptionCharacters (int code);
+XMLPUBFUN int xmlUCSIsKanbun   (int code);
+XMLPUBFUN int xmlUCSIsKangxiRadicals   (int code);
+XMLPUBFUN int xmlUCSIsKannada  (int code);
+XMLPUBFUN int xmlUCSIsKatakana (int code);
+XMLPUBFUN int xmlUCSIsKatakanaPhoneticExtensions       (int code);
+XMLPUBFUN int xmlUCSIsKhmer    (int code);
+XMLPUBFUN int xmlUCSIsKhmerSymbols     (int code);
+XMLPUBFUN int xmlUCSIsLao      (int code);
+XMLPUBFUN int xmlUCSIsLatin1Supplement (int code);
+XMLPUBFUN int xmlUCSIsLatinExtendedA   (int code);
+XMLPUBFUN int xmlUCSIsLatinExtendedB   (int code);
+XMLPUBFUN int xmlUCSIsLatinExtendedAdditional  (int code);
+XMLPUBFUN int xmlUCSIsLetterlikeSymbols        (int code);
+XMLPUBFUN int xmlUCSIsLimbu    (int code);
+XMLPUBFUN int xmlUCSIsLinearBIdeograms (int code);
+XMLPUBFUN int xmlUCSIsLinearBSyllabary (int code);
+XMLPUBFUN int xmlUCSIsLowSurrogates    (int code);
+XMLPUBFUN int xmlUCSIsMalayalam        (int code);
+XMLPUBFUN int xmlUCSIsMathematicalAlphanumericSymbols  (int code);
+XMLPUBFUN int xmlUCSIsMathematicalOperators    (int code);
+XMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsA        (int code);
+XMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsB        (int code);
+XMLPUBFUN int xmlUCSIsMiscellaneousSymbols     (int code);
+XMLPUBFUN int xmlUCSIsMiscellaneousSymbolsandArrows    (int code);
+XMLPUBFUN int xmlUCSIsMiscellaneousTechnical   (int code);
+XMLPUBFUN int xmlUCSIsMongolian        (int code);
+XMLPUBFUN int xmlUCSIsMusicalSymbols   (int code);
+XMLPUBFUN int xmlUCSIsMyanmar  (int code);
+XMLPUBFUN int xmlUCSIsNumberForms      (int code);
+XMLPUBFUN int xmlUCSIsOgham    (int code);
+XMLPUBFUN int xmlUCSIsOldItalic        (int code);
+XMLPUBFUN int xmlUCSIsOpticalCharacterRecognition      (int code);
+XMLPUBFUN int xmlUCSIsOriya    (int code);
+XMLPUBFUN int xmlUCSIsOsmanya  (int code);
+XMLPUBFUN int xmlUCSIsPhoneticExtensions       (int code);
+XMLPUBFUN int xmlUCSIsPrivateUse       (int code);
+XMLPUBFUN int xmlUCSIsPrivateUseArea   (int code);
+XMLPUBFUN int xmlUCSIsRunic    (int code);
+XMLPUBFUN int xmlUCSIsShavian  (int code);
+XMLPUBFUN int xmlUCSIsSinhala  (int code);
+XMLPUBFUN int xmlUCSIsSmallFormVariants        (int code);
+XMLPUBFUN int xmlUCSIsSpacingModifierLetters   (int code);
+XMLPUBFUN int xmlUCSIsSpecials (int code);
+XMLPUBFUN int xmlUCSIsSuperscriptsandSubscripts        (int code);
+XMLPUBFUN int xmlUCSIsSupplementalArrowsA      (int code);
+XMLPUBFUN int xmlUCSIsSupplementalArrowsB      (int code);
+XMLPUBFUN int xmlUCSIsSupplementalMathematicalOperators        (int code);
+XMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaA     (int code);
+XMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaB     (int code);
+XMLPUBFUN int xmlUCSIsSyriac   (int code);
+XMLPUBFUN int xmlUCSIsTagalog  (int code);
+XMLPUBFUN int xmlUCSIsTagbanwa (int code);
+XMLPUBFUN int xmlUCSIsTags     (int code);
+XMLPUBFUN int xmlUCSIsTaiLe    (int code);
+XMLPUBFUN int xmlUCSIsTaiXuanJingSymbols       (int code);
+XMLPUBFUN int xmlUCSIsTamil    (int code);
+XMLPUBFUN int xmlUCSIsTelugu   (int code);
+XMLPUBFUN int xmlUCSIsThaana   (int code);
+XMLPUBFUN int xmlUCSIsThai     (int code);
+XMLPUBFUN int xmlUCSIsTibetan  (int code);
+XMLPUBFUN int xmlUCSIsUgaritic (int code);
+XMLPUBFUN int xmlUCSIsUnifiedCanadianAboriginalSyllabics       (int code);
+XMLPUBFUN int xmlUCSIsVariationSelectors       (int code);
+XMLPUBFUN int xmlUCSIsVariationSelectorsSupplement     (int code);
+XMLPUBFUN int xmlUCSIsYiRadicals       (int code);
+XMLPUBFUN int xmlUCSIsYiSyllables      (int code);
+XMLPUBFUN int xmlUCSIsYijingHexagramSymbols    (int code);
 
-XMLPUBFUN int XMLCALL xmlUCSIsBlock    (int code, const char *block);
+XMLPUBFUN int xmlUCSIsBlock    (int code, const char *block);
 
-XMLPUBFUN int XMLCALL xmlUCSIsCatC     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatCc    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatCf    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatCo    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatCs    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatL     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatLl    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatLm    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatLo    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatLt    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatLu    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatM     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatMc    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatMe    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatMn    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatN     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatNd    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatNl    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatNo    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatP     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPc    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPd    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPe    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPf    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPi    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPo    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatPs    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatS     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatSc    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatSk    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatSm    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatSo    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatZ     (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatZl    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatZp    (int code);
-XMLPUBFUN int XMLCALL xmlUCSIsCatZs    (int code);
+XMLPUBFUN int xmlUCSIsCatC     (int code);
+XMLPUBFUN int xmlUCSIsCatCc    (int code);
+XMLPUBFUN int xmlUCSIsCatCf    (int code);
+XMLPUBFUN int xmlUCSIsCatCo    (int code);
+XMLPUBFUN int xmlUCSIsCatCs    (int code);
+XMLPUBFUN int xmlUCSIsCatL     (int code);
+XMLPUBFUN int xmlUCSIsCatLl    (int code);
+XMLPUBFUN int xmlUCSIsCatLm    (int code);
+XMLPUBFUN int xmlUCSIsCatLo    (int code);
+XMLPUBFUN int xmlUCSIsCatLt    (int code);
+XMLPUBFUN int xmlUCSIsCatLu    (int code);
+XMLPUBFUN int xmlUCSIsCatM     (int code);
+XMLPUBFUN int xmlUCSIsCatMc    (int code);
+XMLPUBFUN int xmlUCSIsCatMe    (int code);
+XMLPUBFUN int xmlUCSIsCatMn    (int code);
+XMLPUBFUN int xmlUCSIsCatN     (int code);
+XMLPUBFUN int xmlUCSIsCatNd    (int code);
+XMLPUBFUN int xmlUCSIsCatNl    (int code);
+XMLPUBFUN int xmlUCSIsCatNo    (int code);
+XMLPUBFUN int xmlUCSIsCatP     (int code);
+XMLPUBFUN int xmlUCSIsCatPc    (int code);
+XMLPUBFUN int xmlUCSIsCatPd    (int code);
+XMLPUBFUN int xmlUCSIsCatPe    (int code);
+XMLPUBFUN int xmlUCSIsCatPf    (int code);
+XMLPUBFUN int xmlUCSIsCatPi    (int code);
+XMLPUBFUN int xmlUCSIsCatPo    (int code);
+XMLPUBFUN int xmlUCSIsCatPs    (int code);
+XMLPUBFUN int xmlUCSIsCatS     (int code);
+XMLPUBFUN int xmlUCSIsCatSc    (int code);
+XMLPUBFUN int xmlUCSIsCatSk    (int code);
+XMLPUBFUN int xmlUCSIsCatSm    (int code);
+XMLPUBFUN int xmlUCSIsCatSo    (int code);
+XMLPUBFUN int xmlUCSIsCatZ     (int code);
+XMLPUBFUN int xmlUCSIsCatZl    (int code);
+XMLPUBFUN int xmlUCSIsCatZp    (int code);
+XMLPUBFUN int xmlUCSIsCatZs    (int code);
 
-XMLPUBFUN int XMLCALL xmlUCSIsCat      (int code, const char *cat);
+XMLPUBFUN int xmlUCSIsCat      (int code, const char *cat);
 
 #ifdef __cplusplus
 }
index bdebfe3..6d2ae87 100644 (file)
@@ -21,7 +21,7 @@ extern "C" {
  * your library and includes mismatch
  */
 #ifndef LIBXML2_COMPILING_MSCCDEF
-XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
+XMLPUBFUN void xmlCheckVersion(int version);
 #endif /* LIBXML2_COMPILING_MSCCDEF */
 
 /**
@@ -313,9 +313,9 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 /**
  * LIBXML_DEBUG_RUNTIME:
  *
- * Whether the runtime debugging is configured in
+ * Removed
  */
-#if @WITH_RUN_DEBUG@
+#if 0
 #define LIBXML_DEBUG_RUNTIME
 #endif
 
@@ -409,12 +409,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 #endif
 
 #ifdef __GNUC__
-
-/**
- * ATTRIBUTE_UNUSED:
- *
- * Macro used to signal to GCC unused function parameters
- */
+/** DOC_DISABLE */
 
 #ifndef ATTRIBUTE_UNUSED
 # if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
@@ -424,12 +419,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 # endif
 #endif
 
-/**
- * LIBXML_ATTR_ALLOC_SIZE:
- *
- * Macro used to indicate to GCC this is an allocator function
- */
-
 #ifndef LIBXML_ATTR_ALLOC_SIZE
 # if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))
 #  define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
@@ -440,12 +429,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 # define LIBXML_ATTR_ALLOC_SIZE(x)
 #endif
 
-/**
- * LIBXML_ATTR_FORMAT:
- *
- * Macro used to indicate to GCC the parameter are printf like
- */
-
 #ifndef LIBXML_ATTR_FORMAT
 # if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
 #  define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
@@ -457,44 +440,69 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 #endif
 
 #ifndef XML_DEPRECATED
-#  ifdef IN_LIBXML
+#  if defined (IN_LIBXML) || (__GNUC__ * 100 + __GNUC_MINOR__ < 301)
 #    define XML_DEPRECATED
-#  else
 /* Available since at least GCC 3.1 */
+#  else
 #    define XML_DEPRECATED __attribute__((deprecated))
 #  endif
 #endif
 
+#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+  #if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 800)
+    #define XML_IGNORE_FPTR_CAST_WARNINGS \
+      _Pragma("GCC diagnostic push") \
+      _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
+      _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
+  #else
+    #define XML_IGNORE_FPTR_CAST_WARNINGS \
+      _Pragma("GCC diagnostic push") \
+      _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
+  #endif
+  #define XML_POP_WARNINGS \
+    _Pragma("GCC diagnostic pop")
+#else
+  #define XML_IGNORE_FPTR_CAST_WARNINGS
+  #define XML_POP_WARNINGS
+#endif
+
 #else /* ! __GNUC__ */
-/**
- * ATTRIBUTE_UNUSED:
- *
- * Macro used to signal to GCC unused function parameters
- */
 #define ATTRIBUTE_UNUSED
-/**
- * LIBXML_ATTR_ALLOC_SIZE:
- *
- * Macro used to indicate to GCC this is an allocator function
- */
 #define LIBXML_ATTR_ALLOC_SIZE(x)
-/**
- * LIBXML_ATTR_FORMAT:
- *
- * Macro used to indicate to GCC the parameter are printf like
- */
 #define LIBXML_ATTR_FORMAT(fmt,args)
-/**
- * XML_DEPRECATED:
- *
- * Macro used to indicate that a function, variable, type or struct member
- * is deprecated.
- */
 #ifndef XML_DEPRECATED
-#define XML_DEPRECATED
+#  if defined (IN_LIBXML) || !defined (_MSC_VER)
+#    define XML_DEPRECATED
+/* Available since Visual Studio 2005 */
+#  elif defined (_MSC_VER) && (_MSC_VER >= 1400)
+#    define XML_DEPRECATED __declspec(deprecated)
+#  endif
+#endif
+#if defined (_MSC_VER) && (_MSC_VER >= 1400)
+#  define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push))
+#else
+#  define XML_IGNORE_FPTR_CAST_WARNINGS
+#endif
+#ifndef XML_POP_WARNINGS
+#  if defined (_MSC_VER) && (_MSC_VER >= 1400)
+#    define XML_POP_WARNINGS __pragma(warning(pop))
+#  else
+#    define XML_POP_WARNINGS
+#  endif
 #endif
 #endif /* __GNUC__ */
 
+#define XML_NO_ATTR
+
+#ifdef LIBXML_THREAD_ENABLED
+  #define XML_DECLARE_GLOBAL(name, type, attrs) \
+    attrs XMLPUBFUN type *__##name(void);
+  #define XML_GLOBAL_MACRO(name) (*__##name())
+#else
+  #define XML_DECLARE_GLOBAL(name, type, attrs) \
+    attrs XMLPUBVAR type name;
+#endif
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index dd5add3..339f251 100644 (file)
@@ -29,20 +29,20 @@ extern "C" {
 /*
  * Constructors & Destructor
  */
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriter(xmlOutputBufferPtr out);
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriterFilename(const char *uri, int compression);
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
-    XMLPUBFUN xmlTextWriterPtr XMLCALL
+    XMLPUBFUN xmlTextWriterPtr
         xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,
                              int compression);
-    XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
+    XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer);
 
 /*
  * Functions
@@ -52,30 +52,30 @@ extern "C" {
 /*
  * Document
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartDocument(xmlTextWriterPtr writer,
                                    const char *version,
                                    const char *encoding,
                                    const char *standalone);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr
                                                    writer);
 
 /*
  * Comments
  */
-    XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr
                                                     writer);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer);
+    XMLPUBFUN int
         xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
                                         const char *format, ...)
                                        LIBXML_ATTR_FORMAT(2,3);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
                                          const char *format,
                                          va_list argptr)
                                         LIBXML_ATTR_FORMAT(2,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr
                                                     writer,
                                                     const xmlChar *
                                                     content);
@@ -83,47 +83,47 @@ extern "C" {
 /*
  * Elements
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartElement(xmlTextWriterPtr writer,
                                   const xmlChar * name);
-    XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr
                                                       writer,
                                                       const xmlChar *
                                                       prefix,
                                                       const xmlChar * name,
                                                       const xmlChar *
                                                       namespaceURI);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer);
-    XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr
                                                       writer);
 
 /*
  * Elements conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
                                         const xmlChar * name,
                                         const char *format, ...)
                                        LIBXML_ATTR_FORMAT(3,4);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
                                          const xmlChar * name,
                                          const char *format,
                                          va_list argptr)
                                         LIBXML_ATTR_FORMAT(3,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr
                                                     writer,
                                                     const xmlChar * name,
                                                     const xmlChar *
                                                     content);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
                                           const xmlChar * prefix,
                                           const xmlChar * name,
                                           const xmlChar * namespaceURI,
                                           const char *format, ...)
                                          LIBXML_ATTR_FORMAT(5,6);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
                                            const xmlChar * prefix,
                                            const xmlChar * name,
@@ -131,7 +131,7 @@ extern "C" {
                                            const char *format,
                                            va_list argptr)
                                           LIBXML_ATTR_FORMAT(5,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr
                                                       writer,
                                                       const xmlChar *
                                                       prefix,
@@ -144,48 +144,48 @@ extern "C" {
 /*
  * Text
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
                                     const char *format, ...)
                                    LIBXML_ATTR_FORMAT(2,3);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
                                      const char *format, va_list argptr)
                                     LIBXML_ATTR_FORMAT(2,0);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
                                  const xmlChar * content, int len);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
                               const xmlChar * content);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr
                                                          writer,
                                                          const char
                                                          *format, ...)
                                                         LIBXML_ATTR_FORMAT(2,3);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr
                                                           writer,
                                                           const char
                                                           *format,
                                                           va_list argptr)
                                                          LIBXML_ATTR_FORMAT(2,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer,
+    XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer,
                                                    const xmlChar *
                                                    content);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
+    XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
                                                    const char *data,
                                                    int start, int len);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
+    XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
                                                    const char *data,
                                                    int start, int len);
 
 /*
  * Attributes
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
                                     const xmlChar * name);
-    XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr
                                                         writer,
                                                         const xmlChar *
                                                         prefix,
@@ -193,36 +193,36 @@ extern "C" {
                                                         name,
                                                         const xmlChar *
                                                         namespaceURI);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr
                                                     writer);
 
 /*
  * Attributes conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
                                           const xmlChar * name,
                                           const char *format, ...)
                                          LIBXML_ATTR_FORMAT(3,4);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
                                            const xmlChar * name,
                                            const char *format,
                                            va_list argptr)
                                           LIBXML_ATTR_FORMAT(3,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr
                                                       writer,
                                                       const xmlChar * name,
                                                       const xmlChar *
                                                       content);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
                                             const xmlChar * prefix,
                                             const xmlChar * name,
                                             const xmlChar * namespaceURI,
                                             const char *format, ...)
                                            LIBXML_ATTR_FORMAT(5,6);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
                                              const xmlChar * prefix,
                                              const xmlChar * name,
@@ -230,7 +230,7 @@ extern "C" {
                                              const char *format,
                                              va_list argptr)
                                             LIBXML_ATTR_FORMAT(5,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
                                                         writer,
                                                         const xmlChar *
                                                         prefix,
@@ -244,25 +244,25 @@ extern "C" {
 /*
  * PI's
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartPI(xmlTextWriterPtr writer,
                              const xmlChar * target);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer);
 
 /*
  * PI conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
                                    const xmlChar * target,
                                    const char *format, ...)
                                   LIBXML_ATTR_FORMAT(3,4);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
                                     const xmlChar * target,
                                     const char *format, va_list argptr)
                                    LIBXML_ATTR_FORMAT(3,0);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWritePI(xmlTextWriterPtr writer,
                              const xmlChar * target,
                              const xmlChar * content);
@@ -277,52 +277,52 @@ extern "C" {
 /*
  * CDATA
  */
-    XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
 
 /*
  * CDATA conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
                                       const char *format, ...)
                                      LIBXML_ATTR_FORMAT(2,3);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
                                        const char *format, va_list argptr)
                                       LIBXML_ATTR_FORMAT(2,0);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
                                 const xmlChar * content);
 
 /*
  * DTD
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartDTD(xmlTextWriterPtr writer,
                               const xmlChar * name,
                               const xmlChar * pubid,
                               const xmlChar * sysid);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer);
 
 /*
  * DTD conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
                                     const xmlChar * name,
                                     const xmlChar * pubid,
                                     const xmlChar * sysid,
                                     const char *format, ...)
                                    LIBXML_ATTR_FORMAT(5,6);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
                                      const xmlChar * name,
                                      const xmlChar * pubid,
                                      const xmlChar * sysid,
                                      const char *format, va_list argptr)
                                     LIBXML_ATTR_FORMAT(5,0);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
                               const xmlChar * name,
                               const xmlChar * pubid,
@@ -339,27 +339,27 @@ extern "C" {
 /*
  * DTD element definition
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
                                      const xmlChar * name);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr
                                                      writer);
 
 /*
  * DTD element definition conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
                                            const xmlChar * name,
                                            const char *format, ...)
                                           LIBXML_ATTR_FORMAT(3,4);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
                                             const xmlChar * name,
                                             const char *format,
                                             va_list argptr)
                                            LIBXML_ATTR_FORMAT(3,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr
                                                        writer,
                                                        const xmlChar *
                                                        name,
@@ -369,27 +369,27 @@ extern "C" {
 /*
  * DTD attribute list definition
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
                                      const xmlChar * name);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
                                                      writer);
 
 /*
  * DTD attribute list definition conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
                                            const xmlChar * name,
                                            const char *format, ...)
                                           LIBXML_ATTR_FORMAT(3,4);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
                                             const xmlChar * name,
                                             const char *format,
                                             va_list argptr)
                                            LIBXML_ATTR_FORMAT(3,0);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
                                                        writer,
                                                        const xmlChar *
                                                        name,
@@ -399,48 +399,48 @@ extern "C" {
 /*
  * DTD entity definition
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
                                     int pe, const xmlChar * name);
-    XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr
                                                     writer);
 
 /*
  * DTD entity definition conveniency functions
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
                                                   int pe,
                                                   const xmlChar * name,
                                                   const char *format, ...)
                                                  LIBXML_ATTR_FORMAT(4,5);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
                                                    int pe,
                                                    const xmlChar * name,
                                                    const char *format,
                                                    va_list argptr)
                                                   LIBXML_ATTR_FORMAT(4,0);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
                                             int pe,
                                             const xmlChar * name,
                                             const xmlChar * content);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
                                             int pe,
                                             const xmlChar * name,
                                             const xmlChar * pubid,
                                             const xmlChar * sysid,
                                             const xmlChar * ndataid);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr
                                                     writer,
                                                     const xmlChar * pubid,
                                                     const xmlChar * sysid,
                                                     const xmlChar *
                                                     ndataid);
-    XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
+    XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
                                                       writer, int pe,
                                                       const xmlChar * name,
                                                       const xmlChar *
@@ -455,7 +455,7 @@ extern "C" {
 /*
  * DTD notation definition
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
                                       const xmlChar * name,
                                       const xmlChar * pubid,
@@ -464,20 +464,20 @@ extern "C" {
 /*
  * Indentation
  */
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
                                      const xmlChar * str);
 
-    XMLPUBFUN int XMLCALL
+    XMLPUBFUN int
         xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
 
 
 /*
  * misc
  */
-    XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer);
+    XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer);
 
 #ifdef __cplusplus
 }
index bfbc5d6..6dae078 100644 (file)
@@ -400,7 +400,7 @@ struct _xmlXPathParserContext {
     int xptr;                          /* it this an XPointer expression */
     xmlNodePtr         ancestor;       /* used for walking preceding axis */
 
-    int              valueFrame;        /* used to limit Pop on the stack */
+    int              valueFrame;        /* always zero for compatibility */
 };
 
 /************************************************************************
@@ -454,68 +454,68 @@ XMLPUBVAR double xmlXPathNINF;
     (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))
 
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathFreeObject          (xmlXPathObjectPtr obj);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                    xmlXPathNodeSetCreate       (xmlNodePtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathFreeNodeSetList     (xmlXPathObjectPtr obj);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathFreeNodeSet         (xmlNodeSetPtr obj);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathObjectCopy          (xmlXPathObjectPtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCmpNodes            (xmlNodePtr node1,
                                                 xmlNodePtr node2);
 /**
  * Conversion functions to basic types.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCastNumberToBoolean (double val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCastStringToBoolean (const xmlChar * val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCastToBoolean       (xmlXPathObjectPtr val);
 
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                    xmlXPathCastBooleanToNumber (int val);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                    xmlXPathCastStringToNumber  (const xmlChar * val);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                    xmlXPathCastNodeToNumber    (xmlNodePtr node);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                    xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                    xmlXPathCastToNumber        (xmlXPathObjectPtr val);
 
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlXPathCastBooleanToString (int val);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlXPathCastNumberToString  (double val);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlXPathCastNodeToString    (xmlNodePtr node);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlXPathCastNodeSetToString (xmlNodeSetPtr ns);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                    xmlXPathCastToString        (xmlXPathObjectPtr val);
 
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathConvertBoolean      (xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathConvertNumber       (xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathConvertString       (xmlXPathObjectPtr val);
 
 /**
  * Context handling.
  */
-XMLPUBFUN xmlXPathContextPtr XMLCALL
+XMLPUBFUN xmlXPathContextPtr
                    xmlXPathNewContext          (xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathFreeContext         (xmlXPathContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
                                            int active,
                                            int value,
@@ -523,48 +523,48 @@ XMLPUBFUN int XMLCALL
 /**
  * Evaluation functions.
  */
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long
                    xmlXPathOrderDocElems       (xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathSetContextNode      (xmlNodePtr node,
                                                 xmlXPathContextPtr ctx);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathNodeEval            (xmlNodePtr node,
                                                 const xmlChar *str,
                                                 xmlXPathContextPtr ctx);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathEval                (const xmlChar *str,
                                                 xmlXPathContextPtr ctx);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathEvalExpression      (const xmlChar *str,
                                                 xmlXPathContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathEvalPredicate       (xmlXPathContextPtr ctxt,
                                                 xmlXPathObjectPtr res);
 /**
  * Separate compilation/evaluation entry points.
  */
-XMLPUBFUN xmlXPathCompExprPtr XMLCALL
+XMLPUBFUN xmlXPathCompExprPtr
                    xmlXPathCompile             (const xmlChar *str);
-XMLPUBFUN xmlXPathCompExprPtr XMLCALL
+XMLPUBFUN xmlXPathCompExprPtr
                    xmlXPathCtxtCompile         (xmlXPathContextPtr ctxt,
                                                 const xmlChar *str);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPathCompiledEval        (xmlXPathCompExprPtr comp,
                                                 xmlXPathContextPtr ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                    xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,
                                                 xmlXPathContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathFreeCompExpr        (xmlXPathCompExprPtr comp);
 #endif /* LIBXML_XPATH_ENABLED */
 #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPathInit                (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathIsNaN   (double val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathIsInf   (double val);
 
 #ifdef __cplusplus
index 76a6b48..d1c90df 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef __XML_XPATH_INTERNALS_H__
 #define __XML_XPATH_INTERNALS_H__
 
+#include <stdio.h>
 #include <libxml/xmlversion.h>
 #include <libxml/xpath.h>
 
@@ -100,15 +101,15 @@ extern "C" {
  */
 #define xmlXPathGetContextNode(ctxt)   ((ctxt)->context->node)
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathPopBoolean      (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                xmlXPathPopNumber       (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlXPathPopString       (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathPopNodeSet      (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void *
                xmlXPathPopExternal     (xmlXPathParserContextPtr ctxt);
 
 /**
@@ -297,7 +298,7 @@ XMLPUBFUN void * XMLCALL
     if (ctxt == NULL) return;                                          \
     if (nargs != (x))                                                  \
         XP_ERROR(XPATH_INVALID_ARITY);                                 \
-    if (ctxt->valueNr < ctxt->valueFrame + (x))                                \
+    if (ctxt->valueNr < (x))                                           \
         XP_ERROR(XPATH_STACK_ERROR);
 
 /**
@@ -331,7 +332,7 @@ XMLPUBFUN void * XMLCALL
  * Variable Lookup forwarding.
  */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
        xmlXPathRegisterVariableLookup  (xmlXPathContextPtr ctxt,
                                         xmlXPathVariableLookupFunc f,
                                         void *data);
@@ -340,7 +341,7 @@ XMLPUBFUN void XMLCALL
  * Function Lookup forwarding.
  */
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlXPathRegisterFuncLookup  (xmlXPathContextPtr ctxt,
                                         xmlXPathFuncLookupFunc f,
                                         void *funcCtxt);
@@ -348,22 +349,22 @@ XMLPUBFUN void XMLCALL
 /*
  * Error reporting.
  */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPatherror   (xmlXPathParserContextPtr ctxt,
                                 const char *file,
                                 int line,
                                 int no);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathErr     (xmlXPathParserContextPtr ctxt,
                                 int error);
 
 #ifdef LIBXML_DEBUG_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathDebugDumpObject (FILE *output,
                                         xmlXPathObjectPtr cur,
                                         int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
            xmlXPathDebugDumpCompExpr(FILE *output,
                                         xmlXPathCompExprPtr comp,
                                         int depth);
@@ -371,48 +372,48 @@ XMLPUBFUN void XMLCALL
 /**
  * NodeSet handling.
  */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathNodeSetContains         (xmlNodeSetPtr cur,
                                                 xmlNodePtr val);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathDifference              (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathIntersection            (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
 
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathDistinctSorted          (xmlNodeSetPtr nodes);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathDistinct                (xmlNodeSetPtr nodes);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathHasSameNodes            (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
 
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathNodeLeadingSorted       (xmlNodeSetPtr nodes,
                                                 xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathLeadingSorted           (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathNodeLeading             (xmlNodeSetPtr nodes,
                                                 xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathLeading                 (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
 
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathNodeTrailingSorted      (xmlNodeSetPtr nodes,
                                                 xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathTrailingSorted          (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathNodeTrailing            (xmlNodeSetPtr nodes,
                                                 xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathTrailing                (xmlNodeSetPtr nodes1,
                                                 xmlNodeSetPtr nodes2);
 
@@ -421,208 +422,208 @@ XMLPUBFUN xmlNodeSetPtr XMLCALL
  * Extending a context.
  */
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathRegisterNs              (xmlXPathContextPtr ctxt,
                                                 const xmlChar *prefix,
                                                 const xmlChar *ns_uri);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar *
                xmlXPathNsLookup                (xmlXPathContextPtr ctxt,
                                                 const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathRegisteredNsCleanup     (xmlXPathContextPtr ctxt);
 
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathRegisterFunc            (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 xmlXPathFunction f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathRegisterFuncNS          (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 const xmlChar *ns_uri,
                                                 xmlXPathFunction f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathRegisterVariable        (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 xmlXPathObjectPtr value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathRegisterVariableNS      (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 const xmlChar *ns_uri,
                                                 xmlXPathObjectPtr value);
-XMLPUBFUN xmlXPathFunction XMLCALL
+XMLPUBFUN xmlXPathFunction
                xmlXPathFunctionLookup          (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name);
-XMLPUBFUN xmlXPathFunction XMLCALL
+XMLPUBFUN xmlXPathFunction
                xmlXPathFunctionLookupNS        (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 const xmlChar *ns_uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathRegisteredFuncsCleanup  (xmlXPathContextPtr ctxt);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathVariableLookup          (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathVariableLookupNS        (xmlXPathContextPtr ctxt,
                                                 const xmlChar *name,
                                                 const xmlChar *ns_uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
 
 /**
  * Utilities to extend XPath.
  */
-XMLPUBFUN xmlXPathParserContextPtr XMLCALL
+XMLPUBFUN xmlXPathParserContextPtr
                  xmlXPathNewParserContext      (const xmlChar *str,
                                                 xmlXPathContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathFreeParserContext       (xmlXPathParserContextPtr ctxt);
 
 /* TODO: remap to xmlXPathValuePop and Push. */
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                valuePop                        (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                valuePush                       (xmlXPathParserContextPtr ctxt,
                                                 xmlXPathObjectPtr value);
 
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewString               (const xmlChar *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewCString              (const char *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathWrapString              (xmlChar *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathWrapCString             (char * val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewFloat                (double val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewBoolean              (int val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewNodeSet              (xmlNodePtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewValueTree            (xmlNodePtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathNodeSetAdd              (xmlNodeSetPtr cur,
                                                 xmlNodePtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathNodeSetAddUnique        (xmlNodeSetPtr cur,
                                                 xmlNodePtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathNodeSetAddNs            (xmlNodeSetPtr cur,
                                                 xmlNodePtr node,
                                                 xmlNsPtr ns);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathNodeSetSort             (xmlNodeSetPtr set);
 
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathRoot                    (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathEvalExpr                (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlXPathParseName               (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar *
                xmlXPathParseNCName             (xmlXPathParserContextPtr ctxt);
 
 /*
  * Existing functions.
  */
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double
                xmlXPathStringEvalNumber        (const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int
                xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
                                                 xmlXPathObjectPtr res);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathRegisterAllFunctions    (xmlXPathContextPtr ctxt);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr
                xmlXPathNodeSetMerge            (xmlNodeSetPtr val1,
                                                 xmlNodeSetPtr val2);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathNodeSetDel              (xmlNodeSetPtr cur,
                                                 xmlNodePtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                xmlXPathNodeSetRemove           (xmlNodeSetPtr cur,
                                                 int val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathNewNodeSetList          (xmlNodeSetPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathWrapNodeSet             (xmlNodeSetPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                xmlXPathWrapExternal            (void *val);
 
-XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
-XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
+XMLPUBFUN void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
 
-XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name);
+XMLPUBFUN int xmlXPathIsNodeType(const xmlChar *name);
 
 /*
  * Some of the axis navigation routines.
  */
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
+XMLPUBFUN xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
                        xmlNodePtr cur);
 /*
  * The official core of XPath functions.
  */
-XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
-XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
+XMLPUBFUN void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
 
 /**
  * Really internal functions
  */
-XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns);
+XMLPUBFUN void xmlXPathNodeSetFreeNs(xmlNsPtr ns);
 
 #ifdef __cplusplus
 }
index ca7bdbe..a526000 100644 (file)
@@ -28,7 +28,7 @@
 extern "C" {
 #endif
 
-#ifdef LIBXML_XPTR_LOCS_ENABLED
+#if defined(LIBXML_XPTR_LOCS_ENABLED)
 /*
  * A Location Set
  */
@@ -45,90 +45,91 @@ struct _xmlLocationSet {
  */
 
 XML_DEPRECATED
-XMLPUBFUN xmlLocationSetPtr XMLCALL
+XMLPUBFUN xmlLocationSetPtr
                    xmlXPtrLocationSetCreate    (xmlXPathObjectPtr val);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrFreeLocationSet      (xmlLocationSetPtr obj);
 XML_DEPRECATED
-XMLPUBFUN xmlLocationSetPtr XMLCALL
+XMLPUBFUN xmlLocationSetPtr
                    xmlXPtrLocationSetMerge     (xmlLocationSetPtr val1,
                                                 xmlLocationSetPtr val2);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRange             (xmlNodePtr start,
                                                 int startindex,
                                                 xmlNodePtr end,
                                                 int endindex);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRangePoints       (xmlXPathObjectPtr start,
                                                 xmlXPathObjectPtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRangeNodePoint    (xmlNodePtr start,
                                                 xmlXPathObjectPtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRangePointNode    (xmlXPathObjectPtr start,
                                                 xmlNodePtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRangeNodes        (xmlNodePtr start,
                                                 xmlNodePtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewLocationSetNodes  (xmlNodePtr start,
                                                 xmlNodePtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewRangeNodeObject   (xmlNodePtr start,
                                                 xmlXPathObjectPtr end);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrNewCollapsedRange    (xmlNodePtr start);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrLocationSetAdd       (xmlLocationSetPtr cur,
                                                 xmlXPathObjectPtr val);
 XML_DEPRECATED
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrWrapLocationSet      (xmlLocationSetPtr val);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrLocationSetDel       (xmlLocationSetPtr cur,
                                                 xmlXPathObjectPtr val);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrLocationSetRemove    (xmlLocationSetPtr cur,
                                                 int val);
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
+#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
 
 /*
  * Functions.
  */
-XMLPUBFUN xmlXPathContextPtr XMLCALL
+XMLPUBFUN xmlXPathContextPtr
                    xmlXPtrNewContext           (xmlDocPtr doc,
                                                 xmlNodePtr here,
                                                 xmlNodePtr origin);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr
                    xmlXPtrEval                 (const xmlChar *str,
                                                 xmlXPathContextPtr ctx);
-#ifdef LIBXML_XPTR_LOCS_ENABLED
+
+#if defined(LIBXML_XPTR_LOCS_ENABLED)
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrRangeToFunction      (xmlXPathParserContextPtr ctxt,
                                                 int nargs);
 XML_DEPRECATED
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr
                    xmlXPtrBuildNodeList        (xmlXPathObjectPtr obj);
 XML_DEPRECATED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void
                    xmlXPtrEvalRangePredicate   (xmlXPathParserContextPtr ctxt);
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
+#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/private/Makefile.am b/include/private/Makefile.am
new file mode 100644 (file)
index 0000000..29c0bdd
--- /dev/null
@@ -0,0 +1,19 @@
+EXTRA_DIST = \
+       buf.h \
+       dict.h \
+       enc.h \
+       entities.h \
+       error.h \
+       globals.h \
+       html.h \
+       io.h \
+       memory.h \
+       parser.h \
+       regexp.h \
+       save.h \
+       string.h \
+       threads.h \
+       tree.h \
+       xinclude.h \
+       xpath.h \
+       xzlib.h
diff --git a/include/private/buf.h b/include/private/buf.h
new file mode 100644 (file)
index 0000000..6fef4ce
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef XML_BUF_H_PRIVATE__
+#define XML_BUF_H_PRIVATE__
+
+#include <libxml/tree.h>
+
+XML_HIDDEN xmlBufPtr
+xmlBufCreate(void);
+XML_HIDDEN xmlBufPtr
+xmlBufCreateSize(size_t size);
+
+XML_HIDDEN int
+xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme);
+XML_HIDDEN int
+xmlBufGetAllocationScheme(xmlBufPtr buf);
+
+XML_HIDDEN void
+xmlBufFree(xmlBufPtr buf);
+XML_HIDDEN void
+xmlBufEmpty(xmlBufPtr buf);
+
+/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
+XML_HIDDEN int
+xmlBufGrow(xmlBufPtr buf, int len);
+XML_HIDDEN int
+xmlBufResize(xmlBufPtr buf, size_t len);
+
+XML_HIDDEN int
+xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
+XML_HIDDEN int
+xmlBufCat(xmlBufPtr buf, const xmlChar *str);
+XML_HIDDEN int
+xmlBufCCat(xmlBufPtr buf, const char *str);
+XML_HIDDEN int
+xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
+
+XML_HIDDEN size_t
+xmlBufAvail(const xmlBufPtr buf);
+XML_HIDDEN size_t
+xmlBufLength(const xmlBufPtr buf);
+/* size_t xmlBufUse(const xmlBufPtr buf); */
+XML_HIDDEN int
+xmlBufIsEmpty(const xmlBufPtr buf);
+XML_HIDDEN int
+xmlBufAddLen(xmlBufPtr buf, size_t len);
+
+/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
+/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
+
+XML_HIDDEN xmlChar *
+xmlBufDetach(xmlBufPtr buf);
+
+XML_HIDDEN size_t
+xmlBufDump(FILE *file, xmlBufPtr buf);
+
+XML_HIDDEN xmlBufPtr
+xmlBufFromBuffer(xmlBufferPtr buffer);
+XML_HIDDEN xmlBufferPtr
+xmlBufBackToBuffer(xmlBufPtr buf);
+XML_HIDDEN int
+xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
+
+XML_HIDDEN int
+xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
+XML_HIDDEN int
+xmlBufUpdateInput(xmlBufPtr buf, xmlParserInputPtr input, size_t pos);
+
+#endif /* XML_BUF_H_PRIVATE__ */
diff --git a/include/private/dict.h b/include/private/dict.h
new file mode 100644 (file)
index 0000000..9b0be62
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef XML_DICT_H_PRIVATE__
+#define XML_DICT_H_PRIVATE__
+
+#include <libxml/dict.h>
+
+/*
+ * Values are ANDed with 0xFFFFFFFF to support platforms where
+ * unsigned is larger than 32 bits. With 32-bit unsigned values,
+ * modern compilers should optimize the operation away.
+ */
+
+#define HASH_ROL(x,n) ((x) << (n) | ((x) & 0xFFFFFFFF) >> (32 - (n)))
+#define HASH_ROR(x,n) (((x) & 0xFFFFFFFF) >> (n) | (x) << (32 - (n)))
+
+/*
+ * GoodOAAT: One of a smallest non-multiplicative One-At-a-Time functions
+ * that passes SMHasher.
+ *
+ * Author: Sokolov Yura aka funny-falcon
+ */
+
+#define HASH_INIT(h1, h2, seed) \
+    do { \
+        h1 = seed ^ 0x3b00; \
+        h2 = HASH_ROL(seed, 15); \
+    } while (0)
+
+#define HASH_UPDATE(h1, h2, ch) \
+    do { \
+        h1 += ch; \
+        h1 += h1 << 3; \
+        h2 += h1; \
+        h2 = HASH_ROL(h2, 7); \
+        h2 += h2 << 2; \
+    } while (0)
+
+/* Result is in h2 */
+#define HASH_FINISH(h1, h2) \
+    do { \
+        h1 ^= h2; \
+        h1 += HASH_ROL(h2, 14); \
+        h2 ^= h1; h2 += HASH_ROR(h1, 6); \
+        h1 ^= h2; h1 += HASH_ROL(h2, 5); \
+        h2 ^= h1; h2 += HASH_ROR(h1, 8); \
+        h2 &= 0xFFFFFFFF; \
+    } while (0)
+
+typedef struct {
+    unsigned hashValue;
+    const xmlChar *name;
+} xmlHashedString;
+
+XML_HIDDEN void
+xmlInitDictInternal(void);
+XML_HIDDEN void
+xmlCleanupDictInternal(void);
+
+XML_HIDDEN unsigned
+xmlDictComputeHash(const xmlDict *dict, const xmlChar *string);
+XML_HIDDEN unsigned
+xmlDictCombineHash(unsigned v1, unsigned v2);
+XML_HIDDEN xmlHashedString
+xmlDictLookupHashed(xmlDictPtr dict, const xmlChar *name, int len);
+
+XML_HIDDEN void
+xmlInitRandom(void);
+XML_HIDDEN void
+xmlCleanupRandom(void);
+XML_HIDDEN unsigned
+xmlRandom(void);
+
+#endif /* XML_DICT_H_PRIVATE__ */
diff --git a/include/private/enc.h b/include/private/enc.h
new file mode 100644 (file)
index 0000000..cd54914
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef XML_ENC_H_PRIVATE__
+#define XML_ENC_H_PRIVATE__
+
+#include <libxml/encoding.h>
+#include <libxml/tree.h>
+
+XML_HIDDEN void
+xmlInitEncodingInternal(void);
+
+XML_HIDDEN int
+xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
+                 int *outlen, const unsigned char *in, int *inlen);
+XML_HIDDEN int
+xmlCharEncInput(xmlParserInputBufferPtr input);
+XML_HIDDEN int
+xmlCharEncOutput(xmlOutputBufferPtr output, int init);
+
+#endif /* XML_ENC_H_PRIVATE__ */
diff --git a/include/private/entities.h b/include/private/entities.h
new file mode 100644 (file)
index 0000000..c3f15e6
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef XML_ENTITIES_H_PRIVATE__
+#define XML_ENTITIES_H_PRIVATE__
+
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+
+/*
+ * Entity flags
+ *
+ * XML_ENT_PARSED: The entity was parsed and `children` points to the
+ * content.
+ * XML_ENT_CHECKED: The entity was checked for loops.
+ */
+#define XML_ENT_PARSED      (1<<0)
+#define XML_ENT_CHECKED     (1<<1)
+#define XML_ENT_EXPANDING   (1<<2)
+#define XML_ENT_CHECKED_LT  (1<<3)
+#define XML_ENT_CONTAINS_LT (1<<4)
+
+XML_HIDDEN xmlChar *
+xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
+
+#endif /* XML_ENTITIES_H_PRIVATE__ */
diff --git a/include/private/error.h b/include/private/error.h
new file mode 100644 (file)
index 0000000..165b782
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef XML_ERROR_H_PRIVATE__
+#define XML_ERROR_H_PRIVATE__
+
+#include <libxml/xmlerror.h>
+#include <libxml/xmlversion.h>
+
+struct _xmlNode;
+
+XML_HIDDEN void
+__xmlRaiseError(xmlStructuredErrorFunc schannel,
+                xmlGenericErrorFunc channel, void *data, void *ctx,
+                void *nod, int domain, int code, xmlErrorLevel level,
+                const char *file, int line, const char *str1,
+                const char *str2, const char *str3, int int1, int col,
+               const char *msg, ...) LIBXML_ATTR_FORMAT(16,17);
+XML_HIDDEN void
+__xmlSimpleError(int domain, int code, struct _xmlNode *node,
+                 const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0);
+XML_HIDDEN void
+xmlGenericErrorDefaultFunc(void *ctx, const char *msg,
+                           ...) LIBXML_ATTR_FORMAT(2,3);
+
+#endif /* XML_ERROR_H_PRIVATE__ */
diff --git a/include/private/globals.h b/include/private/globals.h
new file mode 100644 (file)
index 0000000..5f3f112
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef XML_GLOBALS_H_PRIVATE__
+#define XML_GLOBALS_H_PRIVATE__
+
+XML_HIDDEN void
+xmlInitGlobalsInternal(void);
+XML_HIDDEN void
+xmlCleanupGlobalsInternal(void);
+
+#endif /* XML_GLOBALS_H_PRIVATE__ */
diff --git a/include/private/html.h b/include/private/html.h
new file mode 100644 (file)
index 0000000..6b49929
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef XML_HTML_H_PRIVATE__
+#define XML_HTML_H_PRIVATE__
+
+#include <libxml/xmlversion.h>
+
+#ifdef LIBXML_HTML_ENABLED
+
+XML_HIDDEN void
+__htmlParseContent(void *ctx);
+
+#endif /* LIBXML_HTML_ENABLED */
+
+#endif /* XML_HTML_H_PRIVATE__ */
+
diff --git a/include/private/io.h b/include/private/io.h
new file mode 100644 (file)
index 0000000..5f4b210
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef XML_IO_H_PRIVATE__
+#define XML_IO_H_PRIVATE__
+
+#include <libxml/encoding.h>
+#include <libxml/tree.h>
+#include <libxml/xmlversion.h>
+
+XML_HIDDEN void
+__xmlIOErr(int domain, int code, const char *extra);
+XML_HIDDEN void
+__xmlLoaderErr(void *ctx, const char *msg,
+               const char *filename) LIBXML_ATTR_FORMAT(2,0);
+
+xmlParserInputBufferPtr
+xmlParserInputBufferCreateString(const xmlChar *str);
+
+#ifdef LIBXML_OUTPUT_ENABLED
+XML_HIDDEN xmlOutputBufferPtr
+xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
+#endif
+
+#endif /* XML_IO_H_PRIVATE__ */
diff --git a/include/private/memory.h b/include/private/memory.h
new file mode 100644 (file)
index 0000000..ef0497c
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef XML_MEMORY_H_PRIVATE__
+#define XML_MEMORY_H_PRIVATE__
+
+XML_HIDDEN void
+xmlInitMemoryInternal(void);
+XML_HIDDEN void
+xmlCleanupMemoryInternal(void);
+
+#endif /* XML_MEMORY_H_PRIVATE__ */
diff --git a/include/private/parser.h b/include/private/parser.h
new file mode 100644 (file)
index 0000000..40d179f
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef XML_PARSER_H_PRIVATE__
+#define XML_PARSER_H_PRIVATE__
+
+#include <libxml/parser.h>
+#include <libxml/xmlversion.h>
+
+/**
+ * XML_VCTXT_DTD_VALIDATED:
+ *
+ * Set after xmlValidateDtdFinal was called.
+ */
+#define XML_VCTXT_DTD_VALIDATED (1u << 0)
+/**
+ * XML_VCTXT_USE_PCTXT:
+ *
+ * Set if the validation context is part of a parser context.
+ */
+#define XML_VCTXT_USE_PCTXT (1u << 1)
+
+#define XML_INPUT_HAS_ENCODING      (1u << 0)
+#define XML_INPUT_AUTO_ENCODING     (7u << 1)
+#define XML_INPUT_AUTO_UTF8         (1u << 1)
+#define XML_INPUT_AUTO_UTF16LE      (2u << 1)
+#define XML_INPUT_AUTO_UTF16BE      (3u << 1)
+#define XML_INPUT_AUTO_OTHER        (4u << 1)
+#define XML_INPUT_USES_ENC_DECL     (1u << 4)
+#define XML_INPUT_ENCODING_ERROR    (1u << 5)
+
+XML_HIDDEN void
+xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra);
+XML_HIDDEN void
+xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
+XML_HIDDEN void LIBXML_ATTR_FORMAT(3,0)
+xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
+              const char *msg, const xmlChar *str1, const xmlChar *str2);
+XML_HIDDEN void
+__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
+                 const char *msg, const xmlChar *str1,
+                 const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0);
+XML_HIDDEN void
+xmlHaltParser(xmlParserCtxtPtr ctxt);
+XML_HIDDEN int
+xmlParserGrow(xmlParserCtxtPtr ctxt);
+XML_HIDDEN void
+xmlParserShrink(xmlParserCtxtPtr ctxt);
+
+XML_HIDDEN void
+xmlDetectEncoding(xmlParserCtxtPtr ctxt);
+XML_HIDDEN void
+xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding);
+
+XML_HIDDEN xmlParserNsData *
+xmlParserNsCreate(void);
+XML_HIDDEN void
+xmlParserNsFree(xmlParserNsData *nsdb);
+/*
+ * These functions allow SAX handlers to attach extra data to namespaces
+ * efficiently and should be made public.
+ */
+XML_HIDDEN int
+xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
+                     void *saxData);
+XML_HIDDEN void *
+xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix);
+
+#endif /* XML_PARSER_H_PRIVATE__ */
diff --git a/include/private/regexp.h b/include/private/regexp.h
new file mode 100644 (file)
index 0000000..f202493
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef XML_REGEXP_H_PRIVATE__
+#define XML_REGEXP_H_PRIVATE__
+
+#include <libxml/xmlautomata.h>
+
+XML_HIDDEN void
+xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
+
+#endif /* XML_REGEXP_H_PRIVATE__ */
diff --git a/include/private/save.h b/include/private/save.h
new file mode 100644 (file)
index 0000000..873aad7
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef XML_SAVE_H_PRIVATE__
+#define XML_SAVE_H_PRIVATE__
+
+#include <libxml/tree.h>
+#include <libxml/xmlversion.h>
+
+#ifdef LIBXML_OUTPUT_ENABLED
+
+XML_HIDDEN void
+xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
+                              xmlAttrPtr attr, const xmlChar * string);
+XML_HIDDEN void
+xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
+
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+#endif /* XML_SAVE_H_PRIVATE__ */
+
diff --git a/include/private/string.h b/include/private/string.h
new file mode 100644 (file)
index 0000000..9665fc4
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef XML_STRING_H_PRIVATE__
+#define XML_STRING_H_PRIVATE__
+
+#include <libxml/xmlstring.h>
+
+XML_HIDDEN xmlChar *
+xmlEscapeFormatString(xmlChar **msg);
+
+#endif /* XML_STRING_H_PRIVATE__ */
diff --git a/include/private/threads.h b/include/private/threads.h
new file mode 100644 (file)
index 0000000..473bc7c
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef XML_THREADS_H_PRIVATE__
+#define XML_THREADS_H_PRIVATE__
+
+#include <libxml/threads.h>
+
+#ifdef LIBXML_THREAD_ENABLED
+  #ifdef HAVE_PTHREAD_H
+    #include <pthread.h>
+    #define HAVE_POSIX_THREADS
+  #elif defined(_WIN32)
+    #define WIN32_LEAN_AND_MEAN
+    #include <windows.h>
+    #define HAVE_WIN32_THREADS
+  #endif
+#endif
+
+/*
+ * xmlMutex are a simple mutual exception locks
+ */
+struct _xmlMutex {
+#ifdef HAVE_POSIX_THREADS
+    pthread_mutex_t lock;
+#elif defined HAVE_WIN32_THREADS
+    CRITICAL_SECTION cs;
+#else
+    int empty;
+#endif
+};
+
+XML_HIDDEN void
+xmlInitMutex(xmlMutexPtr mutex);
+XML_HIDDEN void
+xmlCleanupMutex(xmlMutexPtr mutex);
+
+#endif /* XML_THREADS_H_PRIVATE__ */
diff --git a/include/private/tree.h b/include/private/tree.h
new file mode 100644 (file)
index 0000000..fb5e162
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef XML_TREE_H_PRIVATE__
+#define XML_TREE_H_PRIVATE__
+
+/*
+ * Internal variable indicating if a callback has been registered for
+ * node creation/destruction. It avoids spending a lot of time in locking
+ * function while checking if the callback exists.
+ */
+XML_HIDDEN extern int
+__xmlRegisterCallbacks;
+
+XML_HIDDEN xmlNodePtr
+xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
+                  int extended);
+XML_HIDDEN xmlNodePtr
+xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent);
+
+#endif /* XML_TREE_H_PRIVATE__ */
diff --git a/include/private/xinclude.h b/include/private/xinclude.h
new file mode 100644 (file)
index 0000000..43c77e5
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef XML_INCLUDE_H_PRIVATE__
+#define XML_INCLUDE_H_PRIVATE__
+
+#include <libxml/xinclude.h>
+
+XML_HIDDEN int
+xmlXIncludeSetStreamingMode(xmlXIncludeCtxtPtr ctxt, int mode);
+
+#endif /* XML_INCLUDE_H_PRIVATE__ */
diff --git a/include/private/xpath.h b/include/private/xpath.h
new file mode 100644 (file)
index 0000000..0e8d752
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef XML_XPATH_H_PRIVATE__
+#define XML_XPATH_H_PRIVATE__
+
+XML_HIDDEN void
+xmlInitXPathInternal(void);
+
+#endif /* XML_XPATH_H_PRIVATE__ */
diff --git a/include/private/xzlib.h b/include/private/xzlib.h
new file mode 100644 (file)
index 0000000..b332698
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * xzlib.h: header for the front end for the transparent support of lzma
+ *          compression at the I/O layer
+ *
+ * See Copyright for the status of this software.
+ *
+ * Anders F Bjorklund <afb@users.sourceforge.net>
+ */
+
+#ifndef LIBXML2_XZLIB_H
+#define LIBXML2_XZLIB_H
+
+#include <libxml/xmlversion.h>
+
+#ifdef LIBXML_LZMA_ENABLED
+
+typedef void *xzFile;           /* opaque lzma file descriptor */
+
+XML_HIDDEN xzFile
+__libxml2_xzopen(const char *path, const char *mode);
+XML_HIDDEN xzFile
+__libxml2_xzdopen(int fd, const char *mode);
+XML_HIDDEN int
+__libxml2_xzread(xzFile file, void *buf, unsigned len);
+XML_HIDDEN int
+__libxml2_xzclose(xzFile file);
+XML_HIDDEN int
+__libxml2_xzcompressed(xzFile f);
+
+#endif /* LIBXML_LZMA_ENABLED */
+
+#endif /* LIBXML2_XZLIB_H */
index 4f99ae0..a25e038 100644 (file)
@@ -1,20 +1,21 @@
 #ifndef __LIBXML_WIN32_CONFIG__
 #define __LIBXML_WIN32_CONFIG__
 
-#define SEND_ARG2_CAST
-#define GETHOSTBYNAME_ARG_CAST
-
 #define HAVE_SYS_STAT_H
 #define HAVE_STAT
 #define HAVE_FCNTL_H
 
 #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
-#define HAVE_STDINT_H
+  #define HAVE_STDINT_H
 #endif
 
-#if defined(_MSC_VER) && _MSC_VER < 1900
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
+#if defined(_MSC_VER)
+  #if _MSC_VER < 1900
+    #define snprintf _snprintf
+  #endif
+  #if _MSC_VER < 1500
+    #define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
+  #endif
 #endif
 
 #endif /* __LIBXML_WIN32_CONFIG__ */
index 85b9e7d..141de0c 100644 (file)
 /* Check if ws2tcpip.h is a recent version which provides getaddrinfo() */
 #if defined(GetAddrInfo)
 #include <wspiapi.h>
-#define HAVE_GETADDRINFO
+#ifndef SUPPORT_IP6
+  #define SUPPORT_IP6
+#endif
 #endif
 
-#undef XML_SOCKLEN_T
+#ifndef XML_SOCKLEN_T
 #define XML_SOCKLEN_T int
+#endif
 
 #ifndef ECONNRESET
 #define ECONNRESET WSAECONNRESET
index bde3854..4bd25fb 100644 (file)
--- a/legacy.c
+++ b/legacy.c
@@ -1338,5 +1338,427 @@ cdataBlock(void *ctx, const xmlChar * value, int len)
         xmlSAX2CDataBlock(ctx, value, len);
 }
 
+/*
+ * nanoftp.h
+ */
+
+#ifndef LIBXML_FTP_ENABLED
+
+#include <libxml/nanoftp.h>
+
+/** DOC_DISABLE */
+
+#ifdef _WIN32
+  #include <winsock2.h>
+#else
+  #define SOCKET int
+#endif
+
+typedef void
+(*ftpListCallback)(void *userData, const char *filename, const char *attrib,
+                   const char *owner, const char *group, unsigned long size,
+                   int links, int year, const char *month, int day, int hour,
+                   int minute);
+
+typedef void
+(*ftpDataCallback) (void *userData, const char *data, int len);
+
+XMLPUBFUN void
+xmlNanoFTPInit(void);
+
+void
+xmlNanoFTPInit(void) {
+}
+
+XMLPUBFUN void
+xmlNanoFTPCleanup(void);
+
+void
+xmlNanoFTPCleanup(void) {
+}
+
+XMLPUBFUN void
+xmlNanoFTPProxy(const char *host, int port, const char *user,
+                const char *passwd, int type);
+
+void
+xmlNanoFTPProxy(const char *host ATTRIBUTE_UNUSED, int port ATTRIBUTE_UNUSED,
+                const char *user ATTRIBUTE_UNUSED,
+               const char *passwd ATTRIBUTE_UNUSED, int type ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN int
+xmlNanoFTPUpdateURL(void *ctx, const char *URL);
+
+int
+xmlNanoFTPUpdateURL(void *ctx ATTRIBUTE_UNUSED,
+                    const char *URL ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN void
+xmlNanoFTPScanProxy(const char *URL);
+
+void
+xmlNanoFTPScanProxy(const char *URL ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN void *
+xmlNanoFTPNewCtxt(const char *URL);
+
+void*
+xmlNanoFTPNewCtxt(const char *URL ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN void
+xmlNanoFTPFreeCtxt(void *ctx);
+
+void
+xmlNanoFTPFreeCtxt(void * ctx ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN int
+xmlNanoFTPGetResponse(void *ctx);
+
+int
+xmlNanoFTPGetResponse(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPCheckResponse(void *ctx);
+
+int
+xmlNanoFTPCheckResponse(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPQuit(void *ctx);
+
+int
+xmlNanoFTPQuit(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPConnect(void *ctx);
+
+int
+xmlNanoFTPConnect(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN void *
+xmlNanoFTPConnectTo(const char *server, int port);
+
+void*
+xmlNanoFTPConnectTo(const char *server ATTRIBUTE_UNUSED,
+                    int port ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN int
+xmlNanoFTPCwd(void *ctx, const char *directory);
+
+int
+xmlNanoFTPCwd(void *ctx ATTRIBUTE_UNUSED,
+              const char *directory ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPDele(void *ctx, const char *file);
+
+int
+xmlNanoFTPDele(void *ctx ATTRIBUTE_UNUSED, const char *file ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN SOCKET
+xmlNanoFTPGetConnection(void *ctx);
+
+SOCKET
+xmlNanoFTPGetConnection(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPCloseConnection(void *ctx);
+
+int
+xmlNanoFTPCloseConnection(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
+              const char *filename);
+
+int
+xmlNanoFTPList(void *ctx ATTRIBUTE_UNUSED,
+               ftpListCallback callback ATTRIBUTE_UNUSED,
+               void *userData ATTRIBUTE_UNUSED,
+              const char *filename ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN SOCKET
+xmlNanoFTPGetSocket(void *ctx, const char *filename);
+
+SOCKET
+xmlNanoFTPGetSocket(void *ctx ATTRIBUTE_UNUSED,
+                    const char *filename ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
+             const char *filename);
+
+int
+xmlNanoFTPGet(void *ctx ATTRIBUTE_UNUSED,
+              ftpDataCallback callback ATTRIBUTE_UNUSED,
+              void *userData ATTRIBUTE_UNUSED,
+             const char *filename ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlNanoFTPRead(void *ctx, void *dest, int len);
+
+int
+xmlNanoFTPRead(void *ctx ATTRIBUTE_UNUSED, void *dest ATTRIBUTE_UNUSED,
+               int len ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN void *
+xmlNanoFTPOpen(const char *URL);
+
+void*
+xmlNanoFTPOpen(const char *URL ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN int
+xmlNanoFTPClose(void *ctx);
+
+int
+xmlNanoFTPClose(void *ctx ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlIOFTPMatch(const char *filename);
+
+int
+xmlIOFTPMatch(const char *filename ATTRIBUTE_UNUSED) {
+    return(0);
+}
+
+XMLPUBFUN void *
+xmlIOFTPOpen(const char *filename);
+
+void *
+xmlIOFTPOpen(const char *filename ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN int
+xmlIOFTPRead(void *context, char *buffer, int len);
+
+int
+xmlIOFTPRead(void *context ATTRIBUTE_UNUSED, char *buffer ATTRIBUTE_UNUSED,
+             int len ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+XMLPUBFUN int
+xmlIOFTPClose(void *context);
+
+int
+xmlIOFTPClose(void *context ATTRIBUTE_UNUSED) {
+    return(-1);
+}
+
+/** DOC_ENABLE */
+
+#endif /* #ifndef LIBXML_FTP_ENABLED */
+
+/*
+ * xpointer.h
+ */
+
+#ifndef LIBXML_XPTR_LOCS_ENABLED
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/xpointer.h>
+
+/** DOC_DISABLE */
+
+typedef struct _xmlLocationSet *xmlLocationSetPtr;
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRange(xmlNodePtr start, int startindex,
+                xmlNodePtr end, int endindex);
+
+xmlXPathObjectPtr
+xmlXPtrNewRange(xmlNodePtr start ATTRIBUTE_UNUSED,
+                int startindex ATTRIBUTE_UNUSED,
+                xmlNodePtr end ATTRIBUTE_UNUSED,
+                int endindex ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRangePoints(xmlXPathObjectPtr start, xmlXPathObjectPtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewRangePoints(xmlXPathObjectPtr start ATTRIBUTE_UNUSED,
+                      xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRangePointNode(xmlXPathObjectPtr start, xmlNodePtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewRangePointNode(xmlXPathObjectPtr start ATTRIBUTE_UNUSED,
+                         xmlNodePtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewRangeNodePoint(xmlNodePtr start ATTRIBUTE_UNUSED,
+                         xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRangeNodes(xmlNodePtr start, xmlNodePtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewRangeNodes(xmlNodePtr start ATTRIBUTE_UNUSED,
+                     xmlNodePtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewCollapsedRange(xmlNodePtr start);
+
+xmlXPathObjectPtr
+xmlXPtrNewCollapsedRange(xmlNodePtr start ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewRangeNodeObject(xmlNodePtr start ATTRIBUTE_UNUSED,
+                          xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlLocationSetPtr
+xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
+
+xmlLocationSetPtr
+xmlXPtrLocationSetCreate(xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN void
+xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val);
+
+void
+xmlXPtrLocationSetAdd(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
+                      xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN xmlLocationSetPtr
+xmlXPtrLocationSetMerge(xmlLocationSetPtr val1, xmlLocationSetPtr val2);
+
+xmlLocationSetPtr
+xmlXPtrLocationSetMerge(xmlLocationSetPtr val1 ATTRIBUTE_UNUSED,
+                        xmlLocationSetPtr val2 ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN void
+xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val);
+
+void
+xmlXPtrLocationSetDel(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
+                      xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN void
+xmlXPtrLocationSetRemove(xmlLocationSetPtr cur, int val);
+
+void
+xmlXPtrLocationSetRemove(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
+                         int val ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN void
+xmlXPtrFreeLocationSet(xmlLocationSetPtr obj);
+
+void
+xmlXPtrFreeLocationSet(xmlLocationSetPtr obj ATTRIBUTE_UNUSED) {
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end);
+
+xmlXPathObjectPtr
+xmlXPtrNewLocationSetNodes(xmlNodePtr start ATTRIBUTE_UNUSED,
+                           xmlNodePtr end ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
+
+xmlXPathObjectPtr
+xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlXPathObjectPtr
+xmlXPtrWrapLocationSet(xmlLocationSetPtr val);
+
+xmlXPathObjectPtr
+xmlXPtrWrapLocationSet(xmlLocationSetPtr val ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN xmlNodePtr
+xmlXPtrBuildNodeList(xmlXPathObjectPtr obj);
+
+xmlNodePtr
+xmlXPtrBuildNodeList(xmlXPathObjectPtr obj ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+
+XMLPUBFUN void
+xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs);
+
+void
+xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt,
+                       int nargs ATTRIBUTE_UNUSED) {
+    XP_ERROR(XPATH_EXPR_ERROR);
+}
+
+/** DOC_ENABLE */
+
+#endif /* #ifndef LIBXML_XPTR_LOCS_ENABLED */
+
 #endif /* LIBXML_LEGACY_ENABLED */
 
index 0c3186f..a7b81fa 100644 (file)
@@ -7,7 +7,6 @@ modules=@WITH_MODULES@
 Name: libXML
 Version: @VERSION@
 Description: libXML library version2.
-Requires:
-Libs: -L${libdir} @XML_LIBS@
-Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
+Requires@XML_PC_PRIVATE@: @XML_PC_REQUIRES@
+Libs: -L${libdir} @XML_LIBS@ @XML_PC_LIBS_PRIVATE@ @XML_PC_LIBS@ @LIBS@
 Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
index 88e3963..6d7b62f 100644 (file)
@@ -7,7 +7,6 @@ modules=@WITH_MODULES@
 Name: libXML
 Version: @VERSION@
 Description: libXML library version2.
-Requires:
-Libs: -L${libdir} @XML_LIBS@
-Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
+Requires@XML_PC_PRIVATE@: @XML_PC_REQUIRES@
+Libs: -L${libdir} @XML_LIBS@ @XML_PC_LIBS_PRIVATE@ @XML_PC_LIBS@ @LIBS@
 Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
index 66f164d..2f72e0a 100644 (file)
--- a/libxml.h
+++ b/libxml.h
  * Do not add any #include directives above this block.
  */
 #ifndef NO_LARGEFILE_SOURCE
-#ifndef _LARGEFILE_SOURCE
-#define _LARGEFILE_SOURCE
-#endif
-#ifndef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
+  #ifndef _LARGEFILE_SOURCE
+    #define _LARGEFILE_SOURCE
+  #endif
+  #ifndef _FILE_OFFSET_BITS
+    #define _FILE_OFFSET_BITS 64
+  #endif
 #endif
 
 /*
- * Currently supported platforms use either autoconf or
- * copy to config.h own "preset" configuration file.
- * As result ifdef HAVE_CONFIG_H is omitted here.
+ * These files are generated by the build system and contain private
+ * and public build configuration.
  */
 #include "config.h"
 #include <libxml/xmlversion.h>
-#include <libxml/xmlstring.h>
 
+/*
+ * Due to some Autotools limitations, this variable must be passed as
+ * compiler flag. Define a default value if the macro wasn't set by the
+ * build system.
+ */
 #ifndef SYSCONFDIR
   #define SYSCONFDIR "/etc"
 #endif
 
-#if defined(__Lynx__)
-#include <stdio.h> /* pull definition of size_t */
-#include <varargs.h>
-int snprintf(char *, size_t, const char *, ...);
-int vfprintf(FILE *, const char *, va_list);
+#ifdef WITH_TRIO
+  #define TRIO_REPLACE_STDIO
+  #include "trio.h"
 #endif
 
-#ifndef WITH_TRIO
-#include <stdio.h>
+#if !defined(_WIN32) && \
+    !defined(__CYGWIN__) && \
+    (defined(__clang__) || \
+     (defined(__GNUC__) && (__GNUC__ >= 4)))
+  #define XML_HIDDEN __attribute__((visibility("hidden")))
 #else
-/**
- * TRIO_REPLACE_STDIO:
- *
- * This macro is defined if the trio string formatting functions are to
- * be used instead of the default stdio ones.
- */
-#define TRIO_REPLACE_STDIO
-#include "trio.h"
-#endif
-
-#if defined(__clang__) || \
-    (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406))
-#define XML_IGNORE_PEDANTIC_WARNINGS \
-    _Pragma("GCC diagnostic push") \
-    _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
-#define XML_POP_WARNINGS \
-    _Pragma("GCC diagnostic pop")
-#else
-#define XML_IGNORE_PEDANTIC_WARNINGS
-#define XML_POP_WARNINGS
+  #define XML_HIDDEN
 #endif
 
 #if defined(__clang__) || \
     (defined(__GNUC__) && (__GNUC__ >= 8))
-#define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))
+  #define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))
 #else
-#define ATTRIBUTE_NO_SANITIZE(arg)
+  #define ATTRIBUTE_NO_SANITIZE(arg)
 #endif
 
-/*
- * Internal variable indicating if a callback has been registered for
- * node creation/destruction. It avoids spending a lot of time in locking
- * function while checking if the callback exists.
- */
-extern int __xmlRegisterCallbacks;
-/*
- * internal error reporting routines, shared but not part of the API.
- */
-void __xmlIOErr(int domain, int code, const char *extra);
-void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0);
-#ifdef LIBXML_HTML_ENABLED
-/*
- * internal function of HTML parser needed for xmlParseInNodeContext
- * but not part of the API
- */
-void __htmlParseContent(void *ctx);
+#ifdef __clang__
+  #define ATTRIBUTE_NO_SANITIZE_INTEGER \
+    ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") \
+    ATTRIBUTE_NO_SANITIZE("unsigned-shift-base")
+#else
+  #define ATTRIBUTE_NO_SANITIZE_INTEGER
 #endif
 
-/*
- * internal global initialization critical section routines.
- */
-void __xmlGlobalInitMutexLock(void);
-void __xmlGlobalInitMutexUnlock(void);
-void __xmlGlobalInitMutexDestroy(void);
-
-int __xmlInitializeDict(void);
-
-/*
- * internal thread safe random function
- */
-int __xmlRandom(void);
-
-XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg);
-int xmlInputReadCallbackNop(void *context, char *buffer, int len);
-
-#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
-#  define LIBXML_STATIC
-#endif
 #endif /* ! __XML_LIBXML_H__ */
index fc7790c..27ad84d 100644 (file)
--- a/libxml.m4
+++ b/libxml.m4
-# Configure paths for LIBXML2
-# Simon Josefsson 2020-02-12
-# Fix autoconf 2.70+ warnings
-# Mike Hommey 2004-06-19
-# use CPPFLAGS instead of CFLAGS
-# Toshio Kuratomi 2001-04-21
-# Adapted from:
-# Configure paths for GLIB
-# Owen Taylor     97-11-3
-
 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
 dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
 dnl
-AC_DEFUN([AM_PATH_XML2],[ 
-AC_ARG_WITH(xml-prefix,
-            [  --with-xml-prefix=PFX   Prefix where libxml is installed (optional)],
-            xml_config_prefix="$withval", xml_config_prefix="")
-AC_ARG_WITH(xml-exec-prefix,
-            [  --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
-            xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
-AC_ARG_ENABLE(xmltest,
-              [  --disable-xmltest       Do not try to compile and run a test LIBXML program],,
-              enable_xmltest=yes)
-
-  if test x$xml_config_exec_prefix != x ; then
-     xml_config_args="$xml_config_args"
-     if test x${XML2_CONFIG+set} != xset ; then
-        XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
-     fi
-  fi
-  if test x$xml_config_prefix != x ; then
-     xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
-     if test x${XML2_CONFIG+set} != xset ; then
-        XML2_CONFIG=$xml_config_prefix/bin/xml2-config
-     fi
-  fi
-
-  AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
-  min_xml_version=ifelse([$1], ,2.0.0,[$1])
-  AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
-  no_xml=""
-  if test "$XML2_CONFIG" = "no" ; then
-    no_xml=yes
-  else
-    XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
-    XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
-    xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-    xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
-    if test "x$enable_xmltest" = "xyes" ; then
-      ac_save_CPPFLAGS="$CPPFLAGS"
-      ac_save_LIBS="$LIBS"
-      CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
-      LIBS="$XML_LIBS $LIBS"
-dnl
-dnl Now check if the installed libxml is sufficiently new.
-dnl (Also sanity checks the results of xml2-config to some extent)
-dnl
-      rm -f conf.xmltest
-      AC_RUN_IFELSE(
-            [AC_LANG_SOURCE([[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <libxml/xmlversion.h>
-
-int 
-main()
-{
-  int xml_major_version, xml_minor_version, xml_micro_version;
-  int major, minor, micro;
-  char *tmp_version;
-
-  system("touch conf.xmltest");
-
-  /* Capture xml2-config output via autoconf/configure variables */
-  /* HP/UX 9 (%@#!) writes to sscanf strings */
-  tmp_version = (char *)strdup("$min_xml_version");
-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
-     printf("%s, bad version string from xml2-config\n", "$min_xml_version");
-     exit(1);
-   }
-   free(tmp_version);
-
-   /* Capture the version information from the header files */
-   tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
-   if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
-     printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
-     exit(1);
-   }
-   free(tmp_version);
-
- /* Compare xml2-config output to the libxml headers */
-  if ((xml_major_version != $xml_config_major_version) ||
-      (xml_minor_version != $xml_config_minor_version) ||
-      (xml_micro_version != $xml_config_micro_version))
-    {
-      printf("*** libxml header files (version %d.%d.%d) do not match\n",
-         xml_major_version, xml_minor_version, xml_micro_version);
-      printf("*** xml2-config (version %d.%d.%d)\n",
-         $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
-      return 1;
-    } 
-/* Compare the headers to the library to make sure we match */
-  /* Less than ideal -- doesn't provide us with return value feedback, 
-   * only exits if there's a serious mismatch between header and library.
-   */
-    LIBXML_TEST_VERSION;
-
-    /* Test that the library is greater than our minimum version */
-    if ((xml_major_version > major) ||
-        ((xml_major_version == major) && (xml_minor_version > minor)) ||
-        ((xml_major_version == major) && (xml_minor_version == minor) &&
-        (xml_micro_version >= micro)))
-      {
-        return 0;
-       }
-     else
-      {
-        printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
-               xml_major_version, xml_minor_version, xml_micro_version);
-        printf("*** You need a version of libxml newer than %d.%d.%d.\n",
-           major, minor, micro);
-        printf("***\n");
-        printf("*** If you have already installed a sufficiently new version, this error\n");
-        printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
-        printf("*** being found. The easiest way to fix this is to remove the old version\n");
-        printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
-        printf("*** correct copy of xml2-config. (In this case, you will have to\n");
-        printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
-        printf("*** so that the correct libraries are found at run-time))\n");
-    }
-  return 1;
-}
-]])],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
-       CPPFLAGS="$ac_save_CPPFLAGS"
-       LIBS="$ac_save_LIBS"
-     fi
-  fi
+AC_DEFUN([AM_PATH_XML2],[
+  m4_warn([obsolete], [AM_PATH_XML2 is deprecated, use PKG_CHECK_MODULES instead])
+  AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 
-  if test "x$no_xml" = x ; then
-     AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
-     ifelse([$2], , :, [$2])     
-  else
-     AC_MSG_RESULT(no)
-     if test "$XML2_CONFIG" = "no" ; then
-       echo "*** The xml2-config script installed by LIBXML could not be found"
-       echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
-       echo "*** your path, or set the XML2_CONFIG environment variable to the"
-       echo "*** full path to xml2-config."
-     else
-       if test -f conf.xmltest ; then
-        :
-       else
-          echo "*** Could not run libxml test program, checking why..."
-          CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
-          LIBS="$LIBS $XML_LIBS"
-         AC_LINK_IFELSE(
-            [AC_LANG_PROGRAM([[
-#include <libxml/xmlversion.h>
-#include <stdio.h>
-]],    [[ LIBXML_TEST_VERSION; return 0;]])],
-        [ echo "*** The test program compiled, but did not run. This usually means"
-          echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
-          echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
-          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
-          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
-          echo "*** is required on your system"
-          echo "***"
-          echo "*** If you have an old version installed, it is best to remove it, although"
-          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
-        [ echo "*** The test program failed to compile or link. See the file config.log for the"
-          echo "*** exact error that occurred. This usually means LIBXML was incorrectly installed"
-          echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
-          echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
-          CPPFLAGS="$ac_save_CPPFLAGS"
-          LIBS="$ac_save_LIBS"
-       fi
-     fi
+  verdep=ifelse([$1], [], [], [">= $1"])
+  PKG_CHECK_MODULES(XML, [libxml-2.0 $verdep], [$2], [$3])
 
-     XML_CPPFLAGS=""
-     XML_LIBS=""
-     ifelse([$3], , :, [$3])
-  fi
+  XML_CPPFLAGS=$XML_CFLAGS
   AC_SUBST(XML_CPPFLAGS)
   AC_SUBST(XML_LIBS)
-  rm -f conf.xmltest
 ])
diff --git a/libxml.spec.in b/libxml.spec.in
deleted file mode 100644 (file)
index 45083de..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-%global with_python3 1
-
-Summary: Library providing XML and HTML support
-Name: libxml2
-Version: @VERSION@
-Release: 1%{?dist}%{?extra_release}
-License: MIT
-Group: Development/Libraries
-Source: https://download.gnome.org/sources/libxml2/@LIBXML_MAJOR_VERSION@.@LIBXML_MINOR_VERSION@/libxml2-%{version}.tar.xz
-BuildRoot: %{_tmppath}/%{name}-%{version}-root
-BuildRequires: python-devel
-%if 0%{?with_python3}
-BuildRequires: python3-devel
-%endif # with_python3
-BuildRequires: zlib-devel
-BuildRequires: pkgconfig
-BuildRequires: xz-devel
-URL: https://gitlab.gnome.org/GNOME/libxml2
-
-%description
-This library allows to manipulate XML files. It includes support
-to read, modify and write XML and HTML files. There is DTDs support
-this includes parsing and validation even with complex DtDs, either
-at parse time or later once the document has been modified. The output
-can be a simple SAX stream or and in-memory DOM like representations.
-In this case one can use the built-in XPath and XPointer implementation
-to select sub nodes or ranges. A flexible Input/Output mechanism is
-available, with existing HTTP and FTP modules and combined to an
-URI library.
-
-%package devel
-Summary: Libraries, includes, etc. to develop XML and HTML applications
-Group: Development/Libraries
-Requires: libxml2 = %{version}-%{release}
-Requires: zlib-devel
-Requires: xz-devel
-Requires: pkgconfig
-
-%description devel
-Libraries, include files, etc you can use to develop XML applications.
-This library allows to manipulate XML files. It includes support
-to read, modify and write XML and HTML files. There is DTDs support
-this includes parsing and validation even with complex DtDs, either
-at parse time or later once the document has been modified. The output
-can be a simple SAX stream or and in-memory DOM like representations.
-In this case one can use the built-in XPath and XPointer implementation
-to select sub nodes or ranges. A flexible Input/Output mechanism is
-available, with existing HTTP and FTP modules and combined to an
-URI library.
-
-%package static
-Summary: Static library for libxml2
-Group: Development/Libraries
-Requires: libxml2 = %{version}-%{release}
-
-%description static
-Static library for libxml2 provided for specific uses or shaving a few
-microseconds when parsing, do not link to them for generic purpose packages.
-
-%package -n python-%{name}
-%{?python_provide:%python_provide python-%{name}}
-Summary: Python bindings for the libxml2 library
-Group: Development/Libraries
-Requires: libxml2 = %{version}-%{release}
-Obsoletes: %{name}-python < %{version}-%{release}
-Provides: %{name}-python = %{version}-%{release}
-
-%description -n python-%{name}
-The libxml2-python package contains a Python 2 module that permits applications
-written in the Python programming language, version 2, to use the interface
-supplied by the libxml2 library to manipulate XML files.
-
-This library allows to manipulate XML files. It includes support
-to read, modify and write XML and HTML files. There is DTDs support
-this includes parsing and validation even with complex DTDs, either
-at parse time or later once the document has been modified.
-
-%if 0%{?with_python3}
-%package -n python3-%{name}
-Summary: Python 3 bindings for the libxml2 library
-Group: Development/Libraries
-Requires: libxml2 = %{version}-%{release}
-Obsoletes: %{name}-python3 < %{version}-%{release}
-Provides: %{name}-python3 = %{version}-%{release}
-
-%description -n python3-%{name}
-The libxml2-python3 package contains a Python 3 module that permits
-applications written in the Python programming language, version 3, to use the
-interface supplied by the libxml2 library to manipulate XML files.
-
-This library allows to manipulate XML files. It includes support
-to read, modify and write XML and HTML files. There is DTDs support
-this includes parsing and validation even with complex DTDs, either
-at parse time or later once the document has been modified.
-%endif # with_python3
-
-%prep
-%setup -q
-
-mkdir py3doc
-cp doc/*.py py3doc
-sed -i 's|#!/usr/bin/env python|#!/usr/bin/env %{__python3}|' py3doc/*.py
-
-%build
-%configure
-make %{_smp_mflags}
-
-find doc -type f -exec chmod 0644 \{\} \;
-
-%install
-rm -fr %{buildroot}
-
-make install DESTDIR=%{buildroot}
-
-%if 0%{?with_python3}
-make clean
-%configure --with-python=%{__python3}
-make install DESTDIR=%{buildroot}
-%endif # with_python3
-
-
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
-rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
-rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-%{version}/*
-rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-python-%{version}/*
-(cd doc/examples ; make clean ; rm -rf .deps Makefile)
-gzip -9 -c doc/libxml2-api.xml > doc/libxml2-api.xml.gz
-
-%check
-#disabling python tests from rpm build as broken in Fedora 30
-make PYTHON_SUBDIR="" runtests
-
-%clean
-rm -fr %{buildroot}
-
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-, root, root)
-
-%doc NEWS README.md Copyright TODO
-%doc %{_mandir}/man1/xmllint.1*
-%doc %{_mandir}/man1/xmlcatalog.1*
-
-%{_libdir}/lib*.so.*
-%{_bindir}/xmllint
-%{_bindir}/xmlcatalog
-
-%files devel
-%defattr(-, root, root)
-
-%doc %{_mandir}/man1/xml2-config.1*
-%doc NEWS README.md Copyright
-%doc doc/*.html doc/html doc/*.gif doc/*.png
-%doc doc/tutorial doc/libxml2-api.xml.gz
-%doc doc/examples
-%doc %dir %{_datadir}/gtk-doc/html/libxml2
-%doc %{_datadir}/gtk-doc/html/libxml2/*.devhelp
-%doc %{_datadir}/gtk-doc/html/libxml2/*.html
-%doc %{_datadir}/gtk-doc/html/libxml2/*.png
-%doc %{_datadir}/gtk-doc/html/libxml2/*.css
-
-%{_libdir}/lib*.so
-%{_libdir}/*.sh
-%{_includedir}/*
-%{_bindir}/xml2-config
-%{_datadir}/aclocal/libxml.m4
-%{_libdir}/pkgconfig/libxml-2.0.pc
-%{_libdir}/cmake/libxml2/libxml2-config.cmake
-
-%files static
-%defattr(-, root, root)
-
-%{_libdir}/*a
-
-%files -n python-%{name}
-%defattr(-, root, root)
-
-%{_libdir}/python2*/site-packages/libxml2.py*
-%{_libdir}/python2*/site-packages/drv_libxml2.py*
-%{_libdir}/python2*/site-packages/libxml2mod*
-%doc python/TODO
-%doc python/libxml2class.txt
-%doc python/tests/*.py
-%doc doc/*.py
-%doc doc/python.html
-
-%if 0%{?with_python3}
-%files -n python3-%{name}
-%defattr(-, root, root)
-
-%{_libdir}/python3*/site-packages/libxml2.py*
-%{_libdir}/python3*/site-packages/drv_libxml2.py*
-%{_libdir}/python3*/site-packages/__pycache__/*py*
-%{_libdir}/python3*/site-packages/libxml2mod*
-%doc python/TODO
-%doc python/libxml2class.txt
-%doc py3doc/*.py
-%doc doc/python.html
-%endif # with_python3
-
-%changelog
-* @RELDATE@ Daniel Veillard <veillard@redhat.com>
-- upstream release @VERSION@
-
index 27586aa..aead949 100644 (file)
@@ -35,6 +35,7 @@ macro(select_library_location target basename)
     foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
       get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
       get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
+      get_target_property(${basename}_${property}_NOCONFIG ${target} ${property}_NOCONFIG)
       get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE)
       get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO)
 
@@ -52,6 +53,8 @@ macro(select_library_location target basename)
         set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL})
       elseif(${basename}_${property}_DEBUG)
         set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
+      elseif(${basename}_${property}_NOCONFIG)
+        set(${basename}_LIBRARY ${${basename}_${property}_NOCONFIG})
       endif()
     endforeach()
   endif()
@@ -61,6 +64,7 @@ macro(select_executable_location target basename)
   if(TARGET ${target})
     get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG)
     get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL)
+    get_target_property(${basename}_IMPORTED_LOCATION_NOCONFIG ${target} IMPORTED_LOCATION_NOCONFIG)
     get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE)
     get_target_property(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO ${target} IMPORTED_LOCATION_RELWITHDEBINFO)
 
@@ -72,6 +76,8 @@ macro(select_executable_location target basename)
       set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_MINSIZEREL})
     elseif(${basename}_IMPORTED_LOCATION_DEBUG)
       set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG})
+    elseif(${basename}_IMPORTED_LOCATION_NOCONFIG)
+      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_NOCONFIG})
     endif()
   endif()
 endmacro()
@@ -96,6 +102,11 @@ if(LIBXML2_WITH_ICONV)
   find_dependency(Iconv)
   list(APPEND LIBXML2_LIBRARIES    ${Iconv_LIBRARIES})
   list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
+  if(NOT Iconv_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found")
+    return()
+  endif()
 endif()
 
 if(NOT LIBXML2_SHARED)
@@ -104,21 +115,41 @@ if(NOT LIBXML2_SHARED)
   if(LIBXML2_WITH_THREADS)
     find_dependency(Threads)
     list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+    if(NOT Threads_FOUND)
+      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found")
+      return()
+    endif()
   endif()
 
   if(LIBXML2_WITH_ICU)
     find_dependency(ICU COMPONENTS data i18n uc)
     list(APPEND LIBXML2_LIBRARIES    ${ICU_LIBRARIES})
+    if(NOT ICU_FOUND)
+      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found")
+      return()
+    endif()
   endif()
 
   if(LIBXML2_WITH_LZMA)
     find_dependency(LibLZMA)
     list(APPEND LIBXML2_LIBRARIES    ${LIBLZMA_LIBRARIES})
+    if(NOT LibLZMA_FOUND)
+      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found")
+      return()
+    endif()
   endif()
 
   if(LIBXML2_WITH_ZLIB)
     find_dependency(ZLIB)
     list(APPEND LIBXML2_LIBRARIES    ${ZLIB_LIBRARIES})
+    if(NOT ZLIB_FOUND)
+      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found")
+      return()
+    endif()
   endif()
 
   if(UNIX)
index 4989690..0447936 100644 (file)
@@ -55,30 +55,55 @@ if(LIBXML2_WITH_ICONV)
   list(APPEND LIBXML2_LIBRARIES    ${Iconv_LIBRARIES})
   list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
   list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "Iconv::Iconv")
+  if(NOT Iconv_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found")
+    return()
+  endif()
 endif()
 
 if(LIBXML2_WITH_THREADS)
   find_dependency(Threads)
   list(APPEND LIBXML2_LIBRARIES    ${CMAKE_THREAD_LIBS_INIT})
   list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:Threads::Threads>")
+  if(NOT Threads_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found")
+    return()
+  endif()
 endif()
 
 if(LIBXML2_WITH_ICU)
   find_dependency(ICU COMPONENTS data i18n uc)
   list(APPEND LIBXML2_LIBRARIES    ${ICU_LIBRARIES})
   list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ICU::data>;\$<LINK_ONLY:ICU::i18n>;\$<LINK_ONLY:ICU::uc>")
+  if(NOT ICU_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found")
+    return()
+  endif()
 endif()
 
 if(LIBXML2_WITH_LZMA)
   find_dependency(LibLZMA)
   list(APPEND LIBXML2_LIBRARIES    ${LIBLZMA_LIBRARIES})
   list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:LibLZMA::LibLZMA>")
+  if(NOT LibLZMA_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found")
+    return()
+  endif()
 endif()
 
 if(LIBXML2_WITH_ZLIB)
   find_dependency(ZLIB)
   list(APPEND LIBXML2_LIBRARIES    ${ZLIB_LIBRARIES})
   list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ZLIB::ZLIB>")
+  if(NOT ZLIB_FOUND)
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found")
+    return()
+  endif()
 endif()
 
 if(UNIX)
index f692a1c..24b8f9f 100644 (file)
@@ -1,15 +1,5 @@
 #
-# Officially exported symbols, for which header
-# file definitions are installed in /usr/include/libxml2
-#
-# Automatically generated from symbols.xml and syms.xsl
-#
-# Versions here are *fixed* to match the libxml2 version
-# at which the symbol was introduced. This ensures that
-# a new client app requiring symbol foo() can't accidentally
-# run with old libxml2.so not providing foo() - the global
-# soname version info can't enforce this since we never
-# change the soname
+# Retained for backward compatibility. Don't add new symbols.
 #
 
 LIBXML2_2.4.30 {
diff --git a/list.c b/list.c
index 12a7c00..4927a26 100644 (file)
--- a/list.c
+++ b/list.c
@@ -21,8 +21,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <libxml/xmlmemory.h>
+#include <libxml/xmlerror.h>
 #include <libxml/list.h>
-#include <libxml/globals.h>
 
 /*
  * Type definition are kept internal
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
new file mode 100644 (file)
index 0000000..dd6d8b6
--- /dev/null
@@ -0,0 +1,50 @@
+# ===========================================================================
+#      https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+#   FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+#   added in between.
+#
+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+#   CFLAGS) is used.  FLAGS-VARIABLE is not changed if it already contains
+#   FLAG.  If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+#   FLAG.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+  AS_CASE([" AS_VAR_GET(FLAGS) "],
+    [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+    [
+     AS_VAR_APPEND(FLAGS,[" $1"])
+     AC_RUN_LOG([: FLAGS="$FLAGS"])
+    ])
+  ],
+  [
+  AS_VAR_SET(FLAGS,[$1])
+  AC_RUN_LOG([: FLAGS="$FLAGS"])
+  ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/m4/ax_append_link_flags.m4 b/m4/ax_append_link_flags.m4
new file mode 100644 (file)
index 0000000..99b9fa5
--- /dev/null
@@ -0,0 +1,44 @@
+# ===========================================================================
+#   https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   For every FLAG1, FLAG2 it is checked whether the linker works with the
+#   flag.  If it does, the flag is added FLAGS-VARIABLE
+#
+#   If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
+#   used. During the check the flag is always added to the linker's flags.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+#   NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
+#   Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
+#
+# LICENSE
+#
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 7
+
+AC_DEFUN([AX_APPEND_LINK_FLAGS],
+[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+for flag in $1; do
+  AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
+done
+])dnl AX_APPEND_LINK_FLAGS
diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4
new file mode 100644 (file)
index 0000000..03a30ce
--- /dev/null
@@ -0,0 +1,53 @@
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the linker or gives an error.
+#   (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AC_DEFUN([AX_CHECK_LINK_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS $4 $1"
+  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  LDFLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_LINK_FLAGS
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
new file mode 100644 (file)
index 0000000..17c3eab
--- /dev/null
@@ -0,0 +1,37 @@
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+#   AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+#   been defined and thus are available for use.  This avoids random issues
+#   where a macro isn't expanded.  Instead the configure script emits a
+#   non-fatal:
+#
+#     ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+#   It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+#   Here's an example:
+#
+#     AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 2
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+  m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
index 6de7d30..8fbe7aa 100644 (file)
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -23,6 +23,8 @@
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/xmlerror.h>
 #include <libxml/uri.h>
 #include <libxml/nanoftp.h>
-#include <libxml/globals.h>
-
-/* #define DEBUG_FTP 1  */
-#ifdef STANDALONE
-#ifndef DEBUG_FTP
-#define DEBUG_FTP 1
-#endif
-#endif
 
+#include "private/error.h"
+#include "private/io.h"
 
 #if defined(_WIN32)
 #include <wsockcompat.h>
  * A couple portability macros
  */
 #ifndef _WINSOCKAPI_
-#if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
-#endif
-
-#ifdef __BEOS__
-#ifndef PF_INET
-#define PF_INET AF_INET
-#endif
-#endif
-
-#ifdef _AIX
-#ifdef HAVE_BROKEN_SS_FAMILY
-#define ss_family __ss_family
-#endif
-#endif
 
 #ifndef XML_SOCKLEN_T
 #define XML_SOCKLEN_T unsigned int
 #endif
 
+#define GETHOSTBYNAME_ARG_CAST (char *)
+#define SEND_ARG2_CAST (char *)
+
 #define FTP_COMMAND_OK         200
 #define FTP_SYNTAX_ERROR       500
 #define FTP_GET_PASSWD         331
@@ -417,14 +399,6 @@ xmlNanoFTPScanProxy(const char *URL) {
     }
     proxyPort = 0;
 
-#ifdef DEBUG_FTP
-    if (URL == NULL)
-       xmlGenericError(xmlGenericErrorContext,
-               "Removing FTP proxy info\n");
-    else
-       xmlGenericError(xmlGenericErrorContext,
-               "Using FTP proxy %s\n", URL);
-#endif
     if (URL == NULL) return;
 
     uri = xmlParseURIRaw(URL, 1);
@@ -557,28 +531,13 @@ xmlNanoFTPGetMore(void *ctx) {
     if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
 
     if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) {
-#ifdef DEBUG_FTP
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoFTPGetMore : controlBufIndex = %d\n",
-               ctxt->controlBufIndex);
-#endif
        return(-1);
     }
 
     if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) {
-#ifdef DEBUG_FTP
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoFTPGetMore : controlBufUsed = %d\n",
-               ctxt->controlBufUsed);
-#endif
        return(-1);
     }
     if (ctxt->controlBufIndex > ctxt->controlBufUsed) {
-#ifdef DEBUG_FTP
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n",
-              ctxt->controlBufIndex, ctxt->controlBufUsed);
-#endif
        return(-1);
     }
 
@@ -593,10 +552,6 @@ xmlNanoFTPGetMore(void *ctx) {
     }
     size = FTP_BUF_SIZE - ctxt->controlBufUsed;
     if (size == 0) {
-#ifdef DEBUG_FTP
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed);
-#endif
        return(0);
     }
 
@@ -610,11 +565,6 @@ xmlNanoFTPGetMore(void *ctx) {
         ctxt->controlFd = INVALID_SOCKET;
         return(-1);
     }
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext,
-           "xmlNanoFTPGetMore : read %d [%d - %d]\n", len,
-          ctxt->controlBufUsed, ctxt->controlBufUsed + len);
-#endif
     ctxt->controlBufUsed += len;
     ctxt->controlBuf[ctxt->controlBufUsed] = 0;
 
@@ -652,10 +602,6 @@ get_more:
     ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
     end = &ctxt->controlBuf[ctxt->controlBufUsed];
 
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext,
-           "\n<<<\n%s\n--\n", ptr);
-#endif
     while (ptr < end) {
         cur = xmlNanoFTPParseResponse(ptr, end - ptr);
        if (cur > 0) {
@@ -682,14 +628,7 @@ get_more:
 
     if (res < 0) goto get_more;
     ctxt->controlBufIndex = ptr - ctxt->controlBuf;
-#ifdef DEBUG_FTP
-    ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
-    xmlGenericError(xmlGenericErrorContext, "\n---\n%s\n--\n", ptr);
-#endif
 
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "Got %d\n", res);
-#endif
     return(res / 100);
 }
 
@@ -758,9 +697,6 @@ xmlNanoFTPSendUser(void *ctx) {
        snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user);
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -786,9 +722,6 @@ xmlNanoFTPSendPasswd(void *ctx) {
        snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -817,9 +750,6 @@ xmlNanoFTPQuit(void *ctx) {
 
     snprintf(buf, sizeof(buf), "QUIT\r\n");
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1013,9 +943,6 @@ xmlNanoFTPConnect(void *ctx) {
            snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser);
             buf[sizeof(buf) - 1] = 0;
             len = strlen(buf);
-#ifdef DEBUG_FTP
-           xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
            res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
            if (res < 0) {
                __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1036,9 +963,6 @@ xmlNanoFTPConnect(void *ctx) {
                        snprintf(buf, sizeof(buf), "PASS anonymous@\r\n");
                     buf[sizeof(buf) - 1] = 0;
                     len = strlen(buf);
-#ifdef DEBUG_FTP
-                   xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
                    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                    if (res < 0) {
                        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1077,9 +1001,6 @@ xmlNanoFTPConnect(void *ctx) {
                snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname);
                 buf[sizeof(buf) - 1] = 0;
                 len = strlen(buf);
-#ifdef DEBUG_FTP
-               xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
                res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1109,9 +1030,6 @@ xmlNanoFTPConnect(void *ctx) {
                                   ctxt->user, ctxt->hostname);
                 buf[sizeof(buf) - 1] = 0;
                 len = strlen(buf);
-#ifdef DEBUG_FTP
-               xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
                res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1131,9 +1049,6 @@ xmlNanoFTPConnect(void *ctx) {
                    snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
                 buf[sizeof(buf) - 1] = 0;
                 len = strlen(buf);
-#ifdef DEBUG_FTP
-               xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
                res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1282,9 +1197,6 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
     snprintf(buf, sizeof(buf), "CWD %s\r\n", directory);
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1333,9 +1245,6 @@ xmlNanoFTPDele(void *ctx, const char *file) {
     snprintf(buf, sizeof(buf), "DELE %s\r\n", file);
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1405,9 +1314,6 @@ xmlNanoFTPGetConnection(void *ctx) {
 #endif
            snprintf (buf, sizeof(buf), "PASV\r\n");
         len = strlen (buf);
-#ifdef DEBUG_FTP
-       xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
        res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
        if (res < 0) {
            __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1505,9 +1411,6 @@ xmlNanoFTPGetConnection(void *ctx) {
 
         buf[sizeof(buf) - 1] = 0;
         len = strlen(buf);
-#ifdef DEBUG_FTP
-       xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
 
        res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
        if (res < 0) {
@@ -1552,17 +1455,10 @@ xmlNanoFTPCloseConnection(void *ctx) {
     FD_SET(ctxt->controlFd, &efd);
     res = select(ctxt->controlFd + 1, &rfd, NULL, &efd, &tv);
     if (res < 0) {
-#ifdef DEBUG_FTP
-       perror("select");
-#endif
        closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
        return(-1);
     }
     if (res == 0) {
-#ifdef DEBUG_FTP
-       xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoFTPCloseConnection: timeout\n");
-#endif
        closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
     } else {
        res = xmlNanoFTPGetResponse(ctxt);
@@ -1743,9 +1639,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
     }
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1767,9 +1660,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
        FD_SET(ctxt->dataFd, &efd);
        res = select(ctxt->dataFd + 1, &rfd, NULL, &efd, &tv);
        if (res < 0) {
-#ifdef DEBUG_FTP
-           perror("select");
-#endif
            closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
            return(-1);
        }
@@ -1794,9 +1684,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
            ctxt->dataFd = INVALID_SOCKET;
            return(-1);
        }
-#ifdef DEBUG_FTP
-        write(1, &buf[indx], len);
-#endif
        indx += len;
        buf[indx] = 0;
        base = 0;
@@ -1838,9 +1725,6 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
 
     snprintf(buf, sizeof(buf), "TYPE I\r\n");
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1858,9 +1742,6 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
        snprintf(buf, sizeof(buf), "RETR %s\r\n", filename);
     buf[sizeof(buf) - 1] = 0;
     len = strlen(buf);
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "%s", buf);
-#endif
     res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
@@ -1912,9 +1793,6 @@ xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
        FD_SET(ctxt->dataFd, &rfd);
        res = select(ctxt->dataFd + 1, &rfd, NULL, NULL, &tv);
        if (res < 0) {
-#ifdef DEBUG_FTP
-           perror("select");
-#endif
            closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
            return(-1);
        }
@@ -1971,9 +1849,6 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) {
            __xmlIOErr(XML_FROM_FTP, 0, "recv failed");
        xmlNanoFTPCloseConnection(ctxt);
     }
-#ifdef DEBUG_FTP
-    xmlGenericError(xmlGenericErrorContext, "Recvd %d bytes\n", len);
-#endif
     return(len);
 }
 
@@ -2092,7 +1967,6 @@ int main(int argc, char **argv) {
 
     }
     xmlNanoFTPClose(ctxt);
-    xmlMemoryDump();
     exit(0);
 }
 #endif /* STANDALONE */
index 2eafd3f..0d7af48 100644 (file)
 
 #ifdef LIBXML_HTTP_ENABLED
 #include <string.h>
+#include <ctype.h>
 #include <stdlib.h>
 #include <errno.h>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
-#ifdef HAVE_RESOLV_H
-#ifdef HAVE_ARPA_NAMESER_H
-#include <arpa/nameser.h>
-#endif
-#include <resolv.h>
-#endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 #include <wsockcompat.h>
 #endif
 
-#include <libxml/globals.h>
 #include <libxml/xmlerror.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h> /* for xmlStr(n)casecmp() */
 #include <libxml/nanohttp.h>
-#include <libxml/globals.h>
 #include <libxml/uri.h>
 
+#include "private/error.h"
+#include "private/io.h"
+
 /**
  * A couple portability macros
  */
 #ifndef _WINSOCKAPI_
-#if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
-#endif
 #define SOCKET int
 #define INVALID_SOCKET (-1)
 #endif
 
-#ifdef __BEOS__
-#ifndef PF_INET
-#define PF_INET AF_INET
-#endif
-#endif
-
 #ifndef XML_SOCKLEN_T
 #define XML_SOCKLEN_T unsigned int
 #endif
 
+#define GETHOSTBYNAME_ARG_CAST (char *)
+#define SEND_ARG2_CAST (char *)
+
 #ifdef STANDALONE
-#define DEBUG_HTTP
 #define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n)
 #define xmlStrcasecmpi(a, b) strcasecmp((char *)a, (char *)b)
 #endif
@@ -188,20 +177,6 @@ static int socket_errno(void) {
 #endif
 }
 
-#ifdef SUPPORT_IP6
-static
-int have_ipv6(void) {
-    SOCKET s;
-
-    s = socket (AF_INET6, SOCK_STREAM, 0);
-    if (s != INVALID_SOCKET) {
-       close (s);
-       return (1);
-    }
-    return (0);
-}
-#endif
-
 /**
  * xmlNanoHTTPInit:
  *
@@ -350,14 +325,6 @@ xmlNanoHTTPScanProxy(const char *URL) {
     }
     proxyPort = 0;
 
-#ifdef DEBUG_HTTP
-    if (URL == NULL)
-       xmlGenericError(xmlGenericErrorContext,
-               "Removing HTTP proxy info\n");
-    else
-       xmlGenericError(xmlGenericErrorContext,
-               "Using HTTP proxy %s\n", URL);
-#endif
     if (URL == NULL) return;
 
     uri = xmlParseURIRaw(URL, 1);
@@ -535,7 +502,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt)
 
     while (ctxt->state & XML_NANO_HTTP_READ) {
         if (ctxt->in == NULL) {
-            ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char));
+            ctxt->in = (char *) xmlMallocAtomic(65000);
             if (ctxt->in == NULL) {
                 xmlHTTPErrMemory("allocating input");
                 ctxt->last = -1;
@@ -876,9 +843,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
         addrlen = sizeof(struct sockaddr_in);
     }
     if (s == INVALID_SOCKET) {
-#ifdef DEBUG_HTTP
-        perror("socket");
-#endif
         __xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n");
         return INVALID_SOCKET;
     }
@@ -896,15 +860,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
         status = ioctl(s, FIONBIO, &enable);
     }
 #else /* VMS */
-#if defined(__BEOS__) && !defined(__HAIKU__)
-    {
-        bool noblock = true;
-
-        status =
-            setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock,
-                       sizeof(noblock));
-    }
-#else /* __BEOS__ */
     if ((status = fcntl(s, F_GETFL, 0)) != -1) {
 #ifdef O_NONBLOCK
         status |= O_NONBLOCK;
@@ -916,14 +871,10 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
         status = fcntl(s, F_SETFL, status);
     }
     if (status < 0) {
-#ifdef DEBUG_HTTP
-        perror("nonblocking");
-#endif
         __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n");
         closesocket(s);
         return INVALID_SOCKET;
     }
-#endif /* !__BEOS__ */
 #endif /* !VMS */
 #endif /* !_WINSOCKAPI_ */
 
@@ -1042,33 +993,19 @@ xmlNanoHTTPConnectHost(const char *host, int port)
     struct sockaddr_in sockin;
 
 #ifdef SUPPORT_IP6
-    struct in6_addr ia6;
     struct sockaddr_in6 sockin6;
 #endif
     SOCKET s;
 
     memset (&sockin, 0, sizeof(sockin));
-#ifdef SUPPORT_IP6
-    memset (&sockin6, 0, sizeof(sockin6));
-#endif
-
-#if !defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && defined(RES_USE_INET6)
-    if (have_ipv6 ())
-    {
-       if (!(_res.options & RES_INIT))
-           res_init();
-       _res.options |= RES_USE_INET6;
-    }
-#endif
 
-#if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32)
-    if (have_ipv6 ())
-#endif
-#if defined(HAVE_GETADDRINFO) && (defined(SUPPORT_IP6) || defined(_WIN32))
+#if defined(SUPPORT_IP6)
     {
        int status;
        struct addrinfo hints, *res, *result;
 
+        memset (&sockin6, 0, sizeof(sockin6));
+
        result = NULL;
        memset (&hints, 0,sizeof(hints));
        hints.ai_socktype = SOCK_STREAM;
@@ -1089,8 +1026,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
                memcpy (&sockin, res->ai_addr, res->ai_addrlen);
                sockin.sin_port = htons (port);
                addr = (struct sockaddr *)&sockin;
-#ifdef SUPPORT_IP6
-           } else if (have_ipv6 () && (res->ai_family == AF_INET6)) {
+           } else if (res->ai_family == AF_INET6) {
                if ((size_t)res->ai_addrlen > sizeof(sockin6)) {
                    __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
                    freeaddrinfo (result);
@@ -1099,7 +1035,6 @@ xmlNanoHTTPConnectHost(const char *host, int port)
                memcpy (&sockin6, res->ai_addr, res->ai_addrlen);
                sockin6.sin6_port = htons (port);
                addr = (struct sockaddr *)&sockin6;
-#endif
            } else
                continue;              /* for */
 
@@ -1113,11 +1048,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
        if (result)
            freeaddrinfo (result);
     }
-#endif
-#if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32)
-    else
-#endif
-#if !defined(HAVE_GETADDRINFO) || !defined(_WIN32)
+#else
     {
         struct hostent *h;
         struct in_addr ia;
@@ -1179,19 +1110,6 @@ xmlNanoHTTPConnectHost(const char *host, int port)
                sockin.sin_addr = ia;
                sockin.sin_port = (unsigned short)htons ((unsigned short)port);
                addr = (struct sockaddr *) &sockin;
-#ifdef SUPPORT_IP6
-           } else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) {
-               /* AAAA records (IPv6) */
-               if ((unsigned int) h->h_length > sizeof(ia6)) {
-                   __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
-                   return INVALID_SOCKET;
-               }
-               memcpy (&ia6, h->h_addr_list[i], h->h_length);
-               sockin6.sin6_family = h->h_addrtype;
-               sockin6.sin6_addr = ia6;
-               sockin6.sin6_port = htons (port);
-               addr = (struct sockaddr *) &sockin6;
-#endif
            } else
                break;              /* for */
 
@@ -1202,11 +1120,6 @@ xmlNanoHTTPConnectHost(const char *host, int port)
     }
 #endif
 
-#ifdef DEBUG_HTTP
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlNanoHTTPConnectHost:  unable to connect to '%s'.\n",
-                    host);
-#endif
     return INVALID_SOCKET;
 }
 
@@ -1327,6 +1240,107 @@ xmlNanoHTTPClose(void *ctx) {
     xmlNanoHTTPFreeCtxt(ctxt);
 }
 
+
+/**
+ * xmlNanoHTTPHostnameMatch:
+ * @pattern: The pattern as it appears in no_proxy environment variable
+ * @hostname: The hostname to test as it appears in the URL
+ *
+ * This function tests whether a given hostname matches a pattern. The pattern
+ * usually is a token from the no_proxy environment variable. Wildcards in the
+ * pattern are not supported.
+ *
+ * Returns true, iff hostname matches the pattern.
+ */
+
+static int 
+xmlNanoHTTPHostnameMatch(const char *pattern, const char *hostname) {
+    int idx_pattern, idx_hostname;
+    const char * pattern_start;
+
+    if (!pattern || *pattern == '\0' || !hostname)
+       return 0;
+
+    /* Ignore trailing '.' */
+    if (*pattern == '.') {
+        idx_pattern = strlen(pattern) -1;
+        pattern_start = pattern + 1;
+    }
+    else {
+        idx_pattern = strlen(pattern);
+        pattern_start = pattern;
+    }
+    idx_hostname = strlen(hostname);
+
+    for (; idx_pattern >= 0 && idx_hostname >= 0; 
+           --idx_pattern, --idx_hostname) {
+       if (tolower(pattern_start[idx_pattern]) != tolower(hostname[idx_hostname]))
+           break;
+    }
+
+    return idx_pattern == -1 && (idx_hostname == -1|| hostname[idx_hostname] == '.');
+}
+
+
+/**
+ * xmlNanoHTTPBypassProxy:
+ * @hostname: The hostname as it appears in the URL
+ *
+ * This function evaluates the no_proxy environment variable and returns
+ * whether the proxy server should be bypassed for a given host.
+ *
+ * Returns true, iff a proxy server should be bypassed for the given hostname.
+ */
+
+static int
+xmlNanoHTTPBypassProxy(const char *hostname) {
+    size_t envlen;
+    char *env = getenv("no_proxy"), *cpy=NULL, *p=NULL;
+    if (!env)
+       return 0;
+
+    /* (Avoid strdup because it's not portable.) */
+    envlen = strlen(env) + 1;
+    cpy = xmlMalloc(envlen);
+    memcpy(cpy, env, envlen);
+    env = cpy;
+
+    /* The remainder of the function is basically a tokenizing: */
+    while (isspace(*env))
+       ++env;
+    if (*env == '\0') {
+       xmlFree(cpy);
+       return 0;
+    }
+
+    p = env;
+    while (*env) {
+
+       if (*env != ',') {
+           ++env;
+           continue;
+       }
+
+       *(env++) = '\0';
+       if (xmlNanoHTTPHostnameMatch(p, hostname)) {
+           xmlFree(cpy);
+           return 1;
+       }
+
+       while (isspace(*env))
+           ++env;
+       p = env;
+    }
+    if (xmlNanoHTTPHostnameMatch(p, hostname)) {
+       xmlFree(cpy);
+       return 1;
+    }
+
+    xmlFree(cpy);
+    return 0;
+}
+
+
 /**
  * xmlNanoHTTPMethodRedir:
  * @URL:  The URL to load
@@ -1354,10 +1368,8 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
     int blen;
     SOCKET ret;
     int nbRedirects = 0;
+    int use_proxy;
     char *redirURL = NULL;
-#ifdef DEBUG_HTTP
-    int xmt_bytes;
-#endif
 
     if (URL == NULL) return(NULL);
     if (method == NULL) method = "GET";
@@ -1388,7 +1400,8 @@ retry:
        if (redirURL != NULL) xmlFree(redirURL);
         return(NULL);
     }
-    if (proxy) {
+    use_proxy = proxy && !xmlNanoHTTPBypassProxy(ctxt->hostname);
+    if (use_proxy) {
        blen = strlen(ctxt->hostname) * 2 + 16;
        ret = xmlNanoHTTPConnectHost(proxy, proxyPort);
     }
@@ -1423,7 +1436,7 @@ retry:
 #endif
     if (ctxt->port != 80) {
        /* reserve space for ':xxxxx', incl. potential proxy */
-       if (proxy)
+       if (use_proxy)
            blen += 17;
        else
            blen += 11;
@@ -1437,7 +1450,7 @@ retry:
 
     p = bp;
 
-    if (proxy) {
+    if (use_proxy) {
        if (ctxt->port != 80) {
            p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s",
                        method, ctxt->hostname,
@@ -1476,41 +1489,13 @@ retry:
     else
        snprintf(p, blen - (p - bp), "\r\n");
 
-#ifdef DEBUG_HTTP
-    xmlGenericError(xmlGenericErrorContext,
-           "-> %s%s", proxy? "(Proxy) " : "", bp);
-    if ((blen -= strlen(bp)+1) < 0)
-       xmlGenericError(xmlGenericErrorContext,
-               "ERROR: overflowed buffer by %d bytes\n", -blen);
-#endif
     ctxt->outptr = ctxt->out = bp;
     ctxt->state = XML_NANO_HTTP_WRITE;
     blen = strlen( ctxt->out );
-#ifdef DEBUG_HTTP
-    xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen );
-    if ( xmt_bytes != blen )
-        xmlGenericError( xmlGenericErrorContext,
-                       "xmlNanoHTTPMethodRedir:  Only %d of %d %s %s\n",
-                       xmt_bytes, blen,
-                       "bytes of HTTP headers sent to host",
-                       ctxt->hostname );
-#else
     xmlNanoHTTPSend(ctxt, ctxt->out, blen );
-#endif
 
     if ( input != NULL ) {
-#ifdef DEBUG_HTTP
-        xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen );
-
-       if ( xmt_bytes != ilen )
-           xmlGenericError( xmlGenericErrorContext,
-                       "xmlNanoHTTPMethodRedir:  Only %d of %d %s %s\n",
-                       xmt_bytes, ilen,
-                       "bytes of HTTP content sent to host",
-                       ctxt->hostname );
-#else
        xmlNanoHTTPSend( ctxt, input, ilen );
-#endif
     }
 
     ctxt->state = XML_NANO_HTTP_READ;
@@ -1523,18 +1508,11 @@ retry:
        }
        xmlNanoHTTPScanAnswer(ctxt, p);
 
-#ifdef DEBUG_HTTP
-       xmlGenericError(xmlGenericErrorContext, "<- %s\n", p);
-#endif
         xmlFree(p);
     }
 
     if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) &&
         (ctxt->returnValue < 400)) {
-#ifdef DEBUG_HTTP
-       xmlGenericError(xmlGenericErrorContext,
-               "\nRedirect to: %s\n", ctxt->location);
-#endif
        while ( xmlNanoHTTPRecv(ctxt) > 0 )
             ;
         if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
@@ -1547,10 +1525,6 @@ retry:
        }
        xmlNanoHTTPFreeCtxt(ctxt);
        if (redirURL != NULL) xmlFree(redirURL);
-#ifdef DEBUG_HTTP
-       xmlGenericError(xmlGenericErrorContext,
-               "xmlNanoHTTPMethodRedir: Too many redirects, aborting ...\n");
-#endif
        return(NULL);
     }
 
@@ -1570,17 +1544,6 @@ retry:
            *redir = NULL;
     }
 
-#ifdef DEBUG_HTTP
-    if (ctxt->contentType != NULL)
-       xmlGenericError(xmlGenericErrorContext,
-               "\nCode %d, content-type '%s'\n\n",
-              ctxt->returnValue, ctxt->contentType);
-    else
-       xmlGenericError(xmlGenericErrorContext,
-               "\nCode %d, no content-type\n\n",
-              ctxt->returnValue);
-#endif
-
     return((void *) ctxt);
 }
 
@@ -1874,7 +1837,6 @@ int main(int argc, char **argv) {
                "\tusage %s [ URL [ filename ] ]\n", argv[0]);
     }
     xmlNanoHTTPCleanup();
-    xmlMemoryDump();
     return(0);
 }
 #endif /* STANDALONE */
diff --git a/optim/TOTRY b/optim/TOTRY
deleted file mode 100644 (file)
index 5b37b0b..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-XML:
-====
-  - I/O avoid copies when parsing mmap'ed files, need to use
-    unmutable buffers except for the last 4K to make it 0 terminated
-    (or get rid of 0 termination check in the whole parser, hard !)
-  - recheck > 4Gb instances for parsing, and RNG validation.
-    
-
-XSLT:
-=====
-  - global variable access
-     for each expr in stylesheet : allocate index
-     for each transformation context
-       create an index table
-         cache values in the transformation
-          - context evaluation
-            - cache
-            - constants at the XPAth level
-          - provide more info on compiled expressions
-            - dependances w.r.t. variables (which ones)
-            - dependency on the current node
-            - dependency on the current document
-  - do not use _private but other fields in the node structures.
diff --git a/optim/hash_dict.patch b/optim/hash_dict.patch
deleted file mode 100644 (file)
index 6c50abc..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-Index: hash.c
-===================================================================
-RCS file: /cvs/gnome/gnome-xml/hash.c,v
-retrieving revision 1.30
-diff -u -r1.30 hash.c
---- hash.c     29 Oct 2003 11:18:37 -0000      1.30
-+++ hash.c     24 Feb 2004 17:18:42 -0000
-@@ -26,6 +26,7 @@
- #include <libxml/xmlmemory.h>
- #include <libxml/xmlerror.h>
- #include <libxml/globals.h>
-+#include <libxml/dict.h>
- #define MAX_HASH_LEN 8
-@@ -38,9 +39,9 @@
- typedef xmlHashEntry *xmlHashEntryPtr;
- struct _xmlHashEntry {
-     struct _xmlHashEntry *next;
--    xmlChar *name;
--    xmlChar *name2;
--    xmlChar *name3;
-+    const xmlChar *name;
-+    const xmlChar *name2;
-+    const xmlChar *name3;
-     void *payload;
-     int valid;
- };
-@@ -52,6 +53,7 @@
-     struct _xmlHashEntry *table;
-     int size;
-     int nbElems;
-+    xmlDictPtr dict;
- };
- /*
-@@ -143,12 +145,16 @@
- xmlHashTablePtr
- xmlHashCreate(int size) {
-     xmlHashTablePtr table;
-+    xmlDictPtr dict;
-   
-     if (size <= 0)
-         size = 256;
-   
-+    dict = xmlDictCreate();
-+    if (dict == NULL) return(NULL);
-     table = xmlMalloc(sizeof(xmlHashTable));
-     if (table) {
-+        table->dict = dict;
-         table->size = size;
-       table->nbElems = 0;
-         table->table = xmlMalloc(size * sizeof(xmlHashEntry));
-@@ -158,6 +164,7 @@
-         }
-         xmlFree(table);
-     }
-+    xmlDictFree(dict);
-     return(NULL);
- }
-@@ -282,12 +289,6 @@
-               next = iter->next;
-               if ((f != NULL) && (iter->payload != NULL))
-                   f(iter->payload, iter->name);
--              if (iter->name)
--                  xmlFree(iter->name);
--              if (iter->name2)
--                  xmlFree(iter->name2);
--              if (iter->name3)
--                  xmlFree(iter->name3);
-               iter->payload = NULL;
-               if (!inside_table)
-                   xmlFree(iter);
-@@ -299,6 +300,7 @@
-       }
-       xmlFree(table->table);
-     }
-+    xmlDictFree(table->dict);
-     xmlFree(table);
- }
-@@ -465,6 +467,9 @@
-     if ((table == NULL) || name == NULL)
-       return(-1);
-+    if (name) name = xmlDictLookup(table->dict, name, -1);
-+    if (name2) name2 = xmlDictLookup(table->dict, name2, -1);
-+    if (name3) name3 = xmlDictLookup(table->dict, name3, -1);
-     /*
-      * Check for duplicate and insertion location.
-@@ -475,15 +480,15 @@
-     } else {
-       for (insert = &(table->table[key]); insert->next != NULL;
-            insert = insert->next) {
--          if ((xmlStrEqual(insert->name, name)) &&
--              (xmlStrEqual(insert->name2, name2)) &&
--              (xmlStrEqual(insert->name3, name3)))
-+          if ((insert->name == name) &&
-+              (insert->name2 == name2) &&
-+              (insert->name3 == name3))
-               return(-1);
-           len++;
-       }
--      if ((xmlStrEqual(insert->name, name)) &&
--          (xmlStrEqual(insert->name2, name2)) &&
--          (xmlStrEqual(insert->name3, name3)))
-+      if ((insert->name == name) &&
-+          (insert->name2 == name2) &&
-+          (insert->name3 == name3))
-           return(-1);
-     }
-@@ -495,9 +500,9 @@
-            return(-1);
-     }
--    entry->name = xmlStrdup(name);
--    entry->name2 = xmlStrdup(name2);
--    entry->name3 = xmlStrdup(name3);
-+    entry->name = name;
-+    entry->name2 = name2;
-+    entry->name3 = name3;
-     entry->payload = userdata;
-     entry->next = NULL;
-     entry->valid = 1;
-@@ -539,6 +544,9 @@
-     if ((table == NULL) || name == NULL)
-       return(-1);
-+    if (name) name = xmlDictLookup(table->dict, name, -1);
-+    if (name2) name2 = xmlDictLookup(table->dict, name2, -1);
-+    if (name3) name3 = xmlDictLookup(table->dict, name3, -1);
-     /*
-      * Check for duplicate and insertion location.
-@@ -549,18 +557,18 @@
-     } else {
-       for (insert = &(table->table[key]); insert->next != NULL;
-            insert = insert->next) {
--          if ((xmlStrEqual(insert->name, name)) &&
--              (xmlStrEqual(insert->name2, name2)) &&
--              (xmlStrEqual(insert->name3, name3))) {
-+          if ((insert->name == name) &&
-+              (insert->name2 == name2) &&
-+              (insert->name3 == name3)) {
-               if (f)
-                   f(insert->payload, insert->name);
-               insert->payload = userdata;
-               return(0);
-           }
-       }
--      if ((xmlStrEqual(insert->name, name)) &&
--          (xmlStrEqual(insert->name2, name2)) &&
--          (xmlStrEqual(insert->name3, name3))) {
-+      if ((insert->name == name) &&
-+          (insert->name2 == name2) &&
-+          (insert->name3 == name3)) {
-           if (f)
-               f(insert->payload, insert->name);
-           insert->payload = userdata;
-@@ -576,9 +584,9 @@
-            return(-1);
-     }
--    entry->name = xmlStrdup(name);
--    entry->name2 = xmlStrdup(name2);
--    entry->name3 = xmlStrdup(name3);
-+    entry->name = name;
-+    entry->name2 = name2;
-+    entry->name3 = name3;
-     entry->payload = userdata;
-     entry->next = NULL;
-     entry->valid = 1;
-@@ -615,10 +623,13 @@
-     key = xmlHashComputeKey(table, name, name2, name3);
-     if (table->table[key].valid == 0)
-       return(NULL);
-+    if (name) name = xmlDictLookup(table->dict, name, -1);
-+    if (name2) name2 = xmlDictLookup(table->dict, name2, -1);
-+    if (name3) name3 = xmlDictLookup(table->dict, name3, -1);
-     for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
--      if ((xmlStrEqual(entry->name, name)) &&
--          (xmlStrEqual(entry->name2, name2)) &&
--          (xmlStrEqual(entry->name3, name3)))
-+      if ((entry->name == name) &&
-+          (entry->name2 == name2) &&
-+          (entry->name3 == name3))
-           return(entry->payload);
-     }
-     return(NULL);
-@@ -774,6 +785,9 @@
-     if (f == NULL)
-       return;
-+    if (name) name = xmlDictLookup(table->dict, name, -1);
-+    if (name2) name2 = xmlDictLookup(table->dict, name2, -1);
-+    if (name3) name3 = xmlDictLookup(table->dict, name3, -1);
-     if (table->table) {
-       for(i = 0; i < table->size; i++) {
-           if (table->table[i].valid == 0)
-@@ -781,9 +795,9 @@
-           iter = &(table->table[i]);
-           while (iter) {
-               next = iter->next;
--              if (((name == NULL) || (xmlStrEqual(name, iter->name))) &&
--                  ((name2 == NULL) || (xmlStrEqual(name2, iter->name2))) &&
--                  ((name3 == NULL) || (xmlStrEqual(name3, iter->name3))) &&
-+              if (((name == NULL) || (name == iter->name)) &&
-+                  ((name2 == NULL) || (name2 == iter->name2)) &&
-+                  ((name3 == NULL) || (name3 == iter->name3)) &&
-                   (iter->payload != NULL)) {
-                   f(iter->payload, data, iter->name,
-                     iter->name2, iter->name3);
-@@ -913,19 +927,16 @@
-     if (table->table[key].valid == 0) {
-         return(-1);
-     } else {
-+      if (name) name = xmlDictLookup(table->dict, name, -1);
-+      if (name2) name2 = xmlDictLookup(table->dict, name2, -1);
-+      if (name3) name3 = xmlDictLookup(table->dict, name3, -1);
-         for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
--            if (xmlStrEqual(entry->name, name) &&
--                    xmlStrEqual(entry->name2, name2) &&
--                    xmlStrEqual(entry->name3, name3)) {
-+            if ((entry->name == name) &&
-+              (entry->name2 == name2) &&
-+              (entry->name3 == name3)) {
-                 if ((f != NULL) && (entry->payload != NULL))
-                     f(entry->payload, entry->name);
-                 entry->payload = NULL;
--                if(entry->name)
--                    xmlFree(entry->name);
--                if(entry->name2)
--                    xmlFree(entry->name2);
--                if(entry->name3)
--                    xmlFree(entry->name3);
-                 if(prev) {
-                     prev->next = entry->next;
-                   xmlFree(entry);
-Index: include/libxml/hash.h
-===================================================================
-RCS file: /cvs/gnome/gnome-xml/include/libxml/hash.h,v
-retrieving revision 1.15
-diff -u -r1.15 hash.h
---- include/libxml/hash.h      20 Nov 2003 11:59:07 -0000      1.15
-+++ include/libxml/hash.h      24 Feb 2004 17:18:42 -0000
-@@ -42,7 +42,7 @@
-  *
-  * Callback to free data from a hash.
-  */
--typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
-+typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
- /**
-  * xmlHashCopier:
-  * @payload:  the data in the hash
diff --git a/optim/hash_dict.txt b/optim/hash_dict.txt
deleted file mode 100644 (file)
index a447b7e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Reuses a dictionary for the hash table to reduce the string compare
-costs. Not worth it unless validating big DTDs
-
-               without         with
-db10000  tree  175/79          179/81
-db100000 stream        1222            1217
-dba100000stream        593             601
-REC validation 1986            2098
-Docbook valid  10808           10649
-
-Tue Feb 24 19:09:49 CET 2004
index 93f031b..b7534ae 100644 (file)
--- a/parser.c
+++ b/parser.c
 #include <stddef.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <libxml/parser.h>
 #include <libxml/xmlmemory.h>
-#include <libxml/threads.h>
-#include <libxml/globals.h>
 #include <libxml/tree.h>
-#include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/valid.h>
 #include <libxml/entities.h>
 #include <libxml/encoding.h>
 #include <libxml/xmlIO.h>
 #include <libxml/uri.h>
+#include <libxml/SAX2.h>
 #ifdef LIBXML_CATALOG_ENABLED
 #include <libxml/catalog.h>
 #endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-#include <libxml/xmlschemastypes.h>
-#include <libxml/relaxng.h>
-#endif
 
-#include "buf.h"
-#include "enc.h"
+#include "private/buf.h"
+#include "private/dict.h"
+#include "private/entities.h"
+#include "private/error.h"
+#include "private/html.h"
+#include "private/io.h"
+#include "private/parser.h"
+
+#define NS_INDEX_EMPTY  INT_MAX
+#define NS_INDEX_XML    (INT_MAX - 1)
+#define URI_HASH_EMPTY  0xD943A04E
+#define URI_HASH_XML    0xF0451F02
 
 struct _xmlStartTag {
     const xmlChar *prefix;
@@ -81,14 +86,38 @@ struct _xmlStartTag {
     int nsNr;
 };
 
-static void
-xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
+typedef struct {
+    void *saxData;
+    unsigned prefixHashValue;
+    unsigned uriHashValue;
+    unsigned elementId;
+    int oldIndex;
+} xmlParserNsExtra;
 
-static xmlParserCtxtPtr
-xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
-                         const xmlChar *base, xmlParserCtxtPtr pctx);
+typedef struct {
+    unsigned hashValue;
+    int index;
+} xmlParserNsBucket;
+
+struct _xmlParserNsData {
+    xmlParserNsExtra *extra;
 
-static void xmlHaltParser(xmlParserCtxtPtr ctxt);
+    unsigned hashSize;
+    unsigned hashElems;
+    xmlParserNsBucket *hash;
+
+    unsigned elementId;
+    int defaultNsIndex;
+};
+
+struct _xmlAttrHashBucket {
+    int index;
+};
+
+static xmlParserCtxtPtr
+xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
+        const xmlChar *URL, const xmlChar *ID, const xmlChar *base,
+        xmlParserCtxtPtr pctx);
 
 static int
 xmlParseElementStart(xmlParserCtxtPtr ctxt);
@@ -106,156 +135,21 @@ xmlParseElementEnd(xmlParserCtxtPtr ctxt);
 #define XML_PARSER_LOT_ENTITY 5000
 
 /*
- * XML_PARSER_NON_LINEAR is the threshold where the ratio of parsed entity
- *    replacement over the size in byte of the input indicates that you have
- *    and exponential behaviour. A value of 10 correspond to at least 3 entity
- *    replacement per byte of input.
+ * Constants for protection against abusive entity expansion
+ * ("billion laughs").
  */
-#define XML_PARSER_NON_LINEAR 10
 
 /*
- * xmlParserEntityCheck
- *
- * Function to check non-linear entity expansion behaviour
- * This is here to detect and stop exponential linear entity expansion
- * This is not a limitation of the parser but a safety
- * boundary feature. It can be disabled with the XML_PARSE_HUGE
- * parser option.
+ * A certain amount of entity expansion which is always allowed.
  */
-static int
-xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
-                     xmlEntityPtr ent, size_t replacement)
-{
-    size_t consumed = 0;
-    int i;
-
-    if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE))
-        return (0);
-    if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
-        return (1);
-
-    /*
-     * This may look absurd but is needed to detect
-     * entities problems
-     */
-    if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
-       (ent->content != NULL) && (ent->checked == 0) &&
-       (ctxt->errNo != XML_ERR_ENTITY_LOOP)) {
-       unsigned long oldnbent = ctxt->nbentities, diff;
-       xmlChar *rep;
-
-       ent->checked = 1;
-
-        ++ctxt->depth;
-       rep = xmlStringDecodeEntities(ctxt, ent->content,
-                                 XML_SUBSTITUTE_REF, 0, 0, 0);
-        --ctxt->depth;
-       if ((rep == NULL) || (ctxt->errNo == XML_ERR_ENTITY_LOOP)) {
-           ent->content[0] = 0;
-       }
-
-        diff = ctxt->nbentities - oldnbent + 1;
-        if (diff > INT_MAX / 2)
-            diff = INT_MAX / 2;
-       ent->checked = diff * 2;
-       if (rep != NULL) {
-           if (xmlStrchr(rep, '<'))
-               ent->checked |= 1;
-           xmlFree(rep);
-           rep = NULL;
-       }
-    }
-
-    /*
-     * Prevent entity exponential check, not just replacement while
-     * parsing the DTD
-     * The check is potentially costly so do that only once in a thousand
-     */
-    if ((ctxt->instate == XML_PARSER_DTD) && (ctxt->nbentities > 10000) &&
-        (ctxt->nbentities % 1024 == 0)) {
-       for (i = 0;i < ctxt->inputNr;i++) {
-           consumed += ctxt->inputTab[i]->consumed +
-                      (ctxt->inputTab[i]->cur - ctxt->inputTab[i]->base);
-       }
-       if (ctxt->nbentities > consumed * XML_PARSER_NON_LINEAR) {
-           xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
-           ctxt->instate = XML_PARSER_EOF;
-           return (1);
-       }
-       consumed = 0;
-    }
-
-
-
-    if (replacement != 0) {
-       if (replacement < XML_MAX_TEXT_LENGTH)
-           return(0);
-
-        /*
-        * If the volume of entity copy reaches 10 times the
-        * amount of parsed data and over the large text threshold
-        * then that's very likely to be an abuse.
-        */
-        if (ctxt->input != NULL) {
-           consumed = ctxt->input->consumed +
-                      (ctxt->input->cur - ctxt->input->base);
-       }
-        consumed += ctxt->sizeentities;
-
-        if (replacement < XML_PARSER_NON_LINEAR * consumed)
-           return(0);
-    } else if (size != 0) {
-        /*
-         * Do the check based on the replacement size of the entity
-         */
-        if (size < XML_PARSER_BIG_ENTITY)
-           return(0);
-
-        /*
-         * A limit on the amount of text data reasonably used
-         */
-        if (ctxt->input != NULL) {
-            consumed = ctxt->input->consumed +
-                (ctxt->input->cur - ctxt->input->base);
-        }
-        consumed += ctxt->sizeentities;
-
-        if ((size < XML_PARSER_NON_LINEAR * consumed) &&
-           (ctxt->nbentities * 3 < XML_PARSER_NON_LINEAR * consumed))
-            return (0);
-    } else if (ent != NULL) {
-        /*
-         * use the number of parsed entities in the replacement
-         */
-        size = ent->checked / 2;
-
-        /*
-         * The amount of data parsed counting entities size only once
-         */
-        if (ctxt->input != NULL) {
-            consumed = ctxt->input->consumed +
-                (ctxt->input->cur - ctxt->input->base);
-        }
-        consumed += ctxt->sizeentities;
+#define XML_PARSER_ALLOWED_EXPANSION 1000000
 
-        /*
-         * Check the density of entities for the amount of data
-        * knowing an entity reference will take at least 3 bytes
-         */
-        if (size * 3 < consumed * XML_PARSER_NON_LINEAR)
-            return (0);
-    } else {
-        /*
-         * strange we got no data for checking
-         */
-       if (((ctxt->lastError.code != XML_ERR_UNDECLARED_ENTITY) &&
-            (ctxt->lastError.code != XML_WAR_UNDECLARED_ENTITY)) ||
-           (ctxt->nbentities <= 10000))
-           return (0);
-    }
-    xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
-    return (1);
-}
+/*
+ * Fixed cost for each entity reference. This crudely models processing time
+ * as well to protect, for example, against exponential expansion of empty
+ * or very short entities.
+ */
+#define XML_ENT_FIXED_COST 20
 
 /**
  * xmlParserMaxDepth:
@@ -269,7 +163,6 @@ unsigned int xmlParserMaxDepth = 256;
 
 
 
-#define SAX2 1
 #define XML_PARSER_BIG_BUFFER_SIZE 300
 #define XML_PARSER_BUFFER_SIZE 100
 #define SAX_COMPAT_MODE BAD_CAST "SAX compatibility mode document"
@@ -285,6 +178,14 @@ unsigned int xmlParserMaxDepth = 256;
  */
 #define XML_PARSER_CHUNK_SIZE 100
 
+/**
+ * xmlParserVersion:
+ *
+ * Constant string describing the internal version of the library
+ */
+const char *const
+xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
+
 /*
  * List of XML prefixed PI allowed by W3C specs
  */
@@ -307,8 +208,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
                      const xmlChar *ID, xmlNodePtr *list);
 
 static int
-xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options,
-                          const char *encoding);
+xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options);
 #ifdef LIBXML_LEGACY_ENABLED
 static void
 xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,
@@ -365,222 +265,6 @@ xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix,
 }
 
 /**
- * xmlFatalErr:
- * @ctxt:  an XML parser context
- * @error:  the error number
- * @extra:  extra information string
- *
- * Handle a fatal parser error, i.e. violating Well-Formedness constraints
- */
-static void
-xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
-{
-    const char *errmsg;
-
-    if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
-        (ctxt->instate == XML_PARSER_EOF))
-       return;
-    switch (error) {
-        case XML_ERR_INVALID_HEX_CHARREF:
-            errmsg = "CharRef: invalid hexadecimal value";
-            break;
-        case XML_ERR_INVALID_DEC_CHARREF:
-            errmsg = "CharRef: invalid decimal value";
-            break;
-        case XML_ERR_INVALID_CHARREF:
-            errmsg = "CharRef: invalid value";
-            break;
-        case XML_ERR_INTERNAL_ERROR:
-            errmsg = "internal error";
-            break;
-        case XML_ERR_PEREF_AT_EOF:
-            errmsg = "PEReference at end of document";
-            break;
-        case XML_ERR_PEREF_IN_PROLOG:
-            errmsg = "PEReference in prolog";
-            break;
-        case XML_ERR_PEREF_IN_EPILOG:
-            errmsg = "PEReference in epilog";
-            break;
-        case XML_ERR_PEREF_NO_NAME:
-            errmsg = "PEReference: no name";
-            break;
-        case XML_ERR_PEREF_SEMICOL_MISSING:
-            errmsg = "PEReference: expecting ';'";
-            break;
-        case XML_ERR_ENTITY_LOOP:
-            errmsg = "Detected an entity reference loop";
-            break;
-        case XML_ERR_ENTITY_NOT_STARTED:
-            errmsg = "EntityValue: \" or ' expected";
-            break;
-        case XML_ERR_ENTITY_PE_INTERNAL:
-            errmsg = "PEReferences forbidden in internal subset";
-            break;
-        case XML_ERR_ENTITY_NOT_FINISHED:
-            errmsg = "EntityValue: \" or ' expected";
-            break;
-        case XML_ERR_ATTRIBUTE_NOT_STARTED:
-            errmsg = "AttValue: \" or ' expected";
-            break;
-        case XML_ERR_LT_IN_ATTRIBUTE:
-            errmsg = "Unescaped '<' not allowed in attributes values";
-            break;
-        case XML_ERR_LITERAL_NOT_STARTED:
-            errmsg = "SystemLiteral \" or ' expected";
-            break;
-        case XML_ERR_LITERAL_NOT_FINISHED:
-            errmsg = "Unfinished System or Public ID \" or ' expected";
-            break;
-        case XML_ERR_MISPLACED_CDATA_END:
-            errmsg = "Sequence ']]>' not allowed in content";
-            break;
-        case XML_ERR_URI_REQUIRED:
-            errmsg = "SYSTEM or PUBLIC, the URI is missing";
-            break;
-        case XML_ERR_PUBID_REQUIRED:
-            errmsg = "PUBLIC, the Public Identifier is missing";
-            break;
-        case XML_ERR_HYPHEN_IN_COMMENT:
-            errmsg = "Comment must not contain '--' (double-hyphen)";
-            break;
-        case XML_ERR_PI_NOT_STARTED:
-            errmsg = "xmlParsePI : no target name";
-            break;
-        case XML_ERR_RESERVED_XML_NAME:
-            errmsg = "Invalid PI name";
-            break;
-        case XML_ERR_NOTATION_NOT_STARTED:
-            errmsg = "NOTATION: Name expected here";
-            break;
-        case XML_ERR_NOTATION_NOT_FINISHED:
-            errmsg = "'>' required to close NOTATION declaration";
-            break;
-        case XML_ERR_VALUE_REQUIRED:
-            errmsg = "Entity value required";
-            break;
-        case XML_ERR_URI_FRAGMENT:
-            errmsg = "Fragment not allowed";
-            break;
-        case XML_ERR_ATTLIST_NOT_STARTED:
-            errmsg = "'(' required to start ATTLIST enumeration";
-            break;
-        case XML_ERR_NMTOKEN_REQUIRED:
-            errmsg = "NmToken expected in ATTLIST enumeration";
-            break;
-        case XML_ERR_ATTLIST_NOT_FINISHED:
-            errmsg = "')' required to finish ATTLIST enumeration";
-            break;
-        case XML_ERR_MIXED_NOT_STARTED:
-            errmsg = "MixedContentDecl : '|' or ')*' expected";
-            break;
-        case XML_ERR_PCDATA_REQUIRED:
-            errmsg = "MixedContentDecl : '#PCDATA' expected";
-            break;
-        case XML_ERR_ELEMCONTENT_NOT_STARTED:
-            errmsg = "ContentDecl : Name or '(' expected";
-            break;
-        case XML_ERR_ELEMCONTENT_NOT_FINISHED:
-            errmsg = "ContentDecl : ',' '|' or ')' expected";
-            break;
-        case XML_ERR_PEREF_IN_INT_SUBSET:
-            errmsg =
-                "PEReference: forbidden within markup decl in internal subset";
-            break;
-        case XML_ERR_GT_REQUIRED:
-            errmsg = "expected '>'";
-            break;
-        case XML_ERR_CONDSEC_INVALID:
-            errmsg = "XML conditional section '[' expected";
-            break;
-        case XML_ERR_EXT_SUBSET_NOT_FINISHED:
-            errmsg = "Content error in the external subset";
-            break;
-        case XML_ERR_CONDSEC_INVALID_KEYWORD:
-            errmsg =
-                "conditional section INCLUDE or IGNORE keyword expected";
-            break;
-        case XML_ERR_CONDSEC_NOT_FINISHED:
-            errmsg = "XML conditional section not closed";
-            break;
-        case XML_ERR_XMLDECL_NOT_STARTED:
-            errmsg = "Text declaration '<?xml' required";
-            break;
-        case XML_ERR_XMLDECL_NOT_FINISHED:
-            errmsg = "parsing XML declaration: '?>' expected";
-            break;
-        case XML_ERR_EXT_ENTITY_STANDALONE:
-            errmsg = "external parsed entities cannot be standalone";
-            break;
-        case XML_ERR_ENTITYREF_SEMICOL_MISSING:
-            errmsg = "EntityRef: expecting ';'";
-            break;
-        case XML_ERR_DOCTYPE_NOT_FINISHED:
-            errmsg = "DOCTYPE improperly terminated";
-            break;
-        case XML_ERR_LTSLASH_REQUIRED:
-            errmsg = "EndTag: '</' not found";
-            break;
-        case XML_ERR_EQUAL_REQUIRED:
-            errmsg = "expected '='";
-            break;
-        case XML_ERR_STRING_NOT_CLOSED:
-            errmsg = "String not closed expecting \" or '";
-            break;
-        case XML_ERR_STRING_NOT_STARTED:
-            errmsg = "String not started expecting ' or \"";
-            break;
-        case XML_ERR_ENCODING_NAME:
-            errmsg = "Invalid XML encoding name";
-            break;
-        case XML_ERR_STANDALONE_VALUE:
-            errmsg = "standalone accepts only 'yes' or 'no'";
-            break;
-        case XML_ERR_DOCUMENT_EMPTY:
-            errmsg = "Document is empty";
-            break;
-        case XML_ERR_DOCUMENT_END:
-            errmsg = "Extra content at the end of the document";
-            break;
-        case XML_ERR_NOT_WELL_BALANCED:
-            errmsg = "chunk is not well balanced";
-            break;
-        case XML_ERR_EXTRA_CONTENT:
-            errmsg = "extra content at the end of well balanced chunk";
-            break;
-        case XML_ERR_VERSION_MISSING:
-            errmsg = "Malformed declaration expecting version";
-            break;
-        case XML_ERR_NAME_TOO_LONG:
-            errmsg = "Name too long use XML_PARSE_HUGE option";
-            break;
-#if 0
-        case:
-            errmsg = "";
-            break;
-#endif
-        default:
-            errmsg = "Unregistered error message";
-    }
-    if (ctxt != NULL)
-       ctxt->errNo = error;
-    if (info == NULL) {
-        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
-                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
-                        errmsg);
-    } else {
-        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
-                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
-                        errmsg, info);
-    }
-    if (ctxt != NULL) {
-       ctxt->wellFormed = 0;
-       if (ctxt->recovery == 0)
-           ctxt->disableSAX = 1;
-    }
-}
-
-/**
  * xmlFatalErrMsg:
  * @ctxt:  an XML parser context
  * @error:  the error number
@@ -616,7 +300,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
  *
  * Handle a warning.
  */
-static void LIBXML_ATTR_FORMAT(3,0)
+void LIBXML_ATTR_FORMAT(3,0)
 xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
               const char *msg, const xmlChar *str1, const xmlChar *str2)
 {
@@ -852,6 +536,90 @@ xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
                     info1, info2, info3);
 }
 
+static void
+xmlSaturatedAdd(unsigned long *dst, unsigned long val) {
+    if (val > ULONG_MAX - *dst)
+        *dst = ULONG_MAX;
+    else
+        *dst += val;
+}
+
+static void
+xmlSaturatedAddSizeT(unsigned long *dst, unsigned long val) {
+    if (val > ULONG_MAX - *dst)
+        *dst = ULONG_MAX;
+    else
+        *dst += val;
+}
+
+/**
+ * xmlParserEntityCheck:
+ * @ctxt:  parser context
+ * @extra:  sum of unexpanded entity sizes
+ *
+ * Check for non-linear entity expansion behaviour.
+ *
+ * In some cases like xmlStringDecodeEntities, this function is called
+ * for each, possibly nested entity and its unexpanded content length.
+ *
+ * In other cases like xmlParseReference, it's only called for each
+ * top-level entity with its unexpanded content length plus the sum of
+ * the unexpanded content lengths (plus fixed cost) of all nested
+ * entities.
+ *
+ * Summing the unexpanded lengths also adds the length of the reference.
+ * This is by design. Taking the length of the entity name into account
+ * discourages attacks that try to waste CPU time with abusively long
+ * entity names. See test/recurse/lol6.xml for example. Each call also
+ * adds some fixed cost XML_ENT_FIXED_COST to discourage attacks with
+ * short entities.
+ *
+ * Returns 1 on error, 0 on success.
+ */
+static int
+xmlParserEntityCheck(xmlParserCtxtPtr ctxt, unsigned long extra)
+{
+    unsigned long consumed;
+    xmlParserInputPtr input = ctxt->input;
+    xmlEntityPtr entity = input->entity;
+
+    /*
+     * Compute total consumed bytes so far, including input streams of
+     * external entities.
+     */
+    consumed = input->parentConsumed;
+    if ((entity == NULL) ||
+        ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+         ((entity->flags & XML_ENT_PARSED) == 0))) {
+        xmlSaturatedAdd(&consumed, input->consumed);
+        xmlSaturatedAddSizeT(&consumed, input->cur - input->base);
+    }
+    xmlSaturatedAdd(&consumed, ctxt->sizeentities);
+
+    /*
+     * Add extra cost and some fixed cost.
+     */
+    xmlSaturatedAdd(&ctxt->sizeentcopy, extra);
+    xmlSaturatedAdd(&ctxt->sizeentcopy, XML_ENT_FIXED_COST);
+
+    /*
+     * It's important to always use saturation arithmetic when tracking
+     * entity sizes to make the size checks reliable. If "sizeentcopy"
+     * overflows, we have to abort.
+     */
+    if ((ctxt->sizeentcopy > XML_PARSER_ALLOWED_EXPANSION) &&
+        ((ctxt->sizeentcopy >= ULONG_MAX) ||
+         (ctxt->sizeentcopy / ctxt->maxAmpl > consumed))) {
+        xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_LOOP,
+                       "Maximum entity amplification factor exceeded, see "
+                       "xmlCtxtSetMaxAmplification.\n");
+        xmlHaltParser(ctxt);
+        return(1);
+    }
+
+    return(0);
+}
+
 /************************************************************************
  *                                                                     *
  *             Library wide options                                    *
@@ -1047,11 +815,7 @@ xmlHasFeature(xmlFeature feature)
             return(0);
 #endif
         case XML_WITH_DEBUG_RUN:
-#ifdef LIBXML_DEBUG_RUNTIME
-            return(1);
-#else
             return(0);
-#endif
         case XML_WITH_ZLIB:
 #ifdef LIBXML_ZLIB_ENABLED
             return(1);
@@ -1098,7 +862,11 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
     if (ctxt == NULL) return;
     sax = ctxt->sax;
 #ifdef LIBXML_SAX1_ENABLED
-    if ((sax) &&  (sax->initialized == XML_SAX2_MAGIC) &&
+    /*
+     * Only enable SAX2 if there SAX2 element handlers, except when there
+     * are no element handlers at all.
+     */
+    if ((sax) && (sax->initialized == XML_SAX2_MAGIC) &&
         ((sax->startElementNs != NULL) ||
          (sax->endElementNs != NULL) ||
          ((sax->startElement == NULL) && (sax->endElement == NULL))))
@@ -1116,6 +884,15 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
     }
 }
 
+typedef struct {
+    xmlHashedString prefix;
+    xmlHashedString name;
+    xmlHashedString value;
+    const xmlChar *valueEnd;
+    int external;
+    int expandedSize;
+} xmlDefAttr;
+
 typedef struct _xmlDefAttrs xmlDefAttrs;
 typedef xmlDefAttrs *xmlDefAttrsPtr;
 struct _xmlDefAttrs {
@@ -1123,9 +900,9 @@ struct _xmlDefAttrs {
     int maxAttrs;       /* the size of the array */
 #if __STDC_VERSION__ >= 199901L
     /* Using a C99 flexible array member avoids UBSan errors. */
-    const xmlChar *values[]; /* array of localname/prefix/values/external */
+    xmlDefAttr attrs[]; /* array of localname/prefix/values/external */
 #else
-    const xmlChar *values[5];
+    xmlDefAttr attrs[1];
 #endif
 };
 
@@ -1217,7 +994,7 @@ xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, xmlChar *src, int *len)
            return(NULL);
        }
        xmlAttrNormalizeSpace(ret, ret);
-       *len = (int) strlen((const char *)ret);
+       *len = strlen((const char *)ret);
         return(ret);
     } else if (remove_head) {
         *len -= remove_head;
@@ -1242,9 +1019,12 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
                const xmlChar *fullattr,
                const xmlChar *value) {
     xmlDefAttrsPtr defaults;
-    int len;
-    const xmlChar *name;
-    const xmlChar *prefix;
+    xmlDefAttr *attr;
+    int len, expandedSize;
+    xmlHashedString name;
+    xmlHashedString prefix;
+    xmlHashedString hvalue;
+    const xmlChar *localname;
 
     /*
      * Allows to detect attribute redefinitions
@@ -1264,41 +1044,38 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
      * split the element name into prefix:localname , the string found
      * are within the DTD and then not associated to namespace names.
      */
-    name = xmlSplitQName3(fullname, &len);
-    if (name == NULL) {
-        name = xmlDictLookup(ctxt->dict, fullname, -1);
-       prefix = NULL;
+    localname = xmlSplitQName3(fullname, &len);
+    if (localname == NULL) {
+        name = xmlDictLookupHashed(ctxt->dict, fullname, -1);
+       prefix.name = NULL;
     } else {
-        name = xmlDictLookup(ctxt->dict, name, -1);
-       prefix = xmlDictLookup(ctxt->dict, fullname, len);
+        name = xmlDictLookupHashed(ctxt->dict, localname, -1);
+       prefix = xmlDictLookupHashed(ctxt->dict, fullname, len);
+        if (prefix.name == NULL)
+            goto mem_error;
     }
+    if (name.name == NULL)
+        goto mem_error;
 
     /*
      * make sure there is some storage
      */
-    defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix);
-    if (defaults == NULL) {
-        defaults = (xmlDefAttrsPtr) xmlMalloc(sizeof(xmlDefAttrs) +
-                          (4 * 5) * sizeof(const xmlChar *));
-       if (defaults == NULL)
-           goto mem_error;
-       defaults->nbAttrs = 0;
-       defaults->maxAttrs = 4;
-       if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
-                               defaults, NULL) < 0) {
-           xmlFree(defaults);
-           goto mem_error;
-       }
-    } else if (defaults->nbAttrs >= defaults->maxAttrs) {
+    defaults = xmlHashLookup2(ctxt->attsDefault, name.name, prefix.name);
+    if ((defaults == NULL) ||
+        (defaults->nbAttrs >= defaults->maxAttrs)) {
         xmlDefAttrsPtr temp;
+        int newSize;
 
-        temp = (xmlDefAttrsPtr) xmlRealloc(defaults, sizeof(xmlDefAttrs) +
-                      (2 * defaults->maxAttrs * 5) * sizeof(const xmlChar *));
+        newSize = (defaults != NULL) ? 2 * defaults->maxAttrs : 4;
+        temp = xmlRealloc(defaults,
+                          sizeof(*defaults) + newSize * sizeof(xmlDefAttr));
        if (temp == NULL)
            goto mem_error;
-       defaults = temp;
-       defaults->maxAttrs *= 2;
-       if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
+        if (defaults == NULL)
+            temp->nbAttrs = 0;
+       temp->maxAttrs = newSize;
+        defaults = temp;
+       if (xmlHashUpdateEntry2(ctxt->attsDefault, name.name, prefix.name,
                                defaults, NULL) < 0) {
            xmlFree(defaults);
            goto mem_error;
@@ -1306,30 +1083,40 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
     }
 
     /*
-     * Split the element name into prefix:localname , the string found
+     * Split the attribute name into prefix:localname , the string found
      * are within the DTD and hen not associated to namespace names.
      */
-    name = xmlSplitQName3(fullattr, &len);
-    if (name == NULL) {
-        name = xmlDictLookup(ctxt->dict, fullattr, -1);
-       prefix = NULL;
+    localname = xmlSplitQName3(fullattr, &len);
+    if (localname == NULL) {
+        name = xmlDictLookupHashed(ctxt->dict, fullattr, -1);
+       prefix.name = NULL;
     } else {
-        name = xmlDictLookup(ctxt->dict, name, -1);
-       prefix = xmlDictLookup(ctxt->dict, fullattr, len);
+        name = xmlDictLookupHashed(ctxt->dict, localname, -1);
+       prefix = xmlDictLookupHashed(ctxt->dict, fullattr, len);
+        if (prefix.name == NULL)
+            goto mem_error;
     }
+    if (name.name == NULL)
+        goto mem_error;
 
-    defaults->values[5 * defaults->nbAttrs] = name;
-    defaults->values[5 * defaults->nbAttrs + 1] = prefix;
     /* intern the string and precompute the end */
-    len = xmlStrlen(value);
-    value = xmlDictLookup(ctxt->dict, value, len);
-    defaults->values[5 * defaults->nbAttrs + 2] = value;
-    defaults->values[5 * defaults->nbAttrs + 3] = value + len;
-    if (ctxt->external)
-        defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external";
-    else
-        defaults->values[5 * defaults->nbAttrs + 4] = NULL;
-    defaults->nbAttrs++;
+    len = strlen((const char *) value);
+    hvalue = xmlDictLookupHashed(ctxt->dict, value, len);
+    if (hvalue.name == NULL)
+        goto mem_error;
+
+    expandedSize = strlen((const char *) name.name);
+    if (prefix.name != NULL)
+        expandedSize += strlen((const char *) prefix.name);
+    expandedSize += len;
+
+    attr = &defaults->attrs[defaults->nbAttrs++];
+    attr->name = name;
+    attr->prefix = prefix;
+    attr->value = hvalue;
+    attr->valueEnd = hvalue.name + len;
+    attr->external = ctxt->external;
+    attr->expandedSize = expandedSize;
 
     return;
 
@@ -1414,6 +1201,8 @@ xmlCleanSpecialAttr(xmlParserCtxtPtr ctxt)
  * xmlCheckLanguageID:
  * @lang:  pointer to the string value
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Checks that the value conforms to the LanguageID production:
  *
  * NOTE: this is somewhat deprecated, those productions were removed from
@@ -1613,114 +1402,476 @@ region_m49:
 static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt,
                                             const xmlChar ** str);
 
-#ifdef SAX2
 /**
- * nsPush:
- * @ctxt:  an XML parser context
- * @prefix:  the namespace prefix or NULL
- * @URL:  the namespace name
+ * xmlParserNsCreate:
  *
- * Pushes a new parser namespace on top of the ns stack
+ * Create a new namespace database.
  *
- * Returns -1 in case of error, -2 if the namespace should be discarded
- *        and the index in the stack otherwise.
+ * Returns the new obejct.
  */
-static int
-nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
-{
-    if (ctxt->options & XML_PARSE_NSCLEAN) {
-        int i;
-       for (i = ctxt->nsNr - 2;i >= 0;i -= 2) {
-           if (ctxt->nsTab[i] == prefix) {
-               /* in scope */
-               if (ctxt->nsTab[i + 1] == URL)
-                   return(-2);
-               /* out of scope keep it */
-               break;
-           }
-       }
-    }
-    if ((ctxt->nsMax == 0) || (ctxt->nsTab == NULL)) {
-       ctxt->nsMax = 10;
-       ctxt->nsNr = 0;
-       ctxt->nsTab = (const xmlChar **)
-                     xmlMalloc(ctxt->nsMax * sizeof(xmlChar *));
-       if (ctxt->nsTab == NULL) {
-           xmlErrMemory(ctxt, NULL);
-           ctxt->nsMax = 0;
-            return (-1);
-       }
-    } else if (ctxt->nsNr >= ctxt->nsMax) {
-        const xmlChar ** tmp;
-        ctxt->nsMax *= 2;
-        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;
-    return (ctxt->nsNr);
+xmlParserNsData *
+xmlParserNsCreate(void) {
+    xmlParserNsData *nsdb = xmlMalloc(sizeof(*nsdb));
+
+    if (nsdb == NULL)
+        return(NULL);
+    memset(nsdb, 0, sizeof(*nsdb));
+    nsdb->defaultNsIndex = INT_MAX;
+
+    return(nsdb);
 }
+
 /**
- * nsPop:
- * @ctxt: an XML parser context
- * @nr:  the number to pop
- *
- * Pops the top @nr parser prefix/namespace from the ns stack
+ * xmlParserNsFree:
+ * @nsdb: namespace database
  *
- * Returns the number of namespaces removed
+ * Free a namespace database.
  */
-static int
-nsPop(xmlParserCtxtPtr ctxt, int nr)
-{
-    int i;
-
-    if (ctxt->nsTab == NULL) return(0);
-    if (ctxt->nsNr < nr) {
-        xmlGenericError(xmlGenericErrorContext, "Pbm popping %d NS\n", nr);
-        nr = ctxt->nsNr;
-    }
-    if (ctxt->nsNr <= 0)
-        return (0);
+void
+xmlParserNsFree(xmlParserNsData *nsdb) {
+    if (nsdb == NULL)
+        return;
 
-    for (i = 0;i < nr;i++) {
-         ctxt->nsNr--;
-        ctxt->nsTab[ctxt->nsNr] = NULL;
-    }
-    return(nr);
+    xmlFree(nsdb->extra);
+    xmlFree(nsdb->hash);
+    xmlFree(nsdb);
 }
-#endif
 
-static int
+/**
+ * xmlParserNsReset:
+ * @nsdb: namespace database
+ *
+ * Reset a namespace database.
+ */
+static void
+xmlParserNsReset(xmlParserNsData *nsdb) {
+    if (nsdb == NULL)
+        return;
+
+    nsdb->hashElems = 0;
+    nsdb->elementId = 0;
+    nsdb->defaultNsIndex = INT_MAX;
+
+    if (nsdb->hash)
+        memset(nsdb->hash, 0, nsdb->hashSize * sizeof(nsdb->hash[0]));
+}
+
+/**
+ * xmlParserStartElement:
+ * @nsdb: namespace database
+ *
+ * Signal that a new element has started.
+ *
+ * Returns 0 on success, -1 if the element counter overflowed.
+ */
+static int
+xmlParserNsStartElement(xmlParserNsData *nsdb) {
+    if (nsdb->elementId == UINT_MAX)
+        return(-1);
+    nsdb->elementId++;
+
+    return(0);
+}
+
+/**
+ * xmlParserNsLookup:
+ * @ctxt: parser context
+ * @prefix: namespace prefix
+ * @bucketPtr: optional bucket (return value)
+ *
+ * Lookup namespace with given prefix. If @bucketPtr is non-NULL, it will
+ * be set to the matching bucket, or the first empty bucket if no match
+ * was found.
+ *
+ * Returns the namespace index on success, INT_MAX if no namespace was
+ * found.
+ */
+static int
+xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
+                  xmlParserNsBucket **bucketPtr) {
+    xmlParserNsBucket *bucket;
+    unsigned index, hashValue;
+
+    if (prefix->name == NULL)
+        return(ctxt->nsdb->defaultNsIndex);
+
+    if (ctxt->nsdb->hashSize == 0)
+        return(INT_MAX);
+
+    hashValue = prefix->hashValue;
+    index = hashValue & (ctxt->nsdb->hashSize - 1);
+    bucket = &ctxt->nsdb->hash[index];
+
+    while (bucket->hashValue) {
+        if ((bucket->hashValue == hashValue) &&
+            (bucket->index != INT_MAX)) {
+            if (ctxt->nsTab[bucket->index * 2] == prefix->name) {
+                if (bucketPtr != NULL)
+                    *bucketPtr = bucket;
+                return(bucket->index);
+            }
+        }
+
+        index++;
+        bucket++;
+        if (index == ctxt->nsdb->hashSize) {
+            index = 0;
+            bucket = ctxt->nsdb->hash;
+        }
+    }
+
+    if (bucketPtr != NULL)
+        *bucketPtr = bucket;
+    return(INT_MAX);
+}
+
+/**
+ * xmlParserNsLookupUri:
+ * @ctxt: parser context
+ * @prefix: namespace prefix
+ *
+ * Lookup namespace URI with given prefix.
+ *
+ * Returns the namespace URI on success, NULL if no namespace was found.
+ */
+static const xmlChar *
+xmlParserNsLookupUri(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix) {
+    const xmlChar *ret;
+    int nsIndex;
+
+    if (prefix->name == ctxt->str_xml)
+        return(ctxt->str_xml_ns);
+
+    nsIndex = xmlParserNsLookup(ctxt, prefix, NULL);
+    if (nsIndex == INT_MAX)
+        return(NULL);
+
+    ret = ctxt->nsTab[nsIndex * 2 + 1];
+    if (ret[0] == 0)
+        ret = NULL;
+    return(ret);
+}
+
+/**
+ * xmlParserNsLookupSax:
+ * @ctxt: parser context
+ * @prefix: namespace prefix
+ *
+ * Lookup extra data for the given prefix. This returns data stored
+ * with xmlParserNsUdpateSax.
+ *
+ * Returns the data on success, NULL if no namespace was found.
+ */
+void *
+xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix) {
+    xmlHashedString hprefix;
+    int nsIndex;
+
+    if (prefix == ctxt->str_xml)
+        return(NULL);
+
+    hprefix.name = prefix;
+    if (prefix != NULL)
+        hprefix.hashValue = xmlDictComputeHash(ctxt->dict, prefix);
+    else
+        hprefix.hashValue = 0;
+    nsIndex = xmlParserNsLookup(ctxt, &hprefix, NULL);
+    if (nsIndex == INT_MAX)
+        return(NULL);
+
+    return(ctxt->nsdb->extra[nsIndex].saxData);
+}
+
+/**
+ * xmlParserNsUpdateSax:
+ * @ctxt: parser context
+ * @prefix: namespace prefix
+ * @saxData: extra data for SAX handler
+ *
+ * Sets or updates extra data for the given prefix. This value will be
+ * returned by xmlParserNsLookupSax as long as the namespace with the
+ * given prefix is in scope.
+ *
+ * Returns the data on success, NULL if no namespace was found.
+ */
+int
+xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
+                     void *saxData) {
+    xmlHashedString hprefix;
+    int nsIndex;
+
+    if (prefix == ctxt->str_xml)
+        return(-1);
+
+    hprefix.name = prefix;
+    if (prefix != NULL)
+        hprefix.hashValue = xmlDictComputeHash(ctxt->dict, prefix);
+    else
+        hprefix.hashValue = 0;
+    nsIndex = xmlParserNsLookup(ctxt, &hprefix, NULL);
+    if (nsIndex == INT_MAX)
+        return(-1);
+
+    ctxt->nsdb->extra[nsIndex].saxData = saxData;
+    return(0);
+}
+
+/**
+ * xmlParserNsGrow:
+ * @ctxt: parser context
+ *
+ * Grows the namespace tables.
+ *
+ * Returns 0 on success, -1 if a memory allocation failed.
+ */
+static int
+xmlParserNsGrow(xmlParserCtxtPtr ctxt) {
+    const xmlChar **table;
+    xmlParserNsExtra *extra;
+    int newSize;
+
+    if (ctxt->nsMax > INT_MAX / 2)
+        goto error;
+    newSize = ctxt->nsMax ? ctxt->nsMax * 2 : 16;
+
+    table = xmlRealloc(ctxt->nsTab, 2 * newSize * sizeof(table[0]));
+    if (table == NULL)
+        goto error;
+    ctxt->nsTab = table;
+
+    extra = xmlRealloc(ctxt->nsdb->extra, newSize * sizeof(extra[0]));
+    if (extra == NULL)
+        goto error;
+    ctxt->nsdb->extra = extra;
+
+    ctxt->nsMax = newSize;
+    return(0);
+
+error:
+    xmlErrMemory(ctxt, NULL);
+    return(-1);
+}
+
+/**
+ * xmlParserNsPush:
+ * @ctxt: parser context
+ * @prefix: prefix with hash value
+ * @uri: uri with hash value
+ * @saxData: extra data for SAX handler
+ * @defAttr: whether the namespace comes from a default attribute
+ *
+ * Push a new namespace on the table.
+ *
+ * Returns 1 if the namespace was pushed, 0 if the namespace was ignored,
+ * -1 if a memory allocation failed.
+ */
+static int
+xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
+                const xmlHashedString *uri, void *saxData, int defAttr) {
+    xmlParserNsBucket *bucket = NULL;
+    xmlParserNsExtra *extra;
+    const xmlChar **ns;
+    unsigned hashValue, nsIndex, oldIndex;
+
+    if ((prefix != NULL) && (prefix->name == ctxt->str_xml))
+        return(0);
+
+    if ((ctxt->nsNr >= ctxt->nsMax) && (xmlParserNsGrow(ctxt) < 0)) {
+        xmlErrMemory(ctxt, NULL);
+        return(-1);
+    }
+
+    /*
+     * Default namespace and 'xml' namespace
+     */
+    if ((prefix == NULL) || (prefix->name == NULL)) {
+        oldIndex = ctxt->nsdb->defaultNsIndex;
+
+        if (oldIndex != INT_MAX) {
+            extra = &ctxt->nsdb->extra[oldIndex];
+
+            if (extra->elementId == ctxt->nsdb->elementId) {
+                if (defAttr == 0)
+                    xmlErrAttributeDup(ctxt, NULL, BAD_CAST "xmlns");
+                return(0);
+            }
+
+            if ((ctxt->options & XML_PARSE_NSCLEAN) &&
+                (uri->name == ctxt->nsTab[oldIndex * 2 + 1]))
+                return(0);
+        }
+
+        ctxt->nsdb->defaultNsIndex = ctxt->nsNr;
+        goto populate_entry;
+    }
+
+    /*
+     * Hash table lookup
+     */
+    oldIndex = xmlParserNsLookup(ctxt, prefix, &bucket);
+    if (oldIndex != INT_MAX) {
+        extra = &ctxt->nsdb->extra[oldIndex];
+
+        /*
+         * Check for duplicate definitions on the same element.
+         */
+        if (extra->elementId == ctxt->nsdb->elementId) {
+            if (defAttr == 0)
+                xmlErrAttributeDup(ctxt, BAD_CAST "xmlns", prefix->name);
+            return(0);
+        }
+
+        if ((ctxt->options & XML_PARSE_NSCLEAN) &&
+            (uri->name == ctxt->nsTab[bucket->index * 2 + 1]))
+            return(0);
+
+        bucket->index = ctxt->nsNr;
+        goto populate_entry;
+    }
+
+    /*
+     * Insert new bucket
+     */
+
+    hashValue = prefix->hashValue;
+
+    /*
+     * Grow hash table, 50% fill factor
+     */
+    if (ctxt->nsdb->hashElems + 1 > ctxt->nsdb->hashSize / 2) {
+        xmlParserNsBucket *newHash;
+        unsigned newSize, i, index;
+
+        if (ctxt->nsdb->hashSize > UINT_MAX / 2) {
+            xmlErrMemory(ctxt, NULL);
+            return(-1);
+        }
+        newSize = ctxt->nsdb->hashSize ? ctxt->nsdb->hashSize * 2 : 16;
+        newHash = xmlMalloc(newSize * sizeof(newHash[0]));
+        if (newHash == NULL) {
+            xmlErrMemory(ctxt, NULL);
+            return(-1);
+        }
+        memset(newHash, 0, newSize * sizeof(newHash[0]));
+
+        for (i = 0; i < ctxt->nsdb->hashSize; i++) {
+            unsigned hv = ctxt->nsdb->hash[i].hashValue;
+            unsigned newIndex;
+
+            if (hv == 0)
+                continue;
+            newIndex = hv & (newSize - 1);
+
+            while (newHash[newIndex].hashValue != 0) {
+                newIndex++;
+                if (newIndex == newSize)
+                    newIndex = 0;
+            }
+
+            newHash[newIndex] = ctxt->nsdb->hash[i];
+        }
+
+        xmlFree(ctxt->nsdb->hash);
+        ctxt->nsdb->hash = newHash;
+        ctxt->nsdb->hashSize = newSize;
+
+        /*
+         * Relookup
+         */
+        index = hashValue & (newSize - 1);
+
+        while (newHash[index].hashValue != 0) {
+            index++;
+            if (index == newSize)
+                index = 0;
+        }
+
+        bucket = &newHash[index];
+    }
+
+    bucket->hashValue = hashValue;
+    bucket->index = ctxt->nsNr;
+    ctxt->nsdb->hashElems++;
+    oldIndex = INT_MAX;
+
+populate_entry:
+    nsIndex = ctxt->nsNr;
+
+    ns = &ctxt->nsTab[nsIndex * 2];
+    ns[0] = prefix ? prefix->name : NULL;
+    ns[1] = uri->name;
+
+    extra = &ctxt->nsdb->extra[nsIndex];
+    extra->saxData = saxData;
+    extra->prefixHashValue = prefix ? prefix->hashValue : 0;
+    extra->uriHashValue = uri->hashValue;
+    extra->elementId = ctxt->nsdb->elementId;
+    extra->oldIndex = oldIndex;
+
+    ctxt->nsNr++;
+
+    return(1);
+}
+
+/**
+ * xmlParserNsPop:
+ * @ctxt: an XML parser context
+ * @nr:  the number to pop
+ *
+ * Pops the top @nr namespaces and restores the hash table.
+ *
+ * Returns the number of namespaces popped.
+ */
+static int
+xmlParserNsPop(xmlParserCtxtPtr ctxt, int nr)
+{
+    int i;
+
+    /* assert(nr <= ctxt->nsNr); */
+
+    for (i = ctxt->nsNr - 1; i >= ctxt->nsNr - nr; i--) {
+        const xmlChar *prefix = ctxt->nsTab[i * 2];
+        xmlParserNsExtra *extra = &ctxt->nsdb->extra[i];
+
+        if (prefix == NULL) {
+            ctxt->nsdb->defaultNsIndex = extra->oldIndex;
+        } else {
+            xmlHashedString hprefix;
+            xmlParserNsBucket *bucket = NULL;
+
+            hprefix.name = prefix;
+            hprefix.hashValue = extra->prefixHashValue;
+            xmlParserNsLookup(ctxt, &hprefix, &bucket);
+            /* assert(bucket && bucket->hashValue); */
+            bucket->index = extra->oldIndex;
+        }
+    }
+
+    ctxt->nsNr -= nr;
+    return(nr);
+}
+
+static int
 xmlCtxtGrowAttrs(xmlParserCtxtPtr ctxt, int nr) {
     const xmlChar **atts;
-    int *attallocs;
+    unsigned *attallocs;
     int maxatts;
 
-    if (ctxt->atts == NULL) {
-       maxatts = 55; /* allow for 10 attrs by default */
-       atts = (const xmlChar **)
-              xmlMalloc(maxatts * sizeof(xmlChar *));
-       if (atts == NULL) goto mem_error;
-       ctxt->atts = atts;
-       attallocs = (int *) xmlMalloc((maxatts / 5) * sizeof(int));
-       if (attallocs == NULL) goto mem_error;
-       ctxt->attallocs = attallocs;
-       ctxt->maxatts = maxatts;
-    } else if (nr + 5 > ctxt->maxatts) {
-       maxatts = (nr + 5) * 2;
-       atts = (const xmlChar **) xmlRealloc((void *) ctxt->atts,
+    if (nr + 5 > ctxt->maxatts) {
+       maxatts = ctxt->maxatts == 0 ? 55 : (nr + 5) * 2;
+       atts = (const xmlChar **) xmlMalloc(
                                     maxatts * sizeof(const xmlChar *));
        if (atts == NULL) goto mem_error;
+       attallocs = xmlRealloc(ctxt->attallocs,
+                               (maxatts / 5) * sizeof(attallocs[0]));
+       if (attallocs == NULL) {
+            xmlFree(atts);
+            goto mem_error;
+        }
+        if (ctxt->maxatts > 0)
+            memcpy(atts, ctxt->atts, ctxt->maxatts * sizeof(const xmlChar *));
+        xmlFree(ctxt->atts);
        ctxt->atts = atts;
-       attallocs = (int *) xmlRealloc((void *) ctxt->attallocs,
-                                    (maxatts / 5) * sizeof(int));
-       if (attallocs == NULL) goto mem_error;
        ctxt->attallocs = attallocs;
        ctxt->maxatts = maxatts;
     }
@@ -1745,16 +1896,17 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
     if ((ctxt == NULL) || (value == NULL))
         return(-1);
     if (ctxt->inputNr >= ctxt->inputMax) {
-        ctxt->inputMax *= 2;
-        ctxt->inputTab =
-            (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
-                                             ctxt->inputMax *
-                                             sizeof(ctxt->inputTab[0]));
-        if (ctxt->inputTab == NULL) {
+        size_t newSize = ctxt->inputMax * 2;
+        xmlParserInputPtr *tmp;
+
+        tmp = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
+                                               newSize * sizeof(*tmp));
+        if (tmp == NULL) {
             xmlErrMemory(ctxt, NULL);
-           ctxt->inputMax /= 2;
             return (-1);
         }
+        ctxt->inputTab = tmp;
+        ctxt->inputMax = newSize;
     }
     ctxt->inputTab[ctxt->inputNr] = value;
     ctxt->input = value;
@@ -1791,6 +1943,8 @@ inputPop(xmlParserCtxtPtr ctxt)
  * @ctxt:  an XML parser context
  * @value:  the element node
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Pushes a new element node on top of the node stack
  *
  * Returns -1 in case of error, the index in the stack otherwise
@@ -1829,6 +1983,8 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
  * nodePop:
  * @ctxt: an XML parser context
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Pops the top element node from the node stack
  *
  * Returns the node just removed
@@ -1940,6 +2096,8 @@ nameNsPop(xmlParserCtxtPtr ctxt)
  * @ctxt:  an XML parser context
  * @value:  the element name
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Pushes a new element name on top of the name stack
  *
  * Returns -1 in case of error, the index in the stack otherwise
@@ -1967,10 +2125,13 @@ mem_error:
     xmlErrMemory(ctxt, NULL);
     return (-1);
 }
+
 /**
  * namePop:
  * @ctxt: an XML parser context
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Pops the top element name from the name stack
  *
  * Returns the name just removed
@@ -2086,7 +2247,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
 #define SKIP(val) do {                                                 \
     ctxt->input->cur += (val),ctxt->input->col+=(val);                 \
     if (*ctxt->input->cur == 0)                                                \
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);                  \
+        xmlParserGrow(ctxt);                                           \
   } while (0)
 
 #define SKIPL(val) do {                                                        \
@@ -2098,47 +2259,18 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
        ctxt->input->cur++;                                             \
     }                                                                  \
     if (*ctxt->input->cur == 0)                                                \
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);                  \
+        xmlParserGrow(ctxt);                                           \
   } while (0)
 
-#define SHRINK if ((ctxt->progressive == 0) &&                         \
-                  (ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
-                  (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
-       xmlSHRINK (ctxt);
-
-static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
-    xmlParserInputShrink(ctxt->input);
-    if (*ctxt->input->cur == 0)
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-}
-
-#define GROW if ((ctxt->progressive == 0) &&                           \
-                (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK))   \
-       xmlGROW (ctxt);
-
-static void xmlGROW (xmlParserCtxtPtr ctxt) {
-    ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur;
-    ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base;
+/* Don't shrink push parser buffer. */
+#define SHRINK \
+    if (((ctxt->progressive == 0) || (ctxt->inputNr > 1)) && \
+        (ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
+       (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
+       xmlParserShrink(ctxt);
 
-    if (((curEnd > XML_MAX_LOOKUP_LIMIT) ||
-         (curBase > XML_MAX_LOOKUP_LIMIT)) &&
-         ((ctxt->input->buf) &&
-          (ctxt->input->buf->readcallback != xmlInputReadCallbackNop)) &&
-        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
-        xmlHaltParser(ctxt);
-       return;
-    }
-    xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-    if ((ctxt->input->cur > ctxt->input->end) ||
-        (ctxt->input->cur < ctxt->input->base)) {
-        xmlHaltParser(ctxt);
-        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
-       return;
-    }
-    if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0))
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-}
+#define GROW if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)    \
+       xmlParserGrow(ctxt);
 
 #define SKIP_BLANKS xmlSkipBlankChars(ctxt)
 
@@ -2148,7 +2280,7 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
        ctxt->input->col++;                                             \
        ctxt->input->cur++;                                             \
        if (*ctxt->input->cur == 0)                                     \
-           xmlParserInputGrow(ctxt->input, INPUT_CHUNK);               \
+           xmlParserGrow(ctxt);                                                \
     }
 
 #define NEXTL(l) do {                                                  \
@@ -2161,17 +2293,16 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
 #define CUR_CHAR(l) xmlCurrentChar(ctxt, &l)
 #define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
 
-#define COPY_BUF(l,b,i,v)                                              \
-    if (l == 1) b[i++] = (xmlChar) v;                                  \
+#define COPY_BUF(b, i, v)                                              \
+    if (v < 0x80) b[i++] = v;                                          \
     else i += xmlCopyCharMultiByte(&b[i],v)
 
-#define CUR_CONSUMED \
-    (ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))
-
 /**
  * xmlSkipBlankChars:
  * @ctxt:  the XML parser context
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * skip all blanks character found at that point in the input streams.
  * It pops up finished entities in the process if allowable at that point.
  *
@@ -2204,7 +2335,7 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
                res++;
            if (*cur == 0) {
                ctxt->input->cur = cur;
-               xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+               xmlParserGrow(ctxt);
                cur = ctxt->input->cur;
            }
        }
@@ -2212,7 +2343,7 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
     } else {
         int expandPE = ((ctxt->external != 0) || (ctxt->inputNr != 1));
 
-       while (1) {
+       while (ctxt->instate != XML_PARSER_EOF) {
             if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */
                NEXT;
            } else if (CUR == '%') {
@@ -2223,8 +2354,30 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
                     break;
                xmlParsePEReference(ctxt);
             } else if (CUR == 0) {
+                unsigned long consumed;
+                xmlEntityPtr ent;
+
                 if (ctxt->inputNr <= 1)
                     break;
+
+                consumed = ctxt->input->consumed;
+                xmlSaturatedAddSizeT(&consumed,
+                                     ctxt->input->cur - ctxt->input->base);
+
+                /*
+                 * Add to sizeentities when parsing an external entity
+                 * for the first time.
+                 */
+                ent = ctxt->input->entity;
+                if ((ent->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+                    ((ent->flags & XML_ENT_PARSED) == 0)) {
+                    ent->flags |= XML_ENT_PARSED;
+
+                    xmlSaturatedAdd(&ctxt->sizeentities, consumed);
+                }
+
+                xmlParserEntityCheck(ctxt, consumed);
+
                 xmlPopInput(ctxt);
             } else {
                 break;
@@ -2261,6 +2414,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
  */
 xmlChar
 xmlPopInput(xmlParserCtxtPtr ctxt) {
+    xmlParserInputPtr input;
+
     if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
     if (xmlParserDebugEntities)
        xmlGenericError(xmlGenericErrorContext,
@@ -2269,9 +2424,12 @@ xmlPopInput(xmlParserCtxtPtr ctxt) {
         (ctxt->instate != XML_PARSER_EOF))
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
                     "Unfinished entity outside the DTD");
-    xmlFreeInputStream(inputPop(ctxt));
+    input = inputPop(ctxt);
+    if (input->entity != NULL)
+        input->entity->flags &= ~XML_ENT_EXPANDING;
+    xmlFreeInputStream(input);
     if (*ctxt->input->cur == 0)
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+        xmlParserGrow(ctxt);
     return(CUR);
 }
 
@@ -2298,7 +2456,7 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
                "Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
     }
     if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
-        (ctxt->inputNr > 1024)) {
+        (ctxt->inputNr > 100)) {
         xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
         while (ctxt->inputNr > 1)
             xmlFreeInputStream(inputPop(ctxt));
@@ -2315,7 +2473,9 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
  * xmlParseCharRef:
  * @ctxt:  an XML parser context
  *
- * parse Reference declarations
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse a numeric character reference. Always consumes '&'.
  *
  * [66] CharRef ::= '&#' [0-9]+ ';' |
  *                  '&#x' [0-9a-fA-F]+ ';'
@@ -2396,6 +2556,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
            ctxt->input->cur++;
        }
     } else {
+        if (RAW == '&')
+            SKIP(1);
         xmlFatalErr(ctxt, XML_ERR_INVALID_CHARREF, NULL);
     }
 
@@ -2516,6 +2678,8 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
  * xmlParserHandlePEReference:
  * @ctxt:  the parser context
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * [69] PEReference ::= '%' Name ';'
  *
  * [ WFC: No Recursion ]
@@ -2560,6 +2724,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
            return;
         case XML_PARSER_PROLOG:
        case XML_PARSER_START:
+       case XML_PARSER_XML_DECL:
        case XML_PARSER_MISC:
            xmlFatalErr(ctxt, XML_ERR_PEREF_IN_PROLOG, NULL);
            return;
@@ -2619,7 +2784,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
 }
 
 /**
- * xmlStringLenDecodeEntities:
+ * xmlStringDecodeEntitiesInt:
  * @ctxt:  the parser context
  * @str:  the input string
  * @len: the string length
@@ -2627,19 +2792,12 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
  * @end:  an end marker xmlChar, 0 if none
  * @end2:  an end marker xmlChar, 0 if none
  * @end3:  an end marker xmlChar, 0 if none
- *
- * Takes a entity string content and process to do the adequate substitutions.
- *
- * [67] Reference ::= EntityRef | CharRef
- *
- * [69] PEReference ::= '%' Name ';'
- *
- * Returns A newly allocated string with the substitution done. The caller
- *      must deallocate it !
+ * @check:  whether to perform entity checks
  */
-xmlChar *
-xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
-                     int what, xmlChar end, xmlChar  end2, xmlChar end3) {
+static xmlChar *
+xmlStringDecodeEntitiesInt(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
+                          int what, xmlChar end, xmlChar  end2, xmlChar end3,
+                           int check) {
     xmlChar *buffer = NULL;
     size_t buffer_size = 0;
     size_t nbchars = 0;
@@ -2650,14 +2808,15 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
     xmlEntityPtr ent;
     int c,l;
 
-    if ((ctxt == NULL) || (str == NULL) || (len < 0))
-       return(NULL);
+    if (str == NULL)
+        return(NULL);
     last = str + len;
 
     if (((ctxt->depth > 40) &&
          ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
-       (ctxt->depth > 1024)) {
-       xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+       (ctxt->depth > 100)) {
+       xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_LOOP,
+                       "Maximum entity nesting depth exceeded");
        return(NULL);
     }
 
@@ -2685,7 +2844,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
            int val = xmlParseStringCharRef(ctxt, &str);
            if (val == 0)
                 goto int_error;
-           COPY_BUF(0,buffer,nbchars,val);
+           COPY_BUF(buffer, nbchars, val);
            if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
                growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
            }
@@ -2695,13 +2854,10 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                        "String decoding Entity Reference: %.30s\n",
                        str);
            ent = xmlParseStringEntityRef(ctxt, &str);
-           xmlParserEntityCheck(ctxt, 0, ent, 0);
-           if (ent != NULL)
-               ctxt->nbentities += ent->checked / 2;
            if ((ent != NULL) &&
                (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
                if (ent->content != NULL) {
-                   COPY_BUF(0,buffer,nbchars,ent->content[0]);
+                   COPY_BUF(buffer, nbchars, ent->content[0]);
                    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
                        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
                    }
@@ -2711,10 +2867,23 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                     goto int_error;
                }
            } else if ((ent != NULL) && (ent->content != NULL)) {
+               if ((check) && (xmlParserEntityCheck(ctxt, ent->length)))
+                    goto int_error;
+
+                if (ent->flags & XML_ENT_EXPANDING) {
+                   xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+                    xmlHaltParser(ctxt);
+                    ent->content[0] = 0;
+                    goto int_error;
+                }
+
+                ent->flags |= XML_ENT_EXPANDING;
                ctxt->depth++;
-               rep = xmlStringDecodeEntities(ctxt, ent->content, what,
-                                             0, 0, 0);
+               rep = xmlStringDecodeEntitiesInt(ctxt, ent->content,
+                        ent->length, what, 0, 0, 0, check);
                ctxt->depth--;
+                ent->flags &= ~XML_ENT_EXPANDING;
+
                if (rep == NULL) {
                     ent->content[0] = 0;
                     goto int_error;
@@ -2724,8 +2893,6 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                 while (*current != 0) { /* non input consuming loop */
                     buffer[nbchars++] = *current++;
                     if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
-                        if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
-                            goto int_error;
                         growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
                     }
                 }
@@ -2748,9 +2915,6 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                xmlGenericError(xmlGenericErrorContext,
                        "String decoding PE Reference: %.30s\n", str);
            ent = xmlParseStringPEReference(ctxt, &str);
-           xmlParserEntityCheck(ctxt, 0, ent, 0);
-           if (ent != NULL)
-               ctxt->nbentities += ent->checked / 2;
            if (ent != NULL) {
                 if (ent->content == NULL) {
                    /*
@@ -2769,10 +2933,25 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                                      ent->name, NULL);
                    }
                }
+
+               if ((check) && (xmlParserEntityCheck(ctxt, ent->length)))
+                    goto int_error;
+
+                if (ent->flags & XML_ENT_EXPANDING) {
+                   xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+                    xmlHaltParser(ctxt);
+                    if (ent->content != NULL)
+                        ent->content[0] = 0;
+                    goto int_error;
+                }
+
+                ent->flags |= XML_ENT_EXPANDING;
                ctxt->depth++;
-               rep = xmlStringDecodeEntities(ctxt, ent->content, what,
-                                             0, 0, 0);
+               rep = xmlStringDecodeEntitiesInt(ctxt, ent->content,
+                        ent->length, what, 0, 0, 0, check);
                ctxt->depth--;
+                ent->flags &= ~XML_ENT_EXPANDING;
+
                if (rep == NULL) {
                     if (ent->content != NULL)
                         ent->content[0] = 0;
@@ -2782,8 +2961,6 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                 while (*current != 0) { /* non input consuming loop */
                     buffer[nbchars++] = *current++;
                     if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
-                        if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
-                            goto int_error;
                         growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
                     }
                 }
@@ -2791,7 +2968,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
                 rep = NULL;
            }
        } else {
-           COPY_BUF(l,buffer,nbchars,c);
+           COPY_BUF(buffer, nbchars, c);
            str += l;
            if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
                growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
@@ -2816,7 +2993,38 @@ int_error:
 }
 
 /**
- * xmlStringDecodeEntities:
+ * xmlStringLenDecodeEntities:
+ * @ctxt:  the parser context
+ * @str:  the input string
+ * @len: the string length
+ * @what:  combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF
+ * @end:  an end marker xmlChar, 0 if none
+ * @end2:  an end marker xmlChar, 0 if none
+ * @end3:  an end marker xmlChar, 0 if none
+ *
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Takes a entity string content and process to do the adequate substitutions.
+ *
+ * [67] Reference ::= EntityRef | CharRef
+ *
+ * [69] PEReference ::= '%' Name ';'
+ *
+ * Returns A newly allocated string with the substitution done. The caller
+ *      must deallocate it !
+ */
+xmlChar *
+xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
+                           int what, xmlChar end, xmlChar  end2,
+                           xmlChar end3) {
+    if ((ctxt == NULL) || (str == NULL) || (len < 0))
+        return(NULL);
+    return(xmlStringDecodeEntitiesInt(ctxt, str, len, what,
+                                      end, end2, end3, 0));
+}
+
+/**
+ * xmlStringDecodeEntities:
  * @ctxt:  the parser context
  * @str:  the input string
  * @what:  combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF
@@ -2824,6 +3032,8 @@ int_error:
  * @end2:  an end marker xmlChar, 0 if none
  * @end3:  an end marker xmlChar, 0 if none
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * Takes a entity string content and process to do the adequate substitutions.
  *
  * [67] Reference ::= EntityRef | CharRef
@@ -2837,8 +3047,8 @@ xmlChar *
 xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,
                        xmlChar end, xmlChar  end2, xmlChar end3) {
     if ((ctxt == NULL) || (str == NULL)) return(NULL);
-    return(xmlStringLenDecodeEntities(ctxt, str, xmlStrlen(str), what,
-           end, end2, end3));
+    return(xmlStringDecodeEntitiesInt(ctxt, str, xmlStrlen(str), what,
+                                      end, end2, end3, 0));
 }
 
 /************************************************************************
@@ -2978,7 +3188,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
         */
        max = len * 2;
 
-       buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
+       buffer = (xmlChar *) xmlMallocAtomic(max);
        if (buffer == NULL) {
            xmlErrMemory(ctxt, NULL);
            return(NULL);
@@ -2989,8 +3199,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
                xmlChar *tmp;
 
                max *= 2;
-               tmp = (xmlChar *) xmlRealloc(buffer,
-                                               max * sizeof(xmlChar));
+               tmp = (xmlChar *) xmlRealloc(buffer, max);
                if (tmp == NULL) {
                    xmlFree(buffer);
                    xmlErrMemory(ctxt, NULL);
@@ -3057,7 +3266,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
             */
            max = len * 2;
 
-           buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
+           buffer = (xmlChar *) xmlMallocAtomic(max);
            if (buffer == NULL) {
                xmlErrMemory(ctxt, NULL);
                return(NULL);
@@ -3068,8 +3277,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
                    xmlChar *tmp;
 
                    max *= 2;
-                   tmp = (xmlChar *) xmlRealloc(buffer,
-                                                   max * sizeof(xmlChar));
+                   tmp = (xmlChar *) xmlRealloc(buffer, max);
                    if (tmp == NULL) {
                        xmlErrMemory(ctxt, NULL);
                        xmlFree(buffer);
@@ -3105,14 +3313,6 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
  *     Routines to parse Name, NCName and NmToken                      *
  *                                                                     *
  ************************************************************************/
-#ifdef DEBUG
-static unsigned long nbParseName = 0;
-static unsigned long nbParseNmToken = 0;
-static unsigned long nbParseNCName = 0;
-static unsigned long nbParseNCNameComplex = 0;
-static unsigned long nbParseNameComplex = 0;
-static unsigned long nbParseStringName = 0;
-#endif
 
 /*
  * The two following functions are related to the change of accepted
@@ -3201,18 +3401,13 @@ static const xmlChar *
 xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
     int len = 0, l;
     int c;
-    int count = 0;
-
-#ifdef DEBUG
-    nbParseNameComplex++;
-#endif
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
 
     /*
      * Handler for more complex cases
      */
-    GROW;
-    if (ctxt->instate == XML_PARSER_EOF)
-        return(NULL);
     c = CUR_CHAR(l);
     if ((ctxt->options & XML_PARSE_OLD10) == 0) {
         /*
@@ -3261,13 +3456,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
                ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
                ((c >= 0x10000) && (c <= 0xEFFFF))
                )) {
-           if (count++ > XML_PARSER_CHUNK_SIZE) {
-               count = 0;
-               GROW;
-                if (ctxt->instate == XML_PARSER_EOF)
-                    return(NULL);
-           }
-           len += l;
+            if (len <= INT_MAX - l)
+               len += l;
            NEXTL(l);
            c = CUR_CHAR(l);
        }
@@ -3287,19 +3477,15 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
                (c == '_') || (c == ':') ||
                (IS_COMBINING(c)) ||
                (IS_EXTENDER(c)))) {
-           if (count++ > XML_PARSER_CHUNK_SIZE) {
-               count = 0;
-               GROW;
-                if (ctxt->instate == XML_PARSER_EOF)
-                    return(NULL);
-           }
-           len += l;
+            if (len <= INT_MAX - l)
+               len += l;
            NEXTL(l);
            c = CUR_CHAR(l);
        }
     }
-    if ((len > XML_MAX_NAME_LENGTH) &&
-        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(NULL);
+    if (len > maxLength) {
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
         return(NULL);
     }
@@ -3322,6 +3508,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
  * xmlParseName:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML name.
  *
  * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
@@ -3338,13 +3526,14 @@ const xmlChar *
 xmlParseName(xmlParserCtxtPtr ctxt) {
     const xmlChar *in;
     const xmlChar *ret;
-    int count = 0;
+    size_t count = 0;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_TEXT_LENGTH :
+                       XML_MAX_NAME_LENGTH;
 
     GROW;
-
-#ifdef DEBUG
-    nbParseName++;
-#endif
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(NULL);
 
     /*
      * Accelerator for simple ASCII names
@@ -3362,8 +3551,7 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
            in++;
        if ((*in > 0) && (*in < 0x80)) {
            count = in - ctxt->input->cur;
-            if ((count > XML_MAX_NAME_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+            if (count > maxLength) {
                 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
                 return(NULL);
             }
@@ -3379,65 +3567,44 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
     return(xmlParseNameComplex(ctxt));
 }
 
-static const xmlChar *
+static xmlHashedString
 xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
+    xmlHashedString ret;
     int len = 0, l;
     int c;
-    int count = 0;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
     size_t startPosition = 0;
 
-#ifdef DEBUG
-    nbParseNCNameComplex++;
-#endif
+    ret.name = NULL;
+    ret.hashValue = 0;
 
     /*
      * Handler for more complex cases
      */
-    GROW;
     startPosition = CUR_PTR - BASE_PTR;
     c = CUR_CHAR(l);
     if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
        (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {
-       return(NULL);
+       return(ret);
     }
 
     while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
           (xmlIsNameChar(ctxt, c) && (c != ':'))) {
-       if (count++ > XML_PARSER_CHUNK_SIZE) {
-            if ((len > XML_MAX_NAME_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
-                return(NULL);
-            }
-           count = 0;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF)
-                return(NULL);
-       }
-       len += l;
+        if (len <= INT_MAX - l)
+           len += l;
        NEXTL(l);
        c = CUR_CHAR(l);
-       if (c == 0) {
-           count = 0;
-           /*
-            * when shrinking to extend the buffer we really need to preserve
-            * the part of the name we already parsed. Hence rolling back
-            * by current length.
-            */
-           ctxt->input->cur -= l;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF)
-                return(NULL);
-           ctxt->input->cur += l;
-           c = CUR_CHAR(l);
-       }
     }
-    if ((len > XML_MAX_NAME_LENGTH) &&
-        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(ret);
+    if (len > maxLength) {
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
-        return(NULL);
+        return(ret);
     }
-    return(xmlDictLookup(ctxt->dict, (BASE_PTR + startPosition), len));
+    ret = xmlDictLookupHashed(ctxt->dict, (BASE_PTR + startPosition), len);
+    return(ret);
 }
 
 /**
@@ -3455,15 +3622,16 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
  * Returns the Name parsed or NULL
  */
 
-static const xmlChar *
+static xmlHashedString
 xmlParseNCName(xmlParserCtxtPtr ctxt) {
     const xmlChar *in, *e;
-    const xmlChar *ret;
-    int count = 0;
+    xmlHashedString ret;
+    size_t count = 0;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_TEXT_LENGTH :
+                       XML_MAX_NAME_LENGTH;
 
-#ifdef DEBUG
-    nbParseNCName++;
-#endif
+    ret.name = NULL;
 
     /*
      * Accelerator for simple ASCII names
@@ -3484,15 +3652,14 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
            goto complex;
        if ((*in > 0) && (*in < 0x80)) {
            count = in - ctxt->input->cur;
-            if ((count > XML_MAX_NAME_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+            if (count > maxLength) {
                 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
-                return(NULL);
+                return(ret);
             }
-           ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
+           ret = xmlDictLookupHashed(ctxt->dict, ctxt->input->cur, count);
            ctxt->input->cur = in;
            ctxt->input->col += count;
-           if (ret == NULL) {
+           if (ret.name == NULL) {
                xmlErrMemory(ctxt, NULL);
            }
            return(ret);
@@ -3567,21 +3734,20 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
     const xmlChar *cur = *str;
     int len = 0, l;
     int c;
-
-#ifdef DEBUG
-    nbParseStringName++;
-#endif
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
 
     c = CUR_SCHAR(cur, l);
     if (!xmlIsNameStartChar(ctxt, c)) {
        return(NULL);
     }
 
-    COPY_BUF(l,buf,len,c);
+    COPY_BUF(buf, len, c);
     cur += l;
     c = CUR_SCHAR(cur, l);
     while (xmlIsNameChar(ctxt, c)) {
-       COPY_BUF(l,buf,len,c);
+       COPY_BUF(buf, len, c);
        cur += l;
        c = CUR_SCHAR(cur, l);
        if (len >= XML_MAX_NAMELEN) { /* test bigentname.xml */
@@ -3592,7 +3758,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
            xmlChar *buffer;
            int max = len * 2;
 
-           buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
+           buffer = (xmlChar *) xmlMallocAtomic(max);
            if (buffer == NULL) {
                xmlErrMemory(ctxt, NULL);
                return(NULL);
@@ -3602,15 +3768,8 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
                if (len + 10 > max) {
                    xmlChar *tmp;
 
-                    if ((len > XML_MAX_NAME_LENGTH) &&
-                        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                        xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
-                       xmlFree(buffer);
-                        return(NULL);
-                    }
                    max *= 2;
-                   tmp = (xmlChar *) xmlRealloc(buffer,
-                                                   max * sizeof(xmlChar));
+                   tmp = (xmlChar *) xmlRealloc(buffer, max);
                    if (tmp == NULL) {
                        xmlErrMemory(ctxt, NULL);
                        xmlFree(buffer);
@@ -3618,17 +3777,21 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
                    }
                    buffer = tmp;
                }
-               COPY_BUF(l,buffer,len,c);
+               COPY_BUF(buffer, len, c);
                cur += l;
                c = CUR_SCHAR(cur, l);
+                if (len > maxLength) {
+                    xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+                    xmlFree(buffer);
+                    return(NULL);
+                }
            }
            buffer[len] = 0;
            *str = cur;
            return(buffer);
        }
     }
-    if ((len > XML_MAX_NAME_LENGTH) &&
-        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+    if (len > maxLength) {
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
         return(NULL);
     }
@@ -3640,6 +3803,8 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
  * xmlParseNmtoken:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML Nmtoken.
  *
  * [7] Nmtoken ::= (NameChar)+
@@ -3654,32 +3819,16 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
     xmlChar buf[XML_MAX_NAMELEN + 5];
     int len = 0, l;
     int c;
-    int count = 0;
-
-#ifdef DEBUG
-    nbParseNmToken++;
-#endif
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
 
-    GROW;
-    if (ctxt->instate == XML_PARSER_EOF)
-        return(NULL);
     c = CUR_CHAR(l);
 
     while (xmlIsNameChar(ctxt, c)) {
-       if (count++ > XML_PARSER_CHUNK_SIZE) {
-           count = 0;
-           GROW;
-       }
-       COPY_BUF(l,buf,len,c);
+       COPY_BUF(buf, len, c);
        NEXTL(l);
        c = CUR_CHAR(l);
-       if (c == 0) {
-           count = 0;
-           GROW;
-           if (ctxt->instate == XML_PARSER_EOF)
-               return(NULL);
-            c = CUR_CHAR(l);
-       }
        if (len >= XML_MAX_NAMELEN) {
            /*
             * Okay someone managed to make a huge token, so he's ready to pay
@@ -3688,33 +3837,18 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
            xmlChar *buffer;
            int max = len * 2;
 
-           buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
+           buffer = (xmlChar *) xmlMallocAtomic(max);
            if (buffer == NULL) {
                xmlErrMemory(ctxt, NULL);
                return(NULL);
            }
            memcpy(buffer, buf, len);
            while (xmlIsNameChar(ctxt, c)) {
-               if (count++ > XML_PARSER_CHUNK_SIZE) {
-                   count = 0;
-                   GROW;
-                    if (ctxt->instate == XML_PARSER_EOF) {
-                        xmlFree(buffer);
-                        return(NULL);
-                    }
-               }
                if (len + 10 > max) {
                    xmlChar *tmp;
 
-                    if ((max > XML_MAX_NAME_LENGTH) &&
-                        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                        xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
-                        xmlFree(buffer);
-                        return(NULL);
-                    }
                    max *= 2;
-                   tmp = (xmlChar *) xmlRealloc(buffer,
-                                                   max * sizeof(xmlChar));
+                   tmp = (xmlChar *) xmlRealloc(buffer, max);
                    if (tmp == NULL) {
                        xmlErrMemory(ctxt, NULL);
                        xmlFree(buffer);
@@ -3722,18 +3856,28 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
                    }
                    buffer = tmp;
                }
-               COPY_BUF(l,buffer,len,c);
+               COPY_BUF(buffer, len, c);
+                if (len > maxLength) {
+                    xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
+                    xmlFree(buffer);
+                    return(NULL);
+                }
                NEXTL(l);
                c = CUR_CHAR(l);
            }
            buffer[len] = 0;
+            if (ctxt->instate == XML_PARSER_EOF) {
+                xmlFree(buffer);
+                return(NULL);
+            }
            return(buffer);
        }
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(NULL);
     if (len == 0)
         return(NULL);
-    if ((len > XML_MAX_NAME_LENGTH) &&
-        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+    if (len > maxLength) {
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
         return(NULL);
     }
@@ -3745,6 +3889,8 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
  * @ctxt:  an XML parser context
  * @orig:  if non-NULL store a copy of the original entity value
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse a value for ENTITY declarations
  *
  * [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' |
@@ -3759,6 +3905,9 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
     int len = 0;
     int size = XML_PARSER_BUFFER_SIZE;
     int c, l;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
     xmlChar stop;
     xmlChar *ret = NULL;
     const xmlChar *cur = NULL;
@@ -3770,7 +3919,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
        xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_STARTED, NULL);
        return(NULL);
     }
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
        xmlErrMemory(ctxt, NULL);
        return(NULL);
@@ -3802,14 +3951,14 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
            xmlChar *tmp;
 
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlErrMemory(ctxt, NULL);
                 goto error;
            }
            buf = tmp;
        }
-       COPY_BUF(l,buf,len,c);
+       COPY_BUF(buf, len, c);
        NEXTL(l);
 
        GROW;
@@ -3818,6 +3967,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
            GROW;
            c = CUR_CHAR(l);
        }
+
+        if (len > maxLength) {
+            xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
+                           "entity value too long\n");
+            goto error;
+        }
     }
     buf[len] = 0;
     if (ctxt->instate == XML_PARSER_EOF)
@@ -3872,9 +4027,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
      * so XML_SUBSTITUTE_REF is not set here.
      */
     ++ctxt->depth;
-    ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
-                                  0, 0, 0);
+    ret = xmlStringDecodeEntitiesInt(ctxt, buf, len, XML_SUBSTITUTE_PEREF,
+                                     0, 0, 0, /* check */ 1);
     --ctxt->depth;
+
     if (orig != NULL) {
         *orig = buf;
         buf = NULL;
@@ -3905,6 +4061,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
     xmlChar *rep = NULL;
     size_t len = 0;
     size_t buf_size = 0;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_HUGE_LENGTH :
+                       XML_MAX_TEXT_LENGTH;
     int c, l, in_space = 0;
     xmlChar *current = NULL;
     xmlEntityPtr ent;
@@ -3936,16 +4095,6 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
     while (((NXT(0) != limit) && /* checked */
             (IS_CHAR(c)) && (c != '<')) &&
             (ctxt->instate != XML_PARSER_EOF)) {
-        /*
-         * Impose a reasonable limit on attribute size, unless XML_PARSE_HUGE
-         * special option is given
-         */
-        if ((len > XML_MAX_TEXT_LENGTH) &&
-            ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-            xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
-                           "AttValue length too long\n");
-            goto mem_error;
-        }
        if (c == '&') {
            in_space = 0;
            if (NXT(1) == '#') {
@@ -3979,9 +4128,6 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
                }
            } else {
                ent = xmlParseEntityRef(ctxt);
-               ctxt->nbentities++;
-               if (ent != NULL)
-                   ctxt->nbentities += ent->owner;
                if ((ent != NULL) &&
                    (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
                    if (len + 10 > buf_size) {
@@ -4000,10 +4146,13 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
                } else if ((ent != NULL) &&
                           (ctxt->replaceEntities != 0)) {
                    if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
+                        if (xmlParserEntityCheck(ctxt, ent->length))
+                            goto error;
+
                        ++ctxt->depth;
-                       rep = xmlStringDecodeEntities(ctxt, ent->content,
-                                                     XML_SUBSTITUTE_REF,
-                                                     0, 0, 0);
+                       rep = xmlStringDecodeEntitiesInt(ctxt, ent->content,
+                                ent->length, XML_SUBSTITUTE_REF, 0, 0, 0,
+                                /* check */ 1);
                        --ctxt->depth;
                        if (rep != NULL) {
                            current = rep;
@@ -4033,29 +4182,47 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
                    const xmlChar *cur = ent->name;
 
                    /*
-                    * This may look absurd but is needed to detect
-                    * entities problems
+                     * We also check for recursion and amplification
+                     * when entities are not substituted. They're
+                     * often expanded later.
                     */
                    if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
-                       (ent->content != NULL) && (ent->checked == 0)) {
-                       unsigned long oldnbent = ctxt->nbentities, diff;
-
-                       ++ctxt->depth;
-                       rep = xmlStringDecodeEntities(ctxt, ent->content,
-                                                 XML_SUBSTITUTE_REF, 0, 0, 0);
-                       --ctxt->depth;
-
-                        diff = ctxt->nbentities - oldnbent + 1;
-                        if (diff > INT_MAX / 2)
-                            diff = INT_MAX / 2;
-                        ent->checked = diff * 2;
-                       if (rep != NULL) {
-                           if (xmlStrchr(rep, '<'))
-                               ent->checked |= 1;
-                           xmlFree(rep);
-                           rep = NULL;
-                       } else {
-                            ent->content[0] = 0;
+                       (ent->content != NULL)) {
+                        if ((ent->flags & XML_ENT_CHECKED) == 0) {
+                            unsigned long oldCopy = ctxt->sizeentcopy;
+
+                            ctxt->sizeentcopy = ent->length;
+
+                            ++ctxt->depth;
+                            rep = xmlStringDecodeEntitiesInt(ctxt,
+                                    ent->content, ent->length,
+                                    XML_SUBSTITUTE_REF, 0, 0, 0,
+                                    /* check */ 1);
+                            --ctxt->depth;
+
+                            /*
+                             * If we're parsing DTD content, the entity
+                             * might reference other entities which
+                             * weren't defined yet, so the check isn't
+                             * reliable.
+                             */
+                            if (ctxt->inSubset == 0) {
+                                ent->flags |= XML_ENT_CHECKED;
+                                ent->expandedSize = ctxt->sizeentcopy;
+                            }
+
+                            if (rep != NULL) {
+                                xmlFree(rep);
+                                rep = NULL;
+                            } else {
+                                ent->content[0] = 0;
+                            }
+
+                            if (xmlParserEntityCheck(ctxt, oldCopy))
+                                goto error;
+                        } else {
+                            if (xmlParserEntityCheck(ctxt, ent->expandedSize))
+                                goto error;
                         }
                    }
 
@@ -4075,7 +4242,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
            if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
                if ((len != 0) || (!normalize)) {
                    if ((!normalize) || (!in_space)) {
-                       COPY_BUF(l,buf,len,0x20);
+                       COPY_BUF(buf, len, 0x20);
                        while (len + 10 > buf_size) {
                            growBuffer(buf, 10);
                        }
@@ -4084,7 +4251,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
                }
            } else {
                in_space = 0;
-               COPY_BUF(l,buf,len,c);
+               COPY_BUF(buf, len, c);
                if (len + 10 > buf_size) {
                    growBuffer(buf, 10);
                }
@@ -4093,6 +4260,11 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
        }
        GROW;
        c = CUR_CHAR(l);
+        if (len > maxLength) {
+            xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+                           "AttValue length too long\n");
+            goto mem_error;
+        }
     }
     if (ctxt->instate == XML_PARSER_EOF)
         goto error;
@@ -4114,17 +4286,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
     } else
        NEXT;
 
-    /*
-     * There we potentially risk an overflow, don't allow attribute value of
-     * length more than INT_MAX it is a very reasonable assumption !
-     */
-    if (len >= INT_MAX) {
-        xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
-                       "AttValue length too long\n");
-        goto mem_error;
-    }
-
-    if (attlen != NULL) *attlen = (int) len;
+    if (attlen != NULL) *attlen = len;
     return(buf);
 
 mem_error:
@@ -4141,6 +4303,8 @@ error:
  * xmlParseAttValue:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse a value for an attribute
  * Note: the parser won't do substitution of entities here, this
  * will be handled later in xmlStringGetNodeList
@@ -4181,6 +4345,8 @@ xmlParseAttValue(xmlParserCtxtPtr ctxt) {
  * xmlParseSystemLiteral:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML Literal
  *
  * [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
@@ -4194,11 +4360,12 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
     int len = 0;
     int size = XML_PARSER_BUFFER_SIZE;
     int cur, l;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
     xmlChar stop;
     int state = ctxt->instate;
-    int count = 0;
 
-    SHRINK;
     if (RAW == '"') {
         NEXT;
        stop = '"';
@@ -4210,7 +4377,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
        return(NULL);
     }
 
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
         xmlErrMemory(ctxt, NULL);
        return(NULL);
@@ -4221,15 +4388,8 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
        if (len + 5 >= size) {
            xmlChar *tmp;
 
-            if ((size > XML_MAX_NAME_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral");
-                xmlFree(buf);
-               ctxt->instate = (xmlParserInputState) state;
-                return(NULL);
-            }
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlFree(buf);
                xmlErrMemory(ctxt, NULL);
@@ -4238,26 +4398,21 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
            }
            buf = tmp;
        }
-       count++;
-       if (count > 50) {
-           SHRINK;
-           GROW;
-           count = 0;
-            if (ctxt->instate == XML_PARSER_EOF) {
-               xmlFree(buf);
-               return(NULL);
-            }
-       }
-       COPY_BUF(l,buf,len,cur);
+       COPY_BUF(buf, len, cur);
+        if (len > maxLength) {
+            xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral");
+            xmlFree(buf);
+            ctxt->instate = (xmlParserInputState) state;
+            return(NULL);
+        }
        NEXTL(l);
        cur = CUR_CHAR(l);
-       if (cur == 0) {
-           GROW;
-           SHRINK;
-           cur = CUR_CHAR(l);
-       }
     }
     buf[len] = 0;
+    if (ctxt->instate == XML_PARSER_EOF) {
+        xmlFree(buf);
+        return(NULL);
+    }
     ctxt->instate = (xmlParserInputState) state;
     if (!IS_CHAR(cur)) {
        xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, NULL);
@@ -4271,6 +4426,8 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
  * xmlParsePubidLiteral:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML public literal
  *
  * [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
@@ -4283,12 +4440,13 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
     xmlChar *buf = NULL;
     int len = 0;
     int size = XML_PARSER_BUFFER_SIZE;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
     xmlChar cur;
     xmlChar stop;
-    int count = 0;
     xmlParserInputState oldstate = ctxt->instate;
 
-    SHRINK;
     if (RAW == '"') {
         NEXT;
        stop = '"';
@@ -4299,7 +4457,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
        xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL);
        return(NULL);
     }
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
        xmlErrMemory(ctxt, NULL);
        return(NULL);
@@ -4310,14 +4468,8 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
        if (len + 1 >= size) {
            xmlChar *tmp;
 
-            if ((size > XML_MAX_NAME_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID");
-                xmlFree(buf);
-                return(NULL);
-            }
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlErrMemory(ctxt, NULL);
                xmlFree(buf);
@@ -4326,35 +4478,29 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
            buf = tmp;
        }
        buf[len++] = cur;
-       count++;
-       if (count > 50) {
-           SHRINK;
-           GROW;
-           count = 0;
-            if (ctxt->instate == XML_PARSER_EOF) {
-               xmlFree(buf);
-               return(NULL);
-            }
-       }
+        if (len > maxLength) {
+            xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID");
+            xmlFree(buf);
+            return(NULL);
+        }
        NEXT;
        cur = CUR;
-       if (cur == 0) {
-           GROW;
-           SHRINK;
-           cur = CUR;
-       }
     }
     buf[len] = 0;
+    if (ctxt->instate == XML_PARSER_EOF) {
+        xmlFree(buf);
+        return(NULL);
+    }
     if (cur != stop) {
        xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, NULL);
     } else {
-       NEXT;
+       NEXTL(1);
     }
     ctxt->instate = oldstate;
     return(buf);
 }
 
-static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata);
+static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int partial);
 
 /*
  * used for the test in the inner loop of the char data testing
@@ -4395,12 +4541,12 @@ static const unsigned char test_char_data[256] = {
 };
 
 /**
- * xmlParseCharData:
+ * xmlParseCharDataInternal:
  * @ctxt:  an XML parser context
- * @cdata:  int indicating whether we are within a CDATA section
+ * @partial:  buffer may contain partial UTF-8 sequences
  *
- * parse a CharData section.
- * if we are within a CDATA section ']]>' marks an end of section.
+ * Parse character data. Always makes progress if the first char isn't
+ * '<' or '&'.
  *
  * The right angle bracket (>) may be represented using the string "&gt;",
  * and must, for compatibility, be escaped using "&gt;" or a character
@@ -4409,147 +4555,147 @@ static const unsigned char test_char_data[256] = {
  *
  * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
  */
-
-void
-xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {
+static void
+xmlParseCharDataInternal(xmlParserCtxtPtr ctxt, int partial) {
     const xmlChar *in;
     int nbchar = 0;
     int line = ctxt->input->line;
     int col = ctxt->input->col;
     int ccol;
 
-    SHRINK;
     GROW;
     /*
      * Accelerated common case where input don't need to be
      * modified before passing it to the handler.
      */
-    if (!cdata) {
-       in = ctxt->input->cur;
-       do {
+    in = ctxt->input->cur;
+    do {
 get_more_space:
-           while (*in == 0x20) { in++; ctxt->input->col++; }
-           if (*in == 0xA) {
-               do {
-                   ctxt->input->line++; ctxt->input->col = 1;
-                   in++;
-               } while (*in == 0xA);
-               goto get_more_space;
-           }
-           if (*in == '<') {
-               nbchar = in - ctxt->input->cur;
-               if (nbchar > 0) {
-                   const xmlChar *tmp = ctxt->input->cur;
-                   ctxt->input->cur = in;
-
-                   if ((ctxt->sax != NULL) &&
-                       (ctxt->sax->ignorableWhitespace !=
-                        ctxt->sax->characters)) {
-                       if (areBlanks(ctxt, tmp, nbchar, 1)) {
-                           if (ctxt->sax->ignorableWhitespace != NULL)
-                               ctxt->sax->ignorableWhitespace(ctxt->userData,
-                                                      tmp, nbchar);
-                       } else {
-                           if (ctxt->sax->characters != NULL)
-                               ctxt->sax->characters(ctxt->userData,
-                                                     tmp, nbchar);
-                           if (*ctxt->space == -1)
-                               *ctxt->space = -2;
-                       }
-                   } else if ((ctxt->sax != NULL) &&
-                              (ctxt->sax->characters != NULL)) {
-                       ctxt->sax->characters(ctxt->userData,
-                                             tmp, nbchar);
-                   }
-               }
-               return;
-           }
+        while (*in == 0x20) { in++; ctxt->input->col++; }
+        if (*in == 0xA) {
+            do {
+                ctxt->input->line++; ctxt->input->col = 1;
+                in++;
+            } while (*in == 0xA);
+            goto get_more_space;
+        }
+        if (*in == '<') {
+            nbchar = in - ctxt->input->cur;
+            if (nbchar > 0) {
+                const xmlChar *tmp = ctxt->input->cur;
+                ctxt->input->cur = in;
+
+                if ((ctxt->sax != NULL) &&
+                    (ctxt->disableSAX == 0) &&
+                    (ctxt->sax->ignorableWhitespace !=
+                     ctxt->sax->characters)) {
+                    if (areBlanks(ctxt, tmp, nbchar, 1)) {
+                        if (ctxt->sax->ignorableWhitespace != NULL)
+                            ctxt->sax->ignorableWhitespace(ctxt->userData,
+                                                   tmp, nbchar);
+                    } else {
+                        if (ctxt->sax->characters != NULL)
+                            ctxt->sax->characters(ctxt->userData,
+                                                  tmp, nbchar);
+                        if (*ctxt->space == -1)
+                            *ctxt->space = -2;
+                    }
+                } else if ((ctxt->sax != NULL) &&
+                           (ctxt->disableSAX == 0) &&
+                           (ctxt->sax->characters != NULL)) {
+                    ctxt->sax->characters(ctxt->userData,
+                                          tmp, nbchar);
+                }
+            }
+            return;
+        }
 
 get_more:
-            ccol = ctxt->input->col;
-           while (test_char_data[*in]) {
-               in++;
-               ccol++;
-           }
-           ctxt->input->col = ccol;
-           if (*in == 0xA) {
-               do {
-                   ctxt->input->line++; ctxt->input->col = 1;
-                   in++;
-               } while (*in == 0xA);
-               goto get_more;
-           }
-           if (*in == ']') {
-               if ((in[1] == ']') && (in[2] == '>')) {
-                   xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
-                   ctxt->input->cur = in + 1;
-                   return;
-               }
-               in++;
-               ctxt->input->col++;
-               goto get_more;
-           }
-           nbchar = in - ctxt->input->cur;
-           if (nbchar > 0) {
-               if ((ctxt->sax != NULL) &&
-                   (ctxt->sax->ignorableWhitespace !=
-                    ctxt->sax->characters) &&
-                   (IS_BLANK_CH(*ctxt->input->cur))) {
-                   const xmlChar *tmp = ctxt->input->cur;
-                   ctxt->input->cur = in;
-
-                   if (areBlanks(ctxt, tmp, nbchar, 0)) {
-                       if (ctxt->sax->ignorableWhitespace != NULL)
-                           ctxt->sax->ignorableWhitespace(ctxt->userData,
-                                                          tmp, nbchar);
-                   } else {
-                       if (ctxt->sax->characters != NULL)
-                           ctxt->sax->characters(ctxt->userData,
-                                                 tmp, nbchar);
-                       if (*ctxt->space == -1)
-                           *ctxt->space = -2;
-                   }
-                    line = ctxt->input->line;
-                    col = ctxt->input->col;
-               } else if (ctxt->sax != NULL) {
-                   if (ctxt->sax->characters != NULL)
-                       ctxt->sax->characters(ctxt->userData,
-                                             ctxt->input->cur, nbchar);
-                    line = ctxt->input->line;
-                    col = ctxt->input->col;
-               }
-                /* something really bad happened in the SAX callback */
-                if (ctxt->instate != XML_PARSER_CONTENT)
-                    return;
-           }
-           ctxt->input->cur = in;
-           if (*in == 0xD) {
-               in++;
-               if (*in == 0xA) {
-                   ctxt->input->cur = in;
-                   in++;
-                   ctxt->input->line++; ctxt->input->col = 1;
-                   continue; /* while */
-               }
-               in--;
-           }
-           if (*in == '<') {
-               return;
-           }
-           if (*in == '&') {
-               return;
-           }
-           SHRINK;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF)
-               return;
-           in = ctxt->input->cur;
-       } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
-       nbchar = 0;
-    }
+        ccol = ctxt->input->col;
+        while (test_char_data[*in]) {
+            in++;
+            ccol++;
+        }
+        ctxt->input->col = ccol;
+        if (*in == 0xA) {
+            do {
+                ctxt->input->line++; ctxt->input->col = 1;
+                in++;
+            } while (*in == 0xA);
+            goto get_more;
+        }
+        if (*in == ']') {
+            if ((in[1] == ']') && (in[2] == '>')) {
+                xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
+                if (ctxt->instate != XML_PARSER_EOF)
+                    ctxt->input->cur = in + 1;
+                return;
+            }
+            in++;
+            ctxt->input->col++;
+            goto get_more;
+        }
+        nbchar = in - ctxt->input->cur;
+        if (nbchar > 0) {
+            if ((ctxt->sax != NULL) &&
+                (ctxt->disableSAX == 0) &&
+                (ctxt->sax->ignorableWhitespace !=
+                 ctxt->sax->characters) &&
+                (IS_BLANK_CH(*ctxt->input->cur))) {
+                const xmlChar *tmp = ctxt->input->cur;
+                ctxt->input->cur = in;
+
+                if (areBlanks(ctxt, tmp, nbchar, 0)) {
+                    if (ctxt->sax->ignorableWhitespace != NULL)
+                        ctxt->sax->ignorableWhitespace(ctxt->userData,
+                                                       tmp, nbchar);
+                } else {
+                    if (ctxt->sax->characters != NULL)
+                        ctxt->sax->characters(ctxt->userData,
+                                              tmp, nbchar);
+                    if (*ctxt->space == -1)
+                        *ctxt->space = -2;
+                }
+                line = ctxt->input->line;
+                col = ctxt->input->col;
+            } else if ((ctxt->sax != NULL) &&
+                       (ctxt->disableSAX == 0)) {
+                if (ctxt->sax->characters != NULL)
+                    ctxt->sax->characters(ctxt->userData,
+                                          ctxt->input->cur, nbchar);
+                line = ctxt->input->line;
+                col = ctxt->input->col;
+            }
+            if (ctxt->instate == XML_PARSER_EOF)
+                return;
+        }
+        ctxt->input->cur = in;
+        if (*in == 0xD) {
+            in++;
+            if (*in == 0xA) {
+                ctxt->input->cur = in;
+                in++;
+                ctxt->input->line++; ctxt->input->col = 1;
+                continue; /* while */
+            }
+            in--;
+        }
+        if (*in == '<') {
+            return;
+        }
+        if (*in == '&') {
+            return;
+        }
+        SHRINK;
+        GROW;
+        if (ctxt->instate == XML_PARSER_EOF)
+            return;
+        in = ctxt->input->cur;
+    } while (((*in >= 0x20) && (*in <= 0x7F)) ||
+             (*in == 0x09) || (*in == 0x0a));
     ctxt->input->line = line;
     ctxt->input->col = col;
-    xmlParseCharDataComplex(ctxt, cdata);
+    xmlParseCharDataComplex(ctxt, partial);
 }
 
 /**
@@ -4557,34 +4703,28 @@ get_more:
  * @ctxt:  an XML parser context
  * @cdata:  int indicating whether we are within a CDATA section
  *
+ * Always makes progress if the first char isn't '<' or '&'.
+ *
  * parse a CharData section.this is the fallback function
  * of xmlParseCharData() when the parsing requires handling
  * of non-ASCII characters.
  */
 static void
-xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
+xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int partial) {
     xmlChar buf[XML_PARSER_BIG_BUFFER_SIZE + 5];
     int nbchar = 0;
     int cur, l;
-    int count = 0;
 
-    SHRINK;
-    GROW;
     cur = CUR_CHAR(l);
     while ((cur != '<') && /* checked */
            (cur != '&') &&
-          (IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ {
-       if ((cur == ']') && (NXT(1) == ']') &&
-           (NXT(2) == '>')) {
-           if (cdata) break;
-           else {
-               xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
-           }
+          (IS_CHAR(cur))) {
+       if ((cur == ']') && (NXT(1) == ']') && (NXT(2) == '>')) {
+           xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
        }
-       COPY_BUF(l,buf,nbchar,cur);
+       COPY_BUF(buf, nbchar, cur);
        /* move current position before possible calling of ctxt->sax->characters */
        NEXTL(l);
-       cur = CUR_CHAR(l);
        if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) {
            buf[nbchar] = 0;
 
@@ -4609,16 +4749,12 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
             /* something really bad happened in the SAX callback */
             if (ctxt->instate != XML_PARSER_CONTENT)
                 return;
+            SHRINK;
        }
-       count++;
-       if (count > 50) {
-           SHRINK;
-           GROW;
-           count = 0;
-            if (ctxt->instate == XML_PARSER_EOF)
-               return;
-       }
+       cur = CUR_CHAR(l);
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return;
     if (nbchar != 0) {
         buf[nbchar] = 0;
        /*
@@ -4637,22 +4773,51 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
            }
        }
     }
-    if ((cur != 0) && (!IS_CHAR(cur))) {
-       /* Generate the error and skip the offending character */
-        xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
-                          "PCDATA invalid Char value %d\n",
-                         cur);
-       NEXTL(l);
+    /*
+     * cur == 0 can mean
+     *
+     * - XML_PARSER_EOF or memory error. This is checked above.
+     * - An actual 0 character.
+     * - End of buffer.
+     * - An incomplete UTF-8 sequence. This is allowed if partial is set.
+     */
+    if (ctxt->input->cur < ctxt->input->end) {
+        if ((cur == 0) && (CUR != 0)) {
+            if (partial == 0) {
+                xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+                        "Incomplete UTF-8 sequence starting with %02X\n", CUR);
+                NEXTL(1);
+            }
+        } else if ((cur != '<') && (cur != '&')) {
+            /* Generate the error and skip the offending character */
+            xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+                              "PCDATA invalid Char value %d\n", cur);
+            NEXTL(l);
+        }
     }
 }
 
 /**
+ * xmlParseCharData:
+ * @ctxt:  an XML parser context
+ * @cdata:  unused
+ *
+ * DEPRECATED: Internal function, don't use.
+ */
+void
+xmlParseCharData(xmlParserCtxtPtr ctxt, ATTRIBUTE_UNUSED int cdata) {
+    xmlParseCharDataInternal(ctxt, 0);
+}
+
+/**
  * xmlParseExternalID:
  * @ctxt:  an XML parser context
  * @publicID:  a xmlChar** receiving PubidLiteral
  * @strict: indicate whether we should restrict parsing to only
  *          production [75], see NOTE below
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * Parse an External ID or a Public ID
  *
  * NOTE: Productions [75] and [83] interact badly since [75] can generate
@@ -4672,8 +4837,6 @@ xmlChar *
 xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
     xmlChar *URI = NULL;
 
-    SHRINK;
-
     *publicID = NULL;
     if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
         SKIP(6);
@@ -4741,7 +4904,9 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
     int q, ql;
     int r, rl;
     int cur, l;
-    size_t count = 0;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_HUGE_LENGTH :
+                       XML_MAX_TEXT_LENGTH;
     int inputid;
 
     inputid = ctxt->input->id;
@@ -4749,13 +4914,12 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
     if (buf == NULL) {
         len = 0;
        size = XML_PARSER_BUFFER_SIZE;
-       buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+       buf = (xmlChar *) xmlMallocAtomic(size);
        if (buf == NULL) {
            xmlErrMemory(ctxt, NULL);
            return;
        }
     }
-    GROW;      /* Assure there's enough input data */
     q = CUR_CHAR(ql);
     if (q == 0)
         goto not_terminated;
@@ -4773,7 +4937,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
     if (!IS_CHAR(r)) {
         xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
                           "xmlParseComment: invalid xmlChar value %d\n",
-                         q);
+                         r);
        xmlFree (buf);
        return;
     }
@@ -4787,13 +4951,6 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
        if ((r == '-') && (q == '-')) {
            xmlFatalErr(ctxt, XML_ERR_HYPHEN_IN_COMMENT, NULL);
        }
-        if ((len > XML_MAX_TEXT_LENGTH) &&
-            ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-            xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
-                         "Comment too big found", NULL);
-            xmlFree (buf);
-            return;
-        }
        if (len + 5 >= size) {
            xmlChar *new_buf;
             size_t new_size;
@@ -4808,31 +4965,28 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
            buf = new_buf;
             size = new_size;
        }
-       COPY_BUF(ql,buf,len,q);
+       COPY_BUF(buf, len, q);
+        if (len > maxLength) {
+            xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
+                         "Comment too big found", NULL);
+            xmlFree (buf);
+            return;
+        }
+
        q = r;
        ql = rl;
        r = cur;
        rl = l;
 
-       count++;
-       if (count > 50) {
-           SHRINK;
-           GROW;
-           count = 0;
-            if (ctxt->instate == XML_PARSER_EOF) {
-               xmlFree(buf);
-               return;
-            }
-       }
        NEXTL(l);
        cur = CUR_CHAR(l);
-       if (cur == 0) {
-           SHRINK;
-           GROW;
-           cur = CUR_CHAR(l);
-       }
+
     }
     buf[len] = 0;
+    if (ctxt->instate == XML_PARSER_EOF) {
+        xmlFree(buf);
+        return;
+    }
     if (cur == 0) {
        xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
                             "Comment not terminated \n<!--%.50s\n", buf);
@@ -4864,7 +5018,10 @@ not_terminated:
  * xmlParseComment:
  * @ctxt:  an XML parser context
  *
- * Skip an XML (SGML) comment <!-- .... -->
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse an XML (SGML) comment. Always consumes '<!'.
+ *
  *  The spec says that "For compatibility, the string "--" (double-hyphen)
  *  must not occur within comments. "
  *
@@ -4875,6 +5032,9 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
     xmlChar *buf = NULL;
     size_t size = XML_PARSER_BUFFER_SIZE;
     size_t len = 0;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_HUGE_LENGTH :
+                       XML_MAX_TEXT_LENGTH;
     xmlParserInputState state;
     const xmlChar *in;
     size_t nbchar = 0;
@@ -4884,13 +5044,15 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
     /*
      * Check that there is a comment right here.
      */
-    if ((RAW != '<') || (NXT(1) != '!') ||
-        (NXT(2) != '-') || (NXT(3) != '-')) return;
+    if ((RAW != '<') || (NXT(1) != '!'))
+        return;
+    SKIP(2);
+    if ((RAW != '-') || (NXT(1) != '-'))
+        return;
     state = ctxt->instate;
     ctxt->instate = XML_PARSER_COMMENT;
     inputid = ctxt->input->id;
-    SKIP(4);
-    SHRINK;
+    SKIP(2);
     GROW;
 
     /*
@@ -4926,40 +5088,35 @@ get_more:
         * save current set of data
         */
        if (nbchar > 0) {
-           if ((ctxt->sax != NULL) &&
-               (ctxt->sax->comment != NULL)) {
-               if (buf == NULL) {
-                   if ((*in == '-') && (in[1] == '-'))
-                       size = nbchar + 1;
-                   else
-                       size = XML_PARSER_BUFFER_SIZE + nbchar;
-                   buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
-                   if (buf == NULL) {
-                       xmlErrMemory(ctxt, NULL);
-                       ctxt->instate = state;
-                       return;
-                   }
-                   len = 0;
-               } else if (len + nbchar + 1 >= size) {
-                   xmlChar *new_buf;
-                   size  += len + nbchar + XML_PARSER_BUFFER_SIZE;
-                   new_buf = (xmlChar *) xmlRealloc(buf,
-                                                    size * sizeof(xmlChar));
-                   if (new_buf == NULL) {
-                       xmlFree (buf);
-                       xmlErrMemory(ctxt, NULL);
-                       ctxt->instate = state;
-                       return;
-                   }
-                   buf = new_buf;
-               }
-               memcpy(&buf[len], ctxt->input->cur, nbchar);
-               len += nbchar;
-               buf[len] = 0;
-           }
+            if (buf == NULL) {
+                if ((*in == '-') && (in[1] == '-'))
+                    size = nbchar + 1;
+                else
+                    size = XML_PARSER_BUFFER_SIZE + nbchar;
+                buf = (xmlChar *) xmlMallocAtomic(size);
+                if (buf == NULL) {
+                    xmlErrMemory(ctxt, NULL);
+                    ctxt->instate = state;
+                    return;
+                }
+                len = 0;
+            } else if (len + nbchar + 1 >= size) {
+                xmlChar *new_buf;
+                size  += len + nbchar + XML_PARSER_BUFFER_SIZE;
+                new_buf = (xmlChar *) xmlRealloc(buf, size);
+                if (new_buf == NULL) {
+                    xmlFree (buf);
+                    xmlErrMemory(ctxt, NULL);
+                    ctxt->instate = state;
+                    return;
+                }
+                buf = new_buf;
+            }
+            memcpy(&buf[len], ctxt->input->cur, nbchar);
+            len += nbchar;
+            buf[len] = 0;
        }
-        if ((len > XML_MAX_TEXT_LENGTH) &&
-            ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+        if (len > maxLength) {
             xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
                          "Comment too big found", NULL);
             xmlFree (buf);
@@ -5039,6 +5196,8 @@ get_more:
  * xmlParsePITarget:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the name of a PI
  *
  * [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
@@ -5147,6 +5306,8 @@ error:
  * xmlParsePI:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML Processing Instruction.
  *
  * [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
@@ -5159,10 +5320,12 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
     xmlChar *buf = NULL;
     size_t len = 0;
     size_t size = XML_PARSER_BUFFER_SIZE;
+    size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                       XML_MAX_HUGE_LENGTH :
+                       XML_MAX_TEXT_LENGTH;
     int cur, l;
     const xmlChar *target;
     xmlParserInputState state;
-    int count = 0;
 
     if ((RAW == '<') && (NXT(1) == '?')) {
        int inputid = ctxt->input->id;
@@ -5172,7 +5335,6 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
         * this is a Processing Instruction.
         */
        SKIP(2);
-       SHRINK;
 
        /*
         * Parse the target name and check for special support like
@@ -5199,7 +5361,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
                    ctxt->instate = state;
                return;
            }
-           buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+           buf = (xmlChar *) xmlMallocAtomic(size);
            if (buf == NULL) {
                xmlErrMemory(ctxt, NULL);
                ctxt->instate = state;
@@ -5225,42 +5387,22 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
                    buf = tmp;
                     size = new_size;
                }
-               count++;
-               if (count > 50) {
-                   SHRINK;
-                   GROW;
-                    if (ctxt->instate == XML_PARSER_EOF) {
-                        xmlFree(buf);
-                        return;
-                    }
-                   count = 0;
-                    if ((len > XML_MAX_TEXT_LENGTH) &&
-                        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                        xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
-                                          "PI %s too big found", target);
-                        xmlFree(buf);
-                        ctxt->instate = state;
-                        return;
-                    }
-               }
-               COPY_BUF(l,buf,len,cur);
+               COPY_BUF(buf, len, cur);
+                if (len > maxLength) {
+                    xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
+                                      "PI %s too big found", target);
+                    xmlFree(buf);
+                    ctxt->instate = state;
+                    return;
+                }
                NEXTL(l);
                cur = CUR_CHAR(l);
-               if (cur == 0) {
-                   SHRINK;
-                   GROW;
-                   cur = CUR_CHAR(l);
-               }
            }
-            if ((len > XML_MAX_TEXT_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
-                                  "PI %s too big found", target);
+           buf[len] = 0;
+            if (ctxt->instate == XML_PARSER_EOF) {
                 xmlFree(buf);
-                ctxt->instate = state;
                 return;
             }
-           buf[len] = 0;
            if (cur != '?') {
                xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
                      "ParsePI: PI %s never end ...\n", target);
@@ -5305,7 +5447,9 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
  * xmlParseNotationDecl:
  * @ctxt:  an XML parser context
  *
- * parse a notation declaration
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse a notation declaration. Always consumes '<!'.
  *
  * [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID |  PublicID) S? '>'
  *
@@ -5323,10 +5467,13 @@ xmlParseNotationDecl(xmlParserCtxtPtr ctxt) {
     xmlChar *Pubid;
     xmlChar *Systemid;
 
-    if (CMP10(CUR_PTR, '<', '!', 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
+    if ((CUR != '<') || (NXT(1) != '!'))
+        return;
+    SKIP(2);
+
+    if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
        int inputid = ctxt->input->id;
-       SHRINK;
-       SKIP(10);
+       SKIP(8);
        if (SKIP_BLANKS == 0) {
            xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
                           "Space required after '<!NOTATION'\n");
@@ -5377,7 +5524,9 @@ xmlParseNotationDecl(xmlParserCtxtPtr ctxt) {
  * xmlParseEntityDecl:
  * @ctxt:  an XML parser context
  *
- * parse <!ENTITY declarations
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse an entity declaration. Always consumes '<!'.
  *
  * [70] EntityDecl ::= GEDecl | PEDecl
  *
@@ -5404,11 +5553,14 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
     int isParameter = 0;
     xmlChar *orig = NULL;
 
+    if ((CUR != '<') || (NXT(1) != '!'))
+        return;
+    SKIP(2);
+
     /* GROW; done in the caller */
-    if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
+    if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
        int inputid = ctxt->input->id;
-       SHRINK;
-       SKIP(8);
+       SKIP(6);
        if (SKIP_BLANKS == 0) {
            xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
                           "Space required after '<!ENTITY'\n");
@@ -5506,7 +5658,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
                        ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
                        if (ctxt->myDoc == NULL) {
                            xmlErrMemory(ctxt, "New Doc failed");
-                           return;
+                           goto done;
                        }
                        ctxt->myDoc->properties = XML_DOC_INTERNAL;
                    }
@@ -5577,7 +5729,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
                            ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
                            if (ctxt->myDoc == NULL) {
                                xmlErrMemory(ctxt, "New Doc failed");
-                               return;
+                               goto done;
                            }
                            ctxt->myDoc->properties = XML_DOC_INTERNAL;
                        }
@@ -5644,6 +5796,8 @@ done:
  * @ctxt:  an XML parser context
  * @value:  Receive a possible fixed default value for the attribute
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * Parse an attribute default declaration
  *
  * [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
@@ -5705,6 +5859,8 @@ xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value) {
  * xmlParseNotationType:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an Notation attribute type.
  *
  * Note: the leading 'NOTATION' S part has already being parsed...
@@ -5727,7 +5883,6 @@ xmlParseNotationType(xmlParserCtxtPtr ctxt) {
        xmlFatalErr(ctxt, XML_ERR_NOTATION_NOT_STARTED, NULL);
        return(NULL);
     }
-    SHRINK;
     do {
         NEXT;
        SKIP_BLANKS;
@@ -5777,6 +5932,8 @@ xmlParseNotationType(xmlParserCtxtPtr ctxt) {
  * xmlParseEnumerationType:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an Enumeration attribute type.
  *
  * [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
@@ -5797,7 +5954,6 @@ xmlParseEnumerationType(xmlParserCtxtPtr ctxt) {
        xmlFatalErr(ctxt, XML_ERR_ATTLIST_NOT_STARTED, NULL);
        return(NULL);
     }
-    SHRINK;
     do {
         NEXT;
        SKIP_BLANKS;
@@ -5847,6 +6003,8 @@ xmlParseEnumerationType(xmlParserCtxtPtr ctxt) {
  * @ctxt:  an XML parser context
  * @tree:  the enumeration tree built while parsing
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an Enumerated attribute type.
  *
  * [57] EnumeratedType ::= NotationType | Enumeration
@@ -5880,6 +6038,8 @@ xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
  * @ctxt:  an XML parser context
  * @tree:  the enumeration tree built while parsing
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the Attribute list def for an element
  *
  * [54] AttType ::= StringType | TokenizedType | EnumeratedType
@@ -5922,7 +6082,6 @@ xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
  */
 int
 xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
-    SHRINK;
     if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
        SKIP(5);
        return(XML_ATTRIBUTE_CDATA);
@@ -5955,7 +6114,9 @@ xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
  * xmlParseAttributeListDecl:
  * @ctxt:  an XML parser context
  *
- * : parse the Attribute list def for an element
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse an attribute list declaration for an element. Always consumes '<!'.
  *
  * [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
  *
@@ -5968,10 +6129,14 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
     const xmlChar *attrName;
     xmlEnumerationPtr tree;
 
-    if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
+    if ((CUR != '<') || (NXT(1) != '!'))
+        return;
+    SKIP(2);
+
+    if (CMP7(CUR_PTR, 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
        int inputid = ctxt->input->id;
 
-       SKIP(9);
+       SKIP(7);
        if (SKIP_BLANKS == 0) {
            xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
                                 "Space required after '<!ATTLIST'\n");
@@ -6076,6 +6241,8 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
  * @ctxt:  an XML parser context
  * @inputchk:  the input used for the current entity, needed for boundary checks
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the declaration for a Mixed Element content
  * The leading '(' and spaces have been skipped in xmlParseElementContentDecl
  *
@@ -6099,7 +6266,6 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
     if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
        SKIP(7);
        SKIP_BLANKS;
-       SHRINK;
        if (RAW == ')') {
            if (ctxt->input->id != inputchk) {
                xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
@@ -6271,7 +6437,6 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
        GROW;
     }
     SKIP_BLANKS;
-    SHRINK;
     while ((RAW != ')') && (ctxt->instate != XML_PARSER_EOF)) {
         /*
         * Each loop we parse one separator and one element.
@@ -6494,6 +6659,8 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
  * @ctxt:  an XML parser context
  * @inputchk:  the input used for the current entity, needed for boundary checks
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the declaration for a Mixed Element content
  * The leading '(' and spaces have been skipped in xmlParseElementContentDecl
  *
@@ -6531,6 +6698,8 @@ xmlParseElementChildrenContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
  * @name:  the name of the element being defined.
  * @result:  the Element Content pointer will be stored here if any
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the declaration for an Element content either Mixed or Children,
  * the cases EMPTY and ANY are handled directly in xmlParseElementDecl
  *
@@ -6575,7 +6744,9 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name,
  * xmlParseElementDecl:
  * @ctxt:  an XML parser context
  *
- * parse an Element declaration.
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse an element declaration. Always consumes '<!'.
  *
  * [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
  *
@@ -6590,11 +6761,15 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
     int ret = -1;
     xmlElementContentPtr content  = NULL;
 
+    if ((CUR != '<') || (NXT(1) != '!'))
+        return(ret);
+    SKIP(2);
+
     /* GROW; done in the caller */
-    if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
+    if (CMP7(CUR_PTR, 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
        int inputid = ctxt->input->id;
 
-       SKIP(9);
+       SKIP(7);
        if (SKIP_BLANKS == 0) {
            xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
                           "Space required after 'ELEMENT'\n");
@@ -6682,6 +6857,8 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
  * xmlParseConditionalSections
  * @ctxt:  an XML parser context
  *
+ * Parse a conditional section. Always consumes '<!['.
+ *
  * [61] conditionalSect ::= includeSect | ignoreSect
  * [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
  * [63] ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
@@ -6732,8 +6909,6 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
                 inputIds[depth] = id;
                 depth++;
             } else if (CMP6(CUR_PTR, 'I', 'G', 'N', 'O', 'R', 'E')) {
-                int state;
-                xmlParserInputState instate;
                 size_t ignoreDepth = 0;
 
                 SKIP(6);
@@ -6750,15 +6925,6 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
                 }
                 NEXT;
 
-                /*
-                 * Parse up to the end of the conditional section but disable
-                 * SAX event generating DTD building in the meantime
-                 */
-                state = ctxt->disableSAX;
-                instate = ctxt->instate;
-                if (ctxt->recovery == 0) ctxt->disableSAX = 1;
-                ctxt->instate = XML_PARSER_IGNORE;
-
                 while (RAW != 0) {
                     if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
                         SKIP(3);
@@ -6779,9 +6945,6 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
                     }
                 }
 
-                ctxt->disableSAX = state;
-                ctxt->instate = instate;
-
                if (RAW == 0) {
                    xmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);
                     goto error;
@@ -6806,23 +6969,19 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
                                " in the same entity\n");
             }
             SKIP(3);
-        } else {
-            int id = ctxt->input->id;
-            unsigned long cons = CUR_CONSUMED;
-
+        } else if ((RAW == '<') && ((NXT(1) == '!') || (NXT(1) == '?'))) {
             xmlParseMarkupDecl(ctxt);
-
-            if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
-                xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
-                xmlHaltParser(ctxt);
-                goto error;
-            }
+        } else {
+            xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
+            xmlHaltParser(ctxt);
+            goto error;
         }
 
         if (depth == 0)
             break;
 
         SKIP_BLANKS;
+        SHRINK;
         GROW;
     }
 
@@ -6834,7 +6993,9 @@ error:
  * xmlParseMarkupDecl:
  * @ctxt:  an XML parser context
  *
- * parse Markup declarations
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse markup declarations. Always consumes '<!' or '<?'.
  *
  * [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl |
  *                     NotationDecl | PI | Comment
@@ -6863,6 +7024,8 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
                        xmlParseElementDecl(ctxt);
                    else if (NXT(3) == 'N')
                        xmlParseEntityDecl(ctxt);
+                    else
+                        SKIP(2);
                    break;
                case 'A':
                    xmlParseAttributeListDecl(ctxt);
@@ -6875,6 +7038,7 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
                    break;
                default:
                    /* there is an error but it will be detected later */
+                    SKIP(2);
                    break;
            }
        } else if (NXT(1) == '?') {
@@ -6896,6 +7060,8 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
  * xmlParseTextDecl:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML declaration header for external entities
  *
  * [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
@@ -6904,7 +7070,6 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
 void
 xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
     xmlChar *version;
-    const xmlChar *encoding;
     int oldstate;
 
     /*
@@ -6943,7 +7108,9 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
     /*
      * We must have the encoding declaration
      */
-    encoding = xmlParseEncodingDecl(ctxt);
+    xmlParseEncodingDecl(ctxt);
+    if (ctxt->instate == XML_PARSER_EOF)
+        return;
     if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
        /*
         * The XML REC instructs us to stop parsing right here
@@ -6951,10 +7118,6 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
         ctxt->instate = oldstate;
         return;
     }
-    if ((encoding == NULL) && (ctxt->errNo == XML_ERR_OK)) {
-       xmlFatalErrMsg(ctxt, XML_ERR_MISSING_ENCODING,
-                      "Missing encoding in text declaration\n");
-    }
 
     SKIP_BLANKS;
     if ((RAW == '?') && (NXT(1) == '>')) {
@@ -6964,12 +7127,18 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
        xmlFatalErr(ctxt, XML_ERR_XMLDECL_NOT_FINISHED, NULL);
        NEXT;
     } else {
+        int c;
+
        xmlFatalErr(ctxt, XML_ERR_XMLDECL_NOT_FINISHED, NULL);
-       MOVETO_ENDTAG(CUR_PTR);
-       NEXT;
+        while ((c = CUR) != 0) {
+            NEXT;
+            if (c == '>')
+                break;
+        }
     }
 
-    ctxt->instate = oldstate;
+    if (ctxt->instate != XML_PARSER_EOF)
+        ctxt->instate = oldstate;
 }
 
 /**
@@ -6988,21 +7157,8 @@ void
 xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
                        const xmlChar *SystemID) {
     xmlDetectSAX2(ctxt);
-    GROW;
-
-    if ((ctxt->encoding == NULL) &&
-        (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);
-    }
+    xmlDetectEncoding(ctxt);
 
     if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
        xmlParseTextDecl(ctxt);
@@ -7028,23 +7184,19 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
     ctxt->instate = XML_PARSER_DTD;
     ctxt->external = 1;
     SKIP_BLANKS;
-    while (((RAW == '<') && (NXT(1) == '?')) ||
-           ((RAW == '<') && (NXT(1) == '!')) ||
-          (RAW == '%')) {
-       int id = ctxt->input->id;
-       unsigned long cons = CUR_CONSUMED;
-
+    while ((ctxt->instate != XML_PARSER_EOF) && (RAW != 0)) {
        GROW;
         if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
-           xmlParseConditionalSections(ctxt);
-       } else
-           xmlParseMarkupDecl(ctxt);
+            xmlParseConditionalSections(ctxt);
+        } else if ((RAW == '<') && ((NXT(1) == '!') || (NXT(1) == '?'))) {
+            xmlParseMarkupDecl(ctxt);
+        } else {
+            xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
+            xmlHaltParser(ctxt);
+            return;
+        }
         SKIP_BLANKS;
-
-       if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
-           xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
-           break;
-       }
+        SHRINK;
     }
 
     if (RAW != 0) {
@@ -7057,11 +7209,15 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
  * xmlParseReference:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse and handle entity references in content, depending on the SAX
  * interface, this may end-up in a call to character() if this is a
  * CharRef, a predefined entity, if there is no reference() callback.
  * or if the parser was asked to switch to that mode.
  *
+ * Always consumes '&'.
+ *
  * [67] Reference ::= EntityRef | CharRef
  */
 void
@@ -7082,42 +7238,19 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
     if (NXT(1) == '#') {
        int i = 0;
        xmlChar out[16];
-       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
-            * Check that the char fit on 8bits, if not
-            * generate a CharRef.
-            */
-           if (value <= 0xFF) {
-               out[0] = value;
-               out[1] = 0;
-               if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
-                   (!ctxt->disableSAX))
-                   ctxt->sax->characters(ctxt->userData, out, 1);
-           } else {
-               if ((hex == 'x') || (hex == 'X'))
-                   snprintf((char *)out, sizeof(out), "#x%X", value);
-               else
-                   snprintf((char *)out, sizeof(out), "#%d", value);
-               if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
-                   (!ctxt->disableSAX))
-                   ctxt->sax->reference(ctxt->userData, out);
-           }
-       } else {
-           /*
-            * Just encode the value in UTF-8
-            */
-           COPY_BUF(0 ,out, i, value);
-           out[i] = 0;
-           if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
-               (!ctxt->disableSAX))
-               ctxt->sax->characters(ctxt->userData, out, i);
-       }
+
+        /*
+         * Just encode the value in UTF-8
+         */
+        COPY_BUF(out, i, value);
+        out[i] = 0;
+        if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
+            (!ctxt->disableSAX))
+            ctxt->sax->characters(ctxt->userData, out, i);
        return;
     }
 
@@ -7128,7 +7261,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
     if (ent == NULL) return;
     if (!ctxt->wellFormed)
        return;
-    was_checked = ent->checked;
+    was_checked = ent->flags & XML_ENT_PARSED;
 
     /* special case of predefined entities */
     if ((ent->name == NULL) ||
@@ -7153,12 +7286,44 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
      * of validating, or substituting entities were given. Doing so is
      * far more secure as the parser will only process data coming from
      * the document entity by default.
+     *
+     * FIXME: This doesn't work correctly since entities can be
+     * expanded with different namespace declarations in scope.
+     * For example:
+     *
+     * <!DOCTYPE doc [
+     *   <!ENTITY ent "<ns:elem/>">
+     * ]>
+     * <doc>
+     *   <decl1 xmlns:ns="urn:ns1">
+     *     &ent;
+     *   </decl1>
+     *   <decl2 xmlns:ns="urn:ns2">
+     *     &ent;
+     *   </decl2>
+     * </doc>
+     *
+     * Proposed fix:
+     *
+     * - Remove the ent->owner optimization which tries to avoid the
+     *   initial copy of the entity. Always make entities own the
+     *   subtree.
+     * - Ignore current namespace declarations when parsing the
+     *   entity. If a prefix can't be resolved, don't report an error
+     *   but mark it as unresolved.
+     * - Try to resolve these prefixes when expanding the entity.
+     *   This will require a specialized version of xmlStaticCopyNode
+     *   which can also make use of the namespace hash table to avoid
+     *   quadratic behavior.
+     *
+     * Alternatively, we could simply reparse the entity on each
+     * expansion like we already do with custom SAX callbacks.
+     * External entity content should be cached in this case.
      */
-    if (((ent->checked == 0) ||
-         ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
+    if (((ent->flags & XML_ENT_PARSED) == 0) &&
         ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
          (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
-       unsigned long oldnbent = ctxt->nbentities, diff;
+       unsigned long oldsizeentcopy = ctxt->sizeentcopy;
 
        /*
         * This is a bit hackish but this seems the best
@@ -7171,6 +7336,17 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
        else
            user_data = ctxt->userData;
 
+        /* Avoid overflow as much as possible */
+        ctxt->sizeentcopy = 0;
+
+        if (ent->flags & XML_ENT_EXPANDING) {
+            xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+            xmlHaltParser(ctxt);
+            return;
+        }
+
+        ent->flags |= XML_ENT_EXPANDING;
+
        /*
         * Check that this entity is well formed
         * 4.3.2: An internal general parsed entity is well-formed
@@ -7195,87 +7371,67 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                         "invalid entity type found\n", NULL);
        }
 
-       /*
-        * Store the number of entities needing parsing for this entity
-        * content and do checkings
-        */
-        diff = ctxt->nbentities - oldnbent + 1;
-        if (diff > INT_MAX / 2)
-            diff = INT_MAX / 2;
-        ent->checked = diff * 2;
-       if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
-           ent->checked |= 1;
+        ent->flags &= ~XML_ENT_EXPANDING;
+        ent->flags |= XML_ENT_PARSED | XML_ENT_CHECKED;
+        ent->expandedSize = ctxt->sizeentcopy;
        if (ret == XML_ERR_ENTITY_LOOP) {
-           xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
             xmlHaltParser(ctxt);
            xmlFreeNodeList(list);
            return;
        }
-       if (xmlParserEntityCheck(ctxt, 0, ent, 0)) {
+       if (xmlParserEntityCheck(ctxt, oldsizeentcopy)) {
            xmlFreeNodeList(list);
            return;
        }
 
        if ((ret == XML_ERR_OK) && (list != NULL)) {
-           if (((ent->etype == XML_INTERNAL_GENERAL_ENTITY) ||
-            (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY))&&
-               (ent->children == NULL)) {
-               ent->children = list;
-                /*
-                 * Prune it directly in the generated document
-                 * except for single text nodes.
-                 */
-                if ((ctxt->replaceEntities == 0) ||
-                    (ctxt->parseMode == XML_PARSE_READER) ||
-                    ((list->type == XML_TEXT_NODE) &&
-                     (list->next == NULL))) {
-                    ent->owner = 1;
-                    while (list != NULL) {
-                        list->parent = (xmlNodePtr) ent;
-                        if (list->doc != ent->doc)
-                            xmlSetTreeDoc(list, ent->doc);
-                        if (list->next == NULL)
-                            ent->last = list;
-                        list = list->next;
-                    }
-                    list = NULL;
-                } else {
-                    ent->owner = 0;
-                    while (list != NULL) {
-                        list->parent = (xmlNodePtr) ctxt->node;
-                        list->doc = ctxt->myDoc;
-                        if (list->next == NULL)
-                            ent->last = list;
-                        list = list->next;
-                    }
-                    list = ent->children;
+            ent->children = list;
+            /*
+             * Prune it directly in the generated document
+             * except for single text nodes.
+             */
+            if ((ctxt->replaceEntities == 0) ||
+                (ctxt->parseMode == XML_PARSE_READER) ||
+                ((list->type == XML_TEXT_NODE) &&
+                 (list->next == NULL))) {
+                ent->owner = 1;
+                while (list != NULL) {
+                    list->parent = (xmlNodePtr) ent;
+                    if (list->doc != ent->doc)
+                        xmlSetTreeDoc(list, ent->doc);
+                    if (list->next == NULL)
+                        ent->last = list;
+                    list = list->next;
+                }
+                list = NULL;
+            } else {
+                ent->owner = 0;
+                while (list != NULL) {
+                    list->parent = (xmlNodePtr) ctxt->node;
+                    list->doc = ctxt->myDoc;
+                    if (list->next == NULL)
+                        ent->last = list;
+                    list = list->next;
+                }
+                list = ent->children;
 #ifdef LIBXML_LEGACY_ENABLED
-                    if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
-                        xmlAddEntityReference(ent, list, NULL);
+                if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
+                    xmlAddEntityReference(ent, list, NULL);
 #endif /* LIBXML_LEGACY_ENABLED */
-                }
-           } else {
-               xmlFreeNodeList(list);
-               list = NULL;
-           }
+            }
        } else if ((ret != XML_ERR_OK) &&
                   (ret != XML_WAR_UNDECLARED_ENTITY)) {
            xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
                     "Entity '%s' failed to parse\n", ent->name);
             if (ent->content != NULL)
                 ent->content[0] = 0;
-           xmlParserEntityCheck(ctxt, 0, ent, 0);
        } else if (list != NULL) {
            xmlFreeNodeList(list);
            list = NULL;
        }
-       if (ent->checked == 0)
-           ent->checked = 2;
 
         /* Prevent entity from being parsed and expanded twice (Bug 760367). */
         was_checked = 0;
-    } else if (ent->checked != 1) {
-       ctxt->nbentities += ent->checked / 2;
     }
 
     /*
@@ -7309,11 +7465,16 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                ctxt->depth--;
            } else if (ent->etype ==
                       XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
+               unsigned long oldsizeentities = ctxt->sizeentities;
+
                ctxt->depth++;
                ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt,
                           ctxt->sax, user_data, ctxt->depth,
                           ent->URI, ent->ExternalID, NULL);
                ctxt->depth--;
+
+                /* Undo the change to sizeentities */
+                ctxt->sizeentities = oldsizeentities;
            } else {
                ret = XML_ERR_ENTITY_PE_INTERNAL;
                xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
@@ -7323,6 +7484,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
                return;
            }
+            if (xmlParserEntityCheck(ctxt, 0))
+                return;
        }
        if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
            (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
@@ -7336,6 +7499,14 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
     }
 
     /*
+     * We also check for amplification if entities aren't substituted.
+     * They might be expanded later.
+     */
+    if ((was_checked != 0) &&
+        (xmlParserEntityCheck(ctxt, ent->expandedSize)))
+        return;
+
+    /*
      * If we didn't get any children for the entity being built
      */
     if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
@@ -7347,7 +7518,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
        return;
     }
 
-    if ((ctxt->replaceEntities) || (ent->children == NULL))  {
+    if (ctxt->replaceEntities)  {
        /*
         * There is a problem on the handling of _private for entities
         * (bug 155816): Should we copy the content of the field from
@@ -7361,7 +7532,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
         * hack - maybe we should have further tests to determine
         * what to do.
         */
-       if ((ctxt->node != NULL) && (ent->children != NULL)) {
+       if (ctxt->node != NULL) {
            /*
             * Seems we are generating the DOM content, do
             * a simple tree copy for all references except the first
@@ -7372,13 +7543,6 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                xmlNodePtr nw = NULL, cur, firstChild = NULL;
 
                /*
-                * We are copying here, make sure there is no abuse
-                */
-               ctxt->sizeentcopy += ent->length + 5;
-               if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
-                   return;
-
-               /*
                 * when operating on a reader, the entities definitions
                 * are always owning the entities subtree.
                if (ctxt->parseMode == XML_PARSE_READER)
@@ -7420,13 +7584,6 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                           firstChild = NULL;
 
                /*
-                * We are copying here, make sure there is no abuse
-                */
-               ctxt->sizeentcopy += ent->length + 5;
-               if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
-                   return;
-
-               /*
                 * Copy the entity child list and make it the new
                 * entity child list. The goal is to make sure any
                 * ID or REF referenced will be the one from the
@@ -7448,8 +7605,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                            firstChild = cur;
                        }
                        xmlAddChild((xmlNodePtr) ent, nw);
-                       xmlAddChild(ctxt->node, cur);
                    }
+                   xmlAddChild(ctxt->node, cur);
                    if (cur == last)
                        break;
                    cur = next;
@@ -7493,7 +7650,9 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
  * xmlParseEntityRef:
  * @ctxt:  an XML parser context
  *
- * parse ENTITY references declarations
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse an entitiy reference. Always consumes '&'.
  *
  * [68] EntityRef ::= '&' Name ';'
  *
@@ -7551,11 +7710,6 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
     }
 
     /*
-     * Increase the number of entity references parsed
-     */
-    ctxt->nbentities++;
-
-    /*
      * Ask first SAX for entity resolution, otherwise try the
      * entities which may have stored in the parser context.
      */
@@ -7604,11 +7758,11 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
                     "Entity '%s' not defined\n", name);
            if ((ctxt->inSubset == 0) &&
                (ctxt->sax != NULL) &&
+                (ctxt->disableSAX == 0) &&
                (ctxt->sax->reference != NULL)) {
                ctxt->sax->reference(ctxt->userData, name);
            }
        }
-       xmlParserEntityCheck(ctxt, 0, ent, 0);
        ctxt->valid = 0;
     }
 
@@ -7639,13 +7793,16 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
      * not contain a <.
      */
     else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
-            (ent != NULL) && 
             (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
-       if (((ent->checked & 1) || (ent->checked == 0)) &&
-            (ent->content != NULL) && (xmlStrchr(ent->content, '<'))) {
-           xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
-       "'<' in entity '%s' is not allowed in attributes values\n", name);
+       if ((ent->flags & XML_ENT_CHECKED_LT) == 0) {
+            if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
+                ent->flags |= XML_ENT_CONTAINS_LT;
+            ent->flags |= XML_ENT_CHECKED_LT;
         }
+        if (ent->flags & XML_ENT_CONTAINS_LT)
+            xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
+                    "'<' in entity '%s' is not allowed in attributes "
+                    "values\n", name);
     }
 
     /*
@@ -7748,13 +7905,8 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
     }
 
     /*
-     * Increase the number of entity references parsed
-     */
-    ctxt->nbentities++;
-
-    /*
-     * Ask first SAX for entity resolution, otherwise try the
-     * entities which may have stored in the parser context.
+     * Ask first SAX for entity resolution, otherwise try the
+     * entities which may have stored in the parser context.
      */
     if (ctxt->sax != NULL) {
        if (ctxt->sax->getEntity != NULL)
@@ -7802,7 +7954,6 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
                          "Entity '%s' not defined\n",
                          name);
        }
-       xmlParserEntityCheck(ctxt, 0, ent, 0);
        /* TODO ? check regressions ctxt->valid = 0; */
     }
 
@@ -7833,12 +7984,16 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
      * not contain a <.
      */
     else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
-            (ent != NULL) && (ent->content != NULL) &&
-            (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
-            (xmlStrchr(ent->content, '<'))) {
-       xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
-     "'<' in entity '%s' is not allowed in attributes values\n",
-                         name);
+            (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
+       if ((ent->flags & XML_ENT_CHECKED_LT) == 0) {
+            if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
+                ent->flags |= XML_ENT_CONTAINS_LT;
+            ent->flags |= XML_ENT_CHECKED_LT;
+        }
+        if (ent->flags & XML_ENT_CONTAINS_LT)
+            xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
+                    "'<' in entity '%s' is not allowed in attributes "
+                    "values\n", name);
     }
 
     /*
@@ -7873,7 +8028,10 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
  * xmlParsePEReference:
  * @ctxt:  an XML parser context
  *
- * parse PEReference declarations
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse a parameter entity reference. Always consumes '%'.
+ *
  * The entity content is handled directly by pushing it's content as
  * a new input stream.
  *
@@ -7924,11 +8082,6 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
     NEXT;
 
     /*
-     * Increase the number of entity references parsed
-     */
-    ctxt->nbentities++;
-
-    /*
      * Request the entity from SAX
      */
     if ((ctxt->sax != NULL) &&
@@ -7969,7 +8122,6 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
                               name, NULL);
             ctxt->valid = 0;
        }
-       xmlParserEntityCheck(ctxt, 0, NULL, 0);
     } else {
        /*
         * Internal checking in case the entity quest barfed
@@ -7980,11 +8132,8 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
                  "Internal: %%%s; is not a parameter entity\n",
                          name, NULL);
        } else {
-            xmlChar start[4];
-            xmlCharEncoding enc;
-
-           if (xmlParserEntityCheck(ctxt, 0, entity, 0))
-               return;
+            unsigned long parentConsumed;
+            xmlEntityPtr oldEnt;
 
            if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
                ((ctxt->options & XML_PARSE_NOENT) == 0) &&
@@ -7995,35 +8144,35 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
                (ctxt->validate == 0))
                return;
 
+            if (entity->flags & XML_ENT_EXPANDING) {
+                xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+                xmlHaltParser(ctxt);
+                return;
+            }
+
+            /* Must be computed from old input before pushing new input. */
+            parentConsumed = ctxt->input->parentConsumed;
+            oldEnt = ctxt->input->entity;
+            if ((oldEnt == NULL) ||
+                ((oldEnt->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+                 ((oldEnt->flags & XML_ENT_PARSED) == 0))) {
+                xmlSaturatedAdd(&parentConsumed, ctxt->input->consumed);
+                xmlSaturatedAddSizeT(&parentConsumed,
+                                     ctxt->input->cur - ctxt->input->base);
+            }
+
            input = xmlNewEntityInputStream(ctxt, entity);
            if (xmlPushInput(ctxt, input) < 0) {
                 xmlFreeInputStream(input);
                return;
             }
 
+            entity->flags |= XML_ENT_EXPANDING;
+
+            input->parentConsumed = parentConsumed;
+
            if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {
-                /*
-                 * Get the 4 first bytes and decode the charset
-                 * if enc != XML_CHAR_ENCODING_NONE
-                 * plug some encoding conversion routines.
-                 * Note that, since we may have some non-UTF8
-                 * encoding (like UTF16, bug 135229), the 'length'
-                 * is not known, but we can calculate based upon
-                 * the amount of data in the buffer.
-                 */
-                GROW
-                if (ctxt->instate == XML_PARSER_EOF)
-                    return;
-                if ((ctxt->input->end - ctxt->input->cur)>=4) {
-                    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);
-                    }
-                }
+                xmlDetectEncoding(ctxt);
 
                 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
                     (IS_BLANK_CH(NXT(5)))) {
@@ -8048,10 +8197,14 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
  */
 static int
 xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
-    xmlParserInputPtr input;
-    xmlBufferPtr buf;
-    int l, c;
-    int count = 0;
+    xmlParserInputPtr oldinput, input = NULL;
+    xmlParserInputPtr *oldinputTab;
+    const xmlChar *oldencoding;
+    xmlChar *content = NULL;
+    size_t length, i;
+    int oldinputNr, oldinputMax, oldprogressive;
+    int ret = -1;
+    int res;
 
     if ((ctxt == NULL) || (entity == NULL) ||
         ((entity->etype != XML_EXTERNAL_PARAMETER_ENTITY) &&
@@ -8066,72 +8219,114 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
        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);
-    }
-    xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
-
-    input = xmlNewEntityInputStream(ctxt, entity);
+    input = xmlLoadExternalEntity((char *) entity->URI,
+           (char *) entity->ExternalID, ctxt);
     if (input == NULL) {
        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
                    "xmlLoadEntityContent input error");
-       xmlBufferFree(buf);
         return(-1);
     }
 
+    oldinput = ctxt->input;
+    oldinputNr = ctxt->inputNr;
+    oldinputMax = ctxt->inputMax;
+    oldinputTab = ctxt->inputTab;
+    oldencoding = ctxt->encoding;
+    oldprogressive = ctxt->progressive;
+
+    ctxt->input = NULL;
+    ctxt->inputNr = 0;
+    ctxt->inputMax = 1;
+    ctxt->encoding = NULL;
+    ctxt->progressive = 0;
+    ctxt->inputTab = xmlMalloc(sizeof(xmlParserInputPtr));
+    if (ctxt->inputTab == NULL) {
+        xmlErrMemory(ctxt, NULL);
+        xmlFreeInputStream(input);
+        goto error;
+    }
+
+    xmlBufResetInput(input->buf->buffer, input);
+
+    inputPush(ctxt, input);
+
+    xmlDetectEncoding(ctxt);
+
     /*
-     * Push the entity as the current input, read char by char
-     * saving to the buffer until the end of the entity or an error
+     * Parse a possible text declaration first
      */
-    if (xmlPushInput(ctxt, input) < 0) {
-        xmlBufferFree(buf);
-       xmlFreeInputStream(input);
-       return(-1);
+    if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
+       xmlParseTextDecl(ctxt);
+        /*
+         * An XML-1.0 document can't reference an entity not XML-1.0
+         */
+        if ((xmlStrEqual(ctxt->version, BAD_CAST "1.0")) &&
+            (!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
+            xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
+                           "Version mismatch between document and entity\n");
+        }
     }
 
-    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++ > XML_PARSER_CHUNK_SIZE) {
-           count = 0;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF) {
-                xmlBufferFree(buf);
-                return(-1);
-            }
-       }
-       NEXTL(l);
-       c = CUR_CHAR(l);
-       if (c == 0) {
-           count = 0;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF) {
-                xmlBufferFree(buf);
-                return(-1);
-            }
-           c = CUR_CHAR(l);
-       }
+    if (ctxt->instate == XML_PARSER_EOF)
+        goto error;
+
+    length = input->cur - input->base;
+    xmlBufShrink(input->buf->buffer, length);
+    xmlSaturatedAdd(&ctxt->sizeentities, length);
+
+    while ((res = xmlParserInputBufferGrow(input->buf, 4096)) > 0)
+        ;
+
+    xmlBufResetInput(input->buf->buffer, input);
+
+    if (res < 0) {
+        xmlFatalErr(ctxt, input->buf->error, NULL);
+        goto error;
     }
 
-    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);
+    length = xmlBufUse(input->buf->buffer);
+    content = xmlBufDetach(input->buf->buffer);
+
+    if (length > INT_MAX) {
+        xmlErrMemory(ctxt, NULL);
+        goto error;
     }
-    entity->content = buf->content;
-    buf->content = NULL;
-    xmlBufferFree(buf);
 
-    return(0);
+    for (i = 0; i < length; ) {
+        int clen = length - i;
+        int c = xmlGetUTF8Char(content + i, &clen);
+
+        if ((c < 0) || (!IS_CHAR(c))) {
+            xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+                              "xmlLoadEntityContent: invalid char value %d\n",
+                              content[i]);
+            goto error;
+        }
+        i += clen;
+    }
+
+    xmlSaturatedAdd(&ctxt->sizeentities, length);
+    entity->content = content;
+    entity->length = length;
+    content = NULL;
+    ret = 0;
+
+error:
+    while (ctxt->inputNr > 0)
+        xmlFreeInputStream(inputPop(ctxt));
+    xmlFree(ctxt->inputTab);
+    xmlFree((xmlChar *) ctxt->encoding);
+
+    ctxt->input = oldinput;
+    ctxt->inputNr = oldinputNr;
+    ctxt->inputMax = oldinputMax;
+    ctxt->inputTab = oldinputTab;
+    ctxt->encoding = oldencoding;
+    ctxt->progressive = oldprogressive;
+
+    xmlFree(content);
+
+    return(ret);
 }
 
 /**
@@ -8195,11 +8390,6 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
     ptr++;
 
     /*
-     * Increase the number of entity references parsed
-     */
-    ctxt->nbentities++;
-
-    /*
      * Request the entity from SAX
      */
     if ((ctxt->sax != NULL) &&
@@ -8236,7 +8426,6 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
                          name, NULL);
            ctxt->valid = 0;
        }
-       xmlParserEntityCheck(ctxt, 0, NULL, 0);
     } else {
        /*
         * Internal checking in case the entity quest barfed
@@ -8258,6 +8447,8 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
  * xmlParseDocTypeDecl:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse a DOCTYPE declaration
  *
  * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
@@ -8354,14 +8545,9 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
         * PEReferences.
         * Subsequence (markupdecl | PEReference | S)*
         */
+       SKIP_BLANKS;
        while (((RAW != ']') || (ctxt->inputNr > baseInputNr)) &&
                (ctxt->instate != XML_PARSER_EOF)) {
-           int id = ctxt->input->id;
-           unsigned long cons = CUR_CONSUMED;
-
-           SKIP_BLANKS;
-           xmlParseMarkupDecl(ctxt);
-           xmlParsePEReference(ctxt);
 
             /*
              * Conditional sections are allowed from external entities included
@@ -8370,16 +8556,20 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
             if ((ctxt->inputNr > 1) && (ctxt->input->filename != NULL) &&
                 (RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
                 xmlParseConditionalSections(ctxt);
-            }
-
-           if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
+            } else if ((RAW == '<') && ((NXT(1) == '!') || (NXT(1) == '?'))) {
+               xmlParseMarkupDecl(ctxt);
+            } else if (RAW == '%') {
+               xmlParsePEReference(ctxt);
+            } else {
                xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-            "xmlParseInternalSubset: error detected in Markup declaration\n");
-                if (ctxt->inputNr > baseInputNr)
-                    xmlPopInput(ctxt);
-                else
-                   break;
-           }
+                        "xmlParseInternalSubset: error detected in"
+                        " Markup declaration\n");
+                xmlHaltParser(ctxt);
+                return;
+            }
+           SKIP_BLANKS;
+            SHRINK;
+            GROW;
        }
        if (RAW == ']') {
            NEXT;
@@ -8403,6 +8593,8 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
  * @ctxt:  an XML parser context
  * @value:  a xmlChar ** used to store the value of the attribute
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an attribute
  *
  * [41] Attribute ::= Name Eq AttValue
@@ -8457,7 +8649,7 @@ xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlChar **value) {
     } else {
        xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
               "Specification mandates value for attribute %s\n", name);
-       return(NULL);
+       return(name);
     }
 
     /*
@@ -8496,8 +8688,9 @@ xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlChar **value) {
  * xmlParseStartTag:
  * @ctxt:  an XML parser context
  *
- * parse a start of tag either for rule element or
- * EmptyElement. In both case we don't parse the tag closing chars.
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse a start tag. Always consumes '<'.
  *
  * [40] STag ::= '<' Name (S Attribute)* S? '>'
  *
@@ -8551,11 +8744,13 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
     while (((RAW != '>') &&
           ((RAW != '/') || (NXT(1) != '>')) &&
           (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
-        int id = ctxt->input->id;
-       unsigned long cons = CUR_CONSUMED;
-
        attname = xmlParseAttribute(ctxt, &attvalue);
-        if ((attname != NULL) && (attvalue != NULL)) {
+        if (attname == NULL) {
+           xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
+                          "xmlParseStartTag: problem parsing attributes\n");
+           break;
+       }
+        if (attvalue != NULL) {
            /*
             * [ WFC: Unique Att Spec ]
             * No attribute name may appear more than once in the same
@@ -8617,12 +8812,6 @@ failed:
            xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
                           "attributes construct error\n");
        }
-        if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
-            (attname == NULL) && (attvalue == NULL)) {
-           xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
-                          "xmlParseStartTag: problem parsing attributes\n");
-           break;
-       }
        SHRINK;
         GROW;
     }
@@ -8653,7 +8842,7 @@ failed:
  * @line:  line of the start tag
  * @nsNr:  number of namespaces on the start tag
  *
- * parse an end of tag
+ * Parse an end tag. Always consumes '</'.
  *
  * [42] ETag ::= '</' Name S? '>'
  *
@@ -8715,6 +8904,8 @@ xmlParseEndTag1(xmlParserCtxtPtr ctxt, int line) {
  * xmlParseEndTag:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an end of tag
  *
  * [42] ETag ::= '</' Name S? '>'
@@ -8736,28 +8927,64 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
  *                                                                     *
  ************************************************************************/
 
-/*
- * xmlGetNamespace:
+/**
+ * xmlParseQNameHashed:
  * @ctxt:  an XML parser context
- * @prefix:  the prefix to lookup
+ * @prefix:  pointer to store the prefix part
+ *
+ * parse an XML Namespace QName
  *
- * Lookup the namespace name for the @prefix (which ca be NULL)
- * The prefix must come from the @ctxt->dict dictionary
+ * [6]  QName  ::= (Prefix ':')? LocalPart
+ * [7]  Prefix  ::= NCName
+ * [8]  LocalPart  ::= NCName
  *
- * Returns the namespace name or NULL if not bound
+ * Returns the Name parsed or NULL
  */
-static const xmlChar *
-xmlGetNamespace(xmlParserCtxtPtr ctxt, const xmlChar *prefix) {
-    int i;
 
-    if (prefix == ctxt->str_xml) return(ctxt->str_xml_ns);
-    for (i = ctxt->nsNr - 2;i >= 0;i-=2)
-        if (ctxt->nsTab[i] == prefix) {
-           if ((prefix == NULL) && (*ctxt->nsTab[i + 1] == 0))
-               return(NULL);
-           return(ctxt->nsTab[i + 1]);
-       }
-    return(NULL);
+static xmlHashedString
+xmlParseQNameHashed(xmlParserCtxtPtr ctxt, xmlHashedString *prefix) {
+    xmlHashedString l, p;
+    int start, isNCName = 0;
+
+    l.name = NULL;
+    p.name = NULL;
+
+    GROW;
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(l);
+    start = CUR_PTR - BASE_PTR;
+
+    l = xmlParseNCName(ctxt);
+    if (l.name != NULL) {
+        isNCName = 1;
+        if (CUR == ':') {
+            NEXT;
+            p = l;
+            l = xmlParseNCName(ctxt);
+        }
+    }
+    if ((l.name == NULL) || (CUR == ':')) {
+        xmlChar *tmp;
+
+        l.name = NULL;
+        p.name = NULL;
+        if (ctxt->instate == XML_PARSER_EOF)
+            return(l);
+        if ((isNCName == 0) && (CUR != ':'))
+            return(l);
+        tmp = xmlParseNmtoken(ctxt);
+        if (tmp != NULL)
+            xmlFree(tmp);
+        if (ctxt->instate == XML_PARSER_EOF)
+            return(l);
+        l = xmlDictLookupHashed(ctxt->dict, BASE_PTR + start,
+                                CUR_PTR - (BASE_PTR + start));
+        xmlNsErr(ctxt, XML_NS_ERR_QNAME,
+                 "Failed to parse QName '%s'\n", l.name, NULL, NULL);
+    }
+
+    *prefix = p;
+    return(l);
 }
 
 /**
@@ -8776,74 +9003,13 @@ xmlGetNamespace(xmlParserCtxtPtr ctxt, const xmlChar *prefix) {
 
 static const xmlChar *
 xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix) {
-    const xmlChar *l, *p;
-
-    GROW;
+    xmlHashedString n, p;
 
-    l = xmlParseNCName(ctxt);
-    if (l == NULL) {
-        if (CUR == ':') {
-           l = xmlParseName(ctxt);
-           if (l != NULL) {
-               xmlNsErr(ctxt, XML_NS_ERR_QNAME,
-                        "Failed to parse QName '%s'\n", l, NULL, NULL);
-               *prefix = NULL;
-               return(l);
-           }
-       }
+    n = xmlParseQNameHashed(ctxt, &p);
+    if (n.name == NULL)
         return(NULL);
-    }
-    if (CUR == ':') {
-        NEXT;
-       p = l;
-       l = xmlParseNCName(ctxt);
-       if (l == NULL) {
-           xmlChar *tmp;
-
-            if (ctxt->instate == XML_PARSER_EOF)
-                return(NULL);
-            xmlNsErr(ctxt, XML_NS_ERR_QNAME,
-                    "Failed to parse QName '%s:'\n", p, NULL, NULL);
-           l = xmlParseNmtoken(ctxt);
-           if (l == NULL) {
-                if (ctxt->instate == XML_PARSER_EOF)
-                    return(NULL);
-               tmp = xmlBuildQName(BAD_CAST "", p, NULL, 0);
-            } else {
-               tmp = xmlBuildQName(l, p, NULL, 0);
-               xmlFree((char *)l);
-           }
-           p = xmlDictLookup(ctxt->dict, tmp, -1);
-           if (tmp != NULL) xmlFree(tmp);
-           *prefix = NULL;
-           return(p);
-       }
-       if (CUR == ':') {
-           xmlChar *tmp;
-
-            xmlNsErr(ctxt, XML_NS_ERR_QNAME,
-                    "Failed to parse QName '%s:%s:'\n", p, l, NULL);
-           NEXT;
-           tmp = (xmlChar *) xmlParseName(ctxt);
-           if (tmp != NULL) {
-               tmp = xmlBuildQName(tmp, l, NULL, 0);
-               l = xmlDictLookup(ctxt->dict, tmp, -1);
-               if (tmp != NULL) xmlFree(tmp);
-               *prefix = p;
-               return(l);
-           }
-            if (ctxt->instate == XML_PARSER_EOF)
-                return(NULL);
-           tmp = xmlBuildQName(BAD_CAST "", l, NULL, 0);
-           l = xmlDictLookup(ctxt->dict, tmp, -1);
-           if (tmp != NULL) xmlFree(tmp);
-           *prefix = p;
-           return(l);
-       }
-       *prefix = p;
-    } else
-        *prefix = NULL;
-    return(l);
+    *prefix = p.name;
+    return(n.name);
 }
 
 /**
@@ -8895,6 +9061,8 @@ xmlParseQNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *name,
      * all strings coms from the dictionary, equality can be done directly
      */
     ret = xmlParseQName (ctxt, &prefix2);
+    if (ret == NULL)
+        return(NULL);
     if ((ret == name) && (prefix == prefix2))
        return((const xmlChar*) 1);
     return ret;
@@ -8954,6 +9122,9 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
     const xmlChar *in = NULL, *start, *end, *last;
     xmlChar *ret = NULL;
     int line, col;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
 
     GROW;
     in = (xmlChar *) CUR_PTR;
@@ -8993,8 +9164,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
            start = in;
            if (in >= end) {
                 GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
-                if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-                    ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+                if ((in - start) > maxLength) {
                     xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                                    "AttValue length too long\n");
                     return(NULL);
@@ -9007,8 +9177,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
            if ((*in++ == 0x20) && (*in == 0x20)) break;
            if (in >= end) {
                 GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
-                if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-                    ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+                if ((in - start) > maxLength) {
                     xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                                    "AttValue length too long\n");
                     return(NULL);
@@ -9041,16 +9210,14 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
                    last = last + delta;
                }
                end = ctxt->input->end;
-                if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-                    ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+                if ((in - start) > maxLength) {
                     xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                                    "AttValue length too long\n");
                     return(NULL);
                 }
            }
        }
-        if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-            ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+        if ((in - start) > maxLength) {
             xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                            "AttValue length too long\n");
             return(NULL);
@@ -9063,8 +9230,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
            col++;
            if (in >= end) {
                 GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
-                if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-                    ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+                if ((in - start) > maxLength) {
                     xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                                    "AttValue length too long\n");
                     return(NULL);
@@ -9072,8 +9238,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
            }
        }
        last = in;
-        if (((in - start) > XML_MAX_TEXT_LENGTH) &&
-            ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+        if ((in - start) > maxLength) {
             xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
                            "AttValue length too long\n");
             return(NULL);
@@ -9083,6 +9248,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
     in++;
     col++;
     if (len != NULL) {
+        if (alloc) *alloc = 0;
         *len = last - start;
         ret = (xmlChar *) start;
     } else {
@@ -9092,7 +9258,6 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
     CUR_PTR = in;
     ctxt->input->line = line;
     ctxt->input->col = col;
-    if (alloc) *alloc = 0;
     return ret;
 need_complex:
     if (alloc) *alloc = 1;
@@ -9114,24 +9279,30 @@ need_complex:
  * Returns the attribute name, and the value in *value, .
  */
 
-static const xmlChar *
+static xmlHashedString
 xmlParseAttribute2(xmlParserCtxtPtr ctxt,
                    const xmlChar * pref, const xmlChar * elem,
-                   const xmlChar ** prefix, xmlChar ** value,
+                   xmlHashedString * hprefix, xmlChar ** value,
                    int *len, int *alloc)
 {
-    const xmlChar *name;
+    xmlHashedString hname;
+    const xmlChar *prefix, *name;
     xmlChar *val, *internal_val = NULL;
     int normalize = 0;
 
     *value = NULL;
     GROW;
-    name = xmlParseQName(ctxt, prefix);
-    if (name == NULL) {
+    hname = xmlParseQNameHashed(ctxt, hprefix);
+    if (hname.name == NULL) {
         xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
                        "error parsing attribute name\n");
-        return (NULL);
+        return(hname);
     }
+    name = hname.name;
+    if (hprefix->name != NULL)
+        prefix = hprefix->name;
+    else
+        prefix = NULL;
 
     /*
      * get the type if needed
@@ -9140,7 +9311,8 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
         int type;
 
         type = (int) (ptrdiff_t) xmlHashQLookup2(ctxt->attsSpecial,
-                                                 pref, elem, *prefix, name);
+                                                 pref, elem,
+                                                 prefix, name);
         if (type != 0)
             normalize = 1;
     }
@@ -9153,6 +9325,10 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
         NEXT;
         SKIP_BLANKS;
         val = xmlParseAttValueInternal(ctxt, len, alloc, normalize);
+        if (val == NULL) {
+            hname.name = NULL;
+            return(hname);
+        }
        if (normalize) {
            /*
             * Sometimes a second normalisation pass for spaces is needed
@@ -9175,10 +9351,10 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
         xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
                           "Specification mandates value for attribute %s\n",
                           name);
-        return (NULL);
+        return(hname);
     }
 
-    if (*prefix == ctxt->str_xml) {
+    if (prefix == ctxt->str_xml) {
         /*
          * Check that xml:lang conforms to the specification
          * No more registered as an error, just generate a warning now
@@ -9214,14 +9390,64 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
     }
 
     *value = val;
-    return (name);
+    return (hname);
+}
+
+/**
+ * xmlAttrHashInsert:
+ * @ctxt: parser context
+ * @size: size of the hash table
+ * @name: attribute name
+ * @uri: namespace uri
+ * @hashValue: combined hash value of name and uri
+ * @aindex: attribute index (this is a multiple of 5)
+ *
+ * Inserts a new attribute into the hash table.
+ *
+ * Returns INT_MAX if no existing attribute was found, the attribute
+ * index if an attribute was found, -1 if a memory allocation failed.
+ */
+static int
+xmlAttrHashInsert(xmlParserCtxtPtr ctxt, unsigned size, const xmlChar *name,
+                  const xmlChar *uri, unsigned hashValue, int aindex) {
+    xmlAttrHashBucket *table = ctxt->attrHash;
+    xmlAttrHashBucket *bucket;
+    unsigned hindex;
+
+    hindex = hashValue & (size - 1);
+    bucket = &table[hindex];
+
+    while (bucket->index >= 0) {
+        const xmlChar **atts = &ctxt->atts[bucket->index];
+
+        if (name == atts[0]) {
+            int nsIndex = (int) (ptrdiff_t) atts[2];
+
+            if ((nsIndex == NS_INDEX_EMPTY) ? (uri == NULL) :
+                (nsIndex == NS_INDEX_XML) ? (uri == ctxt->str_xml) :
+                (uri == ctxt->nsTab[nsIndex * 2 + 1]))
+                return(bucket->index);
+        }
+
+        hindex++;
+        bucket++;
+        if (hindex >= size) {
+            hindex = 0;
+            bucket = table;
+        }
+    }
+
+    bucket->index = aindex;
+
+    return(INT_MAX);
 }
+
 /**
  * xmlParseStartTag2:
  * @ctxt:  an XML parser context
  *
- * parse a start of tag either for rule element or
- * EmptyElement. In both case we don't parse the tag closing chars.
+ * Parse a start tag. Always consumes '<'.
+ *
  * This routine is called when running SAX2 parsing
  *
  * [40] STag ::= '<' Name (S Attribute)* S? '>'
@@ -9247,48 +9473,48 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
 
 static const xmlChar *
 xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
-                  const xmlChar **URI, int *tlen) {
+                  const xmlChar **URI, int *nbNsPtr) {
+    xmlHashedString hlocalname;
+    xmlHashedString hprefix;
+    xmlHashedString hattname;
+    xmlHashedString haprefix;
     const xmlChar *localname;
     const xmlChar *prefix;
     const xmlChar *attname;
     const xmlChar *aprefix;
-    const xmlChar *nsname;
-    xmlChar *attvalue;
+    const xmlChar *uri;
+    xmlChar *attvalue = NULL;
     const xmlChar **atts = ctxt->atts;
+    unsigned attrHashSize = 0;
     int maxatts = ctxt->maxatts;
     int nratts, nbatts, nbdef, inputid;
-    int i, j, nbNs, attval;
-    unsigned long cur;
-    int nsNr = ctxt->nsNr;
+    int i, j, nbNs, nbTotalDef, attval, nsIndex, maxAtts;
+    int alloc = 0;
 
     if (RAW != '<') return(NULL);
     NEXT1;
 
-    /*
-     * NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that
-     *       point since the attribute values may be stored as pointers to
-     *       the buffer and calling SHRINK would destroy them !
-     *       The Shrinking is only possible once the full set of attribute
-     *       callbacks have been done.
-     */
-    SHRINK;
-    cur = ctxt->input->cur - ctxt->input->base;
     inputid = ctxt->input->id;
     nbatts = 0;
     nratts = 0;
     nbdef = 0;
     nbNs = 0;
+    nbTotalDef = 0;
     attval = 0;
-    /* Forget any namespaces added during an earlier parse of this element. */
-    ctxt->nsNr = nsNr;
 
-    localname = xmlParseQName(ctxt, &prefix);
-    if (localname == NULL) {
+    if (xmlParserNsStartElement(ctxt->nsdb) < 0) {
+        xmlErrMemory(ctxt, NULL);
+        return(NULL);
+    }
+
+    hlocalname = xmlParseQNameHashed(ctxt, &hprefix);
+    if (hlocalname.name == NULL) {
        xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
                       "StartTag: invalid element name\n");
         return(NULL);
     }
-    *tlen = ctxt->input->cur - ctxt->input->base - cur;
+    localname = hlocalname.name;
+    prefix = hprefix.name;
 
     /*
      * Now parse the attributes, it ends up with the ending
@@ -9298,45 +9524,74 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
     SKIP_BLANKS;
     GROW;
 
+    /*
+     * The ctxt->atts array will be ultimately passed to the SAX callback
+     * containing five xmlChar pointers for each attribute:
+     *
+     * [0] attribute name
+     * [1] attribute prefix
+     * [2] namespace URI
+     * [3] attribute value
+     * [4] end of attribute value
+     *
+     * To save memory, we reuse this array temporarily and store integers
+     * in these pointer variables.
+     *
+     * [0] attribute name
+     * [1] attribute prefix
+     * [2] hash value of attribute prefix, and later namespace index
+     * [3] for non-allocated values: ptrdiff_t offset into input buffer
+     * [4] for non-allocated values: ptrdiff_t offset into input buffer
+     *
+     * The ctxt->attallocs array contains an additional unsigned int for
+     * each attribute, containing the hash value of the attribute name
+     * and the alloc flag in bit 31.
+     */
+
     while (((RAW != '>') &&
           ((RAW != '/') || (NXT(1) != '>')) &&
           (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
-       int id = ctxt->input->id;
-       unsigned long cons = CUR_CONSUMED;
-       int len = -1, alloc = 0;
+       int len = -1;
 
-       attname = xmlParseAttribute2(ctxt, prefix, localname,
-                                    &aprefix, &attvalue, &len, &alloc);
-        if ((attname == NULL) || (attvalue == NULL))
+       hattname = xmlParseAttribute2(ctxt, prefix, localname,
+                                          &haprefix, &attvalue, &len,
+                                          &alloc);
+        if (hattname.name == NULL) {
+           xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+                "xmlParseStartTag: problem parsing attributes\n");
+           break;
+       }
+        if (attvalue == NULL)
             goto next_attr;
+        attname = hattname.name;
+        aprefix = haprefix.name;
        if (len < 0) len = xmlStrlen(attvalue);
 
         if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {
-            const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
-            xmlURIPtr uri;
-
-            if (URL == NULL) {
-                xmlErrMemory(ctxt, "dictionary allocation failure");
-                if ((attvalue != NULL) && (alloc != 0))
-                    xmlFree(attvalue);
-                localname = NULL;
-                goto done;
+            xmlHashedString huri;
+            xmlURIPtr parsedUri;
+
+            huri = xmlDictLookupHashed(ctxt->dict, attvalue, len);
+            uri = huri.name;
+            if (uri == NULL) {
+                xmlErrMemory(ctxt, NULL);
+                goto next_attr;
             }
-            if (*URL != 0) {
-                uri = xmlParseURI((const char *) URL);
-                if (uri == NULL) {
+            if (*uri != 0) {
+                parsedUri = xmlParseURI((const char *) uri);
+                if (parsedUri == NULL) {
                     xmlNsErr(ctxt, XML_WAR_NS_URI,
                              "xmlns: '%s' is not a valid URI\n",
-                                       URL, NULL, NULL);
+                                       uri, NULL, NULL);
                 } else {
-                    if (uri->scheme == NULL) {
+                    if (parsedUri->scheme == NULL) {
                         xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
                                   "xmlns: URI %s is not absolute\n",
-                                  URL, NULL, NULL);
+                                  uri, NULL, NULL);
                     }
-                    xmlFreeURI(uri);
+                    xmlFreeURI(parsedUri);
                 }
-                if (URL == ctxt->str_xml_ns) {
+                if (uri == ctxt->str_xml_ns) {
                     if (attname != ctxt->str_xml) {
                         xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                      "xml namespace URI cannot be the default namespace\n",
@@ -9345,7 +9600,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
                     goto next_attr;
                 }
                 if ((len == 29) &&
-                    (xmlStrEqual(URL,
+                    (xmlStrEqual(uri,
                              BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
                     xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                          "reuse of the xmlns namespace name is forbidden\n",
@@ -9353,23 +9608,22 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
                     goto next_attr;
                 }
             }
-            /*
-             * check that it's not a defined namespace
-             */
-            for (j = 1;j <= nbNs;j++)
-                if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)
-                    break;
-            if (j <= nbNs)
-                xmlErrAttributeDup(ctxt, NULL, attname);
-            else
-                if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
 
+            if (xmlParserNsPush(ctxt, NULL, &huri, NULL, 0) > 0)
+                nbNs++;
         } else if (aprefix == ctxt->str_xmlns) {
-            const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
-            xmlURIPtr uri;
+            xmlHashedString huri;
+            xmlURIPtr parsedUri;
+
+            huri = xmlDictLookupHashed(ctxt->dict, attvalue, len);
+            uri = huri.name;
+            if (uri == NULL) {
+                xmlErrMemory(ctxt, NULL);
+                goto next_attr;
+            }
 
             if (attname == ctxt->str_xml) {
-                if (URL != ctxt->str_xml_ns) {
+                if (uri != ctxt->str_xml_ns) {
                     xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                              "xml namespace prefix mapped to wrong URI\n",
                              NULL, NULL, NULL);
@@ -9379,7 +9633,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
                  */
                 goto next_attr;
             }
-            if (URL == ctxt->str_xml_ns) {
+            if (uri == ctxt->str_xml_ns) {
                 if (attname != ctxt->str_xml) {
                     xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                              "xml namespace URI mapped to wrong prefix\n",
@@ -9394,48 +9648,40 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
                 goto next_attr;
             }
             if ((len == 29) &&
-                (xmlStrEqual(URL,
+                (xmlStrEqual(uri,
                              BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
                 xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                          "reuse of the xmlns namespace name is forbidden\n",
                          NULL, NULL, NULL);
                 goto next_attr;
             }
-            if ((URL == NULL) || (URL[0] == 0)) {
+            if ((uri == NULL) || (uri[0] == 0)) {
                 xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
                          "xmlns:%s: Empty XML namespace is not allowed\n",
                               attname, NULL, NULL);
                 goto next_attr;
             } else {
-                uri = xmlParseURI((const char *) URL);
-                if (uri == NULL) {
+                parsedUri = xmlParseURI((const char *) uri);
+                if (parsedUri == NULL) {
                     xmlNsErr(ctxt, XML_WAR_NS_URI,
                          "xmlns:%s: '%s' is not a valid URI\n",
-                                       attname, URL, NULL);
+                                       attname, uri, NULL);
                 } else {
-                    if ((ctxt->pedantic) && (uri->scheme == NULL)) {
+                    if ((ctxt->pedantic) && (parsedUri->scheme == NULL)) {
                         xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
                                   "xmlns:%s: URI %s is not absolute\n",
-                                  attname, URL, NULL);
+                                  attname, uri, NULL);
                     }
-                    xmlFreeURI(uri);
+                    xmlFreeURI(parsedUri);
                 }
             }
 
-            /*
-             * check that it's not a defined namespace
-             */
-            for (j = 1;j <= nbNs;j++)
-                if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)
-                    break;
-            if (j <= nbNs)
-                xmlErrAttributeDup(ctxt, aprefix, attname);
-            else
-                if (nsPush(ctxt, attname, URL) > 0) nbNs++;
-
+            if (xmlParserNsPush(ctxt, &hattname, &huri, NULL, 0) > 0)
+                nbNs++;
         } else {
             /*
-             * Add the pair to atts
+             * Populate attributes array, see above for repurposing
+             * of xmlChar pointers.
              */
             if ((atts == NULL) || (nbatts + 5 > maxatts)) {
                 if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
@@ -9444,22 +9690,25 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
                 maxatts = ctxt->maxatts;
                 atts = ctxt->atts;
             }
-            ctxt->attallocs[nratts++] = alloc;
+            ctxt->attallocs[nratts++] = (hattname.hashValue & 0x7FFFFFFF) |
+                                        ((unsigned) alloc << 31);
             atts[nbatts++] = attname;
             atts[nbatts++] = aprefix;
-            /*
-             * The namespace URI field is used temporarily to point at the
-             * base of the current input buffer for non-alloced attributes.
-             * When the input buffer is reallocated, all the pointers become
-             * invalid, but they can be reconstructed later.
-             */
-            if (alloc)
-                atts[nbatts++] = NULL;
-            else
-                atts[nbatts++] = ctxt->input->base;
-            atts[nbatts++] = attvalue;
-            attvalue += len;
-            atts[nbatts++] = attvalue;
+            atts[nbatts++] = (const xmlChar *) (size_t) haprefix.hashValue;
+            if (alloc) {
+                atts[nbatts++] = attvalue;
+                attvalue += len;
+                atts[nbatts++] = attvalue;
+            } else {
+                /*
+                 * attvalue points into the input buffer which can be
+                 * reallocated. Store differences to input->base instead.
+                 * The pointers will be reconstructed later.
+                 */
+                atts[nbatts++] = (void *) (attvalue - BASE_PTR);
+                attvalue += len;
+                atts[nbatts++] = (void *) (attvalue - BASE_PTR);
+            }
             /*
              * tag if some deallocation is needed
              */
@@ -9483,12 +9732,6 @@ next_attr:
                           "attributes construct error\n");
            break;
        }
-        if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
-            (attname == NULL) && (attvalue == NULL)) {
-           xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                "xmlParseStartTag: problem parsing attributes\n");
-           break;
-       }
         GROW;
     }
 
@@ -9499,175 +9742,286 @@ next_attr:
         goto done;
     }
 
-    /* Reconstruct attribute value pointers. */
-    for (i = 0, j = 0; j < nratts; i += 5, j++) {
-        if (atts[i+2] != NULL) {
-            /*
-             * Arithmetic on dangling pointers is technically undefined
-             * behavior, but well...
-             */
-            ptrdiff_t offset = ctxt->input->base - atts[i+2];
-            atts[i+2]  = NULL;    /* Reset repurposed namespace URI */
-            atts[i+3] += offset;  /* value */
-            atts[i+4] += offset;  /* valuend */
-        }
-    }
-
     /*
-     * The attributes defaulting
+     * Namespaces from default attributes
      */
     if (ctxt->attsDefault != NULL) {
         xmlDefAttrsPtr defaults;
 
        defaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);
        if (defaults != NULL) {
-           for (i = 0;i < defaults->nbAttrs;i++) {
-               attname = defaults->values[5 * i];
-               aprefix = defaults->values[5 * i + 1];
+           for (i = 0; i < defaults->nbAttrs; i++) {
+                xmlDefAttr *attr = &defaults->attrs[i];
+
+               attname = attr->name.name;
+               aprefix = attr->prefix.name;
 
-                /*
-                * special work for namespaces defaulted defs
-                */
                if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {
-                   /*
-                    * check that it's not a defined namespace
-                    */
-                   for (j = 1;j <= nbNs;j++)
-                       if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)
-                           break;
-                   if (j <= nbNs) continue;
-
-                   nsname = xmlGetNamespace(ctxt, NULL);
-                   if (nsname != defaults->values[5 * i + 2]) {
-                       if (nsPush(ctxt, NULL,
-                                  defaults->values[5 * i + 2]) > 0)
-                           nbNs++;
-                   }
+                    xmlParserEntityCheck(ctxt, attr->expandedSize);
+
+                    if (xmlParserNsPush(ctxt, NULL, &attr->value, NULL, 1) > 0)
+                        nbNs++;
                } else if (aprefix == ctxt->str_xmlns) {
-                   /*
-                    * check that it's not a defined namespace
-                    */
-                   for (j = 1;j <= nbNs;j++)
-                       if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)
-                           break;
-                   if (j <= nbNs) continue;
-
-                   nsname = xmlGetNamespace(ctxt, attname);
-                   if (nsname != defaults->values[2]) {
-                       if (nsPush(ctxt, attname,
-                                  defaults->values[5 * i + 2]) > 0)
-                           nbNs++;
-                   }
-               } else {
-                   /*
-                    * check that it's not a defined attribute
-                    */
-                   for (j = 0;j < nbatts;j+=5) {
-                       if ((attname == atts[j]) && (aprefix == atts[j+1]))
-                           break;
-                   }
-                   if (j < nbatts) continue;
+                    xmlParserEntityCheck(ctxt, attr->expandedSize);
 
-                   if ((atts == NULL) || (nbatts + 5 > maxatts)) {
-                       if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
-                            localname = NULL;
-                            goto done;
-                       }
-                       maxatts = ctxt->maxatts;
-                       atts = ctxt->atts;
-                   }
-                   atts[nbatts++] = attname;
-                   atts[nbatts++] = aprefix;
-                   if (aprefix == NULL)
-                       atts[nbatts++] = NULL;
-                   else
-                       atts[nbatts++] = xmlGetNamespace(ctxt, aprefix);
-                   atts[nbatts++] = defaults->values[5 * i + 2];
-                   atts[nbatts++] = defaults->values[5 * i + 3];
-                   if ((ctxt->standalone == 1) &&
-                       (defaults->values[5 * i + 4] != NULL)) {
-                       xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,
-         "standalone: attribute %s on %s defaulted from external subset\n",
-                                        attname, localname);
-                   }
-                   nbdef++;
-               }
+                    if (xmlParserNsPush(ctxt, &attr->name, &attr->value,
+                                      NULL, 1) > 0)
+                        nbNs++;
+               } else {
+                    nbTotalDef += 1;
+                }
            }
        }
     }
 
     /*
-     * The attributes checkings
+     * Resolve attribute namespaces
      */
-    for (i = 0; i < nbatts;i += 5) {
+    for (i = 0; i < nbatts; i += 5) {
+        attname = atts[i];
+        aprefix = atts[i+1];
+
         /*
        * The default namespace does not apply to attribute names.
        */
-       if (atts[i + 1] != NULL) {
-           nsname = xmlGetNamespace(ctxt, atts[i + 1]);
-           if (nsname == NULL) {
-               xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+       if (aprefix == NULL) {
+            nsIndex = NS_INDEX_EMPTY;
+        } else if (aprefix == ctxt->str_xml) {
+            nsIndex = NS_INDEX_XML;
+        } else {
+            haprefix.name = aprefix;
+            haprefix.hashValue = (size_t) atts[i+2];
+            nsIndex = xmlParserNsLookup(ctxt, &haprefix, NULL);
+           if (nsIndex == INT_MAX) {
+                xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
                    "Namespace prefix %s for %s on %s is not defined\n",
-                   atts[i + 1], atts[i], localname);
-           }
-           atts[i + 2] = nsname;
-       } else
-           nsname = NULL;
-       /*
-        * [ WFC: Unique Att Spec ]
-        * No attribute name may appear more than once in the same
-        * start-tag or empty-element tag.
-        * As extended by the Namespace in XML REC.
-        */
-        for (j = 0; j < i;j += 5) {
-           if (atts[i] == atts[j]) {
-               if (atts[i+1] == atts[j+1]) {
-                   xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);
-                   break;
-               }
-               if ((nsname != NULL) && (atts[j + 2] == nsname)) {
-                   xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
-                            "Namespaced Attribute %s in '%s' redefined\n",
-                            atts[i], nsname, NULL);
-                   break;
-               }
+                   aprefix, attname, localname);
+                nsIndex = NS_INDEX_EMPTY;
+            }
+        }
+
+        atts[i+2] = (const xmlChar *) (ptrdiff_t) nsIndex;
+    }
+
+    /*
+     * Maximum number of attributes including default attributes.
+     */
+    maxAtts = nratts + nbTotalDef;
+
+    /*
+     * Verify that attribute names are unique.
+     */
+    if (maxAtts > 1) {
+        attrHashSize = 4;
+        while (attrHashSize / 2 < (unsigned) maxAtts)
+            attrHashSize *= 2;
+
+        if (attrHashSize > ctxt->attrHashMax) {
+            xmlAttrHashBucket *tmp;
+
+            tmp = xmlRealloc(ctxt->attrHash, attrHashSize * sizeof(tmp[0]));
+            if (tmp == NULL) {
+                xmlErrMemory(ctxt, NULL);
+                goto done;
+            }
+
+            ctxt->attrHash = tmp;
+            ctxt->attrHashMax = attrHashSize;
+        }
+
+        memset(ctxt->attrHash, -1, attrHashSize * sizeof(ctxt->attrHash[0]));
+
+        for (i = 0, j = 0; j < nratts; i += 5, j++) {
+            const xmlChar *nsuri;
+            unsigned hashValue, nameHashValue, uriHashValue;
+            int res;
+
+            attname = atts[i];
+            aprefix = atts[i+1];
+            nsIndex = (ptrdiff_t) atts[i+2];
+            /* Hash values always have bit 31 set, see dict.c */
+            nameHashValue = ctxt->attallocs[j] | 0x80000000;
+
+            if (nsIndex == NS_INDEX_EMPTY) {
+                nsuri = NULL;
+                uriHashValue = URI_HASH_EMPTY;
+            } else if (nsIndex == NS_INDEX_XML) {
+                nsuri = ctxt->str_xml_ns;
+                uriHashValue = URI_HASH_XML;
+            } else {
+                nsuri = ctxt->nsTab[nsIndex * 2 + 1];
+                uriHashValue = ctxt->nsdb->extra[nsIndex].uriHashValue;
+            }
+
+            hashValue = xmlDictCombineHash(nameHashValue, uriHashValue);
+            res = xmlAttrHashInsert(ctxt, attrHashSize, attname, nsuri,
+                                    hashValue, i);
+            if (res < 0)
+                continue;
+
+            /*
+             * [ WFC: Unique Att Spec ]
+             * No attribute name may appear more than once in the same
+             * start-tag or empty-element tag.
+             * As extended by the Namespace in XML REC.
+             */
+            if (res < INT_MAX) {
+                if (aprefix == atts[res+1]) {
+                    xmlErrAttributeDup(ctxt, aprefix, attname);
+                } else {
+                    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
+                             "Namespaced Attribute %s in '%s' redefined\n",
+                             attname, nsuri, NULL);
+                }
+            }
+        }
+    }
+
+    /*
+     * Default attributes
+     */
+    if (ctxt->attsDefault != NULL) {
+        xmlDefAttrsPtr defaults;
+
+       defaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);
+       if (defaults != NULL) {
+           for (i = 0; i < defaults->nbAttrs; i++) {
+                xmlDefAttr *attr = &defaults->attrs[i];
+                const xmlChar *nsuri;
+                unsigned hashValue, uriHashValue;
+                int res;
+
+               attname = attr->name.name;
+               aprefix = attr->prefix.name;
+
+               if ((attname == ctxt->str_xmlns) && (aprefix == NULL))
+                    continue;
+               if (aprefix == ctxt->str_xmlns)
+                    continue;
+
+                if (aprefix == NULL) {
+                    nsIndex = NS_INDEX_EMPTY;
+                    nsuri = NULL;
+                    uriHashValue = URI_HASH_EMPTY;
+                } if (aprefix == ctxt->str_xml) {
+                    nsIndex = NS_INDEX_XML;
+                    nsuri = ctxt->str_xml_ns;
+                    uriHashValue = URI_HASH_XML;
+                } else if (aprefix != NULL) {
+                    nsIndex = xmlParserNsLookup(ctxt, &attr->prefix, NULL);
+                    if (nsIndex == INT_MAX) {
+                        xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+                                 "Namespace prefix %s for %s on %s is not "
+                                 "defined\n",
+                                 aprefix, attname, localname);
+                        nsIndex = NS_INDEX_EMPTY;
+                        nsuri = NULL;
+                        uriHashValue = URI_HASH_EMPTY;
+                    } else {
+                        nsuri = ctxt->nsTab[nsIndex * 2 + 1];
+                        uriHashValue = ctxt->nsdb->extra[nsIndex].uriHashValue;
+                    }
+                }
+
+                /*
+                 * Check whether the attribute exists
+                 */
+                if (maxAtts > 1) {
+                    hashValue = xmlDictCombineHash(attr->name.hashValue,
+                                                   uriHashValue);
+                    res = xmlAttrHashInsert(ctxt, attrHashSize, attname, nsuri,
+                                            hashValue, nbatts);
+                    if (res < 0)
+                        continue;
+                    if (res < INT_MAX) {
+                        if (aprefix == atts[res+1])
+                            continue;
+                        xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
+                                 "Namespaced Attribute %s in '%s' redefined\n",
+                                 attname, nsuri, NULL);
+                    }
+                }
+
+                xmlParserEntityCheck(ctxt, attr->expandedSize);
+
+                if ((atts == NULL) || (nbatts + 5 > maxatts)) {
+                    if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
+                        localname = NULL;
+                        goto done;
+                    }
+                    maxatts = ctxt->maxatts;
+                    atts = ctxt->atts;
+                }
+
+                atts[nbatts++] = attname;
+                atts[nbatts++] = aprefix;
+                atts[nbatts++] = (const xmlChar *) (ptrdiff_t) nsIndex;
+                atts[nbatts++] = attr->value.name;
+                atts[nbatts++] = attr->valueEnd;
+                if ((ctxt->standalone == 1) && (attr->external != 0)) {
+                    xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,
+                            "standalone: attribute %s on %s defaulted "
+                            "from external subset\n",
+                            attname, localname);
+                }
+                nbdef++;
            }
        }
     }
 
-    nsname = xmlGetNamespace(ctxt, prefix);
-    if ((prefix != NULL) && (nsname == NULL)) {
+    /*
+     * Reconstruct attribute pointers
+     */
+    for (i = 0, j = 0; i < nbatts; i += 5, j++) {
+        /* namespace URI */
+        nsIndex = (ptrdiff_t) atts[i+2];
+        if (nsIndex == INT_MAX)
+            atts[i+2] = NULL;
+        else if (nsIndex == INT_MAX - 1)
+            atts[i+2] = ctxt->str_xml_ns;
+        else
+            atts[i+2] = ctxt->nsTab[nsIndex * 2 + 1];
+
+        if ((j < nratts) && (ctxt->attallocs[j] & 0x80000000) == 0) {
+            atts[i+3] = BASE_PTR + (ptrdiff_t) atts[i+3];  /* value */
+            atts[i+4] = BASE_PTR + (ptrdiff_t) atts[i+4];  /* valuend */
+        }
+    }
+
+    uri = xmlParserNsLookupUri(ctxt, &hprefix);
+    if ((prefix != NULL) && (uri == NULL)) {
        xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
                 "Namespace prefix %s on %s is not defined\n",
                 prefix, localname, NULL);
     }
     *pref = prefix;
-    *URI = nsname;
+    *URI = uri;
 
     /*
-     * SAX: Start of Element !
+     * SAX callback
      */
     if ((ctxt->sax != NULL) && (ctxt->sax->startElementNs != NULL) &&
        (!ctxt->disableSAX)) {
        if (nbNs > 0)
-           ctxt->sax->startElementNs(ctxt->userData, localname, prefix,
-                         nsname, nbNs, &ctxt->nsTab[ctxt->nsNr - 2 * nbNs],
+           ctxt->sax->startElementNs(ctxt->userData, localname, prefix, uri,
+                          nbNs, ctxt->nsTab + 2 * (ctxt->nsNr - nbNs),
                          nbatts / 5, nbdef, atts);
        else
-           ctxt->sax->startElementNs(ctxt->userData, localname, prefix,
-                         nsname, 0, NULL, nbatts / 5, nbdef, atts);
+           ctxt->sax->startElementNs(ctxt->userData, localname, prefix, uri,
+                          0, NULL, nbatts / 5, nbdef, atts);
     }
 
 done:
     /*
-     * Free up attribute allocated strings if needed
+     * Free allocated attribute values
      */
     if (attval != 0) {
-       for (i = 3,j = 0; j < nratts;i += 5,j++)
-           if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))
-               xmlFree((xmlChar *) atts[i]);
+       for (i = 0, j = 0; j < nratts; i += 5, j++)
+           if (ctxt->attallocs[j] & 0x80000000)
+               xmlFree((xmlChar *) atts[i+3]);
     }
 
+    *nbNsPtr = nbNs;
     return(localname);
 }
 
@@ -9677,7 +10031,7 @@ done:
  * @line:  line of the start tag
  * @nsNr:  number of namespaces on the start tag
  *
- * parse an end of tag
+ * Parse an end tag. Always consumes '</'.
  *
  * [42] ETag ::= '</' Name S? '>'
  *
@@ -9737,14 +10091,16 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlStartTag *tag) {
 
     spacePop(ctxt);
     if (tag->nsNr != 0)
-       nsPop(ctxt, tag->nsNr);
+       xmlParserNsPop(ctxt, tag->nsNr);
 }
 
 /**
  * xmlParseCDSect:
  * @ctxt:  an XML parser context
  *
- * Parse escaped pure raw content.
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Parse escaped pure raw content. Always consumes '<!['.
  *
  * [18] CDSect ::= CDStart CData CDEnd
  *
@@ -9762,81 +10118,72 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
     int r, rl;
     int        s, sl;
     int cur, l;
-    int count = 0;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_HUGE_LENGTH :
+                    XML_MAX_TEXT_LENGTH;
 
-    /* Check 2.6.0 was NXT(0) not RAW */
-    if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
-       SKIP(9);
-    } else
+    if ((CUR != '<') || (NXT(1) != '!') || (NXT(2) != '['))
+        return;
+    SKIP(3);
+
+    if (!CMP6(CUR_PTR, 'C', 'D', 'A', 'T', 'A', '['))
         return;
+    SKIP(6);
 
     ctxt->instate = XML_PARSER_CDATA_SECTION;
     r = CUR_CHAR(rl);
     if (!IS_CHAR(r)) {
        xmlFatalErr(ctxt, XML_ERR_CDATA_NOT_FINISHED, NULL);
-       ctxt->instate = XML_PARSER_CONTENT;
-        return;
+        goto out;
     }
     NEXTL(rl);
     s = CUR_CHAR(sl);
     if (!IS_CHAR(s)) {
        xmlFatalErr(ctxt, XML_ERR_CDATA_NOT_FINISHED, NULL);
-       ctxt->instate = XML_PARSER_CONTENT;
-        return;
+        goto out;
     }
     NEXTL(sl);
     cur = CUR_CHAR(l);
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
        xmlErrMemory(ctxt, NULL);
-       return;
+        goto out;
     }
     while (IS_CHAR(cur) &&
            ((r != ']') || (s != ']') || (cur != '>'))) {
        if (len + 5 >= size) {
            xmlChar *tmp;
 
-            if ((size > XML_MAX_TEXT_LENGTH) &&
-                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
-                xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
-                             "CData section too big found", NULL);
-                xmlFree (buf);
-                return;
-            }
-           tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size * 2);
            if (tmp == NULL) {
-               xmlFree(buf);
                xmlErrMemory(ctxt, NULL);
-               return;
+                goto out;
            }
            buf = tmp;
            size *= 2;
        }
-       COPY_BUF(rl,buf,len,r);
+       COPY_BUF(buf, len, r);
+        if (len > maxLength) {
+            xmlFatalErrMsg(ctxt, XML_ERR_CDATA_NOT_FINISHED,
+                           "CData section too big found\n");
+            goto out;
+        }
        r = s;
        rl = sl;
        s = cur;
        sl = l;
-       count++;
-       if (count > 50) {
-           SHRINK;
-           GROW;
-            if (ctxt->instate == XML_PARSER_EOF) {
-               xmlFree(buf);
-               return;
-            }
-           count = 0;
-       }
        NEXTL(l);
        cur = CUR_CHAR(l);
     }
     buf[len] = 0;
-    ctxt->instate = XML_PARSER_CONTENT;
+    if (ctxt->instate == XML_PARSER_EOF) {
+        xmlFree(buf);
+        return;
+    }
     if (cur != '>') {
        xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
                             "CData section not finished\n%.50s\n", buf);
-       xmlFree(buf);
-        return;
+        goto out;
     }
     NEXTL(l);
 
@@ -9849,6 +10196,10 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
        else if (ctxt->sax->characters != NULL)
            ctxt->sax->characters(ctxt->userData, buf, len);
     }
+
+out:
+    if (ctxt->instate != XML_PARSER_EOF)
+        ctxt->instate = XML_PARSER_CONTENT;
     xmlFree(buf);
 }
 
@@ -9865,10 +10216,8 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
     int nameNr = ctxt->nameNr;
 
     GROW;
-    while ((RAW != 0) &&
+    while ((ctxt->input->cur < ctxt->input->end) &&
           (ctxt->instate != XML_PARSER_EOF)) {
-        int id = ctxt->input->id;
-       unsigned long cons = CUR_CONSUMED;
        const xmlChar *cur = ctxt->input->cur;
 
        /*
@@ -9921,18 +10270,11 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
         * Last case, text. Note that References are handled directly.
         */
        else {
-           xmlParseCharData(ctxt, 0);
+           xmlParseCharDataInternal(ctxt, 0);
        }
 
-       GROW;
        SHRINK;
-
-       if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
-           xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                       "detected an error in element content\n");
-           xmlHaltParser(ctxt);
-            break;
-       }
+       GROW;
     }
 }
 
@@ -9951,7 +10293,9 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
 
     xmlParseContentInternal(ctxt);
 
-    if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->nameNr > nameNr)) {
+    if ((ctxt->instate != XML_PARSER_EOF) &&
+        (ctxt->errNo == XML_ERR_OK) &&
+        (ctxt->nameNr > nameNr)) {
         const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
         int line = ctxt->pushTab[ctxt->nameNr - 1].line;
         xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
@@ -9964,6 +10308,8 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
  * xmlParseElement:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML element
  *
  * [39] element ::= EmptyElemTag | STag content ETag
@@ -9983,12 +10329,14 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
     if (ctxt->instate == XML_PARSER_EOF)
        return;
 
-    if (CUR == 0) {
-        const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
-        int line = ctxt->pushTab[ctxt->nameNr - 1].line;
-        xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
-                "Premature end of data in tag %s line %d\n",
-               name, line, NULL);
+    if (ctxt->input->cur >= ctxt->input->end) {
+        if (ctxt->errNo == XML_ERR_OK) {
+            const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
+            int line = ctxt->pushTab[ctxt->nameNr - 1].line;
+            xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
+                    "Premature end of data in tag %s line %d\n",
+                    name, line, NULL);
+        }
         return;
     }
 
@@ -10001,6 +10349,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
  *
  * Parse the start of an XML element. Returns -1 in case of error, 0 if an
  * opening tag was parsed, 1 if an empty element was parsed.
+ *
+ * Always consumes '<'.
  */
 static int
 xmlParseElementStart(xmlParserCtxtPtr ctxt) {
@@ -10008,9 +10358,9 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
     const xmlChar *prefix = NULL;
     const xmlChar *URI = NULL;
     xmlParserNodeInfo node_info;
-    int line, tlen = 0;
-    xmlNodePtr ret;
-    int nsNr = ctxt->nsNr;
+    int line;
+    xmlNodePtr cur;
+    int nbNs = 0;
 
     if (((unsigned int) ctxt->nameNr > xmlParserMaxDepth) &&
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
@@ -10039,7 +10389,7 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
 #ifdef LIBXML_SAX1_ENABLED
     if (ctxt->sax2)
 #endif /* LIBXML_SAX1_ENABLED */
-        name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen);
+        name = xmlParseStartTag2(ctxt, &prefix, &URI, &nbNs);
 #ifdef LIBXML_SAX1_ENABLED
     else
        name = xmlParseStartTag(ctxt);
@@ -10050,8 +10400,8 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
        spacePop(ctxt);
         return(-1);
     }
-    nameNsPush(ctxt, name, prefix, URI, line, ctxt->nsNr - nsNr);
-    ret = ctxt->node;
+    nameNsPush(ctxt, name, prefix, URI, line, nbNs);
+    cur = ctxt->node;
 
 #ifdef LIBXML_VALID_ENABLED
     /*
@@ -10082,19 +10432,25 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
        }
        namePop(ctxt);
        spacePop(ctxt);
-       if (nsNr != ctxt->nsNr)
-           nsPop(ctxt, ctxt->nsNr - nsNr);
-       if ( ret != NULL && ctxt->record_info ) {
-          node_info.end_pos = ctxt->input->consumed +
-                             (CUR_PTR - ctxt->input->base);
-          node_info.end_line = ctxt->input->line;
-          node_info.node = ret;
-          xmlParserAddNodeInfo(ctxt, &node_info);
+       if (nbNs > 0)
+           xmlParserNsPop(ctxt, nbNs);
+       if (cur != NULL && ctxt->record_info) {
+            node_info.node = cur;
+            node_info.end_pos = ctxt->input->consumed +
+                                (CUR_PTR - ctxt->input->base);
+            node_info.end_line = ctxt->input->line;
+            xmlParserAddNodeInfo(ctxt, &node_info);
        }
        return(1);
     }
     if (RAW == '>') {
         NEXT1;
+        if (cur != NULL && ctxt->record_info) {
+            node_info.node = cur;
+            node_info.end_pos = 0;
+            node_info.end_line = 0;
+            xmlParserAddNodeInfo(ctxt, &node_info);
+        }
     } else {
         xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_GT_REQUIRED,
                     "Couldn't find end of Start Tag %s line %d\n",
@@ -10106,19 +10462,8 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
        nodePop(ctxt);
        namePop(ctxt);
        spacePop(ctxt);
-       if (nsNr != ctxt->nsNr)
-           nsPop(ctxt, ctxt->nsNr - nsNr);
-
-       /*
-        * Capture end position and add node
-        */
-       if ( ret != NULL && ctxt->record_info ) {
-          node_info.end_pos = ctxt->input->consumed +
-                             (CUR_PTR - ctxt->input->base);
-          node_info.end_line = ctxt->input->line;
-          node_info.node = ret;
-          xmlParserAddNodeInfo(ctxt, &node_info);
-       }
+       if (nbNs > 0)
+           xmlParserNsPop(ctxt, nbNs);
        return(-1);
     }
 
@@ -10129,15 +10474,17 @@ xmlParseElementStart(xmlParserCtxtPtr ctxt) {
  * xmlParseElementEnd:
  * @ctxt:  an XML parser context
  *
- * Parse the end of an XML element.
+ * Parse the end of an XML element. Always consumes '</'.
  */
 static void
 xmlParseElementEnd(xmlParserCtxtPtr ctxt) {
-    xmlParserNodeInfo node_info;
-    xmlNodePtr ret = ctxt->node;
+    xmlNodePtr cur = ctxt->node;
 
-    if (ctxt->nameNr <= 0)
+    if (ctxt->nameNr <= 0) {
+        if ((RAW == '<') && (NXT(1) == '/'))
+            SKIP(2);
         return;
+    }
 
     /*
      * parse the end of tag: '</' should be here.
@@ -10152,14 +10499,17 @@ xmlParseElementEnd(xmlParserCtxtPtr ctxt) {
 #endif /* LIBXML_SAX1_ENABLED */
 
     /*
-     * Capture end position and add node
+     * Capture end position
      */
-    if ( ret != NULL && ctxt->record_info ) {
-       node_info.end_pos = ctxt->input->consumed +
-                          (CUR_PTR - ctxt->input->base);
-       node_info.end_line = ctxt->input->line;
-       node_info.node = ret;
-       xmlParserAddNodeInfo(ctxt, &node_info);
+    if (cur != NULL && ctxt->record_info) {
+        xmlParserNodeInfoPtr node_info;
+
+        node_info = (xmlParserNodeInfoPtr) xmlParserFindNodeInfo(ctxt, cur);
+        if (node_info != NULL) {
+            node_info->end_pos = ctxt->input->consumed +
+                                 (CUR_PTR - ctxt->input->base);
+            node_info->end_line = ctxt->input->line;
+        }
     }
 }
 
@@ -10167,6 +10517,8 @@ xmlParseElementEnd(xmlParserCtxtPtr ctxt) {
  * xmlParseVersionNum:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the XML version value.
  *
  * [26] VersionNum ::= '1.' [0-9]+
@@ -10182,7 +10534,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
     int size = 10;
     xmlChar cur;
 
-    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(size);
     if (buf == NULL) {
        xmlErrMemory(ctxt, NULL);
        return(NULL);
@@ -10207,7 +10559,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
            xmlChar *tmp;
 
            size *= 2;
-           tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+           tmp = (xmlChar *) xmlRealloc(buf, size);
            if (tmp == NULL) {
                xmlFree(buf);
                xmlErrMemory(ctxt, NULL);
@@ -10227,6 +10579,8 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
  * xmlParseVersionInfo:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the XML version.
  *
  * [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
@@ -10274,6 +10628,8 @@ xmlParseVersionInfo(xmlParserCtxtPtr ctxt) {
  * xmlParseEncName:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the XML encoding name
  *
  * [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
@@ -10285,12 +10641,15 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
     xmlChar *buf = NULL;
     int len = 0;
     int size = 10;
+    int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
+                    XML_MAX_TEXT_LENGTH :
+                    XML_MAX_NAME_LENGTH;
     xmlChar cur;
 
     cur = CUR;
     if (((cur >= 'a') && (cur <= 'z')) ||
         ((cur >= 'A') && (cur <= 'Z'))) {
-       buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
+       buf = (xmlChar *) xmlMallocAtomic(size);
        if (buf == NULL) {
            xmlErrMemory(ctxt, NULL);
            return(NULL);
@@ -10308,7 +10667,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
                xmlChar *tmp;
 
                size *= 2;
-               tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+               tmp = (xmlChar *) xmlRealloc(buf, size);
                if (tmp == NULL) {
                    xmlErrMemory(ctxt, NULL);
                    xmlFree(buf);
@@ -10317,13 +10676,13 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
                buf = tmp;
            }
            buf[len++] = cur;
+            if (len > maxLength) {
+                xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "EncName");
+                xmlFree(buf);
+                return(NULL);
+            }
            NEXT;
            cur = CUR;
-           if (cur == 0) {
-               SHRINK;
-               GROW;
-               cur = CUR;
-           }
         }
        buf[len] = 0;
     } else {
@@ -10336,6 +10695,8 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
  * xmlParseEncodingDecl:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the XML encoding declaration
  *
  * [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' |  "'" EncName "'")
@@ -10350,106 +10711,53 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
     xmlChar *encoding = NULL;
 
     SKIP_BLANKS;
-    if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
-       SKIP(8);
-       SKIP_BLANKS;
-       if (RAW != '=') {
-           xmlFatalErr(ctxt, XML_ERR_EQUAL_REQUIRED, NULL);
-           return(NULL);
-        }
-       NEXT;
-       SKIP_BLANKS;
-       if (RAW == '"') {
-           NEXT;
-           encoding = xmlParseEncName(ctxt);
-           if (RAW != '"') {
-               xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
-               xmlFree((xmlChar *) encoding);
-               return(NULL);
-           } else
-               NEXT;
-       } else if (RAW == '\''){
-           NEXT;
-           encoding = xmlParseEncName(ctxt);
-           if (RAW != '\'') {
-               xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
-               xmlFree((xmlChar *) encoding);
-               return(NULL);
-           } else
-               NEXT;
-       } else {
-           xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);
-       }
+    if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g') == 0)
+        return(NULL);
 
-        /*
-         * Non standard parsing, allowing the user to ignore encoding
-         */
-        if (ctxt->options & XML_PARSE_IGNORE_ENC) {
-           xmlFree((xmlChar *) encoding);
+    SKIP(8);
+    SKIP_BLANKS;
+    if (RAW != '=') {
+        xmlFatalErr(ctxt, XML_ERR_EQUAL_REQUIRED, NULL);
+        return(NULL);
+    }
+    NEXT;
+    SKIP_BLANKS;
+    if (RAW == '"') {
+        NEXT;
+        encoding = xmlParseEncName(ctxt);
+        if (RAW != '"') {
+            xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
+            xmlFree((xmlChar *) encoding);
             return(NULL);
-       }
-
-       /*
-        * UTF-16 encoding switch has already taken place at this stage,
-        * more over the little-endian/big-endian selection is already done
-        */
-        if ((encoding != NULL) &&
-           ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
-            (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
-           /*
-            * If no encoding was passed to the parser, that we are
-            * using UTF-16 and no decoder is present i.e. the
-            * document is apparently UTF-8 compatible, then raise an
-            * encoding mismatch fatal error
-            */
-           if ((ctxt->encoding == NULL) &&
-               (ctxt->input->buf != NULL) &&
-               (ctxt->input->buf->encoder == NULL)) {
-               xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
-                 "Document labelled UTF-16 but has UTF-8 content\n");
-           }
-           if (ctxt->encoding != NULL)
-               xmlFree((xmlChar *) ctxt->encoding);
-           ctxt->encoding = encoding;
-       }
-       /*
-        * UTF-8 encoding is handled natively
-        */
-        else if ((encoding != NULL) &&
-           ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
-            (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
-           if (ctxt->encoding != NULL)
-               xmlFree((xmlChar *) ctxt->encoding);
-           ctxt->encoding = encoding;
-       }
-       else if (encoding != NULL) {
-           xmlCharEncodingHandlerPtr handler;
-
-           if (ctxt->input->encoding != NULL)
-               xmlFree((xmlChar *) ctxt->input->encoding);
-           ctxt->input->encoding = encoding;
-
-            handler = xmlFindCharEncodingHandler((const char *) encoding);
-           if (handler != NULL) {
-               if (xmlSwitchToEncoding(ctxt, handler) < 0) {
-                   /* failed to convert */
-                   ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
-                   return(NULL);
-               }
-           } else {
-               xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-                       "Unsupported encoding %s\n", encoding);
-               return(NULL);
-           }
-       }
+        } else
+            NEXT;
+    } else if (RAW == '\''){
+        NEXT;
+        encoding = xmlParseEncName(ctxt);
+        if (RAW != '\'') {
+            xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
+            xmlFree((xmlChar *) encoding);
+            return(NULL);
+        } else
+            NEXT;
+    } else {
+        xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);
     }
-    return(encoding);
+
+    if (encoding == NULL)
+        return(NULL);
+
+    xmlSetDeclaredEncoding(ctxt, encoding);
+
+    return(ctxt->encoding);
 }
 
 /**
  * xmlParseSDDecl:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse the XML standalone declaration
  *
  * [32] SDDecl ::= S 'standalone' Eq
@@ -10534,6 +10842,8 @@ xmlParseSDDecl(xmlParserCtxtPtr ctxt) {
  * xmlParseXMLDecl:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML declaration header
  *
  * [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
@@ -10548,7 +10858,8 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
      * XML declaration but it does not have a standalone attribute.
      * It will be overwritten later if a standalone attribute is found.
      */
-    ctxt->input->standalone = -2;
+
+    ctxt->standalone = -2;
 
     /*
      * We know that '<?xml' is here.
@@ -10615,7 +10926,7 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
     /*
      * We may have the standalone status.
      */
-    if ((ctxt->input->encoding != NULL) && (!IS_BLANK_CH(RAW))) {
+    if ((ctxt->encoding != NULL) && (!IS_BLANK_CH(RAW))) {
         if ((RAW == '?') && (NXT(1) == '>')) {
            SKIP(2);
            return;
@@ -10629,7 +10940,7 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
     GROW;
 
     SKIP_BLANKS;
-    ctxt->input->standalone = xmlParseSDDecl(ctxt);
+    ctxt->standalone = xmlParseSDDecl(ctxt);
 
     SKIP_BLANKS;
     if ((RAW == '?') && (NXT(1) == '>')) {
@@ -10639,9 +10950,14 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
        xmlFatalErr(ctxt, XML_ERR_XMLDECL_NOT_FINISHED, NULL);
        NEXT;
     } else {
+        int c;
+
        xmlFatalErr(ctxt, XML_ERR_XMLDECL_NOT_FINISHED, NULL);
-       MOVETO_ENDTAG(CUR_PTR);
-       NEXT;
+        while ((c = CUR) != 0) {
+            NEXT;
+            if (c == '>')
+                break;
+        }
     }
 }
 
@@ -10649,6 +10965,8 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
  * xmlParseMisc:
  * @ctxt:  an XML parser context
  *
+ * DEPRECATED: Internal function, don't use.
+ *
  * parse an XML Misc* optional field.
  *
  * [27] Misc ::= Comment | PI |  S
@@ -10686,9 +11004,6 @@ xmlParseMisc(xmlParserCtxtPtr ctxt) {
 
 int
 xmlParseDocument(xmlParserCtxtPtr ctxt) {
-    xmlChar start[4];
-    xmlCharEncoding enc;
-
     xmlInitParser();
 
     if ((ctxt == NULL) || (ctxt->input == NULL))
@@ -10709,38 +11024,14 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
     if (ctxt->instate == XML_PARSER_EOF)
        return(-1);
 
-    if ((ctxt->encoding == NULL) &&
-        ((ctxt->input->end - ctxt->input->cur) >= 4)) {
-       /*
-        * Get the 4 first bytes and decode the charset
-        * if enc != XML_CHAR_ENCODING_NONE
-        * plug some encoding conversion routines.
-        */
-       start[0] = RAW;
-       start[1] = NXT(1);
-       start[2] = NXT(2);
-       start[3] = NXT(3);
-       enc = xmlDetectCharEncoding(&start[0], 4);
-       if (enc != XML_CHAR_ENCODING_NONE) {
-           xmlSwitchEncoding(ctxt, enc);
-       }
-    }
-
+    xmlDetectEncoding(ctxt);
 
     if (CUR == 0) {
        xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
        return(-1);
     }
 
-    /*
-     * Check for the XMLDecl in the Prolog.
-     * do not GROW here to avoid the detected encoder to decode more
-     * than just the first line, unless the amount of data is really
-     * too small to hold "<?xml version="1.0" encoding="foo"
-     */
-    if ((ctxt->input->end - ctxt->input->cur) < 35) {
-       GROW;
-    }
+    GROW;
     if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
 
        /*
@@ -10754,7 +11045,6 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
             */
            return(-1);
        }
-       ctxt->standalone = ctxt->input->standalone;
        SKIP_BLANKS;
     } else {
        ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
@@ -10825,9 +11115,15 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
         */
        xmlParseMisc(ctxt);
 
-       if (RAW != 0) {
-           xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
-       }
+        if (ctxt->input->cur < ctxt->input->end) {
+            if (ctxt->errNo == XML_ERR_OK)
+               xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
+        } else if ((ctxt->input->buf != NULL) &&
+                   (ctxt->input->buf->encoder != NULL) &&
+                   (!xmlBufIsEmpty(ctxt->input->buf->raw))) {
+            xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
+                           "Truncated multi-byte sequence at EOF\n");
+        }
        ctxt->instate = XML_PARSER_EOF;
     }
 
@@ -10878,38 +11174,18 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
 
 int
 xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
-    xmlChar start[4];
-    xmlCharEncoding enc;
-
     if ((ctxt == NULL) || (ctxt->input == NULL))
         return(-1);
 
     xmlDetectSAX2(ctxt);
 
-    GROW;
-
     /*
      * SAX: beginning of the document processing.
      */
     if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
         ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
 
-    /*
-     * Get the 4 first bytes and decode the charset
-     * if enc != XML_CHAR_ENCODING_NONE
-     * plug some encoding conversion routines.
-     */
-    if ((ctxt->input->end - ctxt->input->cur) >= 4) {
-       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);
-       }
-    }
-
+    xmlDetectEncoding(ctxt);
 
     if (CUR == 0) {
        xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
@@ -10976,142 +11252,263 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
  ************************************************************************/
 
 /**
- * xmlParseLookupSequence:
+ * xmlParseLookupChar:
  * @ctxt:  an XML parser context
- * @first:  the first char to lookup
- * @next:  the next char to lookup or zero
- * @third:  the next char to lookup or zero
+ * @c:  character
  *
- * Try to find if a sequence (first, next, third) or  just (first next) or
- * (first) is available in the input stream.
- * This function has a side effect of (possibly) incrementing ctxt->checkIndex
- * to avoid rescanning sequences of bytes, it DOES change the state of the
- * parser, do not use liberally.
- *
- * Returns the index to the current parsing point if the full sequence
- *      is available, -1 otherwise.
+ * Check whether the input buffer contains a character.
  */
 static int
-xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
-                       xmlChar next, xmlChar third) {
-    int base, len;
-    xmlParserInputPtr in;
-    const xmlChar *buf;
-
-    in = ctxt->input;
-    if (in == NULL) return(-1);
-    base = in->cur - in->base;
-    if (base < 0) return(-1);
-    if (ctxt->checkIndex > base)
-        base = ctxt->checkIndex;
-    if (in->buf == NULL) {
-       buf = in->base;
-       len = in->length;
+xmlParseLookupChar(xmlParserCtxtPtr ctxt, int c) {
+    const xmlChar *cur;
+
+    if (ctxt->checkIndex == 0) {
+        cur = ctxt->input->cur + 1;
     } else {
-       buf = xmlBufContent(in->buf->buffer);
-       len = xmlBufUse(in->buf->buffer);
-    }
-    /* take into account the sequence length */
-    if (third) len -= 2;
-    else if (next) len --;
-    for (;base < len;base++) {
-        if (buf[base] == first) {
-           if (third != 0) {
-               if ((buf[base + 1] != next) ||
-                   (buf[base + 2] != third)) continue;
-           } else if (next != 0) {
-               if (buf[base + 1] != next) continue;
-           }
-           ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-           if (next == 0)
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: lookup '%c' found at %d\n",
-                       first, base);
-           else if (third == 0)
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: lookup '%c%c' found at %d\n",
-                       first, next, base);
-           else
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: lookup '%c%c%c' found at %d\n",
-                       first, next, third, base);
-#endif
-           return(base - (in->cur - in->base));
-       }
+        cur = ctxt->input->cur + ctxt->checkIndex;
+    }
+
+    if (memchr(cur, c, ctxt->input->end - cur) == NULL) {
+        size_t index = ctxt->input->end - ctxt->input->cur;
+
+        if (index > LONG_MAX) {
+            ctxt->checkIndex = 0;
+            return(1);
+        }
+        ctxt->checkIndex = index;
+        return(0);
+    } else {
+        ctxt->checkIndex = 0;
+        return(1);
     }
-    ctxt->checkIndex = base;
-#ifdef DEBUG_PUSH
-    if (next == 0)
-       xmlGenericError(xmlGenericErrorContext,
-               "PP: lookup '%c' failed\n", first);
-    else if (third == 0)
-       xmlGenericError(xmlGenericErrorContext,
-               "PP: lookup '%c%c' failed\n", first, next);
-    else
-       xmlGenericError(xmlGenericErrorContext,
-               "PP: lookup '%c%c%c' failed\n", first, next, third);
-#endif
-    return(-1);
 }
 
 /**
- * xmlParseGetLasts:
+ * xmlParseLookupString:
  * @ctxt:  an XML parser context
- * @lastlt:  pointer to store the last '<' from the input
- * @lastgt:  pointer to store the last '>' from the input
+ * @startDelta: delta to apply at the start
+ * @str:  string
+ * @strLen:  length of string
  *
- * Lookup the last < and > in the current chunk
+ * Check whether the input buffer contains a string.
  */
-static void
-xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt,
-                 const xmlChar **lastgt) {
-    const xmlChar *tmp;
+static const xmlChar *
+xmlParseLookupString(xmlParserCtxtPtr ctxt, size_t startDelta,
+                     const char *str, size_t strLen) {
+    const xmlChar *cur, *term;
 
-    if ((ctxt == NULL) || (lastlt == NULL) || (lastgt == NULL)) {
-       xmlGenericError(xmlGenericErrorContext,
-                   "Internal error: xmlParseGetLasts\n");
-       return;
+    if (ctxt->checkIndex == 0) {
+        cur = ctxt->input->cur + startDelta;
+    } else {
+        cur = ctxt->input->cur + ctxt->checkIndex;
+    }
+
+    term = BAD_CAST strstr((const char *) cur, str);
+    if (term == NULL) {
+        const xmlChar *end = ctxt->input->end;
+        size_t index;
+
+        /* Rescan (strLen - 1) characters. */
+        if ((size_t) (end - cur) < strLen)
+            end = cur;
+        else
+            end -= strLen - 1;
+        index = end - ctxt->input->cur;
+        if (index > LONG_MAX) {
+            ctxt->checkIndex = 0;
+            return(ctxt->input->end - strLen);
+        }
+        ctxt->checkIndex = index;
+    } else {
+        ctxt->checkIndex = 0;
     }
-    if ((ctxt->progressive != 0) && (ctxt->inputNr == 1)) {
-        tmp = ctxt->input->end;
-       tmp--;
-       while ((tmp >= ctxt->input->base) && (*tmp != '<')) tmp--;
-       if (tmp < ctxt->input->base) {
-           *lastlt = NULL;
-           *lastgt = NULL;
-       } else {
-           *lastlt = tmp;
-           tmp++;
-           while ((tmp < ctxt->input->end) && (*tmp != '>')) {
-               if (*tmp == '\'') {
-                   tmp++;
-                   while ((tmp < ctxt->input->end) && (*tmp != '\'')) tmp++;
-                   if (tmp < ctxt->input->end) tmp++;
-               } else if (*tmp == '"') {
-                   tmp++;
-                   while ((tmp < ctxt->input->end) && (*tmp != '"')) tmp++;
-                   if (tmp < ctxt->input->end) tmp++;
-               } else
-                   tmp++;
-           }
-           if (tmp < ctxt->input->end)
-               *lastgt = tmp;
-           else {
-               tmp = *lastlt;
-               tmp--;
-               while ((tmp >= ctxt->input->base) && (*tmp != '>')) tmp--;
-               if (tmp >= ctxt->input->base)
-                   *lastgt = tmp;
-               else
-                   *lastgt = NULL;
-           }
-       }
+
+    return(term);
+}
+
+/**
+ * xmlParseLookupCharData:
+ * @ctxt:  an XML parser context
+ *
+ * Check whether the input buffer contains terminated char data.
+ */
+static int
+xmlParseLookupCharData(xmlParserCtxtPtr ctxt) {
+    const xmlChar *cur = ctxt->input->cur + ctxt->checkIndex;
+    const xmlChar *end = ctxt->input->end;
+    size_t index;
+
+    while (cur < end) {
+        if ((*cur == '<') || (*cur == '&')) {
+            ctxt->checkIndex = 0;
+            return(1);
+        }
+        cur++;
+    }
+
+    index = cur - ctxt->input->cur;
+    if (index > LONG_MAX) {
+        ctxt->checkIndex = 0;
+        return(1);
+    }
+    ctxt->checkIndex = index;
+    return(0);
+}
+
+/**
+ * xmlParseLookupGt:
+ * @ctxt:  an XML parser context
+ *
+ * Check whether there's enough data in the input buffer to finish parsing
+ * a start tag. This has to take quotes into account.
+ */
+static int
+xmlParseLookupGt(xmlParserCtxtPtr ctxt) {
+    const xmlChar *cur;
+    const xmlChar *end = ctxt->input->end;
+    int state = ctxt->endCheckState;
+    size_t index;
+
+    if (ctxt->checkIndex == 0)
+        cur = ctxt->input->cur + 1;
+    else
+        cur = ctxt->input->cur + ctxt->checkIndex;
+
+    while (cur < end) {
+        if (state) {
+            if (*cur == state)
+                state = 0;
+        } else if (*cur == '\'' || *cur == '"') {
+            state = *cur;
+        } else if (*cur == '>') {
+            ctxt->checkIndex = 0;
+            ctxt->endCheckState = 0;
+            return(1);
+        }
+        cur++;
+    }
+
+    index = cur - ctxt->input->cur;
+    if (index > LONG_MAX) {
+        ctxt->checkIndex = 0;
+        ctxt->endCheckState = 0;
+        return(1);
+    }
+    ctxt->checkIndex = index;
+    ctxt->endCheckState = state;
+    return(0);
+}
+
+/**
+ * xmlParseLookupInternalSubset:
+ * @ctxt:  an XML parser context
+ *
+ * Check whether there's enough data in the input buffer to finish parsing
+ * the internal subset.
+ */
+static int
+xmlParseLookupInternalSubset(xmlParserCtxtPtr ctxt) {
+    /*
+     * Sorry, but progressive parsing of the internal subset is not
+     * supported. We first check that the full content of the internal
+     * subset is available and parsing is launched only at that point.
+     * Internal subset ends with "']' S? '>'" in an unescaped section and
+     * not in a ']]>' sequence which are conditional sections.
+     */
+    const xmlChar *cur, *start;
+    const xmlChar *end = ctxt->input->end;
+    int state = ctxt->endCheckState;
+    size_t index;
+
+    if (ctxt->checkIndex == 0) {
+        cur = ctxt->input->cur + 1;
     } else {
-        *lastlt = NULL;
-       *lastgt = NULL;
+        cur = ctxt->input->cur + ctxt->checkIndex;
+    }
+    start = cur;
+
+    while (cur < end) {
+        if (state == '-') {
+            if ((*cur == '-') &&
+                (cur[1] == '-') &&
+                (cur[2] == '>')) {
+                state = 0;
+                cur += 3;
+                start = cur;
+                continue;
+            }
+        }
+        else if (state == ']') {
+            if (*cur == '>') {
+                ctxt->checkIndex = 0;
+                ctxt->endCheckState = 0;
+                return(1);
+            }
+            if (IS_BLANK_CH(*cur)) {
+                state = ' ';
+            } else if (*cur != ']') {
+                state = 0;
+                start = cur;
+                continue;
+            }
+        }
+        else if (state == ' ') {
+            if (*cur == '>') {
+                ctxt->checkIndex = 0;
+                ctxt->endCheckState = 0;
+                return(1);
+            }
+            if (!IS_BLANK_CH(*cur)) {
+                state = 0;
+                start = cur;
+                continue;
+            }
+        }
+        else if (state != 0) {
+            if (*cur == state) {
+                state = 0;
+                start = cur + 1;
+            }
+        }
+        else if (*cur == '<') {
+            if ((cur[1] == '!') &&
+                (cur[2] == '-') &&
+                (cur[3] == '-')) {
+                state = '-';
+                cur += 4;
+                /* Don't treat <!--> as comment */
+                start = cur;
+                continue;
+            }
+        }
+        else if ((*cur == '"') || (*cur == '\'') || (*cur == ']')) {
+            state = *cur;
+        }
+
+        cur++;
+    }
+
+    /*
+     * Rescan the three last characters to detect "<!--" and "-->"
+     * split across chunks.
+     */
+    if ((state == 0) || (state == '-')) {
+        if (cur - start < 3)
+            cur = start;
+        else
+            cur -= 3;
+    }
+    index = cur - ctxt->input->cur;
+    if (index > LONG_MAX) {
+        ctxt->checkIndex = 0;
+        ctxt->endCheckState = 0;
+        return(1);
     }
+    ctxt->checkIndex = index;
+    ctxt->endCheckState = state;
+    return(0);
 }
+
 /**
  * xmlCheckCdataPush:
  * @cur: pointer to the block of characters
@@ -11192,103 +11589,22 @@ xmlCheckCdataPush(const xmlChar *utf, int len, int complete) {
 static int
 xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
     int ret = 0;
-    int avail, tlen;
+    size_t avail;
     xmlChar cur, next;
-    const xmlChar *lastlt, *lastgt;
 
     if (ctxt->input == NULL)
         return(0);
 
-#ifdef DEBUG_PUSH
-    switch (ctxt->instate) {
-       case XML_PARSER_EOF:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try EOF\n"); break;
-       case XML_PARSER_START:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try START\n"); break;
-       case XML_PARSER_MISC:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try MISC\n");break;
-       case XML_PARSER_COMMENT:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try COMMENT\n");break;
-       case XML_PARSER_PROLOG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try PROLOG\n");break;
-       case XML_PARSER_START_TAG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try START_TAG\n");break;
-       case XML_PARSER_CONTENT:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try CONTENT\n");break;
-       case XML_PARSER_CDATA_SECTION:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try CDATA_SECTION\n");break;
-       case XML_PARSER_END_TAG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try END_TAG\n");break;
-       case XML_PARSER_ENTITY_DECL:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try ENTITY_DECL\n");break;
-       case XML_PARSER_ENTITY_VALUE:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try ENTITY_VALUE\n");break;
-       case XML_PARSER_ATTRIBUTE_VALUE:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try ATTRIBUTE_VALUE\n");break;
-       case XML_PARSER_DTD:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try DTD\n");break;
-       case XML_PARSER_EPILOG:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try EPILOG\n");break;
-       case XML_PARSER_PI:
-           xmlGenericError(xmlGenericErrorContext,
-                   "PP: try PI\n");break;
-        case XML_PARSER_IGNORE:
-            xmlGenericError(xmlGenericErrorContext,
-                   "PP: try IGNORE\n");break;
-    }
-#endif
-
     if ((ctxt->input != NULL) &&
         (ctxt->input->cur - ctxt->input->base > 4096)) {
-       xmlSHRINK(ctxt);
-       ctxt->checkIndex = 0;
+        xmlParserShrink(ctxt);
     }
-    xmlParseGetLasts(ctxt, &lastlt, &lastgt);
 
     while (ctxt->instate != XML_PARSER_EOF) {
        if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
            return(0);
 
-       if (ctxt->input == NULL) break;
-       if (ctxt->input->buf == NULL)
-           avail = ctxt->input->length -
-                   (ctxt->input->cur - ctxt->input->base);
-       else {
-           /*
-            * If we are operating on converted input, try to flush
-            * remaining chars to avoid them stalling in the non-converted
-            * buffer. But do not do this in document start where
-            * encoding="..." may not have been read and we work on a
-            * guessed encoding.
-            */
-           if ((ctxt->instate != XML_PARSER_START) &&
-               (ctxt->input->buf->raw != NULL) &&
-               (xmlBufIsEmpty(ctxt->input->buf->raw) == 0)) {
-                size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer,
-                                                 ctxt->input);
-               size_t current = ctxt->input->cur - ctxt->input->base;
-
-               xmlParserInputBufferPush(ctxt->input->buf, 0, "");
-                xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input,
-                                      base, current);
-           }
-           avail = xmlBufUse(ctxt->input->buf->buffer) -
-                   (ctxt->input->cur - ctxt->input->base);
-       }
+        avail = ctxt->input->end - ctxt->input->cur;
         if (avail < 1)
            goto done;
         switch (ctxt->instate) {
@@ -11298,68 +11614,41 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                 */
                goto done;
             case XML_PARSER_START:
-               if (ctxt->charset == XML_CHAR_ENCODING_NONE) {
-                   xmlChar start[4];
-                   xmlCharEncoding enc;
+                /*
+                 * Very first chars read from the document flow.
+                 */
+                if ((!terminate) && (avail < 4))
+                    goto done;
 
-                   /*
-                    * Very first chars read from the document flow.
-                    */
-                   if (avail < 4)
-                       goto done;
+                /*
+                 * We need more bytes to detect EBCDIC code pages.
+                 * See xmlDetectEBCDIC.
+                 */
+                if ((CMP4(CUR_PTR, 0x4C, 0x6F, 0xA7, 0x94)) &&
+                    (!terminate) && (avail < 200))
+                    goto done;
 
-                   /*
-                    * Get the 4 first bytes and decode the charset
-                    * if enc != XML_CHAR_ENCODING_NONE
-                    * plug some encoding conversion routines,
-                    * else xmlSwitchEncoding will set to (default)
-                    * UTF8.
-                    */
-                   start[0] = RAW;
-                   start[1] = NXT(1);
-                   start[2] = NXT(2);
-                   start[3] = NXT(3);
-                   enc = xmlDetectCharEncoding(start, 4);
-                   xmlSwitchEncoding(ctxt, enc);
-                   break;
-               }
+                xmlDetectEncoding(ctxt);
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
+                ctxt->instate = XML_PARSER_XML_DECL;
+               break;
 
-               if (avail < 2)
+            case XML_PARSER_XML_DECL:
+               if ((!terminate) && (avail < 2))
                    goto done;
                cur = ctxt->input->cur[0];
                next = ctxt->input->cur[1];
-               if (cur == 0) {
-                   if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
-                       ctxt->sax->setDocumentLocator(ctxt->userData,
-                                                     &xmlDefaultSAXLocator);
-                   xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
-                   xmlHaltParser(ctxt);
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering EOF\n");
-#endif
-                   if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
-                       ctxt->sax->endDocument(ctxt->userData);
-                   goto done;
-               }
                if ((cur == '<') && (next == '?')) {
                    /* PI or XML decl */
-                   if (avail < 5) return(ret);
                    if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
-                       return(ret);
-                   if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
-                       ctxt->sax->setDocumentLocator(ctxt->userData,
-                                                     &xmlDefaultSAXLocator);
+                        (!xmlParseLookupString(ctxt, 2, "?>", 2)))
+                       goto done;
                    if ((ctxt->input->cur[2] == 'x') &&
                        (ctxt->input->cur[3] == 'm') &&
                        (ctxt->input->cur[4] == 'l') &&
                        (IS_BLANK_CH(ctxt->input->cur[5]))) {
                        ret += 5;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PP: Parsing XML Decl\n");
-#endif
                        xmlParseXMLDecl(ctxt);
                        if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
                            /*
@@ -11369,74 +11658,46 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                            xmlHaltParser(ctxt);
                            return(0);
                        }
-                       ctxt->standalone = ctxt->input->standalone;
-                       if ((ctxt->encoding == NULL) &&
-                           (ctxt->input->encoding != NULL))
-                           ctxt->encoding = xmlStrdup(ctxt->input->encoding);
-                       if ((ctxt->sax) && (ctxt->sax->startDocument) &&
-                           (!ctxt->disableSAX))
-                           ctxt->sax->startDocument(ctxt->userData);
-                       ctxt->instate = XML_PARSER_MISC;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PP: entering MISC\n");
-#endif
                    } else {
                        ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
-                       if ((ctxt->sax) && (ctxt->sax->startDocument) &&
-                           (!ctxt->disableSAX))
-                           ctxt->sax->startDocument(ctxt->userData);
-                       ctxt->instate = XML_PARSER_MISC;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PP: entering MISC\n");
-#endif
                    }
                } else {
-                   if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
-                       ctxt->sax->setDocumentLocator(ctxt->userData,
-                                                     &xmlDefaultSAXLocator);
                    ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
                    if (ctxt->version == NULL) {
                        xmlErrMemory(ctxt, NULL);
                        break;
                    }
-                   if ((ctxt->sax) && (ctxt->sax->startDocument) &&
-                       (!ctxt->disableSAX))
-                       ctxt->sax->startDocument(ctxt->userData);
-                   ctxt->instate = XML_PARSER_MISC;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering MISC\n");
-#endif
                }
+                if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
+                    ctxt->sax->setDocumentLocator(ctxt->userData,
+                                                  &xmlDefaultSAXLocator);
+                if ((ctxt->sax) && (ctxt->sax->startDocument) &&
+                    (!ctxt->disableSAX))
+                    ctxt->sax->startDocument(ctxt->userData);
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
+                ctxt->instate = XML_PARSER_MISC;
                break;
             case XML_PARSER_START_TAG: {
                const xmlChar *name;
                const xmlChar *prefix = NULL;
                const xmlChar *URI = NULL;
                 int line = ctxt->input->line;
-               int nsNr = ctxt->nsNr;
+               int nbNs = 0;
 
-               if ((avail < 2) && (ctxt->inputNr == 1))
+               if ((!terminate) && (avail < 2))
                    goto done;
                cur = ctxt->input->cur[0];
                if (cur != '<') {
-                   xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
+                   xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY,
+                                   "Start tag expected, '<' not found");
                    xmlHaltParser(ctxt);
                    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
                        ctxt->sax->endDocument(ctxt->userData);
                    goto done;
                }
-               if (!terminate) {
-                   if (ctxt->progressive) {
-                       /* > can be found unescaped in attribute values */
-                       if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
-                           goto done;
-                   } else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
-                       goto done;
-                   }
-               }
+               if ((!terminate) && (!xmlParseLookupGt(ctxt)))
+                    goto done;
                if (ctxt->spaceNr == 0)
                    spacePush(ctxt, -1);
                else if (*ctxt->space == -2)
@@ -11446,7 +11707,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
 #ifdef LIBXML_SAX1_ENABLED
                if (ctxt->sax2)
 #endif /* LIBXML_SAX1_ENABLED */
-                   name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen);
+                   name = xmlParseStartTag2(ctxt, &prefix, &URI, &nbNs);
 #ifdef LIBXML_SAX1_ENABLED
                else
                    name = xmlParseStartTag(ctxt);
@@ -11483,8 +11744,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                            (!ctxt->disableSAX))
                            ctxt->sax->endElementNs(ctxt->userData, name,
                                                    prefix, URI);
-                       if (ctxt->nsNr - nsNr > 0)
-                           nsPop(ctxt, ctxt->nsNr - nsNr);
+                       if (nbNs > 0)
+                           xmlParserNsPop(ctxt, nbNs);
 #ifdef LIBXML_SAX1_ENABLED
                    } else {
                        if ((ctxt->sax != NULL) &&
@@ -11493,93 +11754,87 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                            ctxt->sax->endElement(ctxt->userData, name);
 #endif /* LIBXML_SAX1_ENABLED */
                    }
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
                    spacePop(ctxt);
-                   if (ctxt->nameNr == 0) {
-                       ctxt->instate = XML_PARSER_EPILOG;
-                   } else {
-                       ctxt->instate = XML_PARSER_CONTENT;
-                   }
-                    ctxt->progressive = 1;
-                   break;
-               }
-               if (RAW == '>') {
+               } else if (RAW == '>') {
                    NEXT;
+                    nameNsPush(ctxt, name, prefix, URI, line, nbNs);
                } else {
                    xmlFatalErrMsgStr(ctxt, XML_ERR_GT_REQUIRED,
                                         "Couldn't find end of Start Tag %s\n",
                                         name);
                    nodePop(ctxt);
                    spacePop(ctxt);
+                    if (nbNs > 0)
+                        xmlParserNsPop(ctxt, nbNs);
                }
-                nameNsPush(ctxt, name, prefix, URI, line, ctxt->nsNr - nsNr);
 
-               ctxt->instate = XML_PARSER_CONTENT;
-                ctxt->progressive = 1;
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
+                if (ctxt->nameNr == 0)
+                    ctxt->instate = XML_PARSER_EPILOG;
+                else
+                    ctxt->instate = XML_PARSER_CONTENT;
                 break;
            }
             case XML_PARSER_CONTENT: {
-               int id;
-               unsigned long cons;
-               if ((avail < 2) && (ctxt->inputNr == 1))
-                   goto done;
                cur = ctxt->input->cur[0];
-               next = ctxt->input->cur[1];
 
-               id = ctxt->input->id;
-               cons = CUR_CONSUMED;
-               if ((cur == '<') && (next == '/')) {
-                   ctxt->instate = XML_PARSER_END_TAG;
-                   break;
-               } else if ((cur == '<') && (next == '?')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
-                        ctxt->progressive = XML_PARSER_PI;
-                       goto done;
-                    }
-                   xmlParsePI(ctxt);
-                   ctxt->instate = XML_PARSER_CONTENT;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (next != '!')) {
-                   ctxt->instate = XML_PARSER_START_TAG;
-                   break;
-               } else if ((cur == '<') && (next == '!') &&
-                          (ctxt->input->cur[2] == '-') &&
-                          (ctxt->input->cur[3] == '-')) {
-                   int term;
-
-                   if (avail < 4)
-                       goto done;
-                   ctxt->input->cur += 4;
-                   term = xmlParseLookupSequence(ctxt, '-', '-', '>');
-                   ctxt->input->cur -= 4;
-                   if ((!terminate) && (term < 0)) {
-                        ctxt->progressive = XML_PARSER_COMMENT;
-                       goto done;
+               if (cur == '<') {
+                    if ((!terminate) && (avail < 2))
+                        goto done;
+                   next = ctxt->input->cur[1];
+
+                    if (next == '/') {
+                        ctxt->instate = XML_PARSER_END_TAG;
+                        break;
+                    } else if (next == '?') {
+                        if ((!terminate) &&
+                            (!xmlParseLookupString(ctxt, 2, "?>", 2)))
+                            goto done;
+                        xmlParsePI(ctxt);
+                        if (ctxt->instate == XML_PARSER_EOF)
+                            goto done;
+                        ctxt->instate = XML_PARSER_CONTENT;
+                        break;
+                    } else if (next == '!') {
+                        if ((!terminate) && (avail < 3))
+                            goto done;
+                        next = ctxt->input->cur[2];
+
+                        if (next == '-') {
+                            if ((!terminate) && (avail < 4))
+                                goto done;
+                            if (ctxt->input->cur[3] == '-') {
+                                if ((!terminate) &&
+                                    (!xmlParseLookupString(ctxt, 4, "-->", 3)))
+                                    goto done;
+                                xmlParseComment(ctxt);
+                                if (ctxt->instate == XML_PARSER_EOF)
+                                    goto done;
+                                ctxt->instate = XML_PARSER_CONTENT;
+                                break;
+                            }
+                        } else if (next == '[') {
+                            if ((!terminate) && (avail < 9))
+                                goto done;
+                            if ((ctxt->input->cur[2] == '[') &&
+                                (ctxt->input->cur[3] == 'C') &&
+                                (ctxt->input->cur[4] == 'D') &&
+                                (ctxt->input->cur[5] == 'A') &&
+                                (ctxt->input->cur[6] == 'T') &&
+                                (ctxt->input->cur[7] == 'A') &&
+                                (ctxt->input->cur[8] == '[')) {
+                                SKIP(9);
+                                ctxt->instate = XML_PARSER_CDATA_SECTION;
+                                break;
+                            }
+                        }
                     }
-                   xmlParseComment(ctxt);
-                   ctxt->instate = XML_PARSER_CONTENT;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (ctxt->input->cur[1] == '!') &&
-                   (ctxt->input->cur[2] == '[') &&
-                   (ctxt->input->cur[3] == 'C') &&
-                   (ctxt->input->cur[4] == 'D') &&
-                   (ctxt->input->cur[5] == 'A') &&
-                   (ctxt->input->cur[6] == 'T') &&
-                   (ctxt->input->cur[7] == 'A') &&
-                   (ctxt->input->cur[8] == '[')) {
-                   SKIP(9);
-                   ctxt->instate = XML_PARSER_CDATA_SECTION;
-                   break;
-               } else if ((cur == '<') && (next == '!') &&
-                          (avail < 9)) {
-                   goto done;
                } else if (cur == '&') {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
+                   if ((!terminate) && (!xmlParseLookupChar(ctxt, ';')))
                        goto done;
                    xmlParseReference(ctxt);
+                    break;
                } else {
                    /* TODO Avoid the extra copy, handle directly !!! */
                    /*
@@ -11593,42 +11848,21 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                     *    callbacks between the push and pull versions
                     *    of the parser.
                     */
-                   if ((ctxt->inputNr == 1) &&
-                       (avail < XML_PARSER_BIG_BUFFER_SIZE)) {
-                       if (!terminate) {
-                           if (ctxt->progressive) {
-                               if ((lastlt == NULL) ||
-                                   (ctxt->input->cur > lastlt))
-                                   goto done;
-                           } else if (xmlParseLookupSequence(ctxt,
-                                                             '<', 0, 0) < 0) {
-                               goto done;
-                           }
-                       }
+                   if (avail < XML_PARSER_BIG_BUFFER_SIZE) {
+                       if ((!terminate) && (!xmlParseLookupCharData(ctxt)))
+                           goto done;
                     }
-                   ctxt->checkIndex = 0;
-                   xmlParseCharData(ctxt, 0);
-               }
-               if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
-                   xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
-                               "detected an error in element content\n");
-                   xmlHaltParser(ctxt);
-                   break;
+                    ctxt->checkIndex = 0;
+                   xmlParseCharDataInternal(ctxt, !terminate);
+                    break;
                }
+
+                ctxt->instate = XML_PARSER_START_TAG;
                break;
            }
             case XML_PARSER_END_TAG:
-               if (avail < 2)
+               if ((!terminate) && (!xmlParseLookupChar(ctxt, '>')))
                    goto done;
-               if (!terminate) {
-                   if (ctxt->progressive) {
-                       /* > can be found unescaped in attribute values */
-                       if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
-                           goto done;
-                   } else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
-                       goto done;
-                   }
-               }
                if (ctxt->sax2) {
                    xmlParseEndTag2(ctxt, &ctxt->pushTab[ctxt->nameNr - 1]);
                    nameNsPop(ctxt);
@@ -11637,9 +11871,9 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                  else
                    xmlParseEndTag1(ctxt, 0);
 #endif /* LIBXML_SAX1_ENABLED */
-               if (ctxt->instate == XML_PARSER_EOF) {
-                   /* Nothing */
-               } else if (ctxt->nameNr == 0) {
+                if (ctxt->instate == XML_PARSER_EOF)
+                    goto done;
+               if (ctxt->nameNr == 0) {
                    ctxt->instate = XML_PARSER_EPILOG;
                } else {
                    ctxt->instate = XML_PARSER_CONTENT;
@@ -11650,35 +11884,51 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                 * The Push mode need to have the SAX callback for
                 * cdataBlock merge back contiguous callbacks.
                 */
-               int base;
-
-               base = xmlParseLookupSequence(ctxt, ']', ']', '>');
-               if (base < 0) {
-                   if (avail >= XML_PARSER_BIG_BUFFER_SIZE + 2) {
-                       int tmp;
-
-                       tmp = xmlCheckCdataPush(ctxt->input->cur,
-                                               XML_PARSER_BIG_BUFFER_SIZE, 0);
-                       if (tmp < 0) {
-                           tmp = -tmp;
-                           ctxt->input->cur += tmp;
-                           goto encoding_error;
-                       }
-                       if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
-                           if (ctxt->sax->cdataBlock != NULL)
-                               ctxt->sax->cdataBlock(ctxt->userData,
-                                                     ctxt->input->cur, tmp);
-                           else if (ctxt->sax->characters != NULL)
-                               ctxt->sax->characters(ctxt->userData,
-                                                     ctxt->input->cur, tmp);
-                       }
-                       if (ctxt->instate == XML_PARSER_EOF)
-                           goto done;
-                       SKIPL(tmp);
-                       ctxt->checkIndex = 0;
-                   }
-                   goto done;
+               const xmlChar *term;
+
+                if (terminate) {
+                    /*
+                     * Don't call xmlParseLookupString. If 'terminate'
+                     * is set, checkIndex is invalid.
+                     */
+                    term = BAD_CAST strstr((const char *) ctxt->input->cur,
+                                           "]]>");
+                } else {
+                   term = xmlParseLookupString(ctxt, 0, "]]>", 3);
+                }
+
+               if (term == NULL) {
+                   int tmp, size;
+
+                    if (terminate) {
+                        /* Unfinished CDATA section */
+                        size = ctxt->input->end - ctxt->input->cur;
+                    } else {
+                        if (avail < XML_PARSER_BIG_BUFFER_SIZE + 2)
+                            goto done;
+                        ctxt->checkIndex = 0;
+                        /* XXX: Why don't we pass the full buffer? */
+                        size = XML_PARSER_BIG_BUFFER_SIZE;
+                    }
+                    tmp = xmlCheckCdataPush(ctxt->input->cur, size, 0);
+                    if (tmp <= 0) {
+                        tmp = -tmp;
+                        ctxt->input->cur += tmp;
+                        goto encoding_error;
+                    }
+                    if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
+                        if (ctxt->sax->cdataBlock != NULL)
+                            ctxt->sax->cdataBlock(ctxt->userData,
+                                                  ctxt->input->cur, tmp);
+                        else if (ctxt->sax->characters != NULL)
+                            ctxt->sax->characters(ctxt->userData,
+                                                  ctxt->input->cur, tmp);
+                    }
+                    if (ctxt->instate == XML_PARSER_EOF)
+                        goto done;
+                    SKIPL(tmp);
                } else {
+                    int base = term - CUR_PTR;
                    int tmp;
 
                    tmp = xmlCheckCdataPush(ctxt->input->cur, base, 1);
@@ -11712,346 +11962,101 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
                    if (ctxt->instate == XML_PARSER_EOF)
                        goto done;
                    SKIPL(base + 3);
-                   ctxt->checkIndex = 0;
                    ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering CONTENT\n");
-#endif
                }
                break;
            }
             case XML_PARSER_MISC:
-               SKIP_BLANKS;
-               if (ctxt->input->buf == NULL)
-                   avail = ctxt->input->length -
-                           (ctxt->input->cur - ctxt->input->base);
-               else
-                   avail = xmlBufUse(ctxt->input->buf->buffer) -
-                           (ctxt->input->cur - ctxt->input->base);
-               if (avail < 2)
-                   goto done;
-               cur = ctxt->input->cur[0];
-               next = ctxt->input->cur[1];
-               if ((cur == '<') && (next == '?')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
-                        ctxt->progressive = XML_PARSER_PI;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing PI\n");
-#endif
-                   xmlParsePI(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_MISC;
-                    ctxt->progressive = 1;
-                   ctxt->checkIndex = 0;
-               } else if ((cur == '<') && (next == '!') &&
-                   (ctxt->input->cur[2] == '-') &&
-                   (ctxt->input->cur[3] == '-')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
-                        ctxt->progressive = XML_PARSER_COMMENT;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing Comment\n");
-#endif
-                   xmlParseComment(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_MISC;
-                    ctxt->progressive = 1;
-                   ctxt->checkIndex = 0;
-               } else if ((cur == '<') && (next == '!') &&
-                   (ctxt->input->cur[2] == 'D') &&
-                   (ctxt->input->cur[3] == 'O') &&
-                   (ctxt->input->cur[4] == 'C') &&
-                   (ctxt->input->cur[5] == 'T') &&
-                   (ctxt->input->cur[6] == 'Y') &&
-                   (ctxt->input->cur[7] == 'P') &&
-                   (ctxt->input->cur[8] == 'E')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0)) {
-                        ctxt->progressive = XML_PARSER_DTD;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing internal subset\n");
-#endif
-                   ctxt->inSubset = 1;
-                    ctxt->progressive = 0;
-                   ctxt->checkIndex = 0;
-                   xmlParseDocTypeDecl(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   if (RAW == '[') {
-                       ctxt->instate = XML_PARSER_DTD;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PP: entering DTD\n");
-#endif
-                   } else {
-                       /*
-                        * Create and update the external subset.
-                        */
-                       ctxt->inSubset = 2;
-                       if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
-                           (ctxt->sax->externalSubset != NULL))
-                           ctxt->sax->externalSubset(ctxt->userData,
-                                   ctxt->intSubName, ctxt->extSubSystem,
-                                   ctxt->extSubURI);
-                       ctxt->inSubset = 0;
-                       xmlCleanSpecialAttr(ctxt);
-                       ctxt->instate = XML_PARSER_PROLOG;
-#ifdef DEBUG_PUSH
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PP: entering PROLOG\n");
-#endif
-                   }
-               } else if ((cur == '<') && (next == '!') &&
-                          (avail < 9)) {
-                   goto done;
-               } else {
-                   ctxt->instate = XML_PARSER_START_TAG;
-                   ctxt->progressive = XML_PARSER_START_TAG;
-                   xmlParseGetLasts(ctxt, &lastlt, &lastgt);
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering START_TAG\n");
-#endif
-               }
-               break;
             case XML_PARSER_PROLOG:
-               SKIP_BLANKS;
-               if (ctxt->input->buf == NULL)
-                   avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
-               else
-                   avail = xmlBufUse(ctxt->input->buf->buffer) -
-                            (ctxt->input->cur - ctxt->input->base);
-               if (avail < 2)
-                   goto done;
-               cur = ctxt->input->cur[0];
-               next = ctxt->input->cur[1];
-               if ((cur == '<') && (next == '?')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
-                        ctxt->progressive = XML_PARSER_PI;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing PI\n");
-#endif
-                   xmlParsePI(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_PROLOG;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (next == '!') &&
-                   (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
-                        ctxt->progressive = XML_PARSER_COMMENT;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing Comment\n");
-#endif
-                   xmlParseComment(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_PROLOG;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (next == '!') &&
-                          (avail < 4)) {
-                   goto done;
-               } else {
-                   ctxt->instate = XML_PARSER_START_TAG;
-                   if (ctxt->progressive == 0)
-                       ctxt->progressive = XML_PARSER_START_TAG;
-                   xmlParseGetLasts(ctxt, &lastlt, &lastgt);
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering START_TAG\n");
-#endif
-               }
-               break;
             case XML_PARSER_EPILOG:
                SKIP_BLANKS;
-               if (ctxt->input->buf == NULL)
-                   avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
-               else
-                   avail = xmlBufUse(ctxt->input->buf->buffer) -
-                            (ctxt->input->cur - ctxt->input->base);
-               if (avail < 2)
+                avail = ctxt->input->end - ctxt->input->cur;
+               if (avail < 1)
                    goto done;
-               cur = ctxt->input->cur[0];
-               next = ctxt->input->cur[1];
-               if ((cur == '<') && (next == '?')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
-                        ctxt->progressive = XML_PARSER_PI;
-                       goto done;
-                    }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing PI\n");
-#endif
-                   xmlParsePI(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_EPILOG;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (next == '!') &&
-                   (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
-                   if ((!terminate) &&
-                       (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
-                        ctxt->progressive = XML_PARSER_COMMENT;
-                       goto done;
+               if (ctxt->input->cur[0] == '<') {
+                    if ((!terminate) && (avail < 2))
+                        goto done;
+                    next = ctxt->input->cur[1];
+                    if (next == '?') {
+                        if ((!terminate) &&
+                            (!xmlParseLookupString(ctxt, 2, "?>", 2)))
+                            goto done;
+                        xmlParsePI(ctxt);
+                        if (ctxt->instate == XML_PARSER_EOF)
+                            goto done;
+                        break;
+                    } else if (next == '!') {
+                        if ((!terminate) && (avail < 3))
+                            goto done;
+
+                        if (ctxt->input->cur[2] == '-') {
+                            if ((!terminate) && (avail < 4))
+                                goto done;
+                            if (ctxt->input->cur[3] == '-') {
+                                if ((!terminate) &&
+                                    (!xmlParseLookupString(ctxt, 4, "-->", 3)))
+                                    goto done;
+                                xmlParseComment(ctxt);
+                                if (ctxt->instate == XML_PARSER_EOF)
+                                    goto done;
+                                break;
+                            }
+                        } else if (ctxt->instate == XML_PARSER_MISC) {
+                            if ((!terminate) && (avail < 9))
+                                goto done;
+                            if ((ctxt->input->cur[2] == 'D') &&
+                                (ctxt->input->cur[3] == 'O') &&
+                                (ctxt->input->cur[4] == 'C') &&
+                                (ctxt->input->cur[5] == 'T') &&
+                                (ctxt->input->cur[6] == 'Y') &&
+                                (ctxt->input->cur[7] == 'P') &&
+                                (ctxt->input->cur[8] == 'E')) {
+                                if ((!terminate) && (!xmlParseLookupGt(ctxt)))
+                                    goto done;
+                                ctxt->inSubset = 1;
+                                xmlParseDocTypeDecl(ctxt);
+                                if (ctxt->instate == XML_PARSER_EOF)
+                                    goto done;
+                                if (RAW == '[') {
+                                    ctxt->instate = XML_PARSER_DTD;
+                                } else {
+                                    /*
+                                     * Create and update the external subset.
+                                     */
+                                    ctxt->inSubset = 2;
+                                    if ((ctxt->sax != NULL) &&
+                                        (!ctxt->disableSAX) &&
+                                        (ctxt->sax->externalSubset != NULL))
+                                        ctxt->sax->externalSubset(
+                                                ctxt->userData,
+                                                ctxt->intSubName,
+                                                ctxt->extSubSystem,
+                                                ctxt->extSubURI);
+                                    ctxt->inSubset = 0;
+                                    xmlCleanSpecialAttr(ctxt);
+                                    if (ctxt->instate == XML_PARSER_EOF)
+                                        goto done;
+                                    ctxt->instate = XML_PARSER_PROLOG;
+                                }
+                                break;
+                            }
+                        }
                     }
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: Parsing Comment\n");
-#endif
-                   xmlParseComment(ctxt);
-                   if (ctxt->instate == XML_PARSER_EOF)
-                       goto done;
-                   ctxt->instate = XML_PARSER_EPILOG;
-                    ctxt->progressive = 1;
-               } else if ((cur == '<') && (next == '!') &&
-                          (avail < 4)) {
-                   goto done;
-               } else {
-                   xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
-                   xmlHaltParser(ctxt);
-#ifdef DEBUG_PUSH
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: entering EOF\n");
-#endif
-                   if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
-                       ctxt->sax->endDocument(ctxt->userData);
-                   goto done;
+                }
+
+                if (ctxt->instate == XML_PARSER_EPILOG) {
+                    if (ctxt->errNo == XML_ERR_OK)
+                        xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
+                   ctxt->instate = XML_PARSER_EOF;
+                    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
+                        ctxt->sax->endDocument(ctxt->userData);
+                } else {
+                   ctxt->instate = XML_PARSER_START_TAG;
                }
                break;
             case XML_PARSER_DTD: {
-               /*
-                * Sorry but progressive parsing of the internal subset
-                * is not expected to be supported. We first check that
-                * the full content of the internal subset is available and
-                * the parsing is launched only at that point.
-                * Internal subset ends up with "']' S? '>'" in an unescaped
-                * section and not in a ']]>' sequence which are conditional
-                * sections (whoever argued to keep that crap in XML deserve
-                * a place in hell !).
-                */
-               int base, i;
-               xmlChar *buf;
-               xmlChar quote = 0;
-                size_t use;
-
-               base = ctxt->input->cur - ctxt->input->base;
-               if (base < 0) return(0);
-               if (ctxt->checkIndex > base)
-                   base = ctxt->checkIndex;
-               buf = xmlBufContent(ctxt->input->buf->buffer);
-                use = xmlBufUse(ctxt->input->buf->buffer);
-               for (;(unsigned int) base < use; base++) {
-                   if (quote != 0) {
-                       if (buf[base] == quote)
-                           quote = 0;
-                       continue;
-                   }
-                   if ((quote == 0) && (buf[base] == '<')) {
-                       int found  = 0;
-                       /* special handling of comments */
-                       if (((unsigned int) base + 4 < use) &&
-                           (buf[base + 1] == '!') &&
-                           (buf[base + 2] == '-') &&
-                           (buf[base + 3] == '-')) {
-                           for (;(unsigned int) base + 3 < use; base++) {
-                               if ((buf[base] == '-') &&
-                                   (buf[base + 1] == '-') &&
-                                   (buf[base + 2] == '>')) {
-                                   found = 1;
-                                   base += 2;
-                                   break;
-                               }
-                           }
-                           if (!found) {
-#if 0
-                               fprintf(stderr, "unfinished comment\n");
-#endif
-                               break; /* for */
-                           }
-                           continue;
-                       }
-                   }
-                   if (buf[base] == '"') {
-                       quote = '"';
-                       continue;
-                   }
-                   if (buf[base] == '\'') {
-                       quote = '\'';
-                       continue;
-                   }
-                   if (buf[base] == ']') {
-#if 0
-                       fprintf(stderr, "%c%c%c%c: ", buf[base],
-                               buf[base + 1], buf[base + 2], buf[base + 3]);
-#endif
-                       if ((unsigned int) base +1 >= use)
-                           break;
-                       if (buf[base + 1] == ']') {
-                           /* conditional crap, skip both ']' ! */
-                           base++;
-                           continue;
-                       }
-                       for (i = 1; (unsigned int) base + i < use; i++) {
-                           if (buf[base + i] == '>') {
-#if 0
-                               fprintf(stderr, "found\n");
-#endif
-                               goto found_end_int_subset;
-                           }
-                           if (!IS_BLANK_CH(buf[base + i])) {
-#if 0
-                               fprintf(stderr, "not found\n");
-#endif
-                               goto not_end_of_int_subset;
-                           }
-                       }
-#if 0
-                       fprintf(stderr, "end of stream\n");
-#endif
-                       break;
-
-                   }
-not_end_of_int_subset:
-                    continue; /* for */
-               }
-               /*
-                * We didn't found the end of the Internal subset
-                */
-                if (quote == 0)
-                    ctxt->checkIndex = base;
-                else
-                    ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               if (next == 0)
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PP: lookup of int subset end filed\n");
-#endif
-               goto done;
-
-found_end_int_subset:
-                ctxt->checkIndex = 0;
+                if ((!terminate) && (!xmlParseLookupInternalSubset(ctxt)))
+                    goto done;
                xmlParseInternalSubset(ctxt);
                if (ctxt->instate == XML_PARSER_EOF)
                    goto done;
@@ -12065,94 +12070,23 @@ found_end_int_subset:
                if (ctxt->instate == XML_PARSER_EOF)
                    goto done;
                ctxt->instate = XML_PARSER_PROLOG;
-               ctxt->checkIndex = 0;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering PROLOG\n");
-#endif
                 break;
            }
-            case XML_PARSER_COMMENT:
+            default:
                xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == COMMENT\n");
-               ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_IGNORE:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == IGNORE");
-               ctxt->instate = XML_PARSER_DTD;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering DTD\n");
-#endif
-               break;
-            case XML_PARSER_PI:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == PI\n");
-               ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering CONTENT\n");
-#endif
-               break;
-            case XML_PARSER_ENTITY_DECL:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == ENTITY_DECL\n");
-               ctxt->instate = XML_PARSER_DTD;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering DTD\n");
-#endif
-               break;
-            case XML_PARSER_ENTITY_VALUE:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == ENTITY_VALUE\n");
-               ctxt->instate = XML_PARSER_CONTENT;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering DTD\n");
-#endif
-               break;
-            case XML_PARSER_ATTRIBUTE_VALUE:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == ATTRIBUTE_VALUE\n");
-               ctxt->instate = XML_PARSER_START_TAG;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering START_TAG\n");
-#endif
-               break;
-            case XML_PARSER_SYSTEM_LITERAL:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == SYSTEM_LITERAL\n");
-               ctxt->instate = XML_PARSER_START_TAG;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering START_TAG\n");
-#endif
-               break;
-            case XML_PARSER_PUBLIC_LITERAL:
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: internal error, state == PUBLIC_LITERAL\n");
-               ctxt->instate = XML_PARSER_START_TAG;
-#ifdef DEBUG_PUSH
-               xmlGenericError(xmlGenericErrorContext,
-                       "PP: entering START_TAG\n");
-#endif
+                       "PP: internal error\n");
+               ctxt->instate = XML_PARSER_EOF;
                break;
        }
     }
 done:
-#ifdef DEBUG_PUSH
-    xmlGenericError(xmlGenericErrorContext, "PP: done %d\n", ret);
-#endif
     return(ret);
 encoding_error:
-    {
+    if (ctxt->input->end - ctxt->input->cur < 4) {
+       __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+                    "Input is not proper UTF-8, indicate encoding !\n",
+                    NULL, NULL);
+    } else {
         char buffer[150];
 
        snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
@@ -12166,55 +12100,6 @@ encoding_error:
 }
 
 /**
- * xmlParseCheckTransition:
- * @ctxt:  an XML parser context
- * @chunk:  a char array
- * @size:  the size in byte of the chunk
- *
- * Check depending on the current parser state if the chunk given must be
- * processed immediately or one need more data to advance on parsing.
- *
- * Returns -1 in case of error, 0 if the push is not needed and 1 if needed
- */
-static int
-xmlParseCheckTransition(xmlParserCtxtPtr ctxt, const char *chunk, int size) {
-    if ((ctxt == NULL) || (chunk == NULL) || (size < 0))
-        return(-1);
-    if (ctxt->instate == XML_PARSER_START_TAG) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    if (ctxt->progressive == XML_PARSER_COMMENT) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    if (ctxt->instate == XML_PARSER_CDATA_SECTION) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    if (ctxt->progressive == XML_PARSER_PI) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    if (ctxt->instate == XML_PARSER_END_TAG) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    if ((ctxt->progressive == XML_PARSER_DTD) ||
-        (ctxt->instate == XML_PARSER_DTD)) {
-        if (memchr(chunk, '>', size) != NULL)
-            return(1);
-        return(0);
-    }
-    return(1);
-}
-
-/**
  * xmlParseChunk:
  * @ctxt:  an XML parser context
  * @chunk:  an char array
@@ -12229,9 +12114,6 @@ int
 xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
               int terminate) {
     int end_in_lf = 0;
-    int remain = 0;
-    size_t old_avail = 0;
-    size_t avail = 0;
 
     if (ctxt == NULL)
         return(XML_ERR_INTERNAL_ERROR);
@@ -12239,6 +12121,10 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
         return(ctxt->errNo);
     if (ctxt->instate == XML_PARSER_EOF)
         return(-1);
+    if (ctxt->input == NULL)
+        return(-1);
+
+    ctxt->progressive = 1;
     if (ctxt->instate == XML_PARSER_START)
         xmlDetectSAX2(ctxt);
     if ((size > 0) && (chunk != NULL) && (!terminate) &&
@@ -12247,100 +12133,21 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
        size--;
     }
 
-xmldecl_done:
-
     if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF))  {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
-       size_t cur = ctxt->input->cur - ctxt->input->base;
+       size_t pos = ctxt->input->cur - ctxt->input->base;
        int res;
 
-        old_avail = xmlBufUse(ctxt->input->buf->buffer);
-        /*
-         * Specific handling if we autodetected an encoding, we should not
-         * push more than the first line ... which depend on the encoding
-         * And only push the rest once the final encoding was detected
-         */
-        if ((ctxt->instate == XML_PARSER_START) && (ctxt->input != NULL) &&
-            (ctxt->input->buf != NULL) && (ctxt->input->buf->encoder != NULL)) {
-            unsigned int len = 45;
-
-            if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
-                               BAD_CAST "UTF-16")) ||
-                (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
-                               BAD_CAST "UTF16")))
-                len = 90;
-            else if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
-                                    BAD_CAST "UCS-4")) ||
-                     (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
-                                    BAD_CAST "UCS4")))
-                len = 180;
-
-            if (ctxt->input->buf->rawconsumed < len)
-                len -= ctxt->input->buf->rawconsumed;
-
-            /*
-             * Change size for reading the initial declaration only
-             * if size is greater than len. Otherwise, memmove in xmlBufferAdd
-             * will blindly copy extra bytes from memory.
-             */
-            if ((unsigned int) size > len) {
-                remain = size - len;
-                size = len;
-            } else {
-                remain = 0;
-            }
-        }
        res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
+        xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
        if (res < 0) {
-           ctxt->errNo = XML_PARSER_EOF;
+            xmlFatalErr(ctxt, ctxt->input->buf->error, NULL);
            xmlHaltParser(ctxt);
-           return (XML_PARSER_EOF);
-       }
-#ifdef DEBUG_PUSH
-       xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
-#endif
-
-    } else if (ctxt->instate != XML_PARSER_EOF) {
-       if ((ctxt->input != NULL) && ctxt->input->buf != NULL) {
-           xmlParserInputBufferPtr in = ctxt->input->buf;
-           if ((in->encoder != NULL) && (in->buffer != NULL) &&
-                   (in->raw != NULL)) {
-               int nbchars;
-               size_t base = xmlBufGetInputBase(in->buffer, ctxt->input);
-               size_t current = ctxt->input->cur - ctxt->input->base;
-
-               nbchars = xmlCharEncInput(in, terminate);
-               xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
-               if (nbchars < 0) {
-                   /* TODO 2.6.0 */
-                   xmlGenericError(xmlGenericErrorContext,
-                                   "xmlParseChunk: encoder error\n");
-                    xmlHaltParser(ctxt);
-                   return(XML_ERR_INVALID_ENCODING);
-               }
-           }
+           return(ctxt->errNo);
        }
     }
-    if (remain != 0) {
-        xmlParseTryOrFinish(ctxt, 0);
-    } else {
-        if ((ctxt->input != NULL) && (ctxt->input->buf != NULL))
-            avail = xmlBufUse(ctxt->input->buf->buffer);
-        /*
-         * Depending on the current state it may not be such
-         * a good idea to try parsing if there is nothing in the chunk
-         * which would be worth doing a parser state transition and we
-         * need to wait for more data
-         */
-        if ((terminate) || (avail > XML_MAX_TEXT_LENGTH) ||
-            (old_avail == 0) || (avail == 0) ||
-            (xmlParseCheckTransition(ctxt,
-                       (const char *)&ctxt->input->base[old_avail],
-                                     avail - old_avail)))
-            xmlParseTryOrFinish(ctxt, terminate);
-    }
+
+    xmlParseTryOrFinish(ctxt, terminate);
     if (ctxt->instate == XML_PARSER_EOF)
         return(ctxt->errNo);
 
@@ -12354,45 +12161,43 @@ xmldecl_done:
     if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
         return(ctxt->errNo);
 
-    if (remain != 0) {
-        chunk += size;
-        size = remain;
-        remain = 0;
-        goto xmldecl_done;
-    }
     if ((end_in_lf == 1) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL)) {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer,
-                                        ctxt->input);
-       size_t current = ctxt->input->cur - ctxt->input->base;
-
-       xmlParserInputBufferPush(ctxt->input->buf, 1, "\r");
+       size_t pos = ctxt->input->cur - ctxt->input->base;
+        int res;
 
-       xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input,
-                             base, current);
+       res = xmlParserInputBufferPush(ctxt->input->buf, 1, "\r");
+       xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
+        if (res < 0) {
+            xmlFatalErr(ctxt, ctxt->input->buf->error, NULL);
+            xmlHaltParser(ctxt);
+            return(ctxt->errNo);
+        }
     }
     if (terminate) {
        /*
         * Check for termination
         */
-       int cur_avail = 0;
-
-       if (ctxt->input != NULL) {
-           if (ctxt->input->buf == NULL)
-               cur_avail = ctxt->input->length -
-                           (ctxt->input->cur - ctxt->input->base);
-           else
-               cur_avail = xmlBufUse(ctxt->input->buf->buffer) -
-                                     (ctxt->input->cur - ctxt->input->base);
-       }
-
-       if ((ctxt->instate != XML_PARSER_EOF) &&
-           (ctxt->instate != XML_PARSER_EPILOG)) {
-           xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
-       }
-       if ((ctxt->instate == XML_PARSER_EPILOG) && (cur_avail > 0)) {
-           xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
-       }
+        if ((ctxt->instate != XML_PARSER_EOF) &&
+            (ctxt->instate != XML_PARSER_EPILOG)) {
+            if (ctxt->nameNr > 0) {
+                const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
+                int line = ctxt->pushTab[ctxt->nameNr - 1].line;
+                xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
+                        "Premature end of data in tag %s line %d\n",
+                        name, line, NULL);
+            } else if (ctxt->instate == XML_PARSER_START) {
+                xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
+            } else {
+                xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY,
+                               "Start tag expected, '<' not found\n");
+            }
+        } else if ((ctxt->input->buf != NULL) &&
+                   (ctxt->input->buf->encoder != NULL) &&
+                   (!xmlBufIsEmpty(ctxt->input->buf->raw))) {
+            xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
+                           "Truncated multi-byte sequence at EOF\n");
+        }
        if (ctxt->instate != XML_PARSER_EOF) {
            if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
                ctxt->sax->endDocument(ctxt->userData);
@@ -12436,44 +12241,17 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
     xmlParserCtxtPtr ctxt;
     xmlParserInputPtr inputStream;
     xmlParserInputBufferPtr buf;
-    xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
-
-    /*
-     * plug some encoding conversion routines
-     */
-    if ((chunk != NULL) && (size >= 4))
-       enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
 
-    buf = xmlAllocParserInputBuffer(enc);
+    buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
     if (buf == NULL) return(NULL);
 
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(sax, user_data);
     if (ctxt == NULL) {
         xmlErrMemory(NULL, "creating parser: out of memory\n");
        xmlFreeParserInputBuffer(buf);
        return(NULL);
     }
     ctxt->dictNames = 1;
-    if (sax != NULL) {
-#ifdef LIBXML_SAX1_ENABLED
-       if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
-#endif /* LIBXML_SAX1_ENABLED */
-           xmlFree(ctxt->sax);
-       ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
-       if (ctxt->sax == NULL) {
-           xmlErrMemory(ctxt, NULL);
-           xmlFreeParserInputBuffer(buf);
-           xmlFreeParserCtxt(ctxt);
-           return(NULL);
-       }
-       memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
-       if (sax->initialized == XML_SAX2_MAGIC)
-           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
-       else
-           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
-       if (user_data != NULL)
-           ctxt->userData = user_data;
-    }
     if (filename == NULL) {
        ctxt->directory = NULL;
     } else {
@@ -12493,6 +12271,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
        inputStream->filename = (char *)
            xmlCanonicPath((const xmlChar *) filename);
        if (inputStream->filename == NULL) {
+            xmlFreeInputStream(inputStream);
            xmlFreeParserCtxt(ctxt);
            xmlFreeParserInputBuffer(buf);
            return(NULL);
@@ -12502,27 +12281,17 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
     xmlBufResetInput(inputStream->buf->buffer, inputStream);
     inputPush(ctxt, inputStream);
 
-    /*
-     * If the caller didn't provide an initial 'chunk' for determining
-     * the encoding, we set the context to XML_CHAR_ENCODING_NONE so
-     * that it can be automatically determined later
-     */
-    if ((size == 0) || (chunk == NULL)) {
-       ctxt->charset = XML_CHAR_ENCODING_NONE;
-    } else if ((ctxt->input != NULL) && (ctxt->input->buf != NULL)) {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
-       size_t cur = ctxt->input->cur - ctxt->input->base;
-
-       xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+    if ((size != 0) && (chunk != NULL) &&
+        (ctxt->input != NULL) && (ctxt->input->buf != NULL)) {
+       size_t pos = ctxt->input->cur - ctxt->input->base;
+        int res;
 
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
-#ifdef DEBUG_PUSH
-       xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
-#endif
-    }
-
-    if (enc != XML_CHAR_ENCODING_NONE) {
-        xmlSwitchEncoding(ctxt, enc);
+       res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+        xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
+        if (res < 0) {
+            xmlFatalErr(ctxt, ctxt->input->buf->error, NULL);
+            xmlHaltParser(ctxt);
+        }
     }
 
     return(ctxt);
@@ -12530,41 +12299,6 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
 #endif /* LIBXML_PUSH_ENABLED */
 
 /**
- * xmlHaltParser:
- * @ctxt:  an XML parser context
- *
- * Blocks further parser processing don't override error
- * for internal use
- */
-static void
-xmlHaltParser(xmlParserCtxtPtr ctxt) {
-    if (ctxt == NULL)
-        return;
-    ctxt->instate = XML_PARSER_EOF;
-    ctxt->disableSAX = 1;
-    while (ctxt->inputNr > 1)
-        xmlFreeInputStream(inputPop(ctxt));
-    if (ctxt->input != NULL) {
-        /*
-        * in case there was a specific allocation deallocate before
-        * overriding base
-        */
-        if (ctxt->input->free != NULL) {
-           ctxt->input->free((xmlChar *) ctxt->input->base);
-           ctxt->input->free = NULL;
-       }
-        if (ctxt->input->buf != NULL) {
-            xmlFreeParserInputBuffer(ctxt->input->buf);
-            ctxt->input->buf = NULL;
-        }
-       ctxt->input->cur = BAD_CAST"";
-        ctxt->input->length = 0;
-       ctxt->input->base = ctxt->input->cur;
-        ctxt->input->end = ctxt->input->cur;
-    }
-}
-
-/**
  * xmlStopParser:
  * @ctxt:  an XML parser context
  *
@@ -12609,31 +12343,11 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
         return (NULL);
     }
 
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(sax, user_data);
     if (ctxt == NULL) {
        xmlFreeParserInputBuffer(buf);
        return(NULL);
     }
-    if (sax != NULL) {
-#ifdef LIBXML_SAX1_ENABLED
-       if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
-#endif /* LIBXML_SAX1_ENABLED */
-           xmlFree(ctxt->sax);
-       ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
-       if (ctxt->sax == NULL) {
-           xmlFreeParserInputBuffer(buf);
-           xmlErrMemory(ctxt, NULL);
-           xmlFreeParserCtxt(ctxt);
-           return(NULL);
-       }
-       memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
-       if (sax->initialized == XML_SAX2_MAGIC)
-           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
-       else
-           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
-       if (user_data != NULL)
-           ctxt->userData = user_data;
-    }
 
     inputStream = xmlNewIOInputStream(ctxt, buf, enc);
     if (inputStream == NULL) {
@@ -12670,12 +12384,11 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
     xmlDtdPtr ret = NULL;
     xmlParserCtxtPtr ctxt;
     xmlParserInputPtr pinput = NULL;
-    xmlChar start[4];
 
     if (input == NULL)
        return(NULL);
 
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(sax, NULL);
     if (ctxt == NULL) {
         xmlFreeParserInputBuffer(input);
        return(NULL);
@@ -12684,15 +12397,6 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
     /* We are loading a DTD */
     ctxt->options |= XML_PARSE_DTDLOAD;
 
-    /*
-     * Set-up the SAX context
-     */
-    if (sax != NULL) {
-       if (ctxt->sax != NULL)
-           xmlFree(ctxt->sax);
-        ctxt->sax = sax;
-        ctxt->userData = ctxt;
-    }
     xmlDetectSAX2(ctxt);
 
     /*
@@ -12701,7 +12405,6 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
 
     pinput = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
     if (pinput == NULL) {
-        if (sax != NULL) ctxt->sax = NULL;
         xmlFreeParserInputBuffer(input);
        xmlFreeParserCtxt(ctxt);
        return(NULL);
@@ -12711,7 +12414,6 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
      * plug some encoding conversion routines here.
      */
     if (xmlPushInput(ctxt, pinput) < 0) {
-        if (sax != NULL) ctxt->sax = NULL;
        xmlFreeParserCtxt(ctxt);
        return(NULL);
     }
@@ -12719,13 +12421,6 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
         xmlSwitchEncoding(ctxt, enc);
     }
 
-    pinput->filename = NULL;
-    pinput->line = 1;
-    pinput->col = 1;
-    pinput->base = ctxt->input->cur;
-    pinput->cur = ctxt->input->cur;
-    pinput->free = NULL;
-
     /*
      * let's parse that entity knowing it's an external subset.
      */
@@ -12739,22 +12434,7 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
     ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
                                       BAD_CAST "none", BAD_CAST "none");
 
-    if ((enc == XML_CHAR_ENCODING_NONE) &&
-        ((ctxt->input->end - ctxt->input->cur) >= 4)) {
-       /*
-        * Get the 4 first bytes and decode the charset
-        * if enc != XML_CHAR_ENCODING_NONE
-        * plug some encoding conversion routines.
-        */
-       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);
-       }
-    }
+    xmlDetectEncoding(ctxt);
 
     xmlParseExternalSubset(ctxt, BAD_CAST "none", BAD_CAST "none");
 
@@ -12778,7 +12458,6 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
         xmlFreeDoc(ctxt->myDoc);
         ctxt->myDoc = NULL;
     }
-    if (sax != NULL) ctxt->sax = NULL;
     xmlFreeParserCtxt(ctxt);
 
     return(ret);
@@ -12790,6 +12469,8 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
  * @ExternalID:  a NAME* containing the External ID of the DTD
  * @SystemID:  a NAME* containing the URL to the DTD
  *
+ * DEPRECATED: Don't use.
+ *
  * Load and parse an external subset.
  *
  * Returns the resulting xmlDtdPtr or NULL in case of error.
@@ -12801,12 +12482,11 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
     xmlDtdPtr ret = NULL;
     xmlParserCtxtPtr ctxt;
     xmlParserInputPtr input = NULL;
-    xmlCharEncoding enc;
     xmlChar* systemIdCanonic;
 
     if ((ExternalID == NULL) && (SystemID == NULL)) return(NULL);
 
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(sax, NULL);
     if (ctxt == NULL) {
        return(NULL);
     }
@@ -12815,16 +12495,6 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
     ctxt->options |= XML_PARSE_DTDLOAD;
 
     /*
-     * Set-up the SAX context
-     */
-    if (sax != NULL) {
-       if (ctxt->sax != NULL)
-           xmlFree(ctxt->sax);
-        ctxt->sax = sax;
-        ctxt->userData = ctxt;
-    }
-
-    /*
      * Canonicalise the system ID
      */
     systemIdCanonic = xmlCanonicPath(SystemID);
@@ -12841,7 +12511,6 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
        input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
                                         systemIdCanonic);
     if (input == NULL) {
-        if (sax != NULL) ctxt->sax = NULL;
        xmlFreeParserCtxt(ctxt);
        if (systemIdCanonic != NULL)
            xmlFree(systemIdCanonic);
@@ -12852,26 +12521,18 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
      * plug some encoding conversion routines here.
      */
     if (xmlPushInput(ctxt, input) < 0) {
-        if (sax != NULL) ctxt->sax = NULL;
        xmlFreeParserCtxt(ctxt);
        if (systemIdCanonic != NULL)
            xmlFree(systemIdCanonic);
        return(NULL);
     }
-    if ((ctxt->input->end - ctxt->input->cur) >= 4) {
-       enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
-       xmlSwitchEncoding(ctxt, enc);
-    }
+
+    xmlDetectEncoding(ctxt);
 
     if (input->filename == NULL)
        input->filename = (char *) systemIdCanonic;
     else
        xmlFree(systemIdCanonic);
-    input->line = 1;
-    input->col = 1;
-    input->base = ctxt->input->cur;
-    input->cur = ctxt->input->cur;
-    input->free = NULL;
 
     /*
      * let's parse that entity knowing it's an external subset.
@@ -12880,7 +12541,6 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
     ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
     if (ctxt->myDoc == NULL) {
        xmlErrMemory(ctxt, "New Doc failed");
-        if (sax != NULL) ctxt->sax = NULL;
        xmlFreeParserCtxt(ctxt);
        return(NULL);
     }
@@ -12909,7 +12569,6 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
         xmlFreeDoc(ctxt->myDoc);
         ctxt->myDoc = NULL;
     }
-    if (sax != NULL) ctxt->sax = NULL;
     xmlFreeParserCtxt(ctxt);
 
     return(ret);
@@ -13000,15 +12659,14 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
     xmlParserCtxtPtr ctxt;
     xmlDocPtr newDoc;
     xmlNodePtr newRoot;
-    xmlSAXHandlerPtr oldsax = NULL;
     xmlParserErrors ret = XML_ERR_OK;
-    xmlChar start[4];
-    xmlCharEncoding enc;
 
     if (((depth > 40) &&
        ((oldctxt == NULL) || (oldctxt->options & XML_PARSE_HUGE) == 0)) ||
-       (depth > 1024)) {
-       return(XML_ERR_ENTITY_LOOP);
+       (depth > 100)) {
+       xmlFatalErrMsg(oldctxt, XML_ERR_ENTITY_LOOP,
+                       "Maximum entity nesting depth exceeded");
+        return(XML_ERR_ENTITY_LOOP);
     }
 
     if (list != NULL)
@@ -13018,17 +12676,15 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
     if (doc == NULL)
        return(XML_ERR_INTERNAL_ERROR);
 
-
-    ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, oldctxt);
+    ctxt = xmlCreateEntityParserCtxtInternal(sax, user_data, URL, ID, NULL,
+                                             oldctxt);
     if (ctxt == NULL) return(XML_WAR_UNDECLARED_ENTITY);
-    ctxt->userData = ctxt;
-    if (sax != NULL) {
-       oldsax = ctxt->sax;
-        ctxt->sax = sax;
-       if (user_data != NULL)
-           ctxt->userData = user_data;
+    if (oldctxt != NULL) {
+        ctxt->nbErrors = oldctxt->nbErrors;
+        ctxt->nbWarnings = oldctxt->nbWarnings;
     }
     xmlDetectSAX2(ctxt);
+
     newDoc = xmlNewDoc(BAD_CAST "1.0");
     if (newDoc == NULL) {
        xmlFreeParserCtxt(ctxt);
@@ -13049,7 +12705,6 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
     newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
     if (newRoot == NULL) {
        if (sax != NULL)
-           ctxt->sax = oldsax;
        xmlFreeParserCtxt(ctxt);
        newDoc->intSubset = NULL;
        newDoc->extSubset = NULL;
@@ -13065,22 +12720,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
         newRoot->doc = doc;
     }
 
-    /*
-     * Get the 4 first bytes and decode the charset
-     * if enc != XML_CHAR_ENCODING_NONE
-     * plug some encoding conversion routines.
-     */
-    GROW;
-    if ((ctxt->input->end - ctxt->input->cur) >= 4) {
-       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);
-       }
-    }
+    xmlDetectEncoding(ctxt);
 
     /*
      * Parse a possible text declaration first
@@ -13109,6 +12749,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
             ctxt->vctxt.error = oldctxt->vctxt.error;
             ctxt->vctxt.warning = oldctxt->vctxt.warning;
             ctxt->vctxt.userData = oldctxt->vctxt.userData;
+            ctxt->vctxt.flags = oldctxt->vctxt.flags;
         }
        ctxt->external = oldctxt->external;
         if (ctxt->dict) xmlDictFree(ctxt->dict);
@@ -13147,10 +12788,12 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
     }
 
     if (!ctxt->wellFormed) {
-        if (ctxt->errNo == 0)
-           ret = XML_ERR_INTERNAL_ERROR;
-       else
-           ret = (xmlParserErrors)ctxt->errNo;
+       ret = (xmlParserErrors)ctxt->errNo;
+        if (oldctxt != NULL) {
+            oldctxt->errNo = ctxt->errNo;
+            oldctxt->wellFormed = 0;
+            xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
+        }
     } else {
        if (list != NULL) {
            xmlNodePtr cur;
@@ -13171,31 +12814,26 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
     }
 
     /*
-     * Record in the parent context the number of entities replacement
-     * done when parsing that reference.
-     */
-    if (oldctxt != NULL)
-        oldctxt->nbentities += ctxt->nbentities;
-
-    /*
      * Also record the size of the entity parsed
      */
     if (ctxt->input != NULL && oldctxt != NULL) {
-       oldctxt->sizeentities += ctxt->input->consumed;
-       oldctxt->sizeentities += (ctxt->input->cur - ctxt->input->base);
+        unsigned long consumed = ctxt->input->consumed;
+
+        xmlSaturatedAddSizeT(&consumed, ctxt->input->cur - ctxt->input->base);
+
+        xmlSaturatedAdd(&oldctxt->sizeentities, consumed);
+        xmlSaturatedAdd(&oldctxt->sizeentities, ctxt->sizeentities);
+
+        xmlSaturatedAdd(&oldctxt->sizeentcopy, consumed);
+        xmlSaturatedAdd(&oldctxt->sizeentcopy, ctxt->sizeentcopy);
     }
-    /*
-     * And record the last error if any
-     */
-    if ((oldctxt != NULL) && (ctxt->lastError.code != XML_ERR_OK))
-        xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
 
-    if (sax != NULL)
-       ctxt->sax = oldsax;
     if (oldctxt != NULL) {
         ctxt->dict = NULL;
         ctxt->attsDefault = NULL;
         ctxt->attsSpecial = NULL;
+        oldctxt->nbErrors = ctxt->nbErrors;
+        oldctxt->nbWarnings = ctxt->nbWarnings;
         oldctxt->validate = ctxt->validate;
         oldctxt->valid = ctxt->valid;
         oldctxt->node_seq.maximum = ctxt->node_seq.maximum;
@@ -13299,14 +12937,14 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     xmlSAXHandlerPtr oldsax = NULL;
     xmlNodePtr content = NULL;
     xmlNodePtr last = NULL;
-    int size;
     xmlParserErrors ret = XML_ERR_OK;
-#ifdef SAX2
-    int i;
-#endif
+    xmlHashedString hprefix, huri;
+    unsigned i;
 
     if (((oldctxt->depth > 40) && ((oldctxt->options & XML_PARSE_HUGE) == 0)) ||
-        (oldctxt->depth >  1024)) {
+        (oldctxt->depth >  100)) {
+       xmlFatalErrMsg(oldctxt, XML_ERR_ENTITY_LOOP,
+                       "Maximum entity nesting depth exceeded");
        return(XML_ERR_ENTITY_LOOP);
     }
 
@@ -13316,27 +12954,59 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     if (string == NULL)
         return(XML_ERR_INTERNAL_ERROR);
 
-    size = xmlStrlen(string);
-
-    ctxt = xmlCreateMemoryParserCtxt((char *) string, size);
+    ctxt = xmlCreateDocParserCtxt(string);
     if (ctxt == NULL) return(XML_WAR_UNDECLARED_ENTITY);
+    ctxt->nbErrors = oldctxt->nbErrors;
+    ctxt->nbWarnings = oldctxt->nbWarnings;
     if (user_data != NULL)
        ctxt->userData = user_data;
     else
        ctxt->userData = ctxt;
     if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
     ctxt->dict = oldctxt->dict;
-    ctxt->input_id = oldctxt->input_id + 1;
+    ctxt->input_id = oldctxt->input_id;
     ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
     ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
     ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
 
-#ifdef SAX2
-    /* propagate namespaces down the entity */
-    for (i = 0;i < oldctxt->nsNr;i += 2) {
-        nsPush(ctxt, oldctxt->nsTab[i], oldctxt->nsTab[i+1]);
+    /*
+     * Propagate namespaces down the entity
+     *
+     * Making entities and namespaces work correctly requires additional
+     * changes, see xmlParseReference.
+     */
+
+    /* Default namespace */
+    hprefix.name = NULL;
+    hprefix.hashValue = 0;
+    huri.name = xmlParserNsLookupUri(oldctxt, &hprefix);
+    huri.hashValue = 0;
+    if (huri.name != NULL)
+        xmlParserNsPush(ctxt, NULL, &huri, NULL, 0);
+
+    for (i = 0; i < oldctxt->nsdb->hashSize; i++) {
+        xmlParserNsBucket *bucket = &oldctxt->nsdb->hash[i];
+        const xmlChar **ns;
+        xmlParserNsExtra *extra;
+        unsigned nsIndex;
+
+        if ((bucket->hashValue != 0) &&
+            (bucket->index != INT_MAX)) {
+            nsIndex = bucket->index;
+            ns = &oldctxt->nsTab[nsIndex * 2];
+            extra = &oldctxt->nsdb->extra[nsIndex];
+
+            hprefix.name = ns[0];
+            hprefix.hashValue = bucket->hashValue;
+            huri.name = ns[1];
+            huri.hashValue = extra->uriHashValue;
+            /*
+             * Don't copy SAX data to avoid a use-after-free with XML reader.
+             * This matches the pre-2.12 behavior.
+             */
+            xmlParserNsPush(ctxt, &hprefix, &huri, NULL, 0);
+        }
     }
-#endif
 
     oldsax = ctxt->sax;
     ctxt->sax = oldctxt->sax;
@@ -13348,10 +13018,8 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     if (oldctxt->myDoc == NULL) {
        newDoc = xmlNewDoc(BAD_CAST "1.0");
        if (newDoc == NULL) {
-           ctxt->sax = oldsax;
-           ctxt->dict = NULL;
-           xmlFreeParserCtxt(ctxt);
-           return(XML_ERR_INTERNAL_ERROR);
+            ret = XML_ERR_INTERNAL_ERROR;
+            goto error;
        }
        newDoc->properties = XML_DOC_INTERNAL;
        newDoc->dict = ctxt->dict;
@@ -13364,20 +13032,15 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     }
     newRoot = xmlNewDocNode(ctxt->myDoc, NULL, BAD_CAST "pseudoroot", NULL);
     if (newRoot == NULL) {
-       ctxt->sax = oldsax;
-       ctxt->dict = NULL;
-       xmlFreeParserCtxt(ctxt);
-       if (newDoc != NULL) {
-           xmlFreeDoc(newDoc);
-       }
-       return(XML_ERR_INTERNAL_ERROR);
+        ret = XML_ERR_INTERNAL_ERROR;
+        goto error;
     }
     ctxt->myDoc->children = NULL;
     ctxt->myDoc->last = NULL;
     xmlAddChild((xmlNodePtr) ctxt->myDoc, newRoot);
     nodePush(ctxt, ctxt->myDoc->children);
     ctxt->instate = XML_PARSER_CONTENT;
-    ctxt->depth = oldctxt->depth + 1;
+    ctxt->depth = oldctxt->depth;
 
     ctxt->validate = 0;
     ctxt->loadsubset = oldctxt->loadsubset;
@@ -13402,12 +13065,12 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     }
 
     if (!ctxt->wellFormed) {
-        if (ctxt->errNo == 0)
-           ret = XML_ERR_INTERNAL_ERROR;
-       else
-           ret = (xmlParserErrors)ctxt->errNo;
+       ret = (xmlParserErrors)ctxt->errNo;
+        oldctxt->errNo = ctxt->errNo;
+        oldctxt->wellFormed = 0;
+        xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
     } else {
-      ret = XML_ERR_OK;
+        ret = XML_ERR_OK;
     }
 
     if ((lst != NULL) && (ret == XML_ERR_OK)) {
@@ -13440,18 +13103,21 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
     }
 
     /*
-     * Record in the parent context the number of entities replacement
-     * done when parsing that reference.
+     * Also record the size of the entity parsed
      */
-    if (oldctxt != NULL)
-        oldctxt->nbentities += ctxt->nbentities;
+    if (ctxt->input != NULL && oldctxt != NULL) {
+        unsigned long consumed = ctxt->input->consumed;
 
-    /*
-     * Also record the last error if any
-     */
-    if (ctxt->lastError.code != XML_ERR_OK)
-        xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
+        xmlSaturatedAddSizeT(&consumed, ctxt->input->cur - ctxt->input->base);
+
+        xmlSaturatedAdd(&oldctxt->sizeentcopy, consumed);
+        xmlSaturatedAdd(&oldctxt->sizeentcopy, ctxt->sizeentcopy);
+    }
+
+    oldctxt->nbErrors = ctxt->nbErrors;
+    oldctxt->nbWarnings = ctxt->nbWarnings;
 
+error:
     ctxt->sax = oldsax;
     ctxt->dict = NULL;
     ctxt->attsDefault = NULL;
@@ -13486,7 +13152,6 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
 xmlParserErrors
 xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
                       int options, xmlNodePtr *lst) {
-#ifdef SAX2
     xmlParserCtxtPtr ctxt;
     xmlDocPtr doc = NULL;
     xmlNodePtr fake, cur;
@@ -13564,10 +13229,6 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
     if (doc->encoding != NULL) {
         xmlCharEncodingHandlerPtr hdlr;
 
-        if (ctxt->encoding != NULL)
-           xmlFree((xmlChar *) ctxt->encoding);
-        ctxt->encoding = xmlStrdup((const xmlChar *) doc->encoding);
-
         hdlr = xmlFindCharEncodingHandler((const char *) doc->encoding);
         if (hdlr != NULL) {
             xmlSwitchToEncoding(ctxt, hdlr);
@@ -13576,7 +13237,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
         }
     }
 
-    xmlCtxtUseOptionsInternal(ctxt, options, NULL);
+    xmlCtxtUseOptionsInternal(ctxt, options);
     xmlDetectSAX2(ctxt);
     ctxt->myDoc = doc;
     /* parsing in context, i.e. as within existing content */
@@ -13590,29 +13251,23 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
     }
     xmlAddChild(node, fake);
 
-    if (node->type == XML_ELEMENT_NODE) {
+    if (node->type == XML_ELEMENT_NODE)
        nodePush(ctxt, node);
+
+    if ((ctxt->html == 0) && (node->type == XML_ELEMENT_NODE)) {
        /*
         * initialize the SAX2 namespaces stack
         */
        cur = node;
        while ((cur != NULL) && (cur->type == XML_ELEMENT_NODE)) {
            xmlNsPtr ns = cur->nsDef;
-           const xmlChar *iprefix, *ihref;
+            xmlHashedString hprefix, huri;
 
            while (ns != NULL) {
-               if (ctxt->dict) {
-                   iprefix = xmlDictLookup(ctxt->dict, ns->prefix, -1);
-                   ihref = xmlDictLookup(ctxt->dict, ns->href, -1);
-               } else {
-                   iprefix = ns->prefix;
-                   ihref = ns->href;
-               }
-
-               if (xmlGetNamespace(ctxt, iprefix) == NULL) {
-                   nsPush(ctxt, iprefix, ihref);
-                   nsnr++;
-               }
+                hprefix = xmlDictLookupHashed(ctxt->dict, ns->prefix, -1);
+                huri = xmlDictLookupHashed(ctxt->dict, ns->href, -1);
+                if (xmlParserNsPush(ctxt, &hprefix, &huri, ns, 1) > 0)
+                    nsnr++;
                ns = ns->next;
            }
            cur = cur->parent;
@@ -13633,7 +13288,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
 #endif
        xmlParseContent(ctxt);
 
-    nsPop(ctxt, nsnr);
+    xmlParserNsPop(ctxt, nsnr);
     if ((RAW == '<') && (NXT(1) == '/')) {
        xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);
     } else if (RAW != 0) {
@@ -13687,9 +13342,6 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
     xmlFreeParserCtxt(ctxt);
 
     return(ret);
-#else /* !SAX2 */
-    return(XML_ERR_INTERNAL_ERROR);
-#endif
 }
 
 #ifdef LIBXML_SAX1_ENABLED
@@ -13726,7 +13378,6 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
     xmlDocPtr newDoc;
     xmlSAXHandlerPtr oldsax = NULL;
     xmlNodePtr content, newRoot;
-    int size;
     int ret = 0;
 
     if (depth > 40) {
@@ -13739,9 +13390,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
     if (string == NULL)
         return(-1);
 
-    size = xmlStrlen(string);
-
-    ctxt = xmlCreateMemoryParserCtxt((char *) string, size);
+    ctxt = xmlCreateDocParserCtxt(string);
     if (ctxt == NULL) return(-1);
     ctxt->userData = ctxt;
     if (sax != NULL) {
@@ -13764,8 +13413,10 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
        ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
        ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
        ctxt->dictNames = 1;
+        newDoc->dict = ctxt->dict;
+        xmlDictReference(newDoc->dict);
     } else {
-       xmlCtxtUseOptionsInternal(ctxt, XML_PARSE_NODICT, NULL);
+       xmlCtxtUseOptionsInternal(ctxt, XML_PARSE_NODICT);
     }
     /* doc == NULL is only supported for historic reasons */
     if (doc != NULL) {
@@ -13789,7 +13440,6 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
        ctxt->myDoc = newDoc;
     } else {
        ctxt->myDoc = newDoc;
-       newDoc->children->doc = doc;
        /* Ensure that doc has XML spec namespace */
        xmlSearchNsByHref(doc, (xmlNodePtr)doc, XML_XML_NAMESPACE);
        newDoc->oldNs = doc->oldNs;
@@ -13866,6 +13516,8 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
  * @sax:  the SAX handler block
  * @filename:  the filename
  *
+ * DEPRECATED: Don't use.
+ *
  * parse an XML external entity out of context and build a tree.
  * It use the given SAX function block to handle the parsing callback.
  * If sax is NULL, fallback to the default DOM tree building routines.
@@ -13942,14 +13594,15 @@ xmlParseEntity(const char *filename) {
  * Returns the new parser context or NULL
  */
 static xmlParserCtxtPtr
-xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
-                         const xmlChar *base, xmlParserCtxtPtr pctx) {
+xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData,
+        const xmlChar *URL, const xmlChar *ID, const xmlChar *base,
+        xmlParserCtxtPtr pctx) {
     xmlParserCtxtPtr ctxt;
     xmlParserInputPtr inputStream;
     char *directory = NULL;
     xmlChar *uri;
 
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(sax, userData);
     if (ctxt == NULL) {
        return(NULL);
     }
@@ -13957,11 +13610,7 @@ xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
     if (pctx != NULL) {
         ctxt->options = pctx->options;
         ctxt->_private = pctx->_private;
-       /*
-        * this is a subparser of pctx, so the input_id should be
-        * incremented to distinguish from main entity
-        */
-       ctxt->input_id = pctx->input_id + 1;
+       ctxt->input_id = pctx->input_id;
     }
 
     /* Don't read from stdin. */
@@ -14017,7 +13666,7 @@ xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
 xmlParserCtxtPtr
 xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
                          const xmlChar *base) {
-    return xmlCreateEntityParserCtxtInternal(URL, ID, base, NULL);
+    return xmlCreateEntityParserCtxtInternal(NULL, NULL, URL, ID, base, NULL);
 
 }
 
@@ -14052,7 +13701,7 @@ xmlCreateURLParserCtxt(const char *filename, int options)
     }
 
     if (options)
-       xmlCtxtUseOptionsInternal(ctxt, options, NULL);
+       xmlCtxtUseOptionsInternal(ctxt, options);
     ctxt->linenumbers = 1;
 
     inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
@@ -14095,6 +13744,8 @@ xmlCreateFileParserCtxt(const char *filename)
  *             documents
  * @data:  the userdata
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.
+ *
  * parse an XML file and build a tree. Automatic support for ZLIB/Compress
  * compressed document is provided by default if found at compile-time.
  * It use the given SAX function block to handle the parsing callback.
@@ -14163,6 +13814,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
  * @recovery:  work in recovery mode, i.e. tries to read no Well Formed
  *             documents
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.
+ *
  * parse an XML file and build a tree. Automatic support for ZLIB/Compress
  * compressed document is provided by default if found at compile-time.
  * It use the given SAX function block to handle the parsing callback.
@@ -14181,6 +13834,8 @@ xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
  * xmlRecoverDoc:
  * @cur:  a pointer to an array of xmlChar
  *
+ * DEPRECATED: Use xmlReadDoc with XML_PARSE_RECOVER.
+ *
  * parse an XML in-memory document and build a tree.
  * In the case the document is not Well Formed, a attempt to build a
  * tree is tried anyway
@@ -14197,6 +13852,8 @@ xmlRecoverDoc(const xmlChar *cur) {
  * xmlParseFile:
  * @filename:  the filename
  *
+ * DEPRECATED: Use xmlReadFile.
+ *
  * parse an XML file and build a tree. Automatic support for ZLIB/Compress
  * compressed document is provided by default if found at compile-time.
  *
@@ -14213,6 +13870,8 @@ xmlParseFile(const char *filename) {
  * xmlRecoverFile:
  * @filename:  the filename
  *
+ * DEPRECATED: Use xmlReadFile with XML_PARSE_RECOVER.
+ *
  * 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, it attempts to build
@@ -14233,6 +13892,8 @@ xmlRecoverFile(const char *filename) {
  * @buffer:  a xmlChar * buffer
  * @filename:  a file name
  *
+ * DEPRECATED: Don't use.
+ *
  * Setup the parser context to parse a new buffer; Clears any prior
  * contents from the parser context. The buffer parameter must not be
  * NULL, but the filename parameter can be
@@ -14268,6 +13929,8 @@ xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
  * @user_data:  The user data returned on SAX callbacks
  * @filename:  a file name
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile.
+ *
  * parse an XML file and call the given SAX handler routines.
  * Automatic support for ZLIB/Compress compressed document is provided
  *
@@ -14341,7 +14004,6 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
     if (ctxt == NULL)
        return(NULL);
 
-    /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
     buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
     if (buf == NULL) {
        xmlFreeParserCtxt(ctxt);
@@ -14373,6 +14035,8 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
  *             documents
  * @data:  the userdata
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.
+ *
  * parse an XML in-memory block and use the given SAX function block
  * to handle the parsing callback. If sax is NULL, fallback to the default
  * DOM tree building routines.
@@ -14428,6 +14092,8 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
  * @recovery:  work in recovery mode, i.e. tries to read not Well Formed
  *             documents
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.
+ *
  * parse an XML in-memory block and use the given SAX function block
  * to handle the parsing callback. If sax is NULL, fallback to the default
  * DOM tree building routines.
@@ -14445,6 +14111,8 @@ xmlSAXParseMemory(xmlSAXHandlerPtr sax, const char *buffer,
  * @buffer:  an pointer to a char array
  * @size:  the size of the array
  *
+ * DEPRECATED: Use xmlReadMemory.
+ *
  * parse an XML in-memory block and build a tree.
  *
  * Returns the resulting document tree
@@ -14459,6 +14127,8 @@ xmlDocPtr xmlParseMemory(const char *buffer, int size) {
  * @buffer:  an pointer to a char array
  * @size:  the size of the array
  *
+ * DEPRECATED: Use xmlReadMemory with XML_PARSE_RECOVER.
+ *
  * parse an XML in-memory block and build a tree.
  * In the case the document is not Well Formed, an attempt to
  * build a tree is tried anyway
@@ -14477,7 +14147,8 @@ xmlDocPtr xmlRecoverMemory(const char *buffer, int size) {
  * @buffer:  an in-memory XML document input
  * @size:  the length of the XML document in bytes
  *
- * A better SAX parsing routine.
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.
+ *
  * parse an XML in-memory buffer and call the given SAX handler routines.
  *
  * Returns 0 in case of success or a error number otherwise
@@ -14523,20 +14194,44 @@ int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
 
 /**
  * xmlCreateDocParserCtxt:
- * @cur:  a pointer to an array of xmlChar
+ * @str:  a pointer to an array of xmlChar
  *
  * Creates a parser context for an XML in-memory document.
  *
  * Returns the new parser context or NULL
  */
 xmlParserCtxtPtr
-xmlCreateDocParserCtxt(const xmlChar *cur) {
-    int len;
+xmlCreateDocParserCtxt(const xmlChar *str) {
+    xmlParserCtxtPtr ctxt;
+    xmlParserInputPtr input;
+    xmlParserInputBufferPtr buf;
 
-    if (cur == NULL)
+    if (str == NULL)
+       return(NULL);
+
+    ctxt = xmlNewParserCtxt();
+    if (ctxt == NULL)
+       return(NULL);
+
+    buf = xmlParserInputBufferCreateString(str);
+    if (buf == NULL) {
+       xmlFreeParserCtxt(ctxt);
+       return(NULL);
+    }
+
+    input = xmlNewInputStream(ctxt);
+    if (input == NULL) {
+       xmlFreeParserInputBuffer(buf);
+       xmlFreeParserCtxt(ctxt);
        return(NULL);
-    len = xmlStrlen(cur);
-    return(xmlCreateMemoryParserCtxt((const char *)cur, len));
+    }
+
+    input->filename = NULL;
+    input->buf = buf;
+    xmlBufResetInput(input->buf->buffer, input);
+
+    inputPush(ctxt, input);
+    return(ctxt);
 }
 
 #ifdef LIBXML_SAX1_ENABLED
@@ -14547,6 +14242,8 @@ xmlCreateDocParserCtxt(const xmlChar *cur) {
  * @recovery:  work in recovery mode, i.e. tries to read no Well Formed
  *             documents
  *
+ * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadDoc.
+ *
  * parse an XML in-memory document and build a tree.
  * It use the given SAX function block to handle the parsing callback.
  * If sax is NULL, fallback to the default DOM tree building routines.
@@ -14590,6 +14287,8 @@ xmlSAXParseDoc(xmlSAXHandlerPtr sax, const xmlChar *cur, int recovery) {
  * xmlParseDoc:
  * @cur:  a pointer to an array of xmlChar
  *
+ * DEPRECATED: Use xmlReadDoc.
+ *
  * parse an XML in-memory document and build a tree.
  *
  * Returns the resulting document tree
@@ -14644,128 +14343,6 @@ xmlSetEntityReferenceFunc(xmlEntityReferenceFunc func)
 
 /************************************************************************
  *                                                                     *
- *                             Miscellaneous                           *
- *                                                                     *
- ************************************************************************/
-
-#ifdef LIBXML_XPATH_ENABLED
-#include <libxml/xpath.h>
-#endif
-
-extern void XMLCDECL xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...);
-static int xmlParserInitialized = 0;
-
-/**
- * xmlInitParser:
- *
- * Initialization function for the XML parser.
- * This is not reentrant. Call once before processing in case of
- * use in multithreaded programs.
- */
-
-void
-xmlInitParser(void) {
-    if (xmlParserInitialized != 0)
-       return;
-
-#if defined(_WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
-    if (xmlFree == free)
-        atexit(xmlCleanupParser);
-#endif
-
-#ifdef LIBXML_THREAD_ENABLED
-    __xmlGlobalInitMutexLock();
-    if (xmlParserInitialized == 0) {
-#endif
-       xmlInitThreads();
-       xmlInitGlobals();
-       if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
-           (xmlGenericError == NULL))
-           initGenericErrorDefaultFunc(NULL);
-       xmlInitMemory();
-        xmlInitializeDict();
-       xmlInitCharEncodingHandlers();
-       xmlDefaultSAXHandlerInit();
-       xmlRegisterDefaultInputCallbacks();
-#ifdef LIBXML_OUTPUT_ENABLED
-       xmlRegisterDefaultOutputCallbacks();
-#endif /* LIBXML_OUTPUT_ENABLED */
-#ifdef LIBXML_HTML_ENABLED
-       htmlInitAutoClose();
-       htmlDefaultSAXHandlerInit();
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-       xmlXPathInit();
-#endif
-       xmlParserInitialized = 1;
-#ifdef LIBXML_THREAD_ENABLED
-    }
-    __xmlGlobalInitMutexUnlock();
-#endif
-}
-
-/**
- * xmlCleanupParser:
- *
- * 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.
- *
- * WARNING: if your application is multithreaded or has plugin support
- *          calling this may crash the application if another thread or
- *          a plugin is still using libxml2. It's sometimes very hard to
- *          guess if libxml2 is in use in the application, some libraries
- *          or plugins may use it without notice. In case of doubt abstain
- *          from calling this function or do it just before calling exit()
- *          to avoid leak reports from valgrind !
- */
-
-void
-xmlCleanupParser(void) {
-    if (!xmlParserInitialized)
-       return;
-
-    xmlCleanupCharEncodingHandlers();
-#ifdef LIBXML_CATALOG_ENABLED
-    xmlCatalogCleanup();
-#endif
-    xmlDictCleanup();
-    xmlCleanupInputCallbacks();
-#ifdef LIBXML_OUTPUT_ENABLED
-    xmlCleanupOutputCallbacks();
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-    xmlSchemaCleanupTypes();
-    xmlRelaxNGCleanupTypes();
-#endif
-    xmlCleanupGlobals();
-    xmlCleanupThreads(); /* must be last if called not from the main thread */
-    xmlCleanupMemory();
-    xmlParserInitialized = 0;
-}
-
-#if defined(HAVE_ATTRIBUTE_DESTRUCTOR) && !defined(LIBXML_STATIC) && \
-    !defined(_WIN32)
-static void
-ATTRIBUTE_DESTRUCTOR
-xmlDestructor(void) {
-    /*
-     * Calling custom deallocation functions in a destructor can cause
-     * problems, for example with Nokogiri.
-     */
-    if (xmlFree == free)
-        xmlCleanupParser();
-}
-#endif
-
-/************************************************************************
- *                                                                     *
  *     New set (2.6.0) of simpler and more flexible APIs               *
  *                                                                     *
  ************************************************************************/
@@ -14821,6 +14398,7 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
     ctxt->name = NULL;
 
     ctxt->nsNr = 0;
+    xmlParserNsReset(ctxt->nsdb);
 
     DICT_FREE(ctxt->version);
     ctxt->version = NULL;
@@ -14855,12 +14433,11 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
 #endif
     ctxt->record_info = 0;
     ctxt->checkIndex = 0;
+    ctxt->endCheckState = 0;
     ctxt->inSubset = 0;
     ctxt->errNo = XML_ERR_OK;
     ctxt->depth = 0;
-    ctxt->charset = XML_CHAR_ENCODING_UTF8;
     ctxt->catalogs = NULL;
-    ctxt->nbentities = 0;
     ctxt->sizeentities = 0;
     ctxt->sizeentcopy = 0;
     xmlInitNodeInfoSeq(&ctxt->node_seq);
@@ -14878,6 +14455,8 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
     if (ctxt->catalogs != NULL)
        xmlCatalogFreeLocal(ctxt->catalogs);
 #endif
+    ctxt->nbErrors = 0;
+    ctxt->nbWarnings = 0;
     if (ctxt->lastError.code != XML_ERR_OK)
         xmlResetError(&ctxt->lastError);
 }
@@ -14900,15 +14479,11 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
 {
     xmlParserInputPtr inputStream;
     xmlParserInputBufferPtr buf;
-    xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
 
     if (ctxt == NULL)
         return(1);
 
-    if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
-        enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
-
-    buf = xmlAllocParserInputBuffer(enc);
+    buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
     if (buf == NULL)
         return(1);
 
@@ -14943,24 +14518,21 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
 
     if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL)) {
-       size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
-        size_t cur = ctxt->input->cur - ctxt->input->base;
-
-        xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+        size_t pos = ctxt->input->cur - ctxt->input->base;
+        int res;
 
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
-#ifdef DEBUG_PUSH
-        xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
-#endif
+        res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+        xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
+        if (res < 0) {
+            xmlFatalErr(ctxt, ctxt->input->buf->error, NULL);
+            xmlHaltParser(ctxt);
+            return(1);
+        }
     }
 
     if (encoding != NULL) {
         xmlCharEncodingHandlerPtr hdlr;
 
-        if (ctxt->encoding != NULL)
-           xmlFree((xmlChar *) ctxt->encoding);
-        ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
-
         hdlr = xmlFindCharEncodingHandler(encoding);
         if (hdlr != NULL) {
             xmlSwitchToEncoding(ctxt, hdlr);
@@ -14968,8 +14540,6 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
            xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
                              "Unsupported encoding %s\n", BAD_CAST encoding);
         }
-    } else if (enc != XML_CHAR_ENCODING_NONE) {
-        xmlSwitchEncoding(ctxt, enc);
     }
 
     return(0);
@@ -14988,15 +14558,10 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
  *         in case of error.
  */
 static int
-xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
+xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options)
 {
     if (ctxt == NULL)
         return(-1);
-    if (encoding != NULL) {
-        if (ctxt->encoding != NULL)
-           xmlFree((xmlChar *) ctxt->encoding);
-        ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
-    }
     if (options & XML_PARSE_RECOVER) {
         ctxt->recovery = 1;
         options -= XML_PARSE_RECOVER;
@@ -15055,8 +14620,6 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi
     }
 #ifdef LIBXML_SAX1_ENABLED
     if (options & XML_PARSE_SAX1) {
-        ctxt->sax->startElement = xmlSAX2StartElement;
-        ctxt->sax->endElement = xmlSAX2EndElement;
         ctxt->sax->startElementNs = NULL;
         ctxt->sax->endElementNs = NULL;
         ctxt->sax->initialized = 1;
@@ -15131,7 +14694,26 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi
 int
 xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
 {
-   return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
+   return(xmlCtxtUseOptionsInternal(ctxt, options));
+}
+
+/**
+ * xmlCtxtSetMaxAmplification:
+ * @ctxt: an XML parser context
+ * @maxAmpl:  maximum amplification factor
+ *
+ * To protect against exponential entity expansion ("billion laughs"), the
+ * size of serialized output is (roughly) limited to the input size
+ * multiplied by this factor. The default value is 5.
+ *
+ * When working with documents making heavy use of entity expansion, it can
+ * be necessary to increase the value. For security reasons, this should only
+ * be considered when processing trusted input.
+ */
+void
+xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt, unsigned maxAmpl)
+{
+    ctxt->maxAmpl = maxAmpl;
 }
 
 /**
@@ -15152,10 +14734,16 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
 {
     xmlDocPtr ret;
 
-    xmlCtxtUseOptionsInternal(ctxt, options, encoding);
+    xmlCtxtUseOptionsInternal(ctxt, options);
     if (encoding != NULL) {
         xmlCharEncodingHandlerPtr hdlr;
 
+        /*
+         * TODO: We should consider to set XML_PARSE_IGNORE_ENC if the
+         * caller provided an encoding. Otherwise, we might switch to
+         * the encoding from the XML declaration which is likely to
+         * break things. Also see xmlSwitchInputEncoding.
+         */
        hdlr = xmlFindCharEncodingHandler(encoding);
        if (hdlr != NULL)
            xmlSwitchToEncoding(ctxt, hdlr);
@@ -15345,7 +14933,7 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
 /**
  * xmlCtxtReadDoc:
  * @ctxt:  an XML parser context
- * @cur:  a pointer to a zero terminated string
+ * @str:  a pointer to a zero terminated string
  * @URL:  the base URL to use for the document
  * @encoding:  the document encoding, or NULL
  * @options:  a combination of xmlParserOption
@@ -15356,13 +14944,33 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
  * Returns the resulting document tree
  */
 xmlDocPtr
-xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
+xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar *str,
                const char *URL, const char *encoding, int options)
 {
-    if (cur == NULL)
+    xmlParserInputBufferPtr input;
+    xmlParserInputPtr stream;
+
+    if (ctxt == NULL)
+        return (NULL);
+    if (str == NULL)
         return (NULL);
-    return (xmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
-                              encoding, options));
+    xmlInitParser();
+
+    xmlCtxtReset(ctxt);
+
+    input = xmlParserInputBufferCreateString(str);
+    if (input == NULL) {
+       return(NULL);
+    }
+
+    stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
+    if (stream == NULL) {
+       xmlFreeParserInputBuffer(input);
+       return(NULL);
+    }
+
+    inputPush(ctxt, stream);
+    return (xmlDoRead(ctxt, URL, encoding, options, 1));
 }
 
 /**
@@ -15428,7 +15036,8 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
 
     xmlCtxtReset(ctxt);
 
-    input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
+    input = xmlParserInputBufferCreateStatic(buffer, size,
+                                             XML_CHAR_ENCODING_NONE);
     if (input == NULL) {
        return(NULL);
     }
index 31d9468..e6b4cb1 100644 (file)
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
-#include <libxml/valid.h>
 #include <libxml/entities.h>
 #include <libxml/xmlerror.h>
 #include <libxml/encoding.h>
-#include <libxml/valid.h>
 #include <libxml/xmlIO.h>
 #include <libxml/uri.h>
 #include <libxml/dict.h>
-#include <libxml/SAX.h>
+#include <libxml/xmlsave.h>
 #ifdef LIBXML_CATALOG_ENABLED
 #include <libxml/catalog.h>
 #endif
-#include <libxml/globals.h>
 #include <libxml/chvalid.h>
 
 #define CUR(ctxt) ctxt->input->cur
 #define END(ctxt) ctxt->input->end
-#define VALID_CTXT(ctxt) (CUR(ctxt) <= END(ctxt))
 
-#include "buf.h"
-#include "enc.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
+#include "private/io.h"
+#include "private/parser.h"
+
+/*
+ * XML_MAX_AMPLIFICATION_DEFAULT is the default maximum allowed amplification
+ * factor of serialized output after entity expansion.
+ */
+#define XML_MAX_AMPLIFICATION_DEFAULT 5
 
 /*
  * Various global defaults for parsing
@@ -59,7 +64,7 @@
  */
 void
 xmlCheckVersion(int version) {
-    int myversion = (int) LIBXML_VERSION;
+    int myversion = LIBXML_VERSION;
 
     xmlInitParser();
 
@@ -173,6 +178,228 @@ xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
 }
 
 /**
+ * xmlFatalErr:
+ * @ctxt:  an XML parser context
+ * @error:  the error number
+ * @info:  extra information string
+ *
+ * Handle a fatal parser error, i.e. violating Well-Formedness constraints
+ */
+void
+xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
+{
+    const char *errmsg;
+
+    if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
+        (ctxt->instate == XML_PARSER_EOF))
+       return;
+    switch (error) {
+        case XML_ERR_INVALID_HEX_CHARREF:
+            errmsg = "CharRef: invalid hexadecimal value";
+            break;
+        case XML_ERR_INVALID_DEC_CHARREF:
+            errmsg = "CharRef: invalid decimal value";
+            break;
+        case XML_ERR_INVALID_CHARREF:
+            errmsg = "CharRef: invalid value";
+            break;
+        case XML_ERR_INTERNAL_ERROR:
+            errmsg = "internal error";
+            break;
+        case XML_ERR_PEREF_AT_EOF:
+            errmsg = "PEReference at end of document";
+            break;
+        case XML_ERR_PEREF_IN_PROLOG:
+            errmsg = "PEReference in prolog";
+            break;
+        case XML_ERR_PEREF_IN_EPILOG:
+            errmsg = "PEReference in epilog";
+            break;
+        case XML_ERR_PEREF_NO_NAME:
+            errmsg = "PEReference: no name";
+            break;
+        case XML_ERR_PEREF_SEMICOL_MISSING:
+            errmsg = "PEReference: expecting ';'";
+            break;
+        case XML_ERR_ENTITY_LOOP:
+            errmsg = "Detected an entity reference loop";
+            break;
+        case XML_ERR_ENTITY_NOT_STARTED:
+            errmsg = "EntityValue: \" or ' expected";
+            break;
+        case XML_ERR_ENTITY_PE_INTERNAL:
+            errmsg = "PEReferences forbidden in internal subset";
+            break;
+        case XML_ERR_ENTITY_NOT_FINISHED:
+            errmsg = "EntityValue: \" or ' expected";
+            break;
+        case XML_ERR_ATTRIBUTE_NOT_STARTED:
+            errmsg = "AttValue: \" or ' expected";
+            break;
+        case XML_ERR_LT_IN_ATTRIBUTE:
+            errmsg = "Unescaped '<' not allowed in attributes values";
+            break;
+        case XML_ERR_LITERAL_NOT_STARTED:
+            errmsg = "SystemLiteral \" or ' expected";
+            break;
+        case XML_ERR_LITERAL_NOT_FINISHED:
+            errmsg = "Unfinished System or Public ID \" or ' expected";
+            break;
+        case XML_ERR_MISPLACED_CDATA_END:
+            errmsg = "Sequence ']]>' not allowed in content";
+            break;
+        case XML_ERR_URI_REQUIRED:
+            errmsg = "SYSTEM or PUBLIC, the URI is missing";
+            break;
+        case XML_ERR_PUBID_REQUIRED:
+            errmsg = "PUBLIC, the Public Identifier is missing";
+            break;
+        case XML_ERR_HYPHEN_IN_COMMENT:
+            errmsg = "Comment must not contain '--' (double-hyphen)";
+            break;
+        case XML_ERR_PI_NOT_STARTED:
+            errmsg = "xmlParsePI : no target name";
+            break;
+        case XML_ERR_RESERVED_XML_NAME:
+            errmsg = "Invalid PI name";
+            break;
+        case XML_ERR_NOTATION_NOT_STARTED:
+            errmsg = "NOTATION: Name expected here";
+            break;
+        case XML_ERR_NOTATION_NOT_FINISHED:
+            errmsg = "'>' required to close NOTATION declaration";
+            break;
+        case XML_ERR_VALUE_REQUIRED:
+            errmsg = "Entity value required";
+            break;
+        case XML_ERR_URI_FRAGMENT:
+            errmsg = "Fragment not allowed";
+            break;
+        case XML_ERR_ATTLIST_NOT_STARTED:
+            errmsg = "'(' required to start ATTLIST enumeration";
+            break;
+        case XML_ERR_NMTOKEN_REQUIRED:
+            errmsg = "NmToken expected in ATTLIST enumeration";
+            break;
+        case XML_ERR_ATTLIST_NOT_FINISHED:
+            errmsg = "')' required to finish ATTLIST enumeration";
+            break;
+        case XML_ERR_MIXED_NOT_STARTED:
+            errmsg = "MixedContentDecl : '|' or ')*' expected";
+            break;
+        case XML_ERR_PCDATA_REQUIRED:
+            errmsg = "MixedContentDecl : '#PCDATA' expected";
+            break;
+        case XML_ERR_ELEMCONTENT_NOT_STARTED:
+            errmsg = "ContentDecl : Name or '(' expected";
+            break;
+        case XML_ERR_ELEMCONTENT_NOT_FINISHED:
+            errmsg = "ContentDecl : ',' '|' or ')' expected";
+            break;
+        case XML_ERR_PEREF_IN_INT_SUBSET:
+            errmsg =
+                "PEReference: forbidden within markup decl in internal subset";
+            break;
+        case XML_ERR_GT_REQUIRED:
+            errmsg = "expected '>'";
+            break;
+        case XML_ERR_CONDSEC_INVALID:
+            errmsg = "XML conditional section '[' expected";
+            break;
+        case XML_ERR_EXT_SUBSET_NOT_FINISHED:
+            errmsg = "Content error in the external subset";
+            break;
+        case XML_ERR_CONDSEC_INVALID_KEYWORD:
+            errmsg =
+                "conditional section INCLUDE or IGNORE keyword expected";
+            break;
+        case XML_ERR_CONDSEC_NOT_FINISHED:
+            errmsg = "XML conditional section not closed";
+            break;
+        case XML_ERR_XMLDECL_NOT_STARTED:
+            errmsg = "Text declaration '<?xml' required";
+            break;
+        case XML_ERR_XMLDECL_NOT_FINISHED:
+            errmsg = "parsing XML declaration: '?>' expected";
+            break;
+        case XML_ERR_EXT_ENTITY_STANDALONE:
+            errmsg = "external parsed entities cannot be standalone";
+            break;
+        case XML_ERR_ENTITYREF_SEMICOL_MISSING:
+            errmsg = "EntityRef: expecting ';'";
+            break;
+        case XML_ERR_DOCTYPE_NOT_FINISHED:
+            errmsg = "DOCTYPE improperly terminated";
+            break;
+        case XML_ERR_LTSLASH_REQUIRED:
+            errmsg = "EndTag: '</' not found";
+            break;
+        case XML_ERR_EQUAL_REQUIRED:
+            errmsg = "expected '='";
+            break;
+        case XML_ERR_STRING_NOT_CLOSED:
+            errmsg = "String not closed expecting \" or '";
+            break;
+        case XML_ERR_STRING_NOT_STARTED:
+            errmsg = "String not started expecting ' or \"";
+            break;
+        case XML_ERR_ENCODING_NAME:
+            errmsg = "Invalid XML encoding name";
+            break;
+        case XML_ERR_STANDALONE_VALUE:
+            errmsg = "standalone accepts only 'yes' or 'no'";
+            break;
+        case XML_ERR_DOCUMENT_EMPTY:
+            errmsg = "Document is empty";
+            break;
+        case XML_ERR_DOCUMENT_END:
+            errmsg = "Extra content at the end of the document";
+            break;
+        case XML_ERR_NOT_WELL_BALANCED:
+            errmsg = "chunk is not well balanced";
+            break;
+        case XML_ERR_EXTRA_CONTENT:
+            errmsg = "extra content at the end of well balanced chunk";
+            break;
+        case XML_ERR_VERSION_MISSING:
+            errmsg = "Malformed declaration expecting version";
+            break;
+        case XML_ERR_NAME_TOO_LONG:
+            errmsg = "Name too long";
+            break;
+        case XML_ERR_INVALID_ENCODING:
+            errmsg = "Invalid bytes in character encoding";
+            break;
+        case XML_IO_UNKNOWN:
+            errmsg = "I/O error";
+            break;
+#if 0
+        case:
+            errmsg = "";
+            break;
+#endif
+        default:
+            errmsg = "Unregistered error message";
+    }
+    if (ctxt != NULL)
+       ctxt->errNo = error;
+    if (info == NULL) {
+        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
+                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
+                        errmsg);
+    } else {
+        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
+                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
+                        errmsg, info);
+    }
+    if (ctxt != NULL) {
+       ctxt->wellFormed = 0;
+       if (ctxt->recovery == 0)
+           ctxt->disableSAX = 1;
+    }
+}
+
+/**
  * xmlErrEncodingInt:
  * @ctxt:  an XML parser context
  * @error:  the error number
@@ -220,47 +447,50 @@ xmlIsLetter(int c) {
  *                                                                     *
  ************************************************************************/
 
-/* #define DEBUG_INPUT */
-/* #define DEBUG_STACK */
-/* #define DEBUG_PUSH */
-
-
 /* we need to keep enough input to show errors in context */
 #define LINE_LEN        80
 
-#ifdef DEBUG_INPUT
-#define CHECK_BUFFER(in) check_buffer(in)
-
-static
-void check_buffer(xmlParserInputPtr in) {
-    if (in->base != xmlBufContent(in->buf->buffer)) {
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlParserInput: base mismatch problem\n");
-    }
-    if (in->cur < in->base) {
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlParserInput: cur < base problem\n");
-    }
-    if (in->cur > in->base + xmlBufUse(in->buf->buffer)) {
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlParserInput: cur > base + use problem\n");
+/**
+ * xmlHaltParser:
+ * @ctxt:  an XML parser context
+ *
+ * Blocks further parser processing don't override error
+ * for internal use
+ */
+void
+xmlHaltParser(xmlParserCtxtPtr ctxt) {
+    if (ctxt == NULL)
+        return;
+    ctxt->instate = XML_PARSER_EOF;
+    ctxt->disableSAX = 1;
+    while (ctxt->inputNr > 1)
+        xmlFreeInputStream(inputPop(ctxt));
+    if (ctxt->input != NULL) {
+        /*
+        * in case there was a specific allocation deallocate before
+        * overriding base
+        */
+        if (ctxt->input->free != NULL) {
+           ctxt->input->free((xmlChar *) ctxt->input->base);
+           ctxt->input->free = NULL;
+       }
+        if (ctxt->input->buf != NULL) {
+            xmlFreeParserInputBuffer(ctxt->input->buf);
+            ctxt->input->buf = NULL;
+        }
+       ctxt->input->cur = BAD_CAST"";
+        ctxt->input->length = 0;
+       ctxt->input->base = ctxt->input->cur;
+        ctxt->input->end = ctxt->input->cur;
     }
-    xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d\n",
-            (int) in, (int) xmlBufContent(in->buf->buffer), in->cur - in->base,
-           xmlBufUse(in->buf->buffer));
 }
 
-#else
-#define CHECK_BUFFER(in)
-#endif
-
-
 /**
  * xmlParserInputRead:
  * @in:  an XML parser input
  * @len:  an indicative size for the lookahead
  *
- * This function was internal and is deprecated.
+ * DEPRECATED: This function was internal and is deprecated.
  *
  * Returns -1 as this is an error to use it.
  */
@@ -270,10 +500,63 @@ xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUS
 }
 
 /**
+ * xmlParserGrow:
+ * @ctxt:  an XML parser context
+ *
+ * Grow the input buffer.
+ *
+ * Returns the number of bytes read or -1 in case of error.
+ */
+int
+xmlParserGrow(xmlParserCtxtPtr ctxt) {
+    xmlParserInputPtr in = ctxt->input;
+    xmlParserInputBufferPtr buf = in->buf;
+    ptrdiff_t curEnd = in->end - in->cur;
+    ptrdiff_t curBase = in->cur - in->base;
+    int ret;
+
+    if (buf == NULL)
+        return(0);
+    /* Don't grow push parser buffer. */
+    if ((ctxt->progressive) && (ctxt->inputNr <= 1))
+        return(0);
+    /* Don't grow memory buffers. */
+    if ((buf->encoder == NULL) && (buf->readcallback == NULL))
+        return(0);
+    if (buf->error != 0)
+        return(-1);
+
+    if (((curEnd > XML_MAX_LOOKUP_LIMIT) ||
+         (curBase > XML_MAX_LOOKUP_LIMIT)) &&
+        ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+        xmlErrMemory(ctxt, "Huge input lookup");
+        xmlHaltParser(ctxt);
+       return(-1);
+    }
+
+    if (curEnd >= INPUT_CHUNK)
+        return(0);
+
+    ret = xmlParserInputBufferGrow(buf, INPUT_CHUNK);
+    xmlBufUpdateInput(buf->buffer, in, curBase);
+
+    if (ret < 0) {
+        xmlFatalErr(ctxt, buf->error, NULL);
+        /* Buffer contents may be lost in case of memory errors. */
+        if (buf->error == XML_ERR_NO_MEMORY)
+            xmlHaltParser(ctxt);
+    }
+
+    return(ret);
+}
+
+/**
  * xmlParserInputGrow:
  * @in:  an XML parser input
  * @len:  an indicative size for the lookahead
  *
+ * DEPRECATED: Don't use.
+ *
  * This function increase the input for the parser. It tries to
  * preserve pointers to the input buffer, and keep already read data
  *
@@ -286,41 +569,81 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
     size_t indx;
 
     if ((in == NULL) || (len < 0)) return(-1);
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext, "Grow\n");
-#endif
     if (in->buf == NULL) return(-1);
     if (in->base == NULL) return(-1);
     if (in->cur == NULL) return(-1);
     if (in->buf->buffer == NULL) return(-1);
 
-    CHECK_BUFFER(in);
+    /* Don't grow memory buffers. */
+    if ((in->buf->encoder == NULL) && (in->buf->readcallback == NULL))
+        return(0);
 
     indx = in->cur - in->base;
     if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
-
-       CHECK_BUFFER(in);
-
         return(0);
     }
-    if (in->buf->readcallback != NULL) {
-       ret = xmlParserInputBufferGrow(in->buf, len);
-    } else
-        return(0);
+    ret = xmlParserInputBufferGrow(in->buf, len);
 
     in->base = xmlBufContent(in->buf->buffer);
+    if (in->base == NULL) {
+        in->base = BAD_CAST "";
+        in->cur = in->base;
+        in->end = in->base;
+        return(-1);
+    }
     in->cur = in->base + indx;
     in->end = xmlBufEnd(in->buf->buffer);
 
-    CHECK_BUFFER(in);
-
     return(ret);
 }
 
 /**
+ * xmlParserShrink:
+ * @ctxt:  an XML parser context
+ *
+ * Shrink the input buffer.
+ */
+void
+xmlParserShrink(xmlParserCtxtPtr ctxt) {
+    xmlParserInputPtr in = ctxt->input;
+    xmlParserInputBufferPtr buf = in->buf;
+    size_t used;
+
+    if (buf == NULL)
+        return;
+    /* Don't shrink pull parser memory buffers. */
+    if (((ctxt->progressive == 0) || (ctxt->inputNr > 1)) &&
+        (buf->encoder == NULL) &&
+        (buf->readcallback == NULL))
+        return;
+
+    used = in->cur - in->base;
+    /*
+     * Do not shrink on large buffers whose only a tiny fraction
+     * was consumed
+     */
+    if (used > INPUT_CHUNK) {
+       size_t res = xmlBufShrink(buf->buffer, used - LINE_LEN);
+
+       if (res > 0) {
+            used -= res;
+            if ((res > ULONG_MAX) ||
+                (in->consumed > ULONG_MAX - (unsigned long)res))
+                in->consumed = ULONG_MAX;
+            else
+                in->consumed += res;
+       }
+    }
+
+    xmlBufUpdateInput(buf->buffer, in, used);
+}
+
+/**
  * xmlParserInputShrink:
  * @in:  an XML parser input
  *
+ * DEPRECATED: Don't use.
+ *
  * This function removes used input for the parser.
  */
 void
@@ -328,17 +651,12 @@ xmlParserInputShrink(xmlParserInputPtr in) {
     size_t used;
     size_t ret;
 
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext, "Shrink\n");
-#endif
     if (in == NULL) return;
     if (in->buf == NULL) return;
     if (in->base == NULL) return;
     if (in->cur == NULL) return;
     if (in->buf->buffer == NULL) return;
 
-    CHECK_BUFFER(in);
-
     used = in->cur - in->base;
     /*
      * Do not shrink on large buffers whose only a tiny fraction
@@ -348,7 +666,11 @@ xmlParserInputShrink(xmlParserInputPtr in) {
        ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
        if (ret > 0) {
             used -= ret;
-           in->consumed += ret;
+            if ((ret > ULONG_MAX) ||
+                (in->consumed > ULONG_MAX - (unsigned long)ret))
+                in->consumed = ULONG_MAX;
+            else
+                in->consumed += ret;
        }
     }
 
@@ -357,10 +679,15 @@ xmlParserInputShrink(xmlParserInputPtr in) {
     }
 
     in->base = xmlBufContent(in->buf->buffer);
+    if (in->base == NULL) {
+        /* TODO: raise error */
+        in->base = BAD_CAST "";
+        in->cur = in->base;
+        in->end = in->base;
+        return;
+    }
     in->cur = in->base + used;
     in->end = xmlBufEnd(in->buf->buffer);
-
-    CHECK_BUFFER(in);
 }
 
 /************************************************************************
@@ -373,149 +700,111 @@ xmlParserInputShrink(xmlParserInputPtr in) {
  * xmlNextChar:
  * @ctxt:  the XML parser context
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Skip to the next char input char.
  */
 
 void
 xmlNextChar(xmlParserCtxtPtr ctxt)
 {
+    const unsigned char *cur;
+    size_t avail;
+    int c;
+
     if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
         (ctxt->input == NULL))
         return;
 
-    if (!(VALID_CTXT(ctxt))) {
-        xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
-       ctxt->errNo = XML_ERR_INTERNAL_ERROR;
-        xmlStopParser(ctxt);
-       return;
-    }
+    avail = ctxt->input->end - ctxt->input->cur;
 
-    if ((*ctxt->input->cur == 0) &&
-        (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
-        return;
+    if (avail < INPUT_CHUNK) {
+        xmlParserGrow(ctxt);
+        if ((ctxt->instate == XML_PARSER_EOF) ||
+            (ctxt->input->cur >= ctxt->input->end))
+            return;
+        avail = ctxt->input->end - ctxt->input->cur;
     }
 
-    if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
-        const unsigned char *cur;
-        unsigned char c;
+    cur = ctxt->input->cur;
+    c = *cur;
 
-        /*
-         *   2.11 End-of-Line Handling
-         *   the literal two-character sequence "#xD#xA" or a standalone
-         *   literal #xD, an XML processor must pass to the application
-         *   the single character #xA.
-         */
-        if (*(ctxt->input->cur) == '\n') {
-            ctxt->input->line++; ctxt->input->col = 1;
-        } else
+    if (c < 0x80) {
+        if (c == '\n') {
+            ctxt->input->cur++;
+            ctxt->input->line++;
+            ctxt->input->col = 1;
+        } else if (c == '\r') {
+            /*
+             *   2.11 End-of-Line Handling
+             *   the literal two-character sequence "#xD#xA" or a standalone
+             *   literal #xD, an XML processor must pass to the application
+             *   the single character #xA.
+             */
+            ctxt->input->cur += ((cur[1] == '\n') ? 2 : 1);
+            ctxt->input->line++;
+            ctxt->input->col = 1;
+            return;
+        } else {
+            ctxt->input->cur++;
             ctxt->input->col++;
+        }
+    } else {
+        ctxt->input->col++;
 
-        /*
-         * We are supposed to handle UTF8, check it's valid
-         * From rfc2044: encoding of the Unicode values on UTF-8:
-         *
-         * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
-         * 0000 0000-0000 007F   0xxxxxxx
-         * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
-         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
-         *
-         * Check for the 0x110000 limit too
-         */
-        cur = ctxt->input->cur;
-
-        c = *cur;
-        if (c & 0x80) {
-            if (c == 0xC0)
-               goto encoding_error;
-            if (cur[1] == 0) {
-                xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                cur = ctxt->input->cur;
-            }
-            if ((cur[1] & 0xc0) != 0x80)
+        if ((avail < 2) || (cur[1] & 0xc0) != 0x80)
+            goto encoding_error;
+
+        if (c < 0xe0) {
+            /* 2-byte code */
+            if (c < 0xc2)
                 goto encoding_error;
-            if ((c & 0xe0) == 0xe0) {
-                unsigned int val;
+            ctxt->input->cur += 2;
+        } else {
+            unsigned int val = (c << 8) | cur[1];
 
-                if (cur[2] == 0) {
-                    xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                    cur = ctxt->input->cur;
-                }
-                if ((cur[2] & 0xc0) != 0x80)
+            if ((avail < 3) || (cur[2] & 0xc0) != 0x80)
+                goto encoding_error;
+
+            if (c < 0xf0) {
+                /* 3-byte code */
+                if ((val < 0xe0a0) || ((val >= 0xeda0) && (val < 0xee00)))
+                    goto encoding_error;
+                ctxt->input->cur += 3;
+            } else {
+                if ((avail < 4) || ((cur[3] & 0xc0) != 0x80))
                     goto encoding_error;
-                if ((c & 0xf0) == 0xf0) {
-                    if (cur[3] == 0) {
-                        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                        cur = ctxt->input->cur;
-                    }
-                    if (((c & 0xf8) != 0xf0) ||
-                        ((cur[3] & 0xc0) != 0x80))
-                        goto encoding_error;
-                    /* 4-byte code */
-                    ctxt->input->cur += 4;
-                    val = (cur[0] & 0x7) << 18;
-                    val |= (cur[1] & 0x3f) << 12;
-                    val |= (cur[2] & 0x3f) << 6;
-                    val |= cur[3] & 0x3f;
-                } else {
-                    /* 3-byte code */
-                    ctxt->input->cur += 3;
-                    val = (cur[0] & 0xf) << 12;
-                    val |= (cur[1] & 0x3f) << 6;
-                    val |= cur[2] & 0x3f;
-                }
-                if (((val > 0xd7ff) && (val < 0xe000)) ||
-                    ((val > 0xfffd) && (val < 0x10000)) ||
-                    (val >= 0x110000)) {
-               xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
-                                 "Char 0x%X out of allowed range\n",
-                                 val);
-                }
-            } else
-                /* 2-byte code */
-                ctxt->input->cur += 2;
-        } else
-            /* 1-byte code */
-            ctxt->input->cur++;
-    } else {
-        /*
-         * Assume it's a fixed length encoding (1) with
-         * a compatible encoding for the ASCII set, since
-         * XML constructs only use < 128 chars
-         */
 
-        if (*(ctxt->input->cur) == '\n') {
-            ctxt->input->line++; ctxt->input->col = 1;
-        } else
-            ctxt->input->col++;
-        ctxt->input->cur++;
+                /* 4-byte code */
+                if ((val < 0xf090) || (val >= 0xf490))
+                    goto encoding_error;
+                ctxt->input->cur += 4;
+            }
+        }
     }
-    if (*ctxt->input->cur == 0)
-        xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+
     return;
-encoding_error:
-    /*
-     * If we detect an UTF8 error that probably mean that the
-     * input encoding didn't get properly advertised in the
-     * declaration header. Report the error and switch the encoding
-     * to ISO-Latin-1 (if you don't like this policy, just declare the
-     * encoding !)
-     */
-    if ((ctxt == NULL) || (ctxt->input == NULL) ||
-        (ctxt->input->end - ctxt->input->cur < 4)) {
-       __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
-                    "Input is not proper UTF-8, indicate encoding !\n",
-                    NULL, NULL);
-    } else {
-        char buffer[150];
 
-       snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-                       ctxt->input->cur[0], ctxt->input->cur[1],
-                       ctxt->input->cur[2], ctxt->input->cur[3]);
-       __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
-                    "Input is not proper UTF-8, indicate encoding !\n%s",
-                    BAD_CAST buffer, NULL);
+encoding_error:
+    /* Only report the first error */
+    if ((ctxt->input->flags & XML_INPUT_ENCODING_ERROR) == 0) {
+        if ((ctxt == NULL) || (ctxt->input == NULL) ||
+            (ctxt->input->end - ctxt->input->cur < 4)) {
+            __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+                         "Input is not proper UTF-8, indicate encoding !\n",
+                         NULL, NULL);
+        } else {
+            char buffer[150];
+
+            snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+                            ctxt->input->cur[0], ctxt->input->cur[1],
+                            ctxt->input->cur[2], ctxt->input->cur[3]);
+            __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+                         "Input is not proper UTF-8, indicate encoding !\n%s",
+                         BAD_CAST buffer, NULL);
+        }
+        ctxt->input->flags |= XML_INPUT_ENCODING_ERROR;
     }
-    ctxt->charset = XML_CHAR_ENCODING_8859_1;
     ctxt->input->cur++;
     return;
 }
@@ -525,6 +814,8 @@ encoding_error:
  * @ctxt:  the XML parser context
  * @len:  pointer to the length of the char read
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * The current char value, if using UTF-8 this may actually span multiple
  * bytes in the input buffer. Implement the end of line normalization:
  * 2.11 End-of-Line Handling
@@ -540,148 +831,145 @@ encoding_error:
 
 int
 xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
+    const unsigned char *cur;
+    size_t avail;
+    int c;
+
     if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
     if (ctxt->instate == XML_PARSER_EOF)
        return(0);
 
-    if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
-           *len = 1;
-           return((int) *ctxt->input->cur);
-    }
-    if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
-       /*
-        * We are supposed to handle UTF8, check it's valid
-        * From rfc2044: encoding of the Unicode values on UTF-8:
-        *
-        * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
-        * 0000 0000-0000 007F   0xxxxxxx
-        * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
-        * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
-        *
-        * Check for the 0x110000 limit too
-        */
-       const unsigned char *cur = ctxt->input->cur;
-       unsigned char c;
-       unsigned int val;
-
-       c = *cur;
-       if (c & 0x80) {
-           if (((c & 0x40) == 0) || (c == 0xC0))
-               goto encoding_error;
-           if (cur[1] == 0) {
-               xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                cur = ctxt->input->cur;
-            }
-           if ((cur[1] & 0xc0) != 0x80)
-               goto encoding_error;
-           if ((c & 0xe0) == 0xe0) {
-               if (cur[2] == 0) {
-                   xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                    cur = ctxt->input->cur;
-                }
-               if ((cur[2] & 0xc0) != 0x80)
-                   goto encoding_error;
-               if ((c & 0xf0) == 0xf0) {
-                   if (cur[3] == 0) {
-                       xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-                        cur = ctxt->input->cur;
-                    }
-                   if (((c & 0xf8) != 0xf0) ||
-                       ((cur[3] & 0xc0) != 0x80))
-                       goto encoding_error;
-                   /* 4-byte code */
-                   *len = 4;
-                   val = (cur[0] & 0x7) << 18;
-                   val |= (cur[1] & 0x3f) << 12;
-                   val |= (cur[2] & 0x3f) << 6;
-                   val |= cur[3] & 0x3f;
-                   if (val < 0x10000)
-                       goto encoding_error;
-               } else {
-                 /* 3-byte code */
-                   *len = 3;
-                   val = (cur[0] & 0xf) << 12;
-                   val |= (cur[1] & 0x3f) << 6;
-                   val |= cur[2] & 0x3f;
-                   if (val < 0x800)
-                       goto encoding_error;
-               }
-           } else {
-             /* 2-byte code */
-               *len = 2;
-               val = (cur[0] & 0x1f) << 6;
-               val |= cur[1] & 0x3f;
-               if (val < 0x80)
-                   goto encoding_error;
-           }
-           if (!IS_CHAR(val)) {
-               xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
-                                 "Char 0x%X out of allowed range\n", val);
-           }
-           return(val);
-       } else {
-           /* 1-byte code */
-           *len = 1;
-           if (*ctxt->input->cur == 0)
-               xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
-           if ((*ctxt->input->cur == 0) &&
-               (ctxt->input->end > ctxt->input->cur)) {
-               xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
-                                 "Char 0x0 out of allowed range\n", 0);
-           }
-           if (*ctxt->input->cur == 0xD) {
-               if (ctxt->input->cur[1] == 0xA) {
-                   ctxt->input->cur++;
-               }
-               return(0xA);
-           }
-           return((int) *ctxt->input->cur);
-       }
+    avail = ctxt->input->end - ctxt->input->cur;
+
+    if (avail < INPUT_CHUNK) {
+        xmlParserGrow(ctxt);
+        if (ctxt->instate == XML_PARSER_EOF)
+            return(0);
+        avail = ctxt->input->end - ctxt->input->cur;
     }
-    /*
-     * Assume it's a fixed length encoding (1) with
-     * a compatible encoding for the ASCII set, since
-     * XML constructs only use < 128 chars
-     */
-    *len = 1;
-    if (*ctxt->input->cur == 0xD) {
-       if (ctxt->input->cur[1] == 0xA) {
-           ctxt->input->cur++;
-       }
-       return(0xA);
+
+    cur = ctxt->input->cur;
+    c = *cur;
+
+    if (c < 0x80) {
+       /* 1-byte code */
+        if (c < 0x20) {
+            /*
+             *   2.11 End-of-Line Handling
+             *   the literal two-character sequence "#xD#xA" or a standalone
+             *   literal #xD, an XML processor must pass to the application
+             *   the single character #xA.
+             */
+            if (c == '\r') {
+                /*
+                 * TODO: This function shouldn't change the 'cur' pointer
+                 * as side effect, but the NEXTL macro in parser.c relies
+                 * on this behavior when incrementing line numbers.
+                 */
+                if (cur[1] == '\n')
+                    ctxt->input->cur++;
+                *len = 1;
+                c = '\n';
+            } else if (c == 0) {
+                if (ctxt->input->cur >= ctxt->input->end) {
+                    *len = 0;
+                } else {
+                    *len = 1;
+                    /*
+                     * TODO: Null bytes should be handled by callers,
+                     * but this can be tricky.
+                     */
+                    xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
+                            "Char 0x0 out of allowed range\n", c);
+                }
+            } else {
+                *len = 1;
+            }
+        } else {
+            *len = 1;
+        }
+
+        return(c);
+    } else {
+        int val;
+
+        if (avail < 2)
+            goto incomplete_sequence;
+        if ((cur[1] & 0xc0) != 0x80)
+            goto encoding_error;
+
+        if (c < 0xe0) {
+            /* 2-byte code */
+            if (c < 0xc2)
+                goto encoding_error;
+            val = (c & 0x1f) << 6;
+            val |= cur[1] & 0x3f;
+            *len = 2;
+        } else {
+            if (avail < 3)
+                goto incomplete_sequence;
+            if ((cur[2] & 0xc0) != 0x80)
+                goto encoding_error;
+
+            if (c < 0xf0) {
+                /* 3-byte code */
+                val = (c & 0xf) << 12;
+                val |= (cur[1] & 0x3f) << 6;
+                val |= cur[2] & 0x3f;
+                if ((val < 0x800) || ((val >= 0xd800) && (val < 0xe000)))
+                    goto encoding_error;
+                *len = 3;
+            } else {
+                if (avail < 4)
+                    goto incomplete_sequence;
+                if ((cur[3] & 0xc0) != 0x80)
+                    goto encoding_error;
+
+                /* 4-byte code */
+                val = (c & 0x0f) << 18;
+                val |= (cur[1] & 0x3f) << 12;
+                val |= (cur[2] & 0x3f) << 6;
+                val |= cur[3] & 0x3f;
+                if ((val < 0x10000) || (val >= 0x110000))
+                    goto encoding_error;
+                *len = 4;
+            }
+        }
+
+        return(val);
     }
-    return((int) *ctxt->input->cur);
+
 encoding_error:
-    /*
-     * An encoding problem may arise from a truncated input buffer
-     * splitting a character in the middle. In that case do not raise
-     * an error but return 0 to indicate an end of stream problem
-     */
-    if (ctxt->input->end - ctxt->input->cur < 4) {
-       *len = 0;
-       return(0);
+    /* Only report the first error */
+    if ((ctxt->input->flags & XML_INPUT_ENCODING_ERROR) == 0) {
+        if (ctxt->input->end - ctxt->input->cur < 4) {
+            __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+                         "Input is not proper UTF-8, indicate encoding !\n",
+                         NULL, NULL);
+        } else {
+            char buffer[150];
+
+            snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+                            ctxt->input->cur[0], ctxt->input->cur[1],
+                            ctxt->input->cur[2], ctxt->input->cur[3]);
+            __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+                         "Input is not proper UTF-8, indicate encoding !\n%s",
+                         BAD_CAST buffer, NULL);
+        }
+        ctxt->input->flags |= XML_INPUT_ENCODING_ERROR;
     }
+    *len = 1;
+    return(0xFFFD); /* U+FFFD Replacement Character */
 
+incomplete_sequence:
     /*
-     * If we detect an UTF8 error that probably mean that the
-     * input encoding didn't get properly advertised in the
-     * declaration header. Report the error and switch the encoding
-     * to ISO-Latin-1 (if you don't like this policy, just declare the
-     * encoding !)
+     * An encoding problem may arise from a truncated input buffer
+     * splitting a character in the middle. In that case do not raise
+     * an error but return 0. This should only happen when push parsing
+     * char data.
      */
-    {
-        char buffer[150];
-
-       snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-                       ctxt->input->cur[0], ctxt->input->cur[1],
-                       ctxt->input->cur[2], ctxt->input->cur[3]);
-       __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
-                    "Input is not proper UTF-8, indicate encoding !\n%s",
-                    BAD_CAST buffer, NULL);
-    }
-    ctxt->charset = XML_CHAR_ENCODING_8859_1;
-    *len = 1;
-    return((int) *ctxt->input->cur);
+    *len = 0;
+    return(0);
 }
 
 /**
@@ -690,6 +978,8 @@ encoding_error:
  * @cur:  pointer to the beginning of the char
  * @len:  pointer to the length of the char read
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * The current char value, if using UTF-8 this may actually span multiple
  * bytes in the input buffer.
  *
@@ -697,103 +987,18 @@ encoding_error:
  */
 
 int
-xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
-{
-    if ((len == NULL) || (cur == NULL)) return(0);
-    if ((ctxt == NULL) || (ctxt->charset == XML_CHAR_ENCODING_UTF8)) {
-        /*
-         * We are supposed to handle UTF8, check it's valid
-         * From rfc2044: encoding of the Unicode values on UTF-8:
-         *
-         * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
-         * 0000 0000-0000 007F   0xxxxxxx
-         * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
-         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
-         *
-         * Check for the 0x110000 limit too
-         */
-        unsigned char c;
-        unsigned int val;
-
-        c = *cur;
-        if (c & 0x80) {
-            if ((cur[1] & 0xc0) != 0x80)
-                goto encoding_error;
-            if ((c & 0xe0) == 0xe0) {
+xmlStringCurrentChar(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
+                     const xmlChar *cur, int *len) {
+    int c;
 
-                if ((cur[2] & 0xc0) != 0x80)
-                    goto encoding_error;
-                if ((c & 0xf0) == 0xf0) {
-                    if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80))
-                        goto encoding_error;
-                    /* 4-byte code */
-                    *len = 4;
-                    val = (cur[0] & 0x7) << 18;
-                    val |= (cur[1] & 0x3f) << 12;
-                    val |= (cur[2] & 0x3f) << 6;
-                    val |= cur[3] & 0x3f;
-                } else {
-                    /* 3-byte code */
-                    *len = 3;
-                    val = (cur[0] & 0xf) << 12;
-                    val |= (cur[1] & 0x3f) << 6;
-                    val |= cur[2] & 0x3f;
-                }
-            } else {
-                /* 2-byte code */
-                *len = 2;
-                val = (cur[0] & 0x1f) << 6;
-                val |= cur[1] & 0x3f;
-            }
-            if (!IS_CHAR(val)) {
-               xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
-                                 "Char 0x%X out of allowed range\n", val);
-            }
-            return (val);
-        } else {
-            /* 1-byte code */
-            *len = 1;
-            return ((int) *cur);
-        }
-    }
-    /*
-     * Assume it's a fixed length encoding (1) with
-     * a compatible encoding for the ASCII set, since
-     * XML constructs only use < 128 chars
-     */
-    *len = 1;
-    return ((int) *cur);
-encoding_error:
+    if ((cur == NULL) || (len == NULL))
+        return(0);
 
-    /*
-     * An encoding problem may arise from a truncated input buffer
-     * splitting a character in the middle. In that case do not raise
-     * an error but return 0 to indicate an end of stream problem
-     */
-    if ((ctxt == NULL) || (ctxt->input == NULL) ||
-        (ctxt->input->end - ctxt->input->cur < 4)) {
-       *len = 0;
-       return(0);
-    }
-    /*
-     * If we detect an UTF8 error that probably mean that the
-     * input encoding didn't get properly advertised in the
-     * declaration header. Report the error and switch the encoding
-     * to ISO-Latin-1 (if you don't like this policy, just declare the
-     * encoding !)
-     */
-    {
-        char buffer[150];
+    /* cur is zero-terminated, so we can lie about its length. */
+    *len = 4;
+    c = xmlGetUTF8Char(cur, len);
 
-       snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
-                       ctxt->input->cur[0], ctxt->input->cur[1],
-                       ctxt->input->cur[2], ctxt->input->cur[3]);
-       __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
-                    "Input is not proper UTF-8, indicate encoding !\n%s",
-                    BAD_CAST buffer, NULL);
-    }
-    *len = 1;
-    return ((int) *cur);
+    return((c < 0) ? 0 : c);
 }
 
 /**
@@ -807,7 +1012,7 @@ encoding_error:
  */
 int
 xmlCopyCharMultiByte(xmlChar *out, int val) {
-    if (out == NULL) return(0);
+    if ((out == NULL) || (val < 0)) return(0);
     /*
      * We are supposed to handle UTF8, check it's valid
      * From rfc2044: encoding of the Unicode values on UTF-8:
@@ -833,7 +1038,7 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
            *out++= ((val >> bits) & 0x3F) | 0x80 ;
        return (out - savedout);
     }
-    *out = (xmlChar) val;
+    *out = val;
     return 1;
 }
 
@@ -850,12 +1055,12 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
 
 int
 xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
-    if (out == NULL) return(0);
+    if ((out == NULL) || (val < 0)) return(0);
     /* the len parameter is ignored */
     if  (val >= 0x80) {
        return(xmlCopyCharMultiByte (out, val));
     }
-    *out = (xmlChar) val;
+    *out = val;
     return 1;
 }
 
@@ -865,315 +1070,413 @@ xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
  *                                                                     *
  ************************************************************************/
 
-static int
-xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
-                          xmlCharEncodingHandlerPtr handler, int len);
+static xmlCharEncodingHandlerPtr
+xmlDetectEBCDIC(xmlParserInputPtr input) {
+    xmlChar out[200];
+    xmlCharEncodingHandlerPtr handler;
+    int inlen, outlen, res, i;
+
+    /*
+     * To detect the EBCDIC code page, we convert the first 200 bytes
+     * to EBCDIC-US and try to find the encoding declaration.
+     */
+    handler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EBCDIC);
+    if (handler == NULL)
+        return(NULL);
+    outlen = sizeof(out) - 1;
+    inlen = input->end - input->cur;
+    res = xmlEncInputChunk(handler, out, &outlen, input->cur, &inlen);
+    if (res < 0)
+        return(handler);
+    out[outlen] = 0;
+
+    for (i = 0; i < outlen; i++) {
+        if (out[i] == '>')
+            break;
+        if ((out[i] == 'e') &&
+            (xmlStrncmp(out + i, BAD_CAST "encoding", 8) == 0)) {
+            int start, cur, quote;
+
+            i += 8;
+            while (IS_BLANK_CH(out[i]))
+                i += 1;
+            if (out[i++] != '=')
+                break;
+            while (IS_BLANK_CH(out[i]))
+                i += 1;
+            quote = out[i++];
+            if ((quote != '\'') && (quote != '"'))
+                break;
+            start = i;
+            cur = out[i];
+            while (((cur >= 'a') && (cur <= 'z')) ||
+                   ((cur >= 'A') && (cur <= 'Z')) ||
+                   ((cur >= '0') && (cur <= '9')) ||
+                   (cur == '.') || (cur == '_') ||
+                   (cur == '-'))
+                cur = out[++i];
+            if (cur != quote)
+                break;
+            out[i] = 0;
+            xmlCharEncCloseFunc(handler);
+            return(xmlFindCharEncodingHandler((char *) out + start));
+        }
+    }
+
+    /*
+     * ICU handlers are stateful, so we have to recreate them.
+     */
+    xmlCharEncCloseFunc(handler);
+    return(xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EBCDIC));
+}
+
 /**
  * xmlSwitchEncoding:
  * @ctxt:  the parser context
  * @enc:  the encoding value (number)
  *
- * change the input functions when discovering the character encoding
- * of a given entity.
+ * Use encoding specified by enum to decode input data.
+ *
+ * This function can be used to enforce the encoding of chunks passed
+ * to xmlParseChunk.
  *
  * Returns 0 in case of success, -1 otherwise
  */
 int
 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
 {
-    xmlCharEncodingHandlerPtr handler;
-    int len = -1;
+    xmlCharEncodingHandlerPtr handler = NULL;
+    int check = 1;
     int ret;
 
-    if (ctxt == NULL) return(-1);
+    if ((ctxt == NULL) || (ctxt->input == NULL))
+        return(-1);
+
     switch (enc) {
-       case XML_CHAR_ENCODING_ERROR:
-           __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING,
-                          "encoding unknown\n", NULL, NULL);
-           return(-1);
        case XML_CHAR_ENCODING_NONE:
-           /* let's assume it's UTF-8 without the XML decl */
-           ctxt->charset = XML_CHAR_ENCODING_UTF8;
-           return(0);
        case XML_CHAR_ENCODING_UTF8:
-           /* default encoding, no conversion should be needed */
-           ctxt->charset = XML_CHAR_ENCODING_UTF8;
-
-           /*
-            * Errata on XML-1.0 June 20 2001
-            * Specific handling of the Byte Order Mark for
-            * UTF-8
-            */
-           if ((ctxt->input != NULL) &&
-               (ctxt->input->cur[0] == 0xEF) &&
-               (ctxt->input->cur[1] == 0xBB) &&
-               (ctxt->input->cur[2] == 0xBF)) {
-               ctxt->input->cur += 3;
-           }
-           return(0);
-    case XML_CHAR_ENCODING_UTF16LE:
-    case XML_CHAR_ENCODING_UTF16BE:
-        /*The raw input characters are encoded
-         *in UTF-16. As we expect this function
-         *to be called after xmlCharEncInFunc, we expect
-         *ctxt->input->cur to contain UTF-8 encoded characters.
-         *So the raw UTF16 Byte Order Mark
-         *has also been converted into
-         *an UTF-8 BOM. Let's skip that BOM.
-         */
-        if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) &&
-            (ctxt->input->cur[0] == 0xEF) &&
-            (ctxt->input->cur[1] == 0xBB) &&
-            (ctxt->input->cur[2] == 0xBF)) {
-            ctxt->input->cur += 3;
-        }
-        len = 90;
-       break;
-    case XML_CHAR_ENCODING_UCS2:
-        len = 90;
-       break;
-    case XML_CHAR_ENCODING_UCS4BE:
-    case XML_CHAR_ENCODING_UCS4LE:
-    case XML_CHAR_ENCODING_UCS4_2143:
-    case XML_CHAR_ENCODING_UCS4_3412:
-        len = 180;
-       break;
-    case XML_CHAR_ENCODING_EBCDIC:
-    case XML_CHAR_ENCODING_8859_1:
-    case XML_CHAR_ENCODING_8859_2:
-    case XML_CHAR_ENCODING_8859_3:
-    case XML_CHAR_ENCODING_8859_4:
-    case XML_CHAR_ENCODING_8859_5:
-    case XML_CHAR_ENCODING_8859_6:
-    case XML_CHAR_ENCODING_8859_7:
-    case XML_CHAR_ENCODING_8859_8:
-    case XML_CHAR_ENCODING_8859_9:
-    case XML_CHAR_ENCODING_ASCII:
-    case XML_CHAR_ENCODING_2022_JP:
-    case XML_CHAR_ENCODING_SHIFT_JIS:
-    case XML_CHAR_ENCODING_EUC_JP:
-        len = 45;
-       break;
-    }
-    handler = xmlGetCharEncodingHandler(enc);
-    if (handler == NULL) {
-       /*
-        * Default handlers.
-        */
-       switch (enc) {
-           case XML_CHAR_ENCODING_ASCII:
-               /* default encoding, no conversion should be needed */
-               ctxt->charset = XML_CHAR_ENCODING_UTF8;
-               return(0);
-           case XML_CHAR_ENCODING_8859_1:
-               if ((ctxt->inputNr == 1) &&
-                   (ctxt->encoding == NULL) &&
-                   (ctxt->input != NULL) &&
-                   (ctxt->input->encoding != NULL)) {
-                   ctxt->encoding = xmlStrdup(ctxt->input->encoding);
-               }
-               ctxt->charset = enc;
-               return(0);
-           default:
-               __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
-                        "encoding not supported: %s\n",
-                       BAD_CAST xmlGetCharEncodingName(enc), NULL);
-                /*
-                 * TODO: We could recover from errors in external entities
-                 * if we didn't stop the parser. But most callers of this
-                 * function don't check the return value.
-                 */
-                xmlStopParser(ctxt);
-                return(-1);
-        }
-    }
-    ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
-    if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
+        case XML_CHAR_ENCODING_ASCII:
+            check = 0;
+            break;
+        case XML_CHAR_ENCODING_EBCDIC:
+            handler = xmlDetectEBCDIC(ctxt->input);
+            break;
+        default:
+            handler = xmlGetCharEncodingHandler(enc);
+            break;
+    }
+
+    if ((check) && (handler == NULL)) {
+        const char *name = xmlGetCharEncodingName(enc);
+
+        __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
+                "encoding not supported: %s\n",
+                BAD_CAST (name ? name : "<null>"), NULL);
         /*
-        * on encoding conversion errors, stop the parser
-        */
+         * TODO: We could recover from errors in external entities
+         * if we didn't stop the parser. But most callers of this
+         * function don't check the return value.
+         */
         xmlStopParser(ctxt);
-       ctxt->errNo = XML_I18N_CONV_FAILED;
+        return(-1);
     }
+
+    ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
+
+    if ((ret >= 0) && (enc == XML_CHAR_ENCODING_NONE)) {
+        ctxt->input->flags &= ~XML_INPUT_HAS_ENCODING;
+    }
+
     return(ret);
 }
 
 /**
- * xmlSwitchInputEncodingInt:
+ * xmlSwitchInputEncoding:
  * @ctxt:  the parser context
  * @input:  the input stream
  * @handler:  the encoding handler
- * @len:  the number of bytes to convert for the first line or -1
  *
- * change the input functions when discovering the character encoding
- * of a given entity.
+ * DEPRECATED: Internal function, don't use.
+ *
+ * Use encoding handler to decode input data.
  *
  * Returns 0 in case of success, -1 otherwise
  */
-static int
-xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
-                          xmlCharEncodingHandlerPtr handler, int len)
+int
+xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
+                       xmlCharEncodingHandlerPtr handler)
 {
     int nbchars;
+    xmlParserInputBufferPtr in;
 
-    if (handler == NULL)
-        return (-1);
-    if (input == NULL)
-        return (-1);
-    if (input->buf != NULL) {
-       ctxt->charset = XML_CHAR_ENCODING_UTF8;
+    if ((input == NULL) || (input->buf == NULL)) {
+        xmlCharEncCloseFunc(handler);
+       return (-1);
+    }
+    in = input->buf;
 
-        if (input->buf->encoder != NULL) {
-            /*
-             * Check in case the auto encoding detection triggered
-             * in already.
-             */
-            if (input->buf->encoder == handler)
-                return (0);
+    input->flags |= XML_INPUT_HAS_ENCODING;
 
-            /*
-             * "UTF-16" can be used for both LE and BE
-             if ((!xmlStrncmp(BAD_CAST input->buf->encoder->name,
-             BAD_CAST "UTF-16", 6)) &&
-             (!xmlStrncmp(BAD_CAST handler->name,
-             BAD_CAST "UTF-16", 6))) {
-             return(0);
-             }
-             */
+    /*
+     * UTF-8 requires no encoding handler.
+     */
+    if ((handler != NULL) &&
+        (xmlStrcasecmp(BAD_CAST handler->name, BAD_CAST "UTF-8") == 0)) {
+        xmlCharEncCloseFunc(handler);
+        handler = NULL;
+    }
 
-            /*
-             * Note: this is a bit dangerous, but that's what it
-             * takes to use nearly compatible signature for different
-             * encodings.
-             *
-             * FIXME: Encoders might buffer partial byte sequences, so
-             * this probably can't work. We should return an error and
-             * make sure that callers never try to switch the encoding
-             * twice.
-             */
-            xmlCharEncCloseFunc(input->buf->encoder);
-            input->buf->encoder = handler;
-            return (0);
-        }
-        input->buf->encoder = handler;
+    if (in->encoder == handler)
+        return (0);
 
+    if (in->encoder != NULL) {
         /*
-         * Is there already some content down the pipe to convert ?
+         * Switching encodings during parsing is a really bad idea,
+         * but Chromium can switch between ISO-8859-1 and UTF-16 before
+         * separate calls to xmlParseChunk.
+         *
+         * TODO: We should check whether the "raw" input buffer is empty and
+         * convert the old content using the old encoder.
          */
-        if (xmlBufIsEmpty(input->buf->buffer) == 0) {
-            int processed;
-           unsigned int use;
 
-            /*
-             * Specific handling of the Byte Order Mark for
-             * UTF-16
-             */
-            if ((handler->name != NULL) &&
-                (!strcmp(handler->name, "UTF-16LE") ||
-                 !strcmp(handler->name, "UTF-16")) &&
-                (input->cur[0] == 0xFF) && (input->cur[1] == 0xFE)) {
-                input->cur += 2;
-            }
-            if ((handler->name != NULL) &&
-                (!strcmp(handler->name, "UTF-16BE")) &&
-                (input->cur[0] == 0xFE) && (input->cur[1] == 0xFF)) {
-                input->cur += 2;
-            }
-            /*
-             * Errata on XML-1.0 June 20 2001
-             * Specific handling of the Byte Order Mark for
-             * UTF-8
-             */
-            if ((handler->name != NULL) &&
-                (!strcmp(handler->name, "UTF-8")) &&
-                (input->cur[0] == 0xEF) &&
-                (input->cur[1] == 0xBB) && (input->cur[2] == 0xBF)) {
-                input->cur += 3;
-            }
-
-            /*
-             * Shrink the current input buffer.
-             * Move it as the raw buffer and create a new input buffer
-             */
-            processed = input->cur - input->base;
-            xmlBufShrink(input->buf->buffer, processed);
-            input->buf->raw = input->buf->buffer;
-            input->buf->buffer = xmlBufCreate();
-           input->buf->rawconsumed = processed;
-           use = xmlBufUse(input->buf->raw);
-
-            if (ctxt->html) {
-                /*
-                 * convert as much as possible of the buffer
-                 */
-                nbchars = xmlCharEncInput(input->buf, 1);
-            } else {
-                /*
-                 * convert just enough to get
-                 * '<?xml version="1.0" encoding="xxx"?>'
-                 * parsed with the autodetected encoding
-                 * into the parser reading buffer.
-                 */
-                nbchars = xmlCharEncFirstLineInput(input->buf, len);
-            }
-            xmlBufResetInput(input->buf->buffer, input);
-            if (nbchars < 0) {
-                xmlErrInternal(ctxt,
-                               "switching encoding: encoder error\n",
-                               NULL);
-                return (-1);
-            }
-           input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
-        }
+        xmlCharEncCloseFunc(in->encoder);
+        in->encoder = handler;
         return (0);
-    } else {
-       xmlErrInternal(ctxt,
-                "static memory buffer doesn't support encoding\n", NULL);
+    }
+
+    in->encoder = handler;
+
+    /*
+     * Is there already some content down the pipe to convert ?
+     */
+    if (xmlBufIsEmpty(in->buffer) == 0) {
+        size_t processed;
+
         /*
-         * Callers assume that the input buffer takes ownership of the
-         * encoding handler. xmlCharEncCloseFunc frees unregistered
-         * handlers and avoids a memory leak.
+         * Shrink the current input buffer.
+         * Move it as the raw buffer and create a new input buffer
          */
-        xmlCharEncCloseFunc(handler);
-       return (-1);
+        processed = input->cur - input->base;
+        xmlBufShrink(in->buffer, processed);
+        input->consumed += processed;
+        in->raw = in->buffer;
+        in->buffer = xmlBufCreate();
+        in->rawconsumed = processed;
+
+        nbchars = xmlCharEncInput(in);
+        xmlBufResetInput(in->buffer, input);
+        if (nbchars < 0) {
+            /* TODO: This could be an out of memory or an encoding error. */
+            xmlErrInternal(ctxt,
+                           "switching encoding: encoder error\n",
+                           NULL);
+            xmlHaltParser(ctxt);
+            return (-1);
+        }
     }
+    return (0);
 }
 
 /**
- * xmlSwitchInputEncoding:
+ * xmlSwitchToEncoding:
  * @ctxt:  the parser context
- * @input:  the input stream
  * @handler:  the encoding handler
  *
- * DEPRECATED: Use xmlSwitchToEncoding
+ * Use encoding handler to decode input data.
  *
- * change the input functions when discovering the character encoding
- * of a given entity.
+ * This function can be used to enforce the encoding of chunks passed
+ * to xmlParseChunk.
  *
  * Returns 0 in case of success, -1 otherwise
  */
 int
-xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
-                          xmlCharEncodingHandlerPtr handler) {
-    return(xmlSwitchInputEncodingInt(ctxt, input, handler, -1));
+xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
+{
+    if (ctxt == NULL)
+        return(-1);
+    return(xmlSwitchInputEncoding(ctxt, ctxt->input, handler));
 }
 
 /**
- * xmlSwitchToEncoding:
+ * xmlDetectEncoding:
  * @ctxt:  the parser context
- * @handler:  the encoding handler
  *
- * change the input functions when discovering the character encoding
- * of a given entity.
+ * Handle optional BOM, detect and switch to encoding.
  *
- * Returns 0 in case of success, -1 otherwise
+ * Assumes that there are at least four bytes in the input buffer.
  */
-int
-xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
-{
-    if (ctxt == NULL)
-        return(-1);
-    return(xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, -1));
+void
+xmlDetectEncoding(xmlParserCtxtPtr ctxt) {
+    const xmlChar *in;
+    xmlCharEncoding enc;
+    int bomSize;
+    int autoFlag = 0;
+
+    if (xmlParserGrow(ctxt) < 0)
+        return;
+    in = ctxt->input->cur;
+    if (ctxt->input->end - in < 4)
+        return;
+
+    if (ctxt->input->flags & XML_INPUT_HAS_ENCODING) {
+        /*
+         * If the encoding was already set, only skip the BOM which was
+         * possibly decoded to UTF-8.
+         */
+        if ((in[0] == 0xEF) && (in[1] == 0xBB) && (in[2] == 0xBF)) {
+            ctxt->input->cur += 3;
+        }
+
+        return;
+    }
+
+    enc = XML_CHAR_ENCODING_NONE;
+    bomSize = 0;
+
+    switch (in[0]) {
+        case 0x00:
+            if ((in[1] == 0x00) && (in[2] == 0x00) && (in[3] == 0x3C)) {
+                enc = XML_CHAR_ENCODING_UCS4BE;
+                autoFlag = XML_INPUT_AUTO_OTHER;
+            } else if ((in[1] == 0x3C) && (in[2] == 0x00) && (in[3] == 0x3F)) {
+                enc = XML_CHAR_ENCODING_UTF16BE;
+                autoFlag = XML_INPUT_AUTO_UTF16BE;
+            }
+            break;
+
+        case 0x3C:
+            if (in[1] == 0x00) {
+                if ((in[2] == 0x00) && (in[3] == 0x00)) {
+                    enc = XML_CHAR_ENCODING_UCS4LE;
+                    autoFlag = XML_INPUT_AUTO_OTHER;
+                } else if ((in[2] == 0x3F) && (in[3] == 0x00)) {
+                    enc = XML_CHAR_ENCODING_UTF16LE;
+                    autoFlag = XML_INPUT_AUTO_UTF16LE;
+                }
+            }
+            break;
+
+        case 0x4C:
+           if ((in[1] == 0x6F) && (in[2] == 0xA7) && (in[3] == 0x94)) {
+               enc = XML_CHAR_ENCODING_EBCDIC;
+                autoFlag = XML_INPUT_AUTO_OTHER;
+            }
+            break;
+
+        case 0xEF:
+            if ((in[1] == 0xBB) && (in[2] == 0xBF)) {
+                enc = XML_CHAR_ENCODING_UTF8;
+                autoFlag = XML_INPUT_AUTO_UTF8;
+                bomSize = 3;
+            }
+            break;
+
+        case 0xFE:
+            if (in[1] == 0xFF) {
+                enc = XML_CHAR_ENCODING_UTF16BE;
+                autoFlag = XML_INPUT_AUTO_UTF16BE;
+                bomSize = 2;
+            }
+            break;
+
+        case 0xFF:
+            if (in[1] == 0xFE) {
+                enc = XML_CHAR_ENCODING_UTF16LE;
+                autoFlag = XML_INPUT_AUTO_UTF16LE;
+                bomSize = 2;
+            }
+            break;
+    }
+
+    if (bomSize > 0) {
+        ctxt->input->cur += bomSize;
+    }
+
+    if (enc != XML_CHAR_ENCODING_NONE) {
+        ctxt->input->flags |= autoFlag;
+        xmlSwitchEncoding(ctxt, enc);
+    }
+}
+
+/**
+ * xmlSetDeclaredEncoding:
+ * @ctxt:  the parser context
+ * @encoding:  declared encoding
+ *
+ * Set the encoding from a declaration in the document.
+ *
+ * If no encoding was set yet, switch the encoding. Otherwise, only warn
+ * about encoding mismatches.
+ *
+ * Takes ownership of 'encoding'.
+ */
+void
+xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding) {
+    if (ctxt->encoding != NULL)
+        xmlFree((xmlChar *) ctxt->encoding);
+    ctxt->encoding = encoding;
+
+    if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) &&
+        ((ctxt->options & XML_PARSE_IGNORE_ENC) == 0)) {
+        xmlCharEncodingHandlerPtr handler;
+
+        handler = xmlFindCharEncodingHandler((const char *) encoding);
+        if (handler == NULL) {
+            __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
+                             "Unsupported encoding: %s\n",
+                             encoding, NULL);
+            return;
+        }
+
+        xmlSwitchToEncoding(ctxt, handler);
+        ctxt->input->flags |= XML_INPUT_USES_ENC_DECL;
+    } else if (ctxt->input->flags & XML_INPUT_AUTO_ENCODING) {
+        static const char *allowedUTF8[] = {
+            "UTF-8", "UTF8", NULL
+        };
+        static const char *allowedUTF16LE[] = {
+            "UTF-16", "UTF-16LE", "UTF16", NULL
+        };
+        static const char *allowedUTF16BE[] = {
+            "UTF-16", "UTF-16BE", "UTF16", NULL
+        };
+        const char **allowed = NULL;
+        const char *autoEnc = NULL;
+
+        switch (ctxt->input->flags & XML_INPUT_AUTO_ENCODING) {
+            case XML_INPUT_AUTO_UTF8:
+                allowed = allowedUTF8;
+                autoEnc = "UTF-8";
+                break;
+            case XML_INPUT_AUTO_UTF16LE:
+                allowed = allowedUTF16LE;
+                autoEnc = "UTF-16LE";
+                break;
+            case XML_INPUT_AUTO_UTF16BE:
+                allowed = allowedUTF16BE;
+                autoEnc = "UTF-16BE";
+                break;
+        }
+
+        if (allowed != NULL) {
+            const char **p;
+            int match = 0;
+
+            for (p = allowed; *p != NULL; p++) {
+                if (xmlStrcasecmp(encoding, BAD_CAST *p) == 0) {
+                    match = 1;
+                    break;
+                }
+            }
+
+            if (match == 0) {
+                xmlWarningMsg(ctxt, XML_WAR_ENCODING_MISMATCH,
+                              "Encoding '%s' doesn't match "
+                              "auto-detected '%s'\n",
+                              encoding, BAD_CAST autoEnc);
+            }
+        }
+    }
 }
 
 /************************************************************************
@@ -1194,7 +1497,6 @@ xmlFreeInputStream(xmlParserInputPtr input) {
 
     if (input->filename != NULL) xmlFree((char *) input->filename);
     if (input->directory != NULL) xmlFree((char *) input->directory);
-    if (input->encoding != NULL) xmlFree((char *) input->encoding);
     if (input->version != NULL) xmlFree((char *) input->version);
     if ((input->free != NULL) && (input->base != NULL))
         input->free((xmlChar *) input->base);
@@ -1223,15 +1525,19 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
     memset(input, 0, sizeof(xmlParserInput));
     input->line = 1;
     input->col = 1;
-    input->standalone = -1;
 
     /*
      * If the context is NULL the id cannot be initialized, but that
      * should not happen while parsing which is the situation where
      * the id is actually needed.
      */
-    if (ctxt != NULL)
+    if (ctxt != NULL) {
+        if (input->id >= INT_MAX) {
+            xmlErrMemory(ctxt, "Input ID overflow\n");
+            return(NULL);
+        }
         input->id = ctxt->input_id++;
+    }
 
     return(input);
 }
@@ -1275,6 +1581,8 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
  * @ctxt:  an XML parser context
  * @entity:  an Entity pointer
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * Create a new input stream based on an xmlEntityPtr
  *
  * Returns the new input stream or NULL
@@ -1299,8 +1607,11 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
                 break;
             case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
             case XML_EXTERNAL_PARAMETER_ENTITY:
-               return(xmlLoadExternalEntity((char *) entity->URI,
-                      (char *) entity->ExternalID, ctxt));
+               input = xmlLoadExternalEntity((char *) entity->URI,
+                      (char *) entity->ExternalID, ctxt);
+                if (input != NULL)
+                    input->entity = entity;
+                return(input);
             case XML_INTERNAL_GENERAL_ENTITY:
                xmlErrInternal(ctxt,
                      "Internal entity %s without content !\n",
@@ -1331,6 +1642,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
     input->cur = entity->content;
     input->length = entity->length;
     input->end = &entity->content[input->length];
+    input->entity = entity;
     return(input);
 }
 
@@ -1345,6 +1657,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
 xmlParserInputPtr
 xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
     xmlParserInputPtr input;
+    xmlParserInputBufferPtr buf;
 
     if (buffer == NULL) {
         xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
@@ -1354,15 +1667,19 @@ xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
     if (xmlParserDebugEntities)
        xmlGenericError(xmlGenericErrorContext,
                "new fixed input: %.30s\n", buffer);
+    buf = xmlParserInputBufferCreateString(buffer);
+    if (buf == NULL) {
+       xmlErrMemory(ctxt, NULL);
+        return(NULL);
+    }
     input = xmlNewInputStream(ctxt);
     if (input == NULL) {
         xmlErrMemory(ctxt,  "couldn't allocate a new input stream\n");
+       xmlFreeParserInputBuffer(buf);
        return(NULL);
     }
-    input->base = buffer;
-    input->cur = buffer;
-    input->length = xmlStrlen(buffer);
-    input->end = &buffer[input->length];
+    input->buf = buf;
+    xmlBufResetInput(input->buf->buffer, input);
     return(input);
 }
 
@@ -1432,16 +1749,19 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
  ************************************************************************/
 
 /**
- * xmlInitParserCtxt:
- * @ctxt:  an XML parser context
+ * xmlInitSAXParserCtxt:
+ * @ctxt:  XML parser context
+ * @sax:  SAX handlert
+ * @userData:  user data
  *
- * Initialize a parser context
+ * Initialize a SAX parser context
  *
  * Returns 0 in case of success and -1 in case of error
  */
 
-int
-xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
+static int
+xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
+                     void *userData)
 {
     xmlParserInputPtr input;
 
@@ -1466,8 +1786,19 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
         xmlErrMemory(NULL, "cannot initialize parser context\n");
        return(-1);
     }
-    else
+    if (sax == NULL) {
+       memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
         xmlSAXVersion(ctxt->sax, 2);
+        ctxt->userData = ctxt;
+    } else {
+       if (sax->initialized == XML_SAX2_MAGIC) {
+           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
+        } else {
+           memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
+           memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
+        }
+        ctxt->userData = userData ? userData : ctxt;
+    }
 
     ctxt->maxatts = 0;
     ctxt->atts = NULL;
@@ -1565,7 +1896,6 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
     ctxt->spaceMax = 10;
     ctxt->spaceTab[0] = -1;
     ctxt->space = &ctxt->spaceTab[0];
-    ctxt->userData = ctxt;
     ctxt->myDoc = NULL;
     ctxt->wellFormed = 1;
     ctxt->nsWellFormed = 1;
@@ -1607,17 +1937,43 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
     ctxt->inSubset = 0;
     ctxt->errNo = XML_ERR_OK;
     ctxt->depth = 0;
-    ctxt->charset = XML_CHAR_ENCODING_UTF8;
     ctxt->catalogs = NULL;
-    ctxt->nbentities = 0;
     ctxt->sizeentities = 0;
     ctxt->sizeentcopy = 0;
     ctxt->input_id = 1;
+    ctxt->maxAmpl = XML_MAX_AMPLIFICATION_DEFAULT;
     xmlInitNodeInfoSeq(&ctxt->node_seq);
+
+    if (ctxt->nsdb == NULL) {
+        ctxt->nsdb = xmlParserNsCreate();
+        if (ctxt->nsdb == NULL) {
+            xmlErrMemory(ctxt, NULL);
+            return(-1);
+        }
+    }
+
     return(0);
 }
 
 /**
+ * xmlInitParserCtxt:
+ * @ctxt:  an XML parser context
+ *
+ * DEPRECATED: Internal function which will be made private in a future
+ * version.
+ *
+ * Initialize a parser context
+ *
+ * Returns 0 in case of success and -1 in case of error
+ */
+
+int
+xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
+{
+    return(xmlInitSAXParserCtxt(ctxt, NULL, NULL));
+}
+
+/**
  * xmlFreeParserCtxt:
  * @ctxt:  an XML parser context
  *
@@ -1655,7 +2011,9 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
     if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
     if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts);
     if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
-    if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);
+    if (ctxt->nsTab != NULL) xmlFree(ctxt->nsTab);
+    if (ctxt->nsdb != NULL) xmlParserNsFree(ctxt->nsdb);
+    if (ctxt->attrHash != NULL) xmlFree(ctxt->attrHash);
     if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
     if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
     if (ctxt->attsDefault != NULL)
@@ -1714,6 +2072,23 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
 xmlParserCtxtPtr
 xmlNewParserCtxt(void)
 {
+    return(xmlNewSAXParserCtxt(NULL, NULL));
+}
+
+/**
+ * xmlNewSAXParserCtxt:
+ * @sax:  SAX handler
+ * @userData:  user data
+ *
+ * Allocate and initialize a new SAX parser context. If userData is NULL,
+ * the parser context will be passed as user data.
+ *
+ * Returns the xmlParserCtxtPtr or NULL if memory allocation failed.
+ */
+
+xmlParserCtxtPtr
+xmlNewSAXParserCtxt(const xmlSAXHandler *sax, void *userData)
+{
     xmlParserCtxtPtr ctxt;
 
     ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
@@ -1722,7 +2097,7 @@ xmlNewParserCtxt(void)
        return(NULL);
     }
     memset(ctxt, 0, sizeof(xmlParserCtxt));
-    if (xmlInitParserCtxt(ctxt) < 0) {
+    if (xmlInitSAXParserCtxt(ctxt, sax, userData) < 0) {
         xmlFreeParserCtxt(ctxt);
        return(NULL);
     }
@@ -1757,6 +2132,8 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
  * @ctx:  an XML parser context
  * @node:  an XML node within the tree
  *
+ * DEPRECATED: Don't use.
+ *
  * Find the parser node info struct for a given node
  *
  * Returns an xmlParserNodeInfo block pointer or NULL
@@ -1782,6 +2159,8 @@ xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx, const xmlNodePtr node)
  * xmlInitNodeInfoSeq:
  * @seq:  a node info sequence pointer
  *
+ * DEPRECATED: Don't use.
+ *
  * -- Initialize (set to initial state) node info sequence
  */
 void
@@ -1798,6 +2177,8 @@ xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
  * xmlClearNodeInfoSeq:
  * @seq:  a node info sequence pointer
  *
+ * DEPRECATED: Don't use.
+ *
  * -- Clear (release memory and reinitialize) node
  *   info sequence
  */
@@ -1816,6 +2197,7 @@ xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
  * @seq:  a node info sequence pointer
  * @node:  an XML node pointer
  *
+ * DEPRECATED: Don't use.
  *
  * xmlParserFindNodeInfoIndex : Find the index that the info record for
  *   the given node is or should be at in a sorted sequence
@@ -1859,6 +2241,8 @@ xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
  * @ctxt:  an XML parser context
  * @info:  a node info sequence pointer
  *
+ * DEPRECATED: Don't use.
+ *
  * Insert node info record into the sorted sequence
  */
 void
@@ -1929,6 +2313,8 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
  * xmlPedanticParserDefault:
  * @val:  int 0 or 1
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_PEDANTIC.
+ *
  * Set and return the previous value for enabling pedantic warnings.
  *
  * Returns the last value for 0 for no substitution, 1 for substitution.
@@ -1946,6 +2332,8 @@ xmlPedanticParserDefault(int val) {
  * xmlLineNumbersDefault:
  * @val:  int 0 or 1
  *
+ * DEPRECATED: The modern options API always enables line numbers.
+ *
  * Set and return the previous value for enabling line numbers in elements
  * contents. This may break on old application and is turned off by default.
  *
@@ -1964,6 +2352,8 @@ xmlLineNumbersDefault(int val) {
  * xmlSubstituteEntitiesDefault:
  * @val:  int 0 or 1
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_NOENT.
+ *
  * Set and return the previous value for default entity support.
  * Initially the parser always keep entity references instead of substituting
  * entity values in the output. This function has to be used to change the
@@ -1986,6 +2376,8 @@ xmlSubstituteEntitiesDefault(int val) {
  * xmlKeepBlanksDefault:
  * @val:  int 0 or 1
  *
+ * DEPRECATED: Use the modern options API with XML_PARSE_NOBLANKS.
+ *
  * Set and return the previous value for default blanks text nodes support.
  * The 1.x version of the parser used an heuristic to try to detect
  * ignorable white spaces. As a result the SAX callback was generating
@@ -2011,7 +2403,10 @@ xmlKeepBlanksDefault(int val) {
     int old = xmlKeepBlanksDefaultValue;
 
     xmlKeepBlanksDefaultValue = val;
-    if (!val) xmlIndentTreeOutput = 1;
+#ifdef LIBXML_OUTPUT_ENABLED
+    if (!val)
+        xmlIndentTreeOutput = 1;
+#endif
     return(old);
 }
 
index cff4469..55ae2d3 100644 (file)
--- a/pattern.c
+++ b/pattern.c
 #include "libxml.h"
 
 #include <string.h>
+#include <libxml/pattern.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
-#include <libxml/hash.h>
 #include <libxml/dict.h>
 #include <libxml/xmlerror.h>
 #include <libxml/parserInternals.h>
-#include <libxml/pattern.h>
 
 #ifdef LIBXML_PATTERN_ENABLED
 
-/* #define DEBUG_STREAMING */
-
 #ifdef ERROR
 #undef ERROR
 #endif
@@ -935,7 +932,6 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
 
        if (IS_BLANK_CH(CUR)) {
            ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL);
-           XML_PAT_FREE_STRING(ctxt, prefix);
            ctxt->error = 1;
            goto error;
        }
@@ -960,12 +956,12 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
                ERROR5(NULL, NULL, NULL,
                    "xmlCompileAttributeTest : no namespace bound to prefix %s\n",
                    prefix);
-               XML_PAT_FREE_STRING(ctxt, prefix);
                ctxt->error = 1;
                goto error;
            }
        }
-       XML_PAT_FREE_STRING(ctxt, prefix);
+        XML_PAT_FREE_STRING(ctxt, name);
+        name = NULL;
        if (token == NULL) {
            if (CUR == '*') {
                NEXT;
@@ -984,6 +980,8 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
     }
     return;
 error:
+    if (name != NULL)
+       XML_PAT_FREE_STRING(ctxt, name);
     if (URL != NULL)
        XML_PAT_FREE_STRING(ctxt, URL)
     if (token != NULL)
@@ -1415,62 +1413,6 @@ error_unfinished:
  *                                                                     *
  ************************************************************************/
 
-#ifdef DEBUG_STREAMING
-static void
-xmlDebugStreamComp(xmlStreamCompPtr stream) {
-    int i;
-
-    if (stream == NULL) {
-        printf("Stream: NULL\n");
-       return;
-    }
-    printf("Stream: %d steps\n", stream->nbStep);
-    for (i = 0;i < stream->nbStep;i++) {
-       if (stream->steps[i].ns != NULL) {
-           printf("{%s}", stream->steps[i].ns);
-       }
-        if (stream->steps[i].name == NULL) {
-           printf("* ");
-       } else {
-           printf("%s ", stream->steps[i].name);
-       }
-       if (stream->steps[i].flags & XML_STREAM_STEP_ROOT)
-           printf("root ");
-       if (stream->steps[i].flags & XML_STREAM_STEP_DESC)
-           printf("// ");
-       if (stream->steps[i].flags & XML_STREAM_STEP_FINAL)
-           printf("final ");
-       printf("\n");
-    }
-}
-static void
-xmlDebugStreamCtxt(xmlStreamCtxtPtr ctxt, int match) {
-    int i;
-
-    if (ctxt == NULL) {
-        printf("Stream: NULL\n");
-       return;
-    }
-    printf("Stream: level %d, %d states: ", ctxt->level, ctxt->nbState);
-    if (match)
-        printf("matches\n");
-    else
-        printf("\n");
-    for (i = 0;i < ctxt->nbState;i++) {
-        if (ctxt->states[2 * i] < 0)
-           printf(" %d: free\n", i);
-       else {
-           printf(" %d: step %d, level %d", i, ctxt->states[2 * i],
-                  ctxt->states[(2 * i) + 1]);
-            if (ctxt->comp->steps[ctxt->states[2 * i]].flags &
-               XML_STREAM_STEP_DESC)
-               printf(" //\n");
-           else
-               printf("\n");
-       }
-    }
-}
-#endif
 /**
  * xmlNewStreamComp:
  * @size: the number of expected steps
@@ -1729,9 +1671,6 @@ xmlStreamCompile(xmlPatternPtr comp) {
     stream->steps[s].flags |= XML_STREAM_STEP_FINAL;
     if (root)
        stream->steps[0].flags |= XML_STREAM_STEP_ROOT;
-#ifdef DEBUG_STREAMING
-    xmlDebugStreamComp(stream);
-#endif
     comp->stream = stream;
     return(0);
 error:
@@ -1852,9 +1791,6 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
     int ret = 0, err = 0, final = 0, tmp, i, m, match, stepNr, desc;
     xmlStreamCompPtr comp;
     xmlStreamStep step;
-#ifdef DEBUG_STREAMING
-    xmlStreamCtxtPtr orig = stream;
-#endif
 
     if ((stream == NULL) || (stream->nbState < 0))
         return(-1);
@@ -2039,22 +1975,12 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
 #endif /* if 0 ------------------------------------------------------- */
            if (match) {
                final = step.flags & XML_STREAM_STEP_FINAL;
-               if (desc) {
-                   if (final) {
-                       ret = 1;
-                   } else {
-                       /* descending match create a new state */
-                       xmlStreamCtxtAddState(stream, stepNr + 1,
-                                             stream->level + 1);
-                   }
-               } else {
-                   if (final) {
-                       ret = 1;
-                   } else {
-                       xmlStreamCtxtAddState(stream, stepNr + 1,
-                                             stream->level + 1);
-                   }
-               }
+                if (final) {
+                    ret = 1;
+                } else {
+                    xmlStreamCtxtAddState(stream, stepNr + 1,
+                                          stream->level + 1);
+                }
                if ((ret != 1) && (step.flags & XML_STREAM_STEP_IN_SET)) {
                    /*
                    * Check if we have a special case like "foo/bar//.", where
@@ -2182,9 +2108,6 @@ stream_next:
 
     if (err > 0)
         ret = -1;
-#ifdef DEBUG_STREAMING
-    xmlDebugStreamCtxt(orig, ret);
-#endif
     return(ret);
 }
 
@@ -2207,7 +2130,7 @@ stream_next:
 int
 xmlStreamPush(xmlStreamCtxtPtr stream,
               const xmlChar *name, const xmlChar *ns) {
-    return (xmlStreamPushInternal(stream, name, ns, (int) XML_ELEMENT_NODE));
+    return (xmlStreamPushInternal(stream, name, ns, XML_ELEMENT_NODE));
 }
 
 /**
@@ -2257,7 +2180,7 @@ xmlStreamPushNode(xmlStreamCtxtPtr stream,
 int
 xmlStreamPushAttr(xmlStreamCtxtPtr stream,
                  const xmlChar *name, const xmlChar *ns) {
-    return (xmlStreamPushInternal(stream, name, ns, (int) XML_ATTRIBUTE_NODE));
+    return (xmlStreamPushInternal(stream, name, ns, XML_ATTRIBUTE_NODE));
 }
 
 /**
diff --git a/python/.gitignore b/python/.gitignore
new file mode 100644 (file)
index 0000000..b68d6ea
--- /dev/null
@@ -0,0 +1,9 @@
+/gen_prog
+/libxml2-export.c
+/libxml2-py.c
+/libxml2-py.h
+/libxml2.py
+/libxml2class.py
+/libxml2class.txt
+/setup.py
+/tests/tmp.xml
index cc1419a..05d167b 100644 (file)
@@ -1,14 +1,16 @@
 # Makefile for libxml2 python library
 
-SUBDIRS = . tests
+# We use a rule with multiple output files which creates problems with
+# parallel builds.
+.NOTPARALLEL:
 
-docsdir = $(docdir)/python
-dist_docs_DATA = TODO
+SUBDIRS = . tests
 
 EXTRA_DIST =                   \
        generator.py            \
        libxml.py               \
-       libxml2-python-api.xml
+       libxml2-python-api.xml  \
+       pyproject.toml
 
 if WITH_PYTHON
 AM_CPPFLAGS = \
@@ -20,8 +22,8 @@ pyexec_LTLIBRARIES = libxml2mod.la
 
 libxml2mod_la_SOURCES = libxml.c libxml_wrap.h types.c
 nodist_libxml2mod_la_SOURCES = libxml2-py.h libxml2-py.c
-libxml2mod_la_LDFLAGS = $(CYGWIN_EXTRA_LDFLAGS) $(WIN32_EXTRA_LDFLAGS) -module -avoid-version
-libxml2mod_la_LIBADD = $(top_builddir)/libxml2.la $(CYGWIN_EXTRA_PYTHON_LIBADD) $(WIN32_EXTRA_PYTHON_LIBADD) $(PYTHON_LIBS)
+libxml2mod_la_LDFLAGS = $(AM_LDFLAGS) $(PYTHON_LDFLAGS) -module -avoid-version
+libxml2mod_la_LIBADD = $(top_builddir)/libxml2.la $(PYTHON_LIBS)
 
 BUILT_SOURCES = libxml2-export.c libxml2-py.h libxml2-py.c
 
@@ -44,6 +46,6 @@ libxml2.py: $(srcdir)/libxml.py libxml2class.py
        cat $(srcdir)/libxml.py `test -f libxml2class.py || echo $(srcdir)/`libxml2class.py > $@
 
 clean-local:
-       rm -rf __pycache__
+       rm -rf __pycache__ *.pyc
 
 endif
diff --git a/python/TODO b/python/TODO
deleted file mode 100644 (file)
index 4ea1eb1..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-             TODO for the libxml2 Python wrappers
-
-Things to do:
--------------
-
-- SAX interfaces
-  - push is done but no generic interface
-  - elementDecl need some work
-  - need more testing and check full callbacks for xmllib/sgmlop replacement
-- enums -> libxml.py
-- access to XPath variables
-- xmlBuffer exposure
-- xpathContext, being able to set/get info and clean it up
-- more work needed on context handling for function lookup
-  and use of an hash table.
-- add regression tests
-   - SAX flow
-- DTD element and attributes content accesses
-   - attribute handled in SAX
-   - element needed in both
-
-
-Done:
------
-- class hierarchy:
-  + make specific node type inherit from xmlNode
-    done, had to sort the classes in the output
-  + get the generator to output a classes.txt description
-    done libxml2class.txt
-- add regression tests
-   - tests/Makefile.am: export the Python class path
-   - xpath queries
-   - xpath extension
-   - check memory
-   - build tree
-   - saving
-- extensions based on a python.xml description of the new specific
-  interfaces
-   file libxml2-python-api.xml , first entry is xmlRegisterXPathFunction
-- spec file: automatically generate for pythonX.Y if found
-  Done, a bit ugly by running new makes in %install for each level
-  found.
-- error redirections and preformat
-- handling of node.content
-- access to xmlParserCtxt and push mode
-   - needed for SAX too
-   - entry points
-   - wrappers
-   - decent interface for setting/getting behaviour
-- memory debug interfaces
-- SAX interfaces
-   - basic stuff with push is available
-   - basic xmllib replacement
-
-Daniel Veillard
index 09474fc..995cdb1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # generate python wrappers from the XML API description
 #
@@ -240,6 +240,7 @@ py_types = {
     'xmlCatalogPtr': ('O', "catalog", "xmlCatalogPtr", "xmlCatalogPtr"),
     'FILE *': ('O', "File", "FILEPtr", "FILE *"),
     'xmlURIPtr': ('O', "URI", "xmlURIPtr", "xmlURIPtr"),
+    'const xmlError *': ('O', "Error", "xmlErrorPtr", "const xmlError *"),
     'xmlErrorPtr': ('O', "Error", "xmlErrorPtr", "xmlErrorPtr"),
     'xmlOutputBufferPtr': ('O', "outputBuffer", "xmlOutputBufferPtr", "xmlOutputBufferPtr"),
     'xmlParserInputBufferPtr': ('O', "inputBuffer", "xmlParserInputBufferPtr", "xmlParserInputBufferPtr"),
@@ -291,6 +292,13 @@ skip_impl = (
 deprecated_funcs = {
     'htmlDefaultSAXHandlerInit': True,
     'htmlInitAutoClose': True,
+    'htmlParseCharRef': True,
+    'htmlParseElement': True,
+    'namePop': True,
+    'namePush': True,
+    'nodePop': True,
+    'nodePush': True,
+    'xmlCheckLanguageID': True,
     'xmlCleanupCharEncodingHandlers': True,
     'xmlCleanupGlobals': True,
     'xmlDefaultSAXHandlerInit': True,
@@ -303,6 +311,8 @@ deprecated_funcs = {
     'xmlInitializeDict': True,
     'xmlInitializePredefinedEntities': True,
     'xmlIsRef': True,
+    'xmlKeepBlanksDefault': True,
+    'xmlLineNumbersDefault': True,
     'xmlNamespaceParseNCName': True,
     'xmlNamespaceParseNSDef': True,
     'xmlNanoFTPCleanup': True,
@@ -310,15 +320,68 @@ deprecated_funcs = {
     'xmlNanoFTPProxy': True,
     'xmlNanoFTPScanProxy': True,
     'xmlNewGlobalNs': True,
+    'xmlNextChar': True,
+    'xmlParseAttValue': True,
+    'xmlParseAttributeListDecl': True,
+    'xmlParseCDSect': True,
+    'xmlParseCharData': True,
+    'xmlParseCharRef': True,
+    'xmlParseComment': True,
+    'xmlParseDocTypeDecl': True,
+    'xmlParseElement': True,
+    'xmlParseElementDecl': True,
+    'xmlParseEncName': True,
+    'xmlParseEncodingDecl': True,
+    'xmlParseEndTag': True,
+    'xmlParseEntity': True,
+    'xmlParseEntityDecl': True,
+    'xmlParseEntityRef': True,
+    'xmlParseMarkupDecl': True,
+    'xmlParseMisc': True,
+    'xmlParseName': True,
     'xmlParseNamespace': True,
+    'xmlParseNmtoken': True,
+    'xmlParseNotationDecl': True,
+    'xmlParsePEReference': True,
+    'xmlParsePI': True,
+    'xmlParsePITarget': True,
+    'xmlParsePubidLiteral': True,
     'xmlParseQuotedString': True,
+    'xmlParseReference': True,
+    'xmlParseSDDecl': True,
+    'xmlParseStartTag': True,
+    'xmlParseSystemLiteral': True,
+    'xmlParseTextDecl': True,
+    'xmlParseVersionInfo': True,
+    'xmlParseVersionNum': True,
+    'xmlParseXMLDecl': True,
+    'xmlParserHandlePEReference': True,
     'xmlParserHandleReference': True,
+    'xmlPedanticParserDefault': True,
+    'xmlRecoverDoc': True,
+    'xmlRecoverFile': True,
+    'xmlRecoverMemory': True,
     'xmlRelaxNGCleanupTypes': True,
     'xmlRelaxNGInitTypes': True,
     'xmlRemoveRef': True,
+    'xmlSAXDefaultVersion': True,
     'xmlScanName': True,
     'xmlSchemaCleanupTypes': True,
     'xmlSchemaInitTypes': True,
+    'xmlSetupParserForBuffer': True,
+    'xmlSkipBlankChars': True,
+    'xmlStringDecodeEntities': True,
+    'xmlStringLenDecodeEntities': True,
+    'xmlSubstituteEntitiesDefault': True,
+    'xmlThrDefDefaultBufferSize': True,
+    'xmlThrDefDoValidityCheckingDefaultValue': True,
+    'xmlThrDefGetWarningsDefaultValue': True,
+    'xmlThrDefKeepBlanksDefaultValue': True,
+    'xmlThrDefLineNumbersDefaultValue': True,
+    'xmlThrDefLoadExtDtdDefaultValue': True,
+    'xmlThrDefParserDebugEntities': True,
+    'xmlThrDefPedanticParserDefaultValue': True,
+    'xmlThrDefSubstituteEntitiesDefaultValue': True,
     'xmlXPathInit': True,
     'xmlXPtrEvalRangePredicate': True,
     'xmlXPtrNewCollapsedRange': True,
@@ -627,12 +690,12 @@ def buildStubs():
     export.close()
     wrapper.close()
 
-    print("Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap,
+    print("Generated %d wrapper functions, %d failed, %d skipped" % (nb_wrap,
                                                               failed, skipped))
-    print("Missing type converters: ")
-    for type in list(unknown_types.keys()):
-        print("%s:%d " % (type, len(unknown_types[type])))
-    print()
+#    print("Missing type converters: ")
+#    for type in list(unknown_types.keys()):
+#        print("%s:%d " % (type, len(unknown_types[type])))
+#    print()
 
 #######################################################################
 #
@@ -675,6 +738,7 @@ classes_type = {
     "xmlValidCtxtPtr": ("._o", "ValidCtxt(_obj=%s)", "ValidCtxt"),
     "xmlCatalogPtr": ("._o", "catalog(_obj=%s)", "catalog"),
     "xmlURIPtr": ("._o", "URI(_obj=%s)", "URI"),
+    "const xmlError *": ("._o", "Error(_obj=%s)", "Error"),
     "xmlErrorPtr": ("._o", "Error(_obj=%s)", "Error"),
     "xmlOutputBufferPtr": ("._o", "outputBuffer(_obj=%s)", "outputBuffer"),
     "xmlParserInputBufferPtr": ("._o", "inputBuffer(_obj=%s)", "inputBuffer"),
index e071e82..bf04800 100644 (file)
 #define vsnprintf trio_vsnprintf
 #endif
 
-/* #define DEBUG */
-/* #define DEBUG_SAX */
-/* #define DEBUG_XPATH */
-/* #define DEBUG_ERROR */
-/* #define DEBUG_MEMORY */
-/* #define DEBUG_FILES */
-/* #define DEBUG_LOADER */
-
 #if PY_MAJOR_VERSION >= 3
 PyObject *PyInit_libxml2mod(void);
 
@@ -128,10 +120,6 @@ libxml_xmlDebugMemory(PyObject * self ATTRIBUTE_UNUSED, PyObject * args)
     if (!PyArg_ParseTuple(args, (char *) "i:xmlDebugMemory", &activate))
         return (NULL);
 
-#ifdef DEBUG_MEMORY
-    printf("libxml_xmlDebugMemory(%d) called\n", activate);
-#endif
-
     if (activate != 0) {
         if (libxmlMemoryDebug == 0) {
             /*
@@ -145,23 +133,13 @@ libxml_xmlDebugMemory(PyObject * self ATTRIBUTE_UNUSED, PyObject * args)
             if ((freeFunc == xmlMemFree) && (mallocFunc == xmlMemMalloc) &&
                 (reallocFunc == xmlMemRealloc) &&
                 (strdupFunc == xmlMemoryStrdup)) {
-                libxmlMemoryAllocatedBase = xmlMemUsed();
             } else {
-                /* 
-                 * cleanup first, because some memory has been
-                 * allocated with the non-debug malloc in xmlInitParser
-                 * when the python module was imported
-                 */
-                xmlCleanupParser();
                 ret = (long) xmlMemSetup(xmlMemFree, xmlMemMalloc,
                                          xmlMemRealloc, xmlMemoryStrdup);
                 if (ret < 0)
                     goto error;
-                libxmlMemoryAllocatedBase = xmlMemUsed();
-                /* reinitialize */
-                xmlInitParser();
-                libxml_xmlErrorInitialize();
             }
+            libxmlMemoryAllocatedBase = xmlMemUsed();
             ret = 0;
         } else if (libxmlMemoryDebugActivated == 0) {
             libxmlMemoryAllocatedBase = xmlMemUsed();
@@ -188,13 +166,7 @@ libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED,
                               PyObject *args ATTRIBUTE_UNUSED) {
 
     int ix;
-    long freed = -1;
-
-    if (libxmlMemoryDebug) {
-        freed = xmlMemUsed();
-    }
 
-    xmlCleanupParser();
     /*
      * Need to confirm whether we really want to do this (required for
      * memcheck) in all cases...
@@ -212,12 +184,7 @@ libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED,
        libxml_xpathCallbacks = NULL;
     }
 
-    if (libxmlMemoryDebug) {
-        freed -= xmlMemUsed();
-       libxmlMemoryAllocatedBase -= freed;
-       if (libxmlMemoryAllocatedBase < 0)
-           libxmlMemoryAllocatedBase = 0;
-    }
+    xmlCleanupParser();
 
     Py_INCREF(Py_None);
     return(Py_None);
@@ -252,12 +219,9 @@ static int
 xmlPythonFileCloseRaw (void * context) {
     PyObject *file, *ret;
 
-#ifdef DEBUG_FILES
-    printf("xmlPythonFileCloseUnref\n");
-#endif
     file = (PyObject *) context;
     if (file == NULL) return(-1);
-    ret = PyEval_CallMethod(file, (char *) "close", (char *) "()");
+    ret = PyObject_CallMethod(file, (char *) "close", (char *) "()");
     if (ret != NULL) {
        Py_DECREF(ret);
     }
@@ -282,12 +246,9 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
     int lenread = -1;
     char *data;
 
-#ifdef DEBUG_FILES
-    printf("xmlPythonFileReadRaw: %d\n", len);
-#endif
     file = (PyObject *) context;
     if (file == NULL) return(-1);
-    ret = PyEval_CallMethod(file, (char *) "read", (char *) "(i)", len);
+    ret = PyObject_CallMethod(file, (char *) "read", (char *) "(i)", len);
     if (ret == NULL) {
        printf("xmlPythonFileReadRaw: result is NULL\n");
        return(-1);
@@ -347,12 +308,9 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
     int lenread = -1;
     char *data;
 
-#ifdef DEBUG_FILES
-    printf("xmlPythonFileRead: %d\n", len);
-#endif
     file = (PyObject *) context;
     if (file == NULL) return(-1);
-    ret = PyEval_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
+    ret = PyObject_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
     if (ret == NULL) {
        printf("xmlPythonFileRead: result is NULL\n");
        return(-1);
@@ -412,18 +370,15 @@ xmlPythonFileWrite (void * context, const char * buffer, int len) {
     PyObject *ret = NULL;
     int written = -1;
 
-#ifdef DEBUG_FILES
-    printf("xmlPythonFileWrite: %d\n", len);
-#endif
     file = (PyObject *) context;
     if (file == NULL) return(-1);
     string = PY_IMPORT_STRING_SIZE(buffer, len);
     if (string == NULL) return(-1);
     if (PyObject_HasAttrString(file, (char *) "io_write")) {
-        ret = PyEval_CallMethod(file, (char *) "io_write", (char *) "(O)",
+        ret = PyObject_CallMethod(file, (char *) "io_write", (char *) "(O)",
                                string);
     } else if (PyObject_HasAttrString(file, (char *) "write")) {
-        ret = PyEval_CallMethod(file, (char *) "write", (char *) "(O)",
+        ret = PyObject_CallMethod(file, (char *) "write", (char *) "(O)",
                                string);
     }
     Py_DECREF(string);
@@ -453,15 +408,12 @@ static int
 xmlPythonFileClose (void * context) {
     PyObject *file, *ret = NULL;
 
-#ifdef DEBUG_FILES
-    printf("xmlPythonFileClose\n");
-#endif
     file = (PyObject *) context;
     if (file == NULL) return(-1);
     if (PyObject_HasAttrString(file, (char *) "io_close")) {
-        ret = PyEval_CallMethod(file, (char *) "io_close", (char *) "()");
+        ret = PyObject_CallMethod(file, (char *) "io_close", (char *) "()");
     } else if (PyObject_HasAttrString(file, (char *) "flush")) {
-        ret = PyEval_CallMethod(file, (char *) "flush", (char *) "()");
+        ret = PyObject_CallMethod(file, (char *) "flush", (char *) "()");
     }
     if (ret != NULL) {
        Py_DECREF(ret);
@@ -715,18 +667,10 @@ pythonExternalEntityLoader(const char *URL, const char *ID,
        PyObject *ctxtobj;
 
        ctxtobj = libxml_xmlParserCtxtPtrWrap(ctxt);
-#ifdef DEBUG_LOADER
-       printf("pythonExternalEntityLoader: ready to call\n");
-#endif
 
        ret = PyObject_CallFunction(pythonExternalEntityLoaderObjext,
                      (char *) "(ssO)", URL, ID, ctxtobj);
        Py_XDECREF(ctxtobj);
-#ifdef DEBUG_LOADER
-       printf("pythonExternalEntityLoader: result ");
-       PyObject_Print(ret, stdout, 0);
-       printf("\n");
-#endif
 
        if (ret != NULL) {
            if (PyObject_HasAttrString(ret, (char *) "read")) {
@@ -775,9 +719,6 @@ libxml_xmlSetEntityLoader(ATTRIBUTE_UNUSED PyObject *self, PyObject *args) {
        return(NULL);
     }
 
-#ifdef DEBUG_LOADER
-    printf("libxml_xmlSetEntityLoader\n");
-#endif
     if (defaultExternalEntityLoader == NULL) 
        defaultExternalEntityLoader = xmlGetExternalEntityLoader();
 
@@ -897,9 +838,6 @@ pythonStartElement(void *user_data, const xmlChar * name,
     PyObject *result = NULL;
     int type = 0;
 
-#ifdef DEBUG_SAX
-    printf("pythonStartElement(%s) called\n", name);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "startElement"))
         type = 1;
@@ -951,9 +889,6 @@ pythonStartDocument(void *user_data)
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonStartDocument() called\n");
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "startDocument")) {
         result =
@@ -970,9 +905,6 @@ pythonEndDocument(void *user_data)
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonEndDocument() called\n");
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "endDocument")) {
         result =
@@ -993,9 +925,6 @@ pythonEndElement(void *user_data, const xmlChar * name)
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonEndElement(%s) called\n", name);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "endElement")) {
         result = PyObject_CallMethod(handler, (char *) "endElement",
@@ -1018,9 +947,6 @@ pythonReference(void *user_data, const xmlChar * name)
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonReference(%s) called\n", name);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "reference")) {
         result = PyObject_CallMethod(handler, (char *) "reference",
@@ -1038,9 +964,6 @@ pythonCharacters(void *user_data, const xmlChar * ch, int len)
     PyObject *result = NULL;
     int type = 0;
 
-#ifdef DEBUG_SAX
-    printf("pythonCharacters(%s, %d) called\n", ch, len);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "characters"))
         type = 1;
@@ -1066,9 +989,6 @@ pythonIgnorableWhitespace(void *user_data, const xmlChar * ch, int len)
     PyObject *result = NULL;
     int type = 0;
 
-#ifdef DEBUG_SAX
-    printf("pythonIgnorableWhitespace(%s, %d) called\n", ch, len);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "ignorableWhitespace"))
         type = 1;
@@ -1095,9 +1015,6 @@ pythonProcessingInstruction(void *user_data,
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonProcessingInstruction(%s, %s) called\n", target, data);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "processingInstruction")) {
         result = PyObject_CallMethod(handler, (char *)
@@ -1113,9 +1030,6 @@ pythonComment(void *user_data, const xmlChar * value)
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonComment(%s) called\n", value);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "comment")) {
         result =
@@ -1135,9 +1049,6 @@ pythonWarning(void *user_data, const char *msg, ...)
     va_list args;
     char buf[1024];
 
-#ifdef DEBUG_SAX
-    printf("pythonWarning(%s) called\n", msg);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "warning")) {
         va_start(args, msg);
@@ -1161,9 +1072,6 @@ pythonError(void *user_data, const char *msg, ...)
     va_list args;
     char buf[1024];
 
-#ifdef DEBUG_SAX
-    printf("pythonError(%s) called\n", msg);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "error")) {
         va_start(args, msg);
@@ -1187,9 +1095,6 @@ pythonFatalError(void *user_data, const char *msg, ...)
     va_list args;
     char buf[1024];
 
-#ifdef DEBUG_SAX
-    printf("pythonFatalError(%s) called\n", msg);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "fatalError")) {
         va_start(args, msg);
@@ -1212,9 +1117,6 @@ pythonCdataBlock(void *user_data, const xmlChar * ch, int len)
     PyObject *result = NULL;
     int type = 0;
 
-#ifdef DEBUG_SAX
-    printf("pythonCdataBlock(%s, %d) called\n", ch, len);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "cdataBlock"))
         type = 1;
@@ -1243,10 +1145,6 @@ pythonExternalSubset(void *user_data,
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonExternalSubset(%s, %s, %s) called\n",
-           name, externalID, systemID);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "externalSubset")) {
         result =
@@ -1392,10 +1290,6 @@ pythonInternalSubset(void *user_data, const xmlChar * name,
     PyObject *handler;
     PyObject *result;
 
-#ifdef DEBUG_SAX
-    printf("pythonInternalSubset(%s, %s, %s) called\n",
-           name, ExternalID, SystemID);
-#endif
     handler = (PyObject *) user_data;
     if (PyObject_HasAttrString(handler, (char *) "internalSubset")) {
         result = PyObject_CallMethod(handler, (char *) "internalSubset",
@@ -1465,10 +1359,6 @@ libxml_xmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self,
          &size, &URI))
         return (NULL);
 
-#ifdef DEBUG
-    printf("libxml_xmlCreatePushParser(%p, %s, %d, %s) called\n",
-           pyobj_SAX, chunk, size, URI);
-#endif
     if (pyobj_SAX != Py_None) {
         SAX = &pythonSaxHandler;
         Py_INCREF(pyobj_SAX);
@@ -1497,10 +1387,6 @@ libxml_htmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self,
          &size, &URI))
         return (NULL);
 
-#ifdef DEBUG
-    printf("libxml_htmlCreatePushParser(%p, %s, %d, %s) called\n",
-           pyobj_SAX, chunk, size, URI);
-#endif
     if (pyobj_SAX != Py_None) {
         SAX = &pythonSaxHandler;
         Py_INCREF(pyobj_SAX);
@@ -1524,15 +1410,12 @@ libxml_xmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
     const char *URI;
     PyObject *pyobj_SAX = NULL;
     xmlSAXHandlerPtr SAX = NULL;
+    xmlParserCtxtPtr ctxt;
 
     if (!PyArg_ParseTuple(args, (char *) "Osi:xmlSAXParseFile", &pyobj_SAX,
                           &URI, &recover))
         return (NULL);
 
-#ifdef DEBUG
-    printf("libxml_xmlSAXParseFile(%p, %s, %d) called\n",
-           pyobj_SAX, URI, recover);
-#endif
     if (pyobj_SAX == Py_None) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -1540,7 +1423,9 @@ libxml_xmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
     SAX = &pythonSaxHandler;
     Py_INCREF(pyobj_SAX);
     /* The reference is released in pythonEndDocument() */
-    xmlSAXUserParseFile(SAX, pyobj_SAX, URI);
+    ctxt = xmlNewSAXParserCtxt(SAX, pyobj_SAX);
+    xmlCtxtReadFile(ctxt, URI, NULL, 0);
+    xmlFreeParserCtxt(ctxt);
 #endif /* LIBXML_SAX1_ENABLED */
     Py_INCREF(Py_None);
     return (Py_None);
@@ -1554,16 +1439,13 @@ libxml_htmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
     const char *encoding;
     PyObject *pyobj_SAX = NULL;
     xmlSAXHandlerPtr SAX = NULL;
+    htmlParserCtxtPtr ctxt;
 
     if (!PyArg_ParseTuple
         (args, (char *) "Osz:htmlSAXParseFile", &pyobj_SAX, &URI,
          &encoding))
         return (NULL);
 
-#ifdef DEBUG
-    printf("libxml_htmlSAXParseFile(%p, %s, %s) called\n",
-           pyobj_SAX, URI, encoding);
-#endif
     if (pyobj_SAX == Py_None) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -1571,7 +1453,9 @@ libxml_htmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
     SAX = &pythonSaxHandler;
     Py_INCREF(pyobj_SAX);
     /* The reference is released in pythonEndDocument() */
-    htmlSAXParseFile(URI, encoding, SAX, pyobj_SAX);
+    ctxt = htmlNewSAXParserCtxt(SAX, pyobj_SAX);
+    htmlCtxtReadFile(ctxt, URI, encoding, 0);
+    htmlFreeParserCtxt(ctxt);
     Py_INCREF(Py_None);
     return (Py_None);
 #else
@@ -1622,11 +1506,6 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
     PyObject *result;
     char str[1000];
 
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
-#endif
-
-
     if (libxml_xmlPythonErrorFuncHandler == NULL) {
         va_start(ap, msg);
         vfprintf(stderr, msg, ap);
@@ -1642,7 +1521,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
         Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
         message = libxml_charPtrConstWrap(str);
         PyTuple_SetItem(list, 1, message);
-        result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+        result = PyObject_CallObject(libxml_xmlPythonErrorFuncHandler, list);
         Py_XDECREF(list);
         Py_XDECREF(result);
     }
@@ -1651,9 +1530,6 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
 static void
 libxml_xmlErrorInitialize(void)
 {
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlErrorInitialize() called\n");
-#endif
     xmlSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
     xmlThrDefSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
 }
@@ -1671,11 +1547,6 @@ libxml_xmlRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
          &pyobj_ctx))
         return (NULL);
 
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlRegisterErrorHandler(%p, %p) called\n", pyobj_ctx,
-           pyobj_f);
-#endif
-
     if (libxml_xmlPythonErrorFuncHandler != NULL) {
         Py_XDECREF(libxml_xmlPythonErrorFuncHandler);
     }
@@ -1716,10 +1587,6 @@ libxml_xmlParserCtxtGenericErrorFuncHandler(void *ctx, int severity, char *str)
     xmlParserCtxtPtr ctxt;
     xmlParserCtxtPyCtxtPtr pyCtxt;
     
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlParserCtxtGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
-#endif
-
     ctxt = (xmlParserCtxtPtr)ctx;
     pyCtxt = (xmlParserCtxtPyCtxtPtr)ctxt->_private;
 
@@ -1730,7 +1597,7 @@ libxml_xmlParserCtxtGenericErrorFuncHandler(void *ctx, int severity, char *str)
     PyTuple_SetItem(list, 2, libxml_intWrap(severity));
     PyTuple_SetItem(list, 3, Py_None);
     Py_INCREF(Py_None);
-    result = PyEval_CallObject(pyCtxt->f, list);
+    result = PyObject_CallObject(pyCtxt->f, list);
     if (result == NULL) 
     {
        /* TODO: manage for the exception to be propagated... */
@@ -1906,17 +1773,13 @@ libxml_xmlValidCtxtGenericErrorFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sever
     PyObject *result;
     xmlValidCtxtPyCtxtPtr pyCtxt;
     
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlValidCtxtGenericErrorFuncHandler(%p, %d, %s, ...) called\n", ctx, severity, str);
-#endif
-
     pyCtxt = (xmlValidCtxtPyCtxtPtr)ctx;
     
     list = PyTuple_New(2);
     PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
     PyTuple_SetItem(list, 1, pyCtxt->arg);
     Py_XINCREF(pyCtxt->arg);
-    result = PyEval_CallObject(pyCtxt->error, list);
+    result = PyObject_CallObject(pyCtxt->error, list);
     if (result == NULL) 
     {
        /* TODO: manage for the exception to be propagated... */
@@ -1933,17 +1796,13 @@ libxml_xmlValidCtxtGenericWarningFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sev
     PyObject *result;
     xmlValidCtxtPyCtxtPtr pyCtxt;
     
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlValidCtxtGenericWarningFuncHandler(%p, %d, %s, ...) called\n", ctx, severity, str);
-#endif
-
     pyCtxt = (xmlValidCtxtPyCtxtPtr)ctx;
 
     list = PyTuple_New(2);
     PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
     PyTuple_SetItem(list, 1, pyCtxt->arg);
     Py_XINCREF(pyCtxt->arg);
-    result = PyEval_CallObject(pyCtxt->warn, list);
+    result = PyObject_CallObject(pyCtxt->warn, list);
     if (result == NULL) 
     {
        /* TODO: manage for the exception to be propagated... */
@@ -1988,10 +1847,6 @@ libxml_xmlSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         (args, (char *) "OOO|O:xmlSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
         return (NULL);
 
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
-#endif
-
     ctxt = PyValidCtxt_Get(pyobj_ctx);
     pyCtxt = xmlMalloc(sizeof(xmlValidCtxtPyCtxt));
     if (pyCtxt == NULL) {
@@ -2078,7 +1933,7 @@ libxml_xmlTextReaderErrorCallback(void *arg,
     PyTuple_SetItem(list, 1, libxml_charPtrConstWrap(msg));
     PyTuple_SetItem(list, 2, libxml_intWrap(severity));
     PyTuple_SetItem(list, 3, libxml_xmlTextReaderLocatorPtrWrap(locator));
-    result = PyEval_CallObject(pyCtxt->f, list);
+    result = PyObject_CallObject(pyCtxt->f, list);
     if (result == NULL)
     {
        /* TODO: manage for the exception to be propagated... */
@@ -2244,10 +2099,6 @@ libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs)
         return;
     name = rctxt->function;
     ns_uri = rctxt->functionURI;
-#ifdef DEBUG_XPATH
-    printf("libxml_xmlXPathFuncCallback called name %s URI %s\n", name,
-           ns_uri);
-#endif
 
     /*
      * Find the function, it should be there it was there at lookup
@@ -2273,7 +2124,7 @@ libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs)
         cur = libxml_xmlXPathObjectPtrWrap(obj);
         PyTuple_SetItem(list, i + 1, cur);
     }
-    result = PyEval_CallObject(current_function, list);
+    result = PyObject_CallObject(current_function, list);
     Py_DECREF(list);
 
     obj = libxml_xmlXPathObjectPtrConvert(result);
@@ -2286,10 +2137,6 @@ libxml_xmlXPathFuncLookupFunc(void *ctxt, const xmlChar * name,
 {
     int i;
 
-#ifdef DEBUG_XPATH
-    printf("libxml_xmlXPathFuncLookupFunc(%p, %s, %s) called\n",
-           ctxt, name, ns_uri);
-#endif
     /*
      * This is called once only. The address is then stored in the
      * XPath expression evaluation, the proper object to call can
@@ -2314,9 +2161,6 @@ libxml_xpathCallbacksInitialize(void)
     if (libxml_xpathCallbacksInitialized != 0)
         return;
 
-#ifdef DEBUG_XPATH
-    printf("libxml_xpathCallbacksInitialized called\n");
-#endif
     libxml_xpathCallbacks = (libxml_xpathCallbackArray*)xmlMalloc(
                libxml_xpathCallbacksAllocd*sizeof(libxml_xpathCallback));
 
@@ -2356,10 +2200,6 @@ libxml_xmlRegisterXPathFunction(ATTRIBUTE_UNUSED PyObject * self,
         py_retval = libxml_intWrap(-1);
         return (py_retval);
     }
-#ifdef DEBUG_XPATH
-    printf("libxml_registerXPathFunction(%p, %s, %s) called\n",
-           ctx, name, ns_uri);
-#endif
     for (i = 0; i < libxml_xpathCallbacksNb; i++) {
        if ((ctx == (*libxml_xpathCallbacks)[i].ctx) &&
             (xmlStrEqual(name, (*libxml_xpathCallbacks)[i].name)) &&
@@ -2432,10 +2272,6 @@ libxml_name(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_name: cur = %p type %d\n", cur, cur->type);
-#endif
-
     switch (cur->type) {
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:{
@@ -2476,10 +2312,6 @@ libxml_doc(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_doc: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
@@ -2531,10 +2363,6 @@ libxml_next(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_next: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
@@ -2572,10 +2400,6 @@ libxml_prev(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_prev: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
@@ -2609,10 +2433,6 @@ libxml_children(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_children: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_ELEMENT_NODE:
         case XML_ENTITY_REF_NODE:
@@ -2649,10 +2469,6 @@ libxml_last(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_last: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_ELEMENT_NODE:
         case XML_ENTITY_REF_NODE:
@@ -2689,10 +2505,6 @@ libxml_parent(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
         return NULL;
     cur = PyxmlNode_Get(obj);
 
-#ifdef DEBUG
-    printf("libxml_parent: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
@@ -2733,10 +2545,6 @@ libxml_type(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
        return (Py_None);
     }
 
-#ifdef DEBUG
-    printf("libxml_type: cur = %p\n", cur);
-#endif
-
     switch (cur->type) {
         case XML_ELEMENT_NODE:
             res = (const xmlChar *) "element";
@@ -2799,9 +2607,6 @@ libxml_type(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
             res = (const xmlChar *) "xinclude_end";
             break;
     }
-#ifdef DEBUG
-    printf("libxml_type: cur = %p: %s\n", cur, res);
-#endif
 
     resultobj = libxml_constxmlCharPtrWrap(res);
     return resultobj;
@@ -3075,9 +2880,6 @@ libxml_xmlNewNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
     if (!PyArg_ParseTuple(args, (char *) "s:xmlNewNode", &name))
         return (NULL);
     node = (xmlNodePtr) xmlNewNode(NULL, name);
-#ifdef DEBUG
-    printf("NewNode: %s : %p\n", name, (void *) node);
-#endif
 
     if (node == NULL) {
         Py_INCREF(Py_None);
@@ -3109,10 +2911,6 @@ libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
        ctxt->catalogs = xmlCatalogAddLocal(ctxt->catalogs, URL);
     }
 
-#ifdef DEBUG
-    printf("LocalCatalog: %s\n", URL);
-#endif
-
     Py_INCREF(Py_None);
     return (Py_None);
 }
@@ -3140,17 +2938,13 @@ libxml_xmlRelaxNGValidityGenericErrorFuncHandler(void *ctx, char *str)
     PyObject *result;
     xmlRelaxNGValidCtxtPyCtxtPtr pyCtxt;
     
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlRelaxNGValidityGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
-#endif
-
     pyCtxt = (xmlRelaxNGValidCtxtPyCtxtPtr)ctx;
 
     list = PyTuple_New(2);
     PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
     PyTuple_SetItem(list, 1, pyCtxt->arg);
     Py_XINCREF(pyCtxt->arg);
-    result = PyEval_CallObject(pyCtxt->error, list);
+    result = PyObject_CallObject(pyCtxt->error, list);
     if (result == NULL) 
     {
         /* TODO: manage for the exception to be propagated... */
@@ -3167,17 +2961,13 @@ libxml_xmlRelaxNGValidityGenericWarningFuncHandler(void *ctx, char *str)
     PyObject *result;
     xmlRelaxNGValidCtxtPyCtxtPtr pyCtxt;
     
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlRelaxNGValidityGenericWarningFuncHandler(%p, %s, ...) called\n", ctx, str);
-#endif
-
     pyCtxt = (xmlRelaxNGValidCtxtPyCtxtPtr)ctx;
 
     list = PyTuple_New(2);
     PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
     PyTuple_SetItem(list, 1, pyCtxt->arg);
     Py_XINCREF(pyCtxt->arg);
-    result = PyEval_CallObject(pyCtxt->warn, list);
+    result = PyObject_CallObject(pyCtxt->warn, list);
     if (result == NULL) 
     {
         /* TODO: manage for the exception to be propagated... */
@@ -3222,10 +3012,6 @@ libxml_xmlRelaxNGSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * arg
         (args, (char *) "OOO|O:xmlRelaxNGSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
         return (NULL);
 
-#ifdef DEBUG_ERROR
-    printf("libxml_xmlRelaxNGSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
-#endif
-
     ctxt = PyrelaxNgValidCtxt_Get(pyobj_ctx);
     if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == -1)
     {
@@ -3304,17 +3090,13 @@ libxml_xmlSchemaValidityGenericErrorFuncHandler(void *ctx, char *str)
        PyObject *result;
        xmlSchemaValidCtxtPyCtxtPtr pyCtxt;
 
-#ifdef DEBUG_ERROR
-       printf("libxml_xmlSchemaValidityGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
-#endif
-
        pyCtxt = (xmlSchemaValidCtxtPyCtxtPtr) ctx;
 
        list = PyTuple_New(2);
        PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
        PyTuple_SetItem(list, 1, pyCtxt->arg);
        Py_XINCREF(pyCtxt->arg);
-       result = PyEval_CallObject(pyCtxt->error, list);
+       result = PyObject_CallObject(pyCtxt->error, list);
        if (result == NULL) 
        {
                /* TODO: manage for the exception to be propagated... */
@@ -3331,17 +3113,13 @@ libxml_xmlSchemaValidityGenericWarningFuncHandler(void *ctx, char *str)
        PyObject *result;
        xmlSchemaValidCtxtPyCtxtPtr pyCtxt;
 
-#ifdef DEBUG_ERROR
-       printf("libxml_xmlSchemaValidityGenericWarningFuncHandler(%p, %s, ...) called\n", ctx, str);
-#endif
-       
        pyCtxt = (xmlSchemaValidCtxtPyCtxtPtr) ctx;
 
        list = PyTuple_New(2);
        PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
        PyTuple_SetItem(list, 1, pyCtxt->arg);
        Py_XINCREF(pyCtxt->arg);
-       result = PyEval_CallObject(pyCtxt->warn, list);
+       result = PyObject_CallObject(pyCtxt->warn, list);
        if (result == NULL)
        {
                /* TODO: manage for the exception to be propagated... */
@@ -3386,10 +3164,6 @@ libxml_xmlSchemaSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * args
                (args, (char *) "OOO|O:xmlSchemaSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
                return (NULL);
 
-#ifdef DEBUG_ERROR
-       printf("libxml_xmlSchemaSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
-#endif
-
        ctxt = PySchemaValidCtxt_Get(pyobj_ctx);
        if (xmlSchemaGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == -1)
        {
index 478a20d..f9e1f89 100644 (file)
@@ -18,6 +18,8 @@
 #include <libxml/xmlregexp.h>
 #include <libxml/xmlautomata.h>
 #include <libxml/xmlreader.h>
+#include <libxml/globals.h>
+#include <libxml/xmlsave.h>
 #ifdef LIBXML_SCHEMAS_ENABLED
 #include <libxml/relaxng.h>
 #include <libxml/xmlschemas.h>
 #define XML_IGNORE_DEPRECATION_WARNINGS \
     _Pragma("GCC diagnostic push") \
     _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-#define XML_POP_WARNINGS \
-    _Pragma("GCC diagnostic pop")
+#elif defined (_MSC_VER) && (_MSC_VER >= 1400)
+#define XML_IGNORE_DEPRECATION_WARNINGS \
+    __pragma(warning(push)) \
+    __pragma(warning(disable : 4996))
 #else
-#define XML_IGNORE_PEDANTIC_WARNINGS
-#define XML_POP_WARNINGS
+#define XML_IGNORE_DEPRECATION_WARNINGS
 #endif
 
 #define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
@@ -287,7 +290,7 @@ PyObject * libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt);
 PyObject * libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt);
 PyObject * libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid);
 #endif /* LIBXML_SCHEMAS_ENABLED */
-PyObject * libxml_xmlErrorPtrWrap(xmlErrorPtr error);
+PyObject * libxml_xmlErrorPtrWrap(const xmlError *error);
 PyObject * libxml_xmlSchemaSetValidErrors(PyObject * self, PyObject * args);
 PyObject * libxml_xmlRegisterInputCallback(PyObject *self, PyObject *args);
 PyObject * libxml_xmlUnregisterInputCallback(PyObject *self, PyObject *args);
diff --git a/python/pyproject.toml b/python/pyproject.toml
new file mode 100755 (executable)
index 0000000..fed528d
--- /dev/null
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
index 57505eb..d75fe55 100755 (executable)
@@ -1,15 +1,19 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Setup script for libxml2 and libxslt if found
 #
 import sys, os
 
 try:
-    import setuptools
+    from setuptools import setup, Extension
 except ImportError:
-    pass
-
-from distutils.core import setup, Extension
+    try:
+        # Using distutils, for python < 3.12
+        from distutils.core import setup, Extension
+    except ImportError:
+        # distutils is not present in python 3.12 and greater
+        print("setuptools is required for python >= 3.12")
+        sys.exit(1)
 
 # Below ROOT, we expect to find include, include/libxml2, lib and bin.
 # On *nix, it is not needed (but should not harm),
@@ -45,6 +49,11 @@ icu_dlls = ['icuuc%s.dll' % icu_series_s, 'icudt%s.dll' % icu_series_s]
 # dlls must be found somewhere in the PATH at runtime.
 WITHDLLS = 1 and sys.platform.startswith('win')
 
+if WITHDLLS:
+    def altImport(s):
+        s = s.replace("import libxml2mod","from libxmlmods import libxml2mod")
+        return s
+
 def missing(file):
     if os.access(file, os.R_OK) == 0:
         return 1
@@ -182,11 +191,6 @@ if WITHDLLS:
         os.mkdir("libxmlmods")
         open("libxmlmods/__init__.py","w").close()
 
-    def altImport(s):
-        s = s.replace("import libxml2mod","from libxmlmods import libxml2mod")
-        s = s.replace("import libxsltmod","from libxmlmods import libxsltmod")
-        return s
-
     packaged_dlls = [os.path.join(ROOT,'bin',dll) for dll in dlls]
 
 descr = "libxml2 package"
index c2270ce..588dcdd 100644 (file)
@@ -1,5 +1,5 @@
 exampledir = $(docdir)/python/examples
-dist_example_DATA = $(PYTESTS) $(XMLS)
+dist_example_DATA = $(PYTESTS) $(XMLS) setup_test.py
 
 PYTESTS=       \
     build.py   \
index 23def61..5627a37 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -31,4 +32,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 05e4917..f786b0c 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -56,4 +57,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index a11855b..46779b8 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -47,4 +48,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 0aa0150..7deaebb 100755 (executable)
@@ -1,9 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This test exercise the redirection of error messages with a
 # functions defined in Python.
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -53,4 +54,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index b672ae0..4df0902 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -45,4 +46,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 129b57a..5bd4ef8 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -28,5 +29,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index e41c27e..603eb51 100755 (executable)
@@ -1,9 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This test exercise the redirection of error messages with a
 # functions defined in Python.
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -48,4 +49,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 16ca9bc..a80ae7d 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -26,5 +27,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index 4922b5e..4673765 100755 (executable)
@@ -1,6 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: ISO-8859-1 -*-
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -110,4 +111,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 2cb85de..ad8cf3b 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This tests custom input callbacks
 #
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
index b7f8b75..8e1b291 100755 (executable)
@@ -1,9 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this test exercise the XPath basic engine, parser, etc, and
 # allows to detect memory leaks
 #
 import sys
+import setup_test
 import libxml2
 
 instance="""<?xml version="1.0"?>
@@ -59,4 +60,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 8e8ef24..6433565 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -107,4 +108,3 @@ if __name__ == '__main__':
         print("OK")
     else:
         print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-        libxml2.dumpMemory()
index 56864c3..1078178 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -32,4 +33,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 850ae7e..f30088d 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -61,4 +62,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 47cd8a5..c32cd3e 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -62,4 +63,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 5a46146..318eb5e 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: ISO-8859-1 -*-
 #
 # this tests the basic APIs of the XmlTextReader interface
 #
+import setup_test
 import libxml2
 import sys
 try:
@@ -443,4 +444,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 65cecd4..9f14ecd 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 #
 # this tests the DTD validation with the XmlTextReader interface
@@ -6,7 +6,7 @@
 import sys
 import glob
 import os
-import string
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -20,103 +20,76 @@ libxml2.debugMemory(1)
 
 err = ""
 basedir = os.path.dirname(os.path.realpath(__file__))
-dir_prefix = os.path.join(basedir, "../../test/valid/")
+dir_prefix = os.path.realpath(os.path.join(basedir, "..", "..", "test", "valid"))
+
 # This dictionary reflects the contents of the files
 # ../../test/valid/*.xml.err that are not empty, except that
 # the file paths in the messages start with ../../test/
 
 expect = {
     '766956':
-"""../../test/valid/dtds/766956.dtd:2: parser error : PEReference: expecting ';'
+"""{0}/dtds/766956.dtd:2: parser error : PEReference: expecting ';'
 %ä%ent;
    ^
-../../test/valid/dtds/766956.dtd:2: parser error : Content error in the external subset
+{0}/dtds/766956.dtd:2: parser error : Content error in the external subset
 %ä%ent;
         ^
 Entity: line 1: 
 value
 ^
-""",
+""".format(dir_prefix),
     '781333':
-"""../../test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got 
+"""{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got 
 <a/>
     ^
-../../test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child
+{0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
 
 ^
-""",
+""".format(dir_prefix),
     'cond_sect2':
-"""../../test/valid/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity
+"""{0}/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity
     %ent;
          ^
 Entity: line 1: 
 ]]>
 ^
-../../test/valid/dtds/cond_sect2.dtd:17: parser error : Content error in the external subset
+{0}/dtds/cond_sect2.dtd:17: parser error : Content error in the external subset
 
 ^
-""",
+""".format(dir_prefix),
     'rss':
-"""../../test/valid/rss.xml:177: element rss: validity error : Element rss does not carry attribute version
+"""{0}/rss.xml:177: element rss: validity error : Element rss does not carry attribute version
 </rss>
       ^
-""",
+""".format(dir_prefix),
     't8':
-"""../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
+"""{0}/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
 
 %defroot; %defmiddle; %deftest;
          ^
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                     ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                               ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
-""",
+""".format(dir_prefix),
     't8a':
-"""../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
+"""{0}/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
 
 %defroot;%defmiddle;%deftest;
          ^
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                    ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                             ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
-""",
+""".format(dir_prefix),
     'xlink':
-"""../../test/valid/xlink.xml:450: element termdef: validity error : ID dt-arc already defined
+"""{0}/xlink.xml:450: element termdef: validity error : ID dt-arc already defined
        <p><termdef id="dt-arc" term="Arc">An <ter
                                          ^
 validity error : attribute def line 199 references an unknown ID "dt-xlg"
-""",
+""".format(dir_prefix),
 }
 
 # Add prefix_dir and extension to the keys
-expect = {"{}{}.xml".format(dir_prefix, key): val for key, val in expect.items()}
+expect = {os.path.join(dir_prefix, key + ".xml"): val for key, val in expect.items()}
 
 def callback(ctx, str):
     global err
@@ -124,11 +97,12 @@ def callback(ctx, str):
 libxml2.registerErrorHandler(callback, "")
 
 parsing_error_files = ["766956", "cond_sect2", "t8", "t8a"]
-expect_parsing_error = ["{}{}.xml".format(dir_prefix, f) for f in parsing_error_files]
+expect_parsing_error = [os.path.join(dir_prefix, f + ".xml") for f in parsing_error_files]
 
-valid_files = glob.glob(dir_prefix + "*.x*")
+valid_files = glob.glob(os.path.join(dir_prefix, "*.x*"))
 assert valid_files, "found no valid files in '{}'".format(dir_prefix)
 valid_files.sort()
+failures = 0
 for file in valid_files:
     err = ""
     reader = libxml2.newTextReaderFilename(file)
@@ -142,9 +116,15 @@ for file in valid_files:
         #sys.exit(1)
     if (err):
         if not(file in expect and err == expect[file]):
+            failures += 1
             print("Error: ", err)
             if file in expect:
                 print("Expected: ", expect[file])
+
+if failures:
+    print("Failed %d tests" % failures)
+    sys.exit(1)
+
 #
 # another separate test based on Stephane Bidoul one
 #
@@ -337,9 +317,11 @@ while reader.Read() == 1:
 if res != expect:
     print("test5 failed: unexpected output")
     print(res)
+    sys.exit(1)
 if err != "":
     print("test5 failed: validation error found")
     print(err)
+    sys.exit(1)
 
 #
 # cleanup
@@ -353,4 +335,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 39a7f73..9a54540 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the entities substitutions with the XmlTextReader interface
 #
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -157,4 +158,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index f5fbaa1..677d089 100755 (executable)
@@ -1,7 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the basic APIs of the XmlTextReader interface
 #
+import setup_test
 import libxml2
 import sys
 try:
@@ -47,4 +48,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index f564e9b..201a53b 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the Expand() API of the xmlTextReader interface
 # this extract the Dragon bibliography entries from the XML specification
 #
+import setup_test
 import libxml2
 import os
 import sys
@@ -46,4 +47,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 0b2e68d..33a5597 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the entities substitutions with the XmlTextReader interface
 #
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -125,4 +126,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 2b1fb6d..58131a8 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the entities substitutions with the XmlTextReader interface
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -98,4 +99,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 8636b8d..bc055df 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the entities substitutions with the XmlTextReader interface
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -33,4 +34,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 86baa3a..e3fdba6 100755 (executable)
@@ -1,7 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the basic APIs of the XmlTextReader interface
 #
+import setup_test
 import libxml2
 import sys
 try:
@@ -53,4 +54,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index b77acbc..4f216bb 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: ISO-8859-1 -*-
 #
 # this tests the next API of the XmlTextReader interface
 #
+import setup_test
 import libxml2
 import sys
 try:
@@ -83,4 +84,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 2790132..890d1dc 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -29,4 +30,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index a8a6a70..518b97e 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -44,5 +45,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index f506a74..da8fc14 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 try:
     import StringIO
@@ -40,5 +41,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index 7426c60..c73b81a 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -48,5 +49,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index 9f36a10..4666ec4 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -147,4 +148,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
diff --git a/python/tests/setup_test.py b/python/tests/setup_test.py
new file mode 100644 (file)
index 0000000..f893e56
--- /dev/null
@@ -0,0 +1,5 @@
+import os
+import sys
+
+if hasattr(os, 'add_dll_directory'):
+    os.add_dll_directory(os.path.join(os.getcwd(), '..', '..', '.libs'))
index b2a9131..ffbe540 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -135,4 +136,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index fd34951..9991b4c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import string, sys, time
 try:
     from _thread import get_ident
@@ -6,8 +6,12 @@ except:
     from thread import get_ident
 from threading import Thread, Lock
 
+import setup_test
 import libxml2
 
+# Memory debug specific
+libxml2.debugMemory(1)
+
 THREADS_COUNT = 15
 
 failed = 0
@@ -92,8 +96,10 @@ if failed:
 
 # Memory debug specific
 libxml2.cleanupParser()
+# Note that this can leak memory on Windows if the global state
+# destructors weren't run yet. They should be called eventually,
+# so this leak should be harmless.
 if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 5178336..ba624b3 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -25,4 +26,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index ffa3806..64eceac 100755 (executable)
@@ -1,6 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys, unittest
 
+import setup_test
 import libxml2
 
 class TestCase(unittest.TestCase):
@@ -15,7 +16,6 @@ class TestCase(unittest.TestCase):
     def tearDown(self):
         libxml2.cleanupParser()
         if libxml2.debugMemory(1) != 0:
-            libxml2.dumpMemory() 
             self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1),))
         else:
             print("OK")
@@ -71,8 +71,8 @@ class TestCase(unittest.TestCase):
                         (s,len(s),"dummy.xml",None,0),
                         libxml2.treeError,
                         domain=libxml2.XML_FROM_PARSER,
-                        code=libxml2.XML_ERR_TAG_NOT_FINISHED,
-                        message='Premature end of data in tag x line 1\n',
+                        code=libxml2.XML_ERR_TAG_NAME_MISMATCH,
+                        message='Opening and ending tag mismatch: a line 2 and x\n',
                         level=libxml2.XML_ERR_FATAL,
                         file='dummy.xml',
                         line=3)
index 8c22ee7..0b1bcbc 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -38,4 +39,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 858f227..eca0754 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 
 try:
@@ -38,4 +39,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index e8ba082..d429f54 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 #memory debug specific
@@ -60,4 +61,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 17c7b3d..b118326 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -55,5 +56,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index 22ebe31..bcc729f 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -72,5 +73,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index b123e01..9e64210 100755 (executable)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import setup_test
 import libxml2
 import sys
 
@@ -79,5 +80,4 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
 
index 08c30ff..dbf5966 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -79,4 +80,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 00bb4c9..b1af875 100755 (executable)
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this tests the entities substitutions with the XmlTextReader interface
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -141,4 +142,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index de9c2fd..ae14486 100755 (executable)
@@ -1,9 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # this test exercise the XPath basic engine, parser, etc, and
 # allows to detect memory leaks
 #
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -48,4 +49,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index ab7b3bb..4eb8313 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 # Memory debug specific
@@ -46,4 +47,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 0445fce..8734561 100755 (executable)
@@ -1,5 +1,7 @@
-#!/usr/bin/env python
-import sys, libxml2
+#!/usr/bin/env python3
+import setup_test
+import libxml2
+import sys
 
 libxml2.debugMemory(True)
 
@@ -51,5 +53,3 @@ if leakedbytes == 0:
        print("OK")
 else:
        print("Memory leak", leakedbytes, "bytes")
-       # drop file to .memdump file in cwd, but won't work if not compiled in
-       libxml2.dumpMemory()
index 3aae6c7..4567fcf 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
+import setup_test
 import libxml2
 
 expect=' xmlns:a="urn:whatevar"'
@@ -11,6 +12,7 @@ d = libxml2.parseDoc("<a:a xmlns:a='urn:whatevar'/>")
 res=""
 for n in d.xpathEval("//namespace::*"):
     res = res + n.serialize()
+del n
 d.freeDoc()
 
 if res != expect:
@@ -18,7 +20,6 @@ if res != expect:
     print(res)
 del res
 del d
-del n
 # Memory debug specific
 libxml2.cleanupParser()
 
@@ -26,4 +27,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 254bd94..76d5cb7 100755 (executable)
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
+import setup_test
 import libxml2
 
 #memory debug specific
@@ -54,4 +55,3 @@ if libxml2.debugMemory(1) == 0:
     print("OK")
 else:
     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
-    libxml2.dumpMemory()
index 27ad500..2782a6a 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include "libxml_wrap.h"
 #include <libxml/xpathInternals.h>
+#include <string.h>
 
 #if PY_MAJOR_VERSION >= 3
 #define PY_IMPORT_STRING_SIZE PyUnicode_FromStringAndSize
@@ -78,14 +79,12 @@ myInvalidParameterHandler(const wchar_t *expression,
 
 FILE *
 libxml_PyFileGet(PyObject *f) {
-    int flags;
     FILE *res;
     const char *mode;
-
     int fd = PyObject_AsFileDescriptor(f);
-    intptr_t w_fh = -1;
 
 #ifdef _WIN32
+    intptr_t w_fh = -1;
     HMODULE hntdll = NULL;
     IO_STATUS_BLOCK status_block;
     FILE_ACCESS_INFORMATION ai;
@@ -113,8 +112,9 @@ libxml_PyFileGet(PyObject *f) {
 
     if (hntdll == NULL)
         return(NULL);
-
+XML_IGNORE_FPTR_CAST_WARNINGS
     NtQueryInformationFile = (t_NtQueryInformationFile)GetProcAddress(hntdll, "NtQueryInformationFile");
+XML_POP_WARNINGS
 
     if (NtQueryInformationFile != NULL &&
         (NtQueryInformationFile((HANDLE)w_fh,
@@ -130,23 +130,24 @@ libxml_PyFileGet(PyObject *f) {
             if (ai.AccessFlags & FILE_APPEND_DATA)
                 is_append = TRUE;
 
-            if (is_write && is_read)
-                if (is_append)
-                    mode = "a+";
-                else
-                    mode = "rw";
-
-            if (!is_write && is_read)
+            if (is_write) {
+                if (is_read) {
+                    if (is_append)
+                        mode = "a+";
+                    else
+                        mode = "rw";
+                } else {
+                    if (is_append)
+                        mode = "a";
+                    else
+                        mode = "w";
+                }
+            } else {
                 if (is_append)
                     mode = "r+";
                 else
                     mode = "r";
-
-            if (is_write && !is_read)
-                if (is_append)
-                    mode = "a";
-                else
-                    mode = "w";
+            }
         }
 
     FreeLibrary(hntdll);
@@ -154,31 +155,47 @@ libxml_PyFileGet(PyObject *f) {
     if (!is_write && !is_read) /* also happens if we did not load or run NtQueryInformationFile() successfully */
         return(NULL);
 #else
+    int flags;
+
     /*
-     * Get the flags on the fd to understand how it was opened
+     * macOS returns O_RDWR for standard streams, but fails to write to
+     * stdout or stderr when opened with fdopen(dup_fd, "rw").
      */
-    flags = fcntl(fd, F_GETFL, 0);
-    switch (flags & O_ACCMODE) {
-        case O_RDWR:
-           if (flags & O_APPEND)
-               mode = "a+";
-           else
-               mode = "rw";
-           break;
-        case O_RDONLY:
-           if (flags & O_APPEND)
-               mode = "r+";
-           else
-               mode = "r";
-           break;
-       case O_WRONLY:
-           if (flags & O_APPEND)
-               mode = "a";
-           else
-               mode = "w";
-           break;
-       default:
-           return(NULL);
+    switch (fd) {
+        case STDIN_FILENO:
+            mode = "r";
+            break;
+        case STDOUT_FILENO:
+        case STDERR_FILENO:
+            mode = "w";
+            break;
+        default:
+            /*
+             * Get the flags on the fd to understand how it was opened
+             */
+            flags = fcntl(fd, F_GETFL, 0);
+            switch (flags & O_ACCMODE) {
+                case O_RDWR:
+                    if (flags & O_APPEND)
+                        mode = "a+";
+                    else
+                        mode = "rw";
+                    break;
+                case O_RDONLY:
+                    if (flags & O_APPEND)
+                        mode = "r+";
+                    else
+                        mode = "r";
+                    break;
+                case O_WRONLY:
+                    if (flags & O_APPEND)
+                        mode = "a";
+                    else
+                        mode = "w";
+                    break;
+                default:
+                    return(NULL);
+            }
     }
 #endif
 
@@ -213,9 +230,6 @@ libxml_intWrap(int val)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_intWrap: val = %d\n", val);
-#endif
     ret = PY_IMPORT_INT((long) val);
     return (ret);
 }
@@ -225,9 +239,6 @@ libxml_longWrap(long val)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_longWrap: val = %ld\n", val);
-#endif
     ret = PyLong_FromLong(val);
     return (ret);
 }
@@ -237,9 +248,6 @@ libxml_doubleWrap(double val)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_doubleWrap: val = %f\n", val);
-#endif
     ret = PyFloat_FromDouble((double) val);
     return (ret);
 }
@@ -249,9 +257,6 @@ libxml_charPtrWrap(char *str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlcharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -266,9 +271,6 @@ libxml_charPtrConstWrap(const char *str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlcharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -282,9 +284,6 @@ libxml_xmlCharPtrWrap(xmlChar * str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlCharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -299,9 +298,6 @@ libxml_xmlCharPtrConstWrap(const xmlChar * str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlCharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -315,9 +311,6 @@ libxml_constcharPtrWrap(const char *str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlcharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -331,9 +324,6 @@ libxml_constxmlCharPtrWrap(const xmlChar * str)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlCharPtrWrap: str = %s\n", str);
-#endif
     if (str == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -347,9 +337,6 @@ libxml_xmlDocPtrWrap(xmlDocPtr doc)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlDocPtrWrap: doc = %p\n", doc);
-#endif
     if (doc == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -364,9 +351,6 @@ libxml_xmlNodePtrWrap(xmlNodePtr node)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlNodePtrWrap: node = %p\n", node);
-#endif
     if (node == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -380,9 +364,6 @@ libxml_xmlURIPtrWrap(xmlURIPtr uri)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlURIPtrWrap: uri = %p\n", uri);
-#endif
     if (uri == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -396,9 +377,6 @@ libxml_xmlNsPtrWrap(xmlNsPtr ns)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlNsPtrWrap: node = %p\n", ns);
-#endif
     if (ns == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -412,9 +390,6 @@ libxml_xmlAttrPtrWrap(xmlAttrPtr attr)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlAttrNodePtrWrap: attr = %p\n", attr);
-#endif
     if (attr == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -428,9 +403,6 @@ libxml_xmlAttributePtrWrap(xmlAttributePtr attr)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlAttributePtrWrap: attr = %p\n", attr);
-#endif
     if (attr == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -444,9 +416,6 @@ libxml_xmlElementPtrWrap(xmlElementPtr elem)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlElementNodePtrWrap: elem = %p\n", elem);
-#endif
     if (elem == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -460,9 +429,6 @@ libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlXPathContextPtrWrap: ctxt = %p\n", ctxt);
-#endif
     if (ctxt == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -476,9 +442,6 @@ libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlXPathParserContextPtrWrap: ctxt = %p\n", ctxt);
-#endif
     if (ctxt == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -492,9 +455,6 @@ libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlParserCtxtPtrWrap: ctxt = %p\n", ctxt);
-#endif
     if (ctxt == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -521,9 +481,6 @@ static void
 libxml_xmlXPathDestructNsNode(PyObject *cap)
 #endif
 {
-#ifdef DEBUG
-    fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cap);
-#endif
 #if PY_VERSION_HEX < 0x02070000
     xmlXPathNodeSetFreeNs((xmlNsPtr) cap);
 #else
@@ -536,9 +493,6 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlXPathObjectPtrWrap: ctxt = %p\n", obj);
-#endif
     if (obj == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -707,9 +661,6 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
         }
 #endif /* LIBXML_XPTR_LOCS_ENABLED */
         default:
-#ifdef DEBUG
-            printf("Unable to convert XPath object type %d\n", obj->type);
-#endif
             Py_INCREF(Py_None);
             ret = Py_None;
     }
@@ -722,9 +673,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
 {
     xmlXPathObjectPtr ret = NULL;
 
-#ifdef DEBUG
-    printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
-#endif
     if (obj == NULL) {
         return (NULL);
     }
@@ -791,9 +739,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
 
             cur = NULL;
             if (PyCapsule_CheckExact(node)) {
-#ifdef DEBUG
-                printf("Got a Capsule\n");
-#endif
                 cur = PyxmlNode_Get(node);
             } else if ((PyObject_HasAttrString(node, (char *) "_o")) &&
                       (PyObject_HasAttrString(node, (char *) "get_doc"))) {
@@ -803,9 +748,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
                if (wrapper != NULL)
                    cur = PyxmlNode_Get(wrapper);
             } else {
-#ifdef DEBUG
-                printf("Unknown object in Python return list\n");
-#endif
             }
             if (cur != NULL) {
                 xmlXPathNodeSetAdd(set, cur);
@@ -813,9 +755,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
         }
         ret = xmlXPathWrapNodeSet(set);
     } else {
-#ifdef DEBUG
-        printf("Unable to convert Python Object to XPath");
-#endif
     }
     return (ret);
 }
@@ -825,9 +764,6 @@ libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid)
 {
        PyObject *ret;
 
-#ifdef DEBUG
-       printf("libxml_xmlValidCtxtPtrWrap: valid = %p\n", valid);
-#endif
        if (valid == NULL) {
                Py_INCREF(Py_None);
                return (Py_None);
@@ -845,9 +781,6 @@ libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlNodePtrWrap: catal = %p\n", catal);
-#endif
     if (catal == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -863,9 +796,6 @@ libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlOutputBufferPtrWrap: buffer = %p\n", buffer);
-#endif
     if (buffer == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -881,9 +811,6 @@ libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlParserInputBufferPtrWrap: buffer = %p\n", buffer);
-#endif
     if (buffer == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -900,9 +827,6 @@ libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlRegexpPtrWrap: regexp = %p\n", regexp);
-#endif
     if (regexp == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -920,9 +844,6 @@ libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlTextReaderPtrWrap: reader = %p\n", reader);
-#endif
     if (reader == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -938,9 +859,6 @@ libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlTextReaderLocatorPtrWrap: locator = %p\n", locator);
-#endif
     if (locator == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -958,9 +876,6 @@ libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlRelaxNGPtrWrap: ctxt = %p\n", ctxt);
-#endif
     if (ctxt == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -976,9 +891,6 @@ libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlRelaxNGParserCtxtPtrWrap: ctxt = %p\n", ctxt);
-#endif
     if (ctxt == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -993,9 +905,6 @@ libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid)
 {
     PyObject *ret;
 
-#ifdef DEBUG
-    printf("libxml_xmlRelaxNGValidCtxtPtrWrap: valid = %p\n", valid);
-#endif
     if (valid == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
@@ -1011,9 +920,6 @@ libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt)
 {
        PyObject *ret;
 
-#ifdef DEBUG
-       printf("libxml_xmlSchemaPtrWrap: ctxt = %p\n", ctxt);
-#endif
        if (ctxt == NULL) {
                Py_INCREF(Py_None);
                return (Py_None);
@@ -1029,9 +935,6 @@ libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt)
 {
        PyObject *ret;
 
-#ifdef DEBUG
-       printf("libxml_xmlSchemaParserCtxtPtrWrap: ctxt = %p\n", ctxt);
-#endif
        if (ctxt == NULL) {
                Py_INCREF(Py_None);
                return (Py_None);
@@ -1048,9 +951,6 @@ libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid)
 {
        PyObject *ret;
        
-#ifdef DEBUG
-       printf("libxml_xmlSchemaValidCtxtPtrWrap: valid = %p\n", valid);
-#endif
        if (valid == NULL) {
                Py_INCREF(Py_None);
                return (Py_None);
@@ -1064,18 +964,30 @@ libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid)
 }
 #endif /* LIBXML_SCHEMAS_ENABLED */
 
+static void
+libxml_xmlDestructError(PyObject *cap) {
+    xmlErrorPtr err = (xmlErrorPtr) PyCapsule_GetPointer(cap, "xmlErrorPtr");
+    xmlResetError(err);
+    xmlFree(err);
+}
+
 PyObject *
-libxml_xmlErrorPtrWrap(xmlErrorPtr error)
+libxml_xmlErrorPtrWrap(const xmlError *error)
 {
     PyObject *ret;
+    xmlErrorPtr copy;
 
-#ifdef DEBUG
-    printf("libxml_xmlErrorPtrWrap: error = %p\n", error);
-#endif
     if (error == NULL) {
         Py_INCREF(Py_None);
         return (Py_None);
     }
-    ret = PyCapsule_New((void *) error, (char *) "xmlErrorPtr", NULL);
+    copy = xmlMalloc(sizeof(*copy));
+    if (copy == NULL) {
+        Py_INCREF(Py_None);
+        return (Py_None);
+    }
+    memset(copy, 0, sizeof(*copy));
+    xmlCopyError(error, copy);
+    ret = PyCapsule_New(copy, "xmlErrorPtr", libxml_xmlDestructError);
     return (ret);
 }
index 7f0f2e7..d7c407d 100644 (file)
--- a/relaxng.c
+++ b/relaxng.c
 #include <libxml/xmlregexp.h>
 #include <libxml/xmlschemastypes.h>
 
+#include "private/error.h"
+#include "private/regexp.h"
+#include "private/string.h"
+
 /*
  * The Relax-NG namespace
  */
@@ -47,30 +51,6 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
     (xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
 
 
-#if 0
-#define DEBUG 1
-
-#define DEBUG_GRAMMAR 1
-
-#define DEBUG_CONTENT 1
-
-#define DEBUG_TYPE 1
-
-#define DEBUG_VALID 1
-
-#define DEBUG_INTERLEAVE 1
-
-#define DEBUG_LIST 1
-
-#define DEBUG_INCLUDE 1
-
-#define DEBUG_ERROR 1
-
-#define DEBUG_COMPILE 1
-
-#define DEBUG_PROGRESSIVE 1
-#endif
-
 #define MAX_ERROR 5
 
 #define TODO                                                           \
@@ -1523,15 +1503,6 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
     xmlNodePtr tmp, tmp2;
     xmlChar *name2;
 
-#ifdef DEBUG_INCLUDE
-    if (name == NULL)
-        xmlGenericError(xmlGenericErrorContext,
-                        "Elimination of <include> start from %s\n", URL);
-    else
-        xmlGenericError(xmlGenericErrorContext,
-                        "Elimination of <include> define %s from %s\n",
-                        name, URL);
-#endif
     tmp = target;
     while (tmp != NULL) {
         tmp2 = tmp->next;
@@ -1559,18 +1530,11 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
 
                 if (xmlStrEqual
                     (inc->doc->children->name, BAD_CAST "grammar")) {
-#ifdef DEBUG_INCLUDE
-                    href = xmlGetProp(tmp, BAD_CAST "href");
-#endif
                     if (xmlRelaxNGRemoveRedefine(ctxt, href,
                                                  xmlDocGetRootElement(inc->doc)->children,
                                                  name) == 1) {
                         found = 1;
                     }
-#ifdef DEBUG_INCLUDE
-                    if (href != NULL)
-                        xmlFree(href);
-#endif
                 }
             }
             if (xmlRelaxNGRemoveRedefine(ctxt, URL, tmp->children, name) == 1) {
@@ -1604,11 +1568,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
     int i;
     xmlNodePtr root, cur;
 
-#ifdef DEBUG_INCLUDE
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlRelaxNGLoadInclude(%s)\n", URL);
-#endif
-
     /*
      * check against recursion in the stack
      */
@@ -1630,9 +1589,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
                    "xmlRelaxNG: could not load %s\n", URL, NULL);
         return (NULL);
     }
-#ifdef DEBUG_INCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Parsed %s Okay\n", URL);
-#endif
 
     /*
      * Allocate the document structures and register it first.
@@ -1670,9 +1626,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
      * Some preprocessing of the document content, this include recursing
      * in the include stack.
      */
-#ifdef DEBUG_INCLUDE
-    xmlGenericError(xmlGenericErrorContext, "cleanup of %s\n", URL);
-#endif
 
     doc = xmlRelaxNGCleanupDoc(ctxt, doc);
     if (doc == NULL) {
@@ -1685,9 +1638,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
      */
     xmlRelaxNGIncludePop(ctxt);
 
-#ifdef DEBUG_INCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Checking of %s\n", URL);
-#endif
     /*
      * Check that the top element is a grammar
      */
@@ -1779,10 +1729,6 @@ xmlRelaxNGValidErrorPush(xmlRelaxNGValidCtxtPtr ctxt,
 {
     xmlRelaxNGValidErrorPtr cur;
 
-#ifdef DEBUG_ERROR
-    xmlGenericError(xmlGenericErrorContext,
-                    "Pushing error %d at %d on stack\n", err, ctxt->errNr);
-#endif
     if (ctxt->errTab == NULL) {
         ctxt->errMax = 8;
         ctxt->errNr = 0;
@@ -2257,9 +2203,6 @@ xmlRelaxNGShowValidError(xmlRelaxNGValidCtxtPtr ctxt,
     if (ctxt->flags & FLAGS_NOERROR)
         return;
 
-#ifdef DEBUG_ERROR
-    xmlGenericError(xmlGenericErrorContext, "Show error %d\n", err);
-#endif
     msg = xmlRelaxNGGetErrorString(err, arg1, arg2);
     if (msg == NULL)
         return;
@@ -2284,10 +2227,6 @@ xmlRelaxNGPopErrors(xmlRelaxNGValidCtxtPtr ctxt, int level)
     int i;
     xmlRelaxNGValidErrorPtr err;
 
-#ifdef DEBUG_ERROR
-    xmlGenericError(xmlGenericErrorContext,
-                    "Pop errors till level %d\n", level);
-#endif
     for (i = level; i < ctxt->errNr; i++) {
         err = &ctxt->errTab[i];
         if (err->flags & ERROR_IS_DUP) {
@@ -2317,10 +2256,6 @@ xmlRelaxNGDumpValidError(xmlRelaxNGValidCtxtPtr ctxt)
     int i, j, k;
     xmlRelaxNGValidErrorPtr err, dup;
 
-#ifdef DEBUG_ERROR
-    xmlGenericError(xmlGenericErrorContext,
-                    "Dumping error stack %d errors\n", ctxt->errNr);
-#endif
     for (i = 0, k = 0; i < ctxt->errNr; i++) {
         err = &ctxt->errTab[i];
         if (k < MAX_ERROR) {
@@ -2371,9 +2306,6 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
     if (ctxt->flags & FLAGS_NOERROR)
         return;
 
-#ifdef DEBUG_ERROR
-    xmlGenericError(xmlGenericErrorContext, "Adding error %d\n", err);
-#endif
     /*
      * generate the error directly
      */
@@ -2875,10 +2807,6 @@ xmlRelaxNGCleanupTypes(void)
  *                                                                     *
  ************************************************************************/
 
-/* from automata.c but not exported */
-void xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
-
-
 static int xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt,
                                 xmlRelaxNGDefinePtr def);
 
@@ -2937,21 +2865,6 @@ xmlRelaxNGIsCompilable(xmlRelaxNGDefinePtr def)
                }
                 if ((ret == 1) && !(def->dflags &= IS_NOT_COMPILABLE))
                     def->dflags |= IS_COMPILABLE;
-#ifdef DEBUG_COMPILE
-                if (ret == 1) {
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "element content for %s is compilable\n",
-                                    def->name);
-                } else if (ret == 0) {
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "element content for %s is not compilable\n",
-                                    def->name);
-                } else {
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "Problem in RelaxNGIsCompilable for element %s\n",
-                                    def->name);
-                }
-#endif
             }
             /*
              * All elements return a compilable status unless they
@@ -3013,21 +2926,6 @@ xmlRelaxNGIsCompilable(xmlRelaxNGDefinePtr def)
         def->dflags |= IS_NOT_COMPILABLE;
     if (ret == 1)
         def->dflags |= IS_COMPILABLE;
-#ifdef DEBUG_COMPILE
-    if (ret == 1) {
-        xmlGenericError(xmlGenericErrorContext,
-                        "RelaxNGIsCompilable %s : true\n",
-                        xmlRelaxNGDefName(def));
-    } else if (ret == 0) {
-        xmlGenericError(xmlGenericErrorContext,
-                        "RelaxNGIsCompilable %s : false\n",
-                        xmlRelaxNGDefName(def));
-    } else {
-        xmlGenericError(xmlGenericErrorContext,
-                        "Problem in RelaxNGIsCompilable %s\n",
-                        xmlRelaxNGDefName(def));
-    }
-#endif
     return (ret);
 }
 
@@ -3113,11 +3011,6 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
                 xmlAutomataSetFinalState(ctxt->am, ctxt->state);
                 def->contModel = xmlAutomataCompile(ctxt->am);
                 if (!xmlRegexpIsDeterminist(def->contModel)) {
-#ifdef DEBUG_COMPILE
-                    xmlGenericError(xmlGenericErrorContext,
-                        "Content model not determinist %s\n",
-                                    def->name);
-#endif
                     /*
                      * we can only use the automata if it is determinist
                      */
@@ -3282,24 +3175,6 @@ xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
         if ((def->dflags & IS_COMPILABLE) && (def->depth != -25)) {
             ctxt->am = NULL;
             ret = xmlRelaxNGCompile(ctxt, def);
-#ifdef DEBUG_PROGRESSIVE
-            if (ret == 0) {
-                if (def->type == XML_RELAXNG_START)
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "compiled the start\n");
-                else
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "compiled element %s\n", def->name);
-            } else {
-                if (def->type == XML_RELAXNG_START)
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "failed to compile the start\n");
-                else
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "failed to compile element %s\n",
-                                    def->name);
-            }
-#endif
             return (ret);
         }
     }
@@ -4359,19 +4234,12 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
     if (ctxt->nbErrors != 0)
         return;
 
-#ifdef DEBUG_INTERLEAVE
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlRelaxNGComputeInterleaves(%s)\n", name);
-#endif
     cur = def->content;
     while (cur != NULL) {
         nbchild++;
         cur = cur->next;
     }
 
-#ifdef DEBUG_INTERLEAVE
-    xmlGenericError(xmlGenericErrorContext, "  %d child\n", nbchild);
-#endif
     groups = (xmlRelaxNGInterleaveGroupPtr *)
         xmlMalloc(nbchild * sizeof(xmlRelaxNGInterleaveGroupPtr));
     if (groups == NULL)
@@ -4390,9 +4258,6 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
         nbgroups++;
         cur = cur->next;
     }
-#ifdef DEBUG_INTERLEAVE
-    xmlGenericError(xmlGenericErrorContext, "  %d groups\n", nbgroups);
-#endif
 
     /*
      * Let's check that all rules makes a partitions according to 7.4
@@ -5019,11 +4884,6 @@ xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
         xmlRelaxNGGrammarPtr grammar, old;
         xmlRelaxNGGrammarPtr oldparent;
 
-#ifdef DEBUG_GRAMMAR
-        xmlGenericError(xmlGenericErrorContext,
-                        "Found <grammar> pattern\n");
-#endif
-
         oldparent = ctxt->parentgrammar;
         old = ctxt->grammar;
         ctxt->parentgrammar = old;
@@ -5809,11 +5669,6 @@ xmlRelaxNGCheckCombine(void *payload, void *data, const xmlChar * name)
 
         cur = cur->nextHash;
     }
-#ifdef DEBUG
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlRelaxNGCheckCombine(): merging %s defines: %d\n",
-                    name, choiceOrInterleave);
-#endif
     if (choiceOrInterleave == -1)
         choiceOrInterleave = 0;
     cur = xmlRelaxNGNewDefine(ctxt, define->node);
@@ -5939,11 +5794,6 @@ xmlRelaxNGCombineStart(xmlRelaxNGParserCtxtPtr ctxt,
 
         cur = cur->next;
     }
-#ifdef DEBUG
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlRelaxNGCombineStart(): merging <start>: %d\n",
-                    choiceOrInterleave);
-#endif
     if (choiceOrInterleave == -1)
         choiceOrInterleave = 0;
     cur = xmlRelaxNGNewDefine(ctxt, starts->node);
@@ -6609,10 +6459,6 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
 {
     xmlRelaxNGGrammarPtr ret, tmp, old;
 
-#ifdef DEBUG_GRAMMAR
-    xmlGenericError(xmlGenericErrorContext, "Parsing a new grammar\n");
-#endif
-
     ret = xmlRelaxNGNewGrammar(ctxt);
     if (ret == NULL)
         return (NULL);
@@ -6741,11 +6587,6 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
                                  XML_RELAXNG_IN_START, XML_RELAXNG_NOOP);
         }
     }
-#ifdef DEBUG
-    if (schema == NULL)
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlRelaxNGParseDocument() failed\n");
-#endif
 
     return (schema);
 }
@@ -7971,10 +7812,6 @@ xmlRelaxNGValidateCompiledCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
     xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) transdata;
     int ret;
 
-#ifdef DEBUG_COMPILE
-    xmlGenericError(xmlGenericErrorContext,
-                    "Compiled callback for: '%s'\n", token);
-#endif
     if (ctxt == NULL) {
         fprintf(stderr, "callback on %s missing context\n", token);
         return;
@@ -7987,12 +7824,7 @@ xmlRelaxNGValidateCompiledCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
             ctxt->errNo = XML_RELAXNG_ERR_INTERNAL;
         return;
     }
-    if ((ctxt == NULL) || (define == NULL)) {
-        fprintf(stderr, "callback on %s missing info\n", token);
-        if ((ctxt != NULL) && (ctxt->errNo == XML_RELAXNG_OK))
-            ctxt->errNo = XML_RELAXNG_ERR_INTERNAL;
-        return;
-    } else if (define->type != XML_RELAXNG_ELEMENT) {
+    if (define->type != XML_RELAXNG_ELEMENT) {
         fprintf(stderr, "callback on %s define is not element\n", token);
         if (ctxt->errNo == XML_RELAXNG_OK)
             ctxt->errNo = XML_RELAXNG_ERR_INTERNAL;
@@ -8186,10 +8018,6 @@ xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec
     xmlNodePtr node;
     int ret = 0, oldflags;
 
-#ifdef DEBUG_PROGRESSIVE
-    xmlGenericError(xmlGenericErrorContext,
-                    "Progressive callback for: '%s'\n", token);
-#endif
     if (ctxt == NULL) {
         fprintf(stderr, "callback on %s missing context\n", token);
         return;
@@ -8229,11 +8057,6 @@ xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec
         /*
          * this node cannot be validated in a streamable fashion
          */
-#ifdef DEBUG_PROGRESSIVE
-        xmlGenericError(xmlGenericErrorContext,
-                        "Element '%s' validation is not streamable\n",
-                        token);
-#endif
         ctxt->pstate = 0;
         ctxt->pdef = define;
         return;
@@ -8330,9 +8153,6 @@ xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt,
     if ((ctxt == NULL) || (elem == NULL))
         return (-1);
 
-#ifdef DEBUG_PROGRESSIVE
-    xmlGenericError(xmlGenericErrorContext, "PushElem %s\n", elem->name);
-#endif
     if (ctxt->elem == 0) {
         xmlRelaxNGPtr schema;
         xmlRelaxNGGrammarPtr grammar;
@@ -8381,11 +8201,6 @@ xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt,
         else
             ret = 1;
     }
-#ifdef DEBUG_PROGRESSIVE
-    if (ret < 0)
-        xmlGenericError(xmlGenericErrorContext, "PushElem %s failed\n",
-                        elem->name);
-#endif
     return (ret);
 }
 
@@ -8408,10 +8223,6 @@ xmlRelaxNGValidatePushCData(xmlRelaxNGValidCtxtPtr ctxt,
     if ((ctxt == NULL) || (ctxt->elem == NULL) || (data == NULL))
         return (-1);
 
-#ifdef DEBUG_PROGRESSIVE
-    xmlGenericError(xmlGenericErrorContext, "CDATA %s %d\n", data, len);
-#endif
-
     while (*data != 0) {
         if (!IS_BLANK_CH(*data))
             break;
@@ -8423,9 +8234,6 @@ xmlRelaxNGValidatePushCData(xmlRelaxNGValidCtxtPtr ctxt,
     ret = xmlRegExecPushString(ctxt->elem, BAD_CAST "#text", ctxt);
     if (ret < 0) {
         VALID_ERR2(XML_RELAXNG_ERR_TEXTWRONG, BAD_CAST " TODO ");
-#ifdef DEBUG_PROGRESSIVE
-        xmlGenericError(xmlGenericErrorContext, "CDATA failed\n");
-#endif
 
         return (-1);
     }
@@ -8452,9 +8260,6 @@ xmlRelaxNGValidatePopElement(xmlRelaxNGValidCtxtPtr ctxt,
 
     if ((ctxt == NULL) || (ctxt->elem == NULL) || (elem == NULL))
         return (-1);
-#ifdef DEBUG_PROGRESSIVE
-    xmlGenericError(xmlGenericErrorContext, "PopElem %s\n", elem->name);
-#endif
     /*
      * verify that we reached a terminal state of the content model.
      */
@@ -8472,11 +8277,6 @@ xmlRelaxNGValidatePopElement(xmlRelaxNGValidCtxtPtr ctxt,
         ret = 1;
     }
     xmlRegFreeExecCtxt(exec);
-#ifdef DEBUG_PROGRESSIVE
-    if (ret < 0)
-        xmlGenericError(xmlGenericErrorContext, "PopElem %s failed\n",
-                        elem->name);
-#endif
     return (ret);
 }
 
@@ -8501,9 +8301,6 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
 
     if ((ctxt == NULL) || (ctxt->pdef == NULL) || (elem == NULL))
         return (-1);
-#ifdef DEBUG_PROGRESSIVE
-    xmlGenericError(xmlGenericErrorContext, "FullElem %s\n", elem->name);
-#endif
     state = xmlRelaxNGNewValidState(ctxt, elem->parent);
     if (state == NULL) {
         return (-1);
@@ -8518,11 +8315,6 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
         ret = 1;
     xmlRelaxNGFreeValidState(ctxt, ctxt->state);
     ctxt->state = NULL;
-#ifdef DEBUG_PROGRESSIVE
-    if (ret < 0)
-        xmlGenericError(xmlGenericErrorContext, "FullElem %s failed\n",
-                        elem->name);
-#endif
     return (ret);
 }
 
@@ -8588,7 +8380,7 @@ xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * str)
         tmp++;
     len = tmp - str;
 
-    ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMallocAtomic(len + 1);
     if (ret == NULL) {
         xmlRngVErrMemory(ctxt, "validating\n");
         return (NULL);
@@ -8852,10 +8644,6 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
                 xmlRelaxNGDefinePtr list = define->content;
                 xmlChar *oldvalue, *oldend, *val, *cur;
 
-#ifdef DEBUG_LIST
-                int nb_values = 0;
-#endif
-
                 oldvalue = ctxt->state->value;
                 oldend = ctxt->state->endvalue;
 
@@ -8872,20 +8660,11 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
                     if (IS_BLANK_CH(*cur)) {
                         *cur = 0;
                         cur++;
-#ifdef DEBUG_LIST
-                        nb_values++;
-#endif
                         while (IS_BLANK_CH(*cur))
                             *cur++ = 0;
                     } else
                         cur++;
                 }
-#ifdef DEBUG_LIST
-                xmlGenericError(xmlGenericErrorContext,
-                                "list value: '%s' found %d items\n",
-                                oldvalue, nb_values);
-                nb_values = 0;
-#endif
                 ctxt->state->endvalue = cur;
                 cur = val;
                 while ((*cur == 0) && (cur != ctxt->state->endvalue))
@@ -8898,16 +8677,8 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
                         ctxt->state->value = NULL;
                     ret = xmlRelaxNGValidateValue(ctxt, list);
                     if (ret != 0) {
-#ifdef DEBUG_LIST
-                        xmlGenericError(xmlGenericErrorContext,
-                                        "Failed to validate value: '%s' with %d rule\n",
-                                        ctxt->state->value, nb_values);
-#endif
                         break;
                     }
-#ifdef DEBUG_LIST
-                    nb_values++;
-#endif
                     list = list->next;
                 }
 
@@ -9171,11 +8942,6 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
         } else {
             ret = -1;
         }
-#ifdef DEBUG
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlRelaxNGValidateAttribute(%s): %d\n",
-                        define->name, ret);
-#endif
     } else {
         for (i = 0; i < ctxt->state->nbAttrs; i++) {
             tmp = ctxt->state->attrs[i];
@@ -9208,17 +8974,6 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
         } else {
             ret = -1;
         }
-#ifdef DEBUG
-        if (define->ns != NULL) {
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlRelaxNGValidateAttribute(nsName ns = %s): %d\n",
-                            define->ns, ret);
-        } else {
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlRelaxNGValidateAttribute(anyName): %d\n",
-                            ret);
-        }
-#endif
     }
 
     return (ret);
@@ -9900,18 +9655,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
     } else {
         node = NULL;
     }
-#ifdef DEBUG
-    for (i = 0; i < ctxt->depth; i++)
-        xmlGenericError(xmlGenericErrorContext, " ");
-    xmlGenericError(xmlGenericErrorContext,
-                    "Start validating %s ", xmlRelaxNGDefName(define));
-    if (define->name != NULL)
-        xmlGenericError(xmlGenericErrorContext, "%s ", define->name);
-    if ((node != NULL) && (node->name != NULL))
-        xmlGenericError(xmlGenericErrorContext, "on %s\n", node->name);
-    else
-        xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
     ctxt->depth++;
     switch (define->type) {
         case XML_RELAXNG_EMPTY:
@@ -10030,11 +9773,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
                 ctxt->states = tmpstates;
                 xmlRelaxNGFreeValidState(ctxt, nstate);
 
-#ifdef DEBUG_COMPILE
-                xmlGenericError(xmlGenericErrorContext,
-                                "Validating content of '%s' : %d\n",
-                                define->name, tmp);
-#endif
                 if (tmp != 0)
                     ret = -1;
 
@@ -10152,21 +9890,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
                     xmlRelaxNGPopErrors(ctxt, errNr);
             }
 
-#ifdef DEBUG
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlRelaxNGValidateDefinition(): validated %s : %d",
-                            node->name, ret);
-            if (oldstate == NULL)
-                xmlGenericError(xmlGenericErrorContext, ": no state\n");
-            else if (oldstate->seq == NULL)
-                xmlGenericError(xmlGenericErrorContext, ": done\n");
-            else if (oldstate->seq->type == XML_ELEMENT_NODE)
-                xmlGenericError(xmlGenericErrorContext, ": next elem %s\n",
-                                oldstate->seq->name);
-            else
-                xmlGenericError(xmlGenericErrorContext, ": next %s %d\n",
-                                oldstate->seq->name, oldstate->seq->type);
-#endif
             break;
         case XML_RELAXNG_OPTIONAL:{
                 errNr = ctxt->errNr;
@@ -10625,18 +10348,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
             break;
     }
     ctxt->depth--;
-#ifdef DEBUG
-    for (i = 0; i < ctxt->depth; i++)
-        xmlGenericError(xmlGenericErrorContext, " ");
-    xmlGenericError(xmlGenericErrorContext,
-                    "Validating %s ", xmlRelaxNGDefName(define));
-    if (define->name != NULL)
-        xmlGenericError(xmlGenericErrorContext, "%s ", define->name);
-    if (ret == 0)
-        xmlGenericError(xmlGenericErrorContext, "succeeded\n");
-    else
-        xmlGenericError(xmlGenericErrorContext, "failed\n");
-#endif
     return (ret);
 }
 
@@ -10835,14 +10546,6 @@ xmlRelaxNGValidateDocument(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc)
     }
     if (ret != 0)
         xmlRelaxNGDumpValidError(ctxt);
-#ifdef DEBUG
-    else if (ctxt->errNr != 0) {
-        ctxt->error(ctxt->userData,
-                    "%d Extra error messages left on stack !\n",
-                    ctxt->errNr);
-        xmlRelaxNGDumpValidError(ctxt);
-    }
-#endif
 #ifdef LIBXML_VALID_ENABLED
     if (ctxt->idref == 1) {
         xmlValidCtxt vctxt;
index 2cc68b9..8e45a5a 100644 (file)
@@ -47,7 +47,7 @@ eval("page" + id + " = window.open(URL, '" + id + "', 'toolbars=0, scrollbars=0,
     <td valign="top" width="31"><a href="http://bp6.gamesquad.net/"><img align="bottom" border="0" height="74" src="doc3_files/logo.gif" width="252"></a></td>\r
     <td align="left" bgcolor="#000000">
 <img height="15" src="doc3_files/spacer.gif" width="15"><!-- START GAMESQUAD.NET IFRAME RICH MEDIA CODE --> <!-- Â© 2000 GameSquad.net All Rights Reserved. --><iframe border="0" frameborder="no" height="60" marginheight="0" marginwidth="0" scrolling="no" src="doc3_files/adcycle.htm" width="468">
-<a href="http://ads.gamesquad.net/addclick.exe/adclick.cgi?REGION=game%7Ctech%7Cent&amp;id=1" target="_top"><img src="http://ads.gamesquad.net/addclick.exe/adcycle.cgi?group=52&amp;media=1&amp;id=1" width="468" height="60" border="0" alt="GSN ROS Ad"></a>
+<a href="http://ads.gamesquad.net/addclick.exe/adclick.cgi?REGION=game|tech|ent&amp;id=1" target="_top"><img src="http://ads.gamesquad.net/addclick.exe/adcycle.cgi?group=52&amp;media=1&amp;id=1" width="468" height="60" border="0" alt="GSN ROS Ad"></a>
 </iframe><!-- END GAMESQUAD.NET IFRAME RICH MEDIA CODE --><br><img height="15" src="doc3_files/spacer.gif" width="400"> </td>
 </tr>\r
   <tr>\r
diff --git a/result/HTML/names.html b/result/HTML/names.html
new file mode 100644 (file)
index 0000000..dd7dcc2
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html>
+<body>
+  <o:p></o:p>
+</body>
+</html>
diff --git a/result/HTML/names.html.err b/result/HTML/names.html.err
new file mode 100644 (file)
index 0000000..4d91a5d
--- /dev/null
@@ -0,0 +1,3 @@
+./test/HTML/names.html:3: HTML parser error : Tag o:p invalid
+  <o:p></o:p>
+      ^
diff --git a/result/HTML/names.html.sax b/result/HTML/names.html.sax
new file mode 100644 (file)
index 0000000..12a107f
--- /dev/null
@@ -0,0 +1,20 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.startElement(html)
+SAX.characters(
+, 1)
+SAX.startElement(body)
+SAX.characters(
+  , 3)
+SAX.startElement(o:p)
+SAX.error: Tag o:p invalid
+SAX.endElement(o:p)
+SAX.characters(
+, 1)
+SAX.endElement(body)
+SAX.characters(
+, 1)
+SAX.endElement(html)
+SAX.characters(
+, 1)
+SAX.endDocument()
index 66a498a..b497aa6 100644 (file)
@@ -43,7 +43,7 @@
 Ø¯Ø±Ø¨Ø§Ø±Ù‡ Ù…Ù† </a></span> <span class="Item">
 <a href="RSS2.asp">
 
-<img src="showimage.aspx?path=Files_Upload%5C192.png&amp;width=%&gt;" border="0">
+<img src="showimage.aspx?path=Files_Upload\192.png&amp;width=%&gt;" border="0">
 RSS </a></span> <span class="Item">
 <a href="">
  </a></span>
@@ -117,8 +117,8 @@ function ChangeSize( trgt,sz ) {
                        
                        <div class="Image">
                                
-                               <a href="showimage.aspx?path=Files_Upload%5C302.JPG&amp;Width=" rel="lightbox" title="شهير Ø¨Ù„اگ">
-                               <img src="showimage.aspx?path=Files_Upload%5C302.JPG&amp;Width=220" align="left" border="1">
+                               <a href="showimage.aspx?path=Files_Upload\302.JPG&amp;Width=" rel="lightbox" title="شهير Ø¨Ù„اگ">
+                               <img src="showimage.aspx?path=Files_Upload\302.JPG&amp;Width=220" align="left" border="1">
                                </a>
 </div>
                        <strong><font size="4"><font color="#0000ff">عکس</font> <font color="#0000ff">محصول Ù‡Ù†Ø± ÛŒÚ©ÛŒ Ø§Ø² Ù‡Ù…کاران Ø§Ø³Øª. Ø±ÙˆÛŒ Ø¢Ù† Ú©Ù„یک Ú©Ù†Ø¯.</font></font></strong><s1>  </s1>
index a6ef047..b51aa95 100644 (file)
@@ -11,5 +11,5 @@
 Ø² Ù‡Ù…کاران Ø§Ø³Øª. Ø±ÙˆÛŒ Ø¢Ù† Ú©Ù„یک Ú©Ù†Ø¯.</FONT></FONT></STRONG><S1
                                                                                ^
 ./test/HTML/utf8bug.html:177: HTML parser error : htmlParseEntityRef: expecting ';'
-§Û\8cÙ\86 Ã™Â¾Ã˜Â§Ã˜Â³Ã˜Â® Ã˜Â±Ã˜Â§ Ã˜Â¨Ã˜Â±Ã˜Â§Ã›\8c Ã™\86Ù\88Û\8cسÙ\86دÙ\87 Ã™\85Ù\82اÙ\84Ù\87 Ã˜Â±Ã˜Â¬Ã˜Â§Ã™\86Û\8cÙ\88ز copy&paste
+ین Ù¾Ø§Ø³Ø® Ø±Ø§ Ø¨Ø±Ø§ÛŒ Ù†ÙˆÛŒØ³Ù†Ø¯Ù‡ Ù…قاله Ø±Ø¬Ø§Ù†ÛŒÙˆØ² copy&paste 
                                                                                ^
index 3da303f..916630d 100644 (file)
     <td bgcolor="#99FF99"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="http://redirect.wired.com/redir/51/http://stocks.wired.com/">Today's Summary</a></font></td>
   </tr>
   <tr> 
-    <td bgcolor="#CCFFCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="http://r.wired.com/r/hb_fin_r_wn_top/http://stocks.wired.com/stocks_indexes_detail.asp?Symbol=%24WIRED">Wired Index</a> | <a href="http://redirect.wired.com/redir/52/http://stocks.wired.com/stocks_indexes.asp%20">All Indexes</a></font></td>
+    <td bgcolor="#CCFFCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="http://r.wired.com/r/hb_fin_r_wn_top/http://stocks.wired.com/stocks_indexes_detail.asp?Symbol=$WIRED">Wired Index</a> | <a href="http://redirect.wired.com/redir/52/http://stocks.wired.com/stocks_indexes.asp%20">All Indexes</a></font></td>
   </tr>
   <tr> 
     <td bgcolor="#99FF99"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="http://redirect.wired.com/redir/53/http://stocks.wired.com/stocks_portfolios.asp">Portfolios</a></font></td>
diff --git a/result/HTML/xml-declaration-1.html b/result/HTML/xml-declaration-1.html
new file mode 100644 (file)
index 0000000..8c9ebe3
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<?xml encoding="UTF-8"><html><body>
+<p>&ouml;&auml;&uuml;&szlig;</p>
+</body></html>
diff --git a/result/HTML/xml-declaration-1.html.sax b/result/HTML/xml-declaration-1.html.sax
new file mode 100644 (file)
index 0000000..83fe8eb
--- /dev/null
@@ -0,0 +1,13 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.processingInstruction(xml, encoding="UTF-8")
+SAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(&ouml;&auml;&uuml;&szlig;, 8)
+SAX.endElement(p)
+SAX.characters(
+, 1)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/result/URI/file.uri b/result/URI/file.uri
new file mode 100644 (file)
index 0000000..8d8b7a7
--- /dev/null
@@ -0,0 +1 @@
+file:///foo.txt
diff --git a/result/URI/port.uri b/result/URI/port.uri
new file mode 100644 (file)
index 0000000..4b22322
--- /dev/null
@@ -0,0 +1,2 @@
+nbd://:10888
+https://example.com:12345/
index f22b4db..90c7905 100644 (file)
@@ -16,3 +16,6 @@ http://foo.com/root.cgi?OK#OK2
 http://elsewhere.com/#deep
 http://elsewhere.com/?deep
 http://elsewhere.com/?deep#deep2
+http://elsewhere.com/bar
+http://elsewhere.com:8080/bar
+http://:8080
index 899d759..91eef9c 100644 (file)
@@ -4,3 +4,6 @@
 ./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Misplaced b
 
 ^
+./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
+
+^
index aeafd6b..3b51d1a 100644 (file)
@@ -1,6 +1,6 @@
 ./test/VC/ElementValid6:7: element doc: validity error : Element doc content does not follow the DTD, expecting (a , b? , c+)?, got (a b)
 <doc><a/><b>lacks c</b></doc>
                              ^
-./test/VC/ElementValid6:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more child
+./test/VC/ElementValid6:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
 
 ^
index f001fd2..ecafd1d 100644 (file)
@@ -1,6 +1,6 @@
 ./test/VC/ElementValid7:7: element doc: validity error : Element doc content does not follow the DTD, expecting ((a | b)* , c+ , a , b? , c , a?), got (a b a c c a)
 <doc><a/><b/><a/><c/><c/><a/></doc>
                                    ^
-./test/VC/ElementValid7:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more child
+./test/VC/ElementValid7:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
 
 ^
index f1b0dad..7962630 100644 (file)
@@ -1,3 +1,3 @@
-./test/VC/ElementValid8:7: validity error : Content model of doc is not determinist: ((a , b) | (a , c))
+./test/VC/ElementValid8:7: validity error : Content model of doc is not deterministic: ((a , b) | (a , c))
 <doc><a/><c> doc is non-deterministic </c></doc>
                                                 ^
index f1b0dad..7962630 100644 (file)
@@ -1,3 +1,3 @@
-./test/VC/ElementValid8:7: validity error : Content model of doc is not determinist: ((a , b) | (a , c))
+./test/VC/ElementValid8:7: validity error : Content model of doc is not deterministic: ((a , b) | (a , c))
 <doc><a/><c> doc is non-deterministic </c></doc>
                                                 ^
index 966689a..705e24c 100644 (file)
@@ -1,6 +1,3 @@
 ./test/VC/PENesting:1: parser error : StartTag: invalid element name
 <!ENTITY % pe1 "EMPTY> <!ELEMENT e2 EMPTY>"> 
  ^
-./test/VC/PENesting:1: parser error : Extra content at the end of the document
-<!ENTITY % pe1 "EMPTY> <!ELEMENT e2 EMPTY>"> 
- ^
index c53ead6..f138827 100644 (file)
@@ -1,6 +1,3 @@
 ./test/VC/PENesting2:1: parser error : StartTag: invalid element name
 <!ENTITY % p1 "(A|B">
  ^
-./test/VC/PENesting2:1: parser error : Extra content at the end of the document
-<!ENTITY % p1 "(A|B">
- ^
diff --git a/result/XInclude/fallback.xml.err b/result/XInclude/fallback.xml.err
new file mode 100644 (file)
index 0000000..68b5cc0
--- /dev/null
@@ -0,0 +1 @@
+I/O warning : failed to load external entity "test/XInclude/docs/something.xml"
diff --git a/result/XInclude/fallback2.xml.err b/result/XInclude/fallback2.xml.err
new file mode 100644 (file)
index 0000000..5a35a2b
--- /dev/null
@@ -0,0 +1,2 @@
+I/O warning : failed to load external entity "test/XInclude/docs/b.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/c.xml"
diff --git a/result/XInclude/fallback4.xml.err b/result/XInclude/fallback4.xml.err
new file mode 100644 (file)
index 0000000..2861bba
--- /dev/null
@@ -0,0 +1 @@
+I/O warning : failed to load external entity "test/XInclude/docs/c.xml"
diff --git a/result/XInclude/fallback5.xml.err b/result/XInclude/fallback5.xml.err
new file mode 100644 (file)
index 0000000..84dd18e
--- /dev/null
@@ -0,0 +1,16 @@
+I/O warning : failed to load external entity "test/XInclude/docs/a01.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a02.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a03.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a04.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a05.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a06.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a07.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a08.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a09.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a10.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a11.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a12.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a13.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a14.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a15.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/a16.xml"
diff --git a/result/XInclude/fallback6.xml.err b/result/XInclude/fallback6.xml.err
new file mode 100644 (file)
index 0000000..5a35a2b
--- /dev/null
@@ -0,0 +1,2 @@
+I/O warning : failed to load external entity "test/XInclude/docs/b.xml"
+I/O warning : failed to load external entity "test/XInclude/docs/c.xml"
diff --git a/result/XInclude/fallback7.xml b/result/XInclude/fallback7.xml
new file mode 100644 (file)
index 0000000..f5d3718
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+    <a>text</a>
+    <b>
+                <a>text</a>
+            </b>
+    
+            <b>
+                <a>text</a>
+            </b>
+        
+    <b>
+                <a>text</a>
+            </b>
+</x>
diff --git a/result/XInclude/fallback7.xml.err b/result/XInclude/fallback7.xml.err
new file mode 100644 (file)
index 0000000..828a73a
--- /dev/null
@@ -0,0 +1 @@
+I/O warning : failed to load external entity "test/XInclude/without-reader/404.xml"
diff --git a/result/XInclude/invalid_char.xml.err b/result/XInclude/invalid_char.xml.err
new file mode 100644 (file)
index 0000000..c28c109
--- /dev/null
@@ -0,0 +1,2 @@
+./test/XInclude/docs/invalid_char.xml:2: element include: XInclude error : test/XInclude/ents/invalid_char.txt contains invalid char
+./test/XInclude/docs/invalid_char.xml:2: element include: XInclude error : could not load test/XInclude/ents/invalid_char.txt, and no fallback was found
diff --git a/result/XInclude/invalid_char.xml.rdr b/result/XInclude/invalid_char.xml.rdr
new file mode 100644 (file)
index 0000000..1fb5774
--- /dev/null
@@ -0,0 +1,7 @@
+0 1 x 0 0
+1 14 #text 0 1 
+   
+1 1 xinclude:include 1 0
+1 14 #text 0 1 
+
+0 15 x 0 0
diff --git a/result/XInclude/issue424-1.xml b/result/XInclude/issue424-1.xml
new file mode 100644 (file)
index 0000000..ff87b0e
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+   <p>Something</p>
+   <d><p>Something</p></d>
+   <d><p>Something</p></d>
+</x>
diff --git a/result/XInclude/issue424-2.xml b/result/XInclude/issue424-2.xml
new file mode 100644 (file)
index 0000000..ff87b0e
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+   <p>Something</p>
+   <d><p>Something</p></d>
+   <d><p>Something</p></d>
+</x>
diff --git a/result/XInclude/loop.xml.err b/result/XInclude/loop.xml.err
new file mode 100644 (file)
index 0000000..ec8534f
--- /dev/null
@@ -0,0 +1 @@
+./test/XInclude/without-reader/loop.xml:2: element include: XInclude error : inclusion loop detected
diff --git a/result/XInclude/max-recurse.xml.err b/result/XInclude/max-recurse.xml.err
new file mode 100644 (file)
index 0000000..38ff72a
--- /dev/null
@@ -0,0 +1 @@
+./test/XInclude/without-reader/max-recurse.xml:42: element include: XInclude error : maximum recursion depth exceeded
diff --git a/result/XInclude/nodes3.xml b/result/XInclude/nodes3.xml
deleted file mode 100644 (file)
index 9ab2044..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<x xmlns:xinclude="http://www.w3.org/2003/XInclude">
-   <!-- Simple test of including a set of nodes from an XML document -->
-   <xinclude:include href="../ents/something.xml#xpointer(//p)"/>
-</x>
diff --git a/result/XInclude/nodes3.xml.err b/result/XInclude/nodes3.xml.err
new file mode 100644 (file)
index 0000000..fb11525
--- /dev/null
@@ -0,0 +1 @@
+./test/XInclude/docs/nodes3.xml:3: element include: XInclude error : Invalid fragment identifier in URI test/XInclude/ents/something.xml#xpointer(//p) use the xpointer attribute
diff --git a/result/XInclude/ns1.xml.err b/result/XInclude/ns1.xml.err
new file mode 100644 (file)
index 0000000..b05fffb
--- /dev/null
@@ -0,0 +1 @@
+I/O warning : failed to load external entity "test/XInclude/without-reader/b.xml"
diff --git a/result/XInclude/ns1.xml.rdr b/result/XInclude/ns1.xml.rdr
deleted file mode 100644 (file)
index 9a3a5e7..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-0 1 doc 0 0
-1 14 #text 0 1 
-    
-1 1 xi:include 1 0
-1 14 #text 0 1 
-    
-1 1 elem 0 0
-2 14 #text 0 1 
-        
-2 1 ns:elem 1 0
-2 14 #text 0 1 
-    
-1 15 elem 0 0
-1 14 #text 0 1 
-    
-1 14 #text 0 1 
-            
-1 1 ns:elem 1 0
-1 14 #text 0 1 
-        
-1 14 #text 0 1 
-
-0 15 doc 0 0
index e09eb4a..4ff9c58 100644 (file)
@@ -20,6 +20,10 @@ Expression: -number('abc')
 Object is a number : NaN
 
 ========================
+Expression: number('-')
+Object is a number : NaN
+
+========================
 Expression: floor(0.1)
 Object is a number : 0
 
diff --git a/result/boundaries1.xml b/result/boundaries1.xml
new file mode 100644 (file)
index 0000000..dc1848f
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE d [
+<!ENTITY a "]>">
+<!ENTITY b "]>">
+<!--> ]> -->]>
+<?pi p1?>
+<!--> c1 -->
+<d a="&gt;" b="&gt;">
+text&a;text
+<![CDATA[cdata]]>
+<?pi p2?>
+<!--> c2 -->
+</d>
+<?pi p3?>
+<!--> c3 -->
diff --git a/result/boundaries1.xml.rde b/result/boundaries1.xml.rde
new file mode 100644 (file)
index 0000000..113b487
--- /dev/null
@@ -0,0 +1,19 @@
+0 10 d 0 0
+0 7 pi 0 1 p1
+0 8 #comment 0 1 > c1 
+0 1 d 0 0
+1 3 #text 0 1 
+text]>text
+
+1 4 #cdata-section 0 1 cdata
+1 14 #text 0 1 
+
+1 7 pi 0 1 p2
+1 14 #text 0 1 
+
+1 8 #comment 0 1 > c2 
+1 14 #text 0 1 
+
+0 15 d 0 0
+0 7 pi 0 1 p3
+0 8 #comment 0 1 > c3 
diff --git a/result/boundaries1.xml.rdr b/result/boundaries1.xml.rdr
new file mode 100644 (file)
index 0000000..784ece0
--- /dev/null
@@ -0,0 +1,21 @@
+0 10 d 0 0
+0 7 pi 0 1 p1
+0 8 #comment 0 1 > c1 
+0 1 d 0 0
+1 3 #text 0 1 
+text
+1 5 a 0 0
+1 3 #text 0 1 text
+
+1 4 #cdata-section 0 1 cdata
+1 14 #text 0 1 
+
+1 7 pi 0 1 p2
+1 14 #text 0 1 
+
+1 8 #comment 0 1 > c2 
+1 14 #text 0 1 
+
+0 15 d 0 0
+0 7 pi 0 1 p3
+0 8 #comment 0 1 > c3 
diff --git a/result/boundaries1.xml.sax b/result/boundaries1.xml.sax
new file mode 100644 (file)
index 0000000..19e3181
--- /dev/null
@@ -0,0 +1,32 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(d, , )
+SAX.entityDecl(a, 1, (null), (null), ]>)
+SAX.getEntity(a)
+SAX.entityDecl(b, 1, (null), (null), ]>)
+SAX.getEntity(b)
+SAX.comment(> ]> )
+SAX.externalSubset(d, , )
+SAX.processingInstruction(pi, p1)
+SAX.comment(> c1 )
+SAX.startElement(d, a='>', b='>')
+SAX.characters(
+text, 5)
+SAX.getEntity(a)
+SAX.characters(]>, 2)
+SAX.reference(a)
+SAX.characters(text
+, 5)
+SAX.pcdata(cdata, 5)
+SAX.characters(
+, 1)
+SAX.processingInstruction(pi, p2)
+SAX.characters(
+, 1)
+SAX.comment(> c2 )
+SAX.characters(
+, 1)
+SAX.endElement(d)
+SAX.processingInstruction(pi, p3)
+SAX.comment(> c3 )
+SAX.endDocument()
diff --git a/result/boundaries1.xml.sax2 b/result/boundaries1.xml.sax2
new file mode 100644 (file)
index 0000000..b3ad5e8
--- /dev/null
@@ -0,0 +1,33 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(d, , )
+SAX.entityDecl(a, 1, (null), (null), ]>)
+SAX.getEntity(a)
+SAX.entityDecl(b, 1, (null), (null), ]>)
+SAX.getEntity(b)
+SAX.comment(> ]> )
+SAX.externalSubset(d, , )
+SAX.processingInstruction(pi, p1)
+SAX.comment(> c1 )
+SAX.startElementNs(d, NULL, NULL, 0, 2, 0, a='>" b...', 1, b='>'>
+...', 1)
+SAX.characters(
+text, 5)
+SAX.getEntity(a)
+SAX.characters(]>, 2)
+SAX.reference(a)
+SAX.characters(text
+, 5)
+SAX.pcdata(cdata, 5)
+SAX.characters(
+, 1)
+SAX.processingInstruction(pi, p2)
+SAX.characters(
+, 1)
+SAX.comment(> c2 )
+SAX.characters(
+, 1)
+SAX.endElementNs(d, NULL, NULL)
+SAX.processingInstruction(pi, p3)
+SAX.comment(> c3 )
+SAX.endDocument()
index 07d2ce4..46da6fd 100644 (file)
@@ -10,7 +10,6 @@ SAX.startElement(EXAMPLE)
 SAX.characters(
   , 3)
 SAX.getEntity(title)
-SAX.error: Entity 'title' not defined
 SAX.reference(title)
 SAX.characters(
   This text is about XML, the, 31)
index d7c8002..6275de4 100644 (file)
@@ -10,7 +10,6 @@ SAX.startElementNs(EXAMPLE, NULL, NULL, 0, 0, 0)
 SAX.characters(
   , 3)
 SAX.getEntity(title)
-SAX.error: Entity 'title' not defined
 SAX.reference(title)
 SAX.characters(
   This text is about XML, the, 31)
index 3228de3..7a298d7 100644 (file)
@@ -7,11 +7,16 @@ SAX.getParameterEntity(sampleEnt)
 SAX.entityDecl(sampleEnt, 1, (null), (null), the hyacinth girl)
 SAX.getEntity(sampleEnt)
 SAX.getParameterEntity(sampleEnt)
-SAX.error: PEReference: %sampleEnt; not found
+SAX.elementDecl(item, 4, ...)
+SAX.elementDecl(para, 3, ...)
+SAX.externalSubset(item, , )
+SAX.startElement(item)
+SAX.startElement(para)
 SAX.characters('they called me , 16)
 SAX.getEntity(sampleEnt)
-SAX.error: Entity 'sampleEnt' not defined
+SAX.characters(the hyacinth girl, 17)
 SAX.reference(sampleEnt)
 SAX.characters(', 1)
+SAX.endElement(para)
+SAX.endElement(item)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
index 3228de3..2a53198 100644 (file)
@@ -7,11 +7,16 @@ SAX.getParameterEntity(sampleEnt)
 SAX.entityDecl(sampleEnt, 1, (null), (null), the hyacinth girl)
 SAX.getEntity(sampleEnt)
 SAX.getParameterEntity(sampleEnt)
-SAX.error: PEReference: %sampleEnt; not found
+SAX.elementDecl(item, 4, ...)
+SAX.elementDecl(para, 3, ...)
+SAX.externalSubset(item, , )
+SAX.startElementNs(item, NULL, NULL, 0, 0, 0)
+SAX.startElementNs(para, NULL, NULL, 0, 0, 0)
 SAX.characters('they called me , 16)
 SAX.getEntity(sampleEnt)
-SAX.error: Entity 'sampleEnt' not defined
+SAX.characters(the hyacinth girl, 17)
 SAX.reference(sampleEnt)
 SAX.characters(', 1)
+SAX.endElementNs(para, NULL, NULL)
+SAX.endElementNs(item, NULL, NULL)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
index be77781..7dc0bb0 100644 (file)
@@ -5,16 +5,3 @@
 Entity: line 1: 
 A<lbbbbbbbbbbbbbbbbbbb_
 ^
-./test/errors/754946.xml:4: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-  <![
-  ^
-./test/errors/754946.xml:4: parser error : DOCTYPE improperly terminated
-  <![
-  ^
-./test/errors/754946.xml:4: parser error : StartTag: invalid element name
-  <![
-   ^
-./test/errors/754946.xml:4: parser error : Extra content at the end of the document
-  <![
-   ^
index be77781..7dc0bb0 100644 (file)
@@ -5,16 +5,3 @@
 Entity: line 1: 
 A<lbbbbbbbbbbbbbbbbbbb_
 ^
-./test/errors/754946.xml:4: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-  <![
-  ^
-./test/errors/754946.xml:4: parser error : DOCTYPE improperly terminated
-  <![
-  ^
-./test/errors/754946.xml:4: parser error : StartTag: invalid element name
-  <![
-   ^
-./test/errors/754946.xml:4: parser error : Extra content at the end of the document
-  <![
-   ^
index 49395b6..5d6a8b2 100644 (file)
@@ -1,4 +1,8 @@
-./test/errors/754946.xml:1: parser error : Extra content at the end of the document
-<!DOCTYPE A [
-            ^
+./test/errors/754946.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
+
+  %SYSTEM;
+          ^
+Entity: line 1: 
+A<lbbbbbbbbbbbbbbbbbbb_
+^
 ./test/errors/754946.xml : failed to parse
index f45cb5a..372248b 100644 (file)
@@ -1,7 +1,4 @@
 ./test/errors/754947.xml:1: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xEE 0x5D 0x5D 0x3E
-<d><![CDATA[0000000000000î]]>
+<d><![CDATA[0000000000000
                          ^
-./test/errors/754947.xml:1: parser error : Premature end of data in tag d line 1
-<d><![CDATA[0000000000000î]]>
-                             ^
index f45cb5a..372248b 100644 (file)
@@ -1,7 +1,4 @@
 ./test/errors/754947.xml:1: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xEE 0x5D 0x5D 0x3E
-<d><![CDATA[0000000000000î]]>
+<d><![CDATA[0000000000000
                          ^
-./test/errors/754947.xml:1: parser error : Premature end of data in tag d line 1
-<d><![CDATA[0000000000000î]]>
-                             ^
index 4d2f52e..d248323 100644 (file)
@@ -1,5 +1,5 @@
 ./test/errors/754947.xml:1: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xEE 0x5D 0x5D 0x3E
-<d><![CDATA[0000000000000î]]>
+<d><![CDATA[0000000000000
                          ^
 ./test/errors/754947.xml : failed to parse
index f6036a3..c3f4df4 100644 (file)
@@ -7,6 +7,3 @@ and provide access to their content and structure.</termdef> <termdef
 ./test/errors/759398.xml:314: parser error : Opening and ending tag mismatch: spec line 50 and p
 data and the information it must provide to the application.</p>
                                                                 ^
-./test/errors/759398.xml:316: parser error : Extra content at the end of the document
-<div2 id='sec-origin-goals'>
-^
index f6036a3..c3f4df4 100644 (file)
@@ -7,6 +7,3 @@ and provide access to their content and structure.</termdef> <termdef
 ./test/errors/759398.xml:314: parser error : Opening and ending tag mismatch: spec line 50 and p
 data and the information it must provide to the application.</p>
                                                                 ^
-./test/errors/759398.xml:316: parser error : Extra content at the end of the document
-<div2 id='sec-origin-goals'>
-^
index 6809c06..8e37d69 100644 (file)
@@ -1,5 +1,4 @@
-./test/errors/759398.xml:210: parser error : internal error: detected an error in element content
-
+./test/errors/759398.xml:210: parser error : StartTag: invalid element name
 need to worry about parsers whi<! don't expand PErefs finding
-                               ^
+                                ^
 ./test/errors/759398.xml : failed to parse
index 4c45475..01c8157 100644 (file)
@@ -18,18 +18,8 @@ Entity: line 1:
                    ^
 ./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
 
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
+%xx;\ 3
     ^
 Entity: line 2: 
 <![INCLUDE[
-^
-./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
-./test/errors/759573-2.xml:6: parser error : DOCTYPE improperly terminated
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
-./test/errors/759573-2.xml:6: parser error : Start tag expected, '<' not found
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
+  ^
index 4c45475..01c8157 100644 (file)
@@ -18,18 +18,8 @@ Entity: line 1:
                    ^
 ./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
 
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
+%xx;\ 3
     ^
 Entity: line 2: 
 <![INCLUDE[
-^
-./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
-./test/errors/759573-2.xml:6: parser error : DOCTYPE improperly terminated
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
-./test/errors/759573-2.xml:6: parser error : Start tag expected, '<' not found
-%xx;\ 3ÿggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
+  ^
index baac164..39f77a6 100644 (file)
@@ -1,4 +1,26 @@
-./test/errors/759573-2.xml:2: parser error : Extra content at the end of the document
-<!DOCTYPE test [
-               ^
+Entity: line 1: parser error : Space required after '<!ENTITY'
+%zz;
+    ^
+Entity: line 1: 
+<!ENTITY<?xDOCTYPEm~?>
+        ^
+Entity: line 1: parser error : xmlParseEntityDecl: no name
+%zz;
+    ^
+Entity: line 1: 
+<!ENTITY<?xDOCTYPEm~?>
+        ^
+Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
+%zz;
+    ^
+Entity: line 1: 
+<!ENTITY<?xDOCTYPEm~?>
+                   ^
+./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
+
+%xx;\ 3
+    ^
+Entity: line 2: 
+<![INCLUDE[
+  ^
 ./test/errors/759573-2.xml : failed to parse
index 5524750..74322b6 100644 (file)
@@ -19,14 +19,4 @@ T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
                                                                                ^
 Entity: line 1: 
 %<![INCLUDE[000%ஸ000%z;
- ^
-./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
-./test/errors/759573.xml:1: parser error : DOCTYPE improperly terminated
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
-./test/errors/759573.xml:1: parser error : Start tag expected, '<' not found
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
+   ^
index 5524750..74322b6 100644 (file)
@@ -19,14 +19,4 @@ T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
                                                                                ^
 Entity: line 1: 
 %<![INCLUDE[000%ஸ000%z;
- ^
-./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
-./test/errors/759573.xml:1: parser error : DOCTYPE improperly terminated
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
-./test/errors/759573.xml:1: parser error : Start tag expected, '<' not found
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
+   ^
index 1b6addb..37df762 100644 (file)
@@ -1,4 +1,23 @@
-./test/errors/759573.xml:1: parser error : Extra content at the end of the document
-<?h?><!DOCTYPEt[<!ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;00
-               ^
+./test/errors/759573.xml:1: parser error : Space required after '<!ENTITY'
+ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITY
+                                                                               ^
+./test/errors/759573.xml:1: parser error : Space required after the entity name
+LEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz
+                                                                               ^
+./test/errors/759573.xml:1: parser error : Entity value required
+LEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz
+                                                                               ^
+./test/errors/759573.xml:1: parser error : PEReference: no name
+T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
+                                                                               ^
+Entity: line 1: 
+%<![INCLUDE[000%ஸ000%z;
+ ^
+./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
+
+T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
+                                                                               ^
+Entity: line 1: 
+%<![INCLUDE[000%ஸ000%z;
+   ^
 ./test/errors/759573.xml : failed to parse
index 288026e..dd0e68a 100644 (file)
@@ -1,6 +1,6 @@
-Entity: line 2: parser error : Detected an entity reference loop
-        %z; %z; %z; %z; %z;
-           ^
+./test/errors/759579.xml:9: parser error : Detected an entity reference loop
+    %z;
+       ^
 Entity: line 2: 
         %z; %z; %z; %z; %z;
            ^
index 288026e..dd0e68a 100644 (file)
@@ -1,6 +1,6 @@
-Entity: line 2: parser error : Detected an entity reference loop
-        %z; %z; %z; %z; %z;
-           ^
+./test/errors/759579.xml:9: parser error : Detected an entity reference loop
+    %z;
+       ^
 Entity: line 2: 
         %z; %z; %z; %z; %z;
            ^
index 09408f5..e9a929c 100644 (file)
@@ -1,6 +1,6 @@
-Entity: line 2: parser error : Detected an entity reference loop
-        %z; %z; %z; %z; %z;
-           ^
+./test/errors/759579.xml:9: parser error : Detected an entity reference loop
+    %z;
+       ^
 Entity: line 2: 
         %z; %z; %z; %z; %z;
            ^
index a9966d8..89906a1 100644 (file)
@@ -7,6 +7,3 @@
 ./test/errors/attr4.xml:1: parser error : Couldn't find end of Start Tag ROOT line 1
 <ROOT attr="XY\16"/>
               ^
-./test/errors/attr4.xml:1: parser error : Extra content at the end of the document
-<ROOT attr="XY\16"/>
-              ^
index a9966d8..89906a1 100644 (file)
@@ -7,6 +7,3 @@
 ./test/errors/attr4.xml:1: parser error : Couldn't find end of Start Tag ROOT line 1
 <ROOT attr="XY\16"/>
               ^
-./test/errors/attr4.xml:1: parser error : Extra content at the end of the document
-<ROOT attr="XY\16"/>
-              ^
diff --git a/result/errors/attr5.xml.ent b/result/errors/attr5.xml.ent
new file mode 100644 (file)
index 0000000..b1f524f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/attr5.xml:2: parser error : Attribute b redefined
+    <a b="" b=""/>
+                ^
diff --git a/result/errors/attr5.xml.err b/result/errors/attr5.xml.err
new file mode 100644 (file)
index 0000000..b1f524f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/attr5.xml:2: parser error : Attribute b redefined
+    <a b="" b=""/>
+                ^
diff --git a/result/errors/attr5.xml.str b/result/errors/attr5.xml.str
new file mode 100644 (file)
index 0000000..9a73951
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/attr5.xml:2: parser error : Attribute b redefined
+    <a b="" b=""/>
+                ^
+./test/errors/attr5.xml : failed to parse
diff --git a/result/errors/attr6.xml.ent b/result/errors/attr6.xml.ent
new file mode 100644 (file)
index 0000000..96c7a24
--- /dev/null
@@ -0,0 +1,60 @@
+./test/errors/attr6.xml:3: parser error : Attribute c:db redefined
+"" d:em="" d:bw="" b:bb="" b:ey="" c:cd="" a:ce="" b:ah="" c:am="" cq="" c:db=""
+                                                                               ^
+./test/errors/attr6.xml:4: parser error : Attribute d:do redefined
+ c:ba="" b:bj="" a:bn="" c:fd="" c:fe="" a:dh="" b:ef="" d:do="" b:da="" a:cv=""
+                                                                               ^
+./test/errors/attr6.xml:7: parser error : Attribute bu redefined
+r="" b:fe="" dc="" d:cx="" d:ce="" b:fg="" d:dw="" d:cy="" ap="" a:ek="" c:ee=""
+                                                                               ^
+./test/errors/attr6.xml:8: parser error : Attribute c:ae redefined
+a="" b:dk="" a:cl="" d:bd="" d:bh="" bv="" c:fc="" d:bx="" d:bf="" d:cq="" dz=""
+                                                                               ^
+./test/errors/attr6.xml:15: parser error : Attribute c:cy redefined
+"" a:ey="" a:be="" c:df="" b:ej="" a:cv="" c:ds="" d:bx="" c:cd="" eo="" a:fi=""
+                                                                               ^
+./test/errors/attr6.xml:17: parser error : Attribute bt redefined
+"" b:aa="" a:aj="" c:cp="" a:ck="" b:fi="" a:fj="" aw="" d:df="" d:ct="" d:fg=""
+                                                                               ^
+./test/errors/attr6.xml:19: parser error : Attribute aa redefined
+ b:fi="" b:ey="" a:cv="" b:ag="" b:du="" a:az="" a:fg="" b:cr="" d:bd="" d:eu=""
+                                                                               ^
+./test/errors/attr6.xml:19: parser error : Attribute d:cy redefined
+ b:fi="" b:ey="" a:cv="" b:ag="" b:du="" a:az="" a:fg="" b:cr="" d:bd="" d:eu=""
+                                                                               ^
+./test/errors/attr6.xml:27: parser error : Attribute dw redefined
+"" d:ax="" bw="" d:as="" b:eh="" a:cw="" b:cy="" d:ed="" b:do="" b:bx="" a:bo=""
+                                                                               ^
+./test/errors/attr6.xml:27: parser error : Attribute d:du redefined
+"" d:ax="" bw="" d:as="" b:eh="" a:cw="" b:cy="" d:ed="" b:do="" b:bx="" a:bo=""
+                                                                               ^
+./test/errors/attr6.xml:29: parser error : Attribute b:cb redefined
+ a:cu="" c:eu="" fe="" d:ac="" d:bl="" c:dr="" co="" c:bn="" cf="" b:cw="" ew=""
+                                                                               ^
+./test/errors/attr6.xml:36: parser error : Attribute ay redefined
+ b:cv="" d:bi="" b:fl="" fe="" b:am="" c:fm="" c:di="" bs="" dc="" b:bm="" es=""
+                                                                               ^
+./test/errors/attr6.xml:41: parser error : Attribute au redefined
+t="" d:ew="" d:ek="" a:bu="" b:dc="" d:ab="" cj="" d:bj="" a:bg="" a:da="" ac=""
+                                                                               ^
+./test/errors/attr6.xml:43: parser error : Attribute em redefined
+p="" d:cv="" bh="" c:dy="" c:eq="" b:am="" b:ed="" b:co="" a:ew="" c:av="" ad=""
+                                                                               ^
+./test/errors/attr6.xml:45: parser error : Attribute cr redefined
+:ax="" bc="" d:br="" b:aq="" a:dn="" d:fa="" d:cb="" d:bo="" ds="" ad="" c:cg=""
+                                                                               ^
+./test/errors/attr6.xml:45: parser error : Attribute a:az redefined
+:ax="" bc="" d:br="" b:aq="" a:dn="" d:fa="" d:cb="" d:bo="" ds="" ad="" c:cg=""
+                                                                               ^
+./test/errors/attr6.xml:46: parser error : Attribute a:cy redefined
+x="" b:cr="" d:ca="" c:em="" d:es="" a:du="" cc="" c:ci="" b:dt="" d:fm="" bb=""
+                                                                               ^
+./test/errors/attr6.xml:47: parser error : Attribute d:cs redefined
+"" a:ea="" c:en="" c:cv="" c:eq="" c:fk="" ax="" a:az="" a:fd="" d:cw="" d:cs=""
+                                                                               ^
+./test/errors/attr6.xml:49: parser error : Attribute a:dv redefined
+y="" dg="" a:dp="" d:ai="" a:ea="" b:eq="" b:ei="" d:ar="" cp="" a:fe="" a:cv=""
+                                                                               ^
+./test/errors/attr6.xml:50: parser error : Attribute b:do redefined
+"" a:el="" b:fe="" cy="" d:cq="" c:eo="" a:cg="" a:dh="" b:eu="" a:cp="" a:fk=""
+                                                                               ^
diff --git a/result/errors/attr6.xml.err b/result/errors/attr6.xml.err
new file mode 100644 (file)
index 0000000..96c7a24
--- /dev/null
@@ -0,0 +1,60 @@
+./test/errors/attr6.xml:3: parser error : Attribute c:db redefined
+"" d:em="" d:bw="" b:bb="" b:ey="" c:cd="" a:ce="" b:ah="" c:am="" cq="" c:db=""
+                                                                               ^
+./test/errors/attr6.xml:4: parser error : Attribute d:do redefined
+ c:ba="" b:bj="" a:bn="" c:fd="" c:fe="" a:dh="" b:ef="" d:do="" b:da="" a:cv=""
+                                                                               ^
+./test/errors/attr6.xml:7: parser error : Attribute bu redefined
+r="" b:fe="" dc="" d:cx="" d:ce="" b:fg="" d:dw="" d:cy="" ap="" a:ek="" c:ee=""
+                                                                               ^
+./test/errors/attr6.xml:8: parser error : Attribute c:ae redefined
+a="" b:dk="" a:cl="" d:bd="" d:bh="" bv="" c:fc="" d:bx="" d:bf="" d:cq="" dz=""
+                                                                               ^
+./test/errors/attr6.xml:15: parser error : Attribute c:cy redefined
+"" a:ey="" a:be="" c:df="" b:ej="" a:cv="" c:ds="" d:bx="" c:cd="" eo="" a:fi=""
+                                                                               ^
+./test/errors/attr6.xml:17: parser error : Attribute bt redefined
+"" b:aa="" a:aj="" c:cp="" a:ck="" b:fi="" a:fj="" aw="" d:df="" d:ct="" d:fg=""
+                                                                               ^
+./test/errors/attr6.xml:19: parser error : Attribute aa redefined
+ b:fi="" b:ey="" a:cv="" b:ag="" b:du="" a:az="" a:fg="" b:cr="" d:bd="" d:eu=""
+                                                                               ^
+./test/errors/attr6.xml:19: parser error : Attribute d:cy redefined
+ b:fi="" b:ey="" a:cv="" b:ag="" b:du="" a:az="" a:fg="" b:cr="" d:bd="" d:eu=""
+                                                                               ^
+./test/errors/attr6.xml:27: parser error : Attribute dw redefined
+"" d:ax="" bw="" d:as="" b:eh="" a:cw="" b:cy="" d:ed="" b:do="" b:bx="" a:bo=""
+                                                                               ^
+./test/errors/attr6.xml:27: parser error : Attribute d:du redefined
+"" d:ax="" bw="" d:as="" b:eh="" a:cw="" b:cy="" d:ed="" b:do="" b:bx="" a:bo=""
+                                                                               ^
+./test/errors/attr6.xml:29: parser error : Attribute b:cb redefined
+ a:cu="" c:eu="" fe="" d:ac="" d:bl="" c:dr="" co="" c:bn="" cf="" b:cw="" ew=""
+                                                                               ^
+./test/errors/attr6.xml:36: parser error : Attribute ay redefined
+ b:cv="" d:bi="" b:fl="" fe="" b:am="" c:fm="" c:di="" bs="" dc="" b:bm="" es=""
+                                                                               ^
+./test/errors/attr6.xml:41: parser error : Attribute au redefined
+t="" d:ew="" d:ek="" a:bu="" b:dc="" d:ab="" cj="" d:bj="" a:bg="" a:da="" ac=""
+                                                                               ^
+./test/errors/attr6.xml:43: parser error : Attribute em redefined
+p="" d:cv="" bh="" c:dy="" c:eq="" b:am="" b:ed="" b:co="" a:ew="" c:av="" ad=""
+                                                                               ^
+./test/errors/attr6.xml:45: parser error : Attribute cr redefined
+:ax="" bc="" d:br="" b:aq="" a:dn="" d:fa="" d:cb="" d:bo="" ds="" ad="" c:cg=""
+                                                                               ^
+./test/errors/attr6.xml:45: parser error : Attribute a:az redefined
+:ax="" bc="" d:br="" b:aq="" a:dn="" d:fa="" d:cb="" d:bo="" ds="" ad="" c:cg=""
+                                                                               ^
+./test/errors/attr6.xml:46: parser error : Attribute a:cy redefined
+x="" b:cr="" d:ca="" c:em="" d:es="" a:du="" cc="" c:ci="" b:dt="" d:fm="" bb=""
+                                                                               ^
+./test/errors/attr6.xml:47: parser error : Attribute d:cs redefined
+"" a:ea="" c:en="" c:cv="" c:eq="" c:fk="" ax="" a:az="" a:fd="" d:cw="" d:cs=""
+                                                                               ^
+./test/errors/attr6.xml:49: parser error : Attribute a:dv redefined
+y="" dg="" a:dp="" d:ai="" a:ea="" b:eq="" b:ei="" d:ar="" cp="" a:fe="" a:cv=""
+                                                                               ^
+./test/errors/attr6.xml:50: parser error : Attribute b:do redefined
+"" a:el="" b:fe="" cy="" d:cq="" c:eo="" a:cg="" a:dh="" b:eu="" a:cp="" a:fk=""
+                                                                               ^
diff --git a/result/errors/attr6.xml.str b/result/errors/attr6.xml.str
new file mode 100644 (file)
index 0000000..556e949
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/attr6.xml:3: parser error : Attribute c:db redefined
+"" d:em="" d:bw="" b:bb="" b:ey="" c:cd="" a:ce="" b:ah="" c:am="" cq="" c:db=""
+                                                                               ^
+./test/errors/attr6.xml : failed to parse
index f757963..f7c7b48 100644 (file)
@@ -1,4 +1,4 @@
 ./test/errors/cdata.xml:2: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xE1 0x72 0x5D 0x5D
-<A><![CDATA[Cár]]></A>
+<A><![CDATA[C
              ^
index f757963..f7c7b48 100644 (file)
@@ -1,4 +1,4 @@
 ./test/errors/cdata.xml:2: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xE1 0x72 0x5D 0x5D
-<A><![CDATA[Cár]]></A>
+<A><![CDATA[C
              ^
index cf83d2b..af1321e 100644 (file)
@@ -1,5 +1,5 @@
 ./test/errors/cdata.xml:2: parser error : Input is not proper UTF-8, indicate encoding !
 Bytes: 0xE1 0x72 0x5D 0x5D
-<A><![CDATA[Cár]]></A>
+<A><![CDATA[C
              ^
 ./test/errors/cdata.xml : failed to parse
index 9fcd603..6451157 100644 (file)
@@ -8,9 +8,3 @@
 
 <!ELEMENT aElement (a |b * >
                          ^
-./test/errors/content1.xml:7: parser error : DOCTYPE improperly terminated
-<!ELEMENT aElement (a |b * >
-                         ^
-./test/errors/content1.xml:7: parser error : Start tag expected, '<' not found
-<!ELEMENT aElement (a |b * >
-                         ^
index 9fcd603..6451157 100644 (file)
@@ -8,9 +8,3 @@
 
 <!ELEMENT aElement (a |b * >
                          ^
-./test/errors/content1.xml:7: parser error : DOCTYPE improperly terminated
-<!ELEMENT aElement (a |b * >
-                         ^
-./test/errors/content1.xml:7: parser error : Start tag expected, '<' not found
-<!ELEMENT aElement (a |b * >
-                         ^
index d806a63..47a6b6f 100644 (file)
@@ -8,7 +8,4 @@
 
 <!ELEMENT aElement (a |b * >
                          ^
-./test/errors/content1.xml:7: parser error : DOCTYPE improperly terminated
-<!ELEMENT aElement (a |b * >
-                         ^
 ./test/errors/content1.xml : failed to parse
diff --git a/result/errors/empty.xml.ent b/result/errors/empty.xml.ent
new file mode 100644 (file)
index 0000000..922ca6f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/empty.xml:1: parser error : Document is empty
+
+^
diff --git a/result/errors/empty.xml.err b/result/errors/empty.xml.err
new file mode 100644 (file)
index 0000000..922ca6f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/empty.xml:1: parser error : Document is empty
+
+^
diff --git a/result/errors/empty.xml.str b/result/errors/empty.xml.str
new file mode 100644 (file)
index 0000000..37ef177
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/empty.xml:1: parser error : Document is empty
+
+^
+./test/errors/empty.xml : failed to parse
diff --git a/result/errors/extra-content.xml.ent b/result/errors/extra-content.xml.ent
new file mode 100644 (file)
index 0000000..7fedc44
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/extra-content.xml:1: parser error : Extra content at the end of the document
+<d/>x
+    ^
diff --git a/result/errors/extra-content.xml.err b/result/errors/extra-content.xml.err
new file mode 100644 (file)
index 0000000..7fedc44
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/extra-content.xml:1: parser error : Extra content at the end of the document
+<d/>x
+    ^
diff --git a/result/errors/extra-content.xml.str b/result/errors/extra-content.xml.str
new file mode 100644 (file)
index 0000000..50d8b48
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/extra-content.xml:1: parser error : Extra content at the end of the document
+<d/>x
+    ^
+./test/errors/extra-content.xml : failed to parse
diff --git a/result/errors/invalid-start-tag-1.xml.ent b/result/errors/invalid-start-tag-1.xml.ent
new file mode 100644 (file)
index 0000000..e48002f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/invalid-start-tag-1.xml:1: parser error : Start tag expected, '<' not found
+x
+^
diff --git a/result/errors/invalid-start-tag-1.xml.err b/result/errors/invalid-start-tag-1.xml.err
new file mode 100644 (file)
index 0000000..e48002f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/invalid-start-tag-1.xml:1: parser error : Start tag expected, '<' not found
+x
+^
diff --git a/result/errors/invalid-start-tag-1.xml.str b/result/errors/invalid-start-tag-1.xml.str
new file mode 100644 (file)
index 0000000..bbb49cb
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/invalid-start-tag-1.xml:1: parser error : Start tag expected, '<' not found
+x
+^
+./test/errors/invalid-start-tag-1.xml : failed to parse
diff --git a/result/errors/invalid-start-tag-2.xml.ent b/result/errors/invalid-start-tag-2.xml.ent
new file mode 100644 (file)
index 0000000..a71398d
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/invalid-start-tag-2.xml:1: parser error : StartTag: invalid element name
+<
+ ^
diff --git a/result/errors/invalid-start-tag-2.xml.err b/result/errors/invalid-start-tag-2.xml.err
new file mode 100644 (file)
index 0000000..a71398d
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/invalid-start-tag-2.xml:1: parser error : StartTag: invalid element name
+<
+ ^
diff --git a/result/errors/invalid-start-tag-2.xml.str b/result/errors/invalid-start-tag-2.xml.str
new file mode 100644 (file)
index 0000000..da03e41
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/invalid-start-tag-2.xml:1: parser error : StartTag: invalid element name
+<
+ ^
+./test/errors/invalid-start-tag-2.xml : failed to parse
diff --git a/result/errors/name3.xml.ent b/result/errors/name3.xml.ent
new file mode 100644 (file)
index 0000000..3925f9d
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/name3.xml:1: parser error : StartTag: invalid element name
+<.name/>
+ ^
diff --git a/result/errors/name3.xml.err b/result/errors/name3.xml.err
new file mode 100644 (file)
index 0000000..3925f9d
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/name3.xml:1: parser error : StartTag: invalid element name
+<.name/>
+ ^
diff --git a/result/errors/name3.xml.str b/result/errors/name3.xml.str
new file mode 100644 (file)
index 0000000..460b31a
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/name3.xml:1: parser error : StartTag: invalid element name
+<.name/>
+ ^
+./test/errors/name3.xml : failed to parse
diff --git a/result/errors/quadratic-defattr.xml.ent b/result/errors/quadratic-defattr.xml.ent
new file mode 100644 (file)
index 0000000..eddbe4f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/quadratic-defattr.xml:65: parser error : Maximum entity amplification factor exceeded, see xmlCtxtSetMaxAmplification.
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+  ^
diff --git a/result/errors/quadratic-defattr.xml.err b/result/errors/quadratic-defattr.xml.err
new file mode 100644 (file)
index 0000000..eddbe4f
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/quadratic-defattr.xml:65: parser error : Maximum entity amplification factor exceeded, see xmlCtxtSetMaxAmplification.
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+  ^
diff --git a/result/errors/quadratic-defattr.xml.str b/result/errors/quadratic-defattr.xml.str
new file mode 100644 (file)
index 0000000..a6b4d80
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/quadratic-defattr.xml:65: parser error : Maximum entity amplification factor exceeded, see xmlCtxtSetMaxAmplification.
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+  ^
+./test/errors/quadratic-defattr.xml : failed to parse
diff --git a/result/errors/rec_att_default.xml.ent b/result/errors/rec_att_default.xml.ent
new file mode 100644 (file)
index 0000000..375a0d6
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/rec_att_default.xml:3: parser error : Entity 'b' not defined
+  <!ATTLIST x y CDATA "&a;">
+                          ^
+./test/errors/rec_att_default.xml:6: parser error : Detected an entity reference loop
+<doc attr="&a;"/>
+              ^
diff --git a/result/errors/rec_att_default.xml.err b/result/errors/rec_att_default.xml.err
new file mode 100644 (file)
index 0000000..375a0d6
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/rec_att_default.xml:3: parser error : Entity 'b' not defined
+  <!ATTLIST x y CDATA "&a;">
+                          ^
+./test/errors/rec_att_default.xml:6: parser error : Detected an entity reference loop
+<doc attr="&a;"/>
+              ^
diff --git a/result/errors/rec_att_default.xml.str b/result/errors/rec_att_default.xml.str
new file mode 100644 (file)
index 0000000..11e6556
--- /dev/null
@@ -0,0 +1,7 @@
+./test/errors/rec_att_default.xml:3: parser error : Entity 'b' not defined
+  <!ATTLIST x y CDATA "&a;">
+                          ^
+./test/errors/rec_att_default.xml:6: parser error : Detected an entity reference loop
+<doc attr="&a;"/>
+              ^
+./test/errors/rec_att_default.xml : failed to parse
index d8ccec1..1b5f50f 100644 (file)
@@ -1,123 +1,3 @@
 test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
 <ent>&e; &e; &e; &e;</ent>
         ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-test/errors/rec_ext.ent:1: parser error : Detected an entity reference loop
-<ent>&e; &e; &e; &e;</ent>
-        ^
-./test/errors/rec_ext_ent.xml:4: parser error : Detected an entity reference loop
-<doc>&e; &e; &e; &e;</doc>
-        ^
diff --git a/result/errors/trailing-null-1.xml.ent b/result/errors/trailing-null-1.xml.ent
new file mode 100644 (file)
index 0000000..193a77a
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/trailing-null-1.xml:1: parser error : Extra content at the end of the document
+<d/>
+    ^
diff --git a/result/errors/trailing-null-1.xml.err b/result/errors/trailing-null-1.xml.err
new file mode 100644 (file)
index 0000000..193a77a
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/trailing-null-1.xml:1: parser error : Extra content at the end of the document
+<d/>
+    ^
diff --git a/result/errors/trailing-null-1.xml.str b/result/errors/trailing-null-1.xml.str
new file mode 100644 (file)
index 0000000..09fab37
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/trailing-null-1.xml:1: parser error : Extra content at the end of the document
+<d/>
+    ^
+./test/errors/trailing-null-1.xml : failed to parse
diff --git a/result/errors/trailing-null-2.xml.ent b/result/errors/trailing-null-2.xml.ent
new file mode 100644 (file)
index 0000000..fcc5259
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/trailing-null-2.xml:1: parser error : Char 0x0 out of allowed range
+<d>
+   ^
+./test/errors/trailing-null-2.xml:1: parser error : PCDATA invalid Char value 0
+<d>
+   ^
diff --git a/result/errors/trailing-null-2.xml.err b/result/errors/trailing-null-2.xml.err
new file mode 100644 (file)
index 0000000..fcc5259
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/trailing-null-2.xml:1: parser error : Char 0x0 out of allowed range
+<d>
+   ^
+./test/errors/trailing-null-2.xml:1: parser error : PCDATA invalid Char value 0
+<d>
+   ^
diff --git a/result/errors/trailing-null-2.xml.str b/result/errors/trailing-null-2.xml.str
new file mode 100644 (file)
index 0000000..b8139ea
--- /dev/null
@@ -0,0 +1,7 @@
+./test/errors/trailing-null-2.xml:1: parser error : Char 0x0 out of allowed range
+<d>
+   ^
+./test/errors/trailing-null-2.xml:1: parser error : PCDATA invalid Char value 0
+<d>
+   ^
+./test/errors/trailing-null-2.xml : failed to parse
diff --git a/result/errors/truncated-utf16.xml.ent b/result/errors/truncated-utf16.xml.ent
new file mode 100644 (file)
index 0000000..f5be53c
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
+<d/>
+    ^
diff --git a/result/errors/truncated-utf16.xml.err b/result/errors/truncated-utf16.xml.err
new file mode 100644 (file)
index 0000000..f5be53c
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
+<d/>
+    ^
diff --git a/result/errors/truncated-utf16.xml.str b/result/errors/truncated-utf16.xml.str
new file mode 100644 (file)
index 0000000..e45c578
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
+<d/>
+    ^
+./test/errors/truncated-utf16.xml : failed to parse
diff --git a/result/errors/unclosed-element.xml.ent b/result/errors/unclosed-element.xml.ent
new file mode 100644 (file)
index 0000000..1402055
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/unclosed-element.xml:2: parser error : Premature end of data in tag d line 1
+
+^
diff --git a/result/errors/unclosed-element.xml.err b/result/errors/unclosed-element.xml.err
new file mode 100644 (file)
index 0000000..1402055
--- /dev/null
@@ -0,0 +1,3 @@
+./test/errors/unclosed-element.xml:2: parser error : Premature end of data in tag d line 1
+
+^
diff --git a/result/errors/unclosed-element.xml.str b/result/errors/unclosed-element.xml.str
new file mode 100644 (file)
index 0000000..9d7f2e7
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/unclosed-element.xml:2: parser error : Premature end of data in tag d line 1
+
+^
+./test/errors/unclosed-element.xml : failed to parse
diff --git a/result/errors/utf8-1.xml.ent b/result/errors/utf8-1.xml.ent
new file mode 100644 (file)
index 0000000..9ce2b93
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/utf8-1.xml:1: parser error : StartTag: invalid element name
+..............................................................................<<
+                                                                               ^
+./test/errors/utf8-1.xml:1: parser error : StartTag: invalid element name
+..............................................................................<<
+                                                                               ^
diff --git a/result/errors/utf8-1.xml.err b/result/errors/utf8-1.xml.err
new file mode 100644 (file)
index 0000000..9ce2b93
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/utf8-1.xml:1: parser error : StartTag: invalid element name
+..............................................................................<<
+                                                                               ^
+./test/errors/utf8-1.xml:1: parser error : StartTag: invalid element name
+..............................................................................<<
+                                                                               ^
diff --git a/result/errors/utf8-1.xml.str b/result/errors/utf8-1.xml.str
new file mode 100644 (file)
index 0000000..8c6df1d
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/utf8-1.xml:1: parser error : StartTag: invalid element name
+..............................................................................<<
+                                                                               ^
+./test/errors/utf8-1.xml : failed to parse
diff --git a/result/errors/utf8-2.xml.ent b/result/errors/utf8-2.xml.ent
new file mode 100644 (file)
index 0000000..c0e1722
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/utf8-2.xml:1: parser error : StartTag: invalid element name
+<d>.<<€€€€€€€€€€€€€€€€€€€€€€€€
+     ^
+./test/errors/utf8-2.xml:2: parser error : Couldn't find end of Start Tag â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬ line 1
+
+^
diff --git a/result/errors/utf8-2.xml.err b/result/errors/utf8-2.xml.err
new file mode 100644 (file)
index 0000000..c0e1722
--- /dev/null
@@ -0,0 +1,6 @@
+./test/errors/utf8-2.xml:1: parser error : StartTag: invalid element name
+<d>.<<€€€€€€€€€€€€€€€€€€€€€€€€
+     ^
+./test/errors/utf8-2.xml:2: parser error : Couldn't find end of Start Tag â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬â‚¬ line 1
+
+^
diff --git a/result/errors/utf8-2.xml.str b/result/errors/utf8-2.xml.str
new file mode 100644 (file)
index 0000000..f8db7f7
--- /dev/null
@@ -0,0 +1,4 @@
+./test/errors/utf8-2.xml:1: parser error : StartTag: invalid element name
+<d>.<<€€€€€€€€€€€€€€€€€€€€€€€€
+     ^
+./test/errors/utf8-2.xml : failed to parse
index 3ddc203..f4e0892 100644 (file)
@@ -5,13 +5,3 @@
 Entity: line 1: 
 <:0000
 ^
-./test/errors10/781205.xml:4: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-
-^
-./test/errors10/781205.xml:4: parser error : DOCTYPE improperly terminated
-
-^
-./test/errors10/781205.xml:4: parser error : Start tag expected, '<' not found
-
-^
index 655f41a..6153cc9 100644 (file)
@@ -5,9 +5,3 @@
 
 
 ^
-./test/errors10/781361.xml:4: parser error : DOCTYPE improperly terminated
-
-^
-./test/errors10/781361.xml:4: parser error : Start tag expected, '<' not found
-
-^
diff --git a/result/issue626.xml b/result/issue626.xml
new file mode 100644 (file)
index 0000000..001b3d9
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ATTLIST e a1 CDATA #IMPLIED>
+<!ATTLIST e a2 CDATA #IMPLIED>
+<!ATTLIST e a3 CDATA #IMPLIED>
+<!ATTLIST e a4 CDATA #IMPLIED>
+<!ATTLIST e a5 CDATA #IMPLIED>
+<!ATTLIST e a6 CDATA #IMPLIED>
+]>
+<doc>
+    <!-- This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. -->
+    <e a1=" x  x " a2=" x  x " a3=" x  x " a4=" x  x " a5=" x  x " a6=" x  x "/>
+</doc>
diff --git a/result/issue626.xml.rde b/result/issue626.xml.rde
new file mode 100644 (file)
index 0000000..a488238
--- /dev/null
@@ -0,0 +1,12 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 8 #comment 0 1  This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. 
+1 14 #text 0 1 
+    
+1 1 e 1 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/issue626.xml.rdr b/result/issue626.xml.rdr
new file mode 100644 (file)
index 0000000..a488238
--- /dev/null
@@ -0,0 +1,12 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 8 #comment 0 1  This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. 
+1 14 #text 0 1 
+    
+1 1 e 1 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/issue626.xml.sax b/result/issue626.xml.sax
new file mode 100644 (file)
index 0000000..8e6b59b
--- /dev/null
@@ -0,0 +1,23 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(e, a1, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a2, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a3, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a4, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a5, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a6, 1, 3, NULL, ...)
+SAX.externalSubset(doc, , )
+SAX.startElement(doc)
+SAX.characters(
+    , 5)
+SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. )
+SAX.characters(
+    , 5)
+SAX.startElement(e, a1=' x  x ', a2=' x  x ', a3=' x  x ', a4=' x  x ', a5=' x  x ', a6=' x  x ')
+SAX.endElement(e)
+SAX.characters(
+, 1)
+SAX.endElement(doc)
+SAX.endDocument()
diff --git a/result/issue626.xml.sax2 b/result/issue626.xml.sax2
new file mode 100644 (file)
index 0000000..edc2c1f
--- /dev/null
@@ -0,0 +1,23 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(e, a1, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a2, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a3, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a4, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a5, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a6, 1, 3, NULL, ...)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, NULL, 0, 0, 0)
+SAX.characters(
+    , 5)
+SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. )
+SAX.characters(
+    , 5)
+SAX.startElementNs(e, NULL, NULL, 0, 6, 0, a1=' x  ...', 6, a2=' x  ...', 6, a3=' x  ...', 6, a4=' x  ...', 6, a5=' x  ...', 6, a6=' x  ...', 6)
+SAX.endElementNs(e, NULL, NULL)
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, NULL)
+SAX.endDocument()
diff --git a/result/issue643.xml b/result/issue643.xml
new file mode 100644 (file)
index 0000000..3a5a92c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ATTLIST elem xmlns CDATA #FIXED "urn:def2">
+<!ATTLIST elem xmlns:a CDATA #FIXED "urn:a2">
+]>
+<doc xmlns="urn:def" xmlns:a="urn:a">
+    <elem xmlns="urn:def2" xmlns:a="urn:a2"/>
+</doc>
diff --git a/result/issue643.xml.rde b/result/issue643.xml.rde
new file mode 100644 (file)
index 0000000..b8ca139
--- /dev/null
@@ -0,0 +1,8 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 1 elem 1 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/issue643.xml.rdr b/result/issue643.xml.rdr
new file mode 100644 (file)
index 0000000..b8ca139
--- /dev/null
@@ -0,0 +1,8 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 1 elem 1 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/issue643.xml.sax b/result/issue643.xml.sax
new file mode 100644 (file)
index 0000000..85563b9
--- /dev/null
@@ -0,0 +1,15 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
+SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
+SAX.externalSubset(doc, , )
+SAX.startElement(doc, xmlns='urn:def', xmlns:a='urn:a')
+SAX.characters(
+    , 5)
+SAX.startElement(elem)
+SAX.endElement(elem)
+SAX.characters(
+, 1)
+SAX.endElement(doc)
+SAX.endDocument()
diff --git a/result/issue643.xml.sax2 b/result/issue643.xml.sax2
new file mode 100644 (file)
index 0000000..cd7e5f1
--- /dev/null
@@ -0,0 +1,15 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
+SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, 'urn:def', 2, xmlns='urn:def', xmlns:a='urn:a', 0, 0)
+SAX.characters(
+    , 5)
+SAX.startElementNs(elem, NULL, 'urn:def2', 2, xmlns='urn:def2', xmlns:a='urn:a2', 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:def2')
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, 'urn:def')
+SAX.endDocument()
index 432a2e1..3801f61 100644 (file)
@@ -1,3 +1,3 @@
 ./test/namespaces/err_5.xml:1: namespace error : Failed to parse QName 'f:a:'
 <f:a: xmlns:f="http://example.com/foo"/>
-    ^
+     ^
index 47c14fd..8e90fcb 100644 (file)
@@ -1,3 +1,3 @@
-./test/namespaces/err_6.xml:1: namespace error : Failed to parse QName 'f:a:'
+./test/namespaces/err_6.xml:1: namespace error : Failed to parse QName 'f:a:b'
 <f:a:b xmlns:f="http://example.com/foo"/>
-    ^
+      ^
diff --git a/result/noent/boundaries1.xml b/result/noent/boundaries1.xml
new file mode 100644 (file)
index 0000000..da20872
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE d [
+<!ENTITY a "]>">
+<!ENTITY b "]>">
+<!--> ]> -->]>
+<?pi p1?>
+<!--> c1 -->
+<d a="&gt;" b="&gt;">
+text]&gt;text
+<![CDATA[cdata]]>
+<?pi p2?>
+<!--> c2 -->
+</d>
+<?pi p3?>
+<!--> c3 -->
diff --git a/result/noent/boundaries1.xml.sax2 b/result/noent/boundaries1.xml.sax2
new file mode 100644 (file)
index 0000000..093ac3b
--- /dev/null
@@ -0,0 +1,32 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(d, , )
+SAX.entityDecl(a, 1, (null), (null), ]>)
+SAX.getEntity(a)
+SAX.entityDecl(b, 1, (null), (null), ]>)
+SAX.getEntity(b)
+SAX.comment(> ]> )
+SAX.externalSubset(d, , )
+SAX.processingInstruction(pi, p1)
+SAX.comment(> c1 )
+SAX.startElementNs(d, NULL, NULL, 0, 2, 0, a='>" b...', 1, b='>'>
+...', 1)
+SAX.characters(
+text, 5)
+SAX.getEntity(a)
+SAX.characters(]>, 2)
+SAX.characters(text
+, 5)
+SAX.pcdata(cdata, 5)
+SAX.characters(
+, 1)
+SAX.processingInstruction(pi, p2)
+SAX.characters(
+, 1)
+SAX.comment(> c2 )
+SAX.characters(
+, 1)
+SAX.endElementNs(d, NULL, NULL)
+SAX.processingInstruction(pi, p3)
+SAX.comment(> c3 )
+SAX.endDocument()
index 3228de3..3d0e634 100644 (file)
@@ -7,11 +7,15 @@ SAX.getParameterEntity(sampleEnt)
 SAX.entityDecl(sampleEnt, 1, (null), (null), the hyacinth girl)
 SAX.getEntity(sampleEnt)
 SAX.getParameterEntity(sampleEnt)
-SAX.error: PEReference: %sampleEnt; not found
+SAX.elementDecl(item, 4, ...)
+SAX.elementDecl(para, 3, ...)
+SAX.externalSubset(item, , )
+SAX.startElementNs(item, NULL, NULL, 0, 0, 0)
+SAX.startElementNs(para, NULL, NULL, 0, 0, 0)
 SAX.characters('they called me , 16)
 SAX.getEntity(sampleEnt)
-SAX.error: Entity 'sampleEnt' not defined
-SAX.reference(sampleEnt)
+SAX.characters(the hyacinth girl, 17)
 SAX.characters(', 1)
+SAX.endElementNs(para, NULL, NULL)
+SAX.endElementNs(item, NULL, NULL)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
diff --git a/result/noent/issue626.xml b/result/noent/issue626.xml
new file mode 100644 (file)
index 0000000..001b3d9
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ATTLIST e a1 CDATA #IMPLIED>
+<!ATTLIST e a2 CDATA #IMPLIED>
+<!ATTLIST e a3 CDATA #IMPLIED>
+<!ATTLIST e a4 CDATA #IMPLIED>
+<!ATTLIST e a5 CDATA #IMPLIED>
+<!ATTLIST e a6 CDATA #IMPLIED>
+]>
+<doc>
+    <!-- This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. -->
+    <e a1=" x  x " a2=" x  x " a3=" x  x " a4=" x  x " a5=" x  x " a6=" x  x "/>
+</doc>
diff --git a/result/noent/issue626.xml.sax2 b/result/noent/issue626.xml.sax2
new file mode 100644 (file)
index 0000000..edc2c1f
--- /dev/null
@@ -0,0 +1,23 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(e, a1, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a2, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a3, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a4, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a5, 1, 3, NULL, ...)
+SAX.attributeDecl(e, a6, 1, 3, NULL, ...)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, NULL, 0, 0, 0)
+SAX.characters(
+    , 5)
+SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. )
+SAX.characters(
+    , 5)
+SAX.startElementNs(e, NULL, NULL, 0, 6, 0, a1=' x  ...', 6, a2=' x  ...', 6, a3=' x  ...', 6, a4=' x  ...', 6, a5=' x  ...', 6, a6=' x  ...', 6)
+SAX.endElementNs(e, NULL, NULL)
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, NULL)
+SAX.endDocument()
diff --git a/result/noent/issue643.xml b/result/noent/issue643.xml
new file mode 100644 (file)
index 0000000..3a5a92c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ATTLIST elem xmlns CDATA #FIXED "urn:def2">
+<!ATTLIST elem xmlns:a CDATA #FIXED "urn:a2">
+]>
+<doc xmlns="urn:def" xmlns:a="urn:a">
+    <elem xmlns="urn:def2" xmlns:a="urn:a2"/>
+</doc>
diff --git a/result/noent/issue643.xml.sax2 b/result/noent/issue643.xml.sax2
new file mode 100644 (file)
index 0000000..cd7e5f1
--- /dev/null
@@ -0,0 +1,15 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
+SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, 'urn:def', 2, xmlns='urn:def', xmlns:a='urn:a', 0, 0)
+SAX.characters(
+    , 5)
+SAX.startElementNs(elem, NULL, 'urn:def2', 2, xmlns='urn:def2', xmlns:a='urn:a2', 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:def2')
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, 'urn:def')
+SAX.endDocument()
diff --git a/result/noent/ns-ent.xml b/result/noent/ns-ent.xml
new file mode 100644 (file)
index 0000000..2d02e3d
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ENTITY ent1 "<elem/>">
+<!ENTITY ent2 "<ns:elem/>">
+]>
+<doc>
+    <a xmlns="urn:a"><elem/></a>
+    <b xmlns="urn:b"><elem/></b>
+    <a xmlns:ns="urn:a"><elem/></a>
+    <b xmlns:ns="urn:b"><elem/></b>
+</doc>
diff --git a/result/noent/ns-ent.xml.sax2 b/result/noent/ns-ent.xml.sax2
new file mode 100644 (file)
index 0000000..7fe00ae
--- /dev/null
@@ -0,0 +1,41 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.entityDecl(ent1, 1, (null), (null), <elem/>)
+SAX.getEntity(ent1)
+SAX.entityDecl(ent2, 1, (null), (null), <ns:elem/>)
+SAX.getEntity(ent2)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, NULL, 0, 0, 0)
+SAX.characters(
+    , 5)
+SAX.startElementNs(a, NULL, 'urn:a', 1, xmlns='urn:a', 0, 0)
+SAX.getEntity(ent1)
+SAX.startElementNs(elem, NULL, 'urn:a', 0, 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:a')
+SAX.endElementNs(a, NULL, 'urn:a')
+SAX.characters(
+    , 5)
+SAX.startElementNs(b, NULL, 'urn:b', 1, xmlns='urn:b', 0, 0)
+SAX.getEntity(ent1)
+SAX.startElementNs(elem, NULL, 'urn:b', 0, 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:b')
+SAX.endElementNs(b, NULL, 'urn:b')
+SAX.characters(
+    , 5)
+SAX.startElementNs(a, NULL, NULL, 1, xmlns:ns='urn:a', 0, 0)
+SAX.getEntity(ent2)
+SAX.startElementNs(elem, ns, 'urn:a', 0, 0, 0)
+SAX.endElementNs(elem, ns, 'urn:a')
+SAX.endElementNs(a, NULL, NULL)
+SAX.characters(
+    , 5)
+SAX.startElementNs(b, NULL, NULL, 1, xmlns:ns='urn:b', 0, 0)
+SAX.getEntity(ent2)
+SAX.startElementNs(elem, ns, 'urn:b', 0, 0, 0)
+SAX.endElementNs(elem, ns, 'urn:b')
+SAX.endElementNs(b, NULL, NULL)
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, NULL)
+SAX.endDocument()
index 141accd..8932f99 100644 (file)
@@ -8,11 +8,14 @@ SAX.getParameterEntity(xx)
 SAX.entityDecl(zz, 4, (null), (null), <!ENTITY tricky "error-prone" >)
 SAX.getParameterEntity(zz)
 SAX.getParameterEntity(xx)
-SAX.error: PEReference: %xx; not found
+SAX.getParameterEntity(zz)
+SAX.entityDecl(tricky, 1, (null), (null), error-prone)
+SAX.getEntity(tricky)
+SAX.externalSubset(test, , )
+SAX.startElementNs(test, NULL, NULL, 0, 0, 0)
 SAX.characters(This sample shows a , 20)
 SAX.getEntity(tricky)
-SAX.error: Entity 'tricky' not defined
-SAX.reference(tricky)
+SAX.characters(error-prone, 11)
 SAX.characters( method., 8)
+SAX.endElementNs(test, NULL, NULL)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
diff --git a/result/ns-ent.xml b/result/ns-ent.xml
new file mode 100644 (file)
index 0000000..94f89b1
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ENTITY ent1 "<elem/>">
+<!ENTITY ent2 "<ns:elem/>">
+]>
+<doc>
+    <a xmlns="urn:a">&ent1;</a>
+    <b xmlns="urn:b">&ent1;</b>
+    <a xmlns:ns="urn:a">&ent2;</a>
+    <b xmlns:ns="urn:b">&ent2;</b>
+</doc>
diff --git a/result/ns-ent.xml.rde b/result/ns-ent.xml.rde
new file mode 100644 (file)
index 0000000..0b79eaa
--- /dev/null
@@ -0,0 +1,25 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 1 a 0 0
+2 1 elem 1 0
+1 15 a 0 0
+1 14 #text 0 1 
+    
+1 1 b 0 0
+2 1 elem 1 0
+1 15 b 0 0
+1 14 #text 0 1 
+    
+1 1 a 0 0
+2 1 elem 1 0
+1 15 a 0 0
+1 14 #text 0 1 
+    
+1 1 b 0 0
+2 1 elem 1 0
+1 15 b 0 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/ns-ent.xml.rdr b/result/ns-ent.xml.rdr
new file mode 100644 (file)
index 0000000..88bcf47
--- /dev/null
@@ -0,0 +1,25 @@
+0 10 doc 0 0
+0 1 doc 0 0
+1 14 #text 0 1 
+    
+1 1 a 0 0
+2 5 ent1 0 0
+1 15 a 0 0
+1 14 #text 0 1 
+    
+1 1 b 0 0
+2 5 ent1 0 0
+1 15 b 0 0
+1 14 #text 0 1 
+    
+1 1 a 0 0
+2 5 ent2 0 0
+1 15 a 0 0
+1 14 #text 0 1 
+    
+1 1 b 0 0
+2 5 ent2 0 0
+1 15 b 0 0
+1 14 #text 0 1 
+
+0 15 doc 0 0
diff --git a/result/ns-ent.xml.sax b/result/ns-ent.xml.sax
new file mode 100644 (file)
index 0000000..98b63fc
--- /dev/null
@@ -0,0 +1,45 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.entityDecl(ent1, 1, (null), (null), <elem/>)
+SAX.getEntity(ent1)
+SAX.entityDecl(ent2, 1, (null), (null), <ns:elem/>)
+SAX.getEntity(ent2)
+SAX.externalSubset(doc, , )
+SAX.startElement(doc)
+SAX.characters(
+    , 5)
+SAX.startElement(a, xmlns='urn:a')
+SAX.getEntity(ent1)
+SAX.startElement(elem)
+SAX.endElement(elem)
+SAX.reference(ent1)
+SAX.endElement(a)
+SAX.characters(
+    , 5)
+SAX.startElement(b, xmlns='urn:b')
+SAX.getEntity(ent1)
+SAX.startElement(elem)
+SAX.endElement(elem)
+SAX.reference(ent1)
+SAX.endElement(b)
+SAX.characters(
+    , 5)
+SAX.startElement(a, xmlns:ns='urn:a')
+SAX.getEntity(ent2)
+SAX.startElement(ns:elem)
+SAX.endElement(ns:elem)
+SAX.reference(ent2)
+SAX.endElement(a)
+SAX.characters(
+    , 5)
+SAX.startElement(b, xmlns:ns='urn:b')
+SAX.getEntity(ent2)
+SAX.startElement(ns:elem)
+SAX.endElement(ns:elem)
+SAX.reference(ent2)
+SAX.endElement(b)
+SAX.characters(
+, 1)
+SAX.endElement(doc)
+SAX.endDocument()
diff --git a/result/ns-ent.xml.sax2 b/result/ns-ent.xml.sax2
new file mode 100644 (file)
index 0000000..25106c4
--- /dev/null
@@ -0,0 +1,45 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(doc, , )
+SAX.entityDecl(ent1, 1, (null), (null), <elem/>)
+SAX.getEntity(ent1)
+SAX.entityDecl(ent2, 1, (null), (null), <ns:elem/>)
+SAX.getEntity(ent2)
+SAX.externalSubset(doc, , )
+SAX.startElementNs(doc, NULL, NULL, 0, 0, 0)
+SAX.characters(
+    , 5)
+SAX.startElementNs(a, NULL, 'urn:a', 1, xmlns='urn:a', 0, 0)
+SAX.getEntity(ent1)
+SAX.startElementNs(elem, NULL, 'urn:a', 0, 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:a')
+SAX.reference(ent1)
+SAX.endElementNs(a, NULL, 'urn:a')
+SAX.characters(
+    , 5)
+SAX.startElementNs(b, NULL, 'urn:b', 1, xmlns='urn:b', 0, 0)
+SAX.getEntity(ent1)
+SAX.startElementNs(elem, NULL, 'urn:b', 0, 0, 0)
+SAX.endElementNs(elem, NULL, 'urn:b')
+SAX.reference(ent1)
+SAX.endElementNs(b, NULL, 'urn:b')
+SAX.characters(
+    , 5)
+SAX.startElementNs(a, NULL, NULL, 1, xmlns:ns='urn:a', 0, 0)
+SAX.getEntity(ent2)
+SAX.startElementNs(elem, ns, 'urn:a', 0, 0, 0)
+SAX.endElementNs(elem, ns, 'urn:a')
+SAX.reference(ent2)
+SAX.endElementNs(a, NULL, NULL)
+SAX.characters(
+    , 5)
+SAX.startElementNs(b, NULL, NULL, 1, xmlns:ns='urn:b', 0, 0)
+SAX.getEntity(ent2)
+SAX.startElementNs(elem, ns, 'urn:b', 0, 0, 0)
+SAX.endElementNs(elem, ns, 'urn:b')
+SAX.reference(ent2)
+SAX.endElementNs(b, NULL, NULL)
+SAX.characters(
+, 1)
+SAX.endElementNs(doc, NULL, NULL)
+SAX.endDocument()
index 5e4c25e..5b544ba 100644 (file)
@@ -1 +1 @@
-./test/schemas/579746_3.xml:5: element customer: Schemas validity error : Element 'customer': This element is not expected.
+./test/schemas/579746_3.xml:5: Schemas validity error : Element 'customer': This element is not expected.
index 1e5680d..e71f94b 100644 (file)
@@ -1 +1 @@
-./test/schemas/579746_5.xml:5: element comment: Schemas validity error : Element 'comment': This element is not expected.
+./test/schemas/579746_5.xml:5: Schemas validity error : Element 'comment': This element is not expected.
index 5e4c25e..5b544ba 100644 (file)
@@ -1 +1 @@
-./test/schemas/579746_3.xml:5: element customer: Schemas validity error : Element 'customer': This element is not expected.
+./test/schemas/579746_3.xml:5: Schemas validity error : Element 'customer': This element is not expected.
index 1e5680d..e71f94b 100644 (file)
@@ -1 +1 @@
-./test/schemas/579746_5.xml:5: element comment: Schemas validity error : Element 'comment': This element is not expected.
+./test/schemas/579746_5.xml:5: Schemas validity error : Element 'comment': This element is not expected.
index 6933fb7..1d422a5 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_3.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
+./test/schemas/all_3.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
index f846d15..9406539 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_4.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b, c ).
+./test/schemas/all_4.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b, c ).
index d8ca9a7..183c309 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_5.xml:1: element a: Schemas validity error : Element 'a': This element is not expected. Expected is ( c ).
+./test/schemas/all_5.xml:1: Schemas validity error : Element 'a': This element is not expected. Expected is ( c ).
index c31d91b..7a74825 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_6.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( b, c ).
+./test/schemas/all_6.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( b, c ).
index d5c5428..2f4c53f 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_7.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
+./test/schemas/all_7.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
index 6933fb7..1d422a5 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_3.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
+./test/schemas/all_3.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
index d8ca9a7..183c309 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_5.xml:1: element a: Schemas validity error : Element 'a': This element is not expected. Expected is ( c ).
+./test/schemas/all_5.xml:1: Schemas validity error : Element 'a': This element is not expected. Expected is ( c ).
index c31d91b..7a74825 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_6.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( b, c ).
+./test/schemas/all_6.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( b, c ).
index d5c5428..2f4c53f 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_7.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
+./test/schemas/all_7.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ).
index 6ef8590..bf43944 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_0.xml:1: element c: Schemas validity error : Element 'c': This element is not expected.
+./test/schemas/all_0.xml:1: Schemas validity error : Element 'c': This element is not expected.
index fd8cb48..fc12152 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_1.xml:1: element c: Schemas validity error : Element 'c': This element is not expected. Expected is ( a ).
+./test/schemas/all_1.xml:1: Schemas validity error : Element 'c': This element is not expected. Expected is ( a ).
index 1f04462..8e56a78 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_2.xml:1: element c: Schemas validity error : Element 'c': This element is not expected.
+./test/schemas/all_2.xml:1: Schemas validity error : Element 'c': This element is not expected.
index 31dcf12..717e042 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_4.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
+./test/schemas/all_4.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
index e859ebd..42ea79a 100644 (file)
@@ -1 +1 @@
-./test/schemas/all_5.xml:1: element a: Schemas validity error : Element 'a': This element is not expected.
+./test/schemas/all_5.xml:1: Schemas validity error : Element 'a': This element is not expected.
index 628a360..57dd594 100644 (file)
@@ -1 +1 @@
-./test/schemas/allsg_3.xml:6: element gm-B-1: Schemas validity error : Element '{urn:test:foo}gm-B-1': This element is not expected. Expected is one of ( {urn:test:foo}gh-A, {urn:test:foo}gm-A-1, {urn:test:foo}gm-A-2 ).
+./test/schemas/allsg_3.xml:6: Schemas validity error : Element '{urn:test:foo}gm-B-1': This element is not expected. Expected is one of ( {urn:test:foo}gh-A, {urn:test:foo}gm-A-1, {urn:test:foo}gm-A-2 ).
index e72288d..558f984 100644 (file)
@@ -1 +1 @@
-./test/schemas/allsg_4.xml:6: element gm-A-1: Schemas validity error : Element '{urn:test:foo}gm-A-1': This element is not expected. Expected is one of ( {urn:test:foo}gh-B, {urn:test:foo}gm-B-1, {urn:test:foo}gm-B-2 ).
+./test/schemas/allsg_4.xml:6: Schemas validity error : Element '{urn:test:foo}gm-A-1': This element is not expected. Expected is one of ( {urn:test:foo}gh-B, {urn:test:foo}gm-B-1, {urn:test:foo}gm-B-2 ).
index 26a1446..f428fd6 100644 (file)
@@ -1 +1 @@
-./test/schemas/allsg_5.xml:7: element gm-B-2: Schemas validity error : Element '{urn:test:foo}gm-B-2': This element is not expected.
+./test/schemas/allsg_5.xml:7: Schemas validity error : Element '{urn:test:foo}gm-B-2': This element is not expected.
index 49ce581..ee4ca24 100644 (file)
@@ -1 +1 @@
-./test/schemas/any3_0.xml:12: element bar.A: Schemas validity error : Element 'bar.A': This element is not expected. Expected is ( ##other{http://FOO}* ).
+./test/schemas/any3_0.xml:12: Schemas validity error : Element 'bar.A': This element is not expected. Expected is ( ##other{http://FOO}* ).
index b69fd57..72b39a9 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_0.xml:6: element boo: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any5_0.xml:6: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index 79d7e35..52c53a8 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_1.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
+./test/schemas/any5_1.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
index a5bf4c0..cd23a02 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_2.xml:7: element boo: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected.
+./test/schemas/any5_2.xml:7: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected.
index 74a6bda..6ec962c 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_4.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
+./test/schemas/any5_4.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
index e50113f..e777721 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_5.xml:11: element boo: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected.
+./test/schemas/any5_5.xml:11: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected.
index b64cd4f..4998a4e 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_6.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
+./test/schemas/any5_6.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected.
index b69fd57..72b39a9 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_0.xml:6: element boo: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any5_0.xml:6: Schemas validity error : Element '{urn:test:foo}boo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index bbfccb4..9a17c9e 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_1.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
+./test/schemas/any5_1.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
index e6c07b2..f823ee3 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_3.xml:4: element foo: Schemas validity error : Element '{urn:test:foo}foo': Missing child element(s).
+./test/schemas/any5_3.xml:4: Schemas validity error : Element '{urn:test:foo}foo': Missing child element(s).
index 6d89773..9f02329 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_4.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
+./test/schemas/any5_4.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
index 8c3f020..e090bc3 100644 (file)
@@ -1 +1 @@
-./test/schemas/any5_6.xml:11: element boo: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
+./test/schemas/any5_6.xml:11: Schemas validity error : Element '{urn:test:bar}boo': This element is not expected. Expected is ( {urn:test:foo}boo ).
index a4274f8..208c8a6 100644 (file)
@@ -1 +1 @@
-./test/schemas/any7_0.xml:18: element moo: Schemas validity error : Element 'moo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any7_0.xml:18: Schemas validity error : Element 'moo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index 8745468..440d6a5 100644 (file)
@@ -1 +1 @@
-./test/schemas/any7_1.xml:17: element bar: Schemas validity error : Element '{urn:test:foo}bar': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any7_1.xml:17: Schemas validity error : Element '{urn:test:foo}bar': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index a4274f8..208c8a6 100644 (file)
@@ -1 +1 @@
-./test/schemas/any7_0.xml:18: element moo: Schemas validity error : Element 'moo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any7_0.xml:18: Schemas validity error : Element 'moo': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index 8745468..440d6a5 100644 (file)
@@ -1 +1 @@
-./test/schemas/any7_1.xml:17: element bar: Schemas validity error : Element '{urn:test:foo}bar': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
+./test/schemas/any7_1.xml:17: Schemas validity error : Element '{urn:test:foo}bar': This element is not expected. Expected is ( ##other{urn:test:foo}* ).
index dc4766b..f1a6023 100644 (file)
@@ -1,2 +1,2 @@
-./test/schemas/anyAttr-processContents-err1_0.xml:8: element elem.lax: Schemas validity error : Element '{http://FOO}elem.lax', attribute '{http://FOO}bar': 'o o' is not a valid value of the atomic type 'xs:language'.
-./test/schemas/anyAttr-processContents-err1_0.xml:9: element elem.strict: Schemas validity error : Element '{http://FOO}elem.strict', attribute '{http://FOO}barB': No matching global attribute declaration available, but demanded by the strict wildcard.
+./test/schemas/anyAttr-processContents-err1_0.xml:8: Schemas validity error : Element '{http://FOO}elem.lax', attribute '{http://FOO}bar': 'o o' is not a valid value of the atomic type 'xs:language'.
+./test/schemas/anyAttr-processContents-err1_0.xml:9: Schemas validity error : Element '{http://FOO}elem.strict', attribute '{http://FOO}barB': No matching global attribute declaration available, but demanded by the strict wildcard.
index 5dd4fb1..6795f8f 100644 (file)
@@ -1 +1 @@
-./test/schemas/attruse_0_1.xml:3: element barA: Schemas validity error : Element 'barA': The attribute 'attr' is required but missing.
+./test/schemas/attruse_0_1.xml:3: Schemas validity error : Element 'barA': The attribute 'attr' is required but missing.
index 01cf822..d09a2ae 100644 (file)
@@ -1 +1 @@
-./test/schemas/attruse_0_2.xml:6: element barC: Schemas validity error : Element 'barC', attribute 'attr': The attribute 'attr' is not allowed.
+./test/schemas/attruse_0_2.xml:6: Schemas validity error : Element 'barC', attribute 'attr': The attribute 'attr' is not allowed.
index 1655070..0488ef8 100644 (file)
@@ -1 +1 @@
-./test/schemas/bug323510_0.xml:2: element foo: Schemas validity error : Element 'foo': Missing child element(s). Expected is ( bar ).
+./test/schemas/bug323510_0.xml:2: Schemas validity error : Element 'foo': Missing child element(s). Expected is ( bar ).
index ef0b1ec..344a156 100644 (file)
@@ -1 +1 @@
-./test/schemas/changelog093_0.xml:7: element description: Schemas validity error : Element '{http://www.blackperl.com/XML/ChangeLog}description': Duplicate key-sequence ['PL'] in unique identity-constraint '{http://www.blackperl.com/XML/ChangeLog}changelogDescriptionLangConstraint'.
+./test/schemas/changelog093_0.xml:7: Schemas validity error : Element '{http://www.blackperl.com/XML/ChangeLog}description': Duplicate key-sequence ['PL'] in unique identity-constraint '{http://www.blackperl.com/XML/ChangeLog}changelogDescriptionLangConstraint'.
index 5141445..37344b1 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_2.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_2.xml:3: Schemas validity error : Element 'b': This element is not expected.
index ece5d69..57d3728 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_3.xml:3: element a: Schemas validity error : Element 'a': This element is not expected.
+./test/schemas/choice_3.xml:3: Schemas validity error : Element 'a': This element is not expected.
index 3d3af59..273f170 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_4.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
+./test/schemas/choice_4.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
index 39d413c..3a0f40a 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_5.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_5.xml:3: Schemas validity error : Element 'b': This element is not expected.
index 414d1e2..270c1ff 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_6.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_6.xml:3: Schemas validity error : Element 'b': This element is not expected.
index 5141445..37344b1 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_2.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_2.xml:3: Schemas validity error : Element 'b': This element is not expected.
index ece5d69..57d3728 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_3.xml:3: element a: Schemas validity error : Element 'a': This element is not expected.
+./test/schemas/choice_3.xml:3: Schemas validity error : Element 'a': This element is not expected.
index 39d413c..3a0f40a 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_5.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_5.xml:3: Schemas validity error : Element 'b': This element is not expected.
index 414d1e2..270c1ff 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_6.xml:3: element b: Schemas validity error : Element 'b': This element is not expected.
+./test/schemas/choice_6.xml:3: Schemas validity error : Element 'b': This element is not expected.
index 3d3af59..273f170 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_4.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
+./test/schemas/choice_4.xml:1: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( a, b ).
index bef56da..b6ae4a7 100644 (file)
@@ -1 +1 @@
-./test/schemas/choice_6.xml:5: element a: Schemas validity error : Element 'a': This element is not expected.
+./test/schemas/choice_6.xml:5: Schemas validity error : Element 'a': This element is not expected.
index ccc12b6..32e389b 100644 (file)
@@ -1,2 +1,2 @@
-./test/schemas/cos-st-restricts-1-2-err_0.xml:3: element foo: Schemas validity error : Element '{http://FOO}foo': [facet 'length'] The value has a length of '2'; this differs from the allowed length of '3'.
-./test/schemas/cos-st-restricts-1-2-err_0.xml:3: element foo: Schemas validity error : Element '{http://FOO}foo': '1 2' is not a valid value of the list type '{http://FOO}type.A'.
+./test/schemas/cos-st-restricts-1-2-err_0.xml:3: Schemas validity error : Element '{http://FOO}foo': [facet 'length'] The value has a length of '2'; this differs from the allowed length of '3'.
+./test/schemas/cos-st-restricts-1-2-err_0.xml:3: Schemas validity error : Element '{http://FOO}foo': '1 2' is not a valid value of the list type '{http://FOO}type.A'.
index 7f4fa9c..62ca9de 100644 (file)
@@ -1,8 +1,8 @@
-./test/schemas/decimal-1_0.xml:16: element val: Schemas validity error : Element 'val': '.' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:17: element val: Schemas validity error : Element 'val': '-' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:18: element val: Schemas validity error : Element 'val': '+' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:19: element val: Schemas validity error : Element 'val': '*' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:20: element val: Schemas validity error : Element 'val': '- 1' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:21: element val: Schemas validity error : Element 'val': '+ 1' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:22: element val: Schemas validity error : Element 'val': '+ 0' is not a valid value of the atomic type 'myDecimal'.
-./test/schemas/decimal-1_0.xml:23: element val: Schemas validity error : Element 'val': '- 0' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:16: Schemas validity error : Element 'val': '.' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:17: Schemas validity error : Element 'val': '-' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:18: Schemas validity error : Element 'val': '+' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:19: Schemas validity error : Element 'val': '*' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:20: Schemas validity error : Element 'val': '- 1' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:21: Schemas validity error : Element 'val': '+ 1' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:22: Schemas validity error : Element 'val': '+ 0' is not a valid value of the atomic type 'myDecimal'.
+./test/schemas/decimal-1_0.xml:23: Schemas validity error : Element 'val': '- 0' is not a valid value of the atomic type 'myDecimal'.
index bda17a5..89dcb2d 100644 (file)
@@ -1,2 +1,2 @@
-./test/schemas/decimal-2_0.xml:12: element val: Schemas validity error : Element 'val': [facet 'minInclusive'] The value '-0.1' is less than the minimum value allowed ('0').
-./test/schemas/decimal-2_0.xml:13: element val: Schemas validity error : Element 'val': [facet 'minInclusive'] The value '-1' is less than the minimum value allowed ('0').
+./test/schemas/decimal-2_0.xml:12: Schemas validity error : Element 'val': [facet 'minInclusive'] The value '-0.1' is less than the minimum value allowed ('0').
+./test/schemas/decimal-2_0.xml:13: Schemas validity error : Element 'val': [facet 'minInclusive'] The value '-1' is less than the minimum value allowed ('0').
index f37a200..64be553 100644 (file)
@@ -1,4 +1,4 @@
-./test/schemas/decimal-3_0.xml:12: element val: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '0.123' has more digits than are allowed ('2').
-./test/schemas/decimal-3_0.xml:13: element val: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '0.023' has more digits than are allowed ('2').
-./test/schemas/decimal-3_0.xml:14: element val: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '123' has more digits than are allowed ('2').
-./test/schemas/decimal-3_0.xml:15: element val: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '12.3' has more digits than are allowed ('2').
+./test/schemas/decimal-3_0.xml:12: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '0.123' has more digits than are allowed ('2').
+./test/schemas/decimal-3_0.xml:13: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '0.023' has more digits than are allowed ('2').
+./test/schemas/decimal-3_0.xml:14: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '123' has more digits than are allowed ('2').
+./test/schemas/decimal-3_0.xml:15: Schemas validity error : Element 'val': [facet 'totalDigits'] The value '12.3' has more digits than are allowed ('2').
index bb5b047..25e93f7 100644 (file)
@@ -1 +1 @@
-./test/schemas/extension1_1.xml:1: element title: Schemas validity error : Element 'title', attribute 'langue': The attribute 'langue' is not allowed.
+./test/schemas/extension1_1.xml:1: Schemas validity error : Element 'title', attribute 'langue': The attribute 'langue' is not allowed.
index 161fe9e..2268f38 100644 (file)
@@ -1 +1 @@
-./test/schemas/extension1_2.xml:1: element title: Schemas validity error : Element 'title': Element content is not allowed, because the content type is a simple type definition.
+./test/schemas/extension1_2.xml:1: Schemas validity error : Element 'title': Element content is not allowed, because the content type is a simple type definition.
index 392dbe5..dbaa113 100644 (file)
@@ -1 +1 @@
-./test/schemas/facet-unionST-err1_0.xml:3: element foo: Schemas validity error : Element '{http://FOO}foo': 'tiny' is not a valid value of the union type '{http://FOO}fooType.B'.
+./test/schemas/facet-unionST-err1_0.xml:3: Schemas validity error : Element '{http://FOO}foo': 'tiny' is not a valid value of the union type '{http://FOO}fooType.B'.
index f43ef33..15ce34d 100644 (file)
@@ -1,7 +1,7 @@
-./test/schemas/hexbinary_1.xml:6: element hex: Schemas validity error : Element 'hex': '0' is not a valid value of the atomic type 'xs:hexBinary'.
-./test/schemas/hexbinary_1.xml:7: element hex: Schemas validity error : Element 'hex': '0123456789ABCDEFGH' is not a valid value of the atomic type 'xs:hexBinary'.
-./test/schemas/hexbinary_1.xml:8: element hex: Schemas validity error : Element 'hex': '+abcdef0123456789' is not a valid value of the atomic type 'xs:hexBinary'.
-./test/schemas/hexbinary_1.xml:9: element hex: Schemas validity error : Element 'hex': '-0123456789abcdef' is not a valid value of the atomic type 'xs:hexBinary'.
-./test/schemas/hexbinary_1.xml:11: element hex2: Schemas validity error : Element 'hex2': [facet 'maxLength'] The value has a length of '9'; this exceeds the allowed maximum length of '8'.
-./test/schemas/hexbinary_1.xml:13: element hex3: Schemas validity error : Element 'hex3': [facet 'length'] The value has a length of '1'; this differs from the allowed length of '2'.
-./test/schemas/hexbinary_1.xml:14: element hex3: Schemas validity error : Element 'hex3': [facet 'length'] The value has a length of '3'; this differs from the allowed length of '2'.
+./test/schemas/hexbinary_1.xml:6: Schemas validity error : Element 'hex': '0' is not a valid value of the atomic type 'xs:hexBinary'.
+./test/schemas/hexbinary_1.xml:7: Schemas validity error : Element 'hex': '0123456789ABCDEFGH' is not a valid value of the atomic type 'xs:hexBinary'.
+./test/schemas/hexbinary_1.xml:8: Schemas validity error : Element 'hex': '+abcdef0123456789' is not a valid value of the atomic type 'xs:hexBinary'.
+./test/schemas/hexbinary_1.xml:9: Schemas validity error : Element 'hex': '-0123456789abcdef' is not a valid value of the atomic type 'xs:hexBinary'.
+./test/schemas/hexbinary_1.xml:11: Schemas validity error : Element 'hex2': [facet 'maxLength'] The value has a length of '9'; this exceeds the allowed maximum length of '8'.
+./test/schemas/hexbinary_1.xml:13: Schemas validity error : Element 'hex3': [facet 'length'] The value has a length of '1'; this differs from the allowed length of '2'.
+./test/schemas/hexbinary_1.xml:14: Schemas validity error : Element 'hex3': [facet 'length'] The value has a length of '3'; this differs from the allowed length of '2'.
diff --git a/result/schemas/issue491_0_0.err b/result/schemas/issue491_0_0.err
new file mode 100644 (file)
index 0000000..9b2bb96
--- /dev/null
@@ -0,0 +1 @@
+./test/schemas/issue491_0.xsd:8: element complexType: Schemas parser error : complex type 'ChildType': The content type of both, the type and its base type, must either 'mixed' or 'element-only'.
index 7a3b63b..8d25f8a 100644 (file)
@@ -1 +1 @@
-./test/schemas/list0_1.xml:1: element test: Schemas validity error : Element 'test': Missing child element(s). Expected is ( string ).
+./test/schemas/list0_1.xml:1: Schemas validity error : Element 'test': Missing child element(s). Expected is ( string ).
index 0bc3c8a..ae915c4 100644 (file)
@@ -1 +1 @@
-./test/schemas/list0_0.xml:5: element string: Schemas validity error : Element 'string': This element is not expected.
+./test/schemas/list0_0.xml:5: Schemas validity error : Element 'string': This element is not expected.
index 7a3b63b..8d25f8a 100644 (file)
@@ -1 +1 @@
-./test/schemas/list0_1.xml:1: element test: Schemas validity error : Element 'test': Missing child element(s). Expected is ( string ).
+./test/schemas/list0_1.xml:1: Schemas validity error : Element 'test': Missing child element(s). Expected is ( string ).
index 346af26..315553c 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': No matching global declaration available for the validation root.
+./test/schemas/ns0_2.xml:1: Schemas validity error : Element 'foo': No matching global declaration available for the validation root.
index fd1cbd5..7953234 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_3.xml:1: element foo: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute '{http://example.com/xsd/ns}id': The attribute '{http://example.com/xsd/ns}id' is not allowed.
+./test/schemas/ns0_3.xml:1: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute '{http://example.com/xsd/ns}id': The attribute '{http://example.com/xsd/ns}id' is not allowed.
index 2512e8d..f491e14 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_4.xml:2: element foo: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute '{http://example.com/xsd/ns}id': The attribute '{http://example.com/xsd/ns}id' is not allowed.
+./test/schemas/ns0_4.xml:2: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute '{http://example.com/xsd/ns}id': The attribute '{http://example.com/xsd/ns}id' is not allowed.
index 1282888..3a24c8c 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_0.xml:1: element foo: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute 'id': The attribute 'id' is not allowed.
+./test/schemas/ns0_0.xml:1: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute 'id': The attribute 'id' is not allowed.
index 99b2880..6c259ad 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_1.xml:1: element foo: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute 'id': The attribute 'id' is not allowed.
+./test/schemas/ns0_1.xml:1: Schemas validity error : Element '{http://example.com/xsd/ns}foo', attribute 'id': The attribute 'id' is not allowed.
index 346af26..315553c 100644 (file)
@@ -1 +1 @@
-./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': No matching global declaration available for the validation root.
+./test/schemas/ns0_2.xml:1: Schemas validity error : Element 'foo': No matching global declaration available for the validation root.
diff --git a/result/schemas/oss-fuzz-51295_0_0.err b/result/schemas/oss-fuzz-51295_0_0.err
new file mode 100644 (file)
index 0000000..1e89524
--- /dev/null
@@ -0,0 +1,2 @@
+./test/schemas/oss-fuzz-51295_0.xsd:2: element element: Schemas parser error : element decl. 'e': The element declaration 'e' defines a circular substitution group to element declaration 'e'.
+./test/schemas/oss-fuzz-51295_0.xsd:2: element element: Schemas parser error : element decl. 'e': The element declaration 'e' defines a circular substitution group to element declaration 'e'.
index 42dee61..c6ab50d 100644 (file)
@@ -1 +1 @@
-./test/schemas/restriction-enum-1_0.xml:7: element foo: Schemas validity error : Element 'foo': [facet 'enumeration'] The value 'c' is not an element of the set {'a', 'b', 'd'}.
+./test/schemas/restriction-enum-1_0.xml:7: Schemas validity error : Element 'foo': [facet 'enumeration'] The value 'c' is not an element of the set {'a', 'b', 'd'}.
index a66ad59..9fffc2c 100644 (file)
@@ -1,3 +1,3 @@
-./test/schemas/union2_1.xml:4: element ELEMENTS: Schemas validity error : Element '{urn:test:foo}ELEMENTS': '
+./test/schemas/union2_1.xml:4: Schemas validity error : Element '{urn:test:foo}ELEMENTS': '
        5
 ' is not a valid value of the local union type.
index 1b964b2..4a17646 100644 (file)
@@ -1 +1 @@
-./test/schemas/vdv-first4_1.xml:14: element born: Schemas validity error : Element 'born': '196T6-08-22' is not a valid value of the atomic type 'date'.
+./test/schemas/vdv-first4_1.xml:14: Schemas validity error : Element 'born': '196T6-08-22' is not a valid value of the atomic type 'date'.
index 0a49faa..fe405f7 100644 (file)
@@ -1 +1 @@
-./test/schemas/vdv-first4_2.xml:24: element born: Schemas validity error : Element 'born': [facet 'pattern'] The value '2000-01-20Z' is not accepted by the pattern '[^:Z]*'.
+./test/schemas/vdv-first4_2.xml:24: Schemas validity error : Element 'born': [facet 'pattern'] The value '2000-01-20Z' is not accepted by the pattern '[^:Z]*'.
index 5ff5699..dd9df08 100644 (file)
@@ -1,6 +1,6 @@
 ./test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got 
 <a/>
     ^
-./test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child
+./test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
 
 ^
diff --git a/result/valid/huge.xml b/result/valid/huge.xml
new file mode 100644 (file)
index 0000000..648c1b9
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ENTITY % pe SYSTEM "dtds/huge.ent">
+<!-- More than MINLEN (4000) bytes of comments --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!-- ................................................................. --><!ELEMENT doc (#PCDATA)>
+]>
+<doc>test</doc>
index a4c30a8..beacf15 100644 (file)
@@ -7,5 +7,5 @@
 <!ATTLIST a:inner attr CDATA #FIXED "yes">
 ]>
 <a:outer xmlns:a="urn:namespace">
-  <a:inner/>
+  <a:inner xmlns:a="urn:namespace"/>
 </a:outer>
diff --git a/result/valid/pe-latin1.xml b/result/valid/pe-latin1.xml
new file mode 100644 (file)
index 0000000..0014899
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+<!ELEMENT doc (#PCDATA)>
+<!ENTITY % pe SYSTEM "dtds/pe-latin1.ent">
+<!ENTITY latin1 "äöü">
+]>
+<doc>&latin1;</doc>
diff --git a/result/valid/pe-val-latin1.xml b/result/valid/pe-val-latin1.xml
new file mode 100644 (file)
index 0000000..4da3720
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc SYSTEM "dtds/pe-val-latin1.dtd">
+<doc>&latin1;</doc>
index 23a3258..d4576e3 100644 (file)
@@ -1,6 +1,3 @@
 ./test/valid/t4.dtd:1: parser error : StartTag: invalid element name
 <!ENTITY % percent "&#x25;">
  ^
-./test/valid/t4.dtd:1: parser error : Extra content at the end of the document
-<!ENTITY % percent "&#x25;">
- ^
index 48cdd5f..38db989 100644 (file)
@@ -1,6 +1,3 @@
 ./test/valid/t4a.dtd:1: parser error : StartTag: invalid element name
 <!ENTITY % percent "&#x25;">
  ^
-./test/valid/t4a.dtd:1: parser error : Extra content at the end of the document
-<!ENTITY % percent "&#x25;">
- ^
index 6e84d68..487c07d 100644 (file)
@@ -1,6 +1,3 @@
 ./test/valid/t6.dtd:1: parser error : StartTag: invalid element name
 <!ENTITY % xdef "def">
  ^
-./test/valid/t6.dtd:1: parser error : Extra content at the end of the document
-<!ENTITY % xdef "def">
- ^
index 5272694..8f87417 100644 (file)
@@ -5,17 +5,3 @@
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                     ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                               ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
index 8da08fb..06b7baf 100644 (file)
@@ -5,18 +5,4 @@
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                     ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot; %defmiddle; %deftest;
-                               ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
 ./test/valid/t8.xml : failed to parse
index 2846b19..211e9e8 100644 (file)
@@ -5,17 +5,3 @@
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                    ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                             ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
index 6abe75a..2ae90c9 100644 (file)
@@ -5,18 +5,4 @@
 Entity: line 1: 
 &lt;!ELEMENT root (middle) >
 ^
-./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                    ^
-Entity: line 1: 
-&lt;!ELEMENT middle (test) >
-^
-./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
-
-%defroot;%defmiddle;%deftest;
-                             ^
-Entity: line 1: 
-&lt;!ELEMENT test (#PCDATA) >
-^
 ./test/valid/t8a.xml : failed to parse
index 141accd..ced4c73 100644 (file)
@@ -8,11 +8,15 @@ SAX.getParameterEntity(xx)
 SAX.entityDecl(zz, 4, (null), (null), <!ENTITY tricky "error-prone" >)
 SAX.getParameterEntity(zz)
 SAX.getParameterEntity(xx)
-SAX.error: PEReference: %xx; not found
+SAX.getParameterEntity(zz)
+SAX.entityDecl(tricky, 1, (null), (null), error-prone)
+SAX.getEntity(tricky)
+SAX.externalSubset(test, , )
+SAX.startElement(test)
 SAX.characters(This sample shows a , 20)
 SAX.getEntity(tricky)
-SAX.error: Entity 'tricky' not defined
+SAX.characters(error-prone, 11)
 SAX.reference(tricky)
 SAX.characters( method., 8)
+SAX.endElement(test)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
index 141accd..f66b9e0 100644 (file)
@@ -8,11 +8,15 @@ SAX.getParameterEntity(xx)
 SAX.entityDecl(zz, 4, (null), (null), <!ENTITY tricky "error-prone" >)
 SAX.getParameterEntity(zz)
 SAX.getParameterEntity(xx)
-SAX.error: PEReference: %xx; not found
+SAX.getParameterEntity(zz)
+SAX.entityDecl(tricky, 1, (null), (null), error-prone)
+SAX.getEntity(tricky)
+SAX.externalSubset(test, , )
+SAX.startElementNs(test, NULL, NULL, 0, 0, 0)
 SAX.characters(This sample shows a , 20)
 SAX.getEntity(tricky)
-SAX.error: Entity 'tricky' not defined
+SAX.characters(error-prone, 11)
 SAX.reference(tricky)
 SAX.characters( method., 8)
+SAX.endElementNs(test, NULL, NULL)
 SAX.endDocument()
-xmlSAXUserParseFile returned error 27
index 7aa3e1c..bafdcde 100644 (file)
@@ -1,6 +1,3 @@
-./test/xmlid/id_tst3.xml:1: namespace error : Failed to parse QName 'f:o:'
+./test/xmlid/id_tst3.xml:1: namespace error : Failed to parse QName 'f:o:o'
 <f:o:o xml:id="bar"/>
-    ^
-./test/xmlid/id_tst3.xml:1: namespace error : Namespace prefix f on o:o is not defined
-<f:o:o xml:id="bar"/>
-                   ^
+      ^
index 483490a..a36a5f3 100644 (file)
@@ -6,16 +6,11 @@
  * daniel@veillard.com
  */
 
-#include "libxml.h"
+#include "config.h"
 #include <stdio.h>
-
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
@@ -206,9 +201,6 @@ static xmlXPathContextPtr ctxtXPath;
 
 static void
 initializeLibxml2(void) {
-    xmlGetWarningsDefaultValue = 0;
-    xmlPedanticParserDefault(0);
-
     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
     xmlInitParser();
     xmlSetExternalEntityLoader(testExternalEntityLoader);
@@ -527,7 +519,6 @@ xsdTestCase(xmlNodePtr tst) {
            if ((mem != xmlMemUsed()) && (extraMemoryFromResolver == 0)) {
                test_log("Validation of instance line %ld leaked %d\n",
                        xmlGetLineNo(tmp), xmlMemUsed() - mem);
-               xmlMemoryDump();
                nb_leaks++;
            }
        }
@@ -582,7 +573,6 @@ xsdTestCase(xmlNodePtr tst) {
            if ((mem != xmlMemUsed()) && (extraMemoryFromResolver == 0)) {
                test_log("Validation of instance line %ld leaked %d\n",
                        xmlGetLineNo(tmp), xmlMemUsed() - mem);
-               xmlMemoryDump();
                nb_leaks++;
            }
        }
@@ -1054,13 +1044,19 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     old_tests = nb_tests;
     old_leaks = nb_leaks;
     xsdTest();
-    if ((nb_errors == old_errors) && (nb_leaks == old_leaks))
-       printf("Ran %d tests, no errors\n", nb_tests - old_tests);
-    else
-       printf("Ran %d tests, %d errors, %d leaks\n",
-              nb_tests - old_tests,
-              nb_errors - old_errors,
-              nb_leaks - old_leaks);
+    printf("Ran %d tests, %d errors, %d leaks\n",
+           nb_tests - old_tests,
+           nb_errors - old_errors,
+           nb_leaks - old_leaks);
+    if (nb_errors - old_errors == 10) {
+        printf("10 errors were expected\n");
+        nb_errors = old_errors;
+    } else {
+        printf("10 errors were expected, got %d errors\n",
+               nb_errors - old_errors);
+        nb_errors = old_errors + 1;
+    }
+
     old_errors = nb_errors;
     old_tests = nb_tests;
     old_leaks = nb_leaks;
@@ -1072,6 +1068,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_tests - old_tests,
               nb_errors - old_errors,
               nb_leaks - old_leaks);
+
     old_errors = nb_errors;
     old_tests = nb_tests;
     old_leaks = nb_leaks;
@@ -1083,6 +1080,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_tests - old_tests,
               nb_errors - old_errors,
               nb_leaks - old_leaks);
+
     old_errors = nb_errors;
     old_tests = nb_tests;
     old_leaks = nb_leaks;
@@ -1100,6 +1098,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_errors - old_errors,
               nb_internals,
               nb_leaks - old_leaks);
+
     old_errors = nb_errors;
     old_tests = nb_tests;
     old_leaks = nb_leaks;
@@ -1107,16 +1106,20 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     nb_schematas = 0;
     xstcMetadata("xstc/Tests/Metadata/SunXMLSchema1-0-20020116.testSet",
                 "xstc/Tests/");
-    if ((nb_errors == old_errors) && (nb_leaks == old_leaks))
+    if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) {
        printf("Ran %d tests (%d schemata), no errors\n",
               nb_tests - old_tests, nb_schematas);
-    else
+    } else {
        printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n",
               nb_tests - old_tests,
               nb_schematas,
               nb_errors - old_errors,
               nb_internals,
               nb_leaks - old_leaks);
+        printf("Some errors were expected.\n");
+        nb_errors = old_errors;
+    }
+
     old_errors = nb_errors;
     old_tests = nb_tests;
     old_leaks = nb_leaks;
@@ -1124,16 +1127,19 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     nb_schematas = 0;
     xstcMetadata("xstc/Tests/Metadata/MSXMLSchema1-0-20020116.testSet",
                 "xstc/Tests/");
-    if ((nb_errors == old_errors) && (nb_leaks == old_leaks))
+    if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) {
        printf("Ran %d tests (%d schemata), no errors\n",
               nb_tests - old_tests, nb_schematas);
-    else
+    } else {
        printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n",
               nb_tests - old_tests,
               nb_schematas,
               nb_errors - old_errors,
               nb_internals,
               nb_leaks - old_leaks);
+        printf("Some errors were expected.\n");
+        nb_errors = old_errors;
+    }
 
     if ((nb_errors == 0) && (nb_leaks == 0)) {
         ret = 0;
@@ -1146,7 +1152,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     }
     xmlXPathFreeContext(ctxtXPath);
     xmlCleanupParser();
-    xmlMemoryDump();
 
     if (logfile != NULL)
         fclose(logfile);
index 8626b91..c78eec8 100644 (file)
--- a/runtest.c
+++ b/runtest.c
 
 #include "libxml.h"
 #include <stdio.h>
-
-#if !defined(_WIN32)
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
 #ifdef LIBXML_HTML_ENABLED
 #include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
-
-/*
- * pseudo flag for the unification of HTML and XML tests
- */
-#define XML_PARSE_HTML 1 << 24
 #endif
 
 #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
-#include <libxml/globals.h>
 #include <libxml/threads.h>
 #include <libxml/parser.h>
 #include <libxml/catalog.h>
-#include <string.h>
 #endif
 
 /*
+ * pseudo flag for the unification of HTML and XML tests
+ */
+#define XML_PARSE_HTML 1 << 24
+
+/*
  * O_BINARY is just for Windows compatibility - if it isn't defined
  * on this system, avoid any compilation error
  */
@@ -111,7 +110,6 @@ static int checkTestFile(const char *filename);
 #if defined(_WIN32)
 
 #include <windows.h>
-#include <io.h>
 
 typedef struct
 {
@@ -247,7 +245,7 @@ testExternalEntityLoader(const char *URL, const char *ID,
 static char testErrors[32769];
 static int testErrorsSize = 0;
 
-static void XMLCDECL
+static void
 testErrorHandler(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
     int res;
@@ -269,7 +267,7 @@ testErrorHandler(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
     testErrors[testErrorsSize] = 0;
 }
 
-static void XMLCDECL
+static void
 channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
     int res;
@@ -292,7 +290,7 @@ channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
 }
 
 /**
- * xmlParserPrintFileContext:
+ * xmlParserPrintFileContextInternal:
  * @input:  an xmlParserInputPtr input
  *
  * Displays current context within the input content for error tracking
@@ -301,12 +299,14 @@ channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
 static void
 xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
                xmlGenericErrorFunc chanl, void *data ) {
-    const xmlChar *cur, *base;
+    const xmlChar *cur, *base, *start;
     unsigned int n, col;       /* GCC warns if signed, because compared with sizeof() */
     xmlChar  content[81]; /* space for 80 chars + line terminator */
     xmlChar *ctnt;
 
-    if (input == NULL) return;
+    if ((input == NULL) || (input->cur == NULL))
+        return;
+
     cur = input->cur;
     base = input->base;
     /* skip backwards over any end-of-lines */
@@ -316,21 +316,32 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
     n = 0;
     /* search backwards for beginning-of-line (to max buff size) */
     while ((n++ < (sizeof(content)-1)) && (cur > base) &&
-   (*(cur) != '\n') && (*(cur) != '\r'))
+          (*(cur) != '\n') && (*(cur) != '\r'))
         cur--;
-    if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
+    if ((*(cur) == '\n') || (*(cur) == '\r')) {
+        cur++;
+    } else {
+        /* skip over continuation bytes */
+        while ((cur < input->cur) && ((*cur & 0xC0) == 0x80))
+            cur++;
+    }
     /* calculate the error position in terms of the current position */
     col = input->cur - cur;
     /* search forward for end-of-line (to max buff size) */
     n = 0;
-    ctnt = content;
+    start = cur;
     /* copy selected text to our buffer */
-    while ((*cur != 0) && (*(cur) != '\n') &&
-   (*(cur) != '\r') && (n < sizeof(content)-1)) {
-               *ctnt++ = *cur++;
-       n++;
+    while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r')) {
+        int len = input->end - cur;
+        int c = xmlGetUTF8Char(cur, &len);
+
+        if ((c < 0) || (n + len > sizeof(content)-1))
+            break;
+        cur += len;
+       n += len;
     }
-    *ctnt = 0;
+    memcpy(content, start, n);
+    content[n] = 0;
     /* print out the selected text */
     chanl(data ,"%s\n", content);
     /* create blank line with problem pointer */
@@ -348,7 +359,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
 }
 
 static void
-testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
+testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, const xmlError *err) {
     char *file = NULL;
     int line = 0;
     int code = -1;
@@ -406,7 +417,11 @@ testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
         else if ((line != 0) && (domain == XML_FROM_PARSER))
             channel(data, "Entity: line %d: ", line);
     }
-    if (name != NULL) {
+    /*
+     * Skip element name when testing schemas to make memory and streaming
+     * output match.
+     */
+    if ((domain != XML_FROM_SCHEMASV) && (name != NULL)) {
         channel(data, "element %s: ", name);
     }
     if (code == XML_ERR_OK)
@@ -531,10 +546,16 @@ testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
 
 static void
 initializeLibxml2(void) {
-    xmlPedanticParserDefault(0);
-
-    xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
+    /*
+     * This verifies that xmlInitParser doesn't allocate memory with
+     * xmlMalloc
+     */
+    xmlFree = NULL;
+    xmlMalloc = NULL;
+    xmlRealloc = NULL;
+    xmlMemStrdup = NULL;
     xmlInitParser();
+    xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
     xmlSetExternalEntityLoader(testExternalEntityLoader);
     xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
 #ifdef LIBXML_SCHEMAS_ENABLED
@@ -818,6 +839,12 @@ static xmlSAXHandler emptySAXHandlerStruct = {
     NULL  /* xmlStructuredErrorFunc */
 };
 
+typedef struct {
+    const char *filename;
+    xmlHashTablePtr generalEntities;
+    xmlHashTablePtr parameterEntities;
+} debugContext;
+
 static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
 static int callbacks = 0;
 static int quiet = 0;
@@ -976,13 +1003,16 @@ resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
  * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
  */
 static xmlEntityPtr
-getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
+getEntityDebug(void *ctx, const xmlChar *name)
 {
+    debugContext *ctxt = ctx;
+
     callbacks++;
     if (quiet)
        return(NULL);
     fprintf(SAXdebug, "SAX.getEntity(%s)\n", name);
-    return(NULL);
+
+    return(xmlHashLookup(ctxt->generalEntities, name));
 }
 
 /**
@@ -995,13 +1025,16 @@ getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
  * Returns the xmlParserInputPtr
  */
 static xmlEntityPtr
-getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
+getParameterEntityDebug(void *ctx, const xmlChar *name)
 {
+    debugContext *ctxt = ctx;
+
     callbacks++;
     if (quiet)
        return(NULL);
     fprintf(SAXdebug, "SAX.getParameterEntity(%s)\n", name);
-    return(NULL);
+
+    return(xmlHashLookup(ctxt->parameterEntities, name));
 }
 
 
@@ -1017,10 +1050,13 @@ getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
  * An entity definition has been parsed
  */
 static void
-entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
+entityDeclDebug(void *ctx, const xmlChar *name, int type,
           const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 {
-const xmlChar *nullstr = BAD_CAST "(null)";
+    debugContext *ctxt = ctx;
+    xmlEntityPtr ent;
+    const xmlChar *nullstr = BAD_CAST "(null)";
+
     /* not all libraries handle printing null pointers nicely */
     if (publicId == NULL)
         publicId = nullstr;
@@ -1033,6 +1069,16 @@ const xmlChar *nullstr = BAD_CAST "(null)";
        return;
     fprintf(SAXdebug, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
             name, type, publicId, systemId, content);
+
+    ent = xmlNewEntity(NULL, name, type, publicId, systemId, content);
+    if (systemId != NULL)
+        ent->URI = xmlBuildURI(systemId, (const xmlChar *) ctxt->filename);
+
+    if ((type == XML_INTERNAL_PARAMETER_ENTITY) ||
+        (type == XML_EXTERNAL_PARAMETER_ENTITY))
+        xmlHashAddEntry(ctxt->parameterEntities, name, ent);
+    else
+        xmlHashAddEntry(ctxt->generalEntities, name, ent);
 }
 
 /**
@@ -1353,7 +1399,7 @@ commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
  * Display and format a warning messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1376,7 +1422,7 @@ warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
  * Display and format a error messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1399,7 +1445,7 @@ errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
  * Display and format a fatalError messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1690,6 +1736,13 @@ static xmlSAXHandler debugHTMLSAXHandlerStruct = {
 static xmlSAXHandlerPtr debugHTMLSAXHandler = &debugHTMLSAXHandlerStruct;
 #endif /* LIBXML_HTML_ENABLED */
 
+static void
+hashFreeEntity(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlEntityPtr ent = payload;
+
+    xmlFreeEntity(ent);
+}
+
 /**
  * saxParseTest:
  * @filename: the file to parse
@@ -1726,7 +1779,11 @@ saxParseTest(const char *filename, const char *result,
 
 #ifdef LIBXML_HTML_ENABLED
     if (options & XML_PARSE_HTML) {
-       htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL);
+        htmlParserCtxtPtr ctxt;
+
+        ctxt = htmlNewSAXParserCtxt(emptySAXHandler, NULL);
+        htmlCtxtReadFile(ctxt, filename, NULL, options);
+        htmlFreeParserCtxt(ctxt);
        ret = 0;
     } else
 #endif
@@ -1750,21 +1807,33 @@ saxParseTest(const char *filename, const char *result,
     }
 #ifdef LIBXML_HTML_ENABLED
     if (options & XML_PARSE_HTML) {
-       htmlSAXParseFile(filename, NULL, debugHTMLSAXHandler, NULL);
+        htmlParserCtxtPtr ctxt;
+
+        ctxt = htmlNewSAXParserCtxt(debugHTMLSAXHandler, NULL);
+        htmlCtxtReadFile(ctxt, filename, NULL, options);
+        htmlFreeParserCtxt(ctxt);
        ret = 0;
     } else
 #endif
     {
+        debugContext userData;
         xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(filename);
+
         if (options & XML_PARSE_SAX1) {
             memcpy(ctxt->sax, debugSAXHandler, sizeof(xmlSAXHandler));
             options -= XML_PARSE_SAX1;
         } else {
             memcpy(ctxt->sax, debugSAX2Handler, sizeof(xmlSAXHandler));
         }
+        userData.filename = filename;
+        userData.generalEntities = xmlHashCreate(0);
+        userData.parameterEntities = xmlHashCreate(0);
+        ctxt->userData = &userData;
         xmlCtxtUseOptions(ctxt, options);
         xmlParseDocument(ctxt);
         ret = ctxt->wellFormed ? 0 : ctxt->errNo;
+        xmlHashFree(userData.generalEntities, hashFreeEntity);
+        xmlHashFree(userData.parameterEntities, hashFreeEntity);
         xmlFreeDoc(ctxt->myDoc);
         xmlFreeParserCtxt(ctxt);
     }
@@ -1963,6 +2032,312 @@ pushParseTest(const char *filename, const char *result,
     }
     return(0);
 }
+
+static int pushBoundaryCount;
+static int pushBoundaryRefCount;
+static int pushBoundaryCharsCount;
+static int pushBoundaryCDataCount;
+
+static void
+internalSubsetBnd(void *ctx, const xmlChar *name, const xmlChar *externalID,
+                  const xmlChar *systemID) {
+    pushBoundaryCount++;
+    xmlSAX2InternalSubset(ctx, name, externalID, systemID);
+}
+
+static void
+referenceBnd(void *ctx, const xmlChar *name) {
+    pushBoundaryRefCount++;
+    xmlSAX2Reference(ctx, name);
+}
+
+static void
+charactersBnd(void *ctx, const xmlChar *ch, int len) {
+    pushBoundaryCount++;
+    pushBoundaryCharsCount++;
+    xmlSAX2Characters(ctx, ch, len);
+}
+
+static void
+cdataBlockBnd(void *ctx, const xmlChar *ch, int len) {
+    pushBoundaryCount++;
+    pushBoundaryCDataCount++;
+    xmlSAX2CDataBlock(ctx, ch, len);
+}
+
+static void
+processingInstructionBnd(void *ctx, const xmlChar *target,
+                         const xmlChar *data) {
+    pushBoundaryCount++;
+    xmlSAX2ProcessingInstruction(ctx, target, data);
+}
+
+static void
+commentBnd(void *ctx, const xmlChar *value) {
+    xmlParserCtxtPtr ctxt = ctx;
+    if (ctxt->inSubset == 0)
+        pushBoundaryCount++;
+    xmlSAX2Comment(ctx, value);
+}
+
+static void
+startElementBnd(void *ctx, const xmlChar *xname, const xmlChar **atts) {
+    const char *name = (const char *)xname;
+
+    /* Some elements might be created automatically. */
+    if ((strcmp(name, "html") != 0) &&
+        (strcmp(name, "body") != 0) &&
+        (strcmp(name, "head") != 0) &&
+        (strcmp(name, "p") != 0)) {
+        pushBoundaryCount++;
+    }
+    xmlSAX2StartElement(ctx, xname, atts);
+}
+
+static void
+endElementBnd(void *ctx, const xmlChar *name) {
+    /*pushBoundaryCount++;*/
+    xmlSAX2EndElement(ctx, name);
+}
+
+static void
+startElementNsBnd(void *ctx, const xmlChar *localname, const xmlChar *prefix,
+                  const xmlChar *URI, int nb_namespaces,
+                  const xmlChar **namespaces, int nb_attributes,
+                  int nb_defaulted, const xmlChar **attributes) {
+    pushBoundaryCount++;
+    xmlSAX2StartElementNs(ctx, localname, prefix, URI, nb_namespaces,
+                          namespaces, nb_attributes, nb_defaulted, attributes);
+}
+
+static void
+endElementNsBnd(void *ctx, const xmlChar *localname, const xmlChar *prefix,
+                const xmlChar *URI) {
+    /*pushBoundaryCount++;*/
+    xmlSAX2EndElementNs(ctx, localname, prefix, URI);
+}
+
+/**
+ * pushBoundaryTest:
+ * @filename: the file to parse
+ * @result: the file with expected result
+ * @err: the file with error messages: unused
+ *
+ * Test whether the push parser detects boundaries between syntactical
+ * elements correctly.
+ *
+ * Returns 0 in case of success, an error code otherwise
+ */
+static int
+pushBoundaryTest(const char *filename, const char *result,
+                 const char *err ATTRIBUTE_UNUSED,
+                 int options) {
+    xmlParserCtxtPtr ctxt;
+    xmlDocPtr doc;
+    xmlSAXHandler bndSAX;
+    const char *base;
+    int size, res, numCallbacks;
+    int cur = 0;
+    unsigned long avail, oldConsumed, consumed;
+
+    /*
+     * HTML encoding detection doesn't work when data is fed bytewise.
+     */
+    if (strcmp(filename, "./test/HTML/xml-declaration-1.html") == 0)
+        return(0);
+
+    /*
+     * If the parser made progress, check that exactly one construct was
+     * processed and that the input buffer is (almost) empty.
+     * Since we use a chunk size of 1, this tests whether content is
+     * processed as early as possible.
+     */
+
+    nb_tests++;
+
+    memset(&bndSAX, 0, sizeof(bndSAX));
+#ifdef LIBXML_HTML_ENABLED
+    if (options & XML_PARSE_HTML) {
+        xmlSAX2InitHtmlDefaultSAXHandler(&bndSAX);
+        bndSAX.startElement = startElementBnd;
+        bndSAX.endElement = endElementBnd;
+    } else
+#endif
+    {
+        xmlSAXVersion(&bndSAX, 2);
+        bndSAX.startElementNs = startElementNsBnd;
+        bndSAX.endElementNs = endElementNsBnd;
+    }
+
+    bndSAX.internalSubset = internalSubsetBnd;
+    bndSAX.reference = referenceBnd;
+    bndSAX.characters = charactersBnd;
+    bndSAX.cdataBlock = cdataBlockBnd;
+    bndSAX.processingInstruction = processingInstructionBnd;
+    bndSAX.comment = commentBnd;
+
+    /*
+     * load the document in memory and work from there.
+     */
+    if (loadMem(filename, &base, &size) != 0) {
+        fprintf(stderr, "Failed to load %s\n", filename);
+       return(-1);
+    }
+
+#ifdef LIBXML_HTML_ENABLED
+    if (options & XML_PARSE_HTML)
+       ctxt = htmlCreatePushParserCtxt(&bndSAX, NULL, base, 1, filename,
+                                       XML_CHAR_ENCODING_NONE);
+    else
+#endif
+    ctxt = xmlCreatePushParserCtxt(&bndSAX, NULL, base, 1, filename);
+    xmlCtxtUseOptions(ctxt, options);
+    cur = 1;
+    consumed = 0;
+    numCallbacks = 0;
+    avail = 0;
+    while ((cur < size) && (numCallbacks <= 1) && (avail <= 0)) {
+        int terminate = (cur + 1 >= size);
+        int isText = 0;
+
+        if (ctxt->instate == XML_PARSER_CONTENT) {
+            int firstChar = (ctxt->input->end > ctxt->input->cur) ?
+                            *ctxt->input->cur :
+                            base[cur];
+
+            if ((firstChar != '<') &&
+                ((options & XML_PARSE_HTML) || (firstChar != '&')))
+                isText = 1;
+        }
+
+        oldConsumed = ctxt->input->consumed +
+                      (unsigned long) (ctxt->input->cur - ctxt->input->base);
+
+        pushBoundaryCount = 0;
+        pushBoundaryRefCount = 0;
+        pushBoundaryCharsCount = 0;
+        pushBoundaryCDataCount = 0;
+
+#ifdef LIBXML_HTML_ENABLED
+        if (options & XML_PARSE_HTML)
+            htmlParseChunk(ctxt, base + cur, 1, terminate);
+        else
+#endif
+        xmlParseChunk(ctxt, base + cur, 1, terminate);
+       cur += 1;
+
+        /*
+         * Callback check: Check that only a single construct was parsed.
+         */
+        if (pushBoundaryRefCount > 0) {
+            numCallbacks = 1;
+        } else {
+            numCallbacks = pushBoundaryCount;
+            if (pushBoundaryCharsCount > 1) {
+                if (options & XML_PARSE_HTML) {
+                    /*
+                     * The HTML parser can generate a mix of chars and
+                     * references.
+                     */
+                    numCallbacks -= pushBoundaryCharsCount - 1;
+                } else {
+                    /*
+                     * Allow two chars callbacks. This can happen when
+                     * multi-byte chars are split across buffer boundaries.
+                     */
+                    numCallbacks -= 1;
+                }
+            }
+            if (options & XML_PARSE_HTML) {
+                /*
+                 * Allow multiple cdata callbacks in HTML mode.
+                 */
+                if (pushBoundaryCDataCount > 1)
+                    numCallbacks -= pushBoundaryCDataCount - 1;
+            }
+        }
+
+        /*
+         * Buffer check: If input was consumed, check that the input
+         * buffer is (almost) empty.
+         */
+        consumed = ctxt->input->consumed +
+                   (unsigned long) (ctxt->input->cur - ctxt->input->base);
+        if ((ctxt->instate != XML_PARSER_DTD) &&
+            (consumed >= 4) &&
+            (consumed != oldConsumed)) {
+            size_t max = 0;
+
+            avail = ctxt->input->end - ctxt->input->cur;
+
+            if ((options & XML_PARSE_HTML) &&
+                (ctxt->instate == XML_PARSER_END_TAG)) {
+                /* Something related to script parsing. */
+                max = 3;
+            } else if (isText) {
+                int c = *ctxt->input->cur;
+
+                /* 3 bytes for partial UTF-8 */
+                max = ((c == '<') || (c == '&')) ? 1 : 3;
+            } else if (ctxt->instate == XML_PARSER_CDATA_SECTION) {
+                /* 2 bytes for terminator, 3 bytes for UTF-8 */
+                max = 5;
+            }
+
+            if (avail <= max)
+                avail = 0;
+        }
+    }
+    doc = ctxt->myDoc;
+#ifdef LIBXML_HTML_ENABLED
+    if (options & XML_PARSE_HTML)
+        res = 1;
+    else
+#endif
+    res = ctxt->wellFormed;
+    xmlFreeParserCtxt(ctxt);
+    free((char *)base);
+    if (numCallbacks > 1) {
+       xmlFreeDoc(doc);
+       fprintf(stderr, "Failed push boundary callback test (%d@%lu-%lu): %s\n",
+                numCallbacks, oldConsumed, consumed, filename);
+       return(-1);
+    }
+    if (avail > 0) {
+       xmlFreeDoc(doc);
+       fprintf(stderr, "Failed push boundary buffer test (%lu@%lu): %s\n",
+                avail, consumed, filename);
+       return(-1);
+    }
+    if (!res) {
+       xmlFreeDoc(doc);
+       fprintf(stderr, "Failed to parse %s\n", filename);
+       return(-1);
+    }
+#ifdef LIBXML_HTML_ENABLED
+    if (options & XML_PARSE_HTML)
+       htmlDocDumpMemory(doc, (xmlChar **) &base, &size);
+    else
+#endif
+    xmlDocDumpMemory(doc, (xmlChar **) &base, &size);
+    xmlFreeDoc(doc);
+    res = compareFileMem(result, base, size);
+    if ((base == NULL) || (res != 0)) {
+       if (base != NULL)
+           xmlFree((char *)base);
+        fprintf(stderr, "Result for %s failed in %s\n", filename, result);
+       return(-1);
+    }
+    xmlFree((char *)base);
+    if (err != NULL) {
+       res = compareFileMem(err, testErrors, testErrorsSize);
+       if (res != 0) {
+           fprintf(stderr, "Error for %s failed\n", filename);
+           return(-1);
+       }
+    }
+    return(0);
+}
 #endif
 
 /**
@@ -2095,7 +2470,10 @@ errParseTest(const char *filename, const char *result, const char *err,
 #ifdef LIBXML_XINCLUDE_ENABLED
     if (options & XML_PARSE_XINCLUDE) {
        doc = xmlReadFile(filename, NULL, options);
-       xmlXIncludeProcessFlags(doc, options);
+       if (xmlXIncludeProcessFlags(doc, options) < 0) {
+           xmlFreeDoc(doc);
+            doc = NULL;
+        }
     } else
 #endif
     {
@@ -2138,6 +2516,7 @@ errParseTest(const char *filename, const char *result, const char *err,
     return(0);
 }
 
+#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_HTML_ENABLED)
 /**
  * fdParseTest:
  * @filename: the file to parse
@@ -2202,7 +2581,7 @@ fdParseTest(const char *filename, const char *result, const char *err,
 
     return(0);
 }
-
+#endif
 
 
 #ifdef LIBXML_READER_ENABLED
@@ -2420,12 +2799,11 @@ ignoreGenericError(void *ctx ATTRIBUTE_UNUSED,
 
 static void
 testXPath(const char *str, int xptr, int expr) {
-    xmlGenericErrorFunc handler = ignoreGenericError;
     xmlXPathObjectPtr res;
     xmlXPathContextPtr ctxt;
 
     /* Don't print generic errors to stderr. */
-    initGenericErrorDefaultFunc(&handler);
+    xmlSetGenericErrorFunc(NULL, ignoreGenericError);
 
     nb_tests++;
 #if defined(LIBXML_XPTR_ENABLED)
@@ -2457,7 +2835,7 @@ testXPath(const char *str, int xptr, int expr) {
     xmlXPathFreeContext(ctxt);
 
     /* Reset generic error handler. */
-    initGenericErrorDefaultFunc(NULL);
+    xmlSetGenericErrorFunc(NULL, NULL);
 }
 
 /**
@@ -3066,59 +3444,81 @@ static int
 schemasOneTest(const char *sch,
                const char *filename,
                const char *result,
+               const char *err,
               int options,
               xmlSchemaPtr schemas) {
-    xmlDocPtr doc;
-    xmlSchemaValidCtxtPtr ctxt;
     int ret = 0;
-    int validResult = 0;
+    int i;
     char *temp;
-    FILE *schemasOutput;
-
-    doc = xmlReadFile(filename, NULL, options);
-    if (doc == NULL) {
-        fprintf(stderr, "failed to parse instance %s for %s\n", filename, sch);
-       return(-1);
-    }
+    int parseErrorsSize = testErrorsSize;
 
     temp = resultFilename(result, temp_directory, ".res");
     if (temp == NULL) {
         fprintf(stderr, "Out of memory\n");
         fatalError();
-    }
-    schemasOutput = fopen(temp, "wb");
-    if (schemasOutput == NULL) {
-       fprintf(stderr, "failed to open output file %s\n", temp);
-       xmlFreeDoc(doc);
-        free(temp);
-       return(-1);
+        return(-1);
     }
 
-    ctxt = xmlSchemaNewValidCtxt(schemas);
-    xmlSchemaSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt);
-    validResult = xmlSchemaValidateDoc(ctxt, doc);
-    if (validResult == 0) {
-       fprintf(schemasOutput, "%s validates\n", filename);
-    } else if (validResult > 0) {
-       fprintf(schemasOutput, "%s fails to validate\n", filename);
-    } else {
-       fprintf(schemasOutput, "%s validation generated an internal error\n",
-              filename);
-    }
-    fclose(schemasOutput);
-    if (result) {
-       if (compareFiles(temp, result)) {
-           fprintf(stderr, "Result for %s on %s failed\n", filename, sch);
-           ret = 1;
-       }
-    }
-    if (temp != NULL) {
+    /*
+     * Test both memory and streaming validation.
+     */
+    for (i = 0; i < 2; i++) {
+        xmlSchemaValidCtxtPtr ctxt;
+        int validResult = 0;
+        FILE *schemasOutput;
+
+        testErrorsSize = parseErrorsSize;
+        testErrors[parseErrorsSize] = 0;
+
+        ctxt = xmlSchemaNewValidCtxt(schemas);
+        xmlSchemaSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt);
+
+        schemasOutput = fopen(temp, "wb");
+        if (schemasOutput == NULL) {
+            fprintf(stderr, "failed to open output file %s\n", temp);
+            free(temp);
+            return(-1);
+        }
+
+        if (i == 0) {
+            xmlDocPtr doc;
+
+            doc = xmlReadFile(filename, NULL, options);
+            if (doc == NULL) {
+                fprintf(stderr, "failed to parse instance %s for %s\n", filename, sch);
+                return(-1);
+            }
+            validResult = xmlSchemaValidateDoc(ctxt, doc);
+            xmlFreeDoc(doc);
+        } else {
+            validResult = xmlSchemaValidateFile(ctxt, filename, options);
+        }
+
+        if (validResult == 0) {
+            fprintf(schemasOutput, "%s validates\n", filename);
+        } else if (validResult > 0) {
+            fprintf(schemasOutput, "%s fails to validate\n", filename);
+        } else {
+            fprintf(schemasOutput, "%s validation generated an internal error\n",
+                   filename);
+        }
+        fclose(schemasOutput);
+        if (result) {
+            if (compareFiles(temp, result)) {
+                fprintf(stderr, "Result for %s on %s failed\n", filename, sch);
+                ret = 1;
+            }
+        }
+        if (compareFileMem(err, testErrors, testErrorsSize)) {
+            fprintf(stderr, "Error for %s on %s failed\n", filename, sch);
+            ret = 1;
+        }
+
         unlink(temp);
-        free(temp);
+        xmlSchemaFreeValidCtxt(ctxt);
     }
 
-    xmlSchemaFreeValidCtxt(ctxt);
-    xmlFreeDoc(doc);
+    free(temp);
     return(ret);
 }
 /**
@@ -3210,15 +3610,11 @@ schemasTest(const char *filename,
        }
        if (schemas != NULL) {
            nb_tests++;
-           ret = schemasOneTest(filename, instance, result, options, schemas);
+           ret = schemasOneTest(filename, instance, result, err,
+                                 options, schemas);
            if (ret != 0)
                res = ret;
        }
-        if (compareFileMem(err, testErrors, testErrorsSize)) {
-            fprintf(stderr, "Error for %s on %s failed\n", instance,
-                    filename);
-            res = 1;
-        }
     }
     globfree(&globbuf);
     xmlSchemaFree(schemas);
@@ -3713,9 +4109,6 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
     /*
      * load XPath expr as a file
      */
-    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-    xmlSubstituteEntitiesDefault(1);
-
     doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
     if (doc == NULL) {
        fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
@@ -3864,9 +4257,6 @@ c14nRunTest(const char* xml_filename, int with_comments, int mode,
      * build an XML tree from a the file; we need to add default
      * attributes and resolve all character and entities references
      */
-    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-    xmlSubstituteEntitiesDefault(1);
-
     doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
     if (doc == NULL) {
        fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
@@ -4039,13 +4429,6 @@ static xmlThreadParams threadParams[] = {
 static const unsigned int num_threads = sizeof(threadParams) /
                                         sizeof(threadParams[0]);
 
-#ifndef xmlDoValidityCheckingDefaultValue
-#error xmlDoValidityCheckingDefaultValue is not a macro
-#endif
-#ifndef xmlGenericErrorContext
-#error xmlGenericErrorContext is not a macro
-#endif
-
 static void *
 thread_specific_data(void *private_data)
 {
@@ -4054,43 +4437,17 @@ thread_specific_data(void *private_data)
     const char *filename = params->filename;
     int okay = 1;
 
-    if (!strcmp(filename, "test/threads/invalid.xml")) {
-        xmlDoValidityCheckingDefaultValue = 0;
-        xmlGenericErrorContext = stdout;
-    } else {
-        xmlDoValidityCheckingDefaultValue = 1;
-        xmlGenericErrorContext = stderr;
-    }
-#ifdef LIBXML_SAX1_ENABLED
-    myDoc = xmlParseFile(filename);
-#else
-    myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG);
+#ifdef LIBXML_THREAD_ALLOC_ENABLED
+    xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
 #endif
+
+    myDoc = xmlReadFile(filename, NULL, XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
     if (myDoc) {
         xmlFreeDoc(myDoc);
     } else {
         printf("parse failed\n");
         okay = 0;
     }
-    if (!strcmp(filename, "test/threads/invalid.xml")) {
-        if (xmlDoValidityCheckingDefaultValue != 0) {
-            printf("ValidityCheckingDefaultValue override failed\n");
-            okay = 0;
-        }
-        if (xmlGenericErrorContext != stdout) {
-            printf("xmlGenericErrorContext override failed\n");
-            okay = 0;
-        }
-    } else {
-        if (xmlDoValidityCheckingDefaultValue != 1) {
-            printf("ValidityCheckingDefaultValue override failed\n");
-            okay = 0;
-        }
-        if (xmlGenericErrorContext != stderr) {
-            printf("xmlGenericErrorContext override failed\n");
-            okay = 0;
-        }
-    }
     params->okay = okay;
     return(NULL);
 }
@@ -4168,58 +4525,6 @@ testThread(void)
     return (res);
 }
 
-#elif defined __BEOS__
-#include <OS.h>
-
-static thread_id tid[MAX_ARGC];
-
-static int
-testThread(void)
-{
-    unsigned int i, repeat;
-    status_t ret;
-    int res = 0;
-
-    xmlInitParser();
-    for (repeat = 0; repeat < 500; repeat++) {
-        xmlLoadCatalog(catalog);
-        for (i = 0; i < num_threads; i++) {
-            tid[i] = (thread_id) - 1;
-        }
-        for (i = 0; i < num_threads; i++) {
-            tid[i] =
-                spawn_thread(thread_specific_data, "xmlTestThread",
-                             B_NORMAL_PRIORITY, (void *) &threadParams[i]);
-            if (tid[i] < B_OK) {
-                fprintf(stderr, "beos_thread_create failed\n");
-                return (1);
-            }
-            printf("beos_thread_create %d -> %d\n", i, tid[i]);
-        }
-        for (i = 0; i < num_threads; i++) {
-            void *result;
-            ret = wait_for_thread(tid[i], &result);
-            printf("beos_thread_wait %d -> %d\n", i, ret);
-            if (ret != B_OK) {
-                fprintf(stderr, "beos_thread_wait failed\n");
-                return (1);
-            }
-        }
-
-        xmlCatalogCleanup();
-        ret = B_OK;
-        for (i = 0; i < num_threads; i++)
-            if (threadParams[i].okay == 0) {
-                printf("Thread %d handling %s failed\n", i,
-                       threadParams[i].filename);
-                ret = B_ERROR;
-            }
-    }
-    if (ret != B_OK)
-        return(1);
-    return (0);
-}
-
 #elif defined HAVE_PTHREAD_H
 #include <pthread.h>
 
@@ -4316,7 +4621,9 @@ regexpTest(const char *filename, const char *result, const char *err,
     char expression[5000];
     int len, ret, res = 0;
 
-    input = fopen(filename, "r");
+    nb_tests++;
+
+    input = fopen(filename, "rb");
     if (input == NULL) {
         xmlGenericError(xmlGenericErrorContext,
                "Cannot open %s for reading\n", filename);
@@ -4392,7 +4699,246 @@ regexpTest(const char *filename, const char *result, const char *err,
     return(res);
 }
 
-#endif
+#endif /* LIBXML_REGEXPS_ENABLED */
+
+#ifdef LIBXML_AUTOMATA_ENABLED
+/************************************************************************
+ *                                                                     *
+ *                     Automata tests                                  *
+ *                                                                     *
+ ************************************************************************/
+
+static int scanNumber(char **ptr) {
+    int ret = 0;
+    char *cur;
+
+    cur = *ptr;
+    while ((*cur >= '0') && (*cur <= '9')) {
+       ret = ret * 10 + (*cur - '0');
+       cur++;
+    }
+    *ptr = cur;
+    return(ret);
+}
+
+static int
+automataTest(const char *filename, const char *result,
+             const char *err ATTRIBUTE_UNUSED, int options ATTRIBUTE_UNUSED) {
+    FILE *input, *output;
+    char *temp;
+    char expr[5000];
+    int len;
+    int ret;
+    int i;
+    int res = 0;
+    xmlAutomataPtr am;
+    xmlAutomataStatePtr states[1000];
+    xmlRegexpPtr regexp = NULL;
+    xmlRegExecCtxtPtr exec = NULL;
+
+    nb_tests++;
+
+    for (i = 0;i<1000;i++)
+       states[i] = NULL;
+
+    input = fopen(filename, "rb");
+    if (input == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+               "Cannot open %s for reading\n", filename);
+       return(-1);
+    }
+    temp = resultFilename(filename, "", ".res");
+    if (temp == NULL) {
+        fprintf(stderr, "Out of memory\n");
+        fatalError();
+    }
+    output = fopen(temp, "wb");
+    if (output == NULL) {
+       fprintf(stderr, "failed to open output file %s\n", temp);
+        free(temp);
+       return(-1);
+    }
+
+    am = xmlNewAutomata();
+    if (am == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+               "Cannot create automata\n");
+       fclose(input);
+       return(-1);
+    }
+    states[0] = xmlAutomataGetInitState(am);
+    if (states[0] == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+               "Cannot get start state\n");
+       xmlFreeAutomata(am);
+       fclose(input);
+       return(-1);
+    }
+    ret = 0;
+
+    while (fgets(expr, 4500, input) != NULL) {
+       if (expr[0] == '#')
+           continue;
+       len = strlen(expr);
+       len--;
+       while ((len >= 0) &&
+              ((expr[len] == '\n') || (expr[len] == '\t') ||
+               (expr[len] == '\r') || (expr[len] == ' '))) len--;
+       expr[len + 1] = 0;
+       if (len >= 0) {
+           if ((am != NULL) && (expr[0] == 't') && (expr[1] == ' ')) {
+               char *ptr = &expr[2];
+               int from, to;
+
+               from = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               if (states[from] == NULL)
+                   states[from] = xmlAutomataNewState(am);
+               ptr++;
+               to = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               if (states[to] == NULL)
+                   states[to] = xmlAutomataNewState(am);
+               ptr++;
+               xmlAutomataNewTransition(am, states[from], states[to],
+                                        BAD_CAST ptr, NULL);
+           } else if ((am != NULL) && (expr[0] == 'e') && (expr[1] == ' ')) {
+               char *ptr = &expr[2];
+               int from, to;
+
+               from = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               if (states[from] == NULL)
+                   states[from] = xmlAutomataNewState(am);
+               ptr++;
+               to = scanNumber(&ptr);
+               if (states[to] == NULL)
+                   states[to] = xmlAutomataNewState(am);
+               xmlAutomataNewEpsilon(am, states[from], states[to]);
+           } else if ((am != NULL) && (expr[0] == 'f') && (expr[1] == ' ')) {
+               char *ptr = &expr[2];
+               int state;
+
+               state = scanNumber(&ptr);
+               if (states[state] == NULL) {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad state %d : %s\n", state, expr);
+                   break;
+               }
+               xmlAutomataSetFinalState(am, states[state]);
+           } else if ((am != NULL) && (expr[0] == 'c') && (expr[1] == ' ')) {
+               char *ptr = &expr[2];
+               int from, to;
+               int min, max;
+
+               from = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               if (states[from] == NULL)
+                   states[from] = xmlAutomataNewState(am);
+               ptr++;
+               to = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               if (states[to] == NULL)
+                   states[to] = xmlAutomataNewState(am);
+               ptr++;
+               min = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               ptr++;
+               max = scanNumber(&ptr);
+               if (*ptr != ' ') {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Bad line %s\n", expr);
+                   break;
+               }
+               ptr++;
+               xmlAutomataNewCountTrans(am, states[from], states[to],
+                                        BAD_CAST ptr, min, max, NULL);
+           } else if ((am != NULL) && (expr[0] == '-') && (expr[1] == '-')) {
+               /* end of the automata */
+               regexp = xmlAutomataCompile(am);
+               xmlFreeAutomata(am);
+               am = NULL;
+               if (regexp == NULL) {
+                   xmlGenericError(xmlGenericErrorContext,
+                           "Failed to compile the automata");
+                   break;
+               }
+           } else if ((expr[0] == '=') && (expr[1] == '>')) {
+               if (regexp == NULL) {
+                   fprintf(output, "=> failed not compiled\n");
+               } else {
+                   if (exec == NULL)
+                       exec = xmlRegNewExecCtxt(regexp, NULL, NULL);
+                   if (ret == 0) {
+                       ret = xmlRegExecPushString(exec, NULL, NULL);
+                   }
+                   if (ret == 1)
+                       fprintf(output, "=> Passed\n");
+                   else if ((ret == 0) || (ret == -1))
+                       fprintf(output, "=> Failed\n");
+                   else if (ret < 0)
+                       fprintf(output, "=> Error\n");
+                   xmlRegFreeExecCtxt(exec);
+                   exec = NULL;
+               }
+               ret = 0;
+           } else if (regexp != NULL) {
+               if (exec == NULL)
+                   exec = xmlRegNewExecCtxt(regexp, NULL, NULL);
+               ret = xmlRegExecPushString(exec, BAD_CAST expr, NULL);
+           } else {
+               xmlGenericError(xmlGenericErrorContext,
+                       "Unexpected line %s\n", expr);
+           }
+       }
+    }
+    fclose(output);
+    fclose(input);
+    if (regexp != NULL)
+       xmlRegFreeRegexp(regexp);
+    if (exec != NULL)
+       xmlRegFreeExecCtxt(exec);
+    if (am != NULL)
+       xmlFreeAutomata(am);
+
+    ret = compareFiles(temp, result);
+    if (ret) {
+        fprintf(stderr, "Result for %s failed in %s\n", filename, result);
+        res = 1;
+    }
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
+
+    return(res);
+}
+
+#endif /* LIBXML_AUTOMATA_ENABLED */
 
 /************************************************************************
  *                                                                     *
@@ -4462,6 +5008,9 @@ testDesc testDescriptions[] = {
     { "XML push regression tests" ,
       pushParseTest, "./test/*", "result/", "", NULL,
       0 },
+    { "XML push boundary tests" ,
+      pushBoundaryTest, "./test/*", "result/", "", NULL,
+      0 },
 #endif
 #ifdef LIBXML_HTML_ENABLED
     { "HTML regression tests" ,
@@ -4474,6 +5023,9 @@ testDesc testDescriptions[] = {
     { "Push HTML regression tests" ,
       pushParseTest, "./test/HTML/*", "result/HTML/", "", ".err",
       XML_PARSE_HTML },
+    { "Push HTML boundary tests" ,
+      pushBoundaryTest, "./test/HTML/*", "result/HTML/", "", NULL,
+      XML_PARSE_HTML },
 #endif
     { "HTML SAX regression tests" ,
       saxParseTest, "./test/HTML/*", "result/HTML/", ".sax", NULL,
@@ -4500,25 +5052,24 @@ testDesc testDescriptions[] = {
 #endif
 #ifdef LIBXML_XINCLUDE_ENABLED
     { "XInclude regression tests" ,
-      errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL,
-      /* Ignore errors at this point ".err", */
+      errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", ".err",
       XML_PARSE_XINCLUDE },
 #ifdef LIBXML_READER_ENABLED
     { "XInclude xmlReader regression tests",
       streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr",
-      /* Ignore errors at this point ".err", */
-      NULL, XML_PARSE_XINCLUDE },
+      ".err", XML_PARSE_XINCLUDE },
 #endif
     { "XInclude regression tests stripping include nodes" ,
-      errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL,
-      /* Ignore errors at this point ".err", */
+      errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", ".err",
       XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
 #ifdef LIBXML_READER_ENABLED
     { "XInclude xmlReader regression tests stripping include nodes",
       streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr",
-      /* Ignore errors at this point ".err", */
-      NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
+      ".err", XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
 #endif
+    { "XInclude regression tests without reader",
+      errParseTest, "./test/XInclude/without-reader/*", "result/XInclude/", "",
+      ".err", XML_PARSE_XINCLUDE },
 #endif
 #ifdef LIBXML_XPATH_ENABLED
 #ifdef LIBXML_DEBUG_ENABLED
@@ -4601,6 +5152,11 @@ testDesc testDescriptions[] = {
       regexpTest, "./test/regexp/*", "result/regexp/", "", ".err",
       0 },
 #endif
+#if defined(LIBXML_AUTOMATA_ENABLED)
+    { "Automata regression tests" ,
+      automataTest, "./test/automata/*", "result/automata/", "", NULL,
+      0 },
+#endif
     {NULL, NULL, NULL, NULL, NULL, NULL, 0}
 };
 
@@ -4779,7 +5335,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_tests, nb_errors, nb_leaks);
     }
     xmlCleanupParser();
-    xmlMemoryDump();
 
     return(ret);
 }
index 5e88f80..b5c3fd8 100644 (file)
@@ -6,18 +6,14 @@
  * daniel@veillard.com
  */
 
-#include "libxml.h"
+#include "config.h"
 #include <stdio.h>
+#include <libxml/xmlversion.h>
 
-#ifdef LIBXML_XPATH_ENABLED
+#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_VALID_ENABLED)
 
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
@@ -126,7 +122,7 @@ static void test_log(const char *msg, ...) {
 }
 
 static void
-testErrorHandler(void *userData ATTRIBUTE_UNUSED, xmlErrorPtr error) {
+testErrorHandler(void *userData ATTRIBUTE_UNUSED, const xmlError *error) {
     int res;
 
     if (testErrorsSize >= 32768)
@@ -153,9 +149,6 @@ static xmlXPathContextPtr ctxtXPath;
 
 static void
 initializeLibxml2(void) {
-    xmlGetWarningsDefaultValue = 0;
-    xmlPedanticParserDefault(0);
-
     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
     xmlInitParser();
     xmlSetExternalEntityLoader(testExternalEntityLoader);
@@ -257,8 +250,10 @@ xmlconfTestNotNSWF(const char *id, const char *filename, int options) {
         nb_errors++;
        ret = 0;
     } else {
-       if ((xmlLastError.code == XML_ERR_OK) ||
-           (xmlLastError.domain != XML_FROM_NAMESPACE)) {
+        const xmlError *error = xmlGetLastError();
+
+       if ((error->code == XML_ERR_OK) ||
+           (error->domain != XML_FROM_NAMESPACE)) {
            test_log("test %s : %s failed to detect namespace error\n",
                     id, filename);
            nb_errors++;
@@ -591,7 +586,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     }
     xmlXPathFreeContext(ctxtXPath);
     xmlCleanupParser();
-    xmlMemoryDump();
 
     if (logfile != NULL)
         fclose(logfile);
@@ -599,9 +593,9 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
 }
 
 #else /* ! LIBXML_XPATH_ENABLED */
-#include <stdio.h>
 int
 main(int argc ATTRIBUTE_UNUSED, char **argv) {
-    fprintf(stderr, "%s need XPath support\n", argv[0]);
+    fprintf(stderr, "%s need XPath and validation support\n", argv[0]);
+    return(0);
 }
 #endif
diff --git a/save.h b/save.h
deleted file mode 100644 (file)
index 192b674..0000000
--- a/save.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Summary: Internal Interfaces for saving in libxml2
- * Description: this module describes a few interfaces which were
- *              added along with the API changes in 2.9.0
- *              those are private routines at this point
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-#ifndef __XML_SAVE_H__
-#define __XML_SAVE_H__
-
-#include <libxml/tree.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef LIBXML_OUTPUT_ENABLED
-void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
-                                   xmlAttrPtr attr, const xmlChar * string);
-void xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table);
-void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem);
-void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr);
-void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent);
-#endif
-
-xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __XML_SAVE_H__ */
-
index 68a4c62..a825920 100644 (file)
@@ -25,6 +25,7 @@
 
 #ifdef LIBXML_SCHEMATRON_ENABLED
 
+#include <stdlib.h>
 #include <string.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -34,6 +35,8 @@
 #include <libxml/pattern.h>
 #include <libxml/schematron.h>
 
+#include "private/error.h"
+
 #define SCHEMATRON_PARSE_OPTIONS XML_PARSE_NOENT
 
 #define SCT_OLD_NS BAD_CAST "http://www.ascc.net/xml/schematron"
@@ -1506,11 +1509,12 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
                 int size;
 
                 size = snprintf(NULL, 0, "%0g", eval->floatval);
-                buf = (xmlChar*) malloc(size * sizeof(xmlChar));
-                /* xmlStrPrintf(buf, size, "%0g", eval->floatval); // doesn't work */
-                sprintf((char*) buf, "%0g", eval->floatval);
-                ret = xmlStrcat(ret, buf);
-                free(buf);
+                buf = (xmlChar *) xmlMalloc(size + 1);
+                if (buf != NULL) {
+                    snprintf((char *) buf, size + 1, "%0g", eval->floatval);
+                    ret = xmlStrcat(ret, buf);
+                    xmlFree(buf);
+                }
                 break;
             }
             case XPATH_STRING:
@@ -1584,8 +1588,8 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
         long line;
         const xmlChar *report = NULL;
 
-        if (((test->type == XML_SCHEMATRON_REPORT) & (!success)) ||
-            ((test->type == XML_SCHEMATRON_ASSERT) & (success)))
+        if (((test->type == XML_SCHEMATRON_REPORT) && (!success)) ||
+            ((test->type == XML_SCHEMATRON_ASSERT) && (success)))
             return;
         line = xmlGetLineNo(cur);
         path = xmlGetNodePath(cur);
@@ -2051,7 +2055,6 @@ main(void)
     xmlFreeDoc(instance);
 
     xmlCleanupParser();
-    xmlMemoryDump();
 
     return (0);
 }
diff --git a/test/HTML/names.html b/test/HTML/names.html
new file mode 100644 (file)
index 0000000..0dac7a4
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<body>
+  <o:p></o:p>
+</body>
+</html>
diff --git a/test/HTML/xml-declaration-1.html b/test/HTML/xml-declaration-1.html
new file mode 100644 (file)
index 0000000..1950be7
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml encoding="UTF-8">
+<p>öäüß</p>
diff --git a/test/URI/file.uri b/test/URI/file.uri
new file mode 100644 (file)
index 0000000..8d8b7a7
--- /dev/null
@@ -0,0 +1 @@
+file:///foo.txt
diff --git a/test/URI/port.uri b/test/URI/port.uri
new file mode 100644 (file)
index 0000000..4b22322
--- /dev/null
@@ -0,0 +1,2 @@
+nbd://:10888
+https://example.com:12345/
index a96ea5f..0a2e46f 100644 (file)
@@ -16,3 +16,6 @@ bar?baz#baz2
 http://elsewhere.com/#deep
 http://elsewhere.com/?deep
 http://elsewhere.com/?deep#deep2
+//elsewhere.com/bar
+//elsewhere.com:8080/bar
+//:8080
diff --git a/test/XInclude/docs/invalid_char.xml b/test/XInclude/docs/invalid_char.xml
new file mode 100644 (file)
index 0000000..28e5a48
--- /dev/null
@@ -0,0 +1,3 @@
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+   <xinclude:include href="../ents/invalid_char.txt" parse="text"/>
+</x>
diff --git a/test/XInclude/ents/invalid_char.txt b/test/XInclude/ents/invalid_char.txt
new file mode 100644 (file)
index 0000000..ae06618
--- /dev/null
@@ -0,0 +1 @@
+invalid: Ã¿
\ No newline at end of file
diff --git a/test/XInclude/without-reader/fallback7.xml b/test/XInclude/without-reader/fallback7.xml
new file mode 100644 (file)
index 0000000..7ddf936
--- /dev/null
@@ -0,0 +1,12 @@
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+    <a>text</a>
+    <xi:include xpointer="xpointer(//b)"/>
+    <xi:include href="404.xml">
+        <xi:fallback>
+            <b>
+                <xi:include xpointer="xpointer(//a)"/>
+            </b>
+        </xi:fallback>
+    </xi:include>
+    <xi:include xpointer="xpointer(//b)"/>
+</x>
diff --git a/test/XInclude/without-reader/issue424-1.xml b/test/XInclude/without-reader/issue424-1.xml
new file mode 100644 (file)
index 0000000..8b6aa93
--- /dev/null
@@ -0,0 +1,5 @@
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+   <p>Something</p>
+   <d><xinclude:include xpointer="xpointer(//p)"/></d>
+   <xinclude:include xpointer="xpointer(//d)"/>
+</x>
diff --git a/test/XInclude/without-reader/issue424-2.xml b/test/XInclude/without-reader/issue424-2.xml
new file mode 100644 (file)
index 0000000..e61eaba
--- /dev/null
@@ -0,0 +1,5 @@
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+   <p>Something</p>
+   <xinclude:include xpointer="xpointer(//d)"/>
+   <d><xinclude:include xpointer="xpointer(//p)"/></d>
+</x>
diff --git a/test/XInclude/without-reader/loop.xml b/test/XInclude/without-reader/loop.xml
new file mode 100644 (file)
index 0000000..99a7e0b
--- /dev/null
@@ -0,0 +1,4 @@
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+   <a><xi:include xpointer="xpointer(//b)"/></a>
+   <b><xi:include xpointer="xpointer(//a)"/></b>
+</x>
diff --git a/test/XInclude/without-reader/max-recurse.xml b/test/XInclude/without-reader/max-recurse.xml
new file mode 100644 (file)
index 0000000..cfe14bd
--- /dev/null
@@ -0,0 +1,104 @@
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+<e00><xi:include xpointer="xpointer(//e01)"/></e00>
+<e01><xi:include xpointer="xpointer(//e02)"/></e01>
+<e02><xi:include xpointer="xpointer(//e03)"/></e02>
+<e03><xi:include xpointer="xpointer(//e04)"/></e03>
+<e04><xi:include xpointer="xpointer(//e05)"/></e04>
+<e05><xi:include xpointer="xpointer(//e06)"/></e05>
+<e06><xi:include xpointer="xpointer(//e07)"/></e06>
+<e07><xi:include xpointer="xpointer(//e08)"/></e07>
+<e08><xi:include xpointer="xpointer(//e09)"/></e08>
+<e09><xi:include xpointer="xpointer(//e10)"/></e09>
+<e10><xi:include xpointer="xpointer(//e11)"/></e10>
+<e11><xi:include xpointer="xpointer(//e12)"/></e11>
+<e12><xi:include xpointer="xpointer(//e13)"/></e12>
+<e13><xi:include xpointer="xpointer(//e14)"/></e13>
+<e14><xi:include xpointer="xpointer(//e15)"/></e14>
+<e15><xi:include xpointer="xpointer(//e16)"/></e15>
+<e16><xi:include xpointer="xpointer(//e17)"/></e16>
+<e17><xi:include xpointer="xpointer(//e18)"/></e17>
+<e18><xi:include xpointer="xpointer(//e19)"/></e18>
+<e19><xi:include xpointer="xpointer(//e20)"/></e19>
+<e20><xi:include xpointer="xpointer(//e21)"/></e20>
+<e21><xi:include xpointer="xpointer(//e22)"/></e21>
+<e22><xi:include xpointer="xpointer(//e23)"/></e22>
+<e23><xi:include xpointer="xpointer(//e24)"/></e23>
+<e24><xi:include xpointer="xpointer(//e25)"/></e24>
+<e25><xi:include xpointer="xpointer(//e26)"/></e25>
+<e26><xi:include xpointer="xpointer(//e27)"/></e26>
+<e27><xi:include xpointer="xpointer(//e28)"/></e27>
+<e28><xi:include xpointer="xpointer(//e29)"/></e28>
+<e29><xi:include xpointer="xpointer(//e30)"/></e29>
+<e30><xi:include xpointer="xpointer(//e31)"/></e30>
+<e31><xi:include xpointer="xpointer(//e32)"/></e31>
+<e32><xi:include xpointer="xpointer(//e33)"/></e32>
+<e33><xi:include xpointer="xpointer(//e34)"/></e33>
+<e34><xi:include xpointer="xpointer(//e35)"/></e34>
+<e35><xi:include xpointer="xpointer(//e36)"/></e35>
+<e36><xi:include xpointer="xpointer(//e37)"/></e36>
+<e37><xi:include xpointer="xpointer(//e38)"/></e37>
+<e38><xi:include xpointer="xpointer(//e39)"/></e38>
+<e39><xi:include xpointer="xpointer(//e40)"/></e39>
+<e40><xi:include xpointer="xpointer(//e41)"/></e40>
+<e41><xi:include xpointer="xpointer(//e42)"/></e41>
+<e42><xi:include xpointer="xpointer(//e43)"/></e42>
+<e43><xi:include xpointer="xpointer(//e44)"/></e43>
+<e44><xi:include xpointer="xpointer(//e45)"/></e44>
+<e45><xi:include xpointer="xpointer(//e46)"/></e45>
+<e46><xi:include xpointer="xpointer(//e47)"/></e46>
+<e47><xi:include xpointer="xpointer(//e48)"/></e47>
+<e48><xi:include xpointer="xpointer(//e49)"/></e48>
+<e49><xi:include xpointer="xpointer(//e50)"/></e49>
+<e50><xi:include xpointer="xpointer(//e51)"/></e50>
+<e51><xi:include xpointer="xpointer(//e52)"/></e51>
+<e52><xi:include xpointer="xpointer(//e53)"/></e52>
+<e53><xi:include xpointer="xpointer(//e54)"/></e53>
+<e54><xi:include xpointer="xpointer(//e55)"/></e54>
+<e55><xi:include xpointer="xpointer(//e56)"/></e55>
+<e56><xi:include xpointer="xpointer(//e57)"/></e56>
+<e57><xi:include xpointer="xpointer(//e58)"/></e57>
+<e58><xi:include xpointer="xpointer(//e59)"/></e58>
+<e59><xi:include xpointer="xpointer(//e60)"/></e59>
+<e60><xi:include xpointer="xpointer(//e61)"/></e60>
+<e61><xi:include xpointer="xpointer(//e62)"/></e61>
+<e62><xi:include xpointer="xpointer(//e63)"/></e62>
+<e63><xi:include xpointer="xpointer(//e64)"/></e63>
+<e64><xi:include xpointer="xpointer(//e65)"/></e64>
+<e65><xi:include xpointer="xpointer(//e66)"/></e65>
+<e66><xi:include xpointer="xpointer(//e67)"/></e66>
+<e67><xi:include xpointer="xpointer(//e68)"/></e67>
+<e68><xi:include xpointer="xpointer(//e69)"/></e68>
+<e69><xi:include xpointer="xpointer(//e70)"/></e69>
+<e70><xi:include xpointer="xpointer(//e71)"/></e70>
+<e71><xi:include xpointer="xpointer(//e72)"/></e71>
+<e72><xi:include xpointer="xpointer(//e73)"/></e72>
+<e73><xi:include xpointer="xpointer(//e74)"/></e73>
+<e74><xi:include xpointer="xpointer(//e75)"/></e74>
+<e75><xi:include xpointer="xpointer(//e76)"/></e75>
+<e76><xi:include xpointer="xpointer(//e77)"/></e76>
+<e77><xi:include xpointer="xpointer(//e78)"/></e77>
+<e78><xi:include xpointer="xpointer(//e79)"/></e78>
+<e79><xi:include xpointer="xpointer(//e80)"/></e79>
+<e80><xi:include xpointer="xpointer(//e81)"/></e80>
+<e81><xi:include xpointer="xpointer(//e82)"/></e81>
+<e82><xi:include xpointer="xpointer(//e83)"/></e82>
+<e83><xi:include xpointer="xpointer(//e84)"/></e83>
+<e84><xi:include xpointer="xpointer(//e85)"/></e84>
+<e85><xi:include xpointer="xpointer(//e86)"/></e85>
+<e86><xi:include xpointer="xpointer(//e87)"/></e86>
+<e87><xi:include xpointer="xpointer(//e88)"/></e87>
+<e88><xi:include xpointer="xpointer(//e89)"/></e88>
+<e89><xi:include xpointer="xpointer(//e90)"/></e89>
+<e90><xi:include xpointer="xpointer(//e91)"/></e90>
+<e91><xi:include xpointer="xpointer(//e92)"/></e91>
+<e92><xi:include xpointer="xpointer(//e93)"/></e92>
+<e93><xi:include xpointer="xpointer(//e94)"/></e93>
+<e94><xi:include xpointer="xpointer(//e95)"/></e94>
+<e95><xi:include xpointer="xpointer(//e96)"/></e95>
+<e96><xi:include xpointer="xpointer(//e97)"/></e96>
+<e97><xi:include xpointer="xpointer(//e98)"/></e97>
+<e98><xi:include xpointer="xpointer(//e99)"/></e98>
+<e99><xi:include xpointer="xpointer(//e100)"/></e99>
+<e100><xi:include xpointer="xpointer(//e101)"/></e100>
+<e101/>
+</x>
index 00b9461..6008a07 100644 (file)
@@ -3,6 +3,7 @@ false()
 number("1.5")
 number('abc')
 -number('abc')
+number('-')
 floor(0.1)
 floor(-0.1)
 floor(-0)
diff --git a/test/boundaries1.xml b/test/boundaries1.xml
new file mode 100644 (file)
index 0000000..c4301cd
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE d [
+    <!ENTITY a "]>">
+    <!ENTITY b ']>'>
+    <!--> ]> -->
+]    >
+<?pi p1?>
+<!--> c1 -->
+<d a=">" b='>'>
+text&a;text
+<![CDATA[cdata]]>
+<?pi p2?>
+<!--> c2 -->
+</d>
+<?pi p3?>
+<!--> c3 -->
diff --git a/test/errors/attr5.xml b/test/errors/attr5.xml
new file mode 100644 (file)
index 0000000..4ee864a
--- /dev/null
@@ -0,0 +1,3 @@
+<d xmlns="urn:foo">
+    <a b="" b=""/>
+</d>
diff --git a/test/errors/attr6.xml b/test/errors/attr6.xml
new file mode 100644 (file)
index 0000000..57273d4
--- /dev/null
@@ -0,0 +1,52 @@
+<doc xmlns:a="urn:a" xmlns:b="urn:b" xmlns:c="urn:c" xmlns:d="urn:d">
+<e b:ci="" c:fh="" d:ab="" aq="" c:ew="" bw="" aj="" a:ey="" c:eh="" bq="" b:fc="" et="" a:ao="" c:cc="" b:aa="" a:ei="" a:az="" ej="" b:di="" a:cw="" a:ck="" a:bu="" d:av="" a:dk="" a:ea="" c:ca="" bn="" a:db="" b:eb="" bx="" d:bd="" a:bf="" b:ex="" am="" d:fg="" d:bj="" a:dp="" b:dm="" dd="" a:dx="" a:cj="" b:es="" b:df="" fd="" d:ak="" b:ev="" c:ac="" d:ds="" d:br="" b:dl="" a:at="" c:ed="" a:ad="" cd="" a:fj="" d:eq="" ee="" b:dz="" c:du="" af="" c:dv="" a:dh="" d:ay="" b:ff="" cb="" d:cn="" d:em="" ae="" eo="" bk="" a:cf="" dw="" d:en="" be="" ai="" c:bi="" b:bm="" ce="" d:as="" cr="" d:fe="" dr="" c:ag="" c:dn="" c:cg="" d:ew="" c:ek="" ba="" b:bl="" b:ax="" a:bv="" fn="" b:ar="" d:ez="" eg="" a:ap="" d:fl="" an="" a:dy="" bb="" a:ct="" dt="" cu="" b:ef="" c:fb="" b:dg="" c:au="" d:bc="" c:el="" b:cz="" a:al="" d:fi="" a:dc="" d:bg="" d:de="" cx="" do="" b:bh="" d:dq="" ch="" b:da="" a:bz="" b:cs="" c:cv="" fm="" c:bo="" b:cl="" c:bs="" a:cp="" aw="" c:fa="" a:cv="" d:cm="" dj="" ep="" ec="" bt="" by="" co="" c:bp="" a:cy="" ah="" c:fk="" d:cq="" b:er="" a:eu=""/>
+<e d:bf="" ap="" b:cv="" an="" eu="" a:bc="" a:fd="" c:aw="" b:au="" es="" a:eb="" b:fm="" b:eg="" al="" a:av="" c:bm="" d:fb="" d:fl="" fk="" a:ej="" dn="" c:aa="" dj="" bj="" a:eo="" d:bo="" b:dc="" b:as="" a:ee="" dz="" c:bx="" ci="" b:bq="" cu="" b:cg="" d:eh="" c:ax="" d:ai="" c:dm="" a:dd="" a:fn="" d:bt="" c:bl="" c:db="" a:bs="" c:ar="" a:ab="" b:bh="" a:et="" a:bp="" ez="" b:cp="" dp="" cb="" ae="" be="" d:ex="" a:cy="" a:dy="" ec="" d:aj="" d:di="" d:cm="" c:cw="" c:ed="" a:cr="" a:cn="" b:ew="" c:bg="" a:dt="" a:ca="" c:dy="" d:dv="" de="" b:bk="" b:ff="" cf="" d:ag="" cj="" c:ad="" a:du="" a:ea="" a:bd="" a:el="" d:dg="" a:ay="" er="" at="" a:fj="" ct="" a:cx="" cl="" bv="" a:by="" eq="" do="" c:cc="" a:dx="" af="" dr="" ek="" c:ba="" ei="" d:cz="" a:fi="" a:aq="" a:ev="" ds="" fh="" c:ak="" b:ch="" c:cs="" az="" c:ef="" b:fe="" fc="" bu="" a:dq="" b:df="" d:br="" b:dw="" ao="" d:en="" b:co="" b:da="" fg="" a:dl="" ck="" a:dk="" d:dh="" d:ac="" d:bz="" b:bn="" d:fa="" a:bi="" c:ep="" d:em="" d:bw="" b:bb="" b:ey="" c:cd="" a:ce="" b:ah="" c:am="" cq="" c:db=""/>
+<e b:db="" c:eo="" bq="" dt="" a:dd="" b:cg="" b:ei="" b:di="" cp="" c:as="" c:bc="" a:de="" ez="" ch="" c:bv="" b:ck="" d:ep="" d:eg="" af="" b:dj="" fg="" c:fl="" a:cy="" b:cm="" ax="" c:am="" a:fi="" c:eh="" d:bu="" cz="" b:ah="" bm="" b:br="" ed="" d:bt="" a:ff="" a:cn="" b:cc="" a:ci="" c:er="" dl="" d:aq="" ao="" d:du="" d:at="" c:ay="" d:cb="" b:eb="" d:dm="" al="" a:bk="" b:cl="" d:dk="" c:be="" a:df="" b:fk="" a:bz="" cj="" an="" ab="" b:fb="" au="" cf="" d:ae="" cx="" d:es="" by="" d:ac="" a:dy="" ds="" dv="" d:dw="" b:ee="" c:fh="" a:dx="" ar="" ct="" a:dp="" ea="" c:bs="" b:cw="" b:ew="" c:bd="" d:aw="" b:bp="" b:dz="" a:fc="" d:fm="" c:ce="" a:ad="" b:dc="" a:dq="" a:bf="" cq="" ap="" dn="" c:cd="" d:bb="" ca="" a:aa="" c:aj="" b:ey="" b:dr="" d:em="" b:cu="" ec="" b:bh="" d:ai="" d:do="" a:fj="" c:fa="" d:ex="" a:et="" c:eq="" en="" cs="" d:ag="" av="" a:ev="" d:fn="" c:bx="" b:eu="" d:el="" b:bw="" c:ej="" a:az="" c:bo="" c:ek="" a:bi="" a:cl="" c:cr="" c:dg="" bg="" ak="" co="" a:bl="" c:ba="" b:bj="" a:bn="" c:fd="" c:fe="" a:dh="" b:ef="" d:do="" b:da="" a:cv=""/>
+<e c:fd="" bo="" c:ep="" c:cy="" fj="" c:bg="" b:ci="" d:db="" a:ai="" d:af="" a:ez="" b:fi="" eq="" d:bv="" d:ac="" bz="" d:fe="" a:fm="" cu="" ej="" a:ag="" c:au="" d:dn="" er="" d:al="" b:ax="" c:ad="" d:aa="" ba="" b:ew="" b:ef="" d:cg="" a:ap="" c:fg="" dt="" d:ay="" b:cl="" ei="" d:dg="" dp="" b:bx="" dx="" bi="" cz="" c:bm="" fn="" fl="" d:ds="" a:ey="" b:ab="" do="" d:bs="" b:ck="" fk="" b:av="" d:ah="" a:cn="" b:di="" c:du="" c:ff="" d:ct="" d:cc="" b:bl="" ar="" cb="" cd="" b:ao="" be="" c:ae="" d:ce="" a:cs="" a:eb="" b:br="" c:bk="" a:bc="" d:as="" a:fh="" b:de="" cr="" d:am="" d:cw="" aq="" a:ed="" c:el="" b:dl="" bf="" an="" cv="" bq="" dr="" c:bd="" d:cm="" d:eu="" fa="" az="" b:cx="" d:dy="" b:fe="" aj="" c:dk="" c:an="" a:bn="" a:ch="" c:by="" b:dw="" d:cj="" c:ev="" d:dz="" a:es="" b:eh="" a:et="" c:cp="" c:ex="" b:at="" a:dc="" dd="" a:bb="" dh="" d:bt="" d:cf="" b:dm="" c:bw="" c:bu="" d:fb="" a:da="" ca="" en="" a:bp="" d:ea="" a:dv="" cq="" d:ee="" bh="" a:eo="" b:bj="" d:aw="" d:eg="" b:ec="" df="" a:dq="" a:em="" fc="" a:co="" d:ak="" c:ek="" dj=""/>
+<e fi="" d:be="" c:ez="" a:bl="" d:df="" a:fj="" d:cf="" b:ey="" ea="" d:bk="" b:an="" b:cg="" c:fa="" b:dg="" b:do="" a:cl="" d:ax="" d:co="" a:ds="" c:dl="" b:er="" b:dv="" d:ev="" dz="" a:cb="" b:dh="" d:bm="" c:ag="" b:cs="" d:al="" a:da="" d:fn="" b:es="" bh="" d:cr="" c:fd="" c:az="" c:bs="" ep="" a:cu="" b:bn="" b:bx="" cz="" et="" a:db="" b:fh="" aq="" aj="" d:ap="" a:eg="" d:dp="" a:fm="" a:dw="" d:ce="" b:dd="" ds="" d:fl="" c:av="" ad="" c:dk="" a:dr="" c:bq="" d:ca="" a:aa="" c:cn="" d:fe="" c:ak="" d:bg="" d:ek="" b:ew="" b:em="" b:cz="" eq="" ef="" b:bb="" d:fg="" c:bp="" b:en="" b:ac="" c:el="" b:bc="" a:dn="" de="" b:eb="" c:ex="" c:bf="" as="" d:ff="" a:ah="" a:ai="" ar="" b:dm="" d:br="" c:am="" d:ab="" bu="" d:di="" c:cc="" a:bv="" cx="" b:dy="" c:eh="" bt="" cd="" a:du="" dj="" d:bd="" au="" c:ao="" c:dx="" ee="" a:fc="" d:ej="" dq="" c:dc="" c:eu="" d:bo="" ch="" fb="" c:cy="" af="" b:ci="" aw="" ei="" ae="" d:bz="" b:ba="" a:dt="" d:bi="" d:ec="" by="" cm="" a:ed="" b:cp="" fk="" d:cv="" c:bw="" ck="" d:ct="" a:cw="" b:at="" ay="" b:cq="" cj="" b:eo="" d:bj=""/>
+<e dq="" b:en="" a:cn="" c:eh="" cz="" a:eu="" dm="" d:et="" b:ex="" a:au="" a:fj="" b:dk="" cq="" b:dg="" d:cd="" c:ba="" d:ae="" dr="" a:bp="" c:cm="" d:cj="" ad="" a:cl="" c:fc="" a:fb="" a:ec="" c:ej="" a:af="" a:ca="" a:bn="" df="" ah="" a:em="" a:de="" c:cw="" c:ff="" c:dt="" ak="" b:br="" b:aq="" b:eb="" dd="" b:bb="" dz="" d:aa="" av="" a:es="" c:bk="" a:ao="" a:al="" a:fk="" c:dh="" at="" dp="" b:by="" a:el="" d:eq="" d:bo="" ci="" db="" c:ct="" c:du="" b:cr="" bj="" d:bz="" c:bi="" d:fh="" fl="" a:bm="" c:eg="" dn="" ac="" a:be="" c:dl="" d:fn="" dj="" d:br="" c:ck="" b:cb="" cs="" c:bs="" cv="" b:cf="" a:bq="" a:ey="" b:cu="" c:ag="" fm="" ez="" b:fi="" c:an="" do="" c:bg="" ai="" c:bh="" d:ei="" d:ep="" a:eo="" a:dx="" c:cc="" c:cg="" cp="" c:ew="" d:ax="" b:bt="" c:fd="" as="" b:bf="" d:co="" az="" c:ds="" d:am="" b:ev="" a:ed="" d:aj="" a:ea="" d:bx="" d:dv="" b:ar="" a:bw="" d:fa="" b:ay="" bu="" c:ch="" d:bl="" d:bc="" bu="" d:bv="" di="" b:aw="" dy="" a:da="" ab="" ef="" bd="" er="" b:fe="" dc="" d:cx="" d:ce="" b:fg="" d:dw="" d:cy="" ap="" a:ek="" c:ee=""/>
+<e c:df="" ch="" b:bq="" d:ff="" b:ed="" aa="" a:dh="" d:bp="" c:dx="" c:ae="" d:ay="" a:fa="" d:bw="" d:bm="" dr="" a:ao="" d:cn="" ew="" b:bg="" ck="" d:ba="" b:dl="" em="" c:ct="" a:es="" a:ec="" b:co="" b:cw="" b:az="" c:dj="" b:bo="" a:fe="" b:bk="" d:dd="" ex="" b:ca="" d:bj="" a:cm="" b:ab="" c:dg="" b:ci="" b:dp="" b:do="" cr="" c:eo="" b:br="" a:as="" cc="" bi="" c:bl="" fm="" c:ae="" c:cb="" dm="" b:ce="" a:cv="" a:ac="" cz="" a:af="" d:dc="" c:ef="" a:dy="" c:cy="" aw="" d:eq="" a:au="" b:bu="" d:bs="" ek="" a:db="" c:cu="" b:by="" fg="" a:cg="" c:cp="" b:dt="" d:bn="" c:fj="" b:et="" b:ar="" c:cx="" b:aj="" ea="" eg="" d:al="" fh="" fk="" a:ei="" ej="" av="" er="" a:dn="" a:fb="" b:at="" c:be="" fd="" b:bt="" d:ad="" b:cd="" c:fl="" am="" a:eh="" c:di="" d:ax="" ap="" d:bc="" du="" a:cj="" d:eb="" a:ez="" d:fn="" b:cs="" d:ey="" b:ah="" b:ai="" b:cf="" c:de="" b:eu="" d:da="" a:ep="" b:bb="" a:ak="" b:ee="" b:el="" c:bz="" d:ds="" b:an="" a:dw="" a:ag="" b:ev="" fi="" b:aq="" b:dq="" en="" b:dv="" c:da="" b:dk="" a:cl="" d:bd="" d:bh="" bv="" c:fc="" d:bx="" d:bf="" d:cq="" dz=""/>
+<e c:cy="" c:ay="" ai="" da="" c:df="" d:ci="" am="" bc="" bd="" c:eg="" cx="" b:ff="" b:ac="" b:ew="" ba="" db="" fe="" b:eq="" b:cc="" cw="" c:dx="" b:eb="" ed="" a:bj="" a:ae="" ao="" a:ch="" a:fl="" a:cq="" a:fb="" a:bz="" b:ek="" b:al="" aa="" b:bv="" d:bh="" c:fn="" c:an="" b:cl="" d:eh="" fm="" b:et="" c:dp="" a:ey="" b:ct="" c:dg="" cn="" au="" a:fi="" b:dz="" a:ev="" ah="" eu="" c:bb="" cb="" d:cv="" b:dv="" a:ck="" c:eo="" bf="" b:do="" aj="" b:dw="" d:fc="" a:dj="" d:ea="" d:bn="" c:af="" c:ao="" c:dn="" b:ax="" a:bo="" c:co="" b:dd="" b:bl="" d:bk="" d:ad="" du="" dh="" bw="" aq="" b:dk="" c:cz="" c:fh="" bu="" b:di="" b:cs="" az="" b:ei="" a:at="" a:ak="" b:ds="" d:aw="" c:cu="" b:be="" c:bi="" b:ex="" d:de="" d:ar="" a:by="" d:bg="" d:fd="" b:ag="" d:dr="" b:fa="" d:bt="" d:ab="" c:ej="" es="" d:bx="" b:eu="" d:cj="" c:as="" a:cp="" d:cr="" ca="" bq="" b:ee="" bp="" a:av="" c:ap="" c:cd="" b:em="" b:bs="" b:dq="" a:fj="" c:ec="" c:dl="" b:cm="" dm="" ez="" ef="" dt="" c:cf="" b:fg="" c:dy="" br="" a:fk="" er="" dc="" b:bm="" d:cg="" ep="" el="" a:ce="" a:en=""/>
+<e d:bo="" a:fi="" b:fj="" b:dr="" a:dy="" a:db="" b:dp="" d:ei="" fa="" d:ac="" c:ap="" d:bs="" c:ah="" c:ay="" b:bt="" c:de="" a:bw="" b:cr="" c:as="" a:cz="" d:dm="" d:el="" a:am="" du="" dg="" eq="" av="" b:ax="" a:ea="" d:fm="" c:aj="" ek="" b:ey="" b:cy="" a:en="" a:dj="" ak="" d:eg="" b:fe="" d:dq="" b:bm="" bb="" al="" a:cu="" b:ez="" er="" c:cz="" d:fk="" b:dz="" c:bl="" a:bk="" a:au="" c:bi="" c:fd="" a:bn="" d:cb="" d:bj="" c:aw="" d:bp="" b:ba="" b:eh="" d:ci="" ep="" b:ck="" ce="" ar="" a:cm="" d:ca="" b:ab="" b:bf="" dv="" d:di="" b:do="" d:bu="" dl="" b:ev="" d:cl="" ch="" dh="" dd="" a:cq="" c:cd="" b:fn="" d:bx="" c:aa="" b:bh="" b:dc="" a:cj="" a:dw="" b:eu="" ew="" a:at="" c:cg="" ai="" b:da="" d:ds="" b:fc="" a:fh="" b:et="" b:ae="" cp="" a:co="" a:ef="" a:em="" d:be="" a:br="" b:bg="" c:ex="" d:cn="" a:cx="" a:ad="" b:ej="" c:cc="" d:dk="" dt="" cs="" d:cv="" bz="" b:ec="" d:cw="" cf="" bv="" a:eb="" by="" b:ed="" d:af="" a:bc="" b:fg="" c:az="" b:fl="" c:ag="" b:ff="" a:eo="" c:df="" a:bq="" b:fb="" c:aq="" d:dn="" d:az="" b:ao="" b:an="" c:dx="" a:ct="" es="" bd="" c:ee=""/>
+<e d:bx="" a:fe="" cx="" cd="" a:ap="" c:av="" dn="" b:es="" d:al="" a:bz="" a:fd="" b:cn="" c:dm="" b:eh="" d:ce="" a:da="" db="" bn="" do="" ec="" c:dx="" c:cv="" c:eg="" d:at="" a:ds="" au="" b:dc="" c:ej="" d:df="" c:ao="" a:bl="" ar="" b:ai="" b:ez="" a:di="" ad="" c:eu="" bk="" c:dt="" bs="" a:cy="" fa="" b:cu="" a:fi="" b:co="" d:ch="" d:cf="" a:dj="" b:dg="" b:dv="" b:fl="" am="" b:aa="" bj="" c:fm="" d:cz="" b:el="" d:dk="" b:bw="" d:cp="" d:dh="" b:et="" c:bm="" ev="" a:bo="" a:cs="" b:dw="" d:ep="" d:bf="" a:ef="" eq="" cb="" b:cg="" b:cw="" an="" d:ex="" cu="" ba="" a:bu="" ck="" a:fn="" a:ek="" a:be="" b:ci="" c:ak="" c:ag="" ae="" c:de="" d:bg="" cj="" a:cc="" d:dl="" c:dq="" ff="" a:bc="" c:fh="" dr="" d:az="" c:ay="" c:cr="" a:ea="" ah="" d:bi="" ew="" a:cl="" d:br="" d:bb="" eo="" d:dd="" fg="" b:fj="" fk="" b:ax="" bq="" fb="" a:er="" ee="" b:aq="" b:bh="" a:by="" aj="" ey="" d:du="" c:as="" dz="" b:bv="" dy="" bp="" b:bd="" ac="" bt="" c:dp="" b:ca="" c:ei="" b:ct="" af="" ed="" b:em="" a:cq="" b:en="" c:eb="" ab="" d:fc="" c:eo="" a:cm="" aw=""/>
+<e cm="" d:aq="" a:dq="" ch="" c:fd="" d:ff="" b:ce="" a:cj="" b:co="" a:cs="" a:bm="" d:cg="" c:av="" ex="" ay="" b:cu="" a:fc="" b:bz="" d:du="" c:dc="" b:bd="" a:ef="" ec="" b:ez="" cw="" c:dy="" a:dw="" c:ej="" b:eq="" eu="" d:eo="" d:fe="" c:eg="" d:dz="" c:ao="" b:dp="" c:bi="" c:bc="" a:bt="" b:cq="" a:ep="" c:cf="" d:bl="" d:al="" b:bw="" a:do="" d:az="" a:cc="" c:bk="" c:ee="" da="" d:ax="" cb="" cn="" c:de="" db="" a:ci="" a:dt="" d:ay="" an="" c:fh="" c:fb="" a:dg="" b:fi="" c:fn="" c:fk="" b:cz="" ea="" c:eh="" fm="" dm="" c:ck="" a:as="" b:dh="" d:fl="" c:bs="" a:au="" d:bu="" d:cx="" c:el="" cd="" d:ed="" b:ak="" d:ey="" b:bq="" c:am="" ad="" ai="" df="" c:ah="" b:ar="" b:cp="" b:bb="" bn="" b:bx="" bv="" bg="" aj="" b:bh="" a:fg="" dr="" d:ek="" a:bp="" d:dx="" c:dj="" c:er="" c:ac="" b:et="" a:ds="" cy="" b:di="" a:fj="" by="" b:dn="" fa="" c:ei="" b:es="" at="" ew="" c:dd="" ev="" d:dk="" d:bo="" cv="" c:em="" a:aa="" ap="" dv="" d:eb="" d:bj="" b:ct="" ba="" br="" ab="" c:af="" d:cl="" b:be="" b:dl="" d:ca="" c:aw="" a:bf="" c:ag="" cr="" a:ed="" d:en="" d:ae=""/>
+<e dq="" bl="" b:do="" c:dx="" d:di="" aq="" c:ea="" c:es="" c:dy="" a:au="" b:dv="" b:de="" ex="" ew="" c:bd="" a:bh="" c:fe="" b:aa="" d:eu="" c:br="" c:ad="" dh="" c:ap="" d:df="" dj="" c:bz="" c:cq="" a:ag="" d:ch="" b:bc="" a:ea="" c:dz="" b:ar="" fj="" c:ay="" d:cz="" du="" b:fb="" b:db="" b:an="" c:fc="" cs="" ah="" a:ef="" d:fg="" b:ei="" d:eq="" c:bp="" a:ds="" bs="" a:fm="" fh="" c:ak="" d:ci="" a:al="" c:ee="" bo="" b:bk="" d:ey="" b:ct="" ax="" c:bm="" eg="" a:bn="" c:ab="" d:bw="" eo="" a:dr="" c:fn="" ae="" c:af="" c:dt="" d:cg="" b:as="" c:am="" d:be="" a:dc="" d:ca="" dl="" c:cc="" d:bb="" b:dn="" ev="" b:cr="" c:em="" b:fk="" d:ai="" ep="" d:dp="" b:bf="" b:bu="" c:cf="" b:cm="" d:da="" b:cu="" a:ez="" b:ac="" b:ba="" cp="" b:ce="" b:ej="" d:at="" d:ed="" d:dw="" at="" d:bq="" c:bj="" d:fa="" c:ff="" b:ck="" cl="" fd="" aj="" a:dd="" d:fl="" c:bi="" b:av="" b:fi="" a:aw="" cj="" d:cw="" a:ec="" d:dg="" bt="" d:cb="" d:er="" b:dk="" ek="" c:by="" a:el="" d:eb="" a:dm="" b:et="" b:bv="" en="" eh="" b:cy="" a:cd="" a:bg="" d:cx="" a:cv="" b:bx="" a:ao="" c:az="" d:cn="" d:co=""/>
+<e br="" d:eo="" b:az="" cy="" a:bd="" dw="" du="" d:ff="" bj="" a:ds="" b:cj="" a:fg="" b:et="" c:af="" c:ad="" al="" ba="" dg="" d:by="" b:cg="" ak="" en="" b:fm="" es="" bx="" a:bl="" a:cc="" b:ay="" fe="" a:aq="" d:fn="" d:df="" b:ci="" a:be="" d:dc="" b:bs="" d:bm="" em="" b:fc="" c:fa="" ar="" d:cs="" c:bc="" a:fl="" b:ae="" b:bi="" c:ep="" c:aj="" ax="" bf="" dz="" b:dx="" a:dk="" c:fd="" dr="" dv="" dh="" a:co="" d:er="" a:aa="" a:ev="" a:ce="" d:bi="" b:ee="" d:ed="" ek="" a:as="" d:bg="" bk="" a:db="" c:fn="" b:dp="" b:cx="" cp="" c:fb="" a:dq="" c:cr="" bq="" b:ex="" c:dd="" c:cz="" c:ck="" ea="" au="" d:cb="" c:bn="" dm="" b:eg="" dy="" c:cv="" d:bo="" d:fi="" d:ah="" b:ca="" b:cn="" ei="" dt="" b:bv="" a:eq="" ef="" b:fh="" b:el="" d:ac="" c:fj="" c:ej="" d:cq="" c:ch="" b:eh="" b:ap="" at="" a:fk="" d:di="" b:bb="" a:am="" a:dn="" d:bw="" a:do="" a:an="" a:ec="" ew="" c:ct="" ey="" c:eu="" c:eb="" a:ag="" b:cf="" a:av="" dl="" c:cd="" dj="" cw="" c:da="" a:aw="" a:bp="" cu="" ez="" d:cm="" b:bu="" b:de="" ao="" d:cl="" b:ai="" a:bt="" bz="" a:bh="" b:ab=""/>
+<e fc="" a:af="" b:bj="" fj="" bl="" fa="" a:cc="" b:cu="" bt="" a:cm="" cq="" cn="" a:bf="" a:ab="" c:ah="" b:ch="" d:et="" d:az="" c:bk="" b:dr="" b:bq="" a:ct="" c:fm="" a:au="" c:cy="" d:fl="" c:ak="" bz="" cs="" b:du="" a:bi="" d:aw="" a:eu="" d:ck="" ba="" d:ff="" d:dg="" a:bm="" d:br="" eq="" a:dm="" c:cz="" d:cj="" a:an="" c:fe="" b:em="" c:bv="" a:bg="" c:as="" av="" aq="" c:cr="" dh="" b:dp="" d:aa="" d:ev="" d:al="" b:bw="" a:aj="" a:fn="" c:ao="" c:ci="" c:by="" a:cf="" d:dz="" bs="" fg="" bd="" b:cb="" a:fb="" b:el="" d:ee="" d:dk="" c:fd="" a:ex="" c:dv="" a:ap="" a:ef="" a:dx="" eb="" a:dw="" db="" c:ad="" eg="" c:ae="" bb="" es="" b:cl="" d:dj="" b:ez="" c:ed="" a:fh="" er="" ag="" b:bu="" b:ai="" c:ea="" bc="" ax="" cw="" ek="" d:ep="" eh="" d:ca="" dd="" d:fk="" d:ay="" bp="" b:bn="" do="" di="" d:cp="" d:de="" c:ew="" c:cx="" c:dn="" c:en="" c:cy="" a:cg="" c:da="" d:dy="" d:ce="" d:bo="" b:dt="" ar="" b:ec="" dc="" a:ac="" d:dl="" co="" am="" ei="" at="" c:cj="" c:dq="" bh="" a:ey="" a:be="" c:df="" b:ej="" a:cv="" c:ds="" d:bx="" c:cd="" eo="" a:fi=""/>
+<e c:et="" bi="" c:du="" b:av="" c:bt="" c:de="" a:aw="" cg="" b:bj="" c:fk="" d:dc="" d:dy="" b:fd="" b:eq="" c:dz="" c:dh="" a:em="" d:cp="" d:an="" ex="" b:bl="" d:al="" dn="" c:cq="" b:cv="" d:ek="" d:am="" d:em="" c:fi="" d:bf="" d:do="" c:aq="" ab="" a:ae="" c:eu="" d:by="" b:ct="" d:dq="" a:bc="" c:eg="" c:bp="" af="" a:dr="" dv="" c:ez="" ac="" bd="" a:ec="" a:bs="" a:bg="" a:fn="" d:ea="" a:ev="" d:da="" d:dm="" b:cy="" cx="" c:bk="" a:dx="" bx="" ef="" d:cm="" c:en="" b:bz="" ee="" d:bn="" b:bq="" b:ar="" b:ao="" c:cz="" fg="" a:ay="" ad="" b:ch="" a:bh="" d:br="" a:df="" a:cd="" a:ba="" c:dg="" b:ak="" ca="" as="" a:dk="" c:cn="" d:ep="" c:ew="" db="" d:el="" a:fa="" ai="" fe="" bu="" c:ax="" d:bb="" b:aj="" c:ah="" b:di="" bv="" d:ff="" eb="" cf="" d:fh="" b:cu="" dl="" b:ck="" c:fm="" a:ds="" a:az="" d:aa="" b:ei="" co="" b:ce="" a:be="" at="" cl="" a:cc="" fc="" dt="" c:ey="" au="" bm="" c:ap="" a:dj="" a:bo="" b:fl="" b:cj="" c:dw="" ed="" a:ci="" a:eh="" d:es="" a:eo="" b:cb="" c:cs="" cn="" b:ej="" c:dd="" d:cr="" ag="" d:cw="" a:dp="" fj="" a:bw="" a:fb="" er=""/>
+<e bi="" a:cg="" b:ea="" en="" bm="" c:eh="" c:cu="" a:ax="" d:ep="" c:dc="" b:dt="" b:dy="" d:dq="" b:fm="" cb="" d:bx="" ag="" cv="" b:dw="" d:co="" c:eb="" d:eu="" er="" fc="" c:ck="" b:cs="" b:di="" b:cw="" bp="" a:fd="" a:ef="" a:ar="" c:fk="" ah="" bl="" b:dk="" d:bv="" ew="" d:bd="" a:fb="" d:av="" b:cd="" bt="" a:ez="" ej="" el="" c:ak="" c:au="" d:ce="" a:cc="" c:ey="" cr="" c:ei="" a:du="" c:bo="" az="" d:bj="" d:bg="" b:ay="" a:ad="" d:ap="" a:bn="" bw="" c:eo="" d:bf="" c:dv="" d:al="" c:ao="" c:cm="" b:dz="" fe="" af="" d:fn="" b:as="" b:ff="" d:fa="" c:cl="" b:ca="" b:es="" b:ee="" a:cz="" d:db="" a:aq="" c:ai="" br="" c:ec="" b:da="" c:bs="" d:bq="" a:cj="" c:bu="" c:dj="" d:am="" d:dx="" b:de="" b:dp="" d:ed="" b:an="" c:bk="" bt="" b:cn="" a:dg="" c:bc="" d:dm="" b:ds="" b:cy="" d:eq="" a:fl="" a:ba="" d:eg="" d:ac="" d:dd="" a:be="" a:et="" a:dr="" c:dn="" c:ci="" cx="" c:dh="" ch="" a:bb="" d:ex="" bh="" d:ek="" ev="" b:by="" at="" c:em="" c:do="" d:cq="" a:ab="" a:bz="" d:dl="" c:ae="" b:fh="" cf="" b:aa="" a:aj="" c:cp="" a:ck="" b:fi="" a:fj="" aw="" d:df="" d:ct="" d:fg=""/>
+<e d:dv="" c:bi="" c:bl="" a:dj="" c:cs="" ev="" a:bk="" cj="" c:ah="" c:dt="" b:ar="" c:fe="" ck="" b:fa="" d:ad="" d:ai="" bd="" az="" dx="" a:ff="" d:bt="" ap="" a:eh="" a:bz="" c:fi="" b:dx="" em="" c:dh="" ay="" b:ed="" bw="" bv="" b:aa="" d:cf="" c:ec="" da="" a:dp="" af="" fl="" a:co="" c:ew="" a:el="" c:dr="" cn="" c:cg="" a:br="" cv="" ds="" c:au="" bj="" cr="" b:eg="" c:bh="" ee="" c:cw="" c:ag="" by="" dg="" a:dy="" d:dm="" eb="" d:ek="" ez="" b:dw="" b:cm="" b:cd="" a:es="" b:eo="" dl="" a:aw="" a:ef="" a:db="" ak="" b:fj="" ct="" et="" d:bs="" d:bx="" b:ae="" ba="" d:bg="" d:dq="" a:ca="" bo="" ao="" cb="" c:ce="" b:ab="" d:fb="" d:an="" b:at="" c:fh="" a:as="" a:aj="" bu="" b:ba="" bm="" d:cy="" er="" fc="" c:fn="" dc="" c:du="" di="" d:eu="" b:cp="" d:fk="" b:cx="" a:do="" a:eq="" d:am="" ep="" b:cc="" c:bc="" d:bb="" b:bp="" d:ei="" c:fm="" dk="" a:fd="" b:ex="" aq="" b:bn="" dd="" a:ea="" en="" d:cu="" c:df="" a:al="" b:ax="" d:fg="" a:ej="" a:ci="" b:dn="" d:ey="" ac="" a:dz="" a:de="" b:cq="" b:cl="" c:bf="" b:cz="" b:bq="" d:av="" ch="" a:be=""/>
+<e ed="" d:db="" c:eh="" bk="" d:bg="" ca="" b:cm="" a:eb="" b:dx="" be="" d:cu="" d:eo="" a:as="" c:dh="" a:ce="" d:ad="" b:ef="" d:bu="" a:dq="" c:en="" b:dk="" b:dr="" a:cb="" ao="" a:ar="" d:at="" d:de="" b:es="" c:cq="" d:cx="" fn="" aj="" a:bb="" a:fc="" d:cn="" b:ek="" b:cp="" c:aq="" eg="" d:cy="" a:bq="" dy="" c:ep="" d:by="" d:dm="" em="" d:bz="" br="" c:bc="" fb="" c:ec="" a:bm="" a:ez="" d:an="" a:dn="" ev="" a:ci="" d:fm="" c:bo="" c:ae="" d:bl="" ch="" c:bv="" ff="" b:bf="" c:ab="" b:cl="" a:af="" fl="" d:ew="" d:av="" d:ak="" b:do="" a:dw="" d:bj="" c:ei="" cg="" c:dd="" a:dt="" a:cd="" d:dv="" c:dc="" d:bp="" a:fa="" d:ck="" d:cz="" b:ds="" a:ay="" ac="" dp="" b:bs="" a:bw="" a:ba="" b:am="" dz="" b:ah="" d:fe="" aa="" c:cj="" d:fj="" c:au="" d:al="" c:ct="" aw="" b:ap="" a:da="" c:dj="" a:ai="" b:et="" a:bi="" c:cw="" fh="" d:cs="" a:fd="" b:fk="" b:ej="" d:ex="" bt="" d:eq="" d:ea="" d:dl="" df="" c:el="" c:dg="" b:bx="" a:ee="" a:cf="" d:er="" d:ax="" aa="" b:di="" a:co="" c:cc="" d:cy="" a:bn="" a:bh="" b:fi="" b:ey="" a:cv="" b:ag="" b:du="" a:az="" a:fg="" b:cr="" d:bd="" d:eu=""/>
+<e b:cz="" ay="" dn="" d:cf="" a:dl="" b:ax="" ak="" d:fe="" a:bg="" ao="" b:ar="" a:df="" c:cc="" d:cq="" c:em="" a:fn="" d:au="" c:ef="" bf="" bu="" c:ec="" c:dz="" d:en="" c:du="" d:cv="" c:ek="" b:fc="" c:dr="" d:dm="" b:ab="" c:ex="" b:cp="" d:eb="" bn="" dk="" b:db="" d:dg="" b:cw="" d:bx="" cb="" b:ei="" cr="" b:bh="" a:cn="" a:bq="" bz="" c:fa="" aq="" aj="" a:ce="" ci="" c:eq="" d:bm="" b:az="" a:aa="" dc="" a:cj="" c:al="" cm="" b:el="" c:cy="" cl="" a:dj="" eh="" a:ca="" c:ac="" b:ai="" a:ej="" d:cx="" ae="" eo="" cu="" as="" b:ed="" a:bv="" a:dp="" av="" d:eu="" d:ct="" dh="" a:dd="" c:ck="" a:dv="" c:cg="" d:ey="" a:fk="" ev="" d:ee="" c:dq="" a:an="" am="" ff="" bk="" bo="" di="" cs="" a:bc="" a:dw="" da="" c:ad="" d:fi="" a:bj="" c:dy="" bi="" a:dt="" do="" b:fh="" d:fj="" b:fg="" d:ch="" fl="" c:bw="" d:by="" ah="" a:ag="" d:es="" et="" d:af="" a:at="" b:ea="" a:bb="" a:bl="" er="" d:aw="" c:dx="" d:eg="" a:br="" d:bs="" de="" a:bp="" c:cd="" d:bd="" b:fd="" d:be="" a:ap="" a:fm="" d:ba="" a:bt="" a:ew="" b:ds="" bs="" d:dj="" a:ep="" a:ez="" fb="" d:co=""/>
+<e b:fi="" b:ab="" c:aj="" d:da="" c:dn="" a:dj="" bb="" b:bt="" a:ay="" c:cc="" c:bh="" b:aa="" d:dy="" c:dx="" c:bx="" c:ar="" fc="" b:ae="" cn="" c:ds="" eb="" b:es="" bq="" a:ao="" dw="" c:ai="" cx="" dm="" a:al="" d:do="" d:be="" d:dg="" b:di="" b:az="" cv="" d:cw="" a:dt="" a:at="" dq="" b:eo="" fg="" as="" d:an="" c:ah="" b:fa="" b:bw="" a:bo="" c:aw="" d:em="" a:dc="" b:eq="" a:dh="" a:bk="" b:cy="" c:ev="" b:bs="" d:fd="" d:cz="" c:av="" bl="" b:ak="" d:cb="" by="" b:fm="" cm="" b:ec="" br="" b:ed="" a:ap="" c:ej="" fb="" b:bv="" b:bc="" a:cf="" d:cs="" a:dk="" du="" ad="" d:ei="" c:ag="" d:fn="" a:fh="" c:ef="" bp="" b:bz="" cd="" el="" d:er="" fl="" a:bm="" d:bd="" a:cr="" fk="" c:cj="" cu="" d:ci="" c:db="" d:fc="" a:en="" c:ba="" ey="" ek="" a:ex="" c:ea="" a:am="" b:bn="" b:de="" a:fj="" c:eg="" d:ck="" b:ca="" d:ch="" d:dd="" c:ac="" c:eh="" ee="" bf="" ce="" d:cq="" c:af="" au="" cp="" d:fe="" et="" d:ff="" c:co="" a:eu="" ez="" b:dl="" d:bg="" aq="" b:dz="" c:cl="" a:ep="" a:dv="" dr="" cg="" d:ct="" ew="" b:bu="" a:bi="" d:dp="" df="" bj="" c:ax="" d:fm=""/>
+<e b:ej="" a:et="" al="" a:at="" c:fl="" fg="" c:dn="" ba="" bn="" ab="" d:dc="" b:ag="" a:bw="" b:fi="" d:cg="" a:dq="" d:co="" dy="" dm="" ci="" a:fe="" fd="" d:cz="" a:cx="" a:ff="" fm="" a:bt="" b:am="" fk="" c:cl="" bb="" d:ai="" c:as="" eq="" b:by="" c:ev="" d:ek="" a:cw="" d:cc="" c:br="" b:aj="" ee="" b:cr="" c:bg="" a:ex="" c:ey="" a:dt="" c:bu="" c:az="" c:cd="" ah="" b:dj="" dg="" d:cq="" b:el="" d:ce="" d:cj="" cf="" d:cb="" b:bf="" a:bs="" fh="" ep="" b:bx="" a:bz="" a:fj="" bk="" a:ei="" an="" d:ea="" d:ed="" a:ax="" a:ao="" c:au="" d:ak="" c:bv="" b:ck="" bm="" ay="" d:ad="" av="" bc="" ch="" d:be="" d:de="" d:fa="" d:dp="" c:bj="" d:cv="" dv="" b:du="" b:ac="" c:eo="" d:aa="" c:aw="" en="" a:af="" a:em="" b:eu="" a:es="" c:dw="" a:ay="" cs="" c:dk="" di="" ew="" cz="" a:dh="" c:ap="" b:df="" c:bp="" a:fb="" fn="" dl="" c:cp="" b:do="" c:eg="" c:dx="" ds="" a:cn="" c:da="" d:ct="" eh="" a:fc="" eb="" b:dd="" d:cy="" d:cu="" d:dz="" ae="" d:er="" c:cm="" bi="" bq="" b:bl="" dr="" b:db="" a:ec="" a:bh="" a:ef="" d:bo="" aq="" b:ar="" ez="" bd="" ca=""/>
+<e b:fm="" a:bc="" cb="" bz="" d:ay="" a:fd="" a:dm="" a:fc="" b:bx="" d:ej="" c:am="" a:bp="" d:by="" b:dp="" ew="" d:en="" eq="" a:bf="" c:eo="" dz="" a:ea="" c:aj="" bi="" a:cz="" c:do="" d:dc="" d:av="" c:ey="" b:bg="" ax="" eh="" bw="" d:cj="" cl="" a:ed="" c:bh="" ef="" b:br="" b:cu="" ap="" c:db="" a:cw="" b:ai="" a:ar="" b:fi="" cf="" d:da="" a:ah="" b:al="" b:cv="" c:es="" c:dl="" b:aa="" c:fn="" b:dy="" d:de="" b:ei="" b:dg="" c:cx="" d:ee="" d:dd="" di="" c:ek="" dh="" c:ck="" at="" ak="" b:dn="" eg="" a:bj="" d:dw="" b:bd="" d:co="" d:as="" bu="" d:fb="" c:be="" c:ec="" d:dq="" a:az="" a:cy="" aj="" a:et="" d:fj="" c:ep="" eu="" cg="" a:fh="" c:cm="" a:dj="" a:ds="" c:ao="" d:fl="" d:dr="" b:bb="" d:ev="" cp="" d:cc="" fk="" b:dk="" bq="" c:ch="" d:el="" d:cq="" d:bs="" a:ez="" b:aw="" c:bi="" b:cr="" c:bm="" d:bo="" ce="" ci="" d:ba="" d:ac="" b:ex="" ab="" b:bn="" d:er="" c:em="" c:cn="" c:dt="" cs="" d:ca="" a:eb="" au="" c:dx="" c:dv="" b:ad="" c:fa="" ae="" b:fe="" c:ag="" d:an="" a:bk="" fg="" d:df="" ff="" ct="" bv="" b:bl="" a:du="" c:af="" bt="" a:aq="" d:cd=""/>
+<e b:fd="" d:bk="" b:ew="" c:ex="" et="" b:dh="" c:em="" c:bx="" d:fe="" a:ca="" a:ad="" b:ci="" c:ee="" a:cu="" b:eu="" a:cq="" c:ay="" a:fn="" b:ep="" aq="" cd="" d:bg="" d:dg="" a:an="" b:ek="" b:dt="" d:bi="" bd="" a:cg="" br="" ea="" a:ak="" ed="" b:ap="" a:aa="" d:bh="" b:dj="" c:ds="" b:fm="" cx="" a:fi="" a:dm="" c:dz="" c:ag="" fa="" d:at="" d:ct="" a:eo="" el="" b:av="" c:bl="" d:dl="" d:be="" a:bq="" d:df="" d:ce="" au="" a:dx="" d:cw="" bv="" b:ai="" en="" d:ch="" d:bf="" d:ac="" a:da="" ck="" dk="" c:cb="" b:af="" c:do="" c:by="" dp="" eh="" cn="" a:bj="" c:ef="" c:cp="" c:cs="" c:er="" c:dw="" dq="" dr="" a:bz="" a:bu="" b:ec="" b:dy="" bp="" dd="" b:di="" b:ba="" b:dc="" b:cr="" a:bs="" a:cf="" fl="" c:fk="" d:aj="" c:ao="" ax="" fj="" d:du="" al="" b:bb="" a:bt="" d:ey="" b:fg="" c:de="" a:ab="" b:am="" d:ae="" c:bm="" c:ei="" c:bw="" cl="" b:ff="" bo="" a:az="" d:cj="" b:cy="" a:cv="" c:aw="" d:eb="" c:fc="" d:fj="" b:fh="" db="" c:eg="" c:dv="" b:ej="" a:bn="" ez="" d:ar="" a:cc="" c:as="" c:ah="" b:eg="" c:fb="" d:es="" b:ev="" d:cz="" b:co="" b:bc="" a:cm="" b:dn="" b:eq=""/>
+<e a:fb="" d:eb="" a:dz="" b:bm="" c:db="" c:ay="" d:ci="" c:bd="" ch="" a:bp="" a:ah="" ag="" b:fk="" c:el="" a:co="" a:dc="" cz="" em="" cm="" c:di="" b:dl="" d:dw="" a:ax="" a:dh="" ev="" d:bc="" dp="" c:ba="" a:as="" fa="" a:cp="" b:bs="" cv="" b:cr="" b:br="" c:au="" d:eh="" d:aw="" c:ec="" c:eo="" ep="" b:af="" d:cd="" c:ae="" a:eu="" c:eg="" c:ce="" b:bg="" d:ee="" ai="" b:cq="" c:de="" c:aa="" a:am="" d:ej="" d:fi="" a:cq="" c:bj="" a:dj="" a:dx="" a:fm="" et="" d:by="" d:bu="" ap="" ar="" b:da="" bx="" b:cf="" d:dd="" c:cl="" d:fg="" fn="" ek="" bt="" a:cs="" bq="" a:cn="" ds="" d:av="" c:bn="" c:bv="" b:ao="" d:ed="" b:al="" dr="" ey="" d:dq="" b:bb="" b:dt="" c:cc="" b:ck="" c:do="" c:cx="" a:dy="" c:fj="" b:at="" b:eq="" d:aj="" c:fl="" c:ct="" bi="" c:fn="" c:ex="" ea="" b:bh="" c:ak="" bw="" a:bl="" a:az="" b:ab="" a:es="" an="" c:ei="" a:bk="" a:ca="" ad="" c:ez="" er="" b:fc="" a:fd="" b:bf="" d:fe="" d:dg="" a:dm="" a:ew="" c:df="" a:cg="" b:cu="" b:fh="" d:ef="" ff="" a:dv="" aq="" b:cw="" dn="" cy="" c:en="" a:cb="" b:be="" d:bz="" c:du="" bo="" a:cj="" a:ac="" d:dk=""/>
+<e a:fe="" d:di="" b:el="" a:ei="" b:ba="" c:cc="" d:eq="" b:em="" c:bw="" c:fi="" a:ey="" c:bv="" b:ex="" d:dx="" bo="" b:ej="" c:ak="" ck="" c:eu="" d:bu="" ec="" ay="" c:di="" aa="" es="" a:cj="" a:dl="" cm="" b:bk="" b:fk="" d:fa="" a:dk="" b:ci="" bs="" a:cw="" d:ab="" c:df="" a:az="" a:ef="" d:do="" d:ea="" d:ee="" ez="" af="" c:ag="" d:er="" c:bz="" bq="" c:dn="" a:cz="" dm="" d:co="" c:ad="" b:ai="" a:db="" a:ap="" c:bs="" d:fn="" ct="" a:aj="" d:ep="" bh="" c:de="" d:be="" d:fh="" eb="" d:ao="" am="" a:fl="" a:fj="" c:eo="" a:dt="" d:ev="" b:fd="" d:cx="" b:ah="" ae="" d:bb="" a:dw="" a:ax="" d:et="" cg="" a:bd="" ds="" d:aw="" a:ek="" c:bm="" a:cy="" c:ed="" d:fg="" dg="" b:dz="" dd="" a:at="" cr="" c:fc="" b:cu="" c:br="" a:bf="" b:en="" d:aq="" b:cf="" ff="" d:bj="" c:cp="" b:cb="" b:au="" d:bx="" c:dy="" a:cq="" c:dj="" a:fm="" a:fb="" bg="" d:ch="" c:an="" c:bt="" a:al="" b:ew="" d:eg="" bi="" b:ca="" a:cn="" dv="" dr="" b:dq="" dp="" a:du="" dc="" d:cv="" bc="" a:eh="" b:by="" a:cl="" ac="" c:bl="" a:bp="" bn="" b:ar="" c:cd="" a:dh="" da="" b:ce="" c:av="" b:cs="" c:as=""/>
+<e b:cv="" d:fe="" dw="" c:cz="" d:af="" d:ek="" ad="" b:ab="" cm="" ds="" a:bb="" d:er="" b:ay="" a:bl="" a:de="" ej="" a:da="" c:ct="" a:dg="" b:ex="" b:ar="" d:en="" b:fj="" c:dr="" b:bq="" d:cs="" d:bg="" c:cx="" a:ef="" a:ce="" av="" d:et="" b:dd="" b:es="" bc="" d:bt="" a:dh="" fa="" a:aj="" a:cn="" an="" a:ck="" c:dx="" b:eo="" d:bh="" a:ec="" a:ca="" c:eb="" bp="" c:di="" c:ba="" b:ap="" d:dl="" a:eg="" b:dk="" c:fd="" b:az="" ez="" bk="" a:am="" dp="" c:bj="" c:ci="" d:fi="" b:bs="" b:dq="" d:ee="" dw="" dj="" b:br="" d:at="" b:bu="" d:cr="" b:fl="" a:cl="" a:ak="" d:dy="" b:ei="" c:aq="" b:em="" c:cd="" df="" c:cp="" d:eq="" ff="" c:al="" b:by="" b:be="" cf="" d:dm="" b:ag="" d:ep="" fc="" d:fh="" b:cq="" d:du="" d:bm="" b:dn="" a:fb="" b:ai="" fk="" c:ea="" b:aa="" c:ev="" d:cb="" c:bv="" c:bd="" au="" b:fg="" d:fm="" b:cg="" a:ac="" b:ae="" bi="" c:cu="" dz="" d:dt="" d:db="" el="" a:fn="" a:co="" d:dv="" c:ah="" d:bz="" d:du="" dc="" b:cc="" c:ch="" a:eu="" b:ew="" b:bn="" b:aw="" bf="" d:ey="" d:ao="" b:cj="" d:ax="" bw="" d:as="" b:eh="" a:cw="" b:cy="" d:ed="" b:do="" b:bx="" a:bo=""/>
+<e a:ap="" d:dk="" c:et="" c:dp="" d:fd="" ca="" az="" ep="" b:eg="" c:bb="" dd="" d:ao="" b:ec="" b:at="" b:ew="" c:eo="" a:eq="" c:ae="" a:ej="" d:cn="" a:cr="" d:df="" d:bg="" c:ef="" ax="" a:bk="" dq="" bw="" c:bz="" c:as="" c:dl="" bs="" d:ey="" d:al="" b:da="" a:ff="" a:dr="" de="" d:ar="" d:dz="" d:dx="" a:eu="" d:bc="" c:di="" d:ba="" b:dw="" c:dt="" c:ct="" c:dg="" a:ag="" b:bd="" b:cq="" d:cb="" a:ce="" ch="" en="" d:ah="" c:ai="" a:eh="" d:au="" b:cw="" d:fc="" d:av="" bk="" c:bi="" d:cu="" bx="" eb="" a:an="" d:er="" d:dj="" a:bt="" cp="" a:ck="" aa="" a:br="" b:ek="" a:es="" b:by="" bh="" aq="" cl="" a:fm="" a:aw="" d:fh="" a:bm="" b:ac="" a:fk="" bj="" a:fi="" ev="" c:fj="" bp="" a:bv="" ez="" c:ee="" a:fn="" dy="" d:bu="" c:du="" c:ba="" dn="" a:el="" a:cc="" d:em="" d:ei="" b:cd="" d:cm="" c:cy="" a:bf="" ab="" d:cs="" a:af="" a:cf="" d:ay="" d:fl="" d:db="" d:ak="" a:bq="" cx="" fe="" b:ed="" c:dv="" b:ci="" b:fa="" b:ex="" ad="" c:co="" b:aj="" a:bn="" c:dm="" ds="" a:ea="" cz="" a:cj="" b:cg="" a:cv="" c:am="" be="" c:do="" d:bl="" b:dh="" b:dc="" c:fb="" a:bo="" a:fg=""/>
+<e ce="" d:cl="" c:dd="" c:br="" b:fh="" b:ab="" b:cb="" c:ae="" b:fd="" d:cz="" a:bo="" c:ca="" bm="" fa="" b:fb="" b:en="" bh="" d:bu="" b:dg="" c:ao="" ed="" as="" b:cb="" a:ec="" b:bg="" d:bq="" a:ck="" b:bb="" d:aa="" c:ap="" c:cj="" d:bf="" b:dp="" a:do="" ay="" dc="" d:dk="" a:df="" fl="" c:cd="" eo="" a:eh="" a:bk="" b:di="" b:cn="" ah="" a:em="" c:ad="" c:cq="" c:dq="" bj="" ee="" a:am="" a:bx="" a:aq="" ep="" b:ch="" d:ey="" a:fi="" a:bi="" c:an="" b:cs="" d:dt="" a:eg="" dh="" av="" bz="" c:ef="" fc="" c:ax="" b:fg="" a:bw="" a:de="" b:az="" d:bp="" c:fj="" bt="" b:dn="" c:ai="" cm="" a:cp="" ex="" a:db="" a:be="" c:dy="" fn="" dj="" d:at="" a:dl="" b:es="" d:ei="" d:cg="" a:dz="" b:ek="" c:ez="" c:bv="" b:au="" a:fk="" a:ej="" a:eb="" d:dm="" b:ar="" da="" ff="" b:cj="" b:dw="" a:al="" d:ba="" c:dx="" b:ci="" d:du="" d:bs="" d:ak="" b:el="" ea="" fm="" d:dv="" c:bd="" d:cc="" cx="" b:eq="" c:ev="" aj="" b:ds="" cv="" by="" d:et="" er="" ct="" a:bc="" a:af="" c:cy="" c:cr="" a:aw="" d:ag="" a:cu="" c:eu="" fe="" d:ac="" d:bl="" c:dr="" co="" c:bn="" cf="" b:cw="" ew=""/>
+<e d:cm="" a:da="" a:ag="" c:ae="" d:cv="" c:er="" d:dc="" ar="" bf="" b:ac="" c:dq="" ai="" c:df="" b:eu="" d:ef="" d:fa="" c:dh="" ba="" a:am="" c:eb="" b:cs="" d:ay="" a:ah="" ei="" d:fk="" a:aj="" eg="" d:av="" b:aa="" b:ce="" a:bu="" d:do="" cz="" c:bj="" c:el="" d:cc="" b:bs="" a:dn="" b:db="" c:fc="" d:fh="" dl="" a:ey="" ap="" b:bd="" b:cy="" a:bk="" ca="" d:dx="" et="" b:fe="" c:ea="" b:dg="" c:br="" b:ee="" a:fb="" ev="" b:bz="" c:dy="" b:cp="" c:bi="" bo="" ck="" d:ec="" d:ff="" b:cb="" c:dt="" b:fn="" c:dj="" a:cw="" b:di="" c:dd="" bn="" d:ez="" d:dr="" a:ad="" d:ek="" b:cq="" an="" bw="" ct="" ao="" dk="" b:em="" bv="" bq="" dv="" cg="" ex="" c:bg="" a:co="" d:at="" cr="" c:af="" b:bm="" a:bc="" c:fi="" aw="" a:bl="" a:cj="" b:fg="" a:au="" d:fm="" ed="" a:fj="" cf="" b:eh="" b:as="" c:ej="" dw="" d:bt="" a:du="" c:dm="" ci="" al="" dz="" a:by="" c:bh="" ab="" bp="" c:ew="" en="" b:bb="" d:ch="" b:cl="" c:cq="" b:aq="" a:az="" fd="" a:ak="" c:es="" bt="" cx="" de="" cd="" b:be="" a:dp="" d:eq="" c:ep="" d:ax="" a:cn="" eo="" cu="" b:bx="" ds="" a:fl=""/>
+<e c:ab="" aj="" b:cl="" d:dg="" fi="" d:by="" d:am="" b:fk="" b:ap="" d:ee="" b:cz="" c:bk="" d:ej="" a:aw="" c:ca="" bt="" a:cu="" a:ba="" ay="" ea="" b:bl="" c:dj="" c:cp="" c:cy="" d:cr="" d:bo="" b:bg="" a:eq="" ak="" dv="" b:fj="" d:ai="" eb="" b:dw="" b:cb="" a:br="" dq="" a:an="" bs="" c:eu="" ec="" d:cq="" c:bb="" b:dx="" a:ct="" c:dh="" b:es="" a:be="" ch="" d:ck="" d:bz="" av="" a:ce="" c:dn="" b:cw="" bh="" c:bn="" a:cf="" b:cd="" a:ev="" c:bx="" d:dd="" b:ek="" c:ae="" d:bq="" fg="" a:bm="" d:cc="" b:as="" a:fm="" fc="" a:co="" c:do="" b:au="" fa="" b:al="" a:ag="" d:af="" b:er="" a:bi="" d:en="" ef="" a:dp="" b:ew="" c:bc="" b:ds="" d:bw="" b:dm="" b:fe="" a:dy="" c:dl="" b:dz="" d:bp="" ax="" a:az="" b:fd="" c:ad="" d:ah="" b:cv="" d:bf="" b:ff="" d:ex="" ep="" c:fn="" b:de="" d:du="" d:ei="" da="" d:cj="" d:aa="" c:ez="" b:bu="" aq="" d:di="" a:ed="" c:eg="" d:cs="" et="" b:cn="" ci="" dc="" df="" eh="" a:dr="" b:dk="" b:ao="" d:db="" cm="" c:ba="" d:el="" ey="" d:ar="" d:dt="" c:em="" a:at="" c:fl="" d:ac="" c:bj="" d:fb="" d:cu="" b:bv="" d:bd="" a:fh="" cx="" eo="" c:cg=""/>
+<e b:bb="" df="" a:bv="" a:au="" as="" co="" d:ff="" c:be="" b:bh="" c:bg="" cu="" cl="" b:cs="" c:fb="" c:ds="" b:dh="" c:eg="" a:aw="" a:fg="" a:cj="" a:bp="" fi="" cy="" b:fm="" cw="" a:ap="" a:ew="" a:db="" c:aj="" b:aq="" em="" ce="" d:ep="" ae="" c:bn="" c:dk="" dr="" b:ed="" a:dm="" a:dw="" d:bx="" dl="" c:bo="" c:fc="" a:ax="" a:eu="" b:eq="" a:es="" a:dz="" cn="" ei="" d:ai="" b:ct="" cf="" bs="" b:fi="" b:bc="" d:er="" d:ah="" a:dq="" b:cc="" d:ef="" ci="" b:cr="" a:ak="" d:dd="" cm="" a:bf="" c:fe="" a:bk="" c:ec="" a:cz="" d:bi="" b:fk="" b:dp="" an="" a:dj="" a:cv="" a:dy="" d:bm="" a:br="" a:cq="" d:ex="" b:ek="" ch="" d:fn="" fj="" b:ao="" c:ej="" b:dg="" d:ev="" d:fh="" b:da="" b:af="" a:de="" b:fd="" c:by="" d:ca="" b:ac="" c:az="" a:ey="" c:cg="" cx="" ad="" a:cp="" c:eh="" d:cd="" a:eb="" d:bt="" bd="" dn="" b:bw="" c:bq="" d:bl="" ez="" d:di="" do="" a:ba="" a:bj="" c:am="" c:fl="" b:bu="" c:en="" b:bz="" c:ck="" a:at="" a:du="" c:ay="" d:dx="" ag="" a:ea="" d:cb="" dt="" a:fa="" a:av="" d:eo="" cg="" d:et="" a:ar="" d:ee="" al="" d:aa="" el="" d:dc="" d:dv="" a:ab=""/>
+<e a:ct="" a:bc="" b:dd="" c:dc="" ew="" d:bp="" b:ba="" d:dh="" c:eu="" a:da="" c:eh="" d:eq="" d:dx="" eb="" df="" d:aa="" a:cw="" c:fc="" c:bf="" b:cc="" c:bd="" a:dp="" cb="" c:bg="" do="" cl="" c:co="" ee="" b:af="" c:bo="" a:fi="" d:cd="" c:cs="" dj="" d:al="" d:fe="" b:dt="" bl="" d:ag="" c:di="" b:en="" a:ci="" ds="" bx="" c:cr="" ae="" d:es="" b:fk="" c:cx="" dl="" d:bz="" a:ad="" c:ep="" c:at="" bw="" d:cn="" b:aq="" c:ez="" a:bi="" a:db="" b:dg="" b:ea="" c:bt="" a:bj="" d:ca="" c:fb="" bm="" c:dr="" aj="" c:ai="" d:bs="" a:au="" d:cz="" d:du="" c:dq="" b:er="" c:cq="" a:dy="" fl="" c:ay="" a:dw="" d:bv="" bk="" b:ac="" d:an="" d:ch="" fn="" dm="" a:by="" em="" b:ec="" c:av="" a:cg="" et="" bu="" c:ap="" ao="" ar="" d:dn="" d:cy="" b:cu="" b:bn="" br="" a:bh="" fj="" c:ah="" b:de="" b:ce="" a:fm="" aw="" c:eo="" eg="" a:ef="" ej="" am="" a:be="" b:dk="" c:ek="" d:el="" c:de="" dv="" c:ax="" bq="" b:ei="" b:cp="" b:ab="" a:ak="" b:ex="" d:cm="" ck="" a:ev="" a:fd="" fg="" d:az="" a:fa="" b:bx="" a:as="" a:cf="" c:ed="" a:ey="" dz="" c:bb="" cv="" b:fh="" c:cj="" c:ff=""/>
+<e b:bx="" a:ey="" a:fc="" b:dm="" d:ar="" b:di="" b:bk="" b:at="" b:fj="" c:de="" b:cb="" a:dh="" a:ev="" ci="" c:ch="" a:al="" c:ca="" c:fh="" dx="" a:cs="" a:cz="" cp="" b:dy="" cu="" c:aj="" c:cf="" b:em="" d:ew="" bo="" d:co="" a:cw="" ap="" bl="" c:el="" c:dv="" a:eg="" fl="" b:er="" bd="" d:ay="" af="" a:ee="" eq="" b:cc="" be="" b:ed="" d:du="" dw="" d:cv="" cg="" d:ac="" b:aw="" c:ct="" dd="" da="" d:fk="" b:ae="" b:cj="" ck="" b:dt="" ff="" ez="" b:en="" c:bt="" d:cl="" c:dn="" a:bs="" bm="" c:am="" b:dj="" b:cx="" as="" d:eb="" d:eh="" a:ex="" dq="" dr="" dg="" eu="" fn="" ax="" b:ej="" cm="" a:bj="" fa="" d:bv="" a:ei="" a:dp="" ds="" c:cr="" a:br="" ec="" d:bp="" d:ax="" a:ba="" b:av="" b:dz="" d:fb="" b:bu="" c:fi="" bf="" bc="" d:by="" cn="" ce="" a:bn="" bg="" d:dc="" a:cd="" bz="" bi="" ah="" a:es="" d:ep="" dk="" a:bb="" c:ad="" an="" a:au="" ag="" bh="" b:aa="" c:eo="" a:bq="" fm="" bw="" b:ab="" c:fg="" db="" d:az="" b:ea="" a:ai="" b:fd="" do="" b:cy="" a:fe="" b:et="" c:fe="" d:dl="" c:ef="" d:ek="" b:aq="" d:df="" d:ao="" c:ak="" c:cq=""/>
+<e fk="" a:bg="" ev="" a:cj="" b:ci="" b:by="" b:bx="" a:bn="" b:fi="" d:be="" de="" ef="" d:cs="" cf="" a:dw="" d:ch="" d:bz="" d:ei="" ce="" c:cn="" b:bw="" bp="" a:cp="" eo="" c:cc="" a:cg="" d:bb="" dm="" a:bm="" d:eo="" c:az="" dd="" b:ck="" c:dl="" ds="" a:et="" a:aj="" a:dk="" d:as="" bf="" an="" c:fl="" a:ek="" d:ca="" a:di="" a:fd="" b:ec="" a:br="" ep="" a:cd="" d:em="" b:er="" b:av="" cw="" c:ae="" bu="" b:dh="" d:en="" c:dn="" c:ey="" d:cl="" fj="" d:am="" c:fb="" c:ay="" fh="" bo="" c:bv="" a:fg="" ax="" cz="" dr="" c:eu="" b:fc="" c:cr="" c:ac="" ak="" d:dt="" ej="" d:ex="" b:at="" b:bs="" es="" df="" d:bt="" a:eh="" b:bl="" a:cx="" bj="" c:af="" dx="" a:eb="" a:cv="" d:ez="" d:ed="" dz="" db="" d:fe="" fm="" c:ar="" c:aw="" d:eg="" fa="" dg="" ea="" d:eq="" a:bc="" b:dp="" d:co="" cy="" c:bi="" cb="" b:dy="" d:cu="" bq="" au="" a:dc="" c:ah="" b:bh="" cq="" a:dv="" c:ew="" d:br="" c:do="" c:bd="" aq="" c:ff="" d:fn="" c:ct="" c:ap="" a:ab="" c:al="" d:du="" a:dj="" b:ee="" a:ai="" d:aa="" a:cm="" c:dq="" c:ao="" c:ag="" b:ad="" a:ba="" bk="" a:el="" d:da=""/>
+<e d:fc="" b:cd="" d:ab="" a:fg="" a:ax="" bg="" cw="" c:au="" c:co="" d:em="" a:ai="" c:ac="" dl="" c:ce="" b:at="" c:dg="" a:eb="" d:bv="" eu="" c:fd="" d:aa="" b:as="" cx="" a:ad="" b:bp="" aj="" c:ae="" cq="" db="" b:ef="" c:bu="" d:fh="" d:ao="" d:cr="" d:du="" c:eo="" c:fa="" d:ek="" cg="" ew="" b:bc="" fk="" ca="" d:fj="" cc="" a:er="" a:cj="" a:cl="" d:et="" c:dq="" c:fn="" d:cm="" cf="" b:ei="" d:ec="" d:bf="" a:cn="" a:br="" d:bw="" dn="" b:ck="" c:eg="" b:cp="" d:fb="" a:ba="" b:ci="" d:eh="" en="" c:ej="" c:bx="" a:dm="" d:bt="" b:ee="" dk="" ap="" d:be="" d:dr="" d:dy="" c:ea="" b:ah="" c:bk="" c:de="" dp="" el="" b:bo="" cb="" fi="" cz="" a:al="" ct="" bh="" b:ez="" ek="" af="" d:dx="" c:ev="" a:bz="" bl="" a:ep="" d:df="" ex="" do="" d:dz="" bj="" ay="" b:eq="" ar="" b:cu="" d:dt="" cs="" da="" c:dw="" d:bq="" c:ag="" by="" b:ch="" b:ak="" b:dv="" c:an="" a:ds="" b:bd="" b:ed="" c:bb="" b:az="" c:dj="" c:aq="" d:cy="" d:dh="" ff="" a:av="" dd="" c:bn="" aw="" ay="" a:ey="" b:cv="" d:bi="" b:fl="" fe="" b:am="" c:fm="" c:di="" bs="" dc="" b:bm="" es=""/>
+<e d:em="" c:eu="" aj="" c:ch="" b:af="" b:dv="" d:di="" b:bm="" bc="" c:ci="" c:do="" b:fl="" b:fm="" c:eb="" a:dt="" c:ca="" by="" c:ao="" c:ep="" a:ez="" c:ax="" b:ct="" d:ei="" cd="" dg="" a:ek="" c:bf="" be="" de="" an="" cm="" cz="" b:eh="" d:ae="" d:dk="" b:cc="" c:ev="" c:cs="" aq="" d:ej="" a:bo="" dr="" el="" c:bd="" d:cw="" c:ap="" c:du="" d:av="" b:cp="" ec="" a:cr="" b:dm="" bl="" a:cx="" a:bs="" d:eg="" bv="" dl="" c:ah="" d:ay="" a:fh="" b:er="" b:ey="" aw="" c:bk="" es="" b:ed="" b:au="" ea="" a:az="" bt="" c:ag="" d:fk="" fa="" a:bz="" c:al="" d:ar="" a:aa="" c:br="" cc="" c:eq="" c:ak="" b:ck="" d:dp="" c:ex="" dy="" b:ef="" c:ew="" d:cf="" a:da="" cl="" c:bi="" a:et="" a:ai="" bq="" d:bn="" dc="" bb="" a:ds="" a:co="" d:bu="" d:bx="" b:cy="" b:ee="" fi="" a:ac="" d:ba="" dn="" c:fc="" a:bp="" d:fd="" cb="" c:dj="" b:cg="" a:dh="" c:fm="" d:ad="" c:as="" a:dz="" ff="" c:dx="" d:cj="" d:dw="" am="" b:dq="" a:df="" ab="" a:cu="" d:at="" a:dd="" a:fb="" cq="" a:bh="" b:cv="" b:eo="" d:bj="" b:en="" fn="" fg="" bw="" c:fj="" d:cn="" c:bg="" db="" ce="" a:fe=""/>
+<e c:at="" a:aq="" b:ae="" b:bz="" d:dy="" fj="" b:ci="" ai="" c:ax="" a:bw="" a:ei="" a:dt="" c:dz="" c:cr="" c:fh="" b:ah="" a:fc="" bf="" d:aj="" b:ca="" c:dg="" c:co="" c:fe="" a:di="" b:fk="" c:em="" d:ey="" c:ec="" b:ff="" c:au="" a:ad="" ev="" a:bk="" bi="" d:db="" av="" d:en="" b:bn="" a:ao="" d:ag="" b:bj="" d:ee="" a:cs="" bu="" bq="" aa="" bg="" cm="" fa="" cw="" b:cn="" b:ay="" b:ds="" b:dj="" b:dm="" d:fi="" b:ej="" a:de="" c:bc="" d:cb="" du="" c:cj="" d:bm="" a:dr="" a:fl="" a:el="" dq="" b:cf="" c:fg="" c:ea="" a:bv="" c:ba="" dx="" a:bs="" b:ew="" a:ct="" c:df="" b:dp="" cv="" b:cq="" a:dd="" c:dv="" d:bl="" c:ek="" d:eu="" cg="" b:er="" br="" bx="" c:am="" c:eo="" ak="" a:cu="" dk="" b:cw="" da="" dn="" c:eg="" ef="" ed="" d:bt="" b:ch="" a:dl="" dh="" a:cz="" d:cc="" b:cl="" a:eh="" bp="" b:by="" c:an="" a:fd="" c:eb="" as="" b:fm="" fn="" a:aw="" cy="" b:al="" b:az="" a:ez="" ep="" c:ar="" d:fb="" b:do="" es="" d:be="" b:bo="" b:cx="" ap="" c:dc="" d:ck="" b:cd="" c:ab="" c:bb="" b:ce="" et="" c:eq="" bd="" d:dw="" a:cp="" a:ac="" c:bh="" c:ex="" c:cu="" b:af=""/>
+<e b:bb="" ay="" bs="" eo="" a:ff="" d:dq="" c:es="" a:al="" b:bw="" c:ca="" eb="" c:dr="" d:en="" d:bl="" b:dm="" fc="" a:cf="" d:de="" d:ac="" c:el="" c:bl="" a:cj="" b:ci="" ew="" b:cz="" c:dd="" d:fh="" b:aw="" c:fn="" c:bm="" dv="" b:bg="" dh="" d:an="" d:am="" c:dk="" b:fk="" bv="" a:bd="" c:ak="" c:ba="" dp="" a:af="" b:cu="" b:dy="" a:cy="" a:as="" d:co="" d:ee="" c:df="" a:ad="" c:dx="" c:ei="" c:br="" b:ek="" d:ch="" b:et="" b:bj="" aa="" a:fj="" c:dw="" c:ed="" a:ar="" b:eh="" dl="" eg="" c:cq="" eu="" b:dj="" ds="" b:au="" fm="" b:bk="" bc="" a:cm="" ao="" a:cv="" em="" b:ey="" b:cw="" c:av="" d:fl="" a:eq="" c:fi="" a:ag="" c:cl="" ck="" fb="" c:di="" ej="" d:aa="" d:dn="" a:ae="" ap="" fe="" a:cx="" c:cc="" ef="" by="" b:ev="" d:aq="" d:ex="" a:be="" d:dt="" c:er="" bu="" a:at="" b:az="" c:bx="" b:bh="" d:cn="" da="" a:ce="" a:cs="" a:dz="" bo="" c:du="" d:db="" b:cg="" c:cd="" b:ct="" cb="" a:bp="" d:bf="" a:ah="" ab="" a:fg="" d:ea="" a:dc="" a:ez="" b:ax="" b:dg="" do="" c:cp="" b:bz="" b:aj="" a:bn="" bt="" ai="" b:fd="" bi="" c:cr="" bq="" b:ec="" a:ep="" b:fa=""/>
+<e b:ag="" d:eo="" a:fl="" d:cc="" c:ak="" b:fg="" a:ab="" c:eq="" c:bj="" cr="" ez="" b:ap="" b:cj="" b:dy="" dq="" c:cs="" d:fn="" ex="" a:ff="" c:bc="" ev="" bd="" d:df="" c:dw="" d:cd="" cw="" b:fa="" d:fd="" al="" et="" c:bn="" b:cp="" c:av="" a:dx="" bq="" b:du="" d:ao="" b:cf="" b:ef="" b:da="" dn="" a:es="" b:cv="" di="" a:er="" a:fj="" a:bx="" a:ea="" c:el="" d:as="" a:ch="" d:dq="" d:br="" ey="" a:ac="" au="" c:ed="" bh="" b:ek="" c:bu="" a:an="" c:ah="" d:ba="" b:dd="" cm="" b:bl="" c:aa="" bm="" a:ct="" d:dt="" c:dl="" a:ej="" a:bb="" d:bi="" em="" c:af="" a:bt="" a:bv="" d:cu="" a:fi="" b:aq="" ew="" c:fc="" c:cx="" db="" b:ay="" c:bk="" a:bs="" a:am="" c:dz="" b:eh="" d:ce="" c:fm="" c:at="" d:ep="" dj="" bp="" c:ae="" cg="" a:dp="" d:aw="" a:de="" d:eb="" c:ax="" c:dk="" b:bf="" c:dv="" d:fb="" b:ee="" ad="" a:az="" d:fh="" c:cn="" cq="" dc="" c:cb="" d:ei="" a:ci="" ai="" b:eu="" c:do="" cl="" b:bw="" d:ck="" d:en="" c:ef="" b:eg="" dg="" d:dm="" b:by="" d:bz="" b:aj="" d:co="" b:dr="" d:be="" a:fe="" ds="" cy="" fk="" c:cz="" ar="" b:dh="" c:ca="" c:ec="" c:bg="" b:bo=""/>
+<e b:fj="" d:ee="" a:dl="" b:do="" cu="" bb="" b:ej="" b:co="" du="" b:bq="" b:fh="" a:an="" bz="" d:bp="" c:bc="" d:cn="" c:em="" d:dw="" d:eg="" d:ey="" b:cf="" b:cb="" a:eh="" bx="" a:dm="" c:at="" d:fk="" d:ff="" a:ai="" c:dt="" ec="" c:aa="" c:ea="" a:fe="" cs="" a:ah="" c:bf="" a:by="" en="" c:cg="" d:dg="" d:fd="" c:ak="" dj="" aj="" a:be="" c:ck="" c:ez="" b:dd="" c:cm="" aq="" b:fg="" a:br="" a:bk="" d:ba="" b:ep="" b:dk="" b:el="" fi="" a:cz="" a:bm="" b:bl="" b:cl="" a:de="" ed="" c:cc="" cx="" fb="" al="" bo="" fa="" c:cv="" b:dh="" d:ar="" a:as="" c:ds="" d:bh="" d:ae="" c:bi="" b:az="" c:ca="" c:dq="" d:cd="" ay="" a:fl="" a:eu="" ch="" ag="" d:bs="" a:dv="" c:dz="" a:ce="" a:et="" b:dx="" d:ad="" d:ax="" d:eq="" d:eb="" c:cw="" a:bn="" a:dy="" av="" au="" c:ci="" c:bv="" b:ao="" c:af="" b:ef="" cr="" c:cp="" a:cy="" dp="" eo="" fm="" fc="" a:aw="" au="" a:ei="" a:ap="" d:cq="" a:er="" a:df="" a:ex="" c:am="" db="" di="" bt="" dn="" a:bd="" c:bw="" a:el="" b:dr="" a:es="" a:ev="" d:fn="" c:ct="" d:ew="" d:ek="" a:bu="" b:dc="" d:ab="" cj="" d:bj="" a:bg="" a:da="" ac=""/>
+<e a:dw="" c:bu="" c:fl="" b:er="" d:ay="" c:bk="" cg="" a:fb="" b:br="" eq="" d:ek="" a:ag="" ds="" cw="" d:bj="" aw="" c:cz="" c:dg="" d:ey="" d:as="" ce="" a:eg="" b:az="" d:dq="" dj="" bl="" a:ch="" dm="" d:cv="" b:bp="" bs="" d:aa="" c:ex="" aj="" a:fg="" d:et="" b:es="" c:at="" c:an="" a:am="" c:ep="" d:di="" b:dz="" d:ea="" b:bh="" ba="" bn="" ac="" b:av="" c:ci="" d:aq="" b:da="" dn="" cs="" ap="" c:dy="" do="" b:cp="" d:cl="" el="" d:bw="" b:fh="" dt="" a:dc="" c:bo="" ej="" c:dk="" bg="" a:ei="" d:bd="" c:em="" c:ew="" b:fm="" c:en="" d:cm="" b:dx="" b:bx="" a:ab="" bf="" cj="" b:fj="" a:dl="" d:fe="" d:eu="" b:bv="" c:cb="" co="" b:fd="" a:bm="" d:ax="" a:aw="" ad="" a:bc="" d:cr="" a:fa="" ct="" eh="" d:ai="" d:fi="" b:ff="" b:ae="" c:fc="" c:dh="" ee="" ef="" d:fk="" a:dj="" c:cy="" b:bt="" cn="" bi="" c:be="" dv="" ca="" c:al="" by="" a:bb="" a:cq="" bz="" b:au="" d:dp="" ec="" b:ed="" c:eb="" d:db="" b:ev="" ao="" c:cu="" b:ak="" eo="" dd="" df="" b:cc="" a:ah="" fn="" c:cf="" b:bq="" b:de="" dr="" d:du="" c:cd="" d:af="" a:ez="" ar="" b:cx="" a:ck=""/>
+<e et="" a:bt="" d:ai="" bb="" d:fb="" b:ak="" a:ci="" as="" da="" d:cm="" eg="" c:ej="" ek="" b:ag="" c:dm="" ck="" dh="" bu="" d:de="" em="" d:dw="" d:cs="" a:fi="" a:fl="" b:cl="" b:fd="" b:ao="" b:bw="" a:ar="" c:ax="" b:ea="" at="" au="" c:dk="" dd="" b:bk="" ey="" d:be="" d:cw="" di="" c:fc="" b:bd="" d:bc="" a:fk="" cf="" a:ec="" a:cb="" dp="" b:eu="" bq="" d:ah="" a:dt="" b:ef="" a:el="" b:bn="" cc="" d:dg="" b:cr="" bx="" c:aq="" du="" c:cp="" c:cj="" af="" a:db="" c:er="" a:df="" ds="" ct="" c:bl="" b:az="" a:dc="" b:eb="" d:cn="" a:dl="" a:eh="" a:fg="" c:ex="" c:cg="" a:bp="" em="" b:ac="" b:fa="" ee="" d:cd="" d:dq="" cx="" es="" b:bj="" a:fm="" b:en="" d:cz="" fe="" b:by="" bz="" b:dv="" c:aw="" b:cy="" dr="" a:bs="" c:do="" a:bi="" d:dz="" c:ae="" b:bg="" cq="" b:cu="" c:fj="" c:ce="" a:bo="" d:dx="" bv="" d:ez="" d:ei="" b:ab="" d:bf="" a:fh="" d:ay="" d:eo="" b:ep="" d:fn="" b:ba="" c:dn="" al="" ch="" a:aa="" bk="" d:bm="" c:dj="" a:br="" c:an="" ff="" b:ca="" c:ev="" c:aj="" a:ap="" d:cv="" bh="" c:dy="" c:eq="" b:am="" b:ed="" b:co="" a:ew="" c:av="" ad=""/>
+<e c:ei="" a:el="" a:cn="" b:dd="" a:ar="" b:de="" au="" c:bp="" a:cc="" d:dm="" d:ai="" a:eu="" b:dx="" a:ap="" b:bh="" b:ea="" bl="" eo="" ep="" a:ag="" ac="" by="" eb="" a:cf="" b:et="" c:fe="" a:dh="" dz="" bf="" bm="" b:ba="" d:bs="" c:eq="" b:av="" c:fg="" c:af="" c:cg="" df="" ec="" b:em="" a:fb="" d:fd="" a:bo="" c:cs="" c:do="" b:fm="" a:cr="" a:dl="" b:bn="" d:ah="" cu="" a:ds="" d:ca="" b:bt="" fh="" ad="" b:cx="" b:ao="" b:eg="" ce="" c:ex="" bx="" d:ee="" a:as="" b:ax="" c:ek="" b:cj="" c:ew="" c:fk="" c:bc="" c:fi="" b:ff="" c:am="" b:ds="" c:es="" b:bw="" c:co="" bk="" b:bz="" ci="" cq="" d:ev="" c:fa="" c:fn="" a:fl="" da="" b:dc="" b:bd="" al="" ed="" a:aj="" d:cd="" a:fc="" cw="" a:aw="" c:cp="" b:aa="" b:bj="" d:cz="" b:bi="" c:dk="" ay="" d:ae="" a:dp="" dr="" dj="" c:dv="" dq="" d:bq="" a:cb="" d:dn="" d:fj="" b:ez="" b:by="" a:aq="" b:an="" d:dw="" c:ck="" ef="" a:en="" b:dy="" d:du="" d:az="" b:cm="" b:eh="" bu="" c:ab="" b:be="" db="" bv="" d:dt="" bg="" d:dg="" cy="" c:ch="" c:ct="" b:cl="" a:at="" er="" c:ak="" d:cv="" bb="" b:ey="" a:br="" d:di="" ej=""/>
+<e b:ek="" d:cf="" c:ba="" d:aj="" d:aw="" d:dk="" c:cl="" c:be="" b:de="" d:eo="" by="" a:cw="" a:dy="" b:dl="" b:ac="" c:em="" c:dq="" fc="" a:fn="" d:dj="" a:es="" fj="" ct="" cp="" a:cv="" c:ay="" b:dz="" a:ab="" ff="" d:bl="" b:au="" d:bd="" b:aa="" a:cc="" c:bx="" c:bq="" c:er="" c:en="" cr="" c:cq="" a:eh="" c:ag="" c:ao="" a:bp="" b:cx="" bt="" b:ce="" b:cz="" d:fm="" dh="" b:bk="" an="" d:dv="" c:af="" a:ey="" fd="" a:bs="" a:ee="" dr="" d:ar="" b:bf="" d:do="" b:ez="" bv="" a:co="" c:fb="" c:cs="" b:ch="" d:eb="" a:av="" d:as="" cr="" d:cn="" bh="" c:bm="" b:bj="" cd="" a:df="" fe="" c:eu="" a:dm="" ej="" bn="" d:fh="" a:az="" d:fl="" d:dg="" a:ew="" c:ai="" cm="" c:ah="" c:dw="" c:bb="" a:el="" eg="" a:di="" d:cy="" d:ei="" ec="" c:da="" a:ci="" b:fi="" b:ep="" c:ev="" a:dc="" b:fk="" c:cj="" a:ak="" b:du="" c:ck="" d:ap="" c:am="" ae="" dd="" b:bg="" a:at="" a:ea="" bz="" d:eq="" b:db="" b:fg="" b:dt="" d:al="" c:cu="" dx="" ca="" a:az="" d:dp="" bi="" b:et="" d:bw="" d:bu="" d:ed="" d:ex="" d:ef="" d:ax="" bc="" d:br="" b:aq="" a:dn="" d:fa="" d:cb="" d:bo="" ds="" ad="" c:cg=""/>
+<e a:al="" c:ch="" a:fn="" bz="" d:bv="" a:dq="" a:ew="" ei="" c:eo="" bj="" b:aa="" d:aq="" a:eh="" d:dl="" ex="" c:dg="" d:bu="" b:ae="" b:db="" c:dn="" ej="" d:bk="" a:as="" d:el="" ee="" bp="" d:bl="" c:ce="" c:cv="" d:ff="" c:an="" b:bn="" c:co="" dr="" a:ez="" a:dc="" a:dd="" a:bs="" a:eg="" b:fb="" a:bi="" c:az="" c:do="" b:ey="" di="" c:fa="" b:bc="" b:cp="" d:fc="" a:eu="" cj="" d:ay="" b:da="" d:cg="" c:ea="" a:ao="" cw="" bm="" b:ad="" d:dj="" b:ar="" b:be="" b:by="" bx="" d:bw="" d:ep="" d:ef="" d:aj="" eq="" a:ck="" d:eb="" b:dk="" b:fj="" b:ai="" c:cx="" a:ct="" a:fi="" bo="" c:en="" c:bw="" b:ab="" ba="" cn="" c:av="" dv="" de="" c:cl="" cq="" ax="" b:ev="" ek="" a:dy="" a:cy="" a:ds="" a:cy="" d:dz="" a:dh="" d:cs="" a:er="" c:bd="" a:ac="" ap="" c:bt="" aw="" d:cu="" a:bq="" b:dm="" d:cb="" d:at="" d:dp="" b:df="" c:cm="" d:br="" c:bh="" ag="" fl="" et="" am="" d:bg="" ak="" ah="" d:af="" a:dw="" c:fe="" a:bf="" a:fg="" c:cd="" fh="" fk="" a:cz="" d:fd="" d:ec="" au="" ed="" a:cf="" c:dx="" b:cr="" d:ca="" c:em="" d:es="" a:du="" cc="" c:ci="" b:dt="" d:fm="" bb=""/>
+<e a:bn="" b:cy="" c:cf="" a:ev="" a:eo="" b:ex="" d:df="" d:dy="" d:bf="" d:ar="" ad="" a:eb="" d:cl="" c:ee="" c:cb="" d:au="" dc="" c:bz="" ba="" d:dh="" c:cu="" c:er="" b:fh="" c:bu="" d:cs="" a:dx="" bv="" b:du="" d:cn="" c:bb="" a:al="" c:cp="" d:bk="" co="" a:af="" d:fm="" a:do="" b:dn="" ff="" a:eh="" a:cg="" c:fc="" bd="" di="" b:am="" d:ep="" d:fn="" c:as="" a:db="" b:ec="" c:ey="" b:ak="" d:ch="" b:fg="" b:ei="" al="" aj="" ds="" c:ci="" a:dp="" c:cc="" a:ag="" a:bh="" b:br="" dw="" b:de="" c:ce="" b:bp="" c:cd="" b:bo="" c:ca="" c:cx="" a:el="" d:bs="" cj="" ao="" an="" c:bc="" d:ab="" c:dz="" em="" d:da="" c:dt="" d:bq="" c:bi="" b:fl="" a:dl="" d:dg="" ek="" es="" bg="" a:bx="" b:dd="" b:fa="" a:be="" b:ck="" ay="" c:av="" c:ef="" d:eg="" c:cz="" b:eu="" a:ez="" b:et="" dq="" b:bw="" c:bj="" b:ct="" ej="" c:aw="" c:ai="" cr="" c:aq="" a:aa="" d:ah="" c:by="" d:ae="" a:ew="" b:dv="" cq="" b:dr="" b:fi="" b:bt="" a:bm="" c:at="" a:bl="" b:fb="" a:fj="" a:dj="" d:ac="" b:dm="" cm="" d:fe="" a:ed="" ap="" d:dk="" a:ea="" c:en="" c:cv="" c:eq="" c:fk="" ax="" a:az="" a:fd="" d:cw="" d:cs=""/>
+<e d:ed="" a:cx="" a:bb="" c:et="" bg="" cm="" bi="" c:ag="" co="" b:ci="" a:ca="" d:dj="" c:em="" a:ew="" el="" d:fn="" ab="" a:ct="" a:cz="" b:cw="" b:ds="" b:cn="" d:ba="" de="" b:ea="" c:dc="" c:ai="" d:ee="" b:bt="" c:bu="" bc="" da="" b:am="" d:eo="" eu="" a:bp="" d:fe="" ec="" a:dr="" d:cf="" du="" c:bz="" a:ej="" dd="" a:ck="" a:ap="" d:bx="" c:cq="" a:cu="" a:ef="" a:ay="" a:fk="" a:ah="" ar="" b:bn="" d:ek="" a:cj="" d:er="" c:cb="" a:cv="" b:ff="" a:ed="" dk="" ei="" fm="" ax="" b:bq="" a:cy="" b:bh="" cl="" c:ev="" c:ac="" b:dx="" c:bs="" b:ex="" dw="" ep="" b:dy="" cp="" c:dv="" d:fb="" d:bw="" b:di="" c:dg="" a:ad="" b:af="" c:db="" c:df="" fa="" dn="" d:bk="" b:fg="" d:aa="" a:ak="" c:eb="" d:fd="" a:cr="" c:dt="" a:ae="" c:by="" ao="" c:ey="" bd="" a:fl="" b:ez="" c:av="" c:br="" b:dq="" d:bo="" a:at="" c:bj="" c:bl="" c:be="" d:ch="" b:dh="" a:aj="" a:fc="" cg="" a:aq="" a:fj="" cs="" a:as="" b:dp="" bm="" a:bf="" d:fi="" b:eg="" a:cd="" d:ce="" d:dm="" d:az="" a:au="" a:aw="" dz="" b:fh="" dg="" a:do="" a:en="" a:es="" eq="" b:bv="" b:dl="" c:an="" al="" b:eh="" d:cc=""/>
+<e a:ef="" b:bd="" b:do="" a:fn="" a:ab="" eu="" dn="" d:ba="" c:fc="" ey="" b:fj="" c:bp="" b:bg="" a:dv="" dj="" cn="" ae="" cm="" a:ep="" c:bo="" c:dz="" a:ej="" d:ed="" bc="" a:bs="" bf="" eo="" a:ev="" fh="" b:ap="" a:ah="" b:cf="" d:dr="" fl="" d:au="" d:bz="" dt="" d:fd="" ez="" a:bi="" a:bx="" a:ex="" b:al="" er="" a:dv="" d:el="" be="" b:bk="" c:by="" cu="" c:af="" b:as="" a:fb="" b:da="" a:bw="" cs="" b:bv="" d:dk="" c:bb="" d:em="" a:cz="" b:ad="" c:cr="" cw="" d:ag="" a:ec="" c:cd="" co="" b:fk="" ee="" b:fg="" a:br="" b:dc="" av="" d:ff="" b:bt="" b:dd="" a:cq="" d:ch="" a:ak="" a:dw="" c:fa="" ao="" df="" d:eg="" dm="" ca="" a:ek="" b:ac="" b:cj="" c:bl="" a:du="" c:ds="" b:an="" b:at="" d:fm="" b:cl="" d:de="" d:bn="" d:dh="" d:eb="" b:aq="" eh="" c:dy="" a:ay="" b:bq="" b:aw="" a:bh="" a:en="" ct="" d:cg="" ce="" ci="" a:et="" b:bu="" di="" fi="" ck="" es="" ax="" c:bj="" b:dq="" c:am="" b:bs="" cb="" d:az="" aj="" aa="" b:dl="" cc="" d:db="" d:ew="" a:dx="" d:cx="" a:bm="" cy="" dg="" a:dp="" d:ai="" a:ea="" b:eq="" b:ei="" d:ar="" cp="" a:fe="" a:cv=""/>
+<e a:ef="" bl="" cj="" b:do="" d:dk="" a:av="" a:cl="" d:dp="" dm="" a:eb="" c:cv="" c:ak="" d:da="" a:ay="" a:cw="" b:ff="" a:bp="" bt="" b:fc="" bu="" c:eq="" c:ar="" d:co="" cu="" bg="" c:dr="" d:fa="" c:cr="" a:bv="" b:fl="" d:ea="" ae="" b:cz="" b:bh="" c:ao="" b:dl="" b:bd="" de="" cf="" b:cx="" d:ei="" d:dc="" a:fm="" b:du="" d:bz="" a:az="" d:bq="" d:bc="" d:aa="" b:au="" c:dg="" d:aq="" b:dv="" a:cn="" b:eg="" a:bw="" d:be="" c:fd="" b:dy="" dx="" a:eh="" b:dd="" b:bb="" c:fb="" d:ca="" c:bo="" bk="" a:dz="" a:ep="" a:cd="" c:by="" a:ah="" b:al="" a:em="" c:fg="" c:ew="" d:ag="" b:bx="" dt="" an="" a:cb="" a:et="" di="" bj="" d:ex="" c:dn="" a:af="" b:bm="" a:bn="" ec="" a:fn="" ck="" ab="" a:as="" a:bi="" c:ai="" d:ee="" a:cm="" d:ds="" d:dq="" c:ch="" d:cs="" d:ax="" d:ev="" b:at="" b:fh="" c:fj="" b:en="" a:ce="" c:db="" c:dw="" er="" c:df="" fi="" d:ct="" b:ba="" c:ci="" c:ad="" c:ey="" aj="" am="" c:cc="" a:bf="" c:ek="" bw="" c:ap="" c:br="" a:ac="" b:do="" c:ej="" es="" a:dj="" c:ed="" d:ez="" a:aw="" c:bs="" a:el="" b:fe="" cy="" d:cq="" c:eo="" a:cg="" a:dh="" b:eu="" a:cp="" a:fk=""/>
+<e b:fe="" ar="" d:bu="" by="" a:dg="" c:dq="" bm="" cd="" c:ah="" ex="" c:dk="" d:bz="" c:au="" b:fk="" c:do="" b:fa="" c:dn="" d:dd="" d:br="" cs="" d:eg="" ci="" dj="" bk="" c:dz="" b:eq="" d:bn="" c:fb="" a:ef="" ak="" d:cc="" a:el="" a:bw="" a:ev="" ca="" c:dx="" c:ed="" dv="" bo="" d:aj="" b:bu="" a:fj="" a:af="" d:dw="" c:as="" b:cy="" d:cw="" a:al="" c:cl="" ay="" b:fl="" cn="" c:fn="" b:cp="" c:cg="" d:dp="" dc="" b:di="" aw="" a:ez="" b:bq="" d:bx="" c:ai="" a:ew="" a:bs="" c:av="" d:fi="" b:an="" bp="" d:co="" c:fg="" d:dt="" c:eu="" c:bj="" a:dy="" et="" d:ae="" d:du="" d:ba="" a:de="" d:ad="" ds="" b:ey="" ff="" d:am="" c:ee="" b:cz="" c:bf="" a:cb="" b:dr="" d:cx="" c:bl="" a:ek="" eb="" ep="" c:db="" c:ct="" bv="" ch="" c:ce="" em="" d:bb="" d:az="" be="" c:fh="" b:ap="" c:en="" b:fc="" b:aa="" c:ei="" bh="" a:ej="" ac="" b:ax="" c:df="" b:dm="" b:cu="" eh="" es="" b:fm="" c:ag="" cm="" d:da="" dh="" dl="" cv="" fd="" b:at="" c:eo="" b:cf="" b:ec="" d:ab="" bg="" b:cq="" cj="" b:cr="" er="" d:ao="" aq="" b:bd="" bc="" co="" ea="" d:bi="" d:ck="" d:bt=""/>
+</doc>
diff --git a/test/errors/empty.xml b/test/errors/empty.xml
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/errors/extra-content.xml b/test/errors/extra-content.xml
new file mode 100644 (file)
index 0000000..e2ad673
--- /dev/null
@@ -0,0 +1 @@
+<d/>x
diff --git a/test/errors/invalid-start-tag-1.xml b/test/errors/invalid-start-tag-1.xml
new file mode 100644 (file)
index 0000000..587be6b
--- /dev/null
@@ -0,0 +1 @@
+x
diff --git a/test/errors/invalid-start-tag-2.xml b/test/errors/invalid-start-tag-2.xml
new file mode 100644 (file)
index 0000000..9318418
--- /dev/null
@@ -0,0 +1 @@
+<
diff --git a/test/errors/name3.xml b/test/errors/name3.xml
new file mode 100644 (file)
index 0000000..2f5f96e
--- /dev/null
@@ -0,0 +1 @@
+<.name/>
diff --git a/test/errors/quadratic-defattr.xml b/test/errors/quadratic-defattr.xml
new file mode 100644 (file)
index 0000000..dd5189f
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE doc [
+<!ELEMENT doc (e*)>
+<!ELEMENT e EMPTY>
+<!ATTLIST e
+a000 (0) '0' a001 (0) '0' a002 (0) '0' a003 (0) '0' a004 (0) '0' a005 (0) '0'
+a006 (0) '0' a007 (0) '0' a008 (0) '0' a009 (0) '0' a010 (0) '0' a011 (0) '0'
+a012 (0) '0' a013 (0) '0' a014 (0) '0' a015 (0) '0' a016 (0) '0' a017 (0) '0'
+a018 (0) '0' a019 (0) '0' a020 (0) '0' a021 (0) '0' a022 (0) '0' a023 (0) '0'
+a024 (0) '0' a025 (0) '0' a026 (0) '0' a027 (0) '0' a028 (0) '0' a029 (0) '0'
+a030 (0) '0' a031 (0) '0' a032 (0) '0' a033 (0) '0' a034 (0) '0' a035 (0) '0'
+a036 (0) '0' a037 (0) '0' a038 (0) '0' a039 (0) '0' a040 (0) '0' a041 (0) '0'
+a042 (0) '0' a043 (0) '0' a044 (0) '0' a045 (0) '0' a046 (0) '0' a047 (0) '0'
+a048 (0) '0' a049 (0) '0' a050 (0) '0' a051 (0) '0' a052 (0) '0' a053 (0) '0'
+a054 (0) '0' a055 (0) '0' a056 (0) '0' a057 (0) '0' a058 (0) '0' a059 (0) '0'
+a060 (0) '0' a061 (0) '0' a062 (0) '0' a063 (0) '0' a064 (0) '0' a065 (0) '0'
+a066 (0) '0' a067 (0) '0' a068 (0) '0' a069 (0) '0' a070 (0) '0' a071 (0) '0'
+a072 (0) '0' a073 (0) '0' a074 (0) '0' a075 (0) '0' a076 (0) '0' a077 (0) '0'
+a078 (0) '0' a079 (0) '0' a080 (0) '0' a081 (0) '0' a082 (0) '0' a083 (0) '0'
+a084 (0) '0' a085 (0) '0' a086 (0) '0' a087 (0) '0' a088 (0) '0' a089 (0) '0'
+a090 (0) '0' a091 (0) '0' a092 (0) '0' a093 (0) '0' a094 (0) '0' a095 (0) '0'
+a096 (0) '0' a097 (0) '0' a098 (0) '0' a099 (0) '0' a100 (0) '0' a101 (0) '0'
+a102 (0) '0' a103 (0) '0' a104 (0) '0' a105 (0) '0' a106 (0) '0' a107 (0) '0'
+a108 (0) '0' a109 (0) '0' a110 (0) '0' a111 (0) '0' a112 (0) '0' a113 (0) '0'
+a114 (0) '0' a115 (0) '0' a116 (0) '0' a117 (0) '0' a118 (0) '0' a119 (0) '0'
+a120 (0) '0' a121 (0) '0' a122 (0) '0' a123 (0) '0' a124 (0) '0' a125 (0) '0'
+a126 (0) '0' a127 (0) '0' a128 (0) '0' a129 (0) '0' a130 (0) '0' a131 (0) '0'
+a132 (0) '0' a133 (0) '0' a134 (0) '0' a135 (0) '0' a136 (0) '0' a137 (0) '0'
+a138 (0) '0' a139 (0) '0' a140 (0) '0' a141 (0) '0' a142 (0) '0' a143 (0) '0'
+a144 (0) '0' a145 (0) '0' a146 (0) '0' a147 (0) '0' a148 (0) '0' a149 (0) '0'
+a150 (0) '0' a151 (0) '0' a152 (0) '0' a153 (0) '0' a154 (0) '0' a155 (0) '0'
+a156 (0) '0' a157 (0) '0' a158 (0) '0' a159 (0) '0' a160 (0) '0' a161 (0) '0'
+a162 (0) '0' a163 (0) '0' a164 (0) '0' a165 (0) '0' a166 (0) '0' a167 (0) '0'
+a168 (0) '0' a169 (0) '0' a170 (0) '0' a171 (0) '0' a172 (0) '0' a173 (0) '0'
+a174 (0) '0' a175 (0) '0' a176 (0) '0' a177 (0) '0' a178 (0) '0' a179 (0) '0'
+a180 (0) '0' a181 (0) '0' a182 (0) '0' a183 (0) '0' a184 (0) '0' a185 (0) '0'
+a186 (0) '0' a187 (0) '0' a188 (0) '0' a189 (0) '0' a190 (0) '0' a191 (0) '0'
+a192 (0) '0' a193 (0) '0' a194 (0) '0' a195 (0) '0' a196 (0) '0' a197 (0) '0'
+a198 (0) '0' a199 (0) '0' a200 (0) '0' a201 (0) '0' a202 (0) '0' a203 (0) '0'
+a204 (0) '0' a205 (0) '0' a206 (0) '0' a207 (0) '0' a208 (0) '0' a209 (0) '0'
+a210 (0) '0' a211 (0) '0' a212 (0) '0' a213 (0) '0' a214 (0) '0' a215 (0) '0'
+a216 (0) '0' a217 (0) '0' a218 (0) '0' a219 (0) '0' a220 (0) '0' a221 (0) '0'
+a222 (0) '0' a223 (0) '0' a224 (0) '0' a225 (0) '0' a226 (0) '0' a227 (0) '0'
+a228 (0) '0' a229 (0) '0' a230 (0) '0' a231 (0) '0' a232 (0) '0' a233 (0) '0'
+a234 (0) '0' a235 (0) '0' a236 (0) '0' a237 (0) '0' a238 (0) '0' a239 (0) '0'
+a240 (0) '0' a241 (0) '0' a242 (0) '0' a243 (0) '0' a244 (0) '0' a245 (0) '0'
+a246 (0) '0' a247 (0) '0' a248 (0) '0' a249 (0) '0' a250 (0) '0' a251 (0) '0'
+a252 (0) '0' a253 (0) '0' a254 (0) '0' a255 (0) '0' a256 (0) '0' a257 (0) '0'
+a258 (0) '0' a259 (0) '0' a260 (0) '0' a261 (0) '0' a262 (0) '0' a263 (0) '0'
+a264 (0) '0' a265 (0) '0' a266 (0) '0' a267 (0) '0' a268 (0) '0' a269 (0) '0'
+a270 (0) '0' a271 (0) '0' a272 (0) '0' a273 (0) '0' a274 (0) '0' a275 (0) '0'
+a276 (0) '0' a277 (0) '0' a278 (0) '0' a279 (0) '0' a280 (0) '0' a281 (0) '0'
+a282 (0) '0' a283 (0) '0' a284 (0) '0' a285 (0) '0' a286 (0) '0' a287 (0) '0'
+a288 (0) '0' a289 (0) '0' a290 (0) '0' a291 (0) '0' a292 (0) '0' a293 (0) '0'
+a294 (0) '0' a295 (0) '0' a296 (0) '0' a297 (0) '0' a298 (0) '0' a299 (0) '0'
+>
+]>
+<doc>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+<e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/><e/>
+</doc>
diff --git a/test/errors/rec_att_default.xml b/test/errors/rec_att_default.xml
new file mode 100644 (file)
index 0000000..9a33600
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE doc SYSTEM "N" [
+  <!ENTITY a "&b;">
+  <!ATTLIST x y CDATA "&a;">
+  <!ENTITY b "&a;">
+]>
+<doc attr="&a;"/>
diff --git a/test/errors/trailing-null-1.xml b/test/errors/trailing-null-1.xml
new file mode 100644 (file)
index 0000000..de7334d
Binary files /dev/null and b/test/errors/trailing-null-1.xml differ
diff --git a/test/errors/trailing-null-2.xml b/test/errors/trailing-null-2.xml
new file mode 100644 (file)
index 0000000..3bfffd6
Binary files /dev/null and b/test/errors/trailing-null-2.xml differ
diff --git a/test/errors/truncated-utf16.xml b/test/errors/truncated-utf16.xml
new file mode 100644 (file)
index 0000000..b755ddd
Binary files /dev/null and b/test/errors/truncated-utf16.xml differ
diff --git a/test/errors/unclosed-element.xml b/test/errors/unclosed-element.xml
new file mode 100644 (file)
index 0000000..9ba700d
--- /dev/null
@@ -0,0 +1 @@
+<d>
diff --git a/test/errors/utf8-1.xml b/test/errors/utf8-1.xml
new file mode 100644 (file)
index 0000000..0481aa4
--- /dev/null
@@ -0,0 +1 @@
+<d>Ä..............................................................................<<
diff --git a/test/errors/utf8-2.xml b/test/errors/utf8-2.xml
new file mode 100644 (file)
index 0000000..190c7f8
--- /dev/null
@@ -0,0 +1 @@
+<d>.<<€€€€€€€€€€€€€€€€€€€€€€€€€
diff --git a/test/issue626.xml b/test/issue626.xml
new file mode 100644 (file)
index 0000000..5b0f683
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE doc [
+<!ATTLIST e a1 CDATA #IMPLIED>
+<!ATTLIST e a2 CDATA #IMPLIED>
+<!ATTLIST e a3 CDATA #IMPLIED>
+<!ATTLIST e a4 CDATA #IMPLIED>
+<!ATTLIST e a5 CDATA #IMPLIED>
+<!ATTLIST e a6 CDATA #IMPLIED>
+]>
+<doc>
+    <!-- This tests whether xmlCleanSpecialAttr works. The attribute values
+         must not be normalized. -->
+    <e a1=" x  x " a2=" x  x " a3=" x  x " a4=" x  x " a5=" x  x " a6=" x  x "/>
+</doc>
diff --git a/test/issue643.xml b/test/issue643.xml
new file mode 100644 (file)
index 0000000..e4efeaa
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE doc [
+    <!ATTLIST elem xmlns CDATA #FIXED 'urn:def2'>
+    <!ATTLIST elem xmlns:a CDATA #FIXED 'urn:a2'>
+]>
+
+<doc xmlns="urn:def" xmlns:a="urn:a">
+    <elem/>
+</doc>
diff --git a/test/ns-ent.xml b/test/ns-ent.xml
new file mode 100644 (file)
index 0000000..f81fdfc
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE doc [
+  <!ENTITY ent1 "<elem/>">
+  <!ENTITY ent2 "<ns:elem/>">
+]>
+<doc>
+    <a xmlns="urn:a">&ent1;</a>
+    <b xmlns="urn:b">&ent1;</b>
+    <a xmlns:ns="urn:a">&ent2;</a>
+    <b xmlns:ns="urn:b">&ent2;</b>
+</doc>
diff --git a/test/recurse/g0.ent b/test/recurse/g0.ent
new file mode 100644 (file)
index 0000000..46832f1
--- /dev/null
@@ -0,0 +1,4 @@
+hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
+hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
+hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
+hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
diff --git a/test/recurse/g1.ent b/test/recurse/g1.ent
new file mode 100644 (file)
index 0000000..e64e692
--- /dev/null
@@ -0,0 +1,4 @@
+&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;
+&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;
+&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;
+&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;&g0;
diff --git a/test/recurse/g2.ent b/test/recurse/g2.ent
new file mode 100644 (file)
index 0000000..16a80bb
--- /dev/null
@@ -0,0 +1,4 @@
+&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;
+&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;
+&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;
+&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;&g1;
diff --git a/test/recurse/g3.ent b/test/recurse/g3.ent
new file mode 100644 (file)
index 0000000..6407723
--- /dev/null
@@ -0,0 +1,4 @@
+&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;
+&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;
+&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;
+&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;&g2;
diff --git a/test/recurse/ga.ent b/test/recurse/ga.ent
new file mode 100644 (file)
index 0000000..4a182de
--- /dev/null
@@ -0,0 +1 @@
+some internal data
\ No newline at end of file
diff --git a/test/recurse/gb.ent b/test/recurse/gb.ent
new file mode 100644 (file)
index 0000000..1b25ad0
--- /dev/null
@@ -0,0 +1 @@
+&a;&a;
\ No newline at end of file
diff --git a/test/recurse/gc.ent b/test/recurse/gc.ent
new file mode 100644 (file)
index 0000000..c4f16e6
--- /dev/null
@@ -0,0 +1 @@
+&b;&b;
\ No newline at end of file
index 60aa1b6..21b18ae 100644 (file)
 &d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
 &d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
 &d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
 &d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;</foo>
diff --git a/test/recurse/good_attr.xml b/test/recurse/good_attr.xml
new file mode 100644 (file)
index 0000000..6d500dd
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE foo [
+<!ENTITY f "some internal data rather large taking quite some room">
+<!ENTITY e "&f;&f;">
+<!ENTITY d "&e;&e;">
+]>
+<foo bar="&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
+&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;"/>
diff --git a/test/recurse/goodattr.xml b/test/recurse/goodattr.xml
deleted file mode 100644 (file)
index 94f7071..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-<!DOCTYPE foo [
-<!ENTITY f "some internal data rather large taking quite some room">
-<!ENTITY e "&f;&f;">
-<!ENTITY d "&e;&e;">
-]>
-<foo bar="&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;
-&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;"/>
diff --git a/test/recurse/huge_dtd.xml b/test/recurse/huge_dtd.xml
new file mode 100644 (file)
index 0000000..86761b1
--- /dev/null
@@ -0,0 +1,5 @@
+<!-- The DTD is generated dynamically by testrecurse.c -->
+<!DOCTYPE foo SYSTEM "huge_dtd.dtd">
+<!-- Another entity reference to test whether the DTD is added to
+     sizeentities -->
+<foo>&ent;</foo>
diff --git a/test/recurse/lol3.xml b/test/recurse/lol3.xml
deleted file mode 100644 (file)
index acc2346..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>\r
-<!DOCTYPE billion SYSTEM "lol3.dtd">\r
-\r
-<billion></billion>\r
-\r
diff --git a/test/recurse/lol4.patch b/test/recurse/lol4.patch
deleted file mode 100644 (file)
index f41be28..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Index: parser.c
-===================================================================
---- parser.c   (revision 3773)
-+++ parser.c   (working copy)
-@@ -2505,6 +2505,11 @@ xmlStringLenDecodeEntities(xmlParserCtxt
-           c = CUR_SCHAR(str, l);
-       else
-           c = 0;
-+        if ((nbchars > 500000) &&
-+          (ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE)) {
-+          xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
-+          goto int_error;
-+        }
-     }
-     buffer[nbchars++] = 0;
-     return(buffer);
diff --git a/test/recurse/lol_eg.xml b/test/recurse/lol_eg.xml
new file mode 100644 (file)
index 0000000..2f8940b
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE billion [
+  <!ELEMENT billion (#PCDATA)>
+  <!ENTITY g0 SYSTEM "g0.ent">
+  <!ENTITY g1 SYSTEM "g1.ent">
+  <!ENTITY g2 SYSTEM "g2.ent">
+  <!ENTITY g3 SYSTEM "g3.ent">
+]>
+<billion>&g3;</billion>
diff --git a/test/recurse/lol_ep.xml b/test/recurse/lol_ep.xml
new file mode 100644 (file)
index 0000000..705437c
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE billion [
+  <!ELEMENT billion (#PCDATA)>
+  <!ENTITY % p0 SYSTEM "p0.ent">
+  <!ENTITY % p1 SYSTEM "p1.ent">
+  <!ENTITY % p2 SYSTEM "p2.ent">
+  <!ENTITY % p3 SYSTEM "p3.ent">
+  %p3;
+]>
+<billion/>
diff --git a/test/recurse/lol_ip_content.dtd b/test/recurse/lol_ip_content.dtd
new file mode 100644 (file)
index 0000000..fca54b6
--- /dev/null
@@ -0,0 +1,9 @@
+<!ELEMENT billion (#PCDATA)>
+<!ENTITY % p0 "<!---->">
+<!ENTITY % p1 "%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;">
+<!ENTITY % p2 "%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;">
+<!ENTITY % p3 "%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;">
+<!ENTITY % p4 "%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;%p3;">
+<!ENTITY % p5 "%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;%p4;">
+<!ENTITY % p6 "%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;%p5;">
+%p5;
diff --git a/test/recurse/lol_ip_content.xml b/test/recurse/lol_ip_content.xml
new file mode 100644 (file)
index 0000000..4e6f4c5
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!DOCTYPE billion SYSTEM "lol_ip_content.dtd">
+<billion/>
diff --git a/test/recurse/lol_ip_value.xml b/test/recurse/lol_ip_value.xml
new file mode 100644 (file)
index 0000000..dda403d
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>\r
+<!DOCTYPE billion SYSTEM "lol_ip_value.dtd">\r
+\r
+<billion></billion>\r
+\r
diff --git a/test/recurse/lol_param.xml b/test/recurse/lol_param.xml
new file mode 100644 (file)
index 0000000..f627986
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (C) 2020 Sebastian Pipping <sebastian@pipping.org>
+  v3.1 2020-06-21, not (yet) to be published
+
+  "Parameter Laughs", i.e. variant of Billion Laughs Attack
+                           using parameter entities the other way around
+
+  Use of "%pe24;" below makes the XML processor (e.g. "xmlwf -p < file.xml" or
+  "xmllint file.xml > /dev/null") take 3 to 12 seconds on my machine.
+  Increase to "%pe25;" and beyond carefully: use of "%pe40;" makes my machine
+  need a hard reset.
+
+  Note that unlike libxml2, libexpat does not have any protection against
+  billion laughs attacks to this day, so it's not a new vulnerability
+  with regard to libexpat.  Upcoming release libexpat 2.4.0 will have
+  protection against this family of attacks.
+-->
+<!DOCTYPE r [
+  <!ENTITY % pe_1 "<!---->">
+  <!ENTITY % pe_2 "&#37;pe_1;<!---->&#37;pe_1;">
+  <!ENTITY % pe_3 "&#37;pe_2;<!---->&#37;pe_2;">
+  <!ENTITY % pe_4 "&#37;pe_3;<!---->&#37;pe_3;">
+  <!ENTITY % pe_5 "&#37;pe_4;<!---->&#37;pe_4;">
+  <!ENTITY % pe_6 "&#37;pe_5;<!---->&#37;pe_5;">
+  <!ENTITY % pe_7 "&#37;pe_6;<!---->&#37;pe_6;">
+  <!ENTITY % pe_8 "&#37;pe_7;<!---->&#37;pe_7;">
+  <!ENTITY % pe_9 "&#37;pe_8;<!---->&#37;pe_8;">
+  <!ENTITY % pe10 "&#37;pe_9;<!---->&#37;pe_9;">
+  <!ENTITY % pe11 "&#37;pe10;<!---->&#37;pe10;">
+  <!ENTITY % pe12 "&#37;pe11;<!---->&#37;pe11;">
+  <!ENTITY % pe13 "&#37;pe12;<!---->&#37;pe12;">
+  <!ENTITY % pe14 "&#37;pe13;<!---->&#37;pe13;">
+  <!ENTITY % pe15 "&#37;pe14;<!---->&#37;pe14;">
+  <!ENTITY % pe16 "&#37;pe15;<!---->&#37;pe15;">
+  <!ENTITY % pe17 "&#37;pe16;<!---->&#37;pe16;">
+  <!ENTITY % pe17 "&#37;pe16;<!---->&#37;pe16;">
+  <!ENTITY % pe18 "&#37;pe17;<!---->&#37;pe17;">
+  <!ENTITY % pe19 "&#37;pe18;<!---->&#37;pe18;">
+  <!ENTITY % pe20 "&#37;pe19;<!---->&#37;pe19;">
+  <!ENTITY % pe21 "&#37;pe20;<!---->&#37;pe20;">
+  <!ENTITY % pe22 "&#37;pe21;<!---->&#37;pe21;">
+  <!ENTITY % pe23 "&#37;pe22;<!---->&#37;pe22;">
+  <!ENTITY % pe24 "&#37;pe23;<!---->&#37;pe23;">
+  <!ENTITY % pe25 "&#37;pe24;<!---->&#37;pe24;">
+  <!ENTITY % pe26 "&#37;pe25;<!---->&#37;pe25;">
+  <!ENTITY % pe27 "&#37;pe26;<!---->&#37;pe26;">
+  <!ENTITY % pe28 "&#37;pe27;<!---->&#37;pe27;">
+  <!ENTITY % pe29 "&#37;pe28;<!---->&#37;pe28;">
+  <!ENTITY % pe30 "&#37;pe29;<!---->&#37;pe29;">
+  <!ENTITY % pe31 "&#37;pe30;<!---->&#37;pe30;">
+  <!ENTITY % pe32 "&#37;pe31;<!---->&#37;pe31;">
+  <!ENTITY % pe33 "&#37;pe32;<!---->&#37;pe32;">
+  <!ENTITY % pe34 "&#37;pe33;<!---->&#37;pe33;">
+  <!ENTITY % pe35 "&#37;pe34;<!---->&#37;pe34;">
+  <!ENTITY % pe36 "&#37;pe35;<!---->&#37;pe35;">
+  <!ENTITY % pe37 "&#37;pe36;<!---->&#37;pe36;">
+  <!ENTITY % pe38 "&#37;pe37;<!---->&#37;pe37;">
+  <!ENTITY % pe39 "&#37;pe38;<!---->&#37;pe38;">
+  <!ENTITY % pe40 "&#37;pe39;<!---->&#37;pe39;">
+  %pe24; <!-- not at full potential, increase towards "%pe40;" carefully -->
+]>
+<r/>
diff --git a/test/recurse/p0.ent b/test/recurse/p0.ent
new file mode 100644 (file)
index 0000000..82e1292
--- /dev/null
@@ -0,0 +1,4 @@
+<!----><!----><!----><!----><!----><!----><!----><!----><!----><!---->
+<!----><!----><!----><!----><!----><!----><!----><!----><!----><!---->
+<!----><!----><!----><!----><!----><!----><!----><!----><!----><!---->
+<!----><!----><!----><!----><!----><!----><!----><!----><!----><!---->
diff --git a/test/recurse/p1.ent b/test/recurse/p1.ent
new file mode 100644 (file)
index 0000000..9a21bb5
--- /dev/null
@@ -0,0 +1,4 @@
+%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;
+%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;
+%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;
+%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;%p0;
diff --git a/test/recurse/p2.ent b/test/recurse/p2.ent
new file mode 100644 (file)
index 0000000..f45c306
--- /dev/null
@@ -0,0 +1,4 @@
+%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;
+%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;
+%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;
+%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;%p1;
diff --git a/test/recurse/p3.ent b/test/recurse/p3.ent
new file mode 100644 (file)
index 0000000..139d47a
--- /dev/null
@@ -0,0 +1,4 @@
+%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;
+%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;
+%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;
+%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;%p2;
diff --git a/test/recurse/pa.ent b/test/recurse/pa.ent
new file mode 100644 (file)
index 0000000..f68d1d0
--- /dev/null
@@ -0,0 +1 @@
+<!-- comment -->
\ No newline at end of file
diff --git a/test/recurse/pb.ent b/test/recurse/pb.ent
new file mode 100644 (file)
index 0000000..53a8942
--- /dev/null
@@ -0,0 +1 @@
+%a;%a;
\ No newline at end of file
diff --git a/test/recurse/pc.ent b/test/recurse/pc.ent
new file mode 100644 (file)
index 0000000..e3443ea
--- /dev/null
@@ -0,0 +1 @@
+%b;%b;
\ No newline at end of file
diff --git a/test/schemas/issue491_0.xml b/test/schemas/issue491_0.xml
new file mode 100644 (file)
index 0000000..e2b2fc2
--- /dev/null
@@ -0,0 +1 @@
+<Child xmlns="http://www.test.com">5</Child>
diff --git a/test/schemas/issue491_0.xsd b/test/schemas/issue491_0.xsd
new file mode 100644 (file)
index 0000000..8170264
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.com" targetNamespace="http://www.test.com" elementFormDefault="qualified" attributeFormDefault="unqualified">
+  <xs:complexType name="BaseType">
+    <xs:simpleContent>
+      <xs:extension base="xs:int" />
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:complexType name="ChildType">
+    <xs:complexContent>
+      <xs:extension base="BaseType">
+        <xs:sequence>
+          <xs:element name="bad" type="xs:int" minOccurs="0" maxOccurs="1"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:element name="Child" type="ChildType" />
+</xs:schema>
diff --git a/test/schemas/oss-fuzz-51295_0.xml b/test/schemas/oss-fuzz-51295_0.xml
new file mode 100644 (file)
index 0000000..10a7e70
--- /dev/null
@@ -0,0 +1 @@
+<e/>
diff --git a/test/schemas/oss-fuzz-51295_0.xsd b/test/schemas/oss-fuzz-51295_0.xsd
new file mode 100644 (file)
index 0000000..fde96af
--- /dev/null
@@ -0,0 +1,4 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    <xs:element name="e" substitutionGroup="e"/>
+    <xs:element name="t" substitutionGroup="e" type='xs:decimal'/>
+</xs:schema>
diff --git a/test/valid/dtds/huge.ent b/test/valid/dtds/huge.ent
new file mode 100644 (file)
index 0000000..2915fed
--- /dev/null
@@ -0,0 +1,104 @@
+<!-- More than MINLEN (4000) bytes of comments -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+<!-- ................................................................. -->
+
+<!ELEMENT doc (#PCDATA)>
diff --git a/test/valid/dtds/pe-latin1.ent b/test/valid/dtds/pe-latin1.ent
new file mode 100644 (file)
index 0000000..cfee482
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!ENTITY latin1 "äöü">
diff --git a/test/valid/dtds/pe-val-latin1.dtd b/test/valid/dtds/pe-val-latin1.dtd
new file mode 100644 (file)
index 0000000..c7bcb72
--- /dev/null
@@ -0,0 +1,3 @@
+<!ELEMENT doc (#PCDATA)>
+<!ENTITY % pe SYSTEM "pe-val-latin1.ent">
+<!ENTITY latin1 "%pe;">
diff --git a/test/valid/dtds/pe-val-latin1.ent b/test/valid/dtds/pe-val-latin1.ent
new file mode 100644 (file)
index 0000000..171e58f
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+äöü
diff --git a/test/valid/huge.xml b/test/valid/huge.xml
new file mode 100644 (file)
index 0000000..7aed38c
--- /dev/null
@@ -0,0 +1,5 @@
+<!DOCTYPE doc [
+<!ENTITY % pe SYSTEM "dtds/huge.ent">
+%pe;
+]>
+<doc>test</doc>
diff --git a/test/valid/pe-latin1.xml b/test/valid/pe-latin1.xml
new file mode 100644 (file)
index 0000000..33bd910
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE doc [
+<!ELEMENT doc (#PCDATA)>
+<!ENTITY % pe SYSTEM "dtds/pe-latin1.ent">
+%pe;
+]>
+<doc>&latin1;</doc>
diff --git a/test/valid/pe-val-latin1.xml b/test/valid/pe-val-latin1.xml
new file mode 100644 (file)
index 0000000..97664a8
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE doc SYSTEM "dtds/pe-val-latin1.dtd">
+<doc>&latin1;</doc>
diff --git a/testAutomata.c b/testAutomata.c
deleted file mode 100644 (file)
index 8d3cb27..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * testAutomata.c: simple module for testing regexp automata
- *
- * See Copyright for the status of this software.
- *
- * Daniel Veillard <veillard@redhat.com>
- */
-
-#include "libxml.h"
-#ifdef LIBXML_AUTOMATA_ENABLED
-#include <string.h>
-
-#include <libxml/tree.h>
-#include <libxml/xmlautomata.h>
-
-static int scanNumber(char **ptr) {
-    int ret = 0;
-    char *cur;
-
-    cur = *ptr;
-    while ((*cur >= '0') && (*cur <= '9')) {
-       ret = ret * 10 + (*cur - '0');
-       cur++;
-    }
-    *ptr = cur;
-    return(ret);
-}
-
-static void
-testRegexpFile(const char *filename) {
-    FILE *input;
-    char expr[5000];
-    int len;
-    int ret;
-    int i;
-    xmlAutomataPtr am;
-    xmlAutomataStatePtr states[1000];
-    xmlRegexpPtr regexp = NULL;
-    xmlRegExecCtxtPtr exec = NULL;
-
-    for (i = 0;i<1000;i++)
-       states[i] = NULL;
-
-    input = fopen(filename, "rb");
-    if (input == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-               "Cannot open %s for reading\n", filename);
-       return;
-    }
-
-    am = xmlNewAutomata();
-    if (am == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-               "Cannot create automata\n");
-       fclose(input);
-       return;
-    }
-    states[0] = xmlAutomataGetInitState(am);
-    if (states[0] == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-               "Cannot get start state\n");
-       xmlFreeAutomata(am);
-       fclose(input);
-       return;
-    }
-    ret = 0;
-
-    while (fgets(expr, 4500, input) != NULL) {
-       if (expr[0] == '#')
-           continue;
-       len = strlen(expr);
-       len--;
-       while ((len >= 0) &&
-              ((expr[len] == '\n') || (expr[len] == '\t') ||
-               (expr[len] == '\r') || (expr[len] == ' '))) len--;
-       expr[len + 1] = 0;
-       if (len >= 0) {
-           if ((am != NULL) && (expr[0] == 't') && (expr[1] == ' ')) {
-               char *ptr = &expr[2];
-               int from, to;
-
-               from = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               if (states[from] == NULL)
-                   states[from] = xmlAutomataNewState(am);
-               ptr++;
-               to = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               if (states[to] == NULL)
-                   states[to] = xmlAutomataNewState(am);
-               ptr++;
-               xmlAutomataNewTransition(am, states[from], states[to],
-                                        BAD_CAST ptr, NULL);
-           } else if ((am != NULL) && (expr[0] == 'e') && (expr[1] == ' ')) {
-               char *ptr = &expr[2];
-               int from, to;
-
-               from = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               if (states[from] == NULL)
-                   states[from] = xmlAutomataNewState(am);
-               ptr++;
-               to = scanNumber(&ptr);
-               if (states[to] == NULL)
-                   states[to] = xmlAutomataNewState(am);
-               xmlAutomataNewEpsilon(am, states[from], states[to]);
-           } else if ((am != NULL) && (expr[0] == 'f') && (expr[1] == ' ')) {
-               char *ptr = &expr[2];
-               int state;
-
-               state = scanNumber(&ptr);
-               if (states[state] == NULL) {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad state %d : %s\n", state, expr);
-                   break;
-               }
-               xmlAutomataSetFinalState(am, states[state]);
-           } else if ((am != NULL) && (expr[0] == 'c') && (expr[1] == ' ')) {
-               char *ptr = &expr[2];
-               int from, to;
-               int min, max;
-
-               from = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               if (states[from] == NULL)
-                   states[from] = xmlAutomataNewState(am);
-               ptr++;
-               to = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               if (states[to] == NULL)
-                   states[to] = xmlAutomataNewState(am);
-               ptr++;
-               min = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               ptr++;
-               max = scanNumber(&ptr);
-               if (*ptr != ' ') {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Bad line %s\n", expr);
-                   break;
-               }
-               ptr++;
-               xmlAutomataNewCountTrans(am, states[from], states[to],
-                                        BAD_CAST ptr, min, max, NULL);
-           } else if ((am != NULL) && (expr[0] == '-') && (expr[1] == '-')) {
-               /* end of the automata */
-               regexp = xmlAutomataCompile(am);
-               xmlFreeAutomata(am);
-               am = NULL;
-               if (regexp == NULL) {
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Failed to compile the automata");
-                   break;
-               }
-           } else if ((expr[0] == '=') && (expr[1] == '>')) {
-               if (regexp == NULL) {
-                   printf("=> failed not compiled\n");
-               } else {
-                   if (exec == NULL)
-                       exec = xmlRegNewExecCtxt(regexp, NULL, NULL);
-                   if (ret == 0) {
-                       ret = xmlRegExecPushString(exec, NULL, NULL);
-                   }
-                   if (ret == 1)
-                       printf("=> Passed\n");
-                   else if ((ret == 0) || (ret == -1))
-                       printf("=> Failed\n");
-                   else if (ret < 0)
-                       printf("=> Error\n");
-                   xmlRegFreeExecCtxt(exec);
-                   exec = NULL;
-               }
-               ret = 0;
-           } else if (regexp != NULL) {
-               if (exec == NULL)
-                   exec = xmlRegNewExecCtxt(regexp, NULL, NULL);
-               ret = xmlRegExecPushString(exec, BAD_CAST expr, NULL);
-           } else {
-               xmlGenericError(xmlGenericErrorContext,
-                       "Unexpected line %s\n", expr);
-           }
-       }
-    }
-    fclose(input);
-    if (regexp != NULL)
-       xmlRegFreeRegexp(regexp);
-    if (exec != NULL)
-       xmlRegFreeExecCtxt(exec);
-    if (am != NULL)
-       xmlFreeAutomata(am);
-}
-
-int main(int argc, char **argv) {
-
-    xmlInitParser();
-
-    if (argc == 1) {
-       int ret;
-       xmlAutomataPtr am;
-       xmlAutomataStatePtr start, cur;
-       xmlRegexpPtr regexp;
-       xmlRegExecCtxtPtr exec;
-
-       am = xmlNewAutomata();
-       start = xmlAutomataGetInitState(am);
-
-       /* generate a[ba]*a */
-       cur = xmlAutomataNewTransition(am, start, NULL, BAD_CAST"a", NULL);
-       xmlAutomataNewTransition(am, cur, cur, BAD_CAST"b", NULL);
-       xmlAutomataNewTransition(am, cur, cur, BAD_CAST"a", NULL);
-       cur = xmlAutomataNewCountTrans(am, cur, NULL, BAD_CAST"a", 2, 3, NULL);
-       xmlAutomataSetFinalState(am, cur);
-
-       /* compile it in a regexp and free the automata */
-       regexp = xmlAutomataCompile(am);
-       xmlFreeAutomata(am);
-
-       /* test the regexp */
-       xmlRegexpPrint(stdout, regexp);
-       exec = xmlRegNewExecCtxt(regexp, NULL, NULL);
-       ret = xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"b", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL);
-       if (ret == 1)
-           printf("final\n");
-       else if (ret < 0)
-           printf("error\n");
-       if (ret == 0) {
-           ret = xmlRegExecPushString(exec, NULL, NULL);
-           if (ret == 1)
-               printf("final\n");
-           else if (ret < 0)
-               printf("error\n");
-       }
-       xmlRegFreeExecCtxt(exec);
-
-       /* free the regexp */
-       xmlRegFreeRegexp(regexp);
-    } else {
-       int i;
-
-       for (i = 1;i < argc;i++)
-           testRegexpFile(argv[i]);
-    }
-
-    xmlCleanupParser();
-    xmlMemoryDump();
-    return(0);
-}
-
-#else
-#include <stdio.h>
-int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
-    printf("%s : Automata support not compiled in\n", argv[0]);
-    return(0);
-}
-#endif /* LIBXML_AUTOMATA_ENABLED */
index 77b7ba1..6aea44d 100644 (file)
@@ -6,12 +6,12 @@
  * joelwreed@comcast.net
  */
 
-#include "libxml.h"
-#ifdef LIBXML_MODULES_ENABLED
+#include <stdio.h>
 #include <libxml/xmlversion.h>
 
+#ifdef LIBXML_MODULES_ENABLED
+
 #include <limits.h>
-#include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
 
@@ -49,32 +49,31 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     xmlStrPrintf(filename, sizeof(filename),
                  "%s/testdso%s",
                  (const xmlChar*)MODULE_PATH,
-                (const xmlChar*)LIBXML_MODULE_EXTENSION);
+                 (const xmlChar*)LIBXML_MODULE_EXTENSION);
 
     module = xmlModuleOpen((const char*)filename, 0);
-    if (module)
-      {
-        if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
-           fprintf(stderr, "Failure to lookup\n");
-           return(1);
-       }
-       if (hello_world == NULL) {
-           fprintf(stderr, "Lookup returned NULL\n");
-           return(1);
-       }
+    if (module == NULL) {
+      fprintf(stderr, "Failed to open module\n");
+      return(1);
+    }
 
-        (*hello_world)();
+    if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
+      fprintf(stderr, "Failure to lookup\n");
+      return(1);
+    }
+    if (hello_world == NULL) {
+      fprintf(stderr, "Lookup returned NULL\n");
+      return(1);
+    }
 
-        xmlModuleClose(module);
-      }
+    (*hello_world)();
 
-    xmlMemoryDump();
+    xmlModuleClose(module);
 
     return(0);
 }
 
 #else
-#include <stdio.h>
 int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     printf("%s : Module support not compiled in\n", argv[0]);
     return(0);
index 217e04a..95a3c8e 100644 (file)
--- a/testOOM.c
+++ b/testOOM.c
@@ -6,8 +6,6 @@
  * hp@redhat.com
  */
 
-#include "libxml.h"
-
 #include <string.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -352,14 +350,12 @@ int main(int argc, char **argv) {
              if (test_get_malloc_blocks_outstanding () > 0) {
                   fprintf (stdout, "%d blocks leaked\n",
                            test_get_malloc_blocks_outstanding ());
-                 xmlMemoryDump();
                   return 1;
              }
 
            files ++;
        }
     }
-    xmlMemoryDump();
 
     return 0;
 }
index bef6537..fd1f885 100644 (file)
@@ -1,34 +1,26 @@
-#include "libxml.h"
-
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 
-#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
-#include <libxml/globals.h>
-#include <libxml/threads.h>
 #include <libxml/parser.h>
+#include <libxml/threads.h>
+
+#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
 #include <libxml/catalog.h>
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
-#elif defined HAVE_WIN32_THREADS
+#elif defined(_WIN32)
 #include <windows.h>
-#elif defined HAVE_BEOS_THREADS
-#include <OS.h>
 #endif
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <unistd.h>
-#endif
 #include <assert.h>
 
 #define        MAX_ARGC        20
 #define TEST_REPEAT_COUNT 500
 #ifdef HAVE_PTHREAD_H
 static pthread_t tid[MAX_ARGC];
-#elif defined HAVE_WIN32_THREADS
+#elif defined(_WIN32)
 static HANDLE tid[MAX_ARGC];
-#elif defined HAVE_BEOS_THREADS
-static thread_id tid[MAX_ARGC];
 #endif
 
 typedef struct {
@@ -49,13 +41,6 @@ static xmlThreadParams threadParams[] = {
 static const unsigned int num_threads = sizeof(threadParams) /
                                         sizeof(threadParams[0]);
 
-#ifndef xmlDoValidityCheckingDefaultValue
-#error xmlDoValidityCheckingDefaultValue is not a macro
-#endif
-#ifndef xmlGenericErrorContext
-#error xmlGenericErrorContext is not a macro
-#endif
-
 static void *
 thread_specific_data(void *private_data)
 {
@@ -63,59 +48,61 @@ thread_specific_data(void *private_data)
     xmlThreadParams *params = (xmlThreadParams *) private_data;
     const char *filename = params->filename;
     int okay = 1;
+    int options = 0;
 
-    if (!strcmp(filename, "test/threads/invalid.xml")) {
-        xmlDoValidityCheckingDefaultValue = 0;
-        xmlGenericErrorContext = stdout;
-    } else {
-        xmlDoValidityCheckingDefaultValue = 1;
-        xmlGenericErrorContext = stderr;
+    if (xmlCheckThreadLocalStorage() != 0) {
+        printf("xmlCheckThreadLocalStorage failed\n");
+        params->okay = 0;
+        return(NULL);
     }
-#ifdef LIBXML_SAX1_ENABLED
-    myDoc = xmlParseFile(filename);
-#else
-    myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG);
-#endif
+
+    if (strcmp(filename, "test/threads/invalid.xml") != 0) {
+        options |= XML_PARSE_DTDVALID;
+    }
+    myDoc = xmlReadFile(filename, NULL, options);
     if (myDoc) {
         xmlFreeDoc(myDoc);
     } else {
         printf("parse failed\n");
        okay = 0;
     }
-    if (!strcmp(filename, "test/threads/invalid.xml")) {
-        if (xmlDoValidityCheckingDefaultValue != 0) {
-           printf("ValidityCheckingDefaultValue override failed\n");
-           okay = 0;
-       }
-        if (xmlGenericErrorContext != stdout) {
-           printf("xmlGenericErrorContext override failed\n");
-           okay = 0;
-       }
-    } else {
-        if (xmlDoValidityCheckingDefaultValue != 1) {
-           printf("ValidityCheckingDefaultValue override failed\n");
-           okay = 0;
-       }
-        if (xmlGenericErrorContext != stderr) {
-           printf("xmlGenericErrorContext override failed\n");
-           okay = 0;
-       }
-    }
     params->okay = okay;
     return(NULL);
 }
 
-#ifdef HAVE_PTHREAD_H
+#ifdef _WIN32
+static DWORD WINAPI
+win32_thread_specific_data(void *private_data)
+{
+    thread_specific_data(private_data);
+    return(0);
+}
+#endif
+#endif /* LIBXML_THREADS_ENABLED */
+
 int
 main(void)
 {
-    unsigned int i, repeat;
-    int ret;
+    unsigned int repeat;
+    int status = 0;
+
+    (void) repeat;
 
     xmlInitParser();
+
+    if (xmlCheckThreadLocalStorage() != 0) {
+        printf("xmlCheckThreadLocalStorage failed for main thread\n");
+        return(1);
+    }
+
+#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
     for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) {
+        unsigned int i;
+        int ret;
+
        xmlLoadCatalog(catalog);
 
+#ifdef HAVE_PTHREAD_H
         memset(tid, 0xff, sizeof(*tid)*num_threads);
 
        for (i = 0; i < num_threads; i++) {
@@ -134,36 +121,7 @@ main(void)
                exit(1);
            }
        }
-
-       xmlCatalogCleanup();
-       for (i = 0; i < num_threads; i++)
-           if (threadParams[i].okay == 0)
-               printf("Thread %d handling %s failed\n", i,
-                       threadParams[i].filename);
-    }
-    xmlCleanupParser();
-    xmlMemoryDump();
-    return (0);
-}
-#elif defined HAVE_WIN32_THREADS
-static DWORD WINAPI
-win32_thread_specific_data(void *private_data)
-{
-    thread_specific_data(private_data);
-    return(0);
-}
-
-int
-main(void)
-{
-    unsigned int i, repeat;
-    BOOL ret;
-
-    xmlInitParser();
-    for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++)
-    {
-        xmlLoadCatalog(catalog);
-
+#elif defined(_WIN32)
         for (i = 0; i < num_threads; i++)
         {
             tid[i] = (HANDLE) -1;
@@ -195,81 +153,22 @@ main(void)
             }
             CloseHandle (tid[i]);
         }
+#endif /* pthreads */
 
-        xmlCatalogCleanup();
-        for (i = 0; i < num_threads; i++) {
-            if (threadParams[i].okay == 0)
-            printf("Thread %d handling %s failed\n", i,
-                   threadParams[i].filename);
-        }
-    }
-
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-    return (0);
-}
-#elif defined HAVE_BEOS_THREADS
-int
-main(void)
-{
-    unsigned int i, repeat;
-    status_t ret;
+       xmlCatalogCleanup();
 
-    xmlInitParser();
-    printf("Parser initialized\n");
-    for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) {
-    printf("repeat: %d\n",repeat);
-       xmlLoadCatalog(catalog);
-       printf("loaded catalog: %s\n", catalog);
-       for (i = 0; i < num_threads; i++) {
-           tid[i] = (thread_id) -1;
-       }
-       printf("cleaned threads\n");
-       for (i = 0; i < num_threads; i++) {
-               tid[i] = spawn_thread(thread_specific_data, "xmlTestThread", B_NORMAL_PRIORITY, (void *) &threadParams[i]);
-               if (tid[i] < B_OK) {
-                       perror("beos_thread_create");
-                       exit(1);
-               }
-               printf("beos_thread_create %d -> %d\n", i, tid[i]);
-       }
        for (i = 0; i < num_threads; i++) {
-            void *result;
-           ret = wait_for_thread(tid[i], &result);
-           printf("beos_thread_wait %d -> %d\n", i, ret);
-           if (ret != B_OK) {
-                       perror("beos_thread_wait");
-                       exit(1);
-           }
-       }
-
-       xmlCatalogCleanup();
-       ret = B_OK;
-       for (i = 0; i < num_threads; i++)
            if (threadParams[i].okay == 0) {
-                       printf("Thread %d handling %s failed\n", i,
-                               threadParams[i].filename);
-                       ret = B_ERROR;
-               }
+               printf("Thread %d handling %s failed\n", i,
+                       threadParams[i].filename);
+                status = 1;
+            }
+        }
     }
-    xmlCleanupParser();
-    xmlMemoryDump();
+#endif /* LIBXML_THREADS_ENABLED */
 
-       if (ret == B_OK)
-               printf("testThread : BeOS : SUCCESS!\n");
-       else
-               printf("testThread : BeOS : FAILED!\n");
+    xmlCleanupParser();
 
-    return (0);
+    return (status);
 }
-#endif /* pthreads or BeOS threads */
 
-#else /* !LIBXML_THREADS_ENABLED */
-int
-main(void)
-{
-    fprintf(stderr, "libxml was not compiled with thread or catalog support\n");
-    return (0);
-}
-#endif
index c37cc23..0a0aadf 100644 (file)
--- a/testapi.c
+++ b/testapi.c
 /* Disable deprecation warnings */
 #define XML_DEPRECATED
 
-#include "libxml.h"
+#include "config.h"
 #include <stdio.h>
-
-#include <stdlib.h> /* for putenv() */
+#include <stdlib.h>
 #include <string.h>
 #include <libxml/xmlerror.h>
+#include <libxml/catalog.h>
 #include <libxml/relaxng.h>
+#include <libxml/parser.h>
 
 
 static int testlibxml2(void);
@@ -39,7 +40,7 @@ static xmlNsPtr api_ns = NULL;
 
 static void
 structured_errors(void *userData ATTRIBUTE_UNUSED,
-                  xmlErrorPtr error ATTRIBUTE_UNUSED) {
+                  const xmlError *error ATTRIBUTE_UNUSED) {
     generic_errors++;
 }
 
@@ -124,9 +125,12 @@ int main(int argc, char **argv) {
     int ret;
     int blocks, mem;
 
-#ifdef HAVE_PUTENV
-    /* access to the proxy can slow up regression tests a lot */
-    putenv((char *) "http_proxy=");
+#if defined(_WIN32)
+    setvbuf(stdout, NULL, _IONBF, 0);
+    setvbuf(stderr, NULL, _IONBF, 0);
+
+    printf("Skipping on Windows for now\n");
+    return(0);
 #endif
 
     memset(chartab, 0, sizeof(chartab));
@@ -135,6 +139,9 @@ int main(int argc, char **argv) {
     memset(longtab, 0, sizeof(longtab));
 
     xmlInitParser();
+#ifdef LIBXML_CATALOG_ENABLED
+    xmlInitializeCatalog();
+#endif
 #ifdef LIBXML_SCHEMAS_ENABLED
     xmlRelaxNGInitTypes();
 #endif
@@ -162,15 +169,14 @@ int main(int argc, char **argv) {
     mem = xmlMemUsed();
     if ((blocks != 0) || (mem != 0)) {
         printf("testapi leaked %d bytes in %d blocks\n", mem, blocks);
+        ret = 1;
     }
-    xmlMemoryDump();
 
     return (ret != 0);
 }
 
 #include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
-#include <libxml/catalog.h>
 #include <libxml/chvalid.h>
 #include <libxml/dict.h>
 #include <libxml/encoding.h>
@@ -464,10 +470,15 @@ static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val,
         xmlFreeParserCtxt(val);
 }
 
-#ifdef LIBXML_SAX1_ENABLED
+#if defined(LIBXML_SAX1_ENABLED) || \
+    defined(LIBXML_VALID_ENABLED) || \
+    defined(LIBXML_PUSH_ENABLED)
 #define gen_nb_xmlSAXHandlerPtr 2
 static xmlSAXHandlerPtr gen_xmlSAXHandlerPtr(int no, int nr ATTRIBUTE_UNUSED) {
+    (void) no;
+#ifdef LIBXML_SAX1_ENABLED
     if (no == 0) return((xmlSAXHandlerPtr) &xmlDefaultSAXHandler);
+#endif
     return(NULL);
 }
 static void des_xmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, xmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -1457,6 +1468,47 @@ test_htmlAutoCloseTag(void) {
 
 
 static int
+test_htmlCreateFileParserCtxt(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_HTML_ENABLED)
+    int mem_base;
+    htmlParserCtxtPtr ret_val;
+    const char * filename; /* the filename */
+    int n_filename;
+    char * encoding; /* a free form C string describing the HTML document encoding, or NULL */
+    int n_encoding;
+
+    for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+        mem_base = xmlMemBlocks();
+        filename = gen_fileoutput(n_filename, 0);
+        encoding = gen_const_char_ptr(n_encoding, 1);
+
+        ret_val = htmlCreateFileParserCtxt(filename, (const char *)encoding);
+        desret_htmlParserCtxtPtr(ret_val);
+        call_tests++;
+        des_fileoutput(n_filename, filename, 0);
+        des_const_char_ptr(n_encoding, (const char *)encoding, 1);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCreateFileParserCtxt",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf("\n");
+        }
+    }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
+static int
 test_htmlCreateMemoryParserCtxt(void) {
     int test_ret = 0;
 
@@ -1474,8 +1526,8 @@ test_htmlCreateMemoryParserCtxt(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = htmlCreateMemoryParserCtxt((const char *)buffer, size);
         desret_htmlParserCtxtPtr(ret_val);
@@ -1541,8 +1593,8 @@ test_htmlCreatePushParserCtxt(void) {
         filename = gen_fileoutput(n_filename, 4);
         enc = gen_xmlCharEncoding(n_enc, 5);
         if ((chunk != NULL) &&
-            (size > (int) strlen((const char *) chunk) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST chunk)))
+            size = 0;
 
         ret_val = htmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename, enc);
         desret_htmlParserCtxtPtr(ret_val);
@@ -1588,8 +1640,8 @@ test_htmlCtxtReadDoc(void) {
     htmlDocPtr ret_val;
     htmlParserCtxtPtr ctxt; /* an HTML parser context */
     int n_ctxt;
-    xmlChar * cur; /* a pointer to a zero terminated string */
-    int n_cur;
+    xmlChar * str; /* a pointer to a zero terminated string */
+    int n_str;
     const char * URL; /* the base URL to use for the document */
     int n_URL;
     char * encoding; /* the document encoding, or NULL */
@@ -1598,22 +1650,22 @@ test_htmlCtxtReadDoc(void) {
     int n_options;
 
     for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
-    for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
+    for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) {
     for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
     for (n_options = 0;n_options < gen_nb_int;n_options++) {
         mem_base = xmlMemBlocks();
         ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
-        cur = gen_const_xmlChar_ptr(n_cur, 1);
+        str = gen_const_xmlChar_ptr(n_str, 1);
         URL = gen_filepath(n_URL, 2);
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_int(n_options, 4);
 
-        ret_val = htmlCtxtReadDoc(ctxt, (const xmlChar *)cur, URL, (const char *)encoding, options);
+        ret_val = htmlCtxtReadDoc(ctxt, (const xmlChar *)str, URL, (const char *)encoding, options);
         desret_htmlDocPtr(ret_val);
         call_tests++;
         des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
-        des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1);
+        des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1);
         des_filepath(n_URL, URL, 2);
         des_const_char_ptr(n_encoding, (const char *)encoding, 3);
         des_int(n_options, options, 4);
@@ -1623,7 +1675,7 @@ test_htmlCtxtReadDoc(void) {
                   xmlMemBlocks() - mem_base);
            test_ret++;
             printf(" %d", n_ctxt);
-            printf(" %d", n_cur);
+            printf(" %d", n_str);
             printf(" %d", n_URL);
             printf(" %d", n_encoding);
             printf(" %d", n_options);
@@ -1718,8 +1770,8 @@ test_htmlCtxtReadMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 4);
         options = gen_int(n_options, 5);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = htmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options);
         desret_htmlDocPtr(ret_val);
@@ -2076,6 +2128,31 @@ test_htmlHandleOmittedElem(void) {
 
 
 static int
+test_htmlInitAutoClose(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_HTML_ENABLED)
+    int mem_base;
+
+        mem_base = xmlMemBlocks();
+
+        htmlInitAutoClose();
+        call_tests++;
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlInitAutoClose",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf("\n");
+        }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
+static int
 test_htmlIsAutoClosed(void) {
     int test_ret = 0;
 
@@ -2176,6 +2253,54 @@ test_htmlNewParserCtxt(void) {
     return(test_ret);
 }
 
+#ifdef LIBXML_HTML_ENABLED
+
+#define gen_nb_const_htmlSAXHandler_ptr 1
+#define gen_const_htmlSAXHandler_ptr(no, nr) NULL
+#define des_const_htmlSAXHandler_ptr(no, val, nr)
+#endif
+
+
+static int
+test_htmlNewSAXParserCtxt(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_HTML_ENABLED)
+    int mem_base;
+    htmlParserCtxtPtr ret_val;
+    htmlSAXHandler * sax; /* SAX handler */
+    int n_sax;
+    void * userData; /* user data */
+    int n_userData;
+
+    for (n_sax = 0;n_sax < gen_nb_const_htmlSAXHandler_ptr;n_sax++) {
+    for (n_userData = 0;n_userData < gen_nb_userdata;n_userData++) {
+        mem_base = xmlMemBlocks();
+        sax = gen_const_htmlSAXHandler_ptr(n_sax, 0);
+        userData = gen_userdata(n_userData, 1);
+
+        ret_val = htmlNewSAXParserCtxt((const htmlSAXHandler *)sax, userData);
+        desret_htmlParserCtxtPtr(ret_val);
+        call_tests++;
+        des_const_htmlSAXHandler_ptr(n_sax, (const htmlSAXHandler *)sax, 0);
+        des_userdata(n_userData, userData, 1);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlNewSAXParserCtxt",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_sax);
+            printf(" %d", n_userData);
+            printf("\n");
+        }
+    }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
 
 static int
 test_htmlNodeStatus(void) {
@@ -2278,8 +2403,8 @@ test_htmlParseChunk(void) {
         size = gen_int(n_size, 2);
         terminate = gen_int(n_terminate, 3);
         if ((chunk != NULL) &&
-            (size > (int) strlen((const char *) chunk) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST chunk)))
+            size = 0;
 
         ret_val = htmlParseChunk(ctxt, (const char *)chunk, size, terminate);
         if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
@@ -2624,8 +2749,8 @@ test_htmlReadMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_int(n_options, 4);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = htmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options);
         desret_htmlDocPtr(ret_val);
@@ -2782,10 +2907,11 @@ static int
 test_HTMLparser(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing HTMLparser : 32 of 38 functions ...\n");
+    if (quiet == 0) printf("Testing HTMLparser : 35 of 41 functions ...\n");
     test_ret += test_UTF8ToHtml();
     test_ret += test_htmlAttrAllowed();
     test_ret += test_htmlAutoCloseTag();
+    test_ret += test_htmlCreateFileParserCtxt();
     test_ret += test_htmlCreateMemoryParserCtxt();
     test_ret += test_htmlCreatePushParserCtxt();
     test_ret += test_htmlCtxtReadDoc();
@@ -2799,9 +2925,11 @@ test_HTMLparser(void) {
     test_ret += test_htmlEntityLookup();
     test_ret += test_htmlEntityValueLookup();
     test_ret += test_htmlHandleOmittedElem();
+    test_ret += test_htmlInitAutoClose();
     test_ret += test_htmlIsAutoClosed();
     test_ret += test_htmlIsScriptAttribute();
     test_ret += test_htmlNewParserCtxt();
+    test_ret += test_htmlNewSAXParserCtxt();
     test_ret += test_htmlNodeStatus();
     test_ret += test_htmlParseCharRef();
     test_ret += test_htmlParseChunk();
@@ -3843,8 +3971,8 @@ test_xmlSAX2CDataBlock(void) {
         value = gen_const_xmlChar_ptr(n_value, 1);
         len = gen_int(n_len, 2);
         if ((value != NULL) &&
-            (len > (int) strlen((const char *) value) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST value)))
+            len = 0;
 
         xmlSAX2CDataBlock(ctx, (const xmlChar *)value, len);
         call_tests++;
@@ -3890,8 +4018,8 @@ test_xmlSAX2Characters(void) {
         ch = gen_const_xmlChar_ptr(n_ch, 1);
         len = gen_int(n_len, 2);
         if ((ch != NULL) &&
-            (len > (int) strlen((const char *) ch) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST ch)))
+            len = 0;
 
         xmlSAX2Characters(ctx, (const xmlChar *)ch, len);
         call_tests++;
@@ -4533,8 +4661,8 @@ test_xmlSAX2IgnorableWhitespace(void) {
         ch = gen_const_xmlChar_ptr(n_ch, 1);
         len = gen_int(n_len, 2);
         if ((ch != NULL) &&
-            (len > (int) strlen((const char *) ch) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST ch)))
+            len = 0;
 
         xmlSAX2IgnorableWhitespace(ctx, (const xmlChar *)ch, len);
         call_tests++;
@@ -5171,8 +5299,16 @@ test_xmlSAXDefaultVersion(void) {
     for (n_version = 0;n_version < gen_nb_int;n_version++) {
         mem_base = xmlMemBlocks();
         version = gen_int(n_version, 0);
+        
+        {
+            int original_version = xmlSAXDefaultVersion(2);
+
 
         ret_val = xmlSAXDefaultVersion(version);
+        
+            (void)xmlSAXDefaultVersion(original_version);
+        }
+
         desret_int(ret_val);
         call_tests++;
         des_int(n_version, version, 0);
@@ -5282,7 +5418,7 @@ static int
 test_xmlC14NDocDumpMemory(void) {
     int test_ret = 0;
 
-#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_C14N_ENABLED)
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the XML document for canonization */
@@ -5351,7 +5487,7 @@ static int
 test_xmlC14NDocSave(void) {
     int test_ret = 0;
 
-#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_C14N_ENABLED)
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the XML document for canonization */
@@ -5427,7 +5563,7 @@ static int
 test_xmlC14NDocSaveTo(void) {
     int test_ret = 0;
 
-#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_C14N_ENABLED)
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the XML document for canonization */
@@ -8154,8 +8290,8 @@ test_xmlDictExists(void) {
         name = gen_const_xmlChar_ptr(n_name, 1);
         len = gen_int(n_len, 2);
         if ((name != NULL) &&
-            (len > (int) strlen((const char *) name) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST name)))
+            len = 0;
 
         ret_val = xmlDictExists(dict, (const xmlChar *)name, len);
         desret_const_xmlChar_ptr(ret_val);
@@ -8198,11 +8334,11 @@ test_xmlDictLookup(void) {
 
     int mem_base;
     const xmlChar * ret_val;
-    xmlDictPtr dict; /* the dictionary */
+    xmlDictPtr dict; /* dictionary */
     int n_dict;
-    xmlChar * name; /* the name of the userdata */
+    xmlChar * name; /* string key */
     int n_name;
-    int len; /* the length of the name, if -1 it is recomputed */
+    int len; /* length of the key, if -1 it is recomputed */
     int n_len;
 
     for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) {
@@ -8213,8 +8349,8 @@ test_xmlDictLookup(void) {
         name = gen_const_xmlChar_ptr(n_name, 1);
         len = gen_int(n_len, 2);
         if ((name != NULL) &&
-            (len > (int) strlen((const char *) name) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST name)))
+            len = 0;
 
         ret_val = xmlDictLookup(dict, (const xmlChar *)name, len);
         desret_const_xmlChar_ptr(ret_val);
@@ -9615,7 +9751,7 @@ static int
 test_entities(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing entities : 11 of 17 functions ...\n");
+    if (quiet == 0) printf("Testing entities : 11 of 18 functions ...\n");
     test_ret += test_xmlAddDocEntity();
     test_ret += test_xmlAddDtdEntity();
     test_ret += test_xmlCopyEntitiesTable();
@@ -9641,35 +9777,35 @@ test_xmlHashAddEntry(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* string key */
+    int n_key;
+    void * payload; /* pointer to the payload */
+    int n_payload;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        userdata = gen_userdata(n_userdata, 2);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        payload = gen_void_ptr(n_payload, 2);
 
-        ret_val = xmlHashAddEntry(table, (const xmlChar *)name, userdata);
+        ret_val = xmlHashAddEntry(hash, (const xmlChar *)key, payload);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_userdata(n_userdata, userdata, 2);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_void_ptr(n_payload, payload, 2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashAddEntry",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_userdata);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_payload);
             printf("\n");
         }
     }
@@ -9687,41 +9823,41 @@ test_xmlHashAddEntry2(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    void * payload; /* pointer to the payload */
+    int n_payload;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        userdata = gen_userdata(n_userdata, 3);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        payload = gen_void_ptr(n_payload, 3);
 
-        ret_val = xmlHashAddEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, userdata);
+        ret_val = xmlHashAddEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, payload);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_userdata(n_userdata, userdata, 3);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_void_ptr(n_payload, payload, 3);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashAddEntry2",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_userdata);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_payload);
             printf("\n");
         }
     }
@@ -9740,47 +9876,47 @@ test_xmlHashAddEntry3(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    xmlChar * name3; /* a third name of the userdata */
-    int n_name3;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    xmlChar * key3; /* third string key */
+    int n_key3;
+    void * payload; /* pointer to the payload */
+    int n_payload;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_key3 = 0;n_key3 < gen_nb_const_xmlChar_ptr;n_key3++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        name3 = gen_const_xmlChar_ptr(n_name3, 3);
-        userdata = gen_userdata(n_userdata, 4);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        key3 = gen_const_xmlChar_ptr(n_key3, 3);
+        payload = gen_void_ptr(n_payload, 4);
 
-        ret_val = xmlHashAddEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, userdata);
+        ret_val = xmlHashAddEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, payload);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3);
-        des_userdata(n_userdata, userdata, 4);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3);
+        des_void_ptr(n_payload, payload, 4);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashAddEntry3",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_name3);
-            printf(" %d", n_userdata);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_key3);
+            printf(" %d", n_payload);
             printf("\n");
         }
     }
@@ -9829,28 +9965,28 @@ test_xmlHashDefaultDeallocator(void) {
     int test_ret = 0;
 
     int mem_base;
-    void * entry; /* the hash table entry */
+    void * entry; /* hash table entry */
     int n_entry;
-    xmlChar * name; /* the entry's name */
-    int n_name;
+    xmlChar * key; /* the entry's string key */
+    int n_key;
 
     for (n_entry = 0;n_entry < gen_nb_void_ptr;n_entry++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
         mem_base = xmlMemBlocks();
         entry = gen_void_ptr(n_entry, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
+        key = gen_const_xmlChar_ptr(n_key, 1);
 
-        xmlHashDefaultDeallocator(entry, (const xmlChar *)name);
+        xmlHashDefaultDeallocator(entry, (const xmlChar *)key);
         call_tests++;
         des_void_ptr(n_entry, entry, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashDefaultDeallocator",
                   xmlMemBlocks() - mem_base);
            test_ret++;
             printf(" %d", n_entry);
-            printf(" %d", n_name);
+            printf(" %d", n_key);
             printf("\n");
         }
     }
@@ -9867,29 +10003,29 @@ test_xmlHashLookup(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* string key */
+    int n_key;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
 
-        ret_val = xmlHashLookup(table, (const xmlChar *)name);
+        ret_val = xmlHashLookup(hash, (const xmlChar *)key);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashLookup",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
             printf("\n");
         }
     }
@@ -9906,35 +10042,35 @@ test_xmlHashLookup2(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-        mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-
-        ret_val = xmlHashLookup2(table, (const xmlChar *)name, (const xmlChar *)name2);
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+        mem_base = xmlMemBlocks();
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+
+        ret_val = xmlHashLookup2(hash, (const xmlChar *)key, (const xmlChar *)key2);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashLookup2",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
             printf("\n");
         }
     }
@@ -9952,41 +10088,41 @@ test_xmlHashLookup3(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    xmlChar * name3; /* a third name of the userdata */
-    int n_name3;
-
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) {
-        mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        name3 = gen_const_xmlChar_ptr(n_name3, 3);
-
-        ret_val = xmlHashLookup3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3);
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    xmlChar * key3; /* third string key */
+    int n_key3;
+
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_key3 = 0;n_key3 < gen_nb_const_xmlChar_ptr;n_key3++) {
+        mem_base = xmlMemBlocks();
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        key3 = gen_const_xmlChar_ptr(n_key3, 3);
+
+        ret_val = xmlHashLookup3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashLookup3",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_name3);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_key3);
             printf("\n");
         }
     }
@@ -10005,25 +10141,25 @@ test_xmlHashQLookup(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * prefix; /* the prefix of the userdata */
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * prefix; /* prefix of the string key */
     int n_prefix;
-    xmlChar * name; /* the name of the userdata */
+    xmlChar * name; /* local name of the string key */
     int n_name;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
     for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) {
     for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
         prefix = gen_const_xmlChar_ptr(n_prefix, 1);
         name = gen_const_xmlChar_ptr(n_name, 2);
 
-        ret_val = xmlHashQLookup(table, (const xmlChar *)prefix, (const xmlChar *)name);
+        ret_val = xmlHashQLookup(hash, (const xmlChar *)prefix, (const xmlChar *)name);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
+        des_xmlHashTablePtr(n_hash, hash, 0);
         des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1);
         des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2);
         xmlResetLastError();
@@ -10031,7 +10167,7 @@ test_xmlHashQLookup(void) {
             printf("Leak of %d blocks found in xmlHashQLookup",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
+            printf(" %d", n_hash);
             printf(" %d", n_prefix);
             printf(" %d", n_name);
             printf("\n");
@@ -10051,33 +10187,33 @@ test_xmlHashQLookup2(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * prefix; /* the prefix of the userdata */
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * prefix; /* first prefix */
     int n_prefix;
-    xmlChar * name; /* the name of the userdata */
+    xmlChar * name; /* first local name */
     int n_name;
-    xmlChar * prefix2; /* the second prefix of the userdata */
+    xmlChar * prefix2; /* second prefix */
     int n_prefix2;
-    xmlChar * name2; /* a second name of the userdata */
+    xmlChar * name2; /* second local name */
     int n_name2;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
     for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) {
     for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
     for (n_prefix2 = 0;n_prefix2 < gen_nb_const_xmlChar_ptr;n_prefix2++) {
     for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
         prefix = gen_const_xmlChar_ptr(n_prefix, 1);
         name = gen_const_xmlChar_ptr(n_name, 2);
         prefix2 = gen_const_xmlChar_ptr(n_prefix2, 3);
         name2 = gen_const_xmlChar_ptr(n_name2, 4);
 
-        ret_val = xmlHashQLookup2(table, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2);
+        ret_val = xmlHashQLookup2(hash, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
+        des_xmlHashTablePtr(n_hash, hash, 0);
         des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1);
         des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2);
         des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3);
@@ -10087,7 +10223,7 @@ test_xmlHashQLookup2(void) {
             printf("Leak of %d blocks found in xmlHashQLookup2",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
+            printf(" %d", n_hash);
             printf(" %d", n_prefix);
             printf(" %d", n_name);
             printf(" %d", n_prefix2);
@@ -10111,22 +10247,22 @@ test_xmlHashQLookup3(void) {
 
     int mem_base;
     void * ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * prefix; /* the prefix of the userdata */
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * prefix; /* first prefix */
     int n_prefix;
-    xmlChar * name; /* the name of the userdata */
+    xmlChar * name; /* first local name */
     int n_name;
-    xmlChar * prefix2; /* the second prefix of the userdata */
+    xmlChar * prefix2; /* second prefix */
     int n_prefix2;
-    xmlChar * name2; /* a second name of the userdata */
+    xmlChar * name2; /* second local name */
     int n_name2;
-    xmlChar * prefix3; /* the third prefix of the userdata */
+    xmlChar * prefix3; /* third prefix */
     int n_prefix3;
-    xmlChar * name3; /* a third name of the userdata */
+    xmlChar * name3; /* third local name */
     int n_name3;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
     for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) {
     for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
     for (n_prefix2 = 0;n_prefix2 < gen_nb_const_xmlChar_ptr;n_prefix2++) {
@@ -10134,7 +10270,7 @@ test_xmlHashQLookup3(void) {
     for (n_prefix3 = 0;n_prefix3 < gen_nb_const_xmlChar_ptr;n_prefix3++) {
     for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
         prefix = gen_const_xmlChar_ptr(n_prefix, 1);
         name = gen_const_xmlChar_ptr(n_name, 2);
         prefix2 = gen_const_xmlChar_ptr(n_prefix2, 3);
@@ -10142,10 +10278,10 @@ test_xmlHashQLookup3(void) {
         prefix3 = gen_const_xmlChar_ptr(n_prefix3, 5);
         name3 = gen_const_xmlChar_ptr(n_name3, 6);
 
-        ret_val = xmlHashQLookup3(table, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2, (const xmlChar *)prefix3, (const xmlChar *)name3);
+        ret_val = xmlHashQLookup3(hash, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2, (const xmlChar *)prefix3, (const xmlChar *)name3);
         desret_void_ptr(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
+        des_xmlHashTablePtr(n_hash, hash, 0);
         des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1);
         des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2);
         des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3);
@@ -10157,7 +10293,7 @@ test_xmlHashQLookup3(void) {
             printf("Leak of %d blocks found in xmlHashQLookup3",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
+            printf(" %d", n_hash);
             printf(" %d", n_prefix);
             printf(" %d", n_name);
             printf(" %d", n_prefix2);
@@ -10185,35 +10321,35 @@ test_xmlHashRemoveEntry(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlHashDeallocator f; /* the deallocator function for removed item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* string key */
+    int n_key;
+    xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        f = gen_xmlHashDeallocator(n_f, 2);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 2);
 
-        ret_val = xmlHashRemoveEntry(table, (const xmlChar *)name, f);
+        ret_val = xmlHashRemoveEntry(hash, (const xmlChar *)key, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_xmlHashDeallocator(n_f, f, 2);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashRemoveEntry",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -10231,41 +10367,41 @@ test_xmlHashRemoveEntry2(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    xmlHashDeallocator f; /* the deallocator function for removed item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        f = gen_xmlHashDeallocator(n_f, 3);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 3);
 
-        ret_val = xmlHashRemoveEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, f);
+        ret_val = xmlHashRemoveEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_xmlHashDeallocator(n_f, f, 3);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 3);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashRemoveEntry2",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -10284,47 +10420,47 @@ test_xmlHashRemoveEntry3(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    xmlChar * name3; /* a third name of the userdata */
-    int n_name3;
-    xmlHashDeallocator f; /* the deallocator function for removed item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    xmlChar * key3; /* third string key */
+    int n_key3;
+    xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_key3 = 0;n_key3 < gen_nb_const_xmlChar_ptr;n_key3++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        name3 = gen_const_xmlChar_ptr(n_name3, 3);
-        f = gen_xmlHashDeallocator(n_f, 4);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        key3 = gen_const_xmlChar_ptr(n_key3, 3);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 4);
 
-        ret_val = xmlHashRemoveEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, f);
+        ret_val = xmlHashRemoveEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3);
-        des_xmlHashDeallocator(n_f, f, 4);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 4);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashRemoveEntry3",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_name3);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_key3);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -10384,23 +10520,23 @@ test_xmlHashSize(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
 
-        ret_val = xmlHashSize(table);
+        ret_val = xmlHashSize(hash);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
+        des_xmlHashTablePtr(n_hash, hash, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashSize",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
+            printf(" %d", n_hash);
             printf("\n");
         }
     }
@@ -10416,41 +10552,41 @@ test_xmlHashUpdateEntry(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
-    xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* string key */
+    int n_key;
+    void * payload; /* pointer to the payload */
+    int n_payload;
+    xmlHashDeallocator dealloc; /* deallocator function for replaced item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        userdata = gen_userdata(n_userdata, 2);
-        f = gen_xmlHashDeallocator(n_f, 3);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        payload = gen_void_ptr(n_payload, 2);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 3);
 
-        ret_val = xmlHashUpdateEntry(table, (const xmlChar *)name, userdata, f);
+        ret_val = xmlHashUpdateEntry(hash, (const xmlChar *)key, payload, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_userdata(n_userdata, userdata, 2);
-        des_xmlHashDeallocator(n_f, f, 3);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_void_ptr(n_payload, payload, 2);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 3);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashUpdateEntry",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_userdata);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_payload);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -10469,47 +10605,47 @@ test_xmlHashUpdateEntry2(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
-    xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    void * payload; /* pointer to the payload */
+    int n_payload;
+    xmlHashDeallocator dealloc; /* deallocator function for replaced item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        userdata = gen_userdata(n_userdata, 3);
-        f = gen_xmlHashDeallocator(n_f, 4);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        payload = gen_void_ptr(n_payload, 3);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 4);
 
-        ret_val = xmlHashUpdateEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, userdata, f);
+        ret_val = xmlHashUpdateEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, payload, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_userdata(n_userdata, userdata, 3);
-        des_xmlHashDeallocator(n_f, f, 4);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_void_ptr(n_payload, payload, 3);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 4);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashUpdateEntry2",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_userdata);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_payload);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -10529,53 +10665,53 @@ test_xmlHashUpdateEntry3(void) {
 
     int mem_base;
     int ret_val;
-    xmlHashTablePtr table; /* the hash table */
-    int n_table;
-    xmlChar * name; /* the name of the userdata */
-    int n_name;
-    xmlChar * name2; /* a second name of the userdata */
-    int n_name2;
-    xmlChar * name3; /* a third name of the userdata */
-    int n_name3;
-    void * userdata; /* a pointer to the userdata */
-    int n_userdata;
-    xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */
-    int n_f;
+    xmlHashTablePtr hash; /* hash table */
+    int n_hash;
+    xmlChar * key; /* first string key */
+    int n_key;
+    xmlChar * key2; /* second string key */
+    int n_key2;
+    xmlChar * key3; /* third string key */
+    int n_key3;
+    void * payload; /* pointer to the payload */
+    int n_payload;
+    xmlHashDeallocator dealloc; /* deallocator function for replaced item or NULL */
+    int n_dealloc;
 
-    for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) {
-    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) {
-    for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) {
-    for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) {
-    for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) {
+    for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) {
+    for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) {
+    for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) {
+    for (n_key3 = 0;n_key3 < gen_nb_const_xmlChar_ptr;n_key3++) {
+    for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) {
+    for (n_dealloc = 0;n_dealloc < gen_nb_xmlHashDeallocator;n_dealloc++) {
         mem_base = xmlMemBlocks();
-        table = gen_xmlHashTablePtr(n_table, 0);
-        name = gen_const_xmlChar_ptr(n_name, 1);
-        name2 = gen_const_xmlChar_ptr(n_name2, 2);
-        name3 = gen_const_xmlChar_ptr(n_name3, 3);
-        userdata = gen_userdata(n_userdata, 4);
-        f = gen_xmlHashDeallocator(n_f, 5);
+        hash = gen_xmlHashTablePtr(n_hash, 0);
+        key = gen_const_xmlChar_ptr(n_key, 1);
+        key2 = gen_const_xmlChar_ptr(n_key2, 2);
+        key3 = gen_const_xmlChar_ptr(n_key3, 3);
+        payload = gen_void_ptr(n_payload, 4);
+        dealloc = gen_xmlHashDeallocator(n_dealloc, 5);
 
-        ret_val = xmlHashUpdateEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, userdata, f);
+        ret_val = xmlHashUpdateEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, payload, dealloc);
         desret_int(ret_val);
         call_tests++;
-        des_xmlHashTablePtr(n_table, table, 0);
-        des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1);
-        des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2);
-        des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3);
-        des_userdata(n_userdata, userdata, 4);
-        des_xmlHashDeallocator(n_f, f, 5);
+        des_xmlHashTablePtr(n_hash, hash, 0);
+        des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1);
+        des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2);
+        des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3);
+        des_void_ptr(n_payload, payload, 4);
+        des_xmlHashDeallocator(n_dealloc, dealloc, 5);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlHashUpdateEntry3",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_table);
-            printf(" %d", n_name);
-            printf(" %d", n_name2);
-            printf(" %d", n_name3);
-            printf(" %d", n_userdata);
-            printf(" %d", n_f);
+            printf(" %d", n_hash);
+            printf(" %d", n_key);
+            printf(" %d", n_key2);
+            printf(" %d", n_key3);
+            printf(" %d", n_payload);
+            printf(" %d", n_dealloc);
             printf("\n");
         }
     }
@@ -12005,23 +12141,23 @@ test_xmlCreateDocParserCtxt(void) {
 
     int mem_base;
     xmlParserCtxtPtr ret_val;
-    xmlChar * cur; /* a pointer to an array of xmlChar */
-    int n_cur;
+    xmlChar * str; /* a pointer to an array of xmlChar */
+    int n_str;
 
-    for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
+    for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) {
         mem_base = xmlMemBlocks();
-        cur = gen_const_xmlChar_ptr(n_cur, 0);
+        str = gen_const_xmlChar_ptr(n_str, 0);
 
-        ret_val = xmlCreateDocParserCtxt((const xmlChar *)cur);
+        ret_val = xmlCreateDocParserCtxt((const xmlChar *)str);
         desret_xmlParserCtxtPtr(ret_val);
         call_tests++;
-        des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0);
+        des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlCreateDocParserCtxt",
                   xmlMemBlocks() - mem_base);
            test_ret++;
-            printf(" %d", n_cur);
+            printf(" %d", n_str);
             printf("\n");
         }
     }
@@ -12061,8 +12197,8 @@ test_xmlCreatePushParserCtxt(void) {
         size = gen_int(n_size, 3);
         filename = gen_fileoutput(n_filename, 4);
         if ((chunk != NULL) &&
-            (size > (int) strlen((const char *) chunk) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST chunk)))
+            size = 0;
 
         ret_val = xmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename);
         desret_xmlParserCtxtPtr(ret_val);
@@ -12104,8 +12240,8 @@ test_xmlCtxtReadDoc(void) {
     xmlDocPtr ret_val;
     xmlParserCtxtPtr ctxt; /* an XML parser context */
     int n_ctxt;
-    xmlChar * cur; /* a pointer to a zero terminated string */
-    int n_cur;
+    xmlChar * str; /* a pointer to a zero terminated string */
+    int n_str;
     const char * URL; /* the base URL to use for the document */
     int n_URL;
     char * encoding; /* the document encoding, or NULL */
@@ -12114,22 +12250,22 @@ test_xmlCtxtReadDoc(void) {
     int n_options;
 
     for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
-    for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
+    for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) {
     for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
     for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
         mem_base = xmlMemBlocks();
         ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
-        cur = gen_const_xmlChar_ptr(n_cur, 1);
+        str = gen_const_xmlChar_ptr(n_str, 1);
         URL = gen_filepath(n_URL, 2);
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_parseroptions(n_options, 4);
 
-        ret_val = xmlCtxtReadDoc(ctxt, (const xmlChar *)cur, URL, (const char *)encoding, options);
+        ret_val = xmlCtxtReadDoc(ctxt, (const xmlChar *)str, URL, (const char *)encoding, options);
         desret_xmlDocPtr(ret_val);
         call_tests++;
         des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
-        des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1);
+        des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1);
         des_filepath(n_URL, URL, 2);
         des_const_char_ptr(n_encoding, (const char *)encoding, 3);
         des_parseroptions(n_options, options, 4);
@@ -12139,7 +12275,7 @@ test_xmlCtxtReadDoc(void) {
                   xmlMemBlocks() - mem_base);
            test_ret++;
             printf(" %d", n_ctxt);
-            printf(" %d", n_cur);
+            printf(" %d", n_str);
             printf(" %d", n_URL);
             printf(" %d", n_encoding);
             printf(" %d", n_options);
@@ -12242,8 +12378,8 @@ test_xmlCtxtReadMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 4);
         options = gen_parseroptions(n_options, 5);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options);
         desret_xmlDocPtr(ret_val);
@@ -12338,8 +12474,8 @@ test_xmlCtxtResetPush(void) {
         filename = gen_filepath(n_filename, 3);
         encoding = gen_const_char_ptr(n_encoding, 4);
         if ((chunk != NULL) &&
-            (size > (int) strlen((const char *) chunk) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST chunk)))
+            size = 0;
 
         ret_val = xmlCtxtResetPush(ctxt, (const char *)chunk, size, filename, (const char *)encoding);
         desret_int(ret_val);
@@ -12373,6 +12509,16 @@ test_xmlCtxtResetPush(void) {
 
 
 static int
+test_xmlCtxtSetMaxAmplification(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlCtxtUseOptions(void) {
     int test_ret = 0;
 
@@ -12760,6 +12906,49 @@ test_xmlNewParserCtxt(void) {
 }
 
 
+#define gen_nb_const_xmlSAXHandler_ptr 1
+#define gen_const_xmlSAXHandler_ptr(no, nr) NULL
+#define des_const_xmlSAXHandler_ptr(no, val, nr)
+
+static int
+test_xmlNewSAXParserCtxt(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    xmlParserCtxtPtr ret_val;
+    xmlSAXHandler * sax; /* SAX handler */
+    int n_sax;
+    void * userData; /* user data */
+    int n_userData;
+
+    for (n_sax = 0;n_sax < gen_nb_const_xmlSAXHandler_ptr;n_sax++) {
+    for (n_userData = 0;n_userData < gen_nb_userdata;n_userData++) {
+        mem_base = xmlMemBlocks();
+        sax = gen_const_xmlSAXHandler_ptr(n_sax, 0);
+        userData = gen_userdata(n_userData, 1);
+
+        ret_val = xmlNewSAXParserCtxt((const xmlSAXHandler *)sax, userData);
+        desret_xmlParserCtxtPtr(ret_val);
+        call_tests++;
+        des_const_xmlSAXHandler_ptr(n_sax, (const xmlSAXHandler *)sax, 0);
+        des_userdata(n_userData, userData, 1);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlNewSAXParserCtxt",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_sax);
+            printf(" %d", n_userData);
+            printf("\n");
+        }
+    }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
 #define gen_nb_xmlNodePtr_ptr 1
 #define gen_xmlNodePtr_ptr(no, nr) NULL
 #define des_xmlNodePtr_ptr(no, val, nr)
@@ -12949,8 +13138,8 @@ test_xmlParseChunk(void) {
         size = gen_int(n_size, 2);
         terminate = gen_int(n_terminate, 3);
         if ((chunk != NULL) &&
-            (size > (int) strlen((const char *) chunk) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST chunk)))
+            size = 0;
 
         ret_val = xmlParseChunk(ctxt, (const char *)chunk, size, terminate);
         if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
@@ -13409,8 +13598,8 @@ test_xmlParseMemory(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlParseMemory((const char *)buffer, size);
         desret_xmlDocPtr(ret_val);
@@ -13809,8 +13998,8 @@ test_xmlReadMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_parseroptions(n_options, 4);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options);
         desret_xmlDocPtr(ret_val);
@@ -13934,8 +14123,8 @@ test_xmlRecoverMemory(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlRecoverMemory((const char *)buffer, size);
         desret_xmlDocPtr(ret_val);
@@ -14238,8 +14427,8 @@ test_xmlSAXParseMemory(void) {
         size = gen_int(n_size, 2);
         recovery = gen_int(n_recovery, 3);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlSAXParseMemory(sax, (const char *)buffer, size, recovery);
         desret_xmlDocPtr(ret_val);
@@ -14302,8 +14491,8 @@ test_xmlSAXParseMemoryWithData(void) {
         recovery = gen_int(n_recovery, 3);
         data = gen_userdata(n_data, 4);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlSAXParseMemoryWithData(sax, (const char *)buffer, size, recovery, data);
         desret_xmlDocPtr(ret_val);
@@ -14420,8 +14609,8 @@ test_xmlSAXUserParseMemory(void) {
         buffer = gen_const_char_ptr(n_buffer, 2);
         size = gen_int(n_size, 3);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
         
 #ifdef LIBXML_SAX1_ENABLED
         if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
@@ -14579,11 +14768,267 @@ test_xmlSubstituteEntitiesDefault(void) {
     return(test_ret);
 }
 
+
+static int
+test_xmlThrDefDoValidityCheckingDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefDoValidityCheckingDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefDoValidityCheckingDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefGetWarningsDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefGetWarningsDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefGetWarningsDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefKeepBlanksDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefKeepBlanksDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefKeepBlanksDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefLineNumbersDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefLineNumbersDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefLineNumbersDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefLoadExtDtdDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefLoadExtDtdDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefLoadExtDtdDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefParserDebugEntities(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefParserDebugEntities(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefParserDebugEntities",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefPedanticParserDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefPedanticParserDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefPedanticParserDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefSubstituteEntitiesDefaultValue(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefSubstituteEntitiesDefaultValue(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefSubstituteEntitiesDefaultValue",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
 static int
 test_parser(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing parser : 58 of 70 functions ...\n");
+    if (quiet == 0) printf("Testing parser : 67 of 80 functions ...\n");
     test_ret += test_xmlByteConsumed();
     test_ret += test_xmlClearNodeInfoSeq();
     test_ret += test_xmlClearParserCtxt();
@@ -14594,6 +15039,7 @@ test_parser(void) {
     test_ret += test_xmlCtxtReadMemory();
     test_ret += test_xmlCtxtReset();
     test_ret += test_xmlCtxtResetPush();
+    test_ret += test_xmlCtxtSetMaxAmplification();
     test_ret += test_xmlCtxtUseOptions();
     test_ret += test_xmlGetExternalEntityLoader();
     test_ret += test_xmlHasFeature();
@@ -14606,6 +15052,7 @@ test_parser(void) {
     test_ret += test_xmlLoadExternalEntity();
     test_ret += test_xmlNewIOInputStream();
     test_ret += test_xmlNewParserCtxt();
+    test_ret += test_xmlNewSAXParserCtxt();
     test_ret += test_xmlParseBalancedChunkMemory();
     test_ret += test_xmlParseBalancedChunkMemoryRecover();
     test_ret += test_xmlParseChunk();
@@ -14644,6 +15091,14 @@ test_parser(void) {
     test_ret += test_xmlSetupParserForBuffer();
     test_ret += test_xmlStopParser();
     test_ret += test_xmlSubstituteEntitiesDefault();
+    test_ret += test_xmlThrDefDoValidityCheckingDefaultValue();
+    test_ret += test_xmlThrDefGetWarningsDefaultValue();
+    test_ret += test_xmlThrDefKeepBlanksDefaultValue();
+    test_ret += test_xmlThrDefLineNumbersDefaultValue();
+    test_ret += test_xmlThrDefLoadExtDtdDefaultValue();
+    test_ret += test_xmlThrDefParserDebugEntities();
+    test_ret += test_xmlThrDefPedanticParserDefaultValue();
+    test_ret += test_xmlThrDefSubstituteEntitiesDefaultValue();
 
     if (test_ret != 0)
        printf("Module parser: %d errors\n", test_ret);
@@ -14651,72 +15106,6 @@ test_parser(void) {
 }
 
 static int
-test_htmlCreateFileParserCtxt(void) {
-    int test_ret = 0;
-
-#if defined(LIBXML_HTML_ENABLED)
-    int mem_base;
-    htmlParserCtxtPtr ret_val;
-    const char * filename; /* the filename */
-    int n_filename;
-    char * encoding; /* a free form C string describing the HTML document encoding, or NULL */
-    int n_encoding;
-
-    for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) {
-    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
-        mem_base = xmlMemBlocks();
-        filename = gen_fileoutput(n_filename, 0);
-        encoding = gen_const_char_ptr(n_encoding, 1);
-
-        ret_val = htmlCreateFileParserCtxt(filename, (const char *)encoding);
-        desret_htmlParserCtxtPtr(ret_val);
-        call_tests++;
-        des_fileoutput(n_filename, filename, 0);
-        des_const_char_ptr(n_encoding, (const char *)encoding, 1);
-        xmlResetLastError();
-        if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlCreateFileParserCtxt",
-                  xmlMemBlocks() - mem_base);
-           test_ret++;
-            printf(" %d", n_filename);
-            printf(" %d", n_encoding);
-            printf("\n");
-        }
-    }
-    }
-    function_tests++;
-#endif
-
-    return(test_ret);
-}
-
-
-static int
-test_htmlInitAutoClose(void) {
-    int test_ret = 0;
-
-#if defined(LIBXML_HTML_ENABLED)
-    int mem_base;
-
-        mem_base = xmlMemBlocks();
-
-        htmlInitAutoClose();
-        call_tests++;
-        xmlResetLastError();
-        if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlInitAutoClose",
-                  xmlMemBlocks() - mem_base);
-           test_ret++;
-            printf("\n");
-        }
-    function_tests++;
-#endif
-
-    return(test_ret);
-}
-
-
-static int
 test_inputPop(void) {
     int test_ret = 0;
 
@@ -15141,8 +15530,8 @@ test_xmlCreateMemoryParserCtxt(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlCreateMemoryParserCtxt((const char *)buffer, size);
         desret_xmlParserCtxtPtr(ret_val);
@@ -15245,43 +15634,6 @@ test_xmlCurrentChar(void) {
 
 
 static int
-test_xmlErrMemory(void) {
-    int test_ret = 0;
-
-    int mem_base;
-    xmlParserCtxtPtr ctxt; /* an XML parser context */
-    int n_ctxt;
-    char * extra; /* extra information */
-    int n_extra;
-
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
-    for (n_extra = 0;n_extra < gen_nb_const_char_ptr;n_extra++) {
-        mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
-        extra = gen_const_char_ptr(n_extra, 1);
-
-        xmlErrMemory(ctxt, (const char *)extra);
-        call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
-        des_const_char_ptr(n_extra, (const char *)extra, 1);
-        xmlResetLastError();
-        if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlErrMemory",
-                  xmlMemBlocks() - mem_base);
-           test_ret++;
-            printf(" %d", n_ctxt);
-            printf(" %d", n_extra);
-            printf("\n");
-        }
-    }
-    }
-    function_tests++;
-
-    return(test_ret);
-}
-
-
-static int
 test_xmlIsLetter(void) {
     int test_ret = 0;
 
@@ -15799,8 +16151,8 @@ test_xmlStringLenDecodeEntities(void) {
         end2 = gen_xmlChar(n_end2, 5);
         end3 = gen_xmlChar(n_end3, 6);
         if ((str != NULL) &&
-            (len > (int) strlen((const char *) str) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str)))
+            len = 0;
 
         ret_val = xmlStringLenDecodeEntities(ctxt, (const xmlChar *)str, len, what, end, end2, end3);
         desret_xmlChar_ptr(ret_val);
@@ -15966,9 +16318,7 @@ static int
 test_parserInternals(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing parserInternals : 33 of 90 functions ...\n");
-    test_ret += test_htmlCreateFileParserCtxt();
-    test_ret += test_htmlInitAutoClose();
+    if (quiet == 0) printf("Testing parserInternals : 30 of 87 functions ...\n");
     test_ret += test_inputPop();
     test_ret += test_inputPush();
     test_ret += test_namePop();
@@ -15983,7 +16333,6 @@ test_parserInternals(void) {
     test_ret += test_xmlCreateMemoryParserCtxt();
     test_ret += test_xmlCreateURLParserCtxt();
     test_ret += test_xmlCurrentChar();
-    test_ret += test_xmlErrMemory();
     test_ret += test_xmlIsLetter();
     test_ret += test_xmlNewEntityInputStream();
     test_ret += test_xmlNewInputFromFile();
@@ -16754,8 +17103,8 @@ test_xmlRelaxNGNewMemParserCtxt(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlRelaxNGNewMemParserCtxt((const char *)buffer, size);
         desret_xmlRelaxNGParserCtxtPtr(ret_val);
@@ -17033,8 +17382,8 @@ test_xmlRelaxNGValidatePushCData(void) {
         data = gen_const_xmlChar_ptr(n_data, 1);
         len = gen_int(n_len, 2);
         if ((data != NULL) &&
-            (len > (int) strlen((const char *) data) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST data)))
+            len = 0;
 
         ret_val = xmlRelaxNGValidatePushCData(ctxt, (const xmlChar *)data, len);
         desret_int(ret_val);
@@ -17739,8 +18088,8 @@ test_xmlBufferAdd(void) {
         str = gen_const_xmlChar_ptr(n_str, 1);
         len = gen_int(n_len, 2);
         if ((str != NULL) &&
-            (len > (int) strlen((const char *) str) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str)))
+            len = 0;
 
         ret_val = xmlBufferAdd(buf, (const xmlChar *)str, len);
         desret_int(ret_val);
@@ -17788,8 +18137,8 @@ test_xmlBufferAddHead(void) {
         str = gen_const_xmlChar_ptr(n_str, 1);
         len = gen_int(n_len, 2);
         if ((str != NULL) &&
-            (len > (int) strlen((const char *) str) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str)))
+            len = 0;
 
         ret_val = xmlBufferAddHead(buf, (const xmlChar *)str, len);
         desret_int(ret_val);
@@ -18164,7 +18513,6 @@ test_xmlBufferSetAllocationScheme(void) {
         scheme = gen_xmlBufferAllocationScheme(n_scheme, 1);
 
         xmlBufferSetAllocationScheme(buf, scheme);
-        if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;}
         call_tests++;
         des_xmlBufferPtr(n_buf, buf, 0);
         des_xmlBufferAllocationScheme(n_scheme, scheme, 1);
@@ -18360,8 +18708,8 @@ test_xmlBuildQName(void) {
         memory = gen_xmlChar_ptr(n_memory, 2);
         len = gen_int(n_len, 3);
         if ((prefix != NULL) &&
-            (len > (int) strlen((const char *) prefix) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST prefix)))
+            len = 0;
 
         ret_val = xmlBuildQName((const xmlChar *)ncname, (const xmlChar *)prefix, memory, len);
         if ((ret_val != NULL) && (ret_val != ncname) &&
@@ -19035,6 +19383,16 @@ test_xmlDOMWrapRemoveNode(void) {
 
 
 static int
+test_xmlDeregisterNodeDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlDocCopyNode(void) {
     int test_ret = 0;
 
@@ -20131,8 +20489,8 @@ test_xmlNewCDataBlock(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         ret_val = xmlNewCDataBlock(doc, (const xmlChar *)content, len);
         desret_xmlNodePtr(ret_val);
@@ -20707,8 +21065,8 @@ test_xmlNewDocTextLen(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         ret_val = xmlNewDocTextLen(doc, (const xmlChar *)content, len);
         desret_xmlNodePtr(ret_val);
@@ -21253,8 +21611,8 @@ test_xmlNewTextLen(void) {
         content = gen_const_xmlChar_ptr(n_content, 0);
         len = gen_int(n_len, 1);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         ret_val = xmlNewTextLen((const xmlChar *)content, len);
         desret_xmlNodePtr(ret_val);
@@ -21369,8 +21727,8 @@ test_xmlNodeAddContentLen(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         xmlNodeAddContentLen(cur, (const xmlChar *)content, len);
         call_tests++;
@@ -21922,8 +22280,8 @@ test_xmlNodeSetContentLen(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         xmlNodeSetContentLen(cur, (const xmlChar *)content, len);
         call_tests++;
@@ -22145,6 +22503,16 @@ test_xmlReconciliateNs(void) {
 
 
 static int
+test_xmlRegisterNodeDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlRemoveProp(void) {
     int test_ret = 0;
 
@@ -22989,8 +23357,8 @@ test_xmlStringLenGetNodeList(void) {
         value = gen_const_xmlChar_ptr(n_value, 1);
         len = gen_int(n_len, 2);
         if ((value != NULL) &&
-            (len > (int) strlen((const char *) value) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST value)))
+            len = 0;
 
         ret_val = xmlStringLenGetNodeList((const xmlDoc *)doc, (const xmlChar *)value, len);
         desret_xmlNodePtr(ret_val);
@@ -23038,8 +23406,8 @@ test_xmlTextConcat(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         ret_val = xmlTextConcat(node, (const xmlChar *)content, len);
         desret_int(ret_val);
@@ -23109,6 +23477,90 @@ test_xmlTextMerge(void) {
 
 
 static int
+test_xmlThrDefBufferAllocScheme(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    xmlBufferAllocationScheme ret_val;
+    xmlBufferAllocationScheme v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_xmlBufferAllocationScheme;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_xmlBufferAllocationScheme(n_v, 0);
+
+        ret_val = xmlThrDefBufferAllocScheme(v);
+        desret_xmlBufferAllocationScheme(ret_val);
+        call_tests++;
+        des_xmlBufferAllocationScheme(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefBufferAllocScheme",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefDefaultBufferSize(void) {
+    int test_ret = 0;
+
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefDefaultBufferSize(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefDefaultBufferSize",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefDeregisterNodeDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefRegisterNodeDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlUnsetNsProp(void) {
     int test_ret = 0;
 
@@ -23201,7 +23653,6 @@ static int
 test_xmlValidateNCName(void) {
     int test_ret = 0;
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
@@ -23234,7 +23685,6 @@ test_xmlValidateNCName(void) {
     }
     function_tests++;
 #endif
-#endif
 
     return(test_ret);
 }
@@ -23372,7 +23822,7 @@ static int
 test_tree(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing tree : 142 of 164 functions ...\n");
+    if (quiet == 0) printf("Testing tree : 144 of 170 functions ...\n");
     test_ret += test_xmlAddChild();
     test_ret += test_xmlAddChildList();
     test_ret += test_xmlAddNextSibling();
@@ -23419,6 +23869,7 @@ test_tree(void) {
     test_ret += test_xmlDOMWrapNewCtxt();
     test_ret += test_xmlDOMWrapReconcileNamespaces();
     test_ret += test_xmlDOMWrapRemoveNode();
+    test_ret += test_xmlDeregisterNodeDefault();
     test_ret += test_xmlDocCopyNode();
     test_ret += test_xmlDocCopyNodeList();
     test_ret += test_xmlDocDump();
@@ -23494,6 +23945,7 @@ test_tree(void) {
     test_ret += test_xmlNodeSetSpacePreserve();
     test_ret += test_xmlPreviousElementSibling();
     test_ret += test_xmlReconciliateNs();
+    test_ret += test_xmlRegisterNodeDefault();
     test_ret += test_xmlRemoveProp();
     test_ret += test_xmlReplaceNode();
     test_ret += test_xmlSaveFile();
@@ -23516,6 +23968,10 @@ test_tree(void) {
     test_ret += test_xmlStringLenGetNodeList();
     test_ret += test_xmlTextConcat();
     test_ret += test_xmlTextMerge();
+    test_ret += test_xmlThrDefBufferAllocScheme();
+    test_ret += test_xmlThrDefDefaultBufferSize();
+    test_ret += test_xmlThrDefDeregisterNodeDefault();
+    test_ret += test_xmlThrDefRegisterNodeDefault();
     test_ret += test_xmlUnsetNsProp();
     test_ret += test_xmlUnsetProp();
     test_ret += test_xmlValidateNCName();
@@ -25700,23 +26156,23 @@ test_xmlValidateElement(void) {
     int n_ctxt;
     xmlDocPtr doc; /* a document instance */
     int n_doc;
-    xmlNodePtr elem; /* an element instance */
-    int n_elem;
+    xmlNodePtr root; /* an element instance */
+    int n_root;
 
     for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) {
     for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_root = 0;n_root < gen_nb_xmlNodePtr;n_root++) {
         mem_base = xmlMemBlocks();
         ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0);
         doc = gen_xmlDocPtr(n_doc, 1);
-        elem = gen_xmlNodePtr(n_elem, 2);
+        root = gen_xmlNodePtr(n_root, 2);
 
-        ret_val = xmlValidateElement(ctxt, doc, elem);
+        ret_val = xmlValidateElement(ctxt, doc, root);
         desret_int(ret_val);
         call_tests++;
         des_xmlValidCtxtPtr(n_ctxt, ctxt, 0);
         des_xmlDocPtr(n_doc, doc, 1);
-        des_xmlNodePtr(n_elem, elem, 2);
+        des_xmlNodePtr(n_root, root, 2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in xmlValidateElement",
@@ -25724,7 +26180,7 @@ test_xmlValidateElement(void) {
            test_ret++;
             printf(" %d", n_ctxt);
             printf(" %d", n_doc);
-            printf(" %d", n_elem);
+            printf(" %d", n_root);
             printf("\n");
         }
     }
@@ -26273,8 +26729,8 @@ test_xmlValidatePushCData(void) {
         data = gen_const_xmlChar_ptr(n_data, 1);
         len = gen_int(n_len, 2);
         if ((data != NULL) &&
-            (len > (int) strlen((const char *) data) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST data)))
+            len = 0;
 
         ret_val = xmlValidatePushCData(ctxt, (const xmlChar *)data, len);
         desret_int(ret_val);
@@ -27710,6 +28166,16 @@ test_xmlOutputBufferCreateFilename(void) {
 
 
 static int
+test_xmlOutputBufferCreateFilenameDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlOutputBufferFlush(void) {
     int test_ret = 0;
 
@@ -27809,8 +28275,8 @@ test_xmlOutputBufferWrite(void) {
         len = gen_int(n_len, 1);
         buf = gen_const_char_ptr(n_buf, 2);
         if ((buf != NULL) &&
-            (len > (int) strlen((const char *) buf) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST buf)))
+            len = 0;
 
         ret_val = xmlOutputBufferWrite(out, len, (const char *)buf);
         desret_int(ret_val);
@@ -28018,6 +28484,16 @@ test_xmlParserInputBufferCreateFilename(void) {
 
 
 static int
+test_xmlParserInputBufferCreateFilenameDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlParserInputBufferCreateMem(void) {
     int test_ret = 0;
 
@@ -28038,8 +28514,8 @@ test_xmlParserInputBufferCreateMem(void) {
         size = gen_int(n_size, 1);
         enc = gen_xmlCharEncoding(n_enc, 2);
         if ((mem != NULL) &&
-            (size > (int) strlen((const char *) mem) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST mem)))
+            size = 0;
 
         ret_val = xmlParserInputBufferCreateMem((const char *)mem, size, enc);
         desret_xmlParserInputBufferPtr(ret_val);
@@ -28087,8 +28563,8 @@ test_xmlParserInputBufferCreateStatic(void) {
         size = gen_int(n_size, 1);
         enc = gen_xmlCharEncoding(n_enc, 2);
         if ((mem != NULL) &&
-            (size > (int) strlen((const char *) mem) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST mem)))
+            size = 0;
 
         ret_val = xmlParserInputBufferCreateStatic((const char *)mem, size, enc);
         desret_xmlParserInputBufferPtr(ret_val);
@@ -28175,8 +28651,8 @@ test_xmlParserInputBufferPush(void) {
         len = gen_int(n_len, 1);
         buf = gen_const_char_ptr(n_buf, 2);
         if ((buf != NULL) &&
-            (len > (int) strlen((const char *) buf) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST buf)))
+            len = 0;
 
         ret_val = xmlParserInputBufferPush(in, len, (const char *)buf);
         desret_int(ret_val);
@@ -28366,11 +28842,31 @@ test_xmlRegisterHTTPPostCallbacks(void) {
     return(test_ret);
 }
 
+
+static int
+test_xmlThrDefOutputBufferCreateFilenameDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefParserInputBufferCreateFilenameDefault(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
 static int
 test_xmlIO(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing xmlIO : 41 of 51 functions ...\n");
+    if (quiet == 0) printf("Testing xmlIO : 41 of 55 functions ...\n");
     test_ret += test_xmlAllocOutputBuffer();
     test_ret += test_xmlAllocParserInputBuffer();
     test_ret += test_xmlCheckFilename();
@@ -28395,6 +28891,7 @@ test_xmlIO(void) {
     test_ret += test_xmlOutputBufferCreateFd();
     test_ret += test_xmlOutputBufferCreateFile();
     test_ret += test_xmlOutputBufferCreateFilename();
+    test_ret += test_xmlOutputBufferCreateFilenameDefault();
     test_ret += test_xmlOutputBufferFlush();
     test_ret += test_xmlOutputBufferGetContent();
     test_ret += test_xmlOutputBufferGetSize();
@@ -28405,6 +28902,7 @@ test_xmlIO(void) {
     test_ret += test_xmlParserInputBufferCreateFd();
     test_ret += test_xmlParserInputBufferCreateFile();
     test_ret += test_xmlParserInputBufferCreateFilename();
+    test_ret += test_xmlParserInputBufferCreateFilenameDefault();
     test_ret += test_xmlParserInputBufferCreateMem();
     test_ret += test_xmlParserInputBufferCreateStatic();
     test_ret += test_xmlParserInputBufferGrow();
@@ -28415,6 +28913,8 @@ test_xmlIO(void) {
     test_ret += test_xmlRegisterDefaultInputCallbacks();
     test_ret += test_xmlRegisterDefaultOutputCallbacks();
     test_ret += test_xmlRegisterHTTPPostCallbacks();
+    test_ret += test_xmlThrDefOutputBufferCreateFilenameDefault();
+    test_ret += test_xmlThrDefParserInputBufferCreateFilenameDefault();
 
     if (test_ret != 0)
        printf("Module xmlIO: %d errors\n", test_ret);
@@ -28770,6 +29270,10 @@ test_initGenericErrorDefaultFunc(void) {
 }
 
 
+#define gen_nb_const_xmlError_ptr 1
+#define gen_const_xmlError_ptr(no, nr) NULL
+#define des_const_xmlError_ptr(no, val, nr)
+
 #define gen_nb_xmlErrorPtr 1
 #define gen_xmlErrorPtr(no, nr) NULL
 #define des_xmlErrorPtr(no, val, nr)
@@ -28780,21 +29284,21 @@ test_xmlCopyError(void) {
 
     int mem_base;
     int ret_val;
-    xmlErrorPtr from; /* a source error */
+    xmlError * from; /* a source error */
     int n_from;
     xmlErrorPtr to; /* a target error */
     int n_to;
 
-    for (n_from = 0;n_from < gen_nb_xmlErrorPtr;n_from++) {
+    for (n_from = 0;n_from < gen_nb_const_xmlError_ptr;n_from++) {
     for (n_to = 0;n_to < gen_nb_xmlErrorPtr;n_to++) {
         mem_base = xmlMemBlocks();
-        from = gen_xmlErrorPtr(n_from, 0);
+        from = gen_const_xmlError_ptr(n_from, 0);
         to = gen_xmlErrorPtr(n_to, 1);
 
-        ret_val = xmlCopyError(from, to);
+        ret_val = xmlCopyError((const xmlError *)from, to);
         desret_int(ret_val);
         call_tests++;
-        des_xmlErrorPtr(n_from, from, 0);
+        des_const_xmlError_ptr(n_from, (const xmlError *)from, 0);
         des_xmlErrorPtr(n_to, to, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
@@ -29027,11 +29531,31 @@ test_xmlSetStructuredErrorFunc(void) {
     return(test_ret);
 }
 
+
+static int
+test_xmlThrDefSetGenericErrorFunc(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefSetStructuredErrorFunc(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
 static int
 test_xmlerror(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing xmlerror : 7 of 15 functions ...\n");
+    if (quiet == 0) printf("Testing xmlerror : 7 of 17 functions ...\n");
     test_ret += test_initGenericErrorDefaultFunc();
     test_ret += test_xmlCopyError();
     test_ret += test_xmlCtxtGetLastError();
@@ -29047,6 +29571,8 @@ test_xmlerror(void) {
     test_ret += test_xmlResetLastError();
     test_ret += test_xmlSetGenericErrorFunc();
     test_ret += test_xmlSetStructuredErrorFunc();
+    test_ret += test_xmlThrDefSetGenericErrorFunc();
+    test_ret += test_xmlThrDefSetStructuredErrorFunc();
 
     if (test_ret != 0)
        printf("Module xmlerror: %d errors\n", test_ret);
@@ -29373,8 +29899,8 @@ test_xmlReaderForMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_parseroptions(n_options, 4);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlReaderForMemory((const char *)buffer, size, URL, (const char *)encoding, options);
         desret_xmlTextReaderPtr(ret_val);
@@ -29559,8 +30085,8 @@ test_xmlReaderNewMemory(void) {
         encoding = gen_const_char_ptr(n_encoding, 4);
         options = gen_parseroptions(n_options, 5);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlReaderNewMemory(reader, (const char *)buffer, size, URL, (const char *)encoding, options);
         desret_int(ret_val);
@@ -31881,6 +32407,16 @@ test_xmlTextReaderSetErrorHandler(void) {
 
 
 static int
+test_xmlTextReaderSetMaxAmplification(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlTextReaderSetParserProp(void) {
     int test_ret = 0;
 
@@ -32145,7 +32681,7 @@ static int
 test_xmlreader(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing xmlreader : 76 of 86 functions ...\n");
+    if (quiet == 0) printf("Testing xmlreader : 76 of 87 functions ...\n");
     test_ret += test_xmlNewTextReader();
     test_ret += test_xmlNewTextReaderFilename();
     test_ret += test_xmlReaderForDoc();
@@ -32217,6 +32753,7 @@ test_xmlreader(void) {
     test_ret += test_xmlTextReaderSchemaValidate();
     test_ret += test_xmlTextReaderSchemaValidateCtxt();
     test_ret += test_xmlTextReaderSetErrorHandler();
+    test_ret += test_xmlTextReaderSetMaxAmplification();
     test_ret += test_xmlTextReaderSetParserProp();
     test_ret += test_xmlTextReaderSetSchema();
     test_ret += test_xmlTextReaderSetStructuredErrorHandler();
@@ -33268,7 +33805,7 @@ test_xmlSaveTree(void) {
     long ret_val;
     xmlSaveCtxtPtr ctxt; /* a document saving context */
     int n_ctxt;
-    xmlNodePtr cur; /*  */
+    xmlNodePtr cur; /* the top node of the subtree to save */
     int n_cur;
 
     for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) {
@@ -33299,11 +33836,113 @@ test_xmlSaveTree(void) {
     return(test_ret);
 }
 
+
+static int
+test_xmlThrDefIndentTreeOutput(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefIndentTreeOutput(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefIndentTreeOutput",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefSaveNoEmptyTags(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+    int mem_base;
+    int ret_val;
+    int v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_int;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_int(n_v, 0);
+
+        ret_val = xmlThrDefSaveNoEmptyTags(v);
+        desret_int(ret_val);
+        call_tests++;
+        des_int(n_v, v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefSaveNoEmptyTags",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
+static int
+test_xmlThrDefTreeIndentString(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+    int mem_base;
+    const char * ret_val;
+    char * v; /*  */
+    int n_v;
+
+    for (n_v = 0;n_v < gen_nb_const_char_ptr;n_v++) {
+        mem_base = xmlMemBlocks();
+        v = gen_const_char_ptr(n_v, 0);
+
+        ret_val = xmlThrDefTreeIndentString((const char *)v);
+        desret_const_char_ptr(ret_val);
+        call_tests++;
+        des_const_char_ptr(n_v, (const char *)v, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlThrDefTreeIndentString",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_v);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
 static int
 test_xmlsave(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing xmlsave : 4 of 10 functions ...\n");
+    if (quiet == 0) printf("Testing xmlsave : 7 of 13 functions ...\n");
     test_ret += test_xmlSaveClose();
     test_ret += test_xmlSaveDoc();
     test_ret += test_xmlSaveFlush();
@@ -33313,6 +33952,9 @@ test_xmlsave(void) {
     test_ret += test_xmlSaveToFd();
     test_ret += test_xmlSaveToFilename();
     test_ret += test_xmlSaveTree();
+    test_ret += test_xmlThrDefIndentTreeOutput();
+    test_ret += test_xmlThrDefSaveNoEmptyTags();
+    test_ret += test_xmlThrDefTreeIndentString();
 
     if (test_ret != 0)
        printf("Module xmlsave: %d errors\n", test_ret);
@@ -33575,8 +34217,8 @@ test_xmlSchemaNewMemParserCtxt(void) {
         buffer = gen_const_char_ptr(n_buffer, 0);
         size = gen_int(n_size, 1);
         if ((buffer != NULL) &&
-            (size > (int) strlen((const char *) buffer) + 1))
-            continue;
+            (size > xmlStrlen(BAD_CAST buffer)))
+            size = 0;
 
         ret_val = xmlSchemaNewMemParserCtxt((const char *)buffer, size);
         desret_xmlSchemaParserCtxtPtr(ret_val);
@@ -34625,9 +35267,11 @@ test_xmlSchemaInitTypes(void) {
     int test_ret = 0;
 
 #if defined(LIBXML_SCHEMAS_ENABLED)
+    int ret_val;
 
 
-        xmlSchemaInitTypes();
+        ret_val = xmlSchemaInitTypes();
+        desret_int(ret_val);
         call_tests++;
         xmlResetLastError();
     function_tests++;
@@ -35437,8 +36081,8 @@ test_xmlCharStrndup(void) {
         cur = gen_const_char_ptr(n_cur, 0);
         len = gen_int(n_len, 1);
         if ((cur != NULL) &&
-            (len > (int) strlen((const char *) cur) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST cur)))
+            len = 0;
 
         ret_val = xmlCharStrndup((const char *)cur, len);
         desret_xmlChar_ptr(ret_val);
@@ -35879,8 +36523,8 @@ test_xmlStrncasecmp(void) {
         str2 = gen_const_xmlChar_ptr(n_str2, 1);
         len = gen_int(n_len, 2);
         if ((str2 != NULL) &&
-            (len > (int) strlen((const char *) str2) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str2)))
+            len = 0;
 
         ret_val = xmlStrncasecmp((const xmlChar *)str1, (const xmlChar *)str2, len);
         desret_int(ret_val);
@@ -35928,8 +36572,8 @@ test_xmlStrncatNew(void) {
         str2 = gen_const_xmlChar_ptr(n_str2, 1);
         len = gen_int(n_len, 2);
         if ((str2 != NULL) &&
-            (len > (int) strlen((const char *) str2) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str2)))
+            len = 0;
 
         ret_val = xmlStrncatNew((const xmlChar *)str1, (const xmlChar *)str2, len);
         desret_xmlChar_ptr(ret_val);
@@ -35977,8 +36621,8 @@ test_xmlStrncmp(void) {
         str2 = gen_const_xmlChar_ptr(n_str2, 1);
         len = gen_int(n_len, 2);
         if ((str2 != NULL) &&
-            (len > (int) strlen((const char *) str2) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str2)))
+            len = 0;
 
         ret_val = xmlStrncmp((const xmlChar *)str1, (const xmlChar *)str2, len);
         desret_int(ret_val);
@@ -36022,8 +36666,8 @@ test_xmlStrndup(void) {
         cur = gen_const_xmlChar_ptr(n_cur, 0);
         len = gen_int(n_len, 1);
         if ((cur != NULL) &&
-            (len > (int) strlen((const char *) cur) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST cur)))
+            len = 0;
 
         ret_val = xmlStrndup((const xmlChar *)cur, len);
         desret_xmlChar_ptr(ret_val);
@@ -36107,11 +36751,11 @@ test_xmlStrsub(void) {
         start = gen_int(n_start, 1);
         len = gen_int(n_len, 2);
         if ((str != NULL) &&
-            (start > (int) strlen((const char *) str) + 1))
-            continue;
+            (start > xmlStrlen(BAD_CAST str)))
+            start = 0;
         if ((str != NULL) &&
-            (len > (int) strlen((const char *) str) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST str)))
+            len = 0;
 
         ret_val = xmlStrsub((const xmlChar *)str, start, len);
         desret_xmlChar_ptr(ret_val);
@@ -36297,8 +36941,8 @@ test_xmlUTF8Strndup(void) {
         utf = gen_const_xmlChar_ptr(n_utf, 0);
         len = gen_int(n_len, 1);
         if ((utf != NULL) &&
-            (len > (int) strlen((const char *) utf) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST utf)))
+            len = 0;
 
         ret_val = xmlUTF8Strndup((const xmlChar *)utf, len);
         desret_xmlChar_ptr(ret_val);
@@ -36378,8 +37022,8 @@ test_xmlUTF8Strsize(void) {
         utf = gen_const_xmlChar_ptr(n_utf, 0);
         len = gen_int(n_len, 1);
         if ((utf != NULL) &&
-            (len > (int) strlen((const char *) utf) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST utf)))
+            len = 0;
 
         ret_val = xmlUTF8Strsize((const xmlChar *)utf, len);
         desret_int(ret_val);
@@ -36424,11 +37068,11 @@ test_xmlUTF8Strsub(void) {
         start = gen_int(n_start, 1);
         len = gen_int(n_len, 2);
         if ((utf != NULL) &&
-            (start > (int) strlen((const char *) utf) + 1))
-            continue;
+            (start > xmlStrlen(BAD_CAST utf)))
+            start = 0;
         if ((utf != NULL) &&
-            (len > (int) strlen((const char *) utf) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST utf)))
+            len = 0;
 
         ret_val = xmlUTF8Strsub((const xmlChar *)utf, start, len);
         desret_xmlChar_ptr(ret_val);
@@ -43742,11 +44386,11 @@ test_xmlTextWriterWriteBase64(void) {
         start = gen_int(n_start, 2);
         len = gen_int(n_len, 3);
         if ((data != NULL) &&
-            (start > (int) strlen((const char *) data) + 1))
-            continue;
+            (start > xmlStrlen(BAD_CAST data)))
+            start = 0;
         if ((data != NULL) &&
-            (len > (int) strlen((const char *) data) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST data)))
+            len = 0;
 
         ret_val = xmlTextWriterWriteBase64(writer, (const char *)data, start, len);
         desret_int(ret_val);
@@ -43803,11 +44447,11 @@ test_xmlTextWriterWriteBinHex(void) {
         start = gen_int(n_start, 2);
         len = gen_int(n_len, 3);
         if ((data != NULL) &&
-            (start > (int) strlen((const char *) data) + 1))
-            continue;
+            (start > xmlStrlen(BAD_CAST data)))
+            start = 0;
         if ((data != NULL) &&
-            (len > (int) strlen((const char *) data) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST data)))
+            len = 0;
 
         ret_val = xmlTextWriterWriteBinHex(writer, (const char *)data, start, len);
         desret_int(ret_val);
@@ -44739,8 +45383,8 @@ test_xmlTextWriterWriteRawLen(void) {
         content = gen_const_xmlChar_ptr(n_content, 1);
         len = gen_int(n_len, 2);
         if ((content != NULL) &&
-            (len > (int) strlen((const char *) content) + 1))
-            continue;
+            (len > xmlStrlen(BAD_CAST content)))
+            len = 0;
 
         ret_val = xmlTextWriterWriteRawLen(writer, (const xmlChar *)content, len);
         desret_int(ret_val);
index bd1a8d6..f4b2f4f 100644 (file)
@@ -5,16 +5,17 @@
  * copy: see Copyright for the status of this software.
  */
 
+#define XML_DEPRECATED
+
 #include <stdio.h>
 #include <string.h>
+#include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 
-#include "buf.h"
-
 int lastError;
 
-static void errorHandler(void *unused, xmlErrorPtr err) {
+static void errorHandler(void *unused, const xmlError *err) {
     if ((unused == NULL) && (err != NULL) && (lastError == 0)) {
         lastError = err->code;
     }
@@ -260,19 +261,55 @@ static int testDocumentRanges(void) {
     return(test_ret);
 }
 
-static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
+static int
+testCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
+    const xmlChar *oldcur;
+    int c, err, len2;
+
+    lastError = 0;
+    c = xmlCurrentChar(ctxt, len);
+    ctxt->input->flags = 0;
+    err = lastError;
+
+    oldcur = ctxt->input->cur;
+    lastError = 0;
+    xmlNextChar(ctxt);
+    ctxt->input->flags = 0;
+    len2 = ctxt->input->cur - oldcur;
+    ctxt->input->cur = oldcur;
+
+    if ((*ctxt->input->cur != 0) && (err != lastError)) {
+        fprintf(stderr, "xmlCurrentChar and xmlNextChar report different "
+                "errors: %d %d\n", err, lastError);
+        return(-1);
+    }
+
+    if ((err == 0) && (*len != len2)) {
+        fprintf(stderr, "xmlCurrentChar and xmlNextChar report different "
+                "lengths: %d %d\n", *len, len2);
+        return(-1);
+    }
+
+    lastError = err;
+
+    return(c);
+}
+
+static int testCharRangeByte1(xmlParserCtxtPtr ctxt) {
     int i = 0;
     int len, c;
+    char *data = (char *) ctxt->input->cur;
 
     data[1] = 0;
     data[2] = 0;
     data[3] = 0;
     for (i = 0;i <= 0xFF;i++) {
         data[0] = (char) i;
-       ctxt->charset = XML_CHAR_ENCODING_UTF8;
+        ctxt->nbErrors = 0;
 
-       lastError = 0;
-        c = xmlCurrentChar(ctxt, &len);
+        c = testCurrentChar(ctxt, &len);
+        if (c < 0)
+            continue;
        if ((i == 0) || (i >= 0x80)) {
            /* we must see an error there */
            if (lastError != XML_ERR_INVALID_CHAR) {
@@ -293,9 +330,10 @@ static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
     return(0);
 }
 
-static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte2(xmlParserCtxtPtr ctxt) {
     int i, j;
     int len, c;
+    char *data = (char *) ctxt->input->cur;
 
     data[2] = 0;
     data[3] = 0;
@@ -303,10 +341,11 @@ static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
        for (j = 0;j <= 0xFF;j++) {
            data[0] = (char) i;
            data[1] = (char) j;
-           ctxt->charset = XML_CHAR_ENCODING_UTF8;
+            ctxt->nbErrors = 0;
 
-           lastError = 0;
-           c = xmlCurrentChar(ctxt, &len);
+            c = testCurrentChar(ctxt, &len);
+            if (c < 0)
+                continue;
 
            /* if first bit of first char is set, then second bit must too */
            if ((i & 0x80) && ((i & 0x40) == 0)) {
@@ -380,10 +419,11 @@ static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
     return(0);
 }
 
-static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte3(xmlParserCtxtPtr ctxt) {
     int i, j, k, K;
     int len, c;
     unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
+    char *data = (char *) ctxt->input->cur;
     int value;
 
     data[3] = 0;
@@ -395,10 +435,11 @@ static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
        K = lows[k];
        data[2] = (char) K;
        value = (K & 0x3F) + ((j & 0x3F) << 6) + ((i & 0xF) << 12);
-       ctxt->charset = XML_CHAR_ENCODING_UTF8;
+        ctxt->nbErrors = 0;
 
-       lastError = 0;
-       c = xmlCurrentChar(ctxt, &len);
+        c = testCurrentChar(ctxt, &len);
+        if (c < 0)
+            continue;
 
        /*
         * if fourth bit of first char is set, then the sequence would need
@@ -440,10 +481,9 @@ static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
        }
 
         /*
-        * There are values in that range that are not allowed in XML-1.0
+        * There are values that are not allowed in UTF-8
         */
-       else if (((value > 0xD7FF) && (value <0xE000)) ||
-                ((value > 0xFFFD) && (value <0x10000))) {
+       else if ((value > 0xD7FF) && (value <0xE000)) {
            if (lastError != XML_ERR_INVALID_CHAR) {
                fprintf(stderr,
        "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n",
@@ -477,10 +517,11 @@ static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
     return(0);
 }
 
-static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
+static int testCharRangeByte4(xmlParserCtxtPtr ctxt) {
     int i, j, k, K, l, L;
     int len, c;
     unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
+    char *data = (char *) ctxt->input->cur;
     int value;
 
     data[4] = 0;
@@ -496,10 +537,11 @@ static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
        data[3] = (char) L;
        value = (L & 0x3F) + ((K & 0x3F) << 6) + ((j & 0x3F) << 12) +
                ((i & 0x7) << 18);
-       ctxt->charset = XML_CHAR_ENCODING_UTF8;
+        ctxt->nbErrors = 0;
 
-       lastError = 0;
-       c = xmlCurrentChar(ctxt, &len);
+        c = testCurrentChar(ctxt, &len);
+        if (c < 0)
+            continue;
 
        /*
         * if fifth bit of first char is set, then the sequence would need
@@ -542,10 +584,9 @@ static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
        }
 
         /*
-        * There are values in that range that are not allowed in XML-1.0
+        * There are values in that are not allowed in UTF-8
         */
-       else if (((value > 0xD7FF) && (value <0xE000)) ||
-                ((value > 0xFFFD) && (value <0x10000)) ||
+       else if (((value > 0xD7FF) && (value < 0xE000)) ||
                 (value > 0x10FFFF)) {
            if (lastError != XML_ERR_INVALID_CHAR) {
                fprintf(stderr,
@@ -629,16 +670,16 @@ static int testCharRanges(void) {
 
     printf("testing char range: 1");
     fflush(stdout);
-    test_ret += testCharRangeByte1(ctxt, data);
+    test_ret += testCharRangeByte1(ctxt);
     printf(" 2");
     fflush(stdout);
-    test_ret += testCharRangeByte2(ctxt, data);
+    test_ret += testCharRangeByte2(ctxt);
     printf(" 3");
     fflush(stdout);
-    test_ret += testCharRangeByte3(ctxt, data);
+    test_ret += testCharRangeByte3(ctxt);
     printf(" 4");
     fflush(stdout);
-    test_ret += testCharRangeByte4(ctxt, data);
+    test_ret += testCharRangeByte4(ctxt);
     printf(" done\n");
     fflush(stdout);
 
@@ -647,6 +688,197 @@ error:
     return(test_ret);
 }
 
+static int
+testUserEncoding(void) {
+    /*
+     * Create a document encoded as UTF-16LE with an ISO-8859-1 encoding
+     * declaration, then parse it with xmlReadMemory and the encoding
+     * argument set to UTF-16LE.
+     */
+    xmlDocPtr doc = NULL;
+    const char *start = "<?xml version='1.0' encoding='ISO-8859-1'?><d>";
+    const char *end = "</d>";
+    char *buf = NULL;
+    xmlChar *text;
+    int startSize = strlen(start);
+    int textSize = 100000; /* Make sure to exceed internal buffer sizes. */
+    int endSize = strlen(end);
+    int totalSize = startSize + textSize + endSize;
+    int k = 0;
+    int i;
+    int ret = 1;
+
+    buf = xmlMalloc(2 * totalSize);
+    for (i = 0; start[i] != 0; i++) {
+        buf[k++] = start[i];
+        buf[k++] = 0;
+    }
+    for (i = 0; i < textSize; i++) {
+        buf[k++] = 'x';
+        buf[k++] = 0;
+    }
+    for (i = 0; end[i] != 0; i++) {
+        buf[k++] = end[i];
+        buf[k++] = 0;
+    }
+
+    doc = xmlReadMemory(buf, 2 * totalSize, NULL, "UTF-16LE", 0);
+    if (doc == NULL) {
+        fprintf(stderr, "failed to parse document\n");
+        goto error;
+    }
+
+    text = doc->children->children->content;
+    for (i = 0; i < textSize; i++) {
+        if (text[i] != 'x') {
+            fprintf(stderr, "text node has wrong content at offset %d\n", k);
+            goto error;
+        }
+    }
+
+    ret = 0;
+
+error:
+    xmlFreeDoc(doc);
+    xmlFree(buf);
+
+    return ret;
+}
+
+#if defined(LIBXML_PUSH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+
+static char *
+convert(xmlCharEncodingHandlerPtr handler, const char *utf8, int size,
+        int *outSize) {
+    char *ret;
+    int inlen;
+    int res;
+
+    inlen = size;
+    *outSize = size * 2;
+    ret = xmlMalloc(*outSize);
+    if (ret == NULL)
+        return(NULL);
+    res = handler->output(BAD_CAST ret, outSize, BAD_CAST utf8, &inlen);
+    if ((res < 0) || (inlen != size)) {
+        xmlFree(ret);
+        return(NULL);
+    }
+
+    return(ret);
+}
+
+static int
+testUserEncodingPush(void) {
+    xmlCharEncodingHandlerPtr handler;
+    xmlParserCtxtPtr ctxt;
+    xmlDocPtr doc;
+    char buf[] =
+        "\xEF\xBB\xBF"
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"
+        "<d>text</d>\n";
+    char *utf16;
+    int utf16Size;
+    int ret = 1;
+
+    handler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF16LE);
+    utf16 = convert(handler, buf, sizeof(buf) - 1, &utf16Size);
+    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
+    xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_UTF16LE);
+    xmlParseChunk(ctxt, utf16, utf16Size, 0);
+    xmlParseChunk(ctxt, NULL, 0, 1);
+    doc = ctxt->myDoc;
+
+    if ((doc != NULL) &&
+        (doc->children != NULL) &&
+        (doc->children->children != NULL) &&
+        (xmlStrcmp(doc->children->children->content, BAD_CAST "text") == 0))
+        ret = 0;
+
+    xmlFreeDoc(doc);
+    xmlFreeParserCtxt(ctxt);
+    xmlFree(utf16);
+
+    return(ret);
+}
+
+static int
+testUTF8Chunks(void) {
+    xmlParserCtxtPtr ctxt;
+    xmlChar *out;
+    int outSize;
+    char *buf;
+    int i;
+    int ret = 0;
+
+    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
+
+    xmlParseChunk(ctxt, "<d>", 3, 0);
+    xmlParseChunk(ctxt, "\xF0", 1, 0);
+    xmlParseChunk(ctxt, "\x9F", 1, 0);
+    xmlParseChunk(ctxt, "\x98", 1, 0);
+    xmlParseChunk(ctxt, "\x8A", 1, 0);
+    xmlParseChunk(ctxt, "</d>", 4, 1);
+
+    xmlDocDumpMemory(ctxt->myDoc, &out, &outSize);
+    if (strcmp((char *) out,
+               "<?xml version=\"1.0\"?>\n<d>&#x1F60A;</d>\n") != 0) {
+        fprintf(stderr, "failed UTF-8 chunk test 1\n");
+        ret += 1;
+    }
+
+    xmlFree(out);
+    xmlFreeDoc(ctxt->myDoc);
+    xmlFreeParserCtxt(ctxt);
+
+    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
+
+    xmlParseChunk(ctxt, "<d>", 3, 0);
+
+    /*
+     * Create a chunk longer than XML_PARSER_BIG_BUFFER_SIZE (300) ending
+     * with an incomplete UTF-8 sequence.
+     */
+    buf = xmlMalloc(1000 * 2 + 1);
+    for (i = 0; i < 2000; i += 2)
+        memcpy(buf + i, "\xCE\xB1", 2);
+    buf[i] = '\xCE';
+    xmlParseChunk(ctxt, buf, 2001, 0);
+    xmlFree(buf);
+
+    xmlParseChunk(ctxt, "\xB1</d>", 4, 0);
+    xmlParseChunk(ctxt, NULL, 0, 0);
+
+    xmlDocDumpMemory(ctxt->myDoc, &out, &outSize);
+    if (strncmp((char *) out, "<?xml version=\"1.0\"?>\n<d>", 25) != 0) {
+        fprintf(stderr, "failed UTF-8 chunk test 2-1\n");
+        ret += 1;
+        goto error;
+    }
+    for (i = 25; i < 25 + 1001 * 7; i += 7) {
+        if (memcmp(out + i, "&#x3B1;", 7) != 0) {
+            fprintf(stderr, "failed UTF-8 chunk test 2-2 %d\n", i);
+            ret += 1;
+            goto error;
+        }
+    }
+    if (strcmp((char *) out + i, "</d>\n") != 0) {
+        fprintf(stderr, "failed UTF-8 chunk test 2-3\n");
+        ret += 1;
+        goto error;
+    }
+
+error:
+    xmlFree(out);
+    xmlFreeDoc(ctxt->myDoc);
+    xmlFreeParserCtxt(ctxt);
+
+    return(ret);
+    return(0);
+}
+
+#endif
+
 int main(void) {
 
     int ret = 0;
@@ -669,14 +901,15 @@ int main(void) {
      */
     ret += testCharRanges();
     ret += testDocumentRanges();
+    ret += testUserEncoding();
+#if defined(LIBXML_PUSH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+    ret += testUserEncodingPush();
+    ret += testUTF8Chunks();
+#endif
 
     /*
      * Cleanup function for the XML library.
      */
     xmlCleanupParser();
-    /*
-     * this is to debug memory for regression tests
-     */
-    xmlMemoryDump();
     return(ret ? 1 : 0);
 }
index 40bebd0..ffbbc94 100644 (file)
@@ -1,7 +1,19 @@
+#include <stdlib.h>
 #include <string.h>
 #include <libxml/parser.h>
 #include <libxml/dict.h>
 
+
+/**** dictionary tests ****/
+
+#ifdef __clang__
+  #define ATTRIBUTE_NO_SANITIZE_INTEGER \
+    __attribute__ ((no_sanitize("unsigned-integer-overflow"))) \
+    __attribute__ ((no_sanitize("unsigned-shift-base")))
+#else
+  #define ATTRIBUTE_NO_SANITIZE_INTEGER
+#endif
+
 /* #define WITH_PRINT */
 
 static const char *seeds1[] = {
@@ -22,99 +34,71 @@ static const char *seeds2[] = {
    NULL
 };
 
-#define NB_STRINGS_NS 100
-#define NB_STRINGS_MAX 10000
+#define NB_STRINGS_MAX 100000
+#define NB_STRINGS_NS  10000
+#define NB_STRINGS_PREFIX (NB_STRINGS_NS / 20)
 #define NB_STRINGS_MIN 10
 
-static xmlChar *strings1[NB_STRINGS_MAX];
-static xmlChar *strings2[NB_STRINGS_MAX];
-static const xmlChar *test1[NB_STRINGS_MAX];
-static const xmlChar *test2[NB_STRINGS_MAX];
+static xmlChar **strings1;
+static xmlChar **strings2;
+static const xmlChar **test1;
+static const xmlChar **test2;
 static int nbErrors = 0;
 
-static void fill_strings(void) {
+static void
+fill_string_pool(xmlChar **strings, const char **seeds) {
     int i, j, k;
+    int start_ns = NB_STRINGS_MAX - NB_STRINGS_NS;
 
     /*
      * That's a bit nasty but the output is fine and it doesn't take hours
      * there is a small but sufficient number of duplicates, and we have
      * ":xxx" and full QNames in the last NB_STRINGS_NS values
      */
-    for (i = 0; seeds1[i] != NULL; i++) {
-        strings1[i] = xmlStrdup((const xmlChar *) seeds1[i]);
-       if (strings1[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings1\n");
-           exit(1);
-       }
-    }
-    for (j = 0, k = 0;i < NB_STRINGS_MAX - NB_STRINGS_NS;i++,j++) {
-        strings1[i] = xmlStrncatNew(strings1[j], strings1[k], -1);
-       if (strings1[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings1\n");
-           exit(1);
-       }
-       if (j >= 50) {
-           j = 0;
-           k++;
-       }
-    }
-    for (j = 0; (j < 50) && (i < NB_STRINGS_MAX); i++, j+=2) {
-        strings1[i] = xmlStrncatNew(strings1[j], (const xmlChar *) ":", -1);
-       if (strings1[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings1\n");
-           exit(1);
-       }
-    }
-    for (j = NB_STRINGS_MAX - NB_STRINGS_NS, k = 0;
-         i < NB_STRINGS_MAX;i++,j++) {
-        strings1[i] = xmlStrncatNew(strings1[j], strings1[k], -1);
-       if (strings1[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings1\n");
-           exit(1);
-       }
-       k += 3;
-       if (k >= 50) k = 0;
-    }
-
-    /*
-     * Now do the same with the second pool of strings
-     */
-    for (i = 0; seeds2[i] != NULL; i++) {
-        strings2[i] = xmlStrdup((const xmlChar *) seeds2[i]);
-       if (strings2[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings2\n");
+    for (i = 0; seeds[i] != NULL; i++) {
+        strings[i] = xmlStrdup((const xmlChar *) seeds[i]);
+       if (strings[i] == NULL) {
+           fprintf(stderr, "Out of memory while generating strings\n");
            exit(1);
        }
     }
-    for (j = 0, k = 0;i < NB_STRINGS_MAX - NB_STRINGS_NS;i++,j++) {
-        strings2[i] = xmlStrncatNew(strings2[j], strings2[k], -1);
-       if (strings2[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings2\n");
+    for (j = 0, k = 0; i < start_ns; i++) {
+        strings[i] = xmlStrncatNew(strings[j], strings[k], -1);
+       if (strings[i] == NULL) {
+           fprintf(stderr, "Out of memory while generating strings\n");
            exit(1);
        }
+        if (xmlStrlen(strings[i]) > 30) {
+            fprintf(stderr, "### %s %s\n", strings[start_ns+j], strings[k]);
+            abort();
+        }
+        j++;
        if (j >= 50) {
            j = 0;
            k++;
        }
     }
-    for (j = 0; (j < 50) && (i < NB_STRINGS_MAX); i++, j+=2) {
-        strings2[i] = xmlStrncatNew(strings2[j], (const xmlChar *) ":", -1);
-       if (strings2[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings2\n");
+    for (j = 0, k = 0; (j < NB_STRINGS_PREFIX) && (i < NB_STRINGS_MAX);
+         i++, j++) {
+        strings[i] = xmlStrncatNew(strings[k], (const xmlChar *) ":", -1);
+       if (strings[i] == NULL) {
+           fprintf(stderr, "Out of memory while generating strings\n");
            exit(1);
        }
+        k += 1;
+        if (k >= start_ns) k = 0;
     }
-    for (j = NB_STRINGS_MAX - NB_STRINGS_NS, k = 0;
-         i < NB_STRINGS_MAX;i++,j++) {
-        strings2[i] = xmlStrncatNew(strings2[j], strings2[k], -1);
-       if (strings2[i] == NULL) {
-           fprintf(stderr, "Out of memory while generating strings2\n");
+    for (j = 0, k = 0; i < NB_STRINGS_MAX; i++) {
+        strings[i] = xmlStrncatNew(strings[start_ns+j], strings[k], -1);
+       if (strings[i] == NULL) {
+           fprintf(stderr, "Out of memory while generating strings\n");
            exit(1);
        }
-       k += 3;
-       if (k >= 50) k = 0;
+        j++;
+        if (j >= NB_STRINGS_PREFIX) j = 0;
+       k += 5;
+        if (k >= start_ns) k = 0;
     }
-
 }
 
 #ifdef WITH_PRINT
@@ -146,7 +130,8 @@ static void clean_strings(void) {
 /*
  * This tests the sub-dictionary support
  */
-static int run_test2(xmlDictPtr parent) {
+static int
+test_subdict(xmlDictPtr parent) {
     int i, j;
     xmlDictPtr dict;
     int ret = 0;
@@ -159,7 +144,8 @@ static int run_test2(xmlDictPtr parent) {
        fprintf(stderr, "Out of memory while creating sub-dictionary\n");
        exit(1);
     }
-    memset(test2, 0, sizeof(test2));
+    /* Cast to avoid buggy warning on MSVC. */
+    memset((void *) test2, 0, sizeof(test2));
 
     /*
      * Fill in NB_STRINGS_MIN, at this point the dictionary should not grow
@@ -309,20 +295,16 @@ static int run_test2(xmlDictPtr parent) {
 /*
  * Test a single dictionary
  */
-static int run_test1(void) {
+static int
+test_dict(xmlDict *dict) {
     int i, j;
-    xmlDictPtr dict;
     int ret = 0;
     xmlChar prefix[40];
     xmlChar *cur, *pref;
     const xmlChar *tmp;
 
-    dict = xmlDictCreate();
-    if (dict == NULL) {
-       fprintf(stderr, "Out of memory while creating dictionary\n");
-       exit(1);
-    }
-    memset(test1, 0, sizeof(test1));
+    /* Cast to avoid buggy warning on MSVC. */
+    memset((void *) test1, 0, sizeof(test1));
 
     /*
      * Fill in NB_STRINGS_MIN, at this point the dictionary should not grow
@@ -416,29 +398,426 @@ static int run_test1(void) {
        }
     }
 
-    run_test2(dict);
-
-    xmlDictFree(dict);
     return(ret);
 }
 
-int main(void)
-{
-    int ret;
+static int
+testall_dict(void) {
+    xmlDictPtr dict;
+    int ret = 0;
 
-    LIBXML_TEST_VERSION
-    fill_strings();
+    strings1 = xmlMalloc(NB_STRINGS_MAX * sizeof(strings1[0]));
+    memset(strings1, 0, NB_STRINGS_MAX * sizeof(strings1[0]));
+    strings2 = xmlMalloc(NB_STRINGS_MAX * sizeof(strings2[0]));
+    memset(strings2, 0, NB_STRINGS_MAX * sizeof(strings2[0]));
+    test1 = xmlMalloc(NB_STRINGS_MAX * sizeof(test1[0]));
+    memset(test1, 0, NB_STRINGS_MAX * sizeof(test1[0]));
+    test2 = xmlMalloc(NB_STRINGS_MAX * sizeof(test2[0]));
+    memset(test2, 0, NB_STRINGS_MAX * sizeof(test2[0]));
+
+    fill_string_pool(strings1, seeds1);
+    fill_string_pool(strings2, seeds2);
 #ifdef WITH_PRINT
     print_strings();
 #endif
-    ret = run_test1();
-    if (ret == 0) {
-        printf("dictionary tests succeeded %d strings\n", 2 * NB_STRINGS_MAX);
-    } else {
-        printf("dictionary tests failed with %d errors\n", nbErrors);
+
+    dict = xmlDictCreate();
+    if (dict == NULL) {
+       fprintf(stderr, "Out of memory while creating dictionary\n");
+       exit(1);
+    }
+    if (test_dict(dict) != 0) {
+        ret = 1;
+    }
+    if (test_subdict(dict) != 0) {
+        ret = 1;
     }
+    xmlDictFree(dict);
+
     clean_strings();
+    xmlFree(strings1);
+    xmlFree(strings2);
+    xmlFree(test1);
+    xmlFree(test2);
+
+    return ret;
+}
+
+
+/**** Hash table tests ****/
+
+static unsigned
+rng_state[2] = { 123, 456 };
+
+#define HASH_ROL(x,n) ((x) << (n) | ((x) & 0xFFFFFFFF) >> (32 - (n)))
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
+static unsigned
+my_rand(unsigned max) {
+    unsigned s0 = rng_state[0];
+    unsigned s1 = rng_state[1];
+    unsigned result = HASH_ROL(s0 * 0x9E3779BB, 5) * 5;
+
+    s1 ^= s0;
+    rng_state[0] = HASH_ROL(s0, 26) ^ s1 ^ (s1 << 9);
+    rng_state[1] = HASH_ROL(s1, 13);
+
+    return((result & 0xFFFFFFFF) % max);
+}
+
+static xmlChar *
+gen_random_string(xmlChar id) {
+    unsigned size = my_rand(64) + 1;
+    unsigned id_pos = my_rand(size);
+    size_t j;
+
+    xmlChar *str = xmlMalloc(size + 1);
+    for (j = 0; j < size; j++) {
+        str[j] = 'a' + my_rand(26);
+    }
+    str[id_pos] = id;
+    str[size] = 0;
+
+    /* Generate QName in 75% of cases */
+    if (size > 3 && my_rand(4) > 0) {
+        unsigned colon_pos = my_rand(size - 3) + 1;
+
+        if (colon_pos >= id_pos)
+            colon_pos++;
+        str[colon_pos] = ':';
+    }
+
+    return str;
+}
+
+typedef struct {
+    xmlChar **strings;
+    size_t num_entries;
+    size_t num_keys;
+    size_t num_strings;
+    size_t index;
+    xmlChar id;
+} StringPool;
+
+static StringPool *
+pool_new(size_t num_entries, size_t num_keys, xmlChar id) {
+    StringPool *ret;
+    size_t num_strings;
+
+    ret = xmlMalloc(sizeof(*ret));
+    ret->num_entries = num_entries;
+    ret->num_keys = num_keys;
+    num_strings = num_entries * num_keys;
+    ret->strings = xmlMalloc(num_strings * sizeof(ret->strings[0]));
+    memset(ret->strings, 0, num_strings * sizeof(ret->strings[0]));
+    ret->num_strings = num_strings;
+    ret->index = 0;
+    ret->id = id;
+
+    return ret;
+}
+
+static void
+pool_free(StringPool *pool) {
+    size_t i;
+
+    for (i = 0; i < pool->num_strings; i++) {
+        xmlFree(pool->strings[i]);
+    }
+    xmlFree(pool->strings);
+    xmlFree(pool);
+}
+
+static int
+pool_done(StringPool *pool) {
+    return pool->index >= pool->num_strings;
+}
+
+static void
+pool_reset(StringPool *pool) {
+    pool->index = 0;
+}
+
+static int
+pool_bulk_insert(StringPool *pool, xmlHashTablePtr hash, size_t num) {
+    size_t i, j;
+    int ret = 0;
+
+    for (i = pool->index, j = 0; i < pool->num_strings && j < num; j++) {
+        xmlChar *str[3];
+        size_t k;
+
+        while (1) {
+            xmlChar tmp_key[1];
+            int res;
+
+            for (k = 0; k < pool->num_keys; k++)
+                str[k] = gen_random_string(pool->id);
+
+            switch (pool->num_keys) {
+                case 1:
+                    res = xmlHashAddEntry(hash, str[0], tmp_key);
+                    if (res == 0 &&
+                        xmlHashUpdateEntry(hash, str[0], str[0], NULL) != 0)
+                        ret = -1;
+                    break;
+                case 2:
+                    res = xmlHashAddEntry2(hash, str[0], str[1], tmp_key);
+                    if (res == 0 &&
+                        xmlHashUpdateEntry2(hash, str[0], str[1], str[0],
+                                            NULL) != 0)
+                        ret = -1;
+                    break;
+                case 3:
+                    res = xmlHashAddEntry3(hash, str[0], str[1], str[2],
+                                           tmp_key);
+                    if (res == 0 &&
+                        xmlHashUpdateEntry3(hash, str[0], str[1], str[2],
+                                            str[0], NULL) != 0)
+                        ret = -1;
+                    break;
+            }
+
+            if (res == 0)
+                break;
+            for (k = 0; k < pool->num_keys; k++)
+                xmlFree(str[k]);
+        }
+
+        for (k = 0; k < pool->num_keys; k++)
+            pool->strings[i++] = str[k];
+    }
+
+    pool->index = i;
+    return ret;
+}
+
+static xmlChar *
+hash_qlookup(xmlHashTable *hash, xmlChar **names, size_t num_keys) {
+    xmlChar *prefix[3];
+    const xmlChar *local[3];
+    xmlChar *res;
+    size_t i;
+
+    for (i = 0; i < 3; ++i) {
+        if (i >= num_keys) {
+            prefix[i] = NULL;
+            local[i] = NULL;
+        } else {
+            const xmlChar *name = names[i];
+            const xmlChar *colon = BAD_CAST strchr((const char *) name, ':');
+
+            if (colon == NULL) {
+                prefix[i] = NULL;
+                local[i] = name;
+            } else {
+                prefix[i] = xmlStrndup(name, colon - name);
+                local[i] = &colon[1];
+            }
+        }
+    }
+
+    res = xmlHashQLookup3(hash, prefix[0], local[0], prefix[1], local[1],
+                          prefix[2], local[2]);
+
+    for (i = 0; i < 3; ++i)
+        xmlFree(prefix[i]);
+
+    return res;
+}
+
+static int
+pool_bulk_lookup(StringPool *pool, xmlHashTablePtr hash, size_t num,
+                 int existing) {
+    size_t i, j;
+    int ret = 0;
+
+    for (i = pool->index, j = 0; i < pool->num_strings && j < num; j++) {
+        xmlChar **str = &pool->strings[i];
+        int q;
+
+        for (q = 0; q < 2; q++) {
+            xmlChar *res = NULL;
+
+            if (q) {
+                res = hash_qlookup(hash, str, pool->num_keys);
+            } else {
+                switch (pool->num_keys) {
+                    case 1:
+                        res = xmlHashLookup(hash, str[0]);
+                        break;
+                    case 2:
+                        res = xmlHashLookup2(hash, str[0], str[1]);
+                        break;
+                    case 3:
+                        res = xmlHashLookup3(hash, str[0], str[1], str[2]);
+                        break;
+                }
+            }
+
+            if (existing) {
+                if (res != str[0])
+                    ret = -1;
+            } else {
+                if (res != NULL)
+                    ret = -1;
+            }
+        }
+
+        i += pool->num_keys;
+    }
+
+    pool->index = i;
+    return ret;
+}
+
+static int
+pool_bulk_remove(StringPool *pool, xmlHashTablePtr hash, size_t num) {
+    size_t i, j;
+    int ret = 0;
+
+    for (i = pool->index, j = 0; i < pool->num_strings && j < num; j++) {
+        xmlChar **str = &pool->strings[i];
+        int res = -1;
+
+        switch (pool->num_keys) {
+            case 1:
+                res = xmlHashRemoveEntry(hash, str[0], NULL);
+                break;
+            case 2:
+                res = xmlHashRemoveEntry2(hash, str[0], str[1], NULL);
+                break;
+            case 3:
+                res = xmlHashRemoveEntry3(hash, str[0], str[1], str[2], NULL);
+                break;
+        }
+
+        if (res != 0)
+            ret = -1;
+
+        i += pool->num_keys;
+    }
+
+    pool->index = i;
+    return ret;
+}
+
+static int
+test_hash(size_t num_entries, size_t num_keys, int use_dict) {
+    xmlDict *dict = NULL;
+    xmlHashTable *hash;
+    StringPool *pool1, *pool2;
+    int ret = 0;
+
+    if (use_dict) {
+        dict = xmlDictCreate();
+        hash = xmlHashCreateDict(0, dict);
+    } else {
+        hash = xmlHashCreate(0);
+    }
+    pool1 = pool_new(num_entries, num_keys, '1');
+    pool2 = pool_new(num_entries, num_keys, '2');
+
+    /* Insert all strings from pool2 and about half of pool1. */
+    while (!pool_done(pool2)) {
+        if (pool_bulk_insert(pool1, hash, my_rand(50)) != 0) {
+            fprintf(stderr, "pool1: hash insert failed\n");
+            ret = 1;
+        }
+        if (pool_bulk_insert(pool2, hash, my_rand(100)) != 0) {
+            fprintf(stderr, "pool1: hash insert failed\n");
+            ret = 1;
+        }
+    }
+
+    /* Check existing entries */
+    pool_reset(pool2);
+    if (pool_bulk_lookup(pool2, hash, pool2->num_entries, 1) != 0) {
+        fprintf(stderr, "pool2: hash lookup failed\n");
+        ret = 1;
+    }
+
+    /* Remove all strings from pool2 and insert the rest of pool1. */
+    pool_reset(pool2);
+    while (!pool_done(pool1) || !pool_done(pool2)) {
+        if (pool_bulk_insert(pool1, hash, my_rand(50)) != 0) {
+            fprintf(stderr, "pool1: hash insert failed\n");
+            ret = 1;
+        }
+        if (pool_bulk_remove(pool2, hash, my_rand(100)) != 0) {
+            fprintf(stderr, "pool2: hash remove failed\n");
+            ret = 1;
+        }
+    }
+
+    /* Check existing entries */
+    pool_reset(pool1);
+    if (pool_bulk_lookup(pool1, hash, pool1->num_entries, 1) != 0) {
+        fprintf(stderr, "pool1: hash lookup failed\n");
+        ret = 1;
+    }
+
+    /* Check removed entries */
+    pool_reset(pool2);
+    if (pool_bulk_lookup(pool2, hash, pool2->num_entries, 0) != 0) {
+        fprintf(stderr, "pool2: hash lookup succeeded unexpectedly\n");
+        ret = 1;
+    }
+
+    pool_free(pool1);
+    pool_free(pool2);
+    xmlHashFree(hash, NULL);
+    xmlDictFree(dict);
+
+    return ret;
+}
+
+static int
+testall_hash(void) {
+    size_t num_keys;
+
+    for (num_keys = 1; num_keys <= 3; num_keys++) {
+        size_t num_strings;
+        size_t max_strings = num_keys == 1 ? 100000 : 1000;
+
+        for (num_strings = 10; num_strings <= max_strings; num_strings *= 10) {
+            size_t reps, i;
+
+            reps = 1000 / num_strings;
+            if (reps == 0)
+                reps = 1;
+
+            for (i = 0; i < reps; i++) {
+                if (test_hash(num_strings, num_keys, /* use_dict */ 0) != 0)
+                    return(1);
+            }
+
+            if (test_hash(num_strings, num_keys, /* use_dict */ 1) != 0)
+                return(1);
+        }
+    }
+
+    return(0);
+}
+
+
+/**** main ****/
+
+int
+main(void) {
+    int ret = 0;
+
+    LIBXML_TEST_VERSION
+
+    if (testall_dict() != 0) {
+        fprintf(stderr, "dictionary tests failed\n");
+        ret = 1;
+    }
+    if (testall_hash() != 0) {
+        fprintf(stderr, "hash tests failed\n");
+        ret = 1;
+    }
+
     xmlCleanupParser();
-    xmlMemoryDump();
     return(ret);
 }
index 0b045ea..78d62fb 100644 (file)
  * daniel@veillard.com
  */
 
-#include "libxml.h"
 #include <stdio.h>
-
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 #include <time.h>
 
 #include <libxml/parser.h>
@@ -402,7 +396,7 @@ testExternalEntityLoader(const char *URL, const char *ID,
 static char testErrors[32769];
 static int testErrorsSize = 0;
 
-static void XMLCDECL
+static void
 channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
     int res;
@@ -481,7 +475,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
 }
 
 static void
-testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
+testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, const xmlError *err) {
     char *file = NULL;
     int line = 0;
     int code = -1;
@@ -664,9 +658,6 @@ testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
 
 static void
 initializeLibxml2(void) {
-    xmlGetWarningsDefaultValue = 0;
-    xmlPedanticParserDefault(0);
-
     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
     xmlInitParser();
     xmlSetExternalEntityLoader(testExternalEntityLoader);
@@ -1117,7 +1108,7 @@ commentCallback(void *ctx ATTRIBUTE_UNUSED,
  * Display and format a warning messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 warningCallback(void *ctx ATTRIBUTE_UNUSED,
                 const char *msg ATTRIBUTE_UNUSED, ...)
 {
@@ -1134,7 +1125,7 @@ warningCallback(void *ctx ATTRIBUTE_UNUSED,
  * Display and format a error messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 errorCallback(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
               ...)
 {
@@ -1151,7 +1142,7 @@ errorCallback(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
  * Display and format a fatalError messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL
+static void
 fatalErrorCallback(void *ctx ATTRIBUTE_UNUSED,
                    const char *msg ATTRIBUTE_UNUSED, ...)
 {
@@ -1261,19 +1252,15 @@ saxTest(const char *filename, size_t limit, int options, int fail) {
     int res = 0;
     xmlParserCtxtPtr ctxt;
     xmlDocPtr doc;
-    xmlSAXHandlerPtr old_sax;
 
     nb_tests++;
 
     maxlen = limit;
-    ctxt = xmlNewParserCtxt();
+    ctxt = xmlNewSAXParserCtxt(callbackSAX2Handler, NULL);
     if (ctxt == NULL) {
         fprintf(stderr, "Failed to create parser context\n");
        return(1);
     }
-    old_sax = ctxt->sax;
-    ctxt->sax = callbackSAX2Handler;
-    ctxt->userData = NULL;
     doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
 
     if (doc != NULL) {
@@ -1296,7 +1283,6 @@ saxTest(const char *filename, size_t limit, int options, int fail) {
         } else
             res = 0;
     }
-    ctxt->sax = old_sax;
     xmlFreeParserCtxt(ctxt);
 
     return(res);
@@ -1632,7 +1618,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_tests, nb_errors, nb_leaks);
     }
     xmlCleanupParser();
-    xmlMemoryDump();
 
     return(ret);
 }
diff --git a/testparser.c b/testparser.c
new file mode 100644 (file)
index 0000000..e67cea5
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * testparser.c: Additional parser tests
+ *
+ * See Copyright for the status of this software.
+ */
+
+#include <libxml/parser.h>
+
+static int
+testStandaloneWithEncoding(void) {
+    xmlDocPtr doc;
+    const char *str =
+        "<?xml version=\"1.0\" standalone=\"yes\"?>\n"
+        "<doc></doc>\n";
+    int err = 0;
+
+    xmlResetLastError();
+
+    doc = xmlReadDoc(BAD_CAST str, NULL, "UTF-8", 0);
+    if (doc == NULL) {
+        fprintf(stderr, "xmlReadDoc failed\n");
+        err = 1;
+    }
+    xmlFreeDoc(doc);
+
+    return err;
+}
+
+#ifdef LIBXML_PUSH_ENABLED
+static int
+testHugePush(void) {
+    xmlParserCtxtPtr ctxt;
+    int err, i;
+
+    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
+
+    /*
+     * Push parse a document larger than XML_MAX_LOOKUP_LIMIT
+     * (10,000,000 bytes). This mainly tests whether shrinking the
+     * buffer works when push parsing.
+     */
+    xmlParseChunk(ctxt, "<doc>", 5, 0);
+    for (i = 0; i < 1000000; i++)
+        xmlParseChunk(ctxt, "<elem>text</elem>", 17, 0);
+    xmlParseChunk(ctxt, "</doc>", 6, 1);
+
+    err = ctxt->wellFormed ? 0 : 1;
+    xmlFreeDoc(ctxt->myDoc);
+    xmlFreeParserCtxt(ctxt);
+
+    return err;
+}
+
+static int
+testHugeEncodedChunk(void) {
+    xmlBufferPtr buf;
+    xmlChar *chunk;
+    xmlParserCtxtPtr ctxt;
+    int err, i;
+
+    /*
+     * Test the push parser with a built-in encoding handler like ISO-8859-1
+     * and a chunk larger than the initial decoded buffer (currently 4 KB).
+     */
+    buf = xmlBufferCreate();
+    xmlBufferCat(buf,
+            BAD_CAST "<?xml version='1.0' encoding='ISO-8859-1'?>\n");
+    xmlBufferCat(buf, BAD_CAST "<doc><!-- ");
+    for (i = 0; i < 2000; i++)
+        xmlBufferCat(buf, BAD_CAST "0123456789");
+    xmlBufferCat(buf, BAD_CAST " --></doc>");
+    chunk = xmlBufferDetach(buf);
+    xmlBufferFree(buf);
+
+    ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
+
+    xmlParseChunk(ctxt, (char *) chunk, xmlStrlen(chunk), 0);
+    xmlParseChunk(ctxt, NULL, 0, 1);
+
+    err = ctxt->wellFormed ? 0 : 1;
+    xmlFreeDoc(ctxt->myDoc);
+    xmlFreeParserCtxt(ctxt);
+    xmlFree(chunk);
+
+    return err;
+}
+#endif
+
+int
+main(void) {
+    int err = 0;
+
+    err |= testStandaloneWithEncoding();
+#ifdef LIBXML_PUSH_ENABLED
+    err |= testHugePush();
+    err |= testHugeEncodedChunk();
+#endif
+
+    return err;
+}
+
index fabc513..63b6bc4 100644 (file)
  * daniel@veillard.com
  */
 
-#include "libxml.h"
+#include "config.h"
 #include <stdio.h>
 
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 
 #include <libxml/parser.h>
+#include <libxml/parserInternals.h>
 #include <libxml/tree.h>
 #include <libxml/uri.h>
-#ifdef LIBXML_READER_ENABLED
-#include <libxml/xmlreader.h>
-#endif
 
 /*
  * O_BINARY is just for Windows compatibility - if it isn't defined
@@ -38,6 +32,9 @@
 #define        RD_FLAGS        O_RDONLY
 #endif
 
+#define OPT_SAX         (1<<0)
+#define OPT_NO_SUBST    (1<<1)
+
 typedef int (*functest) (const char *filename, const char *result,
                          const char *error, int options);
 
@@ -59,7 +56,6 @@ static int checkTestFile(const char *filename);
 #if defined(_WIN32)
 
 #include <windows.h>
-#include <io.h>
 
 typedef struct
 {
@@ -158,17 +154,62 @@ static void globfree(glob_t *pglob) {
 
 #include <libxml/xmlIO.h>
 
+typedef struct {
+    const char *URL;
+    const char *start;
+    const char *segment;
+    const char *finish;
+} xmlHugeDocParts;
+
+static const xmlHugeDocParts hugeDocTable[] = {
+    {
+        "test/recurse/huge.xml",
+
+        "<!DOCTYPE foo ["
+        "<!ELEMENT foo (bar*)> "
+        "<!ELEMENT bar (#PCDATA)> "
+        "<!ATTLIST bar attr CDATA #IMPLIED> "
+        "<!ENTITY a SYSTEM 'ga.ent'> "
+        "<!ENTITY b SYSTEM 'gb.ent'> "
+        "<!ENTITY c SYSTEM 'gc.ent'> "
+        "<!ENTITY f 'some internal data'> "
+        "<!ENTITY e '&f;&f;'> "
+        "<!ENTITY d '&e;&e;'> "
+        "]> "
+        "<foo>",
+
+        "  <bar attr='&e; &f; &d;'>&a; &b; &c; &e; &f; &d;</bar>\n"
+        "  <bar>_123456789_123456789_123456789_123456789</bar>\n"
+        "  <bar>_123456789_123456789_123456789_123456789</bar>\n"
+        "  <bar>_123456789_123456789_123456789_123456789</bar>\n"
+        "  <bar>_123456789_123456789_123456789_123456789</bar>\n",
+
+        "</foo>"
+    },
+    {
+        "test/recurse/huge_dtd.dtd",
+
+        "<!ELEMENT foo (#PCDATA)>\n"
+        "<!ENTITY ent 'success'>\n"
+        "<!ENTITY % a SYSTEM 'pa.ent'>\n"
+        "<!ENTITY % b SYSTEM 'pb.ent'>\n"
+        "<!ENTITY % c SYSTEM 'pc.ent'>\n"
+        "<!ENTITY % d '<!-- comment -->'>\n"
+        "<!ENTITY % e '%d;%d;'>\n"
+        "<!ENTITY % f '%e;%e;'>\n",
+
+        "<!ENTITY ent '%a; %b; %c; %d; %e; %f;'>\n"
+        "%a; %b; %c; %d; %e; %f;\n"
+        "<!-- _123456789_123456789_123456789_123456789 -->\n"
+        "<!-- _123456789_123456789_123456789_123456789 -->\n"
+        "<!-- _123456789_123456789_123456789_123456789 -->\n",
+
+        ""
+    },
+    { NULL, NULL, NULL, NULL }
+};
 
-static const char *start = "<!DOCTYPE foo [\
-<!ENTITY f 'some internal data'> \
-<!ENTITY e '&f;&f;'> \
-<!ENTITY d '&e;&e;'> \
-]> \
-<foo>";
-
-static const char *segment = "  <bar>&e; &f; &d;</bar>\n";
-static const char *finish = "</foo>";
-
+static const xmlHugeDocParts *hugeDocParts;
 static int curseg = 0;
 static const char *current;
 static int rlen;
@@ -177,14 +218,22 @@ static int rlen;
  * hugeMatch:
  * @URI: an URI to test
  *
- * Check for an huge: query
+ * Check for a huge query
  *
  * Returns 1 if yes and 0 if another Input module should be used
  */
 static int
 hugeMatch(const char * URI) {
-    if ((URI != NULL) && (!strncmp(URI, "huge:", 4)))
-        return(1);
+    int i;
+
+    if (URI == NULL)
+        return(0);
+
+    for (i = 0; hugeDocTable[i].URL; i++) {
+        if (strcmp(URI, hugeDocTable[i].URL) == 0)
+            return(1);
+    }
+
     return(0);
 }
 
@@ -192,25 +241,36 @@ hugeMatch(const char * URI) {
  * hugeOpen:
  * @URI: an URI to test
  *
- * Return a pointer to the huge: query handler, in this example simply
+ * Return a pointer to the huge query handler, in this example simply
  * the current pointer...
  *
  * Returns an Input context or NULL in case or error
  */
 static void *
 hugeOpen(const char * URI) {
-    if ((URI == NULL) || (strncmp(URI, "huge:", 4)))
+    int i;
+
+    if (URI == NULL)
         return(NULL);
-    rlen = strlen(start);
-    current = start;
-    return((void *) current);
+
+    for (i = 0; hugeDocTable[i].URL; i++) {
+        if (strcmp(URI, hugeDocTable[i].URL) == 0) {
+            hugeDocParts = hugeDocTable + i;
+            curseg = 0;
+            current = hugeDocParts->start;
+            rlen = strlen(current);
+            return((void *) current);
+        }
+    }
+
+    return(NULL);
 }
 
 /**
  * hugeClose:
  * @context: the read context
  *
- * Close the huge: query handler
+ * Close the huge query handler
  *
  * Returns 0 or -1 in case of error
  */
@@ -220,7 +280,7 @@ hugeClose(void * context) {
     return(0);
 }
 
-#define MAX_NODES 1000000
+#define MAX_NODES 1000
 
 /**
  * hugeRead:
@@ -228,7 +288,7 @@ hugeClose(void * context) {
  * @buffer: where to store data
  * @len: number of bytes to read
  *
- * Implement an huge: query read.
+ * Implement an huge query read.
  *
  * Returns the number of bytes read or -1 in case of error
  */
@@ -248,15 +308,11 @@ hugeRead(void *context, char *buffer, int len)
        memcpy(buffer, current, len);
         curseg ++;
         if (curseg == MAX_NODES) {
-           fprintf(stderr, "\n");
-            rlen = strlen(finish);
-            current = finish;
+            current = hugeDocParts->finish;
        } else {
-           if (curseg % (MAX_NODES / 10) == 0)
-               fprintf(stderr, ".");
-            rlen = strlen(segment);
-            current = segment;
+            current = hugeDocParts->segment;
        }
+        rlen = strlen(current);
     } else {
        memcpy(buffer, current, len);
        rlen -= len;
@@ -310,7 +366,7 @@ testExternalEntityLoader(const char *URL, const char *ID,
 static char testErrors[32769];
 static int testErrorsSize = 0;
 
-static void XMLCDECL
+static void
 channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
     int res;
@@ -389,7 +445,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
 }
 
 static void
-testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
+testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, const xmlError *err) {
     char *file = NULL;
     int line = 0;
     int code = -1;
@@ -572,9 +628,6 @@ testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
 
 static void
 initializeLibxml2(void) {
-    xmlGetWarningsDefaultValue = 0;
-    xmlPedanticParserDefault(0);
-
     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
     xmlInitParser();
     xmlSetExternalEntityLoader(testExternalEntityLoader);
@@ -589,6 +642,19 @@ initializeLibxml2(void) {
     }
 }
 
+static void
+initSAX(xmlParserCtxtPtr ctxt) {
+    ctxt->sax->startElementNs = NULL;
+    ctxt->sax->endElementNs = NULL;
+    ctxt->sax->startElement = NULL;
+    ctxt->sax->endElement = NULL;
+    ctxt->sax->characters = NULL;
+    ctxt->sax->cdataBlock = NULL;
+    ctxt->sax->ignorableWhitespace = NULL;
+    ctxt->sax->processingInstruction = NULL;
+    ctxt->sax->comment = NULL;
+}
+
 /************************************************************************
  *                                                                     *
  *             File name and path utilities                            *
@@ -676,19 +742,28 @@ static int
 recursiveDetectTest(const char *filename,
              const char *result ATTRIBUTE_UNUSED,
              const char *err ATTRIBUTE_UNUSED,
-            int options ATTRIBUTE_UNUSED) {
+            int options) {
     xmlDocPtr doc;
     xmlParserCtxtPtr ctxt;
     int res = 0;
+    /*
+     * XML_PARSE_DTDVALID is the only way to load external entities
+     * without XML_PARSE_NOENT. The validation result doesn't matter
+     * anyway.
+     */
+    int parserOptions = XML_PARSE_DTDVALID;
 
     nb_tests++;
 
     ctxt = xmlNewParserCtxt();
+    if (options & OPT_SAX)
+        initSAX(ctxt);
+    if ((options & OPT_NO_SUBST) == 0)
+        parserOptions |= XML_PARSE_NOENT;
     /*
      * base of the test, parse with the old API
      */
-    doc = xmlCtxtReadFile(ctxt, filename, NULL,
-                          XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
+    doc = xmlCtxtReadFile(ctxt, filename, NULL, parserOptions);
     if ((doc != NULL) || (ctxt->lastError.code != XML_ERR_ENTITY_LOOP)) {
         fprintf(stderr, "Failed to detect recursion in %s\n", filename);
        xmlFreeParserCtxt(ctxt);
@@ -715,19 +790,23 @@ static int
 notRecursiveDetectTest(const char *filename,
              const char *result ATTRIBUTE_UNUSED,
              const char *err ATTRIBUTE_UNUSED,
-            int options ATTRIBUTE_UNUSED) {
+            int options) {
     xmlDocPtr doc;
     xmlParserCtxtPtr ctxt;
     int res = 0;
+    int parserOptions = XML_PARSE_DTDLOAD;
 
     nb_tests++;
 
     ctxt = xmlNewParserCtxt();
+    if (options & OPT_SAX)
+        initSAX(ctxt);
+    if ((options & OPT_NO_SUBST) == 0)
+        parserOptions |= XML_PARSE_NOENT;
     /*
      * base of the test, parse with the old API
      */
-    doc = xmlCtxtReadFile(ctxt, filename, NULL,
-                          XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
+    doc = xmlCtxtReadFile(ctxt, filename, NULL, parserOptions);
     if (doc == NULL) {
         fprintf(stderr, "Failed to parse correct file %s\n", filename);
        xmlFreeParserCtxt(ctxt);
@@ -739,7 +818,6 @@ notRecursiveDetectTest(const char *filename,
     return(res);
 }
 
-#ifdef LIBXML_READER_ENABLED
 /**
  * notRecursiveHugeTest:
  * @filename: the file to parse
@@ -755,32 +833,186 @@ static int
 notRecursiveHugeTest(const char *filename ATTRIBUTE_UNUSED,
              const char *result ATTRIBUTE_UNUSED,
              const char *err ATTRIBUTE_UNUSED,
-            int options ATTRIBUTE_UNUSED) {
-    xmlTextReaderPtr reader;
+            int options) {
+    xmlParserCtxtPtr ctxt;
+    xmlDocPtr doc;
     int res = 0;
-    int ret;
+    int parserOptions = XML_PARSE_DTDVALID;
 
     nb_tests++;
 
-    reader = xmlReaderForFile("huge:test" , NULL,
-                              XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
-    if (reader == NULL) {
-        fprintf(stderr, "Failed to open huge:test\n");
-       return(1);
-    }
-    ret = xmlTextReaderRead(reader);
-    while (ret == 1) {
-        ret = xmlTextReaderRead(reader);
+    ctxt = xmlNewParserCtxt();
+    if (options & OPT_SAX)
+        initSAX(ctxt);
+    if ((options & OPT_NO_SUBST) == 0)
+        parserOptions |= XML_PARSE_NOENT;
+    doc = xmlCtxtReadFile(ctxt, "test/recurse/huge.xml", NULL, parserOptions);
+    if (doc == NULL) {
+        fprintf(stderr, "Failed to parse huge.xml\n");
+       res = 1;
+    } else {
+        xmlEntityPtr ent;
+        unsigned long fixed_cost = 20;
+        unsigned long allowed_expansion = 1000000;
+        unsigned long f_size = xmlStrlen(BAD_CAST "some internal data");
+        unsigned long e_size;
+        unsigned long d_size;
+        unsigned long total_size;
+
+        ent = xmlGetDocEntity(doc, BAD_CAST "e");
+        e_size = f_size * 2 +
+                 xmlStrlen(BAD_CAST "&f;") * 2 +
+                 fixed_cost * 2;
+        if (ent->expandedSize != e_size) {
+            fprintf(stderr, "Wrong size for entity e: %lu (expected %lu)\n",
+                    ent->expandedSize, e_size);
+            res = 1;
+        }
+
+        ent = xmlGetDocEntity(doc, BAD_CAST "b");
+        if (ent->expandedSize != e_size) {
+            fprintf(stderr, "Wrong size for entity b: %lu (expected %lu)\n",
+                    ent->expandedSize, e_size);
+            res = 1;
+        }
+
+        ent = xmlGetDocEntity(doc, BAD_CAST "d");
+        d_size = e_size * 2 +
+                 xmlStrlen(BAD_CAST "&e;") * 2 +
+                 fixed_cost * 2;
+        if (ent->expandedSize != d_size) {
+            fprintf(stderr, "Wrong size for entity d: %lu (expected %lu)\n",
+                    ent->expandedSize, d_size);
+            res = 1;
+        }
+
+        ent = xmlGetDocEntity(doc, BAD_CAST "c");
+        if (ent->expandedSize != d_size) {
+            fprintf(stderr, "Wrong size for entity c: %lu (expected %lu)\n",
+                    ent->expandedSize, d_size);
+            res = 1;
+        }
+
+        if (ctxt->sizeentcopy < allowed_expansion) {
+            fprintf(stderr, "Total entity size too small: %lu\n",
+                    ctxt->sizeentcopy);
+            res = 1;
+        }
+
+        total_size = (f_size + e_size + d_size + 3 * fixed_cost) *
+                     (MAX_NODES - 1) * 3;
+        if (ctxt->sizeentcopy != total_size) {
+            fprintf(stderr, "Wrong total entity size: %lu (expected %lu)\n",
+                    ctxt->sizeentcopy, total_size);
+            res = 1;
+        }
+
+        if (ctxt->sizeentities != 30) {
+            fprintf(stderr, "Wrong parsed entity size: %lu (expected %lu)\n",
+                    ctxt->sizeentities, 30lu);
+            res = 1;
+        }
     }
-    if (ret != 0) {
-        fprintf(stderr, "Failed to parser huge:test with entities\n");
+
+    xmlFreeDoc(doc);
+    xmlFreeParserCtxt(ctxt);
+
+    return(res);
+}
+
+/**
+ * notRecursiveHugeTest:
+ * @filename: the file to parse
+ * @result: the file with expected result
+ * @err: the file with error messages: unused
+ *
+ * Parse a memory generated file
+ * good cases
+ *
+ * Returns 0 in case of success, an error code otherwise
+ */
+static int
+hugeDtdTest(const char *filename ATTRIBUTE_UNUSED,
+            const char *result ATTRIBUTE_UNUSED,
+            const char *err ATTRIBUTE_UNUSED,
+            int options) {
+    xmlParserCtxtPtr ctxt;
+    xmlDocPtr doc;
+    int res = 0;
+    int parserOptions = XML_PARSE_DTDVALID;
+
+    nb_tests++;
+
+    ctxt = xmlNewParserCtxt();
+    if (options & OPT_SAX)
+        initSAX(ctxt);
+    if ((options & OPT_NO_SUBST) == 0)
+        parserOptions |= XML_PARSE_NOENT;
+    doc = xmlCtxtReadFile(ctxt, "test/recurse/huge_dtd.xml", NULL,
+                          parserOptions);
+    if (doc == NULL) {
+        fprintf(stderr, "Failed to parse huge_dtd.xml\n");
        res = 1;
+    } else {
+        unsigned long fixed_cost = 20;
+        unsigned long allowed_expansion = 1000000;
+        unsigned long a_size = xmlStrlen(BAD_CAST "<!-- comment -->");
+        unsigned long b_size;
+        unsigned long c_size;
+        unsigned long e_size;
+        unsigned long f_size;
+        unsigned long total_size;
+
+        if (ctxt->sizeentcopy < allowed_expansion) {
+            fprintf(stderr, "Total entity size too small: %lu\n",
+                    ctxt->sizeentcopy);
+            res = 1;
+        }
+
+        b_size = (a_size + strlen("&a;") + fixed_cost) * 2;
+        c_size = (b_size + strlen("&b;") + fixed_cost) * 2;
+        /*
+         * Internal parameter entites are substitued eagerly and
+         * need different accounting.
+         */
+        e_size = a_size * 2;
+        f_size = e_size * 2;
+        total_size = /* internal */
+                     e_size + f_size + fixed_cost * 4 +
+                     (a_size + e_size + f_size + fixed_cost * 3) *
+                     (MAX_NODES - 1) * 2 +
+                     /* external */
+                     (a_size + b_size + c_size + fixed_cost * 3) *
+                     (MAX_NODES - 1) * 2 +
+                     /* final reference in main doc */
+                     strlen("success") + fixed_cost;
+        if (ctxt->sizeentcopy != total_size) {
+            fprintf(stderr, "Wrong total entity size: %lu (expected %lu)\n",
+                    ctxt->sizeentcopy, total_size);
+            res = 1;
+        }
+
+        total_size = strlen(hugeDocParts->start) +
+                     strlen(hugeDocParts->segment) * (MAX_NODES - 1) +
+                     strlen(hugeDocParts->finish) +
+                     /*
+                      * Other external entities pa.ent, pb.ent, pc.ent.
+                      * These are currently counted twice because they're
+                      * used both in DTD and EntityValue.
+                      */
+                     (16 + 6 + 6) * 2;
+        if (ctxt->sizeentities != total_size) {
+            fprintf(stderr, "Wrong parsed entity size: %lu (expected %lu)\n",
+                    ctxt->sizeentities, total_size);
+            res = 1;
+        }
     }
-    xmlFreeTextReader(reader);
+
+    xmlFreeDoc(doc);
+    xmlFreeParserCtxt(ctxt);
 
     return(res);
 }
-#endif
 
 /************************************************************************
  *                                                                     *
@@ -793,14 +1025,36 @@ testDesc testDescriptions[] = {
     { "Parsing recursive test cases" ,
       recursiveDetectTest, "./test/recurse/lol*.xml", NULL, NULL, NULL,
       0 },
+    { "Parsing recursive test cases (no substitution)" ,
+      recursiveDetectTest, "./test/recurse/lol*.xml", NULL, NULL, NULL,
+      OPT_NO_SUBST },
+    { "Parsing recursive test cases (SAX)" ,
+      recursiveDetectTest, "./test/recurse/lol*.xml", NULL, NULL, NULL,
+      OPT_SAX },
+    { "Parsing recursive test cases (SAX, no substitution)" ,
+      recursiveDetectTest, "./test/recurse/lol*.xml", NULL, NULL, NULL,
+      OPT_SAX | OPT_NO_SUBST },
     { "Parsing non-recursive test cases" ,
       notRecursiveDetectTest, "./test/recurse/good*.xml", NULL, NULL, NULL,
       0 },
-#ifdef LIBXML_READER_ENABLED
+    { "Parsing non-recursive test cases (SAX)" ,
+      notRecursiveDetectTest, "./test/recurse/good*.xml", NULL, NULL, NULL,
+      OPT_SAX },
     { "Parsing non-recursive huge case" ,
       notRecursiveHugeTest, NULL, NULL, NULL, NULL,
       0 },
-#endif
+    { "Parsing non-recursive huge case (no substitution)" ,
+      notRecursiveHugeTest, NULL, NULL, NULL, NULL,
+      OPT_NO_SUBST },
+    { "Parsing non-recursive huge case (SAX)" ,
+      notRecursiveHugeTest, NULL, NULL, NULL, NULL,
+      OPT_SAX },
+    { "Parsing non-recursive huge case (SAX, no substitution)" ,
+      notRecursiveHugeTest, NULL, NULL, NULL, NULL,
+      OPT_SAX | OPT_NO_SUBST },
+    { "Parsing non-recursive huge DTD case" ,
+      hugeDtdTest, NULL, NULL, NULL, NULL,
+      0 },
     {NULL, NULL, NULL, NULL, NULL, NULL, 0}
 };
 
@@ -959,7 +1213,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
               nb_tests, nb_errors, nb_leaks);
     }
     xmlCleanupParser();
-    xmlMemoryDump();
 
     return(ret);
 }
index f462ebf..461f4a5 100644 (file)
--- a/threads.c
+++ b/threads.c
 #include <stdlib.h>
 
 #include <libxml/threads.h>
-#include <libxml/globals.h>
-
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#elif defined HAVE_WIN32_THREADS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#ifndef HAVE_COMPILER_TLS
-#include <process.h>
+#include <libxml/parser.h>
+#ifdef LIBXML_CATALOG_ENABLED
+#include <libxml/catalog.h>
 #endif
-#endif
-
-#ifdef HAVE_BEOS_THREADS
-#include <OS.h>
-#include <TLS.h>
+#ifdef LIBXML_SCHEMAS_ENABLED
+#include <libxml/xmlschemastypes.h>
+#include <libxml/relaxng.h>
 #endif
 
 #if defined(SOLARIS)
 #include <note.h>
 #endif
 
-/* #define DEBUG_THREADS */
+#include "private/dict.h"
+#include "private/enc.h"
+#include "private/globals.h"
+#include "private/memory.h"
+#include "private/threads.h"
+#include "private/xpath.h"
 
-#ifdef HAVE_PTHREAD_H
+#if defined(HAVE_POSIX_THREADS) && \
+    defined(__GLIBC__) && \
+    __GLIBC__ * 100 + __GLIBC_MINOR__ >= 234
 
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 303) && \
-    defined(__GLIBC__) && defined(__linux__)
+/*
+ * The modern way available since glibc 2.32.
+ *
+ * The check above is for glibc 2.34 which merged the pthread symbols into
+ * libc. Since we still allow linking without pthread symbols (see below),
+ * this only works if pthread symbols are guaranteed to be available.
+ */
 
-static int libxml_is_threaded = -1;
+#include <sys/single_threaded.h>
 
-#define XML_PTHREAD_WEAK
+#define XML_IS_THREADED() (!__libc_single_threaded)
+#define XML_IS_NEVER_THREADED() 0
+
+#elif defined(HAVE_POSIX_THREADS) && \
+      defined(__GLIBC__) && \
+      defined(__GNUC__)
+
+/*
+ * The traditional way to check for single-threaded applications with
+ * glibc was to check whether the separate libpthread library is
+ * linked in. This works by not linking libxml2 with libpthread (see
+ * BASE_THREAD_LIBS in configure.ac and Makefile.am) and declaring
+ * pthread functions as weak symbols.
+ *
+ * In glibc 2.34, the pthread symbols were moved from libpthread to libc,
+ * so this doesn't work anymore.
+ *
+ * At some point, this legacy code and the BASE_THREAD_LIBS hack in
+ * configure.ac can probably be removed.
+ */
 
-#pragma weak pthread_once
-#pragma weak pthread_getspecific
-#pragma weak pthread_setspecific
-#pragma weak pthread_key_create
-#pragma weak pthread_key_delete
 #pragma weak pthread_mutex_init
 #pragma weak pthread_mutex_destroy
 #pragma weak pthread_mutex_lock
@@ -60,17 +78,20 @@ static int libxml_is_threaded = -1;
 #pragma weak pthread_cond_wait
 #pragma weak pthread_equal
 #pragma weak pthread_self
-#pragma weak pthread_key_create
-#pragma weak pthread_key_delete
 #pragma weak pthread_cond_signal
 
-#else /* __GNUC__, __GLIBC__, __linux__ */
+#define XML_PTHREAD_WEAK
+#define XML_IS_THREADED() libxml_is_threaded
+#define XML_IS_NEVER_THREADED() (!libxml_is_threaded)
+
+static int libxml_is_threaded = -1;
 
-static int libxml_is_threaded = 1;
+#else /* other POSIX platforms */
 
-#endif /* __GNUC__, __GLIBC__, __linux__ */
+#define XML_IS_THREADED() 1
+#define XML_IS_NEVER_THREADED() 0
 
-#endif /* HAVE_PTHREAD_H */
+#endif
 
 /*
  * TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
@@ -79,26 +100,10 @@ static int libxml_is_threaded = 1;
  */
 
 /*
- * xmlMutex are a simple mutual exception locks
- */
-struct _xmlMutex {
-#ifdef HAVE_PTHREAD_H
-    pthread_mutex_t lock;
-#elif defined HAVE_WIN32_THREADS
-    CRITICAL_SECTION cs;
-#elif defined HAVE_BEOS_THREADS
-    sem_id sem;
-    thread_id tid;
-#else
-    int empty;
-#endif
-};
-
-/*
  * xmlRMutex are reentrant mutual exception locks
  */
 struct _xmlRMutex {
-#ifdef HAVE_PTHREAD_H
+#ifdef HAVE_POSIX_THREADS
     pthread_mutex_t lock;
     unsigned int held;
     unsigned int waiters;
@@ -106,55 +111,31 @@ struct _xmlRMutex {
     pthread_cond_t cv;
 #elif defined HAVE_WIN32_THREADS
     CRITICAL_SECTION cs;
-#elif defined HAVE_BEOS_THREADS
-    xmlMutexPtr lock;
-    thread_id tid;
-    int32 count;
 #else
     int empty;
 #endif
 };
 
-/*
- * This module still has some internal static data.
- *   - xmlLibraryLock a global lock
- *   - globalkey used for per-thread data
- */
-
-#ifdef HAVE_PTHREAD_H
-static pthread_key_t globalkey;
-static pthread_t mainthread;
-static pthread_once_t once_control = PTHREAD_ONCE_INIT;
-static pthread_once_t once_control_init = PTHREAD_ONCE_INIT;
-static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
-#elif defined HAVE_WIN32_THREADS
-#if defined(HAVE_COMPILER_TLS)
-static __declspec(thread) xmlGlobalState tlstate;
-static __declspec(thread) int tlstate_inited = 0;
-#else /* HAVE_COMPILER_TLS */
-static DWORD globalkey = TLS_OUT_OF_INDEXES;
-#endif /* HAVE_COMPILER_TLS */
-static DWORD mainthread;
-static struct {
-    DWORD done;
-    LONG control;
-} run_once = { 0, 0};
-static volatile LPCRITICAL_SECTION global_init_lock = NULL;
-
-/* endif HAVE_WIN32_THREADS */
-#elif defined HAVE_BEOS_THREADS
-int32 globalkey = 0;
-thread_id mainthread = 0;
-int32 run_once_init = 0;
-static int32 global_init_lock = -1;
-static vint32 global_init_count = 0;
-#endif
-
 static xmlRMutexPtr xmlLibraryLock = NULL;
 
-#ifdef LIBXML_THREAD_ENABLED
-static void xmlOnceInit(void);
+/**
+ * xmlInitMutex:
+ * @mutex:  the mutex
+ *
+ * Initialize a mutex.
+ */
+void
+xmlInitMutex(xmlMutexPtr mutex)
+{
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_NEVER_THREADED() == 0)
+        pthread_mutex_init(&mutex->lock, NULL);
+#elif defined HAVE_WIN32_THREADS
+    InitializeCriticalSection(&mutex->cs);
+#else
+    (void) mutex;
 #endif
+}
 
 /**
  * xmlNewMutex:
@@ -171,27 +152,34 @@ xmlNewMutex(void)
 
     if ((tok = malloc(sizeof(xmlMutex))) == NULL)
         return (NULL);
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0)
-        pthread_mutex_init(&tok->lock, NULL);
+    xmlInitMutex(tok);
+    return (tok);
+}
+
+/**
+ * xmlCleanupMutex:
+ * @mutex:  the simple mutex
+ *
+ * Reclaim resources associated with a mutex.
+ */
+void
+xmlCleanupMutex(xmlMutexPtr mutex)
+{
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_NEVER_THREADED() == 0)
+        pthread_mutex_destroy(&mutex->lock);
 #elif defined HAVE_WIN32_THREADS
-    InitializeCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
-        free(tok);
-        return NULL;
-    }
-    tok->tid = -1;
+    DeleteCriticalSection(&mutex->cs);
+#else
+    (void) mutex;
 #endif
-    return (tok);
 }
 
 /**
  * xmlFreeMutex:
  * @tok:  the simple mutex
  *
- * xmlFreeMutex() is used to reclaim resources associated with a libxml2 token
- * struct.
+ * Free a mutex.
  */
 void
 xmlFreeMutex(xmlMutexPtr tok)
@@ -199,14 +187,7 @@ xmlFreeMutex(xmlMutexPtr tok)
     if (tok == NULL)
         return;
 
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0)
-        pthread_mutex_destroy(&tok->lock);
-#elif defined HAVE_WIN32_THREADS
-    DeleteCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    delete_sem(tok->sem);
-#endif
+    xmlCleanupMutex(tok);
     free(tok);
 }
 
@@ -221,19 +202,15 @@ xmlMutexLock(xmlMutexPtr tok)
 {
     if (tok == NULL)
         return;
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0)
+#ifdef HAVE_POSIX_THREADS
+    /*
+     * This assumes that __libc_single_threaded won't change while the
+     * lock is held.
+     */
+    if (XML_IS_THREADED() != 0)
         pthread_mutex_lock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (acquire_sem(tok->sem) != B_NO_ERROR) {
-#ifdef DEBUG_THREADS
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlMutexLock():BeOS:Couldn't acquire semaphore\n");
-#endif
-    }
-    tok->tid = find_thread(NULL);
 #endif
 
 }
@@ -249,16 +226,11 @@ xmlMutexUnlock(xmlMutexPtr tok)
 {
     if (tok == NULL)
         return;
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0)
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_THREADED() != 0)
         pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     LeaveCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (tok->tid == find_thread(NULL)) {
-        tok->tid = -1;
-        release_sem(tok->sem);
-    }
 #endif
 }
 
@@ -279,8 +251,8 @@ xmlNewRMutex(void)
 
     if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
         return (NULL);
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0) {
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_NEVER_THREADED() == 0) {
         pthread_mutex_init(&tok->lock, NULL);
         tok->held = 0;
         tok->waiters = 0;
@@ -288,12 +260,6 @@ xmlNewRMutex(void)
     }
 #elif defined HAVE_WIN32_THREADS
     InitializeCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if ((tok->lock = xmlNewMutex()) == NULL) {
-        free(tok);
-        return NULL;
-    }
-    tok->count = 0;
 #endif
     return (tok);
 }
@@ -310,15 +276,13 @@ xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
 {
     if (tok == NULL)
         return;
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0) {
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_NEVER_THREADED() == 0) {
         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);
 #endif
     free(tok);
 }
@@ -334,8 +298,8 @@ xmlRMutexLock(xmlRMutexPtr tok)
 {
     if (tok == NULL)
         return;
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded == 0)
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_THREADED() == 0)
         return;
 
     pthread_mutex_lock(&tok->lock);
@@ -356,14 +320,6 @@ xmlRMutexLock(xmlRMutexPtr tok)
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (tok->lock->tid == find_thread(NULL)) {
-        tok->count++;
-        return;
-    } else {
-        xmlMutexLock(tok->lock);
-        tok->count = 1;
-    }
 #endif
 }
 
@@ -378,8 +334,8 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
 {
     if (tok == NULL)
         return;
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded == 0)
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_THREADED() == 0)
         return;
 
     pthread_mutex_lock(&tok->lock);
@@ -392,342 +348,6 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     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;
-    }
-#endif
-}
-
-/**
- * xmlGlobalInitMutexLock
- *
- * Makes sure that the global initialization mutex is initialized and
- * locks it.
- */
-void
-__xmlGlobalInitMutexLock(void)
-{
-    /* Make sure the global init lock is initialized and then lock it. */
-#ifdef HAVE_PTHREAD_H
-    /* The mutex is statically initialized, so we just lock it. */
-#ifdef XML_PTHREAD_WEAK
-    if (pthread_mutex_lock == NULL)
-        return;
-#endif /* XML_PTHREAD_WEAK */
-    pthread_mutex_lock(&global_init_lock);
-#elif defined HAVE_WIN32_THREADS
-    LPCRITICAL_SECTION cs;
-
-    /* Create a new critical section */
-    if (global_init_lock == NULL) {
-        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 */
-#ifdef InterlockedCompareExchangePointer
-        InterlockedCompareExchangePointer((void **) &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);
-        }
-    }
-
-    /* Lock the chosen critical section */
-    EnterCriticalSection(global_init_lock);
-#elif defined HAVE_BEOS_THREADS
-    int32 sem;
-
-    /* Allocate a new semaphore */
-    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 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);
-
-    /* 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");
-#endif
-    }
-#endif
-}
-
-void
-__xmlGlobalInitMutexUnlock(void)
-{
-#ifdef HAVE_PTHREAD_H
-#ifdef XML_PTHREAD_WEAK
-    if (pthread_mutex_unlock == NULL)
-        return;
-#endif /* XML_PTHREAD_WEAK */
-    pthread_mutex_unlock(&global_init_lock);
-#elif defined HAVE_WIN32_THREADS
-    if (global_init_lock != NULL) {
-       LeaveCriticalSection(global_init_lock);
-    }
-#elif defined HAVE_BEOS_THREADS
-    release_sem(global_init_lock);
-#endif
-}
-
-/**
- * xmlGlobalInitMutexDestroy
- *
- * Makes sure that the global initialization mutex is destroyed before
- * application termination.
- */
-void
-__xmlGlobalInitMutexDestroy(void)
-{
-#ifdef HAVE_PTHREAD_H
-#elif defined HAVE_WIN32_THREADS
-    if (global_init_lock != NULL) {
-        DeleteCriticalSection(global_init_lock);
-        free(global_init_lock);
-        global_init_lock = NULL;
-    }
-#endif
-}
-
-/************************************************************************
- *                                                                     *
- *                     Per thread global state handling                *
- *                                                                     *
- ************************************************************************/
-
-#ifdef LIBXML_THREAD_ENABLED
-#ifdef xmlLastError
-#undef xmlLastError
-#endif
-
-/**
- * xmlFreeGlobalState:
- * @state:  a thread global state
- *
- * xmlFreeGlobalState() is called when a thread terminates with a non-NULL
- * global state. It is is used here to reclaim memory resources.
- */
-static void
-xmlFreeGlobalState(void *state)
-{
-    xmlGlobalState *gs = (xmlGlobalState *) state;
-
-    /* free any memory allocated in the thread's xmlLastError */
-    xmlResetError(&(gs->xmlLastError));
-    free(state);
-}
-
-/**
- * xmlNewGlobalState:
- *
- * xmlNewGlobalState() allocates a global state. This structure is used to
- * hold all data for use by a thread when supporting backwards compatibility
- * of libxml2 to pre-thread-safe behaviour.
- *
- * Returns the newly allocated xmlGlobalStatePtr or NULL in case of error
- */
-static xmlGlobalStatePtr
-xmlNewGlobalState(void)
-{
-    xmlGlobalState *gs;
-
-    gs = malloc(sizeof(xmlGlobalState));
-    if (gs == NULL) {
-       xmlGenericError(xmlGenericErrorContext,
-                       "xmlGetGlobalState: out of memory\n");
-        return (NULL);
-    }
-
-    memset(gs, 0, sizeof(xmlGlobalState));
-    xmlInitializeGlobalState(gs);
-    return (gs);
-}
-#endif /* LIBXML_THREAD_ENABLED */
-
-#ifdef HAVE_PTHREAD_H
-#elif defined HAVE_WIN32_THREADS
-#if !defined(HAVE_COMPILER_TLS)
-#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
-typedef struct _xmlGlobalStateCleanupHelperParams {
-    HANDLE thread;
-    void *memory;
-} xmlGlobalStateCleanupHelperParams;
-
-static void XMLCDECL
-xmlGlobalStateCleanupHelper(void *p)
-{
-    xmlGlobalStateCleanupHelperParams *params =
-        (xmlGlobalStateCleanupHelperParams *) p;
-    WaitForSingleObject(params->thread, INFINITE);
-    CloseHandle(params->thread);
-    xmlFreeGlobalState(params->memory);
-    free(params);
-    _endthread();
-}
-#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
-
-typedef struct _xmlGlobalStateCleanupHelperParams {
-    void *memory;
-    struct _xmlGlobalStateCleanupHelperParams *prev;
-    struct _xmlGlobalStateCleanupHelperParams *next;
-} xmlGlobalStateCleanupHelperParams;
-
-static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
-static CRITICAL_SECTION cleanup_helpers_cs;
-
-#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
-#endif /* HAVE_COMPILER_TLS */
-#endif /* HAVE_WIN32_THREADS */
-
-#if defined HAVE_BEOS_THREADS
-
-/**
- * xmlGlobalStateCleanup:
- * @data: unused parameter
- *
- * Used for Beos only
- */
-void
-xmlGlobalStateCleanup(void *data)
-{
-    void *globalval = tls_get(globalkey);
-
-    if (globalval != NULL)
-        xmlFreeGlobalState(globalval);
-}
-#endif
-
-/**
- * xmlGetGlobalState:
- *
- * xmlGetGlobalState() is called to retrieve the global state for a thread.
- *
- * Returns the thread global state or NULL in case of error
- */
-xmlGlobalStatePtr
-xmlGetGlobalState(void)
-{
-#ifdef HAVE_PTHREAD_H
-    xmlGlobalState *globalval;
-
-    if (libxml_is_threaded == 0)
-        return (NULL);
-
-    pthread_once(&once_control, xmlOnceInit);
-
-    if ((globalval = (xmlGlobalState *)
-         pthread_getspecific(globalkey)) == NULL) {
-        xmlGlobalState *tsd = xmlNewGlobalState();
-       if (tsd == NULL)
-           return(NULL);
-
-        pthread_setspecific(globalkey, tsd);
-        return (tsd);
-    }
-    return (globalval);
-#elif defined HAVE_WIN32_THREADS
-#if defined(HAVE_COMPILER_TLS)
-    if (!tlstate_inited) {
-        tlstate_inited = 1;
-        xmlInitializeGlobalState(&tlstate);
-    }
-    return &tlstate;
-#else /* HAVE_COMPILER_TLS */
-    xmlGlobalState *globalval;
-    xmlGlobalStateCleanupHelperParams *p;
-
-    xmlOnceInit();
-#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
-    globalval = (xmlGlobalState *) TlsGetValue(globalkey);
-#else
-    p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
-    globalval = (xmlGlobalState *) (p ? p->memory : NULL);
-#endif
-    if (globalval == NULL) {
-        xmlGlobalState *tsd = xmlNewGlobalState();
-
-        if (tsd == NULL)
-           return(NULL);
-        p = (xmlGlobalStateCleanupHelperParams *)
-            malloc(sizeof(xmlGlobalStateCleanupHelperParams));
-       if (p == NULL) {
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlGetGlobalState: out of memory\n");
-            xmlFreeGlobalState(tsd);
-           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);
-#else
-        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);
-#endif
-
-        return (tsd);
-    }
-    return (globalval);
-#endif /* HAVE_COMPILER_TLS */
-#elif defined HAVE_BEOS_THREADS
-    xmlGlobalState *globalval;
-
-    xmlOnceInit();
-
-    if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) {
-        xmlGlobalState *tsd = xmlNewGlobalState();
-       if (tsd == NULL)
-           return (NULL);
-
-        tls_set(globalkey, tsd);
-        on_exit_thread(xmlGlobalStateCleanup, NULL);
-        return (tsd);
-    }
-    return (globalval);
-#else
-    return (NULL);
 #endif
 }
 
@@ -740,6 +360,8 @@ xmlGetGlobalState(void)
 /**
  * xmlGetThreadId:
  *
+ * DEPRECATED: Internal function, do not use.
+ *
  * xmlGetThreadId() find the current thread ID number
  * Note that this is likely to be broken on some platforms using pthreads
  * as the specification doesn't mandate pthread_t to be an integer type
@@ -749,11 +371,11 @@ xmlGetGlobalState(void)
 int
 xmlGetThreadId(void)
 {
-#ifdef HAVE_PTHREAD_H
+#ifdef HAVE_POSIX_THREADS
     pthread_t id;
     int ret;
 
-    if (libxml_is_threaded == 0)
+    if (XML_IS_THREADED() == 0)
         return (0);
     id = pthread_self();
     /* horrible but preserves compat, see warning above */
@@ -761,50 +383,12 @@ xmlGetThreadId(void)
     return (ret);
 #elif defined HAVE_WIN32_THREADS
     return GetCurrentThreadId();
-#elif defined HAVE_BEOS_THREADS
-    return find_thread(NULL);
 #else
     return ((int) 0);
 #endif
 }
 
 /**
- * xmlIsMainThread:
- *
- * xmlIsMainThread() check whether the current thread is the main thread.
- *
- * Returns 1 if the current thread is the main thread, 0 otherwise
- */
-int
-xmlIsMainThread(void)
-{
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded == -1)
-        xmlInitThreads();
-    if (libxml_is_threaded == 0)
-        return (1);
-    pthread_once(&once_control, xmlOnceInit);
-#elif defined HAVE_WIN32_THREADS
-    xmlOnceInit();
-#elif defined HAVE_BEOS_THREADS
-    xmlOnceInit();
-#endif
-
-#ifdef DEBUG_THREADS
-    xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
-#endif
-#ifdef HAVE_PTHREAD_H
-    return (pthread_equal(mainthread,pthread_self()));
-#elif defined HAVE_WIN32_THREADS
-    return (mainthread == GetCurrentThreadId());
-#elif defined HAVE_BEOS_THREADS
-    return (mainthread == find_thread(NULL));
-#else
-    return (1);
-#endif
-}
-
-/**
  * xmlLockLibrary:
  *
  * xmlLockLibrary() is used to take out a re-entrant lock on the libxml2
@@ -813,9 +397,6 @@ xmlIsMainThread(void)
 void
 xmlLockLibrary(void)
 {
-#ifdef DEBUG_THREADS
-    xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n");
-#endif
     xmlRMutexLock(xmlLibraryLock);
 }
 
@@ -828,32 +409,67 @@ xmlLockLibrary(void)
 void
 xmlUnlockLibrary(void)
 {
-#ifdef DEBUG_THREADS
-    xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n");
-#endif
     xmlRMutexUnlock(xmlLibraryLock);
 }
 
 /**
  * xmlInitThreads:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
- *
- * xmlInitThreads() is used to to initialize all the thread related
- * data of the libxml2 library.
+ * DEPRECATED: Alias for xmlInitParser.
  */
 void
 xmlInitThreads(void)
 {
-#ifdef HAVE_PTHREAD_H
+    xmlInitParser();
+}
+
+/**
+ * xmlCleanupThreads:
+ *
+ * DEPRECATED: This function is a no-op. Call xmlCleanupParser
+ * to free global state but see the warnings there. xmlCleanupParser
+ * should be only called once at program exit. In most cases, you don't
+ * have call cleanup functions at all.
+ */
+void
+xmlCleanupThreads(void)
+{
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Library wide initialization                     *
+ *                                                                     *
+ ************************************************************************/
+
+static int xmlParserInitialized = 0;
+static int xmlParserInnerInitialized = 0;
+
+
+#ifdef HAVE_POSIX_THREADS
+static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
+#elif defined HAVE_WIN32_THREADS
+static volatile LPCRITICAL_SECTION global_init_lock = NULL;
+#endif
+
+/**
+ * xmlGlobalInitMutexLock
+ *
+ * Makes sure that the global initialization mutex is initialized and
+ * locks it.
+ */
+static void
+xmlGlobalInitMutexLock(void) {
+#ifdef HAVE_POSIX_THREADS
+
 #ifdef XML_PTHREAD_WEAK
-    if (libxml_is_threaded == -1) {
-        if ((pthread_once != NULL) &&
-            (pthread_getspecific != NULL) &&
-            (pthread_setspecific != NULL) &&
-            (pthread_key_create != NULL) &&
-            (pthread_key_delete != NULL) &&
+    /*
+     * This is somewhat unreliable since libpthread could be loaded
+     * later with dlopen() and threads could be created. But it's
+     * long-standing behavior and hard to work around.
+     */
+    if (libxml_is_threaded == -1)
+        libxml_is_threaded =
             (pthread_mutex_init != NULL) &&
             (pthread_mutex_destroy != NULL) &&
             (pthread_mutex_lock != NULL) &&
@@ -861,32 +477,146 @@ xmlInitThreads(void)
             (pthread_cond_init != NULL) &&
             (pthread_cond_destroy != NULL) &&
             (pthread_cond_wait != NULL) &&
-            (pthread_equal != NULL) &&
+            /*
+             * pthread_equal can be inline, resuting in -Waddress warnings.
+             * Let's assume it's available if all the other functions are.
+             */
+            /* (pthread_equal != NULL) && */
             (pthread_self != NULL) &&
-            (pthread_cond_signal != NULL)) {
-            libxml_is_threaded = 1;
+            (pthread_cond_signal != NULL);
+#endif
 
-/* fprintf(stderr, "Running multithreaded\n"); */
-        } else {
+    /* The mutex is statically initialized, so we just lock it. */
+    if (XML_IS_THREADED() != 0)
+        pthread_mutex_lock(&global_init_lock);
 
-/* fprintf(stderr, "Running without multithread\n"); */
-            libxml_is_threaded = 0;
+#elif defined HAVE_WIN32_THREADS
+
+    LPCRITICAL_SECTION cs;
+
+    /* Create a new critical section */
+    if (global_init_lock == NULL) {
+        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 */
+#ifdef InterlockedCompareExchangePointer
+        InterlockedCompareExchangePointer((void **) &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);
         }
     }
-#endif /* XML_PTHREAD_WEAK */
+
+    /* Lock the chosen critical section */
+    EnterCriticalSection(global_init_lock);
+
+#endif
+}
+
+static void
+xmlGlobalInitMutexUnlock(void) {
+#ifdef HAVE_POSIX_THREADS
+    if (XML_IS_THREADED() != 0)
+        pthread_mutex_unlock(&global_init_lock);
+#elif defined HAVE_WIN32_THREADS
+    if (global_init_lock != NULL)
+       LeaveCriticalSection(global_init_lock);
 #endif
 }
 
 /**
- * xmlCleanupThreads:
+ * xmlGlobalInitMutexDestroy
  *
- * DEPRECATED: This function will be made private. Call xmlCleanupParser
- * to free global state but see the warnings there. xmlCleanupParser
- * should be only called once at program exit. In most cases, you don't
- * have call cleanup functions at all.
+ * Makes sure that the global initialization mutex is destroyed before
+ * application termination.
+ */
+static void
+xmlGlobalInitMutexDestroy(void) {
+#ifdef HAVE_POSIX_THREADS
+#elif defined HAVE_WIN32_THREADS
+    if (global_init_lock != NULL) {
+        DeleteCriticalSection(global_init_lock);
+        free(global_init_lock);
+        global_init_lock = NULL;
+    }
+#endif
+}
+
+/**
+ * xmlInitParser:
  *
- * xmlCleanupThreads() is used to to cleanup all the thread related
- * data of the libxml2 library once processing has ended.
+ * Initialization function for the XML parser.
+ *
+ * Call once from the main thread before using the library in
+ * multithreaded programs.
+ */
+void
+xmlInitParser(void) {
+    /*
+     * Note that the initialization code must not make memory allocations.
+     */
+    if (xmlParserInitialized != 0)
+        return;
+
+    xmlGlobalInitMutexLock();
+
+    if (xmlParserInnerInitialized == 0) {
+#if defined(_WIN32) && \
+    !defined(LIBXML_THREAD_ALLOC_ENABLED) && \
+    (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+        if (xmlFree == free)
+            atexit(xmlCleanupParser);
+#endif
+
+        xmlInitMemoryInternal(); /* Should come second */
+        xmlInitGlobalsInternal();
+        xmlInitRandom();
+        xmlInitDictInternal();
+        xmlInitEncodingInternal();
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+        xmlInitXPathInternal();
+#endif
+
+        xmlRegisterDefaultInputCallbacks();
+#ifdef LIBXML_OUTPUT_ENABLED
+        xmlRegisterDefaultOutputCallbacks();
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+        xmlParserInnerInitialized = 1;
+    }
+
+    xmlGlobalInitMutexUnlock();
+
+    xmlParserInitialized = 1;
+}
+
+/**
+ * xmlCleanupParser:
+ *
+ * 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.
  *
  * WARNING: if your application is multithreaded or has plugin support
  *          calling this may crash the application if another thread or
@@ -897,153 +627,56 @@ xmlInitThreads(void)
  *          to avoid leak reports from valgrind !
  */
 void
-xmlCleanupThreads(void)
-{
-#ifdef DEBUG_THREADS
-    xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n");
-#endif
-#ifdef HAVE_PTHREAD_H
-    if (libxml_is_threaded != 0)
-        pthread_key_delete(globalkey);
-    once_control = once_control_init;
-#elif defined(HAVE_WIN32_THREADS)
-#if !defined(HAVE_COMPILER_TLS)
-    if (globalkey != TLS_OUT_OF_INDEXES) {
-#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
-        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);
-#endif
-        TlsFree(globalkey);
-        globalkey = TLS_OUT_OF_INDEXES;
-    }
-#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
-    DeleteCriticalSection(&cleanup_helpers_cs);
-#endif
-#endif
-    run_once.done = 0;
-    run_once.control = 0;
-#endif
-}
+xmlCleanupParser(void) {
+    if (!xmlParserInitialized)
+        return;
 
-#ifdef LIBXML_THREAD_ENABLED
+    /* These functions can call xmlFree. */
 
-/**
- * xmlOnceInit
- *
- * xmlOnceInit() is used to initialize the value of mainthread for use
- * in other routines. This function should only be called using
- * pthread_once() in association with the once_control variable to ensure
- * that the function is only called once. See man pthread_once for more
- * details.
- */
-static void
-xmlOnceInit(void)
-{
-#ifdef HAVE_PTHREAD_H
-    (void) pthread_key_create(&globalkey, xmlFreeGlobalState);
-    mainthread = pthread_self();
-    __xmlInitializeDict();
-#elif defined(HAVE_WIN32_THREADS)
-    if (!run_once.done) {
-        if (InterlockedIncrement(&run_once.control) == 1) {
-#if !defined(HAVE_COMPILER_TLS)
-#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
-            InitializeCriticalSection(&cleanup_helpers_cs);
+    xmlCleanupCharEncodingHandlers();
+#ifdef LIBXML_CATALOG_ENABLED
+    xmlCatalogCleanup();
 #endif
-            globalkey = TlsAlloc();
+#ifdef LIBXML_SCHEMAS_ENABLED
+    xmlSchemaCleanupTypes();
+    xmlRelaxNGCleanupTypes();
 #endif
-            mainthread = GetCurrentThreadId();
-           __xmlInitializeDict();
-            run_once.done = 1;
-        } else {
-            /* Another thread is working; give up our slice and
-             * wait until they're done. */
-            while (!run_once.done)
-                Sleep(0);
-        }
-    }
-#elif defined HAVE_BEOS_THREADS
-    if (atomic_add(&run_once_init, 1) == 0) {
-        globalkey = tls_allocate();
-        tls_set(globalkey, NULL);
-        mainthread = find_thread(NULL);
-       __xmlInitializeDict();
-    } else
-        atomic_add(&run_once_init, -1);
+
+    /* These functions should never call xmlFree. */
+
+    xmlCleanupInputCallbacks();
+#ifdef LIBXML_OUTPUT_ENABLED
+    xmlCleanupOutputCallbacks();
 #endif
+
+    xmlCleanupDictInternal();
+    xmlCleanupRandom();
+    xmlCleanupGlobalsInternal();
+    /*
+     * Must come last. On Windows, xmlCleanupGlobalsInternal can call
+     * xmlFree which uses xmlMemMutex in debug mode.
+     */
+    xmlCleanupMemoryInternal();
+
+    xmlGlobalInitMutexDestroy();
+
+    xmlParserInitialized = 0;
+    xmlParserInnerInitialized = 0;
 }
-#endif
 
-/**
- * DllMain:
- * @hinstDLL: handle to DLL instance
- * @fdwReason: Reason code for entry
- * @lpvReserved: generic pointer (depends upon reason code)
- *
- * Entry point for Windows library. It is being used to free thread-specific
- * storage.
- *
- * Returns TRUE always
- */
-#ifdef HAVE_PTHREAD_H
-#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
-#if defined(LIBXML_STATIC_FOR_DLL)
-int XMLCALL
-xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason,
-           ATTRIBUTE_UNUSED void *lpvReserved)
-#else
-/* declare to avoid "no previous prototype for 'DllMain'" warning */
-/* Note that we do NOT want to include this function declaration in
-   a public header because it's meant to be called by Windows itself,
-   not a program that uses this library.  This also has to be exported. */
-
-XMLPUBFUN BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-         DWORD     fdwReason,
-         LPVOID    lpvReserved);
-
-BOOL WINAPI
-DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
-        ATTRIBUTE_UNUSED 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);
-                }
-                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;
-    }
-    return TRUE;
+#if defined(HAVE_ATTRIBUTE_DESTRUCTOR) && \
+    !defined(LIBXML_THREAD_ALLOC_ENABLED) && \
+    !defined(LIBXML_STATIC) && \
+    !defined(_WIN32)
+static void
+ATTRIBUTE_DESTRUCTOR
+xmlDestructor(void) {
+    /*
+     * Calling custom deallocation functions in a destructor can cause
+     * problems, for example with Nokogiri.
+     */
+    if (xmlFree == free)
+        xmlCleanupParser();
 }
 #endif
+
diff --git a/tree.c b/tree.c
index 4c9f00d..dc3ac4f 100644 (file)
--- a/tree.c
+++ b/tree.c
 #include <zlib.h>
 #endif
 
-#include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
+#include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/uri.h>
 #include <libxml/entities.h>
-#include <libxml/valid.h>
 #include <libxml/xmlerror.h>
 #include <libxml/parserInternals.h>
-#include <libxml/globals.h>
 #ifdef LIBXML_HTML_ENABLED
 #include <libxml/HTMLtree.h>
 #endif
 #include <libxml/debugXML.h>
 #endif
 
-#include "buf.h"
-#include "save.h"
+#include "private/buf.h"
+#include "private/entities.h"
+#include "private/error.h"
+#include "private/tree.h"
 
 int __xmlRegisterCallbacks = 0;
 
@@ -140,9 +140,6 @@ static int xmlCheckDTD = 1;
 #define IS_STR_XML(str) ((str != NULL) && (str[0] == 'x') && \
   (str[1] == 'm') && (str[2] == 'l') && (str[3] == 0))
 
-/* #define DEBUG_BUFFER */
-/* #define DEBUG_TREE */
-
 /************************************************************************
  *                                                                     *
  *             Functions to move to entities.c once the                *
@@ -355,7 +352,6 @@ xmlSplitQName3(const xmlChar *name, int *len) {
 
 #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 /**
  * xmlValidateNCName:
  * @value: the value to check
@@ -427,7 +423,6 @@ try_complex:
 
     return(0);
 }
-#endif
 
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
 /**
@@ -803,10 +798,6 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
 void
 xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
     if (node == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlSetNs: node == NULL\n");
-#endif
        return;
     }
     if ((node->type == XML_ELEMENT_NODE) ||
@@ -823,10 +814,6 @@ xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
 void
 xmlFreeNs(xmlNsPtr cur) {
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlFreeNs : ns == NULL\n");
-#endif
        return;
     }
     if (cur->href != NULL) xmlFree((char *) cur->href);
@@ -844,10 +831,6 @@ void
 xmlFreeNsList(xmlNsPtr cur) {
     xmlNsPtr next;
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlFreeNsList : ns == NULL\n");
-#endif
        return;
     }
     while (cur != NULL) {
@@ -875,12 +858,6 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
     xmlDtdPtr cur;
 
     if ((doc != NULL) && (doc->extSubset != NULL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewDtd(%s): document %s already have a DTD %s\n",
-           /* !!! */ (char *) name, doc->name,
-           /* !!! */ (char *)doc->extSubset->name);
-#endif
        return(NULL);
     }
 
@@ -949,12 +926,6 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
     xmlDtdPtr cur;
 
     if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-
-     "xmlCreateIntSubset(): document %s already have an internal subset\n",
-           doc->name);
-#endif
        return(NULL);
     }
 
@@ -1208,17 +1179,8 @@ xmlFreeDoc(xmlDocPtr cur) {
     xmlDictPtr dict = NULL;
 
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlFreeDoc : document == NULL\n");
-#endif
        return;
     }
-#ifdef LIBXML_DEBUG_RUNTIME
-#ifdef LIBXML_DEBUG_ENABLED
-    xmlDebugCheckDocument(stderr, cur);
-#endif
-#endif
 
     if (cur != NULL) dict = cur->dict;
 
@@ -1414,14 +1376,21 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
                            if (val != NULL) xmlFree(val);
                            goto out;
                        }
-                       else if ((ent != NULL) && (ent->children == NULL)) {
+                       else if ((ent != NULL) &&
+                                 ((ent->flags & XML_ENT_PARSED) == 0) &&
+                                 ((ent->flags & XML_ENT_EXPANDING) == 0)) {
                            xmlNodePtr temp;
 
-                            /* Set to non-NULL value to avoid recursion. */
-                           ent->children = (xmlNodePtr) -1;
+                            /*
+                             * The entity should have been checked already,
+                             * but set the flag anyway to avoid recursion.
+                             */
+                           ent->flags |= XML_ENT_EXPANDING;
                            ent->children = xmlStringGetNodeList(doc,
                                    (const xmlChar*)node->content);
                            ent->owner = 1;
+                           ent->flags &= ~XML_ENT_EXPANDING;
+                            ent->flags |= XML_ENT_PARSED;
                            temp = ent->children;
                            while (temp) {
                                temp->parent = (xmlNodePtr)ent;
@@ -1493,9 +1462,9 @@ out:
  */
 xmlNodePtr
 xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
-    xmlNodePtr ret = NULL, last = NULL;
+    xmlNodePtr ret = NULL, head = NULL, last = NULL;
     xmlNodePtr node;
-    xmlChar *val;
+    xmlChar *val = NULL;
     const xmlChar *cur = value;
     const xmlChar *q;
     xmlEntityPtr ent;
@@ -1593,14 +1562,12 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
                         */
                        if (!xmlBufIsEmpty(buf)) {
                            node = xmlNewDocText(doc, NULL);
-                           if (node == NULL) {
-                               if (val != NULL) xmlFree(val);
-                               goto out;
-                           }
+                            if (node == NULL)
+                                goto out;
                            node->content = xmlBufDetach(buf);
 
                            if (last == NULL) {
-                               last = ret = node;
+                               last = head = node;
                            } else {
                                last = xmlAddNextSibling(last, node);
                            }
@@ -1610,18 +1577,23 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
                         * Create a new REFERENCE_REF node
                         */
                        node = xmlNewReference(doc, val);
-                       if (node == NULL) {
-                           if (val != NULL) xmlFree(val);
+                       if (node == NULL)
                            goto out;
-                       }
-                       else if ((ent != NULL) && (ent->children == NULL)) {
+                       if ((ent != NULL) &&
+                            ((ent->flags & XML_ENT_PARSED) == 0) &&
+                            ((ent->flags & XML_ENT_EXPANDING) == 0)) {
                            xmlNodePtr temp;
 
-                            /* Set to non-NULL value to avoid recursion. */
-                           ent->children = (xmlNodePtr) -1;
+                            /*
+                             * The entity should have been checked already,
+                             * but set the flag anyway to avoid recursion.
+                             */
+                           ent->flags |= XML_ENT_EXPANDING;
                            ent->children = xmlStringGetNodeList(doc,
                                    (const xmlChar*)node->content);
                            ent->owner = 1;
+                           ent->flags &= ~XML_ENT_EXPANDING;
+                            ent->flags |= XML_ENT_PARSED;
                            temp = ent->children;
                            while (temp) {
                                temp->parent = (xmlNodePtr)ent;
@@ -1630,12 +1602,13 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
                            }
                        }
                        if (last == NULL) {
-                           last = ret = node;
+                           last = head = node;
                        } else {
                            last = xmlAddNextSibling(last, node);
                        }
                    }
                    xmlFree(val);
+                    val = NULL;
                }
                cur++;
                q = cur;
@@ -1654,7 +1627,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
        } else
            cur++;
     }
-    if ((cur != q) || (ret == NULL)) {
+    if ((cur != q) || (head == NULL)) {
         /*
         * Handle the last piece of text.
         */
@@ -1663,21 +1636,24 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
 
     if (!xmlBufIsEmpty(buf)) {
        node = xmlNewDocText(doc, NULL);
-        if (node == NULL) {
-            xmlBufFree(buf);
-            return(NULL);
-        }
+        if (node == NULL)
+            goto out;
        node->content = xmlBufDetach(buf);
 
        if (last == NULL) {
-           ret = node;
+           head = node;
        } else {
            xmlAddNextSibling(last, node);
        }
     }
 
+    ret = head;
+    head = NULL;
+
 out:
     xmlBufFree(buf);
+    if (val != NULL) xmlFree(val);
+    if (head != NULL) xmlFreeNodeList(head);
     return(ret);
 }
 
@@ -1863,7 +1839,7 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
 
     if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) {
         if ((eatname == 1) &&
-           ((node->doc == NULL) ||
+           ((node->doc == NULL) || (node->doc->dict == NULL) ||
             (!(xmlDictOwns(node->doc->dict, name)))))
             xmlFree((xmlChar *) name);
         return (NULL);
@@ -1876,6 +1852,7 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
     if (cur == NULL) {
         if ((eatname == 1) &&
            ((node == NULL) || (node->doc == NULL) ||
+             (node->doc->dict == NULL) ||
             (!(xmlDictOwns(node->doc->dict, name)))))
             xmlFree((xmlChar *) name);
         xmlTreeErrMemory("building attribute");
@@ -1953,10 +1930,6 @@ xmlAttrPtr
 xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewProp : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -1979,10 +1952,6 @@ xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
            const xmlChar *value) {
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewNsProp : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2004,10 +1973,6 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
            const xmlChar *value) {
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewNsPropEatName : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2033,10 +1998,6 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
     xmlAttrPtr cur;
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewDocProp : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2131,17 +2092,9 @@ int
 xmlRemoveProp(xmlAttrPtr cur) {
     xmlAttrPtr tmp;
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlRemoveProp : cur == NULL\n");
-#endif
        return(-1);
     }
     if (cur->parent == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlRemoveProp : cur->parent == NULL\n");
-#endif
        return(-1);
     }
     tmp = cur->parent->properties;
@@ -2162,10 +2115,6 @@ xmlRemoveProp(xmlAttrPtr cur) {
        }
         tmp = tmp->next;
     }
-#ifdef DEBUG_TREE
-    xmlGenericError(xmlGenericErrorContext,
-           "xmlRemoveProp : attribute not owned by its node\n");
-#endif
     return(-1);
 }
 
@@ -2183,10 +2132,6 @@ xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) {
     xmlNodePtr cur;
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewPI : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2248,10 +2193,6 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
     xmlNodePtr cur;
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewNode : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2292,10 +2233,6 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
     xmlNodePtr cur;
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewNode : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2386,8 +2323,9 @@ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
        }
     } else {
         /* if name don't come from the doc dictionary free it here */
-        if ((name != NULL) && (doc != NULL) &&
-           (!(xmlDictOwns(doc->dict, name))))
+        if ((name != NULL) &&
+            ((doc == NULL) || (doc->dict == NULL) ||
+            (!(xmlDictOwns(doc->dict, name)))))
            xmlFree(name);
     }
     return(cur);
@@ -2513,18 +2451,10 @@ xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns,
     xmlNodePtr cur, prev;
 
     if (parent == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewTextChild : parent == NULL\n");
-#endif
        return(NULL);
     }
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewTextChild : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -2948,18 +2878,10 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
     xmlNodePtr cur, prev;
 
     if (parent == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewChild : parent == NULL\n");
-#endif
        return(NULL);
     }
 
     if (name == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewChild : name == NULL\n");
-#endif
        return(NULL);
     }
 
@@ -3076,25 +2998,13 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
 xmlNodePtr
 xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddNextSibling : cur == NULL\n");
-#endif
        return(NULL);
     }
     if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddNextSibling : elem == NULL\n");
-#endif
        return(NULL);
     }
 
     if (cur == elem) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddNextSibling : cur == elem\n");
-#endif
        return(NULL);
     }
 
@@ -3156,25 +3066,13 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
 xmlNodePtr
 xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddPrevSibling : cur == NULL\n");
-#endif
        return(NULL);
     }
     if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddPrevSibling : elem == NULL\n");
-#endif
        return(NULL);
     }
 
     if (cur == elem) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddPrevSibling : cur == elem\n");
-#endif
        return(NULL);
     }
 
@@ -3236,26 +3134,14 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
     xmlNodePtr parent;
 
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddSibling : cur == NULL\n");
-#endif
        return(NULL);
     }
 
     if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddSibling : elem == NULL\n");
-#endif
        return(NULL);
     }
 
     if (cur == elem) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddSibling : cur == elem\n");
-#endif
        return(NULL);
     }
 
@@ -3314,27 +3200,15 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
     xmlNodePtr prev;
 
     if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddChildList : parent == NULL\n");
-#endif
        return(NULL);
     }
 
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddChildList : child == NULL\n");
-#endif
        return(NULL);
     }
 
     if ((cur->doc != NULL) && (parent->doc != NULL) &&
         (cur->doc != parent->doc)) {
-#ifdef DEBUG_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "Elements moved to a different document\n");
-#endif
     }
 
     /*
@@ -3406,26 +3280,14 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
     xmlNodePtr prev;
 
     if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddChild : parent == NULL\n");
-#endif
        return(NULL);
     }
 
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddChild : child == NULL\n");
-#endif
        return(NULL);
     }
 
     if (parent == cur) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlAddChild : parent == cur\n");
-#endif
        return(NULL);
     }
     /*
@@ -3528,10 +3390,6 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
 xmlNodePtr
 xmlGetLastChild(const xmlNode *parent) {
     if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlGetLastChild : parent == NULL\n");
-#endif
        return(NULL);
     }
     return(parent->last);
@@ -3896,10 +3754,6 @@ xmlFreeNode(xmlNodePtr cur) {
 void
 xmlUnlinkNode(xmlNodePtr cur) {
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlUnlinkNode : node == NULL\n");
-#endif
        return;
     }
     if (cur->type == XML_NAMESPACE_DECL)
@@ -3976,10 +3830,6 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
     if (old == cur) return(NULL);
     if ((old == NULL) || (old->type == XML_NAMESPACE_DECL) ||
         (old->parent == NULL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlReplaceNode : old == NULL or without parent\n");
-#endif
        return(NULL);
     }
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
@@ -3990,17 +3840,9 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
        return(old);
     }
     if ((old->type==XML_ATTRIBUTE_NODE) && (cur->type!=XML_ATTRIBUTE_NODE)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlReplaceNode : Trying to replace attribute node with other node type\n");
-#endif
        return(old);
     }
     if ((cur->type==XML_ATTRIBUTE_NODE) && (old->type!=XML_ATTRIBUTE_NODE)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlReplaceNode : Trying to replace a non-attribute node with attribute node\n");
-#endif
        return(old);
     }
     xmlUnlinkNode(cur);
@@ -4053,10 +3895,6 @@ xmlCopyNamespace(xmlNsPtr cur) {
            ret = xmlNewNs(NULL, cur->href, cur->prefix);
            break;
        default:
-#ifdef DEBUG_TREE
-           xmlGenericError(xmlGenericErrorContext,
-                   "xmlCopyNamespace: invalid type %d\n", cur->type);
-#endif
            return(NULL);
     }
     return(ret);
@@ -4077,6 +3915,10 @@ xmlCopyNamespaceList(xmlNsPtr cur) {
 
     while (cur != NULL) {
         q = xmlCopyNamespace(cur);
+        if (q == NULL) {
+            xmlFreeNsList(ret);
+            return(NULL);
+        }
        if (p == NULL) {
            ret = p = q;
        } else {
@@ -4088,9 +3930,6 @@ xmlCopyNamespaceList(xmlNsPtr cur) {
     return(ret);
 }
 
-static xmlNodePtr
-xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent);
-
 static xmlAttrPtr
 xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
     xmlAttrPtr ret;
@@ -4221,8 +4060,10 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
         return(NULL);
     while (cur != NULL) {
         q = xmlCopyProp(target, cur);
-       if (q == NULL)
+       if (q == NULL) {
+            xmlFreePropList(ret);
            return(NULL);
+        }
        if (p == NULL) {
            ret = p = q;
        } else {
@@ -4254,7 +4095,7 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
  * namespace info, but don't recurse on children.
  */
 
-static xmlNodePtr
+xmlNodePtr
 xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
                   int extended) {
     xmlNodePtr ret;
@@ -4365,7 +4206,10 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
            /*
             * Humm, we are copying an element whose namespace is defined
             * out of the new tree scope. Search it in the original tree
-            * and add it at the top of the new tree
+            * and add it at the top of the new tree.
+             *
+             * TODO: Searching the original tree seems unnecessary. We
+             * already have a namespace URI.
             */
            ns = xmlSearchNs(node->doc, node, node->ns->prefix);
            if (ns != NULL) {
@@ -4373,8 +4217,8 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
 
                while (root->parent != NULL) root = root->parent;
                ret->ns = xmlNewNs(root, ns->href, ns->prefix);
-               } else {
-                       ret->ns = xmlNewReconciledNs(doc, ret, node->ns);
+            } else {
+                ret->ns = xmlNewReconciledNs(doc, ret, node->ns);
            }
        } else {
            /*
@@ -4453,10 +4297,12 @@ out:
     return(ret);
 }
 
-static xmlNodePtr
+xmlNodePtr
 xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
     xmlNodePtr ret = NULL;
     xmlNodePtr p = NULL,q;
+    xmlDtdPtr newSubset = NULL;
+    int linkedSubset = 0;
 
     while (node != NULL) {
 #ifdef LIBXML_TREE_ENABLED
@@ -4465,21 +4311,22 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
                node = node->next;
                continue;
            }
-           if (doc->intSubset == NULL) {
+           if ((doc->intSubset == NULL) && (newSubset == NULL)) {
                q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
-               if (q == NULL) return(NULL);
+               if (q == NULL) goto error;
                q->doc = doc;
                q->parent = parent;
-               doc->intSubset = (xmlDtdPtr) q;
+               newSubset = (xmlDtdPtr) q;
                xmlAddChild(parent, q);
            } else {
+                linkedSubset = 1;
                q = (xmlNodePtr) doc->intSubset;
                xmlAddChild(parent, q);
            }
        } else
 #endif /* LIBXML_TREE_ENABLED */
            q = xmlStaticCopyNode(node, doc, parent, 1);
-       if (q == NULL) return(NULL);
+       if (q == NULL) goto error;
        if (ret == NULL) {
            q->prev = NULL;
            ret = p = q;
@@ -4491,7 +4338,14 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
        }
        node = node->next;
     }
+    if ((doc != NULL) && (newSubset != NULL))
+        doc->intSubset = newSubset;
     return(ret);
+error:
+    if (linkedSubset != 0)
+        xmlUnlinkNode((xmlNodePtr) doc->intSubset);
+    xmlFreeNodeList(ret);
+    return(NULL);
 }
 
 /**
@@ -4808,12 +4662,12 @@ xmlGetNodePath(const xmlNode *node)
         return (NULL);
 
     buf_len = 500;
-    buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
+    buffer = (xmlChar *) xmlMallocAtomic(buf_len);
     if (buffer == NULL) {
        xmlTreeErrMemory("getting node path");
         return (NULL);
     }
-    buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
+    buf = (xmlChar *) xmlMallocAtomic(buf_len);
     if (buf == NULL) {
        xmlTreeErrMemory("getting node path");
         xmlFree(buffer);
@@ -5752,10 +5606,6 @@ xmlNodeGetContent(const xmlNode *cur)
 void
 xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNodeSetContent : node == NULL\n");
-#endif
        return;
     }
     switch (cur->type) {
@@ -5825,10 +5675,6 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
 void
 xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNodeSetContentLen : node == NULL\n");
-#endif
        return;
     }
     switch (cur->type) {
@@ -5895,10 +5741,6 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
 void
 xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNodeAddContentLen : node == NULL\n");
-#endif
        return;
     }
     if (len <= 0) return;
@@ -5969,10 +5811,6 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
     int len;
 
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNodeAddContent : node == NULL\n");
-#endif
        return;
     }
     if (content == NULL) return;
@@ -6019,7 +5857,7 @@ xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node)
     xmlNsPtr cur;
     xmlNsPtr *ret = NULL;
     int nbns = 0;
-    int maxns = 10;
+    int maxns = 0;
     int i;
 
     if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
@@ -6029,16 +5867,6 @@ xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node)
         if (node->type == XML_ELEMENT_NODE) {
             cur = node->nsDef;
             while (cur != NULL) {
-                if (ret == NULL) {
-                    ret =
-                        (xmlNsPtr *) xmlMalloc((maxns + 1) *
-                                               sizeof(xmlNsPtr));
-                    if (ret == NULL) {
-                       xmlTreeErrMemory("getting namespace list");
-                        return (NULL);
-                    }
-                    ret[nbns] = NULL;
-                }
                 for (i = 0; i < nbns; i++) {
                     if ((cur->prefix == ret[i]->prefix) ||
                         (xmlStrEqual(cur->prefix, ret[i]->prefix)))
@@ -6046,15 +5874,18 @@ xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node)
                 }
                 if (i >= nbns) {
                     if (nbns >= maxns) {
-                        maxns *= 2;
-                        ret = (xmlNsPtr *) xmlRealloc(ret,
-                                                      (maxns +
-                                                       1) *
+                        xmlNsPtr *tmp;
+
+                        maxns = maxns ? maxns * 2 : 10;
+                        tmp = (xmlNsPtr *) xmlRealloc(ret,
+                                                      (maxns + 1) *
                                                       sizeof(xmlNsPtr));
-                        if (ret == NULL) {
+                        if (tmp == NULL) {
                            xmlTreeErrMemory("getting namespace list");
+                            xmlFree(ret);
                             return (NULL);
                         }
+                        ret = tmp;
                     }
                     ret[nbns++] = cur;
                     ret[nbns] = NULL;
@@ -6345,17 +6176,9 @@ xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
     int counter = 1;
 
     if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewReconciledNs : tree == NULL\n");
-#endif
        return(NULL);
     }
     if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlNewReconciledNs : ns == NULL\n");
-#endif
        return(NULL);
     }
     /*
@@ -7102,10 +6925,6 @@ xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) {
         (node->type != XML_CDATA_SECTION_NODE) &&
        (node->type != XML_COMMENT_NODE) &&
        (node->type != XML_PI_NODE)) {
-#ifdef DEBUG_TREE
-       xmlGenericError(xmlGenericErrorContext,
-               "xmlTextConcat: node is not text nor CDATA\n");
-#endif
         return(-1);
     }
     /* need to check if content is currently in the dictionary */
@@ -7146,7 +6965,7 @@ xmlBufferCreate(void) {
     ret->use = 0;
     ret->size = xmlDefaultBufferSize;
     ret->alloc = xmlBufferAllocScheme;
-    ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+    ret->content = (xmlChar *) xmlMallocAtomic(ret->size);
     if (ret->content == NULL) {
        xmlTreeErrMemory("creating buffer");
        xmlFree(ret);
@@ -7179,7 +6998,7 @@ xmlBufferCreateSize(size_t size) {
     ret->alloc = xmlBufferAllocScheme;
     ret->size = (size ? size + 1 : 0);         /* +1 for ending null */
     if (ret->size){
-        ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+        ret->content = (xmlChar *) xmlMallocAtomic(ret->size);
         if (ret->content == NULL) {
            xmlTreeErrMemory("creating buffer");
             xmlFree(ret);
@@ -7208,8 +7027,6 @@ xmlBufferDetach(xmlBufferPtr buf) {
 
     if (buf == NULL)
         return(NULL);
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
-        return(NULL);
 
     ret = buf->content;
     buf->content = NULL;
@@ -7225,31 +7042,14 @@ xmlBufferDetach(xmlBufferPtr buf) {
  * @mem: the memory area
  * @size:  the size in byte
  *
- * routine to create an XML buffer from an immutable memory area.
- * The area won't be modified nor copied, and is expected to be
- * present until the end of the buffer lifetime.
- *
- * returns the new structure.
+ * Returns an XML buffer initialized with bytes.
  */
 xmlBufferPtr
 xmlBufferCreateStatic(void *mem, size_t size) {
-    xmlBufferPtr ret;
+    xmlBufferPtr buf = xmlBufferCreateSize(size);
 
-    if ((mem == NULL) || (size == 0))
-        return(NULL);
-    if (size > UINT_MAX)
-        return(NULL);
-
-    ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
-    if (ret == NULL) {
-       xmlTreeErrMemory("creating buffer");
-        return(NULL);
-    }
-    ret->use = size;
-    ret->size = size;
-    ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE;
-    ret->content = (xmlChar *) mem;
-    return(ret);
+    xmlBufferAdd(buf, mem, size);
+    return(buf);
 }
 
 /**
@@ -7263,18 +7063,12 @@ void
 xmlBufferSetAllocationScheme(xmlBufferPtr buf,
                              xmlBufferAllocationScheme scheme) {
     if (buf == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferSetAllocationScheme: buf == NULL\n");
-#endif
         return;
     }
-    if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
-        (buf->alloc == XML_BUFFER_ALLOC_IO)) return;
+    if (buf->alloc == XML_BUFFER_ALLOC_IO) return;
     if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
         (scheme == XML_BUFFER_ALLOC_EXACT) ||
-        (scheme == XML_BUFFER_ALLOC_HYBRID) ||
-        (scheme == XML_BUFFER_ALLOC_IMMUTABLE))
+        (scheme == XML_BUFFER_ALLOC_HYBRID))
        buf->alloc = scheme;
 }
 
@@ -7288,18 +7082,13 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
 void
 xmlBufferFree(xmlBufferPtr buf) {
     if (buf == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferFree: buf == NULL\n");
-#endif
        return;
     }
 
     if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
         (buf->contentIO != NULL)) {
         xmlFree(buf->contentIO);
-    } else if ((buf->content != NULL) &&
-        (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
+    } else if (buf->content != NULL) {
         xmlFree(buf->content);
     }
     xmlFree(buf);
@@ -7316,10 +7105,7 @@ xmlBufferEmpty(xmlBufferPtr buf) {
     if (buf == NULL) return;
     if (buf->content == NULL) return;
     buf->use = 0;
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
-        buf->content = BAD_CAST "";
-    } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
-               (buf->contentIO != NULL)) {
+    if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
         size_t start_buf = buf->content - buf->contentIO;
 
        buf->size += start_buf;
@@ -7346,8 +7132,7 @@ xmlBufferShrink(xmlBufferPtr buf, unsigned int len) {
     if (len > buf->use) return(-1);
 
     buf->use -= len;
-    if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
-        ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
+    if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
        /*
         * we just move the content pointer, but also make sure
         * the perceived buffer size has shrunk accordingly
@@ -7391,7 +7176,6 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
 
     if (buf == NULL) return(-1);
 
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
     if (len < buf->size - buf->use)
         return(0);
     if (len >= UINT_MAX - buf->use) {
@@ -7441,23 +7225,15 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
     size_t ret;
 
     if (buf == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferDump: buf == NULL\n");
-#endif
        return(0);
     }
     if (buf->content == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferDump: buf->content == NULL\n");
-#endif
        return(0);
     }
     if (file == NULL)
        file = stdout;
-    ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
-    return(ret > INT_MAX ? INT_MAX : (int)ret);
+    ret = fwrite(buf->content, 1, buf->use, file);
+    return(ret > INT_MAX ? INT_MAX : ret);
 }
 
 /**
@@ -7515,8 +7291,6 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
     if (buf == NULL)
         return(0);
 
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
-
     /* Don't resize if we don't have to */
     if (size < buf->size)
         return 1;
@@ -7634,12 +7408,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
     if ((str == NULL) || (buf == NULL)) {
        return -1;
     }
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
     if (len < -1) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferAdd: len < 0\n");
-#endif
        return -1;
     }
     if (len == 0) return 0;
@@ -7663,7 +7432,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
         }
     }
 
-    memmove(&buf->content[buf->use], str, len*sizeof(xmlChar));
+    memmove(&buf->content[buf->use], str, len);
     buf->use += len;
     buf->content[buf->use] = 0;
     return 0;
@@ -7687,19 +7456,10 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
 
     if (buf == NULL)
         return(-1);
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
     if (str == NULL) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferAddHead: str == NULL\n");
-#endif
        return -1;
     }
     if (len < -1) {
-#ifdef DEBUG_BUFFER
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlBufferAddHead: len < 0\n");
-#endif
        return -1;
     }
     if (len == 0) return 0;
@@ -7758,7 +7518,6 @@ int
 xmlBufferCat(xmlBufferPtr buf, const xmlChar *str) {
     if (buf == NULL)
         return(-1);
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
     if (str == NULL) return -1;
     return xmlBufferAdd(buf, str, -1);
 }
@@ -7790,7 +7549,6 @@ void
 xmlBufferWriteCHAR(xmlBufferPtr buf, const xmlChar *string) {
     if (buf == NULL)
         return;
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
     xmlBufferCat(buf, string);
 }
 
@@ -7806,7 +7564,6 @@ void
 xmlBufferWriteChar(xmlBufferPtr buf, const char *string) {
     if (buf == NULL)
         return;
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
     xmlBufferCCat(buf, string);
 }
 
@@ -7825,13 +7582,8 @@ xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
     const xmlChar *cur, *base;
     if (buf == NULL)
         return;
-    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
     if (xmlStrchr(string, '\"')) {
         if (xmlStrchr(string, '\'')) {
-#ifdef DEBUG_BUFFER
-           xmlGenericError(xmlGenericErrorContext,
- "xmlBufferWriteQuotedString: string contains quote and double-quotes !\n");
-#endif
            xmlBufferCCat(buf, "\"");
             base = cur = string;
             while(*cur != 0){
@@ -10248,3 +10000,90 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
     return (0);
 }
 
+/************************************************************************
+ *                                                                     *
+ *                     XHTML detection                                 *
+ *                                                                     *
+ ************************************************************************/
+
+#define XHTML_STRICT_PUBLIC_ID BAD_CAST \
+   "-//W3C//DTD XHTML 1.0 Strict//EN"
+#define XHTML_STRICT_SYSTEM_ID BAD_CAST \
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+#define XHTML_FRAME_PUBLIC_ID BAD_CAST \
+   "-//W3C//DTD XHTML 1.0 Frameset//EN"
+#define XHTML_FRAME_SYSTEM_ID BAD_CAST \
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"
+#define XHTML_TRANS_PUBLIC_ID BAD_CAST \
+   "-//W3C//DTD XHTML 1.0 Transitional//EN"
+#define XHTML_TRANS_SYSTEM_ID BAD_CAST \
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+
+/**
+ * xmlIsXHTML:
+ * @systemID:  the system identifier
+ * @publicID:  the public identifier
+ *
+ * Try to find if the document correspond to an XHTML DTD
+ *
+ * Returns 1 if true, 0 if not and -1 in case of error
+ */
+int
+xmlIsXHTML(const xmlChar *systemID, const xmlChar *publicID) {
+    if ((systemID == NULL) && (publicID == NULL))
+       return(-1);
+    if (publicID != NULL) {
+       if (xmlStrEqual(publicID, XHTML_STRICT_PUBLIC_ID)) return(1);
+       if (xmlStrEqual(publicID, XHTML_FRAME_PUBLIC_ID)) return(1);
+       if (xmlStrEqual(publicID, XHTML_TRANS_PUBLIC_ID)) return(1);
+    }
+    if (systemID != NULL) {
+       if (xmlStrEqual(systemID, XHTML_STRICT_SYSTEM_ID)) return(1);
+       if (xmlStrEqual(systemID, XHTML_FRAME_SYSTEM_ID)) return(1);
+       if (xmlStrEqual(systemID, XHTML_TRANS_SYSTEM_ID)) return(1);
+    }
+    return(0);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Node callbacks                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xmlRegisterNodeDefault:
+ * @func: function pointer to the new RegisterNodeFunc
+ *
+ * Registers a callback for node creation
+ *
+ * Returns the old value of the registration function
+ */
+xmlRegisterNodeFunc
+xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
+{
+    xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
+
+    __xmlRegisterCallbacks = 1;
+    xmlRegisterNodeDefaultValue = func;
+    return(old);
+}
+
+/**
+ * xmlDeregisterNodeDefault:
+ * @func: function pointer to the new DeregisterNodeFunc
+ *
+ * Registers a callback for node destruction
+ *
+ * Returns the previous value of the deregistration function
+ */
+xmlDeregisterNodeFunc
+xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
+{
+    xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
+
+    __xmlRegisterCallbacks = 1;
+    xmlDeregisterNodeDefaultValue = func;
+    return(old);
+}
+
diff --git a/uri.c b/uri.c
index e5c790e..03b5a31 100644 (file)
--- a/uri.c
+++ b/uri.c
 
 #include <libxml/xmlmemory.h>
 #include <libxml/uri.h>
-#include <libxml/globals.h>
 #include <libxml/xmlerror.h>
 
+#include "private/error.h"
+
 /**
  * MAX_URI_LENGTH:
  *
@@ -33,6 +34,9 @@
  */
 #define MAX_URI_LENGTH 1024 * 1024
 
+#define PORT_EMPTY           0
+#define PORT_EMPTY_SERVER   -1
+
 static void
 xmlURIErrMemory(const char *extra)
 {
@@ -768,8 +772,11 @@ xmlParse3986HierPart(xmlURIPtr uri, const char **str)
         cur += 2;
        ret = xmlParse3986Authority(uri, &cur);
        if (ret != 0) return(ret);
-       if (uri->server == NULL)
-           uri->port = -1;
+        /*
+         * An empty server is marked with a special URI value.
+         */
+       if ((uri->server == NULL) && (uri->port == PORT_EMPTY))
+           uri->port = PORT_EMPTY_SERVER;
        ret = xmlParse3986PathAbEmpty(uri, &cur);
        if (ret != 0) return(ret);
        *str = cur;
@@ -1026,6 +1033,7 @@ xmlCreateURI(void) {
        return(NULL);
     }
     memset(ret, 0, sizeof(xmlURI));
+    ret->port = PORT_EMPTY;
     return(ret);
 }
 
@@ -1074,7 +1082,7 @@ xmlSaveUri(xmlURIPtr uri) {
 
 
     max = 80;
-    ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMallocAtomic(max + 1);
     if (ret == NULL) {
         xmlURIErrMemory("saving URI\n");
        return(NULL);
@@ -1117,7 +1125,7 @@ xmlSaveUri(xmlURIPtr uri) {
            }
        }
     } else {
-       if ((uri->server != NULL) || (uri->port == -1)) {
+       if ((uri->server != NULL) || (uri->port != PORT_EMPTY)) {
            if (len + 3 >= max) {
                 temp = xmlSaveUriRealloc(ret, &max);
                 if (temp == NULL) goto mem_error;
@@ -1162,17 +1170,18 @@ xmlSaveUri(xmlURIPtr uri) {
                        if (temp == NULL) goto mem_error;
                        ret = temp;
                    }
-                   ret[len++] = *p++;
-               }
-               if (uri->port > 0) {
-                   if (len + 10 >= max) {
-                       temp = xmlSaveUriRealloc(ret, &max);
-                       if (temp == NULL) goto mem_error;
-                       ret = temp;
-                   }
-                   len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
+                    /* TODO: escaping? */
+                   ret[len++] = (xmlChar) *p++;
                }
            }
+            if (uri->port > 0) {
+                if (len + 10 >= max) {
+                    temp = xmlSaveUriRealloc(ret, &max);
+                    if (temp == NULL) goto mem_error;
+                    ret = temp;
+                }
+                len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
+            }
        } else if (uri->authority != NULL) {
            if (len + 3 >= max) {
                 temp = xmlSaveUriRealloc(ret, &max);
@@ -1655,6 +1664,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
                c = c * 16 + (*in - 'A') + 10;
            in++;
            len -= 3;
+            /* Explicit sign change */
            *out++ = (char) c;
        } else {
            *out++ = *in++;
@@ -1670,8 +1680,8 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
  * @str:  string to escape
  * @list: exception list string of chars not to escape
  *
- * This routine escapes a string to hex, ignoring reserved characters (a-z)
- * and the characters in the exception list.
+ * This routine escapes a string to hex, ignoring reserved characters
+ * (a-z, A-Z, 0-9, "@-_.!~*'()") and the characters in the exception list.
  *
  * Returns a new escaped string or NULL in case of error.
  */
@@ -1817,10 +1827,10 @@ xmlURIEscape(const xmlChar * str)
         xmlFree(segment);
     }
 
-    if (uri->port) {
-        xmlChar port[10];
+    if (uri->port > 0) {
+        xmlChar port[11];
 
-        snprintf((char *) port, 10, "%d", uri->port);
+        snprintf((char *) port, 11, "%d", uri->port);
         ret = xmlStrcat(ret, BAD_CAST ":");
         ret = xmlStrcat(ret, port);
     }
@@ -1966,12 +1976,13 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
     if (res == NULL)
        goto done;
     if ((ref->scheme == NULL) && (ref->path == NULL) &&
-       ((ref->authority == NULL) && (ref->server == NULL))) {
+       ((ref->authority == NULL) && (ref->server == NULL) &&
+         (ref->port == PORT_EMPTY))) {
        if (bas->scheme != NULL)
            res->scheme = xmlMemStrdup(bas->scheme);
        if (bas->authority != NULL)
            res->authority = xmlMemStrdup(bas->authority);
-       else if ((bas->server != NULL) || (bas->port == -1)) {
+       else {
            if (bas->server != NULL)
                res->server = xmlMemStrdup(bas->server);
            if (bas->user != NULL)
@@ -2020,11 +2031,13 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
      *    component, which will also be undefined if the URI scheme does not
      *    use an authority component.
      */
-    if ((ref->authority != NULL) || (ref->server != NULL)) {
+    if ((ref->authority != NULL) || (ref->server != NULL) ||
+         (ref->port != PORT_EMPTY)) {
        if (ref->authority != NULL)
            res->authority = xmlMemStrdup(ref->authority);
        else {
-           res->server = xmlMemStrdup(ref->server);
+            if (ref->server != NULL)
+                res->server = xmlMemStrdup(ref->server);
            if (ref->user != NULL)
                res->user = xmlMemStrdup(ref->user);
             res->port = ref->port;
@@ -2035,7 +2048,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
     }
     if (bas->authority != NULL)
        res->authority = xmlMemStrdup(bas->authority);
-    else if ((bas->server != NULL) || (bas->port == -1)) {
+    else if ((bas->server != NULL) || (bas->port != PORT_EMPTY)) {
        if (bas->server != NULL)
            res->server = xmlMemStrdup(bas->server);
        if (bas->user != NULL)
@@ -2105,7 +2118,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
        /*
         * Ensure the path includes a '/'
         */
-       if ((out == 0) && (bas->server != NULL))
+       if ((out == 0) && ((bas->server != NULL) || bas->port != PORT_EMPTY))
            res->path[out++] = '/';
        while (ref->path[indx] != 0) {
            res->path[out++] = ref->path[indx++];
@@ -2223,7 +2236,8 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
     if ((ref->scheme != NULL) &&
        ((bas->scheme == NULL) ||
         (xmlStrcmp ((xmlChar *)bas->scheme, (xmlChar *)ref->scheme)) ||
-        (xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)))) {
+        (xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)) ||
+         (bas->port != ref->port))) {
        val = xmlStrdup (URI);
        goto done;
     }
diff --git a/valid.c b/valid.c
index 1da812e..76d657d 100644 (file)
--- a/valid.c
+++ b/valid.c
 #include <libxml/parserInternals.h>
 #include <libxml/xmlerror.h>
 #include <libxml/list.h>
-#include <libxml/globals.h>
 
-static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name,
-                                  int create);
-/* #define DEBUG_VALID_ALGO */
-/* #define DEBUG_REGEXP_ALGO */
+#include "private/error.h"
+#include "private/parser.h"
+
+static xmlElementPtr
+xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
+                      int create);
 
 #define TODO                                                           \
     xmlGenericError(xmlGenericErrorContext,                            \
@@ -64,9 +65,7 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
        /* Look up flag to detect if it is part of a parsing
           context */
        if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
-           long delta = (char *) ctxt - (char *) ctxt->userData;
-           if ((delta > 0) && (delta < 250))
-               pctxt = ctxt->userData;
+           pctxt = ctxt->userData;
        }
     }
     if (extra)
@@ -103,9 +102,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
        /* Look up flag to detect if it is part of a parsing
           context */
        if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
-           long delta = (char *) ctxt - (char *) ctxt->userData;
-           if ((delta > 0) && (delta < 250))
-               pctxt = ctxt->userData;
+           pctxt = ctxt->userData;
        }
     }
     if (extra)
@@ -149,9 +146,7 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt,
        /* Look up flag to detect if it is part of a parsing
           context */
        if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
-           long delta = (char *) ctxt - (char *) ctxt->userData;
-           if ((delta > 0) && (delta < 250))
-               pctxt = ctxt->userData;
+           pctxt = ctxt->userData;
        }
     }
     __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
@@ -191,9 +186,7 @@ xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
        /* Look up flag to detect if it is part of a parsing
           context */
        if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
-           long delta = (char *) ctxt - (char *) ctxt->userData;
-           if ((delta > 0) && (delta < 250))
-               pctxt = ctxt->userData;
+           pctxt = ctxt->userData;
        }
     }
     __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
@@ -231,9 +224,7 @@ xmlErrValidWarning(xmlValidCtxtPtr ctxt,
        /* Look up flag to detect if it is part of a parsing
           context */
        if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
-           long delta = (char *) ctxt - (char *) ctxt->userData;
-           if ((delta > 0) && (delta < 250))
-               pctxt = ctxt->userData;
+           pctxt = ctxt->userData;
        }
     }
     __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
@@ -471,151 +462,6 @@ nodeVPop(xmlValidCtxtPtr ctxt)
     return (ret);
 }
 
-#ifdef DEBUG_VALID_ALGO
-static void
-xmlValidPrintNode(xmlNodePtr cur) {
-    if (cur == NULL) {
-       xmlGenericError(xmlGenericErrorContext, "null");
-       return;
-    }
-    switch (cur->type) {
-       case XML_ELEMENT_NODE:
-           xmlGenericError(xmlGenericErrorContext, "%s ", cur->name);
-           break;
-       case XML_TEXT_NODE:
-           xmlGenericError(xmlGenericErrorContext, "text ");
-           break;
-       case XML_CDATA_SECTION_NODE:
-           xmlGenericError(xmlGenericErrorContext, "cdata ");
-           break;
-       case XML_ENTITY_REF_NODE:
-           xmlGenericError(xmlGenericErrorContext, "&%s; ", cur->name);
-           break;
-       case XML_PI_NODE:
-           xmlGenericError(xmlGenericErrorContext, "pi(%s) ", cur->name);
-           break;
-       case XML_COMMENT_NODE:
-           xmlGenericError(xmlGenericErrorContext, "comment ");
-           break;
-       case XML_ATTRIBUTE_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?attr? ");
-           break;
-       case XML_ENTITY_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?ent? ");
-           break;
-       case XML_DOCUMENT_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?doc? ");
-           break;
-       case XML_DOCUMENT_TYPE_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?doctype? ");
-           break;
-       case XML_DOCUMENT_FRAG_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?frag? ");
-           break;
-       case XML_NOTATION_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?nota? ");
-           break;
-       case XML_HTML_DOCUMENT_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?html? ");
-           break;
-       case XML_DTD_NODE:
-           xmlGenericError(xmlGenericErrorContext, "?dtd? ");
-           break;
-       case XML_ELEMENT_DECL:
-           xmlGenericError(xmlGenericErrorContext, "?edecl? ");
-           break;
-       case XML_ATTRIBUTE_DECL:
-           xmlGenericError(xmlGenericErrorContext, "?adecl? ");
-           break;
-       case XML_ENTITY_DECL:
-           xmlGenericError(xmlGenericErrorContext, "?entdecl? ");
-           break;
-       case XML_NAMESPACE_DECL:
-           xmlGenericError(xmlGenericErrorContext, "?nsdecl? ");
-           break;
-       case XML_XINCLUDE_START:
-           xmlGenericError(xmlGenericErrorContext, "incstart ");
-           break;
-       case XML_XINCLUDE_END:
-           xmlGenericError(xmlGenericErrorContext, "incend ");
-           break;
-    }
-}
-
-static void
-xmlValidPrintNodeList(xmlNodePtr cur) {
-    if (cur == NULL)
-       xmlGenericError(xmlGenericErrorContext, "null ");
-    while (cur != NULL) {
-       xmlValidPrintNode(cur);
-       cur = cur->next;
-    }
-}
-
-static void
-xmlValidDebug(xmlNodePtr cur, xmlElementContentPtr cont) {
-    char expr[5000];
-
-    expr[0] = 0;
-    xmlGenericError(xmlGenericErrorContext, "valid: ");
-    xmlValidPrintNodeList(cur);
-    xmlGenericError(xmlGenericErrorContext, "against ");
-    xmlSnprintfElementContent(expr, 5000, cont, 1);
-    xmlGenericError(xmlGenericErrorContext, "%s\n", expr);
-}
-
-static void
-xmlValidDebugState(xmlValidStatePtr state) {
-    xmlGenericError(xmlGenericErrorContext, "(");
-    if (state->cont == NULL)
-       xmlGenericError(xmlGenericErrorContext, "null,");
-    else
-       switch (state->cont->type) {
-            case XML_ELEMENT_CONTENT_PCDATA:
-               xmlGenericError(xmlGenericErrorContext, "pcdata,");
-               break;
-            case XML_ELEMENT_CONTENT_ELEMENT:
-               xmlGenericError(xmlGenericErrorContext, "%s,",
-                               state->cont->name);
-               break;
-            case XML_ELEMENT_CONTENT_SEQ:
-               xmlGenericError(xmlGenericErrorContext, "seq,");
-               break;
-            case XML_ELEMENT_CONTENT_OR:
-               xmlGenericError(xmlGenericErrorContext, "or,");
-               break;
-       }
-    xmlValidPrintNode(state->node);
-    xmlGenericError(xmlGenericErrorContext, ",%d,%X,%d)",
-           state->depth, state->occurs, state->state);
-}
-
-static void
-xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
-    int i, j;
-
-    xmlGenericError(xmlGenericErrorContext, "state: ");
-    xmlValidDebugState(ctxt->vstate);
-    xmlGenericError(xmlGenericErrorContext, " stack: %d ",
-           ctxt->vstateNr - 1);
-    for (i = 0, j = ctxt->vstateNr - 1;(i < 3) && (j > 0);i++,j--)
-       xmlValidDebugState(&ctxt->vstateTab[j]);
-    xmlGenericError(xmlGenericErrorContext, "\n");
-}
-
-/*****
-#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
- *****/
-
-#define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt);
-#define DEBUG_VALID_MSG(m)                                     \
-    xmlGenericError(xmlGenericErrorContext, "%s\n", m);
-
-#else
-#define DEBUG_VALID_STATE(n,c)
-#define DEBUG_VALID_MSG(m)
-#endif
-
 /* TODO: use hash table for accesses to elem and attribute definitions */
 
 
@@ -832,11 +678,8 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
        xmlSnprintfElementContent(expr, 5000, elem->content, 1);
        xmlErrValidNode(ctxt, (xmlNodePtr) elem,
                        XML_DTD_CONTENT_NOT_DETERMINIST,
-              "Content model of %s is not determinist: %s\n",
+              "Content model of %s is not deterministic: %s\n",
               elem->name, BAD_CAST expr, NULL);
-#ifdef DEBUG_REGEXP_ALGO
-        xmlRegexpPrint(stderr, elem->contModel);
-#endif
         ctxt->valid = 0;
        ctxt->state = NULL;
        xmlFreeAutomata(ctxt->am);
@@ -885,6 +728,8 @@ xmlValidCtxtPtr xmlNewValidCtxt(void) {
  */
 void
 xmlFreeValidCtxt(xmlValidCtxtPtr cur) {
+    if (cur == NULL)
+        return;
     if (cur->vstateTab != NULL)
         xmlFree(cur->vstateTab);
     if (cur->nodeTab != NULL)
@@ -1056,7 +901,7 @@ xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
            if (cur->c1 != NULL)
                tmp->c1 = xmlCopyDocElementContent(doc,cur->c1);
            if (tmp->c1 != NULL)
-               tmp->c1->parent = ret;
+               tmp->c1->parent = tmp;
            prev = tmp;
            cur = cur->c2;
        }
@@ -2120,7 +1965,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
      * Validity Check:
      * Multiple ID per element
      */
-    elemDef = xmlGetDtdElementDesc2(dtd, elem, 1);
+    elemDef = xmlGetDtdElementDesc2(ctxt, dtd, elem, 1);
     if (elemDef != NULL) {
 
 #ifdef LIBXML_VALID_ENABLED
@@ -3284,7 +3129,8 @@ xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name) {
  */
 
 static xmlElementPtr
-xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
+xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
+                      int create) {
     xmlElementTablePtr table;
     xmlElementPtr cur;
     xmlChar *uqname = NULL, *prefix = NULL;
@@ -3307,7 +3153,7 @@ xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
            dtd->elements = (void *) table;
        }
        if (table == NULL) {
-           xmlVErrMemory(NULL, "element table allocation failed");
+           xmlVErrMemory(ctxt, "element table allocation failed");
            return(NULL);
        }
     }
@@ -3320,8 +3166,8 @@ xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
     if ((cur == NULL) && (create)) {
        cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
        if (cur == NULL) {
-           xmlVErrMemory(NULL, "malloc failed");
-           return(NULL);
+           xmlVErrMemory(ctxt, "malloc failed");
+           goto error;
        }
        memset(cur, 0, sizeof(xmlElement));
        cur->type = XML_ELEMENT_DECL;
@@ -3333,8 +3179,13 @@ xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
        cur->prefix = xmlStrdup(prefix);
        cur->etype = XML_ELEMENT_TYPE_UNDEFINED;
 
-       xmlHashAddEntry2(table, name, prefix, cur);
+       if (xmlHashAddEntry2(table, name, prefix, cur) < 0) {
+           xmlVErrMemory(ctxt, "adding entry failed");
+            xmlFreeElement(cur);
+            cur = NULL;
+        }
     }
+error:
     if (prefix != NULL) xmlFree(prefix);
     if (uqname != NULL) xmlFree(uqname);
     return(cur);
@@ -4890,24 +4741,21 @@ cont:
      * epsilon transition, go directly to the analysis phase
      */
     if (STATE == ROLLBACK_PARENT) {
-       DEBUG_VALID_MSG("restored parent branch");
-       DEBUG_VALID_STATE(NODE, CONT)
        ret = 1;
        goto analyze;
     }
 
-    DEBUG_VALID_STATE(NODE, CONT)
     /*
      * we may have to save a backup state here. This is the equivalent
      * of handling epsilon transition in NFAs.
      */
     if ((CONT != NULL) &&
        ((CONT->parent == NULL) ||
+        (CONT->parent == (xmlElementContentPtr) 1) ||
         (CONT->parent->type != XML_ELEMENT_CONTENT_OR)) &&
        ((CONT->ocur == XML_ELEMENT_CONTENT_MULT) ||
         (CONT->ocur == XML_ELEMENT_CONTENT_OPT) ||
         ((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURRENCE)))) {
-       DEBUG_VALID_MSG("saving parent branch");
        if (vstateVPush(ctxt, CONT, NODE, DEPTH, OCCURS, ROLLBACK_PARENT) < 0)
            return(0);
     }
@@ -4919,12 +4767,10 @@ cont:
     switch (CONT->type) {
        case XML_ELEMENT_CONTENT_PCDATA:
            if (NODE == NULL) {
-               DEBUG_VALID_MSG("pcdata failed no node");
                ret = 0;
                break;
            }
            if (NODE->type == XML_TEXT_NODE) {
-               DEBUG_VALID_MSG("pcdata found, skip to next");
                /*
                 * go to next element in the content model
                 * skipping ignorable elems
@@ -4942,14 +4788,12 @@ cont:
                 ret = 1;
                break;
            } else {
-               DEBUG_VALID_MSG("pcdata failed");
                ret = 0;
                break;
            }
            break;
        case XML_ELEMENT_CONTENT_ELEMENT:
            if (NODE == NULL) {
-               DEBUG_VALID_MSG("element failed no node");
                ret = 0;
                break;
            }
@@ -4965,7 +4809,6 @@ cont:
                }
            }
            if (ret == 1) {
-               DEBUG_VALID_MSG("element found, skip to next");
                /*
                 * go to next element in the content model
                 * skipping ignorable elems
@@ -4981,7 +4824,6 @@ cont:
                          (NODE->type != XML_TEXT_NODE) &&
                          (NODE->type != XML_CDATA_SECTION_NODE)));
            } else {
-               DEBUG_VALID_MSG("element failed");
                ret = 0;
                break;
            }
@@ -5014,8 +4856,7 @@ cont:
            /*
             * save the second branch 'or' branch
             */
-           DEBUG_VALID_MSG("saving 'or' branch");
-           if (vstateVPush(ctxt, CONT->c2, NODE, (unsigned char)(DEPTH + 1),
+           if (vstateVPush(ctxt, CONT->c2, NODE, DEPTH + 1,
                            OCCURS, ROLLBACK_OR) < 0)
                return(-1);
            DEPTH++;
@@ -5056,7 +4897,6 @@ cont:
      * At this point handle going up in the tree
      */
     if (ret == -1) {
-       DEBUG_VALID_MSG("error found returning");
        return(ret);
     }
 analyze:
@@ -5071,9 +4911,7 @@ analyze:
 
                case XML_ELEMENT_CONTENT_ONCE:
                    cur = ctxt->vstate->node;
-                   DEBUG_VALID_MSG("Once branch failed, rollback");
                    if (vstateVPop(ctxt) < 0 ) {
-                       DEBUG_VALID_MSG("exhaustion, failed");
                        return(0);
                    }
                    if (cur != ctxt->vstate->node)
@@ -5082,69 +4920,50 @@ analyze:
                case XML_ELEMENT_CONTENT_PLUS:
                    if (OCCURRENCE == 0) {
                        cur = ctxt->vstate->node;
-                       DEBUG_VALID_MSG("Plus branch failed, rollback");
                        if (vstateVPop(ctxt) < 0 ) {
-                           DEBUG_VALID_MSG("exhaustion, failed");
                            return(0);
                        }
                        if (cur != ctxt->vstate->node)
                            determinist = -3;
                        goto cont;
                    }
-                   DEBUG_VALID_MSG("Plus branch found");
                    ret = 1;
                    break;
                case XML_ELEMENT_CONTENT_MULT:
-#ifdef DEBUG_VALID_ALGO
-                   if (OCCURRENCE == 0) {
-                       DEBUG_VALID_MSG("Mult branch failed");
-                   } else {
-                       DEBUG_VALID_MSG("Mult branch found");
-                   }
-#endif
                    ret = 1;
                    break;
                case XML_ELEMENT_CONTENT_OPT:
-                   DEBUG_VALID_MSG("Option branch failed");
                    ret = 1;
                    break;
            }
        } else {
            switch (CONT->ocur) {
                case XML_ELEMENT_CONTENT_OPT:
-                   DEBUG_VALID_MSG("Option branch succeeded");
                    ret = 1;
                    break;
                case XML_ELEMENT_CONTENT_ONCE:
-                   DEBUG_VALID_MSG("Once branch succeeded");
                    ret = 1;
                    break;
                case XML_ELEMENT_CONTENT_PLUS:
                    if (STATE == ROLLBACK_PARENT) {
-                       DEBUG_VALID_MSG("Plus branch rollback");
                        ret = 1;
                        break;
                    }
                    if (NODE == NULL) {
-                       DEBUG_VALID_MSG("Plus branch exhausted");
                        ret = 1;
                        break;
                    }
-                   DEBUG_VALID_MSG("Plus branch succeeded, continuing");
                    SET_OCCURRENCE;
                    goto cont;
                case XML_ELEMENT_CONTENT_MULT:
                    if (STATE == ROLLBACK_PARENT) {
-                       DEBUG_VALID_MSG("Mult branch rollback");
                        ret = 1;
                        break;
                    }
                    if (NODE == NULL) {
-                       DEBUG_VALID_MSG("Mult branch exhausted");
                        ret = 1;
                        break;
                    }
-                   DEBUG_VALID_MSG("Mult branch succeeded, continuing");
                    /* SET_OCCURRENCE; */
                    goto cont;
            }
@@ -5155,38 +4974,32 @@ analyze:
         * Then act accordingly at the parent level
         */
        RESET_OCCURRENCE;
-       if (CONT->parent == NULL)
+       if ((CONT->parent == NULL) ||
+            (CONT->parent == (xmlElementContentPtr) 1))
            break;
 
        switch (CONT->parent->type) {
            case XML_ELEMENT_CONTENT_PCDATA:
-               DEBUG_VALID_MSG("Error: parent pcdata");
                return(-1);
            case XML_ELEMENT_CONTENT_ELEMENT:
-               DEBUG_VALID_MSG("Error: parent element");
                return(-1);
            case XML_ELEMENT_CONTENT_OR:
                if (ret == 1) {
-                   DEBUG_VALID_MSG("Or succeeded");
                    CONT = CONT->parent;
                    DEPTH--;
                } else {
-                   DEBUG_VALID_MSG("Or failed");
                    CONT = CONT->parent;
                    DEPTH--;
                }
                break;
            case XML_ELEMENT_CONTENT_SEQ:
                if (ret == 0) {
-                   DEBUG_VALID_MSG("Sequence failed");
                    CONT = CONT->parent;
                    DEPTH--;
                } else if (CONT == CONT->parent->c1) {
-                   DEBUG_VALID_MSG("Sequence testing 2nd branch");
                    CONT = CONT->parent->c2;
                    goto cont;
                } else {
-                   DEBUG_VALID_MSG("Sequence succeeded");
                    CONT = CONT->parent;
                    DEPTH--;
                }
@@ -5196,9 +5009,7 @@ analyze:
        xmlNodePtr cur;
 
        cur = ctxt->vstate->node;
-       DEBUG_VALID_MSG("Failed, remaining input, rollback");
        if (vstateVPop(ctxt) < 0 ) {
-           DEBUG_VALID_MSG("exhaustion, failed");
            return(0);
        }
        if (cur != ctxt->vstate->node)
@@ -5209,9 +5020,7 @@ analyze:
        xmlNodePtr cur;
 
        cur = ctxt->vstate->node;
-       DEBUG_VALID_MSG("Failure, rollback");
        if (vstateVPop(ctxt) < 0 ) {
-           DEBUG_VALID_MSG("exhaustion, failed");
            return(0);
        }
        if (cur != ctxt->vstate->node)
@@ -5437,16 +5246,19 @@ fail:
     STATE = 0;
     ret = xmlValidateElementType(ctxt);
     if ((ret == -3) && (warn)) {
-       xmlErrValidWarning(ctxt, child, XML_DTD_CONTENT_NOT_DETERMINIST,
-              "Content model for Element %s is ambiguous\n",
-                          name, NULL, NULL);
+       char expr[5000];
+       expr[0] = 0;
+       xmlSnprintfElementContent(expr, 5000, elemDecl->content, 1);
+       xmlErrValidNode(ctxt, (xmlNodePtr) elemDecl,
+                XML_DTD_CONTENT_NOT_DETERMINIST,
+               "Content model of %s is not deterministic: %s\n",
+               name, BAD_CAST expr, NULL);
     } else if (ret == -2) {
        /*
         * An entities reference appeared at this level.
         * Build a minimal representation of this node content
         * sufficient to run the validation process on it
         */
-       DEBUG_VALID_MSG("Found an entity reference, linearizing");
        cur = child;
        while (cur != NULL) {
            switch (cur->type) {
@@ -5660,6 +5472,7 @@ done:
     return(ret);
 }
 
+#ifdef LIBXML_REGEXP_ENABLED
 /**
  * xmlValidateCheckMixed:
  * @ctxt:  the validation context
@@ -5725,6 +5538,7 @@ xmlValidateCheckMixed(xmlValidCtxtPtr ctxt,
     }
     return(0);
 }
+#endif /* LIBXML_REGEXP_ENABLED */
 
 /**
  * xmlValidGetElemDecl:
@@ -5989,11 +5803,12 @@ xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED,
            if (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT) {
                if (state->exec != NULL) {
                    ret = xmlRegExecPushString(state->exec, NULL, NULL);
-                   if (ret == 0) {
+                   if (ret <= 0) {
                        xmlErrValidNode(ctxt, state->node,
                                        XML_DTD_CONTENT_MODEL,
-          "Element %s content does not follow the DTD, Expecting more child\n",
+          "Element %s content does not follow the DTD, Expecting more children\n",
                               state->node->name, NULL,NULL);
+                       ret = 0;
                    } else {
                        /*
                         * previous validation errors should not generate
@@ -6449,7 +6264,7 @@ name_ok:
  * xmlValidateElement:
  * @ctxt:  the validation context
  * @doc:  a document instance
- * @elem:  an element instance
+ * @root:  an element instance
  *
  * Try to validate the subtree under an element
  *
@@ -6457,60 +6272,60 @@ name_ok:
  */
 
 int
-xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
-    xmlNodePtr child;
+xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr root) {
+    xmlNodePtr elem;
     xmlAttrPtr attr;
     xmlNsPtr ns;
     const xmlChar *value;
     int ret = 1;
 
-    if (elem == NULL) return(0);
-
-    /*
-     * XInclude elements were added after parsing in the infoset,
-     * they don't really mean anything validation wise.
-     */
-    if ((elem->type == XML_XINCLUDE_START) ||
-       (elem->type == XML_XINCLUDE_END) ||
-       (elem->type == XML_NAMESPACE_DECL))
-       return(1);
+    if (root == NULL) return(0);
 
     CHECK_DTD;
 
-    /*
-     * Entities references have to be handled separately
-     */
-    if (elem->type == XML_ENTITY_REF_NODE) {
-       return(1);
-    }
+    elem = root;
+    while (1) {
+        ret &= xmlValidateOneElement(ctxt, doc, elem);
+
+        if (elem->type == XML_ELEMENT_NODE) {
+            attr = elem->properties;
+            while (attr != NULL) {
+                value = xmlNodeListGetString(doc, attr->children, 0);
+                ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
+                if (value != NULL)
+                    xmlFree((char *)value);
+                attr= attr->next;
+            }
 
-    ret &= xmlValidateOneElement(ctxt, doc, elem);
-    if (elem->type == XML_ELEMENT_NODE) {
-       attr = elem->properties;
-       while (attr != NULL) {
-           value = xmlNodeListGetString(doc, attr->children, 0);
-           ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
-           if (value != NULL)
-               xmlFree((char *)value);
-           attr= attr->next;
-       }
-       ns = elem->nsDef;
-       while (ns != NULL) {
-           if (elem->ns == NULL)
-               ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL,
-                                              ns, ns->href);
-           else
-               ret &= xmlValidateOneNamespace(ctxt, doc, elem,
-                                              elem->ns->prefix, ns, ns->href);
-           ns = ns->next;
-       }
-    }
-    child = elem->children;
-    while (child != NULL) {
-        ret &= xmlValidateElement(ctxt, doc, child);
-        child = child->next;
+            ns = elem->nsDef;
+            while (ns != NULL) {
+                if (elem->ns == NULL)
+                    ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL,
+                                                   ns, ns->href);
+                else
+                    ret &= xmlValidateOneNamespace(ctxt, doc, elem,
+                                                   elem->ns->prefix, ns,
+                                                   ns->href);
+                ns = ns->next;
+            }
+
+            if (elem->children != NULL) {
+                elem = elem->children;
+                continue;
+            }
+        }
+
+        while (1) {
+            if (elem == root)
+                goto done;
+            if (elem->next != NULL)
+                break;
+            elem = elem->parent;
+        }
+        elem = elem->next;
     }
 
+done:
     return(ret);
 }
 
@@ -7007,7 +6822,7 @@ xmlValidGetPotentialChildren(xmlElementContent *ctree,
 /*
  * Dummy function to suppress messages while we try out valid elements
  */
-static void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED,
+static void xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED,
                                 const char *msg ATTRIBUTE_UNUSED, ...) {
     return;
 }
index c4b5125..13e0239 100644 (file)
@@ -31,7 +31,6 @@ XML_NAME = xml2
 XML_BASENAME = lib$(XML_NAME)
 XML_SO = $(XML_BASENAME).dll
 XML_IMP = $(XML_BASENAME).lib
-XML_DEF = $(XML_BASENAME).def
 XML_A = $(XML_BASENAME)_a.lib
 DUMMY = dir.exists
 
@@ -42,7 +41,7 @@ XML_INTDIR_A = int.a.bcb
 UTILS_INTDIR = int.utils.bcb
 
 # The preprocessor and its options.
-CPP = cpp32.exe -P- -DWIN32
+CPP = cpp32.exe -P-
 CPPFLAGS = -I"$(XML_SRCDIR)\include" -DNOLIBTOOL 
 !if "$(WITH_THREADS)" != "no"
 CPPFLAGS = $(CPPFLAGS) -D_REENTRANT -D__MT__
@@ -50,7 +49,7 @@ CPPFLAGS = $(CPPFLAGS) -D_REENTRANT -D__MT__
 
 # The compiler and its options.
 CC = bcc32.exe
-CFLAGS = -q -DWIN32 -D_NO_VCL -D_WINDOWS -D_MBCS -DEILSEQ=2 -DNOLIBTOOL -w-
+CFLAGS = -q -D_NO_VCL -D_WINDOWS -D_MBCS -DEILSEQ=2 -DNOLIBTOOL -w-
 CFLAGS = $(CFLAGS) -I"$(XML_SRCDIR)" -I"$(XML_SRCDIR)\include" -I"$(INCPREFIX)" -I"$(INCLUDE)"
 !if "$(WITH_THREADS)" != "no"
 CFLAGS = $(CFLAGS) -D_REENTRANT -tWM
@@ -58,10 +57,8 @@ CFLAGS = $(CFLAGS) -D_REENTRANT -tWM
 !if "$(DYNRUNTIME)" == "1"
 CFLAGS = $(CFLAGS) -tWR
 !endif
-!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls"
-CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
-!else if "$(WITH_THREADS)" == "native"
-CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS
+!if "$(WITH_THREADS)" == "ctls"
+CFLAGS = $(CFLAGS) "-DXML_THREAD_LOCAL=__declspec(thread)"
 !else if "$(WITH_THREADS)" == "posix"
 CFLAGS = $(CFLAGS) -DHAVE_PTHREAD_H
 !endif
@@ -205,7 +202,6 @@ XML_OBJS_A = $(XML_INTDIR_A)\buf.obj\
 # Xmllint and friends executables.
 UTILS = $(BINDIR)\xmllint.exe\
        $(BINDIR)\xmlcatalog.exe\
-       $(BINDIR)\testAutomata.exe\
        $(BINDIR)\testModule.exe\
        $(BINDIR)\runtest.exe\
        $(BINDIR)\runsuite.exe\
@@ -295,17 +291,12 @@ $(XML_OBJS_A) : $(XML_INTDIR_A)\$(DUMMY)
 
 #def4bcb.exe : def4bcb.c
 
-# Creates the export definition file (DEF) for libxml.
-#$(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR)\$(DUMMY) $(XML_DEF).src def4bcb.exe
-#      $(CPP) $(CPPFLAGS) -o $(XML_INTDIR)\$(XML_DEF).tmp $(XML_DEF).src
-#      def4bcb -msnames < $(XML_INTDIR)\$(XML_DEF).tmp > $(XML_INTDIR)\$(XML_DEF)
-
 # Creates the libxml shared object.
 $(BINDIR)\$(XML_SO) : $(BINDIR)\$(DUMMY) $(XML_OBJS)
        $(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS)
 
-#$(BINDIR)\$(XML_SO) : $(BINDIR)\$(DUMMY) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF)
-#      $(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS),$(XML_INTDIR)\$(XML_DEF)
+#$(BINDIR)\$(XML_SO) : $(BINDIR)\$(DUMMY) $(XML_OBJS)
+#      $(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS)
 
 # Creates the libxml archive.
 $(BINDIR)\$(XML_A) : $(BINDIR)\$(DUMMY) $(XML_OBJS_A)
index 13f2d96..620dc1d 100644 (file)
@@ -40,19 +40,13 @@ endif
 
 # The compiler and its options.
 CC = gcc.exe
-CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS -DNOLIBTOOL 
+CFLAGS += -D_WINDOWS -D_MBCS -DNOLIBTOOL
 CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX) $(INCLUDE)
 ifneq ($(WITH_THREADS),no)
 CFLAGS += -D_REENTRANT
 endif
-ifeq ($(WITH_THREADS),yes) 
-CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
-endif
 ifeq ($(WITH_THREADS),ctls)
-CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
-endif
-ifeq ($(WITH_THREADS),native)
-CFLAGS += -DHAVE_WIN32_THREADS
+CFLAGS += "-DXML_THREAD_LOCAL=__declspec(thread)"
 endif
 ifeq ($(WITH_THREADS),posix)
 CFLAGS += -DHAVE_PTHREAD_H
@@ -201,7 +195,6 @@ XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)
 # Xmllint and friends executables.
 UTILS = $(BINDIR)/xmllint.exe\
        $(BINDIR)/xmlcatalog.exe\
-       $(BINDIR)/testAutomata.exe\
        $(BINDIR)/testModule.exe\
        $(BINDIR)/runtest.exe\
        $(BINDIR)/runsuite.exe\
index 80e64e2..bc8ddd0 100644 (file)
@@ -24,7 +24,6 @@ XML_BASENAME = lib$(XML_NAME)
 XML_SO = $(XML_BASENAME).dll
 XML_RES = $(XML_BASENAME).res
 XML_IMP = $(XML_BASENAME).lib
-XML_DEF = $(XML_BASENAME).def
 XML_A = $(XML_BASENAME)_a.lib
 XML_A_DLL = $(XML_BASENAME)_a_dll.lib
 
@@ -49,10 +48,8 @@ CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX)
 !if "$(WITH_THREADS)" != "no"
 CFLAGS = $(CFLAGS) /D "_REENTRANT"
 !endif
-!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls"
-CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS" /D "HAVE_COMPILER_TLS"
-!else if "$(WITH_THREADS)" == "native"
-CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS"
+!if "$(WITH_THREADS)" == "ctls"
+CFLAGS = $(CFLAGS) /D "XML_THREAD_LOCAL=__declspec(thread)"
 !else if "$(WITH_THREADS)" == "posix"
 CFLAGS = $(CFLAGS) /D "HAVE_PTHREAD_H"
 !endif
@@ -255,7 +252,6 @@ XML_OBJS_A_DLL = $(XML_OBJS_A_DLL) $(XML_INTDIR_A_DLL)\xzlib.obj
 # Xmllint and friends executables.
 UTILS = $(BINDIR)\xmllint.exe\
        $(BINDIR)\xmlcatalog.exe\
-       $(BINDIR)\testAutomata.exe\
        $(BINDIR)\testModule.exe\
        $(BINDIR)\runtest.exe\
        $(BINDIR)\runsuite.exe\
@@ -368,22 +364,15 @@ $(XML_OBJS_A) : $(XML_INTDIR_A)
 # Compiles static for dll libxml source. Uses the implicit rule for commands.
 $(XML_OBJS_A_DLL) : $(XML_INTDIR_A_DLL) 
 
-# Creates the export definition file (DEF) for libxml.
-$(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR) $(XML_DEF).src
-       $(CPP) $(CPPFLAGS) $(XML_DEF).src > $(XML_INTDIR)\$(XML_DEF)
 $(XML_INTDIR)\$(XML_RES) : $(XML_INTDIR) libxml2.rc
        rc -Fo $(XML_INTDIR)\$(XML_RES) libxml2.rc
 
 # Creates the libxml shared object.
-$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF) $(XML_INTDIR)\$(XML_RES)
+$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_RES)
        $(LD) $(LDFLAGS) /DLL \
                /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(XML_INTDIR)\$(XML_RES) $(LIBS)
        @$(_VC_MANIFEST_EMBED_DLL)
 
-#$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF)
-#      $(LD) $(LDFLAGS) /DLL /DEF:$(XML_INTDIR)\$(XML_DEF) \
-#              /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(LIBS)
-
 # Creates the libxml archive.
 $(BINDIR)\$(XML_A) : $(BINDIR) $(XML_OBJS_A)
        $(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XML_A) $(XML_OBJS_A)
index d02070e..238686e 100644 (file)
@@ -2,6 +2,9 @@
                              Windows port
                              ============
 
+DEPRECATION WARNING: The build system in the win32 directory is deprecated
+and will be removed in a future release. Please switch to CMake.
+
 This directory contains the files required to build this software on the
 native Windows platform. This is not a place to look for help if you are
 using a POSIX emulator, such as Cygwin. Check the Unix instructions for 
index 8499428..3e49635 100644 (file)
@@ -46,7 +46,6 @@ var withZlib = false;
 var withLzma = false;
 var withDebug = true;
 var withMemDebug = false;
-var withRunDebug = false;
 var withSchemas = true;
 var withSchematron = true;
 var withRegExps = true;
@@ -132,7 +131,6 @@ function usage()
        txt += "  lzma:       Enable lzma support (" + (withLzma? "yes" : "no")  + ")\n";
        txt += "  xml_debug:  Enable XML debbugging module (" + (withDebug? "yes" : "no")  + ")\n";
        txt += "  mem_debug:  Enable memory debugger (" + (withMemDebug? "yes" : "no")  + ")\n";
-       txt += "  run_debug:  Enable memory debugger (" + (withRunDebug? "yes" : "no")  + ")\n";
        txt += "  regexps:    Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
        txt += "  modules:    Enable module support (" + (withModules? "yes" : "no") + ")\n";
        txt += "  tree:       Enable tree api (" + (withTree? "yes" : "no") + ")\n";
@@ -229,7 +227,6 @@ function discoverVersion()
        vf.WriteLine("WITH_LZMA=" + (withLzma? "1" : "0"));
        vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
        vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
-       vf.WriteLine("WITH_RUN_DEBUG=" + (withRunDebug? "1" : "0"));
        vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
        vf.WriteLine("WITH_SCHEMATRON=" + (withSchematron? "1" : "0"));
        vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
@@ -337,8 +334,6 @@ function configureLibxml()
                        of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
                } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
                        of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
-               } else if (s.search(/\@WITH_RUN_DEBUG\@/) != -1) {
-                       of.WriteLine(s.replace(/\@WITH_RUN_DEBUG\@/, withRunDebug? "1" : "0"));
                } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
                        of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
                } else if (s.search(/\@WITH_SCHEMATRON\@/) != -1) {
@@ -492,8 +487,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
                        withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
                else if (opt == "mem_debug")
                        withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
-               else if (opt == "run_debug")
-                       withRunDebug = strToBool(arg.substring(opt.length + 1, arg.length));
                else if (opt == "schemas")
                        withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
                else if (opt == "schematron")
@@ -672,7 +665,6 @@ txtOut += "      zlib support: " + boolToStr(withZlib) + "\n";
 txtOut += "      lzma support: " + boolToStr(withLzma) + "\n";
 txtOut += "  Debugging module: " + boolToStr(withDebug) + "\n";
 txtOut += "  Memory debugging: " + boolToStr(withMemDebug) + "\n";
-txtOut += " Runtime debugging: " + boolToStr(withRunDebug) + "\n";
 txtOut += "    Regexp support: " + boolToStr(withRegExps) + "\n";
 txtOut += "    Module support: " + boolToStr(withModules) + "\n";
 txtOut += "      Tree support: " + boolToStr(withTree) + "\n";
@@ -706,6 +698,10 @@ txtOut += "Put static libs in: " + buildLibPrefix + "\n";
 txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
 txtOut += "      Include path: " + buildInclude + "\n";
 txtOut += "          Lib path: " + buildLib + "\n";
+txtOut += "\n";
+txtOut += "DEPRECATION WARNING: The build system in the win32 directory is\n";
+txtOut += "deprecated and will be removed in a future release. Please switch\n";
+txtOut += "to CMake.\n";
 WScript.Echo(txtOut);
 
 //
diff --git a/win32/defgen.xsl b/win32/defgen.xsl
deleted file mode 100644 (file)
index 423a231..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-<?xml version="1.0"?>
-<!-- 
-       win32/defgen.xsl
-       This stylesheet is used to transform doc/libxml2-api.xml into a pseudo-source,
-       which can then be preprocessed to get the .DEF file for the Microsoft's linker.
-       
-       Use any XSLT processor to produce a file called libxml2.def.src in the win32
-       subdirectory, for example, run xsltproc from the win32 subdirectory:
-       
-         xsltproc -o libxml2.def.src defgen.xsl ../doc/libxml2-api.xml
-         
-       Once that finishes, rest assured, the Makefile will know what to do with the
-       generated file. 
-
-       April 2003, Igor Zlatkovic <igor@zlatkovic.com>
--->
-<!DOCTYPE xsl:stylesheet [ <!ENTITY nl '&#xd;&#xa;'> ]>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-       <xsl:strip-space elements="*"/>
-       <xsl:output method="text"/>
-       <xsl:template match="/">
-               <xsl:text>#define LIBXML2_COMPILING_MSCCDEF&nl;</xsl:text>
-               <xsl:text>#include "../include/libxml/xmlversion.h"&nl;</xsl:text>
-               <xsl:text>LIBRARY libxml2&nl;</xsl:text>
-               <xsl:text>EXPORTS&nl;</xsl:text>
-               <xsl:for-each select="/api/symbols/*[self::variable or self::function]">
-                       <!-- Basic tests -->
-                       <xsl:if test="@file = 'c14n'">
-                               <xsl:text>#ifdef LIBXML_C14N_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'catalog'">
-                               <xsl:text>#ifdef LIBXML_CATALOG_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'debugXML'">
-                               <xsl:text>#ifdef LIBXML_DEBUG_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'HTMLparser') 
-                                       or (@file = 'HTMLtree')">
-                               <xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'nanohttp'">
-                               <xsl:text>#ifdef LIBXML_HTTP_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'nanoftp'">
-                               <xsl:text>#ifdef LIBXML_FTP_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'relaxng') 
-                                       or (@file = 'xmlschemas') 
-                                       or (@file = 'xmlschemastypes')">
-                               <xsl:text>#ifdef LIBXML_SCHEMAS_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xinclude'">
-                               <xsl:text>#ifdef LIBXML_XINCLUDE_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xlink'">
-                               <xsl:text>#ifdef LIBXML_XLINK_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xmlautomata'">
-                               <xsl:text>#ifdef LIBXML_AUTOMATA_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'xmlregexp') 
-                                       or (@file = 'xmlunicode')">
-                               <xsl:text>#ifdef LIBXML_REGEXP_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'xpath') 
-                                       or (@file = 'xpathInternals')">
-                               <xsl:text>#ifdef LIBXML_XPATH_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xpointer'">
-                               <xsl:text>#ifdef LIBXML_XPTR_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <!-- Extended tests -->
-                       <xsl:if test="(@name = 'htmlDefaultSAXHandlerInit') 
-                                       or (@name = 'htmlInitAutoClose') 
-                                       or (@name = 'htmlCreateFileParserCtxt') 
-                                       or (@name = 'inithtmlDefaultSAXHandler')
-                                       or (@name = 'xmlIsXHTML') 
-                                       or (@name = 'xmlIOHTTPOpenW') 
-                                       or (@name = 'xmlRegisterHTTPPostCallbacks') 
-                                       or (@name = 'xmlIOHTTPMatch')
-                                       or (@name = 'xmlIOHTTPOpen') 
-                                       or (@name = 'xmlIOHTTPRead') 
-                                       or (@name = 'xmlIOHTTPClose')">
-                               <xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@name = 'xmlValidBuildContentModel'">
-                               <xsl:text>#ifdef LIBXML_REGEXP_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlIOFTPMatch') 
-                                       or (@name = 'xmlIOFTPOpen') 
-                                       or (@name = 'xmlIOFTPRead') 
-                                       or (@name = 'xmlIOFTPClose')">
-                               <xsl:text>#ifdef LIBXML_FTP_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlTextReaderRelaxNGValidate') 
-                                       or (@name = 'xmlTextReaderRelaxNGSetSchema')">
-                               <xsl:text>#ifdef LIBXML_SCHEMAS_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlXPathDebugDumpObject') 
-                                       or (@name = 'xmlXPathDebugDumpCompExpr')">
-                               <xsl:text>#ifdef LIBXML_DEBUG_ENABLED&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlMallocLoc') 
-                                       or (@name = 'xmlMallocAtomicLoc') 
-                                       or (@name = 'xmlReallocLoc') 
-                                       or (@name = 'xmlMemStrdupLoc')">
-                               <xsl:text>#ifdef DEBUG_MEMORY_LOCATION&nl;</xsl:text>
-                       </xsl:if>
-                       <!-- Symbol -->
-                       <xsl:choose>
-                               <xsl:when test="(@name = 'xmlMalloc') 
-                                               or (@name = 'xmlMallocAtomic') 
-                                               or (@name = 'xmlRealloc') 
-                                               or (@name = 'xmlFree') 
-                                               or (@name = 'xmlMemStrdup')">
-                                       <xsl:text>#ifdef LIBXML_THREAD_ALLOC_ENABLED&nl;</xsl:text>
-                                       <xsl:text>__</xsl:text>
-                                       <xsl:value-of select="@name"/>
-                                       <xsl:text>&nl;</xsl:text>
-                                       <xsl:text>#else&nl;</xsl:text>
-                                       <xsl:value-of select="@name"/>
-                                       <xsl:text> DATA&nl;</xsl:text>
-                                       <xsl:text>#endif&nl;</xsl:text>
-                               </xsl:when>
-                               <xsl:when test="(@name = 'htmlDefaultSAXHandler') 
-                                               or (@name = 'oldXMLWDcompatibility') 
-                                               or (@name = 'xmlBufferAllocScheme') 
-                                               or (@name = 'xmlDefaultBufferSize') 
-                                               or (@name = 'xmlDefaultSAXHandler') 
-                                               or (@name = 'xmlDefaultSAXLocator') 
-                                               or (@name = 'xmlDoValidityCheckingDefaultValue') 
-                                               or (@name = 'xmlGenericError') 
-                                               or (@name = 'xmlGenericErrorContext') 
-                                               or (@name = 'xmlGetWarningsDefaultValue') 
-                                               or (@name = 'xmlIndentTreeOutput') 
-                                               or (@name = 'xmlTreeIndentString') 
-                                               or (@name = 'xmlKeepBlanksDefaultValue') 
-                                               or (@name = 'xmlLineNumbersDefaultValue') 
-                                               or (@name = 'xmlLoadExtDtdDefaultValue') 
-                                               or (@name = 'xmlParserDebugEntities') 
-                                               or (@name = 'xmlParserVersion') 
-                                               or (@name = 'xmlPedanticParserDefaultValue') 
-                                               or (@name = 'xmlSaveNoEmptyTags') 
-                                               or (@name = 'xmlSubstituteEntitiesDefaultValue') 
-                                               or (@name = 'xmlRegisterNodeDefaultValue') 
-                                               or (@name = 'xmlDeregisterNodeDefaultValue')">
-                                       <xsl:text>#ifdef LIBXML_THREAD_ENABLED&nl;</xsl:text>
-                                       <xsl:if test="@name = 'htmlDefaultSAXHandler'">
-                                               <xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
-                                       </xsl:if>
-                                       <xsl:text>__</xsl:text>
-                                       <xsl:value-of select="@name"/>
-                                       <xsl:text>&nl;</xsl:text>
-                                       <xsl:if test="@name = 'htmlDefaultSAXHandler'">
-                                               <xsl:text>#endif&nl;</xsl:text>
-                                       </xsl:if>
-                                       <xsl:text>#else&nl;</xsl:text>
-                                       <xsl:if test="@name = 'htmlDefaultSAXHandler'">
-                                               <xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
-                                       </xsl:if>
-                                       <xsl:value-of select="@name"/>
-                                       <xsl:text> DATA&nl;</xsl:text>
-                                       <xsl:if test="@name = 'htmlDefaultSAXHandler'">
-                                               <xsl:text>#endif&nl;</xsl:text>
-                                       </xsl:if>
-                                       <xsl:text>#endif&nl;</xsl:text>
-                               </xsl:when>
-                               <xsl:otherwise>
-                                       <xsl:value-of select="@name"/>
-                                       <xsl:if test="self::variable">
-                                               <xsl:text> DATA</xsl:text>
-                                       </xsl:if>
-                                       <xsl:text>&nl;</xsl:text>
-                               </xsl:otherwise>
-                       </xsl:choose>
-                       <!-- Basic tests (close) -->
-                       <xsl:if test="@file = 'c14n'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'catalog'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'debugXML'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'HTMLparser') 
-                                       or (@file = 'HTMLtree')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'nanohttp'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'nanoftp'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'relaxng') 
-                                       or (@file = 'xmlschemas') 
-                                       or (@file = 'xmlschemastypes')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xinclude'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xlink'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xmlautomata'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'xmlregexp') 
-                                       or (@file = 'xmlunicode')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@file = 'xpath') 
-                                       or (@file = 'xpathInternals')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@file = 'xpointer'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <!-- Extended tests (close) -->
-                       <xsl:if test="(@name = 'htmlDefaultSAXHandlerInit') 
-                                       or (@name = 'htmlInitAutoClose') 
-                                       or (@name = 'htmlCreateFileParserCtxt') 
-                                       or (@name = 'inithtmlDefaultSAXHandler')
-                                       or (@name = 'xmlIsXHTML') 
-                                       or (@name = 'xmlIOHTTPOpenW') 
-                                       or (@name = 'xmlRegisterHTTPPostCallbacks') 
-                                       or (@name = 'xmlIOHTTPMatch')
-                                       or (@name = 'xmlIOHTTPOpen') 
-                                       or (@name = 'xmlIOHTTPRead') 
-                                       or (@name = 'xmlIOHTTPClose')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="@name = 'xmlValidBuildContentModel'">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlIOFTPMatch') 
-                                       or (@name = 'xmlIOFTPOpen') 
-                                       or (@name = 'xmlIOFTPRead') 
-                                       or (@name = 'xmlIOFTPClose')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlTextReaderRelaxNGValidate') 
-                                       or (@name = 'xmlTextReaderRelaxNGSetSchema')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlXPathDebugDumpObject') 
-                                       or (@name = 'xmlXPathDebugDumpCompExpr')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-                       <xsl:if test="(@name = 'xmlMallocLoc') 
-                                       or (@name = 'xmlMallocAtomicLoc') 
-                                       or (@name = 'xmlReallocLoc') 
-                                       or (@name = 'xmlMemStrdupLoc')">
-                               <xsl:text>#endif&nl;</xsl:text>
-                       </xsl:if>
-               </xsl:for-each>
-       </xsl:template>
-</xsl:stylesheet>
-
diff --git a/win32/libxml2.def.src b/win32/libxml2.def.src
deleted file mode 100644 (file)
index d83dbf4..0000000
+++ /dev/null
@@ -1,3146 +0,0 @@
-#define LIBXML2_COMPILING_MSCCDEF
-#include "../include/libxml/xmlversion.h"
-LIBRARY libxml2
-EXPORTS
-#ifdef LIBXML_REGEXP_ENABLED
-emptyExp DATA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-forbiddenExp DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-#ifdef LIBXML_HTML_ENABLED
-__htmlDefaultSAXHandler
-#endif
-#else
-#ifdef LIBXML_HTML_ENABLED
-htmlDefaultSAXHandler DATA
-#endif
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__oldXMLWDcompatibility
-#else
-oldXMLWDcompatibility DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlBufferAllocScheme
-#else
-xmlBufferAllocScheme DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlDefaultBufferSize
-#else
-xmlDefaultBufferSize DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlDefaultSAXHandler
-#else
-xmlDefaultSAXHandler DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlDefaultSAXLocator
-#else
-xmlDefaultSAXLocator DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlDeregisterNodeDefaultValue
-#else
-xmlDeregisterNodeDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlDoValidityCheckingDefaultValue
-#else
-xmlDoValidityCheckingDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-__xmlFree
-#else
-xmlFree DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlGenericError
-#else
-xmlGenericError DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlGenericErrorContext
-#else
-xmlGenericErrorContext DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlGetWarningsDefaultValue
-#else
-xmlGetWarningsDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlIndentTreeOutput
-#else
-xmlIndentTreeOutput DATA
-#endif
-xmlIsBaseCharGroup DATA
-xmlIsCharGroup DATA
-xmlIsCombiningGroup DATA
-xmlIsDigitGroup DATA
-xmlIsExtenderGroup DATA
-xmlIsIdeographicGroup DATA
-xmlIsPubidChar_tab DATA
-#ifdef LIBXML_THREAD_ENABLED
-__xmlKeepBlanksDefaultValue
-#else
-xmlKeepBlanksDefaultValue DATA
-#endif
-xmlLastError DATA
-#ifdef LIBXML_THREAD_ENABLED
-__xmlLineNumbersDefaultValue
-#else
-xmlLineNumbersDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlLoadExtDtdDefaultValue
-#else
-xmlLoadExtDtdDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-__xmlMalloc
-#else
-xmlMalloc DATA
-#endif
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-__xmlMallocAtomic
-#else
-xmlMallocAtomic DATA
-#endif
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-__xmlMemStrdup
-#else
-xmlMemStrdup DATA
-#endif
-xmlOutputBufferCreateFilenameValue DATA
-#ifdef LIBXML_THREAD_ENABLED
-__xmlParserDebugEntities
-#else
-xmlParserDebugEntities DATA
-#endif
-xmlParserInputBufferCreateFilenameValue DATA
-xmlParserMaxDepth DATA
-#ifdef LIBXML_THREAD_ENABLED
-__xmlParserVersion
-#else
-xmlParserVersion DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlPedanticParserDefaultValue
-#else
-xmlPedanticParserDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ALLOC_ENABLED
-__xmlRealloc
-#else
-xmlRealloc DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlRegisterNodeDefaultValue
-#else
-xmlRegisterNodeDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlSaveNoEmptyTags
-#else
-xmlSaveNoEmptyTags DATA
-#endif
-xmlStringComment DATA
-xmlStringText DATA
-xmlStringTextNoenc DATA
-xmlStructuredError DATA
-xmlStructuredErrorContext DATA
-#ifdef LIBXML_THREAD_ENABLED
-__xmlSubstituteEntitiesDefaultValue
-#else
-xmlSubstituteEntitiesDefaultValue DATA
-#endif
-#ifdef LIBXML_THREAD_ENABLED
-__xmlTreeIndentString
-#else
-xmlTreeIndentString DATA
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNAN DATA
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNINF DATA
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPINF DATA
-#endif
-#ifdef LIBXML_HTML_ENABLED
-UTF8ToHtml
-#endif
-UTF8Toisolat1
-attribute
-attributeDecl
-cdataBlock
-characters
-checkNamespace
-comment
-elementDecl
-endDocument
-endElement
-entityDecl
-externalSubset
-getColumnNumber
-getEntity
-getLineNumber
-getNamespace
-getParameterEntity
-getPublicId
-getSystemId
-globalNamespace
-hasExternalSubset
-hasInternalSubset
-#ifdef LIBXML_HTML_ENABLED
-htmlAttrAllowed
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlAutoCloseTag
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCreateFileParserCtxt
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCreateMemoryParserCtxt
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCreatePushParserCtxt
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReadDoc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReadFd
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReadFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReadIO
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReadMemory
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtReset
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlCtxtUseOptions
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDefaultSAXHandlerInit
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDocContentDumpFormatOutput
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDocContentDumpOutput
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDocDump
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDocDumpMemory
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlDocDumpMemoryFormat
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlElementAllowedHere
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlElementStatusHere
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlEncodeEntities
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlEntityLookup
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlEntityValueLookup
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlFreeParserCtxt
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlGetMetaEncoding
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlHandleOmittedElem
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlInitAutoClose
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlIsAutoClosed
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlIsBooleanAttr
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlIsScriptAttribute
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNewDoc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNewDocNoDtD
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNewParserCtxt
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeDump
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeDumpFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeDumpFileFormat
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeDumpFormatOutput
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeDumpOutput
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlNodeStatus
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseCharRef
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseChunk
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseDoc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseDocument
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseElement
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseEntityRef
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlParseFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlReadDoc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlReadFd
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlReadFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlReadIO
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlReadMemory
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSAXParseDoc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSAXParseFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSaveFile
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSaveFileEnc
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSaveFileFormat
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlSetMetaEncoding
-#endif
-#ifdef LIBXML_HTML_ENABLED
-htmlTagLookup
-#endif
-ignorableWhitespace
-initGenericErrorDefaultFunc
-#ifdef LIBXML_HTML_ENABLED
-inithtmlDefaultSAXHandler
-#endif
-initxmlDefaultSAXHandler
-inputPop
-inputPush
-internalSubset
-isStandalone
-isolat1ToUTF8
-namePop
-namePush
-namespaceDecl
-nodePop
-nodePush
-notationDecl
-processingInstruction
-reference
-resolveEntity
-setDocumentLocator
-setNamespace
-startDocument
-startElement
-unparsedEntityDecl
-#ifdef LIBXML_XPATH_ENABLED
-valuePop
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-valuePush
-#endif
-#ifdef LIBXML_XLINK_ENABLED
-xlinkGetDefaultDetect
-#endif
-#ifdef LIBXML_XLINK_ENABLED
-xlinkGetDefaultHandler
-#endif
-#ifdef LIBXML_XLINK_ENABLED
-xlinkIsLink
-#endif
-#ifdef LIBXML_XLINK_ENABLED
-xlinkSetDefaultDetect
-#endif
-#ifdef LIBXML_XLINK_ENABLED
-xlinkSetDefaultHandler
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogAdd
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogDump
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogRemove
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogResolve
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogResolvePublic
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogResolveSystem
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlACatalogResolveURI
-#endif
-xmlAddAttributeDecl
-xmlAddChild
-xmlAddChildList
-xmlAddDocEntity
-xmlAddDtdEntity
-xmlAddElementDecl
-xmlAddEncodingAlias
-xmlAddID
-xmlAddNextSibling
-xmlAddNotationDecl
-xmlAddPrevSibling
-xmlAddRef
-xmlAddSibling
-xmlAllocOutputBuffer
-xmlAllocParserInputBuffer
-xmlAttrSerializeTxtContent
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataCompile
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataGetInitState
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataIsDeterminist
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewAllTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewCountTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewCountTrans2
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewCountedTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewCounter
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewCounterTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewEpsilon
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewNegTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewOnceTrans
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewOnceTrans2
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewState
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewTransition
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataNewTransition2
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlAutomataSetFinalState
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlBoolToText
-#endif
-xmlBufContent
-xmlBufEnd
-xmlBufGetNodeContent
-xmlBufNodeDump
-xmlBufShrink
-xmlBufUse
-xmlBufferAdd
-xmlBufferAddHead
-xmlBufferCCat
-xmlBufferCat
-xmlBufferContent
-xmlBufferCreate
-xmlBufferCreateSize
-xmlBufferCreateStatic
-xmlBufferDetach
-xmlBufferDump
-xmlBufferEmpty
-xmlBufferFree
-xmlBufferGrow
-xmlBufferLength
-xmlBufferResize
-xmlBufferSetAllocationScheme
-xmlBufferShrink
-xmlBufferWriteCHAR
-xmlBufferWriteChar
-xmlBufferWriteQuotedString
-xmlBuildQName
-xmlBuildRelativeURI
-xmlBuildURI
-xmlByteConsumed
-#ifdef LIBXML_C14N_ENABLED
-xmlC14NDocDumpMemory
-#endif
-#ifdef LIBXML_C14N_ENABLED
-xmlC14NDocSave
-#endif
-#ifdef LIBXML_C14N_ENABLED
-xmlC14NDocSaveTo
-#endif
-#ifdef LIBXML_C14N_ENABLED
-xmlC14NExecute
-#endif
-xmlCanonicPath
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogAdd
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogAddLocal
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogCleanup
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogConvert
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogDump
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogFreeLocal
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogGetDefaults
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogGetPublic
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogGetSystem
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogIsEmpty
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogLocalResolve
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogLocalResolveURI
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogRemove
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogResolve
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogResolvePublic
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogResolveSystem
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogResolveURI
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogSetDebug
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogSetDefaultPrefer
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlCatalogSetDefaults
-#endif
-xmlCharEncCloseFunc
-xmlCharEncFirstLine
-xmlCharEncInFunc
-xmlCharEncOutFunc
-xmlCharInRange
-xmlCharStrdup
-xmlCharStrndup
-xmlCheckFilename
-xmlCheckHTTPInput
-xmlCheckLanguageID
-xmlCheckUTF8
-xmlCheckVersion
-xmlChildElementCount
-xmlCleanupCharEncodingHandlers
-xmlCleanupEncodingAliases
-xmlCleanupGlobals
-xmlCleanupInputCallbacks
-xmlCleanupMemory
-xmlCleanupOutputCallbacks
-xmlCleanupParser
-xmlCleanupPredefinedEntities
-xmlCleanupThreads
-xmlClearNodeInfoSeq
-xmlClearParserCtxt
-#ifdef LIBXML_CATALOG_ENABLED
-xmlConvertSGMLCatalog
-#endif
-xmlCopyAttributeTable
-xmlCopyChar
-xmlCopyCharMultiByte
-xmlCopyDoc
-xmlCopyDocElementContent
-xmlCopyDtd
-xmlCopyElementContent
-xmlCopyElementTable
-xmlCopyEntitiesTable
-xmlCopyEnumeration
-xmlCopyError
-xmlCopyNamespace
-xmlCopyNamespaceList
-xmlCopyNode
-xmlCopyNodeList
-xmlCopyNotationTable
-xmlCopyProp
-xmlCopyPropList
-xmlCreateDocParserCtxt
-xmlCreateEntitiesTable
-xmlCreateEntityParserCtxt
-xmlCreateEnumeration
-xmlCreateFileParserCtxt
-xmlCreateIOParserCtxt
-xmlCreateIntSubset
-xmlCreateMemoryParserCtxt
-xmlCreatePushParserCtxt
-xmlCreateURI
-xmlCreateURLParserCtxt
-xmlCtxtGetLastError
-xmlCtxtReadDoc
-xmlCtxtReadFd
-xmlCtxtReadFile
-xmlCtxtReadIO
-xmlCtxtReadMemory
-xmlCtxtReset
-xmlCtxtResetLastError
-xmlCtxtResetPush
-xmlCtxtUseOptions
-xmlCurrentChar
-xmlDOMWrapAdoptNode
-xmlDOMWrapCloneNode
-xmlDOMWrapFreeCtxt
-xmlDOMWrapNewCtxt
-xmlDOMWrapReconcileNamespaces
-xmlDOMWrapRemoveNode
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugCheckDocument
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpAttr
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpAttrList
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpDTD
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpDocument
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpDocumentHead
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpEntities
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpNode
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpNodeList
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpOneNode
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlDebugDumpString
-#endif
-xmlDecodeEntities
-xmlDefaultSAXHandlerInit
-xmlDelEncodingAlias
-xmlDeregisterNodeDefault
-xmlDetectCharEncoding
-xmlDictCleanup
-xmlDictCreate
-xmlDictCreateSub
-xmlDictExists
-xmlDictFree
-xmlDictGetUsage
-xmlDictLookup
-xmlDictOwns
-xmlDictQLookup
-xmlDictReference
-xmlDictSetLimit
-xmlDictSize
-xmlDllMain
-xmlDocCopyNode
-xmlDocCopyNodeList
-xmlDocDump
-xmlDocDumpFormatMemory
-xmlDocDumpFormatMemoryEnc
-xmlDocDumpMemory
-xmlDocDumpMemoryEnc
-xmlDocFormatDump
-xmlDocGetRootElement
-xmlDocSetRootElement
-xmlDumpAttributeDecl
-xmlDumpAttributeTable
-xmlDumpElementDecl
-xmlDumpElementTable
-xmlDumpEntitiesTable
-xmlDumpEntityDecl
-xmlDumpNotationDecl
-xmlDumpNotationTable
-xmlElemDump
-xmlEncodeEntities
-xmlEncodeEntitiesReentrant
-xmlEncodeSpecialChars
-xmlErrMemory
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpCtxtNbCons
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpCtxtNbNodes
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpDump
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpExpDerive
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpFree
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpFreeCtxt
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpGetLanguage
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpGetStart
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpIsNillable
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpMaxToken
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpNewAtom
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpNewCtxt
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpNewOr
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpNewRange
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpNewSeq
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpParse
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpRef
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpStringDerive
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlExpSubsume
-#endif
-xmlFileClose
-xmlFileMatch
-xmlFileOpen
-xmlFileRead
-xmlFindCharEncodingHandler
-xmlFirstElementChild
-xmlFreeAttributeTable
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlFreeAutomata
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlFreeCatalog
-#endif
-xmlFreeDoc
-xmlFreeDocElementContent
-xmlFreeDtd
-xmlFreeElementContent
-xmlFreeElementTable
-xmlFreeEntitiesTable
-xmlFreeEnumeration
-xmlFreeIDTable
-xmlFreeInputStream
-xmlFreeMutex
-xmlFreeNode
-xmlFreeNodeList
-xmlFreeNotationTable
-xmlFreeNs
-xmlFreeNsList
-xmlFreeParserCtxt
-xmlFreeParserInputBuffer
-xmlFreePattern
-xmlFreePatternList
-xmlFreeProp
-xmlFreePropList
-xmlFreeRMutex
-xmlFreeRefTable
-xmlFreeStreamCtxt
-xmlFreeTextReader
-xmlFreeTextWriter
-xmlFreeURI
-xmlFreeValidCtxt
-xmlGcMemGet
-xmlGcMemSetup
-xmlGetBufferAllocationScheme
-xmlGetCharEncodingHandler
-xmlGetCharEncodingName
-xmlGetCompressMode
-xmlGetDocCompressMode
-xmlGetDocEntity
-xmlGetDtdAttrDesc
-xmlGetDtdElementDesc
-xmlGetDtdEntity
-xmlGetDtdNotationDesc
-xmlGetDtdQAttrDesc
-xmlGetDtdQElementDesc
-xmlGetEncodingAlias
-xmlGetExternalEntityLoader
-xmlGetFeature
-xmlGetFeaturesList
-xmlGetGlobalState
-xmlGetID
-xmlGetIntSubset
-xmlGetLastChild
-xmlGetLastError
-xmlGetLineNo
-xmlGetNoNsProp
-xmlGetNodePath
-xmlGetNsList
-xmlGetNsProp
-xmlGetParameterEntity
-xmlGetPredefinedEntity
-xmlGetProp
-xmlGetRefs
-xmlGetThreadId
-xmlGetUTF8Char
-xmlHandleEntity
-xmlHasFeature
-xmlHasNsProp
-xmlHasProp
-xmlHashAddEntry
-xmlHashAddEntry2
-xmlHashAddEntry3
-xmlHashCopy
-xmlHashCreate
-xmlHashCreateDict
-xmlHashDefaultDeallocator
-xmlHashFree
-xmlHashLookup
-xmlHashLookup2
-xmlHashLookup3
-xmlHashQLookup
-xmlHashQLookup2
-xmlHashQLookup3
-xmlHashRemoveEntry
-xmlHashRemoveEntry2
-xmlHashRemoveEntry3
-xmlHashScan
-xmlHashScan3
-xmlHashScanFull
-xmlHashScanFull3
-xmlHashSize
-xmlHashUpdateEntry
-xmlHashUpdateEntry2
-xmlHashUpdateEntry3
-#ifdef LIBXML_FTP_ENABLED
-xmlIOFTPClose
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlIOFTPMatch
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlIOFTPOpen
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlIOFTPRead
-#endif
-#ifdef LIBXML_HTML_ENABLED
-xmlIOHTTPClose
-#endif
-#ifdef LIBXML_HTML_ENABLED
-xmlIOHTTPMatch
-#endif
-#ifdef LIBXML_HTML_ENABLED
-xmlIOHTTPOpen
-#endif
-#ifdef LIBXML_HTML_ENABLED
-xmlIOHTTPOpenW
-#endif
-#ifdef LIBXML_HTML_ENABLED
-xmlIOHTTPRead
-#endif
-xmlIOParseDTD
-xmlInitCharEncodingHandlers
-xmlInitGlobals
-xmlInitMemory
-xmlInitNodeInfoSeq
-xmlInitParser
-xmlInitParserCtxt
-xmlInitThreads
-#ifdef LIBXML_CATALOG_ENABLED
-xmlInitializeCatalog
-#endif
-xmlInitializeDict
-xmlInitializeGlobalState
-xmlInitializePredefinedEntities
-xmlIsBaseChar
-xmlIsBlank
-xmlIsBlankNode
-xmlIsChar
-xmlIsCombining
-xmlIsDigit
-xmlIsExtender
-xmlIsID
-xmlIsIdeographic
-xmlIsLetter
-xmlIsMainThread
-xmlIsMixedElement
-xmlIsPubidChar
-xmlIsRef
-#ifdef LIBXML_HTML_ENABLED
-xmlIsXHTML
-#endif
-xmlKeepBlanksDefault
-xmlLastElementChild
-xmlLineNumbersDefault
-xmlLinkGetData
-xmlListAppend
-xmlListClear
-xmlListCopy
-xmlListCreate
-xmlListDelete
-xmlListDup
-xmlListEmpty
-xmlListEnd
-xmlListFront
-xmlListInsert
-xmlListMerge
-xmlListPopBack
-xmlListPopFront
-xmlListPushBack
-xmlListPushFront
-xmlListRemoveAll
-xmlListRemoveFirst
-xmlListRemoveLast
-xmlListReverse
-xmlListReverseSearch
-xmlListReverseWalk
-xmlListSearch
-xmlListSize
-xmlListSort
-xmlListWalk
-#ifdef LIBXML_CATALOG_ENABLED
-xmlLoadACatalog
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlLoadCatalog
-#endif
-#ifdef LIBXML_CATALOG_ENABLED
-xmlLoadCatalogs
-#endif
-xmlLoadExternalEntity
-#ifdef LIBXML_CATALOG_ENABLED
-xmlLoadSGMLSuperCatalog
-#endif
-xmlLockLibrary
-#ifdef LIBXML_DEBUG_ENABLED
-xmlLsCountNode
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlLsOneNode
-#endif
-#ifdef DEBUG_MEMORY_LOCATION
-xmlMallocAtomicLoc
-#endif
-#ifdef DEBUG_MEMORY_LOCATION
-xmlMallocLoc
-#endif
-xmlMemBlocks
-xmlMemDisplay
-xmlMemDisplayLast
-xmlMemFree
-xmlMemGet
-xmlMemMalloc
-xmlMemRealloc
-xmlMemSetup
-xmlMemShow
-#ifdef DEBUG_MEMORY_LOCATION
-xmlMemStrdupLoc
-#endif
-xmlMemUsed
-xmlMemoryDump
-xmlMemoryStrdup
-xmlModuleClose
-xmlModuleFree
-xmlModuleOpen
-xmlModuleSymbol
-xmlMutexLock
-xmlMutexUnlock
-xmlNamespaceParseNCName
-xmlNamespaceParseNSDef
-xmlNamespaceParseQName
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPCheckResponse
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPCleanup
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPClose
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPCloseConnection
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPConnect
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPConnectTo
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPCwd
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPDele
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPFreeCtxt
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPGet
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPGetConnection
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPGetResponse
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPGetSocket
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPInit
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPList
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPNewCtxt
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPOpen
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPProxy
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPQuit
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPRead
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPScanProxy
-#endif
-#ifdef LIBXML_FTP_ENABLED
-xmlNanoFTPUpdateURL
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPAuthHeader
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPCleanup
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPClose
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPContentLength
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPEncoding
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPFetch
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPInit
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPMethod
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPMethodRedir
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPMimeType
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPOpen
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPOpenRedir
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPRead
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPRedir
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPReturnCode
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPSave
-#endif
-#ifdef LIBXML_HTTP_ENABLED
-xmlNanoHTTPScanProxy
-#endif
-#ifdef LIBXML_AUTOMATA_ENABLED
-xmlNewAutomata
-#endif
-xmlNewCDataBlock
-#ifdef LIBXML_CATALOG_ENABLED
-xmlNewCatalog
-#endif
-xmlNewCharEncodingHandler
-xmlNewCharRef
-xmlNewChild
-xmlNewComment
-xmlNewDoc
-xmlNewDocComment
-xmlNewDocElementContent
-xmlNewDocFragment
-xmlNewDocNode
-xmlNewDocNodeEatName
-xmlNewDocPI
-xmlNewDocProp
-xmlNewDocRawNode
-xmlNewDocText
-xmlNewDocTextLen
-xmlNewDtd
-xmlNewElementContent
-xmlNewEntity
-xmlNewEntityInputStream
-xmlNewGlobalNs
-xmlNewIOInputStream
-xmlNewInputFromFile
-xmlNewInputStream
-xmlNewMutex
-xmlNewNode
-xmlNewNodeEatName
-xmlNewNs
-xmlNewNsProp
-xmlNewNsPropEatName
-xmlNewPI
-xmlNewParserCtxt
-xmlNewProp
-xmlNewRMutex
-xmlNewReference
-xmlNewStringInputStream
-xmlNewText
-xmlNewTextChild
-xmlNewTextLen
-xmlNewTextReader
-xmlNewTextReaderFilename
-xmlNewTextWriter
-xmlNewTextWriterDoc
-xmlNewTextWriterFilename
-xmlNewTextWriterMemory
-xmlNewTextWriterPushParser
-xmlNewTextWriterTree
-xmlNewValidCtxt
-xmlNextChar
-xmlNextElementSibling
-xmlNoNetExternalEntityLoader
-xmlNodeAddContent
-xmlNodeAddContentLen
-xmlNodeBufGetContent
-xmlNodeDump
-xmlNodeDumpOutput
-xmlNodeGetBase
-xmlNodeGetContent
-xmlNodeGetLang
-xmlNodeGetSpacePreserve
-xmlNodeIsText
-xmlNodeListGetRawString
-xmlNodeListGetString
-xmlNodeSetBase
-xmlNodeSetContent
-xmlNodeSetContentLen
-xmlNodeSetLang
-xmlNodeSetName
-xmlNodeSetSpacePreserve
-xmlNormalizeURIPath
-xmlNormalizeWindowsPath
-xmlOutputBufferClose
-xmlOutputBufferCreateBuffer
-xmlOutputBufferCreateFd
-xmlOutputBufferCreateFile
-xmlOutputBufferCreateFilename
-xmlOutputBufferCreateFilenameDefault
-xmlOutputBufferCreateIO
-xmlOutputBufferFlush
-xmlOutputBufferGetContent
-xmlOutputBufferGetSize
-xmlOutputBufferWrite
-xmlOutputBufferWriteEscape
-xmlOutputBufferWriteString
-xmlParseAttValue
-xmlParseAttribute
-xmlParseAttributeListDecl
-xmlParseAttributeType
-xmlParseBalancedChunkMemory
-xmlParseBalancedChunkMemoryRecover
-xmlParseCDSect
-#ifdef LIBXML_CATALOG_ENABLED
-xmlParseCatalogFile
-#endif
-xmlParseCharData
-xmlParseCharEncoding
-xmlParseCharRef
-xmlParseChunk
-xmlParseComment
-xmlParseContent
-xmlParseCtxtExternalEntity
-xmlParseDTD
-xmlParseDefaultDecl
-xmlParseDoc
-xmlParseDocTypeDecl
-xmlParseDocument
-xmlParseElement
-xmlParseElementChildrenContentDecl
-xmlParseElementContentDecl
-xmlParseElementDecl
-xmlParseElementMixedContentDecl
-xmlParseEncName
-xmlParseEncodingDecl
-xmlParseEndTag
-xmlParseEntity
-xmlParseEntityDecl
-xmlParseEntityRef
-xmlParseEntityValue
-xmlParseEnumeratedType
-xmlParseEnumerationType
-xmlParseExtParsedEnt
-xmlParseExternalEntity
-xmlParseExternalID
-xmlParseExternalSubset
-xmlParseFile
-xmlParseInNodeContext
-xmlParseMarkupDecl
-xmlParseMemory
-xmlParseMisc
-xmlParseName
-xmlParseNamespace
-xmlParseNmtoken
-xmlParseNotationDecl
-xmlParseNotationType
-xmlParsePEReference
-xmlParsePI
-xmlParsePITarget
-xmlParsePubidLiteral
-xmlParseQuotedString
-xmlParseReference
-xmlParseSDDecl
-xmlParseStartTag
-xmlParseSystemLiteral
-xmlParseTextDecl
-xmlParseURI
-xmlParseURIRaw
-xmlParseURIReference
-xmlParseVersionInfo
-xmlParseVersionNum
-xmlParseXMLDecl
-xmlParserAddNodeInfo
-xmlParserError
-xmlParserFindNodeInfo
-xmlParserFindNodeInfoIndex
-xmlParserGetDirectory
-xmlParserHandlePEReference
-xmlParserHandleReference
-xmlParserInputBufferCreateFd
-xmlParserInputBufferCreateFile
-xmlParserInputBufferCreateFilename
-xmlParserInputBufferCreateFilenameDefault
-xmlParserInputBufferCreateIO
-xmlParserInputBufferCreateMem
-xmlParserInputBufferCreateStatic
-xmlParserInputBufferGrow
-xmlParserInputBufferPush
-xmlParserInputBufferRead
-xmlParserInputGrow
-xmlParserInputRead
-xmlParserInputShrink
-xmlParserPrintFileContext
-xmlParserPrintFileInfo
-xmlParserValidityError
-xmlParserValidityWarning
-xmlParserWarning
-xmlPathToURI
-xmlPatternFromRoot
-xmlPatternGetStreamCtxt
-xmlPatternMatch
-xmlPatternMaxDepth
-xmlPatternMinDepth
-xmlPatternStreamable
-xmlPatterncompile
-xmlPedanticParserDefault
-xmlPopInput
-xmlPopInputCallbacks
-xmlPopOutputCallbacks
-xmlPreviousElementSibling
-xmlPrintURI
-xmlPushInput
-xmlRMutexLock
-xmlRMutexUnlock
-xmlReadDoc
-xmlReadFd
-xmlReadFile
-xmlReadIO
-xmlReadMemory
-xmlReaderForDoc
-xmlReaderForFd
-xmlReaderForFile
-xmlReaderForIO
-xmlReaderForMemory
-xmlReaderNewDoc
-xmlReaderNewFd
-xmlReaderNewFile
-xmlReaderNewIO
-xmlReaderNewMemory
-xmlReaderNewWalker
-xmlReaderWalker
-#ifdef DEBUG_MEMORY_LOCATION
-xmlReallocLoc
-#endif
-xmlReconciliateNs
-xmlRecoverDoc
-xmlRecoverFile
-xmlRecoverMemory
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegExecErrInfo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegExecNextValues
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegExecPushString
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegExecPushString2
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegFreeExecCtxt
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegFreeRegexp
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegNewExecCtxt
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegexpCompile
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegexpExec
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegexpIsDeterminist
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlRegexpPrint
-#endif
-xmlRegisterCharEncodingHandler
-xmlRegisterDefaultInputCallbacks
-xmlRegisterDefaultOutputCallbacks
-#ifdef LIBXML_HTML_ENABLED
-xmlRegisterHTTPPostCallbacks
-#endif
-xmlRegisterInputCallbacks
-xmlRegisterNodeDefault
-xmlRegisterOutputCallbacks
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGCleanupTypes
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGDump
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGDumpTree
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGFree
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGFreeParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGFreeValidCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGGetParserErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGGetValidErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGInitTypes
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGNewDocParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGNewMemParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGNewParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGNewValidCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGParse
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGSetParserErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGSetParserStructuredErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGSetValidErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGSetValidStructuredErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGValidateDoc
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGValidateFullElement
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGValidatePopElement
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGValidatePushCData
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxNGValidatePushElement
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlRelaxParserSetFlag
-#endif
-xmlRemoveID
-xmlRemoveProp
-xmlRemoveRef
-xmlReplaceNode
-xmlResetError
-xmlResetLastError
-xmlSAX2AttributeDecl
-xmlSAX2CDataBlock
-xmlSAX2Characters
-xmlSAX2Comment
-xmlSAX2ElementDecl
-xmlSAX2EndDocument
-xmlSAX2EndElement
-xmlSAX2EndElementNs
-xmlSAX2EntityDecl
-xmlSAX2ExternalSubset
-xmlSAX2GetColumnNumber
-xmlSAX2GetEntity
-xmlSAX2GetLineNumber
-xmlSAX2GetParameterEntity
-xmlSAX2GetPublicId
-xmlSAX2GetSystemId
-xmlSAX2HasExternalSubset
-xmlSAX2HasInternalSubset
-xmlSAX2IgnorableWhitespace
-xmlSAX2InitDefaultSAXHandler
-xmlSAX2InitHtmlDefaultSAXHandler
-xmlSAX2InternalSubset
-xmlSAX2IsStandalone
-xmlSAX2NotationDecl
-xmlSAX2ProcessingInstruction
-xmlSAX2Reference
-xmlSAX2ResolveEntity
-xmlSAX2SetDocumentLocator
-xmlSAX2StartDocument
-xmlSAX2StartElement
-xmlSAX2StartElementNs
-xmlSAX2UnparsedEntityDecl
-xmlSAXDefaultVersion
-xmlSAXParseDTD
-xmlSAXParseDoc
-xmlSAXParseEntity
-xmlSAXParseFile
-xmlSAXParseFileWithData
-xmlSAXParseMemory
-xmlSAXParseMemoryWithData
-xmlSAXUserParseFile
-xmlSAXUserParseMemory
-xmlSAXVersion
-xmlSaveClose
-xmlSaveDoc
-xmlSaveFile
-xmlSaveFileEnc
-xmlSaveFileTo
-xmlSaveFlush
-xmlSaveFormatFile
-xmlSaveFormatFileEnc
-xmlSaveFormatFileTo
-xmlSaveSetAttrEscape
-xmlSaveSetEscape
-xmlSaveToBuffer
-xmlSaveToFd
-xmlSaveToFilename
-xmlSaveToIO
-xmlSaveTree
-xmlSaveUri
-xmlScanName
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCheckFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCleanupTypes
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCollapseString
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCompareValues
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCompareValuesWhtsp
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaCopyValue
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaDump
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaFree
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaFreeFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaFreeParserCtxt
-#endif
-xmlSchemaFreeType
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaFreeValidCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaFreeValue
-#endif
-xmlSchemaFreeWildcard
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetBuiltInListSimpleTypeItemType
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetBuiltInType
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetCanonValue
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetCanonValueWhtsp
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetFacetValueAsULong
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetParserErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetPredefinedType
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetValType
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaGetValidErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaInitTypes
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaIsBuiltInTypeFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaIsValid
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewDocParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewMemParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewNOTATIONValue
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewQNameValue
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewStringValue
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaNewValidCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaParse
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSAXPlug
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSAXUnplug
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSetParserErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSetParserStructuredErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSetValidErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSetValidOptions
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaSetValidStructuredErrors
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValPredefTypeNode
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValPredefTypeNodeNoNorm
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidCtxtGetOptions
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidCtxtGetParserCtxt
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateDoc
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateFacetWhtsp
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateFile
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateLengthFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateLengthFacetWhtsp
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateListSimpleTypeFacet
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateOneElement
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidatePredefinedType
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateSetFilename
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateSetLocator
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValidateStream
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValueAppend
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValueGetAsBoolean
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValueGetAsString
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaValueGetNext
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlSchemaWhiteSpaceReplace
-#endif
-xmlSchematronFree
-xmlSchematronFreeParserCtxt
-xmlSchematronFreeValidCtxt
-xmlSchematronNewDocParserCtxt
-xmlSchematronNewMemParserCtxt
-xmlSchematronNewParserCtxt
-xmlSchematronNewValidCtxt
-xmlSchematronParse
-xmlSchematronSetValidStructuredErrors
-xmlSchematronValidateDoc
-xmlSearchNs
-xmlSearchNsByHref
-xmlSetBufferAllocationScheme
-xmlSetCompressMode
-xmlSetDocCompressMode
-xmlSetEntityReferenceFunc
-xmlSetExternalEntityLoader
-xmlSetFeature
-xmlSetGenericErrorFunc
-xmlSetListDoc
-xmlSetNs
-xmlSetNsProp
-xmlSetProp
-xmlSetStructuredErrorFunc
-xmlSetTreeDoc
-xmlSetupParserForBuffer
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShell
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellBase
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellCat
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellDir
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellDu
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellList
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellLoad
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellPrintNode
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellPrintXPathError
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellPrintXPathResult
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellPwd
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellSave
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellValidate
-#endif
-#ifdef LIBXML_DEBUG_ENABLED
-xmlShellWrite
-#endif
-xmlSkipBlankChars
-xmlSnprintfElementContent
-xmlSplitQName
-xmlSplitQName2
-xmlSplitQName3
-xmlSprintfElementContent
-xmlStopParser
-xmlStrEqual
-xmlStrPrintf
-xmlStrQEqual
-xmlStrVPrintf
-xmlStrcasecmp
-xmlStrcasestr
-xmlStrcat
-xmlStrchr
-xmlStrcmp
-xmlStrdup
-xmlStreamPop
-xmlStreamPush
-xmlStreamPushAttr
-xmlStreamPushNode
-xmlStreamWantsAnyNode
-xmlStringCurrentChar
-xmlStringDecodeEntities
-xmlStringGetNodeList
-xmlStringLenDecodeEntities
-xmlStringLenGetNodeList
-xmlStrlen
-xmlStrncasecmp
-xmlStrncat
-xmlStrncatNew
-xmlStrncmp
-xmlStrndup
-xmlStrstr
-xmlStrsub
-xmlSubstituteEntitiesDefault
-xmlSwitchEncoding
-xmlSwitchInputEncoding
-xmlSwitchToEncoding
-xmlTextConcat
-xmlTextMerge
-xmlTextReaderAttributeCount
-xmlTextReaderBaseUri
-xmlTextReaderByteConsumed
-xmlTextReaderClose
-xmlTextReaderConstBaseUri
-xmlTextReaderConstEncoding
-xmlTextReaderConstLocalName
-xmlTextReaderConstName
-xmlTextReaderConstNamespaceUri
-xmlTextReaderConstPrefix
-xmlTextReaderConstString
-xmlTextReaderConstValue
-xmlTextReaderConstXmlLang
-xmlTextReaderConstXmlVersion
-xmlTextReaderCurrentDoc
-xmlTextReaderCurrentNode
-xmlTextReaderDepth
-xmlTextReaderExpand
-xmlTextReaderGetAttribute
-xmlTextReaderGetAttributeNo
-xmlTextReaderGetAttributeNs
-xmlTextReaderGetErrorHandler
-xmlTextReaderGetParserColumnNumber
-xmlTextReaderGetParserLineNumber
-xmlTextReaderGetParserProp
-xmlTextReaderGetRemainder
-xmlTextReaderHasAttributes
-xmlTextReaderHasValue
-xmlTextReaderIsDefault
-xmlTextReaderIsEmptyElement
-xmlTextReaderIsNamespaceDecl
-xmlTextReaderIsValid
-xmlTextReaderLocalName
-xmlTextReaderLocatorBaseURI
-xmlTextReaderLocatorLineNumber
-xmlTextReaderLookupNamespace
-xmlTextReaderMoveToAttribute
-xmlTextReaderMoveToAttributeNo
-xmlTextReaderMoveToAttributeNs
-xmlTextReaderMoveToElement
-xmlTextReaderMoveToFirstAttribute
-xmlTextReaderMoveToNextAttribute
-xmlTextReaderName
-xmlTextReaderNamespaceUri
-xmlTextReaderNext
-xmlTextReaderNextSibling
-xmlTextReaderNodeType
-xmlTextReaderNormalization
-xmlTextReaderPrefix
-xmlTextReaderPreserve
-xmlTextReaderPreservePattern
-xmlTextReaderQuoteChar
-xmlTextReaderRead
-xmlTextReaderReadAttributeValue
-xmlTextReaderReadInnerXml
-xmlTextReaderReadOuterXml
-xmlTextReaderReadState
-xmlTextReaderReadString
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlTextReaderRelaxNGSetSchema
-#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
-xmlTextReaderRelaxNGValidate
-#endif
-xmlTextReaderRelaxNGValidateCtxt
-xmlTextReaderSchemaValidate
-xmlTextReaderSchemaValidateCtxt
-xmlTextReaderSetErrorHandler
-xmlTextReaderSetParserProp
-xmlTextReaderSetSchema
-xmlTextReaderSetStructuredErrorHandler
-xmlTextReaderSetup
-xmlTextReaderStandalone
-xmlTextReaderValue
-xmlTextReaderXmlLang
-xmlTextWriterEndAttribute
-xmlTextWriterEndCDATA
-xmlTextWriterEndComment
-xmlTextWriterEndDTD
-xmlTextWriterEndDTDAttlist
-xmlTextWriterEndDTDElement
-xmlTextWriterEndDTDEntity
-xmlTextWriterEndDocument
-xmlTextWriterEndElement
-xmlTextWriterEndPI
-xmlTextWriterFlush
-xmlTextWriterFullEndElement
-xmlTextWriterSetIndent
-xmlTextWriterSetIndentString
-xmlTextWriterSetQuoteChar
-xmlTextWriterStartAttribute
-xmlTextWriterStartAttributeNS
-xmlTextWriterStartCDATA
-xmlTextWriterStartComment
-xmlTextWriterStartDTD
-xmlTextWriterStartDTDAttlist
-xmlTextWriterStartDTDElement
-xmlTextWriterStartDTDEntity
-xmlTextWriterStartDocument
-xmlTextWriterStartElement
-xmlTextWriterStartElementNS
-xmlTextWriterStartPI
-xmlTextWriterWriteAttribute
-xmlTextWriterWriteAttributeNS
-xmlTextWriterWriteBase64
-xmlTextWriterWriteBinHex
-xmlTextWriterWriteCDATA
-xmlTextWriterWriteComment
-xmlTextWriterWriteDTD
-xmlTextWriterWriteDTDAttlist
-xmlTextWriterWriteDTDElement
-xmlTextWriterWriteDTDEntity
-xmlTextWriterWriteDTDExternalEntity
-xmlTextWriterWriteDTDExternalEntityContents
-xmlTextWriterWriteDTDInternalEntity
-xmlTextWriterWriteDTDNotation
-xmlTextWriterWriteElement
-xmlTextWriterWriteElementNS
-xmlTextWriterWriteFormatAttribute
-xmlTextWriterWriteFormatAttributeNS
-xmlTextWriterWriteFormatCDATA
-xmlTextWriterWriteFormatComment
-xmlTextWriterWriteFormatDTD
-xmlTextWriterWriteFormatDTDAttlist
-xmlTextWriterWriteFormatDTDElement
-xmlTextWriterWriteFormatDTDInternalEntity
-xmlTextWriterWriteFormatElement
-xmlTextWriterWriteFormatElementNS
-xmlTextWriterWriteFormatPI
-xmlTextWriterWriteFormatRaw
-xmlTextWriterWriteFormatString
-xmlTextWriterWritePI
-xmlTextWriterWriteRaw
-xmlTextWriterWriteRawLen
-xmlTextWriterWriteString
-xmlTextWriterWriteVFormatAttribute
-xmlTextWriterWriteVFormatAttributeNS
-xmlTextWriterWriteVFormatCDATA
-xmlTextWriterWriteVFormatComment
-xmlTextWriterWriteVFormatDTD
-xmlTextWriterWriteVFormatDTDAttlist
-xmlTextWriterWriteVFormatDTDElement
-xmlTextWriterWriteVFormatDTDInternalEntity
-xmlTextWriterWriteVFormatElement
-xmlTextWriterWriteVFormatElementNS
-xmlTextWriterWriteVFormatPI
-xmlTextWriterWriteVFormatRaw
-xmlTextWriterWriteVFormatString
-xmlThrDefBufferAllocScheme
-xmlThrDefDefaultBufferSize
-xmlThrDefDeregisterNodeDefault
-xmlThrDefDoValidityCheckingDefaultValue
-xmlThrDefGetWarningsDefaultValue
-xmlThrDefIndentTreeOutput
-xmlThrDefKeepBlanksDefaultValue
-xmlThrDefLineNumbersDefaultValue
-xmlThrDefLoadExtDtdDefaultValue
-xmlThrDefOutputBufferCreateFilenameDefault
-xmlThrDefParserDebugEntities
-xmlThrDefParserInputBufferCreateFilenameDefault
-xmlThrDefPedanticParserDefaultValue
-xmlThrDefRegisterNodeDefault
-xmlThrDefSaveNoEmptyTags
-xmlThrDefSetGenericErrorFunc
-xmlThrDefSetStructuredErrorFunc
-xmlThrDefSubstituteEntitiesDefaultValue
-xmlThrDefTreeIndentString
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsAegeanNumbers
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsAlphabeticPresentationForms
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsArabic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsArabicPresentationFormsA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsArabicPresentationFormsB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsArmenian
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsArrows
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBasicLatin
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBengali
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBlock
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBlockElements
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBopomofo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBopomofoExtended
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBoxDrawing
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBraillePatterns
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsBuhid
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsByzantineMusicalSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKCompatibility
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKCompatibilityForms
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKCompatibilityIdeographs
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKCompatibilityIdeographsSupplement
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKRadicalsSupplement
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKSymbolsandPunctuation
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKUnifiedIdeographs
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKUnifiedIdeographsExtensionA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCJKUnifiedIdeographsExtensionB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCat
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatC
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatCc
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatCf
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatCo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatCs
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatL
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatLl
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatLm
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatLo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatLt
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatLu
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatM
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatMc
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatMe
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatMn
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatN
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatNd
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatNl
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatNo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatP
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPc
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPd
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPe
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPf
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPi
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatPs
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatS
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatSc
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatSk
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatSm
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatSo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatZ
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatZl
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatZp
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCatZs
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCherokee
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCombiningDiacriticalMarks
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCombiningDiacriticalMarksforSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCombiningHalfMarks
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCombiningMarksforSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsControlPictures
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCurrencySymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCypriotSyllabary
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCyrillic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsCyrillicSupplement
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsDeseret
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsDevanagari
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsDingbats
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsEnclosedAlphanumerics
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsEnclosedCJKLettersandMonths
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsEthiopic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGeneralPunctuation
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGeometricShapes
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGeorgian
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGothic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGreek
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGreekExtended
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGreekandCoptic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGujarati
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsGurmukhi
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHalfwidthandFullwidthForms
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHangulCompatibilityJamo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHangulJamo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHangulSyllables
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHanunoo
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHebrew
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHighPrivateUseSurrogates
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHighSurrogates
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsHiragana
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsIPAExtensions
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsIdeographicDescriptionCharacters
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKanbun
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKangxiRadicals
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKannada
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKatakana
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKatakanaPhoneticExtensions
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKhmer
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsKhmerSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLao
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLatin1Supplement
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLatinExtendedA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLatinExtendedAdditional
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLatinExtendedB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLetterlikeSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLimbu
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLinearBIdeograms
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLinearBSyllabary
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsLowSurrogates
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMalayalam
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMathematicalAlphanumericSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMathematicalOperators
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMiscellaneousMathematicalSymbolsA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMiscellaneousMathematicalSymbolsB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMiscellaneousSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMiscellaneousSymbolsandArrows
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMiscellaneousTechnical
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMongolian
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMusicalSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsMyanmar
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsNumberForms
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsOgham
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsOldItalic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsOpticalCharacterRecognition
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsOriya
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsOsmanya
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsPhoneticExtensions
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsPrivateUse
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsPrivateUseArea
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsRunic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsShavian
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSinhala
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSmallFormVariants
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSpacingModifierLetters
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSpecials
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSuperscriptsandSubscripts
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSupplementalArrowsA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSupplementalArrowsB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSupplementalMathematicalOperators
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSupplementaryPrivateUseAreaA
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSupplementaryPrivateUseAreaB
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsSyriac
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTagalog
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTagbanwa
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTags
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTaiLe
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTaiXuanJingSymbols
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTamil
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTelugu
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsThaana
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsThai
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsTibetan
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsUgaritic
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsUnifiedCanadianAboriginalSyllabics
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsVariationSelectors
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsVariationSelectorsSupplement
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsYiRadicals
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsYiSyllables
-#endif
-#ifdef LIBXML_REGEXP_ENABLED
-xmlUCSIsYijingHexagramSymbols
-#endif
-xmlURIEscape
-xmlURIEscapeStr
-xmlURIUnescapeString
-xmlUTF8Charcmp
-xmlUTF8Size
-xmlUTF8Strlen
-xmlUTF8Strloc
-xmlUTF8Strndup
-xmlUTF8Strpos
-xmlUTF8Strsize
-xmlUTF8Strsub
-xmlUnlinkNode
-xmlUnlockLibrary
-xmlUnsetNsProp
-xmlUnsetProp
-#ifdef LIBXML_REGEXP_ENABLED
-xmlValidBuildContentModel
-#endif
-xmlValidCtxtNormalizeAttributeValue
-xmlValidGetPotentialChildren
-xmlValidGetValidElements
-xmlValidNormalizeAttributeValue
-xmlValidateAttributeDecl
-xmlValidateAttributeValue
-xmlValidateDocument
-xmlValidateDocumentFinal
-xmlValidateDtd
-xmlValidateDtdFinal
-xmlValidateElement
-xmlValidateElementDecl
-xmlValidateNCName
-xmlValidateNMToken
-xmlValidateName
-xmlValidateNameValue
-xmlValidateNamesValue
-xmlValidateNmtokenValue
-xmlValidateNmtokensValue
-xmlValidateNotationDecl
-xmlValidateNotationUse
-xmlValidateOneAttribute
-xmlValidateOneElement
-xmlValidateOneNamespace
-xmlValidatePopElement
-xmlValidatePushCData
-xmlValidatePushElement
-xmlValidateQName
-xmlValidateRoot
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeFreeContext
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeNewContext
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcess
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessFlags
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessFlagsData
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessNode
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessTree
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessTreeFlags
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeProcessTreeFlagsData
-#endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-xmlXIncludeSetFlags
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathAddValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathBooleanFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastBooleanToNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastBooleanToString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNodeSetToBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNodeSetToNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNodeSetToString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNodeToNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNodeToString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNumberToBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastNumberToString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastStringToBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastStringToNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastToBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastToNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCastToString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCeilingFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCmpNodes
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCompareValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCompile
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCompiledEval
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCompiledEvalToBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathConcatFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathContainsFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathContextSetCache
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathConvertBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathConvertNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathConvertString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCountFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathCtxtCompile
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-#ifdef LIBXML_DEBUG_ENABLED
-xmlXPathDebugDumpCompExpr
-#endif
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-#ifdef LIBXML_DEBUG_ENABLED
-xmlXPathDebugDumpObject
-#endif
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathDifference
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathDistinct
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathDistinctSorted
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathDivValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEqualValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathErr
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEval
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEvalExpr
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEvalExpression
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEvalPredicate
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathEvaluatePredicateResult
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFalseFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFloorFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeCompExpr
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeContext
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeNodeSet
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeNodeSetList
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeObject
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFreeParserContext
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFunctionLookup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathFunctionLookupNS
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathHasSameNodes
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathIdFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathInit
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathIntersection
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathIsInf
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathIsNaN
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathIsNodeType
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathLangFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathLastFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathLeading
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathLeadingSorted
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathLocalNameFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathModValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathMultValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNamespaceURIFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewCString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewContext
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewFloat
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewNodeSet
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewNodeSetList
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewParserContext
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNewValueTree
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextAncestor
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextAncestorOrSelf
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextAttribute
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextChild
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextDescendant
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextDescendantOrSelf
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextFollowing
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextFollowingSibling
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextNamespace
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextParent
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextPreceding
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextPrecedingSibling
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNextSelf
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeEval
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeLeading
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeLeadingSorted
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetAdd
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetAddNs
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetAddUnique
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetContains
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetCreate
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetDel
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetFreeNs
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetMerge
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetRemove
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeSetSort
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeTrailing
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNodeTrailingSorted
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNormalizeFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNotEqualValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNotFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNsLookup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathNumberFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathObjectCopy
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathOrderDocElems
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathParseNCName
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathParseName
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPopBoolean
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPopExternal
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPopNodeSet
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPopNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPopString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathPositionFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterAllFunctions
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterFunc
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterFuncLookup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterFuncNS
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterNs
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterVariable
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterVariableLookup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisterVariableNS
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisteredFuncsCleanup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisteredNsCleanup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRegisteredVariablesCleanup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRoot
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathRoundFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSetContextNode
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathStartsWithFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathStringEvalNumber
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathStringFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathStringLengthFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSubValues
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSubstringAfterFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSubstringBeforeFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSubstringFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathSumFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathTrailing
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathTrailingSorted
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathTranslateFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathTrueFunction
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathValueFlipSign
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathVariableLookup
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathVariableLookupNS
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathWrapCString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathWrapExternal
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathWrapNodeSet
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPathWrapString
-#endif
-#ifdef LIBXML_XPATH_ENABLED
-xmlXPatherror
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrBuildNodeList
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrEval
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrEvalRangePredicate
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrFreeLocationSet
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrLocationSetAdd
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrLocationSetCreate
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrLocationSetDel
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrLocationSetMerge
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrLocationSetRemove
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewCollapsedRange
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewContext
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewLocationSetNodeSet
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewLocationSetNodes
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRange
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRangeNodeObject
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRangeNodePoint
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRangeNodes
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRangePointNode
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrNewRangePoints
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrRangeToFunction
-#endif
-#ifdef LIBXML_XPTR_ENABLED
-xmlXPtrWrapLocationSet
-#endif
index 0c6b3f2..b658155 100644 (file)
 #include <libxml/parserInternals.h>
 #include <libxml/xmlerror.h>
 #include <libxml/encoding.h>
-#include <libxml/globals.h>
 
 #ifdef LIBXML_XINCLUDE_ENABLED
 #include <libxml/xinclude.h>
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/error.h"
+#include "private/tree.h"
+#include "private/xinclude.h"
 
 #define XINCLUDE_MAX_DEPTH 40
 
-/* #define DEBUG_XINCLUDE */
-#ifdef DEBUG_XINCLUDE
-#ifdef LIBXML_DEBUG_ENABLED
-#include <libxml/debugXML.h>
-#endif
-#endif
-
 /************************************************************************
  *                                                                     *
  *                     XInclude context handling                       *
@@ -54,45 +49,67 @@ typedef xmlXIncludeRef *xmlXIncludeRefPtr;
 struct _xmlXIncludeRef {
     xmlChar              *URI; /* the fully resolved resource URL */
     xmlChar         *fragment; /* the fragment in the URI */
-    xmlDocPtr            doc; /* the parsed document */
-    xmlNodePtr            ref; /* the node making the reference in the source */
+    xmlNodePtr           elem; /* the xi:include element */
     xmlNodePtr            inc; /* the included copy */
     int                   xml; /* xml or txt */
-    int                 count; /* how many refs use that specific doc */
     int                     fallback; /* fallback was loaded */
     int                      emptyFb; /* flag to show fallback empty */
+    int                    expanding; /* flag to detect inclusion loops */
+    int                      replace; /* should the node be replaced? */
+};
+
+typedef struct _xmlXIncludeDoc xmlXIncludeDoc;
+typedef xmlXIncludeDoc *xmlXIncludeDocPtr;
+struct _xmlXIncludeDoc {
+    xmlDocPtr             doc; /* the parsed document */
+    xmlChar              *url; /* the URL */
+    int             expanding; /* flag to detect inclusion loops */
+};
+
+typedef struct _xmlXIncludeTxt xmlXIncludeTxt;
+typedef xmlXIncludeTxt *xmlXIncludeTxtPtr;
+struct _xmlXIncludeTxt {
+    xmlChar            *text; /* text string */
+    xmlChar              *url; /* the URL */
 };
 
 struct _xmlXIncludeCtxt {
     xmlDocPtr             doc; /* the source document */
-    int               incBase; /* the first include for this document */
     int                 incNr; /* number of includes */
     int                incMax; /* size of includes tab */
     xmlXIncludeRefPtr *incTab; /* array of included references */
 
     int                 txtNr; /* number of unparsed documents */
     int                txtMax; /* size of unparsed documents tab */
-    xmlChar *         *txtTab; /* array of unparsed text strings */
-    xmlURL         *txturlTab; /* array of unparsed text URLs */
+    xmlXIncludeTxt    *txtTab; /* array of unparsed documents */
 
-    xmlChar *             url; /* the current URL processed */
-    int                 urlNr; /* number of URLs stacked */
-    int                urlMax; /* size of URL stack */
-    xmlChar *         *urlTab; /* URL stack */
+    int                 urlNr; /* number of documents stacked */
+    int                urlMax; /* size of document stack */
+    xmlXIncludeDoc    *urlTab; /* document stack */
 
     int              nbErrors; /* the number of errors detected */
+    int              fatalErr; /* abort processing */
     int                legacy; /* using XINCLUDE_OLD_NS */
     int            parseFlags; /* the flags used for parsing XML documents */
     xmlChar *           base; /* the current xml:base */
 
     void            *_private; /* application data */
 
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
     unsigned long    incTotal; /* total number of processed inclusions */
+#endif
+    int                        depth; /* recursion depth */
+    int                     isStream; /* streaming mode */
 };
 
+static xmlXIncludeRefPtr
+xmlXIncludeExpandNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node);
+
 static int
-xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree,
-                     int skipRoot);
+xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref);
+
+static int
+xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree);
 
 
 /************************************************************************
@@ -197,15 +214,6 @@ static void
 xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) {
     if (ref == NULL)
        return;
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Freeing ref\n");
-#endif
-    if (ref->doc != NULL) {
-#ifdef DEBUG_XINCLUDE
-       xmlGenericError(xmlGenericErrorContext, "Freeing doc %s\n", ref->URI);
-#endif
-       xmlFreeDoc(ref->doc);
-    }
     if (ref->URI != NULL)
        xmlFree(ref->URI);
     if (ref->fragment != NULL)
@@ -217,6 +225,7 @@ xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) {
  * xmlXIncludeNewRef:
  * @ctxt: the XInclude context
  * @URI:  the resource URI
+ * @elem:  the xi:include element
  *
  * Creates a new reference within an XInclude context
  *
@@ -224,15 +233,12 @@ xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) {
  */
 static xmlXIncludeRefPtr
 xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
-                 xmlNodePtr ref) {
+                 xmlNodePtr elem) {
     xmlXIncludeRefPtr ret;
 
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "New ref %s\n", URI);
-#endif
     ret = (xmlXIncludeRefPtr) xmlMalloc(sizeof(xmlXIncludeRef));
     if (ret == NULL) {
-        xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context");
+        xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
        return(NULL);
     }
     memset(ret, 0, sizeof(xmlXIncludeRef));
@@ -241,30 +247,26 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
     else
        ret->URI = xmlStrdup(URI);
     ret->fragment = NULL;
-    ret->ref = ref;
-    ret->doc = NULL;
-    ret->count = 0;
+    ret->elem = elem;
     ret->xml = 0;
     ret->inc = NULL;
-    if (ctxt->incMax == 0) {
-       ctxt->incMax = 4;
-        ctxt->incTab = (xmlXIncludeRefPtr *) xmlMalloc(ctxt->incMax *
-                                             sizeof(ctxt->incTab[0]));
-        if (ctxt->incTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context");
-           xmlXIncludeFreeRef(ret);
-           return(NULL);
-       }
-    }
     if (ctxt->incNr >= ctxt->incMax) {
-       ctxt->incMax *= 2;
-        ctxt->incTab = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
-                    ctxt->incMax * sizeof(ctxt->incTab[0]));
-        if (ctxt->incTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, ref, "growing XInclude context");
+        xmlXIncludeRefPtr *tmp;
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+        size_t newSize = ctxt->incMax ? ctxt->incMax * 2 : 1;
+#else
+        size_t newSize = ctxt->incMax ? ctxt->incMax * 2 : 4;
+#endif
+
+        tmp = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
+                    newSize * sizeof(ctxt->incTab[0]));
+        if (tmp == NULL) {
+           xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
            xmlXIncludeFreeRef(ret);
            return(NULL);
        }
+        ctxt->incTab = tmp;
+        ctxt->incMax = newSize;
     }
     ctxt->incTab[ctxt->incNr++] = ret;
     return(ret);
@@ -282,9 +284,6 @@ xmlXIncludeCtxtPtr
 xmlXIncludeNewContext(xmlDocPtr doc) {
     xmlXIncludeCtxtPtr ret;
 
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "New context\n");
-#endif
     if (doc == NULL)
        return(NULL);
     ret = (xmlXIncludeCtxtPtr) xmlMalloc(sizeof(xmlXIncludeCtxt));
@@ -296,7 +295,6 @@ xmlXIncludeNewContext(xmlDocPtr doc) {
     memset(ret, 0, sizeof(xmlXIncludeCtxt));
     ret->doc = doc;
     ret->incNr = 0;
-    ret->incBase = 0;
     ret->incMax = 0;
     ret->incTab = NULL;
     ret->nbErrors = 0;
@@ -304,73 +302,6 @@ xmlXIncludeNewContext(xmlDocPtr doc) {
 }
 
 /**
- * xmlXIncludeURLPush:
- * @ctxt:  the parser context
- * @value:  the url
- *
- * Pushes a new url on top of the url stack
- *
- * Returns -1 in case of error, the index in the stack otherwise
- */
-static int
-xmlXIncludeURLPush(xmlXIncludeCtxtPtr ctxt,
-                  const xmlChar *value)
-{
-    if (ctxt->urlNr > XINCLUDE_MAX_DEPTH) {
-       xmlXIncludeErr(ctxt, NULL, XML_XINCLUDE_RECURSION,
-                      "detected a recursion in %s\n", value);
-       return(-1);
-    }
-    if (ctxt->urlTab == NULL) {
-       ctxt->urlMax = 4;
-       ctxt->urlNr = 0;
-       ctxt->urlTab = (xmlChar * *) xmlMalloc(
-                       ctxt->urlMax * sizeof(ctxt->urlTab[0]));
-        if (ctxt->urlTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "adding URL");
-            return (-1);
-        }
-    }
-    if (ctxt->urlNr >= ctxt->urlMax) {
-        ctxt->urlMax *= 2;
-        ctxt->urlTab =
-            (xmlChar * *) xmlRealloc(ctxt->urlTab,
-                                      ctxt->urlMax *
-                                      sizeof(ctxt->urlTab[0]));
-        if (ctxt->urlTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "adding URL");
-            return (-1);
-        }
-    }
-    ctxt->url = ctxt->urlTab[ctxt->urlNr] = xmlStrdup(value);
-    return (ctxt->urlNr++);
-}
-
-/**
- * xmlXIncludeURLPop:
- * @ctxt: the parser context
- *
- * Pops the top URL from the URL stack
- */
-static void
-xmlXIncludeURLPop(xmlXIncludeCtxtPtr ctxt)
-{
-    xmlChar * ret;
-
-    if (ctxt->urlNr <= 0)
-        return;
-    ctxt->urlNr--;
-    if (ctxt->urlNr > 0)
-        ctxt->url = ctxt->urlTab[ctxt->urlNr - 1];
-    else
-        ctxt->url = NULL;
-    ret = ctxt->urlTab[ctxt->urlNr];
-    ctxt->urlTab[ctxt->urlNr] = NULL;
-    if (ret != NULL)
-       xmlFree(ret);
-}
-
-/**
  * xmlXIncludeFreeContext:
  * @ctxt: the XInclude context
  *
@@ -380,15 +311,15 @@ void
 xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
     int i;
 
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Freeing context\n");
-#endif
     if (ctxt == NULL)
        return;
-    while (ctxt->urlNr > 0)
-       xmlXIncludeURLPop(ctxt);
-    if (ctxt->urlTab != NULL)
+    if (ctxt->urlTab != NULL) {
+       for (i = 0; i < ctxt->urlNr; i++) {
+           xmlFreeDoc(ctxt->urlTab[i].doc);
+           xmlFree(ctxt->urlTab[i].url);
+       }
        xmlFree(ctxt->urlTab);
+    }
     for (i = 0;i < ctxt->incNr;i++) {
        if (ctxt->incTab[i] != NULL)
            xmlXIncludeFreeRef(ctxt->incTab[i]);
@@ -397,18 +328,11 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
        xmlFree(ctxt->incTab);
     if (ctxt->txtTab != NULL) {
        for (i = 0;i < ctxt->txtNr;i++) {
-           if (ctxt->txtTab[i] != NULL)
-               xmlFree(ctxt->txtTab[i]);
+           xmlFree(ctxt->txtTab[i].text);
+           xmlFree(ctxt->txtTab[i].url);
        }
        xmlFree(ctxt->txtTab);
     }
-    if (ctxt->txturlTab != NULL) {
-       for (i = 0;i < ctxt->txtNr;i++) {
-           if (ctxt->txturlTab[i] != NULL)
-               xmlFree(ctxt->txturlTab[i]);
-       }
-       xmlFree(ctxt->txturlTab);
-    }
     if (ctxt->base != NULL) {
         xmlFree(ctxt->base);
     }
@@ -494,7 +418,7 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
  *
  * Add a new node to process to an XInclude context
  */
-static int
+static xmlXIncludeRefPtr
 xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
     xmlXIncludeRefPtr ref;
     xmlURIPtr uri;
@@ -504,18 +428,15 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
     xmlChar *parse;
     xmlChar *base;
     xmlChar *URI;
-    int xml = 1, i; /* default Issue 64 */
+    int xml = 1;
     int local = 0;
 
 
     if (ctxt == NULL)
-       return(-1);
+       return(NULL);
     if (cur == NULL)
-       return(-1);
+       return(NULL);
 
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Add node\n");
-#endif
     /*
      * read the attributes
      */
@@ -523,7 +444,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
     if (href == NULL) {
        href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
        if (href == NULL)
-           return(-1);
+           return(NULL);
     }
     parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
     if (parse != NULL) {
@@ -538,7 +459,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
                xmlFree(href);
            if (parse != NULL)
                xmlFree(parse);
-           return(-1);
+           return(NULL);
        }
     }
 
@@ -574,7 +495,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
     if (URI == NULL) {
        xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI,
                       "failed build URL\n", NULL);
-       return(-1);
+       return(NULL);
     }
     fragment = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE_XPOINTER);
 
@@ -588,7 +509,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
        if (fragment != NULL)
            xmlFree(fragment);
        xmlFree(URI);
-       return(-1);
+       return(NULL);
     }
 
     if (uri->fragment != NULL) {
@@ -606,20 +527,21 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
                xmlFree(fragment);
            xmlFreeURI(uri);
            xmlFree(URI);
-           return(-1);
+           return(NULL);
        }
        uri->fragment = NULL;
     }
     URL = xmlSaveUri(uri);
     xmlFreeURI(uri);
-    xmlFree(URI);
     if (URL == NULL) {
        xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI,
                       "invalid value URI %s\n", URI);
        if (fragment != NULL)
            xmlFree(fragment);
-       return(-1);
+        xmlFree(URI);
+       return(NULL);
     }
+    xmlFree(URI);
 
     if (xmlStrEqual(URL, ctxt->doc->URL))
        local = 1;
@@ -634,34 +556,18 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
                       URL);
         xmlFree(URL);
         xmlFree(fragment);
-       return(-1);
-    }
-
-    /*
-     * Check the URL against the stack for recursions
-     */
-    if ((!local) && (xml == 1)) {
-       for (i = 0;i < ctxt->urlNr;i++) {
-           if (xmlStrEqual(URL, ctxt->urlTab[i])) {
-               xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
-                              "detected a recursion in %s\n", URL);
-                xmlFree(URL);
-                xmlFree(fragment);
-               return(-1);
-           }
-       }
+       return(NULL);
     }
 
     ref = xmlXIncludeNewRef(ctxt, URL, cur);
     xmlFree(URL);
     if (ref == NULL) {
-       return(-1);
+        xmlFree(fragment);
+       return(NULL);
     }
     ref->fragment = fragment;
-    ref->doc = NULL;
     ref->xml = xml;
-    ref->count = 1;
-    return(0);
+    return(ref);
 }
 
 /**
@@ -675,138 +581,35 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
 static void
 xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
                      const xmlURL url ATTRIBUTE_UNUSED) {
-    xmlXIncludeCtxtPtr newctxt;
+    xmlDocPtr oldDoc;
+    xmlXIncludeRefPtr *oldIncTab;
+    int oldIncMax, oldIncNr, oldIsStream;
     int i;
 
-    /*
-     * Avoid recursion in already substituted resources
-    for (i = 0;i < ctxt->urlNr;i++) {
-       if (xmlStrEqual(doc->URL, ctxt->urlTab[i]))
-           return;
-    }
-     */
-
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Recursing in doc %s\n", doc->URL);
-#endif
-    /*
-     * Handle recursion here.
-     */
-
-    newctxt = xmlXIncludeNewContext(doc);
-    if (newctxt != NULL) {
-       /*
-        * Copy the private user data
-        */
-       newctxt->_private = ctxt->_private;
-       /*
-        * Copy the existing document set
-        */
-       newctxt->incMax = ctxt->incMax;
-       newctxt->incNr = ctxt->incNr;
-        newctxt->incTab = (xmlXIncludeRefPtr *) xmlMalloc(newctxt->incMax *
-                                         sizeof(newctxt->incTab[0]));
-        if (newctxt->incTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, (xmlNodePtr) doc, "processing doc");
-           xmlFree(newctxt);
-           return;
-       }
-       /*
-        * copy the urlTab
-        */
-       newctxt->urlMax = ctxt->urlMax;
-       newctxt->urlNr = ctxt->urlNr;
-       newctxt->urlTab = ctxt->urlTab;
-
-       /*
-        * Inherit the existing base
-        */
-       newctxt->base = xmlStrdup(ctxt->base);
-
-       /*
-        * Inherit the documents already in use by other includes
-        */
-       newctxt->incBase = ctxt->incNr;
-       for (i = 0;i < ctxt->incNr;i++) {
-           newctxt->incTab[i] = ctxt->incTab[i];
-           newctxt->incTab[i]->count++; /* prevent the recursion from
-                                           freeing it */
-       }
-       /*
-        * The new context should also inherit the Parse Flags
-        * (bug 132597)
-        */
-       newctxt->parseFlags = ctxt->parseFlags;
-        newctxt->incTotal = ctxt->incTotal;
-       xmlXIncludeDoProcess(newctxt, doc, xmlDocGetRootElement(doc), 0);
-        ctxt->incTotal = newctxt->incTotal;
-       for (i = 0;i < ctxt->incNr;i++) {
-           newctxt->incTab[i]->count--;
-           newctxt->incTab[i] = NULL;
-       }
-
-       /* urlTab may have been reallocated */
-       ctxt->urlTab = newctxt->urlTab;
-       ctxt->urlMax = newctxt->urlMax;
-
-       newctxt->urlMax = 0;
-       newctxt->urlNr = 0;
-       newctxt->urlTab = NULL;
-
-       xmlXIncludeFreeContext(newctxt);
-    }
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Done recursing in doc %s\n", url);
-#endif
-}
-
-/**
- * xmlXIncludeAddTxt:
- * @ctxt:  the XInclude context
- * @txt:  the new text node
- * @url:  the associated URL
- *
- * Add a new text node to the list
- */
-static void
-xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *txt,
-                  const xmlURL url) {
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Adding text %s\n", url);
-#endif
-    if (ctxt->txtMax == 0) {
-       ctxt->txtMax = 4;
-        ctxt->txtTab = (xmlChar **) xmlMalloc(ctxt->txtMax *
-                                         sizeof(ctxt->txtTab[0]));
-        if (ctxt->txtTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "processing text");
-           return;
-       }
-        ctxt->txturlTab = (xmlURL *) xmlMalloc(ctxt->txtMax *
-                                         sizeof(ctxt->txturlTab[0]));
-        if (ctxt->txturlTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "processing text");
-           return;
-       }
-    }
-    if (ctxt->txtNr >= ctxt->txtMax) {
-       ctxt->txtMax *= 2;
-        ctxt->txtTab = (xmlChar **) xmlRealloc(ctxt->txtTab,
-                    ctxt->txtMax * sizeof(ctxt->txtTab[0]));
-        if (ctxt->txtTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "processing text");
-           return;
-       }
-        ctxt->txturlTab = (xmlURL *) xmlRealloc(ctxt->txturlTab,
-                    ctxt->txtMax * sizeof(ctxt->txturlTab[0]));
-        if (ctxt->txturlTab == NULL) {
-           xmlXIncludeErrMemory(ctxt, NULL, "processing text");
-           return;
-       }
-    }
-    ctxt->txtTab[ctxt->txtNr] = xmlStrdup(txt);
-    ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url);
-    ctxt->txtNr++;
+    oldDoc = ctxt->doc;
+    oldIncMax = ctxt->incMax;
+    oldIncNr = ctxt->incNr;
+    oldIncTab = ctxt->incTab;
+    oldIsStream = ctxt->isStream;
+    ctxt->doc = doc;
+    ctxt->incMax = 0;
+    ctxt->incNr = 0;
+    ctxt->incTab = NULL;
+    ctxt->isStream = 0;
+
+    xmlXIncludeDoProcess(ctxt, xmlDocGetRootElement(doc));
+
+    if (ctxt->incTab != NULL) {
+        for (i = 0; i < ctxt->incNr; i++)
+            xmlXIncludeFreeRef(ctxt->incTab[i]);
+        xmlFree(ctxt->incTab);
+    }
+
+    ctxt->doc = oldDoc;
+    ctxt->incMax = oldIncMax;
+    ctxt->incNr = oldIncNr;
+    ctxt->incTab = oldIncTab;
+    ctxt->isStream = oldIsStream;
 }
 
 /************************************************************************
@@ -815,70 +618,107 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *txt,
  *                                                                     *
  ************************************************************************/
 
-static xmlNodePtr
-xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
-                       xmlDocPtr source, xmlNodePtr elem);
-
 /**
  * xmlXIncludeCopyNode:
  * @ctxt:  the XInclude context
- * @target:  the document target
- * @source:  the document source
  * @elem:  the element
+ * @copyChildren:  copy children instead of node if true
  *
- * Make a copy of the node while preserving the XInclude semantic
- * of the Infoset copy
+ * Make a copy of the node while expanding nested XIncludes.
+ *
+ * Returns a node list, not a single node.
  */
 static xmlNodePtr
-xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
-                   xmlDocPtr source, xmlNodePtr elem) {
+xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr elem,
+                    int copyChildren) {
     xmlNodePtr result = NULL;
+    xmlNodePtr insertParent = NULL;
+    xmlNodePtr insertLast = NULL;
+    xmlNodePtr cur;
 
-    if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
-       (elem == NULL))
-       return(NULL);
-    if (elem->type == XML_DTD_NODE)
-       return(NULL);
-    if (elem->type == XML_DOCUMENT_NODE)
-       result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children);
-    else
-        result = xmlDocCopyNode(elem, target, 1);
-    return(result);
-}
+    if (copyChildren) {
+        cur = elem->children;
+        if (cur == NULL)
+            return(NULL);
+    } else {
+        cur = elem;
+    }
 
-/**
- * xmlXIncludeCopyNodeList:
- * @ctxt:  the XInclude context
- * @target:  the document target
- * @source:  the document source
- * @elem:  the element list
- *
- * Make a copy of the node list while preserving the XInclude semantic
- * of the Infoset copy
- */
-static xmlNodePtr
-xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
-                       xmlDocPtr source, xmlNodePtr elem) {
-    xmlNodePtr cur, res, result = NULL, last = NULL;
+    while (1) {
+        xmlNodePtr copy = NULL;
+        int recurse = 0;
 
-    if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
-       (elem == NULL))
-       return(NULL);
-    cur = elem;
-    while (cur != NULL) {
-       res = xmlXIncludeCopyNode(ctxt, target, source, cur);
-       if (res != NULL) {
-           if (result == NULL) {
-               result = last = res;
-           } else {
-               last->next = res;
-               res->prev = last;
-               last = res;
-           }
-       }
-       cur = cur->next;
+        if ((cur->type == XML_DOCUMENT_NODE) ||
+            (cur->type == XML_DTD_NODE)) {
+            ;
+        } else if ((cur->type == XML_ELEMENT_NODE) &&
+                   (cur->ns != NULL) &&
+                   (xmlStrEqual(cur->name, XINCLUDE_NODE)) &&
+                   ((xmlStrEqual(cur->ns->href, XINCLUDE_NS)) ||
+                    (xmlStrEqual(cur->ns->href, XINCLUDE_OLD_NS)))) {
+            xmlXIncludeRefPtr ref = xmlXIncludeExpandNode(ctxt, cur);
+
+            if (ref == NULL)
+                goto error;
+            /*
+             * TODO: Insert XML_XINCLUDE_START and XML_XINCLUDE_END nodes
+             */
+            if (ref->inc != NULL) {
+                copy = xmlStaticCopyNodeList(ref->inc, ctxt->doc,
+                                             insertParent);
+                if (copy == NULL)
+                    goto error;
+            }
+        } else {
+            copy = xmlStaticCopyNode(cur, ctxt->doc, insertParent, 2);
+            if (copy == NULL)
+                goto error;
+
+            recurse = (cur->type != XML_ENTITY_REF_NODE) &&
+                      (cur->children != NULL);
+        }
+
+        if (copy != NULL) {
+            if (result == NULL)
+                result = copy;
+            if (insertLast != NULL) {
+                insertLast->next = copy;
+                copy->prev = insertLast;
+            } else if (insertParent != NULL) {
+                insertParent->children = copy;
+            }
+            insertLast = copy;
+            while (insertLast->next != NULL) {
+                insertLast = insertLast->next;
+            }
+        }
+
+        if (recurse) {
+            cur = cur->children;
+            insertParent = insertLast;
+            insertLast = NULL;
+            continue;
+        }
+
+        if (cur == elem)
+            return(result);
+
+        while (cur->next == NULL) {
+            if (insertParent != NULL)
+                insertParent->last = insertLast;
+            cur = cur->parent;
+            if (cur == elem)
+                return(result);
+            insertLast = insertParent;
+            insertParent = insertParent->parent;
+        }
+
+        cur = cur->next;
     }
-    return(result);
+
+error:
+    xmlFreeNodeList(result);
+    return(NULL);
 }
 
 #ifdef LIBXML_XPTR_LOCS_ENABLED
@@ -913,8 +753,6 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */
 /**
  * xmlXIncludeCopyRange:
  * @ctxt:  the XInclude context
- * @target:  the document target
- * @source:  the document source
  * @obj:  the XPointer result from the evaluation.
  *
  * Build a node list tree copy of the XPointer result.
@@ -923,8 +761,7 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */
  *         The caller has to free the node tree.
  */
 static xmlNodePtr
-xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
-                       xmlDocPtr source, xmlXPathObjectPtr range) {
+xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr range) {
     /* pointers to generated nodes */
     xmlNodePtr list = NULL, last = NULL, listParent = NULL;
     xmlNodePtr tmp, tmp2;
@@ -933,8 +770,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
     int index1, index2;
     int level = 0, lastLevel = 0, endLevel = 0, endFlag = 0;
 
-    if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
-       (range == NULL))
+    if ((ctxt == NULL) || (range == NULL))
        return(NULL);
     if (range->type != XPATH_RANGE)
        return(NULL);
@@ -944,7 +780,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
        return(NULL);
     end = range->user2;
     if (end == NULL)
-       return(xmlDocCopyNode(start, target, 1));
+       return(xmlDocCopyNode(start, ctxt->doc, 1));
     if (end->type == XML_NAMESPACE_DECL)
         return(NULL);
 
@@ -966,7 +802,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
        if (level < 0) {
            while (level < 0) {
                /* copy must include namespaces and properties */
-               tmp2 = xmlDocCopyNode(listParent, target, 2);
+               tmp2 = xmlDocCopyNode(listParent, ctxt->doc, 2);
                xmlAddChild(tmp2, list);
                list = tmp2;
                listParent = listParent->parent;
@@ -988,7 +824,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                int len;
 
                if (content == NULL) {
-                   tmp = xmlNewDocTextLen(target, NULL, 0);
+                   tmp = xmlNewDocTextLen(ctxt->doc, NULL, 0);
                } else {
                    len = index2;
                    if ((cur == start) && (index1 > 1)) {
@@ -997,7 +833,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                    } else {
                        len = index2;
                    }
-                   tmp = xmlNewDocTextLen(target, content, len);
+                   tmp = xmlNewDocTextLen(ctxt->doc, content, len);
                }
                /* single sub text node selection */
                if (list == NULL)
@@ -1012,7 +848,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                endLevel = level;       /* remember the level of the end node */
                endFlag = 1;
                /* last node - need to take care of properties + namespaces */
-               tmp = xmlDocCopyNode(cur, target, 2);
+               tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
                if (list == NULL) {
                    list = tmp;
                    listParent = cur->parent;
@@ -1048,13 +884,13 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                const xmlChar *content = cur->content;
 
                if (content == NULL) {
-                   tmp = xmlNewDocTextLen(target, NULL, 0);
+                   tmp = xmlNewDocTextLen(ctxt->doc, NULL, 0);
                } else {
                    if (index1 > 1) {
                        content += (index1 - 1);
                        index1 = 0;
                    }
-                   tmp = xmlNewDocText(target, content);
+                   tmp = xmlNewDocText(ctxt->doc, content);
                }
                last = list = tmp;
                listParent = cur->parent;
@@ -1063,7 +899,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                 * start of the range - need to take care of
                 * properties and namespaces
                 */
-               tmp = xmlDocCopyNode(cur, target, 2);
+               tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
                list = last = tmp;
                listParent = cur->parent;
                if (index1 > 1) {       /* Do we need to position? */
@@ -1100,7 +936,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                     * Middle of the range - need to take care of
                     * properties and namespaces
                     */
-                   tmp = xmlDocCopyNode(cur, target, 2);
+                   tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
                    break;
            }
            if (tmp != NULL) {
@@ -1124,10 +960,8 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
 #endif /* LIBXML_XPTR_LOCS_ENABLED */
 
 /**
- * xmlXIncludeBuildNodeList:
+ * xmlXIncludeCopyXPointer:
  * @ctxt:  the XInclude context
- * @target:  the document target
- * @source:  the document source
  * @obj:  the XPointer result from the evaluation.
  *
  * Build a node list tree copy of the XPointer result.
@@ -1137,15 +971,11 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
  *         the caller has to free the node tree.
  */
 static xmlNodePtr
-xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
-                       xmlDocPtr source, xmlXPathObjectPtr obj) {
-    xmlNodePtr list = NULL, last = NULL;
+xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr obj) {
+    xmlNodePtr list = NULL, last = NULL, copy;
     int i;
 
-    if (source == NULL)
-       source = ctxt->doc;
-    if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
-       (obj == NULL))
+    if ((ctxt == NULL) || (obj == NULL))
        return(NULL);
     switch (obj->type) {
         case XPATH_NODESET: {
@@ -1153,70 +983,56 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
            if (set == NULL)
                return(NULL);
            for (i = 0;i < set->nodeNr;i++) {
+                xmlNodePtr node;
+
                if (set->nodeTab[i] == NULL)
                    continue;
                switch (set->nodeTab[i]->type) {
+                   case XML_DOCUMENT_NODE:
+                   case XML_HTML_DOCUMENT_NODE:
+                        node = xmlDocGetRootElement(
+                                (xmlDocPtr) set->nodeTab[i]);
+                        if (node == NULL) {
+                            xmlXIncludeErr(ctxt, set->nodeTab[i],
+                                           XML_ERR_INTERNAL_ERROR,
+                                           "document without root\n", NULL);
+                            continue;
+                        }
+                        break;
                    case XML_TEXT_NODE:
                    case XML_CDATA_SECTION_NODE:
                    case XML_ELEMENT_NODE:
-                   case XML_ENTITY_REF_NODE:
-                   case XML_ENTITY_NODE:
                    case XML_PI_NODE:
                    case XML_COMMENT_NODE:
-                   case XML_DOCUMENT_NODE:
-                   case XML_HTML_DOCUMENT_NODE:
-                   case XML_XINCLUDE_END:
+                        node = set->nodeTab[i];
                        break;
-                   case XML_XINCLUDE_START: {
-                       xmlNodePtr tmp, cur = set->nodeTab[i];
-
-                       cur = cur->next;
-                       while (cur != NULL) {
-                           switch(cur->type) {
-                               case XML_TEXT_NODE:
-                               case XML_CDATA_SECTION_NODE:
-                               case XML_ELEMENT_NODE:
-                               case XML_ENTITY_REF_NODE:
-                               case XML_ENTITY_NODE:
-                               case XML_PI_NODE:
-                               case XML_COMMENT_NODE:
-                                   tmp = xmlXIncludeCopyNode(ctxt, target,
-                                                             source, cur);
-                                   if (last == NULL) {
-                                       list = last = tmp;
-                                   } else {
-                                       last = xmlAddNextSibling(last, tmp);
-                                   }
-                                   cur = cur->next;
-                                   continue;
-                               default:
-                                   break;
-                           }
-                           break;
-                       }
-                       continue;
-                   }
-                   case XML_ATTRIBUTE_NODE:
-                   case XML_NAMESPACE_DECL:
-                   case XML_DOCUMENT_TYPE_NODE:
-                   case XML_DOCUMENT_FRAG_NODE:
-                   case XML_NOTATION_NODE:
-                   case XML_DTD_NODE:
-                   case XML_ELEMENT_DECL:
-                   case XML_ATTRIBUTE_DECL:
-                   case XML_ENTITY_DECL:
+                    default:
+                        xmlXIncludeErr(ctxt, set->nodeTab[i],
+                                       XML_XINCLUDE_XPTR_RESULT,
+                                       "invalid node type in XPtr result\n",
+                                       NULL);
                        continue; /* for */
                }
-               if (last == NULL)
-                   list = last = xmlXIncludeCopyNode(ctxt, target, source,
-                                                     set->nodeTab[i]);
-               else {
-                   xmlAddNextSibling(last,
-                           xmlXIncludeCopyNode(ctxt, target, source,
-                                               set->nodeTab[i]));
-                   if (last->next != NULL)
-                       last = last->next;
+                /*
+                 * OPTIMIZE TODO: External documents should already be
+                 * expanded, so xmlDocCopyNode should work as well.
+                 * xmlXIncludeCopyNode is only required for the initial
+                 * document.
+                 */
+               copy = xmlXIncludeCopyNode(ctxt, node, 0);
+                if (copy == NULL) {
+                    xmlFreeNodeList(list);
+                    return(NULL);
+                }
+               if (last == NULL) {
+                    list = copy;
+                } else {
+                    while (last->next != NULL)
+                        last = last->next;
+                    copy->prev = last;
+                    last->next = copy;
                }
+                last = copy;
            }
            break;
        }
@@ -1227,12 +1043,11 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
                return(NULL);
            for (i = 0;i < set->locNr;i++) {
                if (last == NULL)
-                   list = last = xmlXIncludeCopyXPointer(ctxt, target, source,
+                   list = last = xmlXIncludeCopyXPointer(ctxt,
                                                          set->locTab[i]);
                else
                    xmlAddNextSibling(last,
-                           xmlXIncludeCopyXPointer(ctxt, target, source,
-                                                   set->locTab[i]));
+                           xmlXIncludeCopyXPointer(ctxt, set->locTab[i]));
                if (last != NULL) {
                    while (last->next != NULL)
                        last = last->next;
@@ -1241,7 +1056,7 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
            break;
        }
        case XPATH_RANGE:
-           return(xmlXIncludeCopyRange(ctxt, target, source, obj));
+           return(xmlXIncludeCopyRange(ctxt, obj));
        case XPATH_POINT:
            /* points are ignored in XInclude */
            break;
@@ -1268,7 +1083,7 @@ struct _xmlXIncludeMergeData {
  * xmlXIncludeMergeOneEntity:
  * @ent: the entity
  * @doc:  the including doc
- * @nr: the entity name
+ * @name: the entity name
  *
  * Implements the merge of one entity
  */
@@ -1406,59 +1221,50 @@ xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
  * xmlXIncludeLoadDoc:
  * @ctxt:  the XInclude context
  * @url:  the associated URL
- * @nr:  the xinclude node number
+ * @ref:  an XMLXincludeRefPtr
  *
  * Load the document, and store the result in the XInclude context
  *
  * Returns 0 in case of success, -1 in case of failure
  */
 static int
-xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
+xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
+                   xmlXIncludeRefPtr ref) {
+    xmlXIncludeDocPtr cache;
     xmlDocPtr doc;
     xmlURIPtr uri;
-    xmlChar *URL;
+    xmlChar *URL = NULL;
     xmlChar *fragment = NULL;
     int i = 0;
+    int ret = -1;
+    int cacheNr;
 #ifdef LIBXML_XPTR_ENABLED
     int saveFlags;
 #endif
 
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "Loading doc %s:%d\n", url, nr);
-#endif
     /*
      * Check the URL and remove any fragment identifier
      */
     uri = xmlParseURI((const char *)url);
     if (uri == NULL) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                      XML_XINCLUDE_HREF_URI,
+       xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_HREF_URI,
                       "invalid value URI %s\n", url);
-       return(-1);
+        goto error;
     }
     if (uri->fragment != NULL) {
        fragment = (xmlChar *) uri->fragment;
        uri->fragment = NULL;
     }
-    if ((ctxt->incTab != NULL) && (ctxt->incTab[nr] != NULL) &&
-        (ctxt->incTab[nr]->fragment != NULL)) {
+    if (ref->fragment != NULL) {
        if (fragment != NULL) xmlFree(fragment);
-       fragment = xmlStrdup(ctxt->incTab[nr]->fragment);
+       fragment = xmlStrdup(ref->fragment);
     }
     URL = xmlSaveUri(uri);
     xmlFreeURI(uri);
     if (URL == NULL) {
-        if (ctxt->incTab != NULL)
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_HREF_URI,
-                          "invalid value URI %s\n", url);
-       else
-           xmlXIncludeErr(ctxt, NULL,
-                          XML_XINCLUDE_HREF_URI,
-                          "invalid value URI %s\n", url);
-       if (fragment != NULL)
-           xmlFree(fragment);
-       return(-1);
+        xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_HREF_URI,
+                       "invalid value URI %s\n", url);
+        goto error;
     }
 
     /*
@@ -1472,15 +1278,18 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
     }
 
     /*
-     * Prevent reloading twice the document.
+     * Prevent reloading the document twice.
      */
-    for (i = 0; i < ctxt->incNr; i++) {
-       if ((xmlStrEqual(URL, ctxt->incTab[i]->URI)) &&
-           (ctxt->incTab[i]->doc != NULL)) {
-           doc = ctxt->incTab[i]->doc;
-#ifdef DEBUG_XINCLUDE
-           printf("Already loaded %s\n", URL);
-#endif
+    for (i = 0; i < ctxt->urlNr; i++) {
+       if (xmlStrEqual(URL, ctxt->urlTab[i].url)) {
+            if (ctxt->urlTab[i].expanding) {
+                xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_RECURSION,
+                               "inclusion loop detected\n", NULL);
+                goto error;
+            }
+           doc = ctxt->urlTab[i].doc;
+            if (doc == NULL)
+                goto error;
            goto loaded;
        }
     }
@@ -1488,9 +1297,6 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
     /*
      * Load it.
      */
-#ifdef DEBUG_XINCLUDE
-    printf("loading %s\n", URL);
-#endif
 #ifdef LIBXML_XPTR_ENABLED
     /*
      * If this is an XPointer evaluation, we want to assure that
@@ -1507,13 +1313,34 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
 #ifdef LIBXML_XPTR_ENABLED
     ctxt->parseFlags = saveFlags;
 #endif
-    if (doc == NULL) {
-       xmlFree(URL);
-       if (fragment != NULL)
-           xmlFree(fragment);
-       return(-1);
+
+    /* Also cache NULL docs */
+    if (ctxt->urlNr >= ctxt->urlMax) {
+        xmlXIncludeDoc *tmp;
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+        size_t newSize = ctxt->urlMax ? ctxt->urlMax * 2 : 1;
+#else
+        size_t newSize = ctxt->urlMax ? ctxt->urlMax * 2 : 8;
+#endif
+
+        tmp = xmlRealloc(ctxt->urlTab, sizeof(xmlXIncludeDoc) * newSize);
+        if (tmp == NULL) {
+            xmlXIncludeErrMemory(ctxt, ref->elem,
+                                 "growing XInclude URL table");
+            xmlFreeDoc(doc);
+            goto error;
+        }
+        ctxt->urlMax = newSize;
+        ctxt->urlTab = tmp;
     }
-    ctxt->incTab[nr]->doc = doc;
+    cacheNr = ctxt->urlNr++;
+    cache = &ctxt->urlTab[cacheNr];
+    cache->doc = doc;
+    cache->url = xmlStrdup(URL);
+    cache->expanding = 0;
+
+    if (doc == NULL)
+        goto error;
     /*
      * It's possible that the requested URL has been mapped to a
      * completely different location (e.g. through a catalog entry).
@@ -1524,15 +1351,6 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
        xmlFree(URL);
        URL = xmlStrdup(doc->URL);
    }
-    for (i = nr + 1; i < ctxt->incNr; i++) {
-       if (xmlStrEqual(URL, ctxt->incTab[i]->URI)) {
-           ctxt->incTab[nr]->count++;
-#ifdef DEBUG_XINCLUDE
-           printf("Increasing %s count since reused\n", URL);
-#endif
-            break;
-       }
-    }
 
     /*
      * Make sure we have all entities fixed up
@@ -1552,15 +1370,18 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
        doc->extSubset = NULL;
     }
      */
+    cache->expanding = 1;
     xmlXIncludeRecurseDoc(ctxt, doc, URL);
+    /* urlTab might be reallocated. */
+    cache = &ctxt->urlTab[cacheNr];
+    cache->expanding = 0;
 
 loaded:
     if (fragment == NULL) {
        /*
         * Add the top children list as the replacement copy.
         */
-       ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc,
-                                                       doc, doc->children);
+        ref->inc = xmlDocCopyNode(xmlDocGetRootElement(doc), ctxt->doc, 1);
     }
 #ifdef LIBXML_XPTR_ENABLED
     else {
@@ -1572,25 +1393,26 @@ loaded:
        xmlXPathContextPtr xptrctxt;
        xmlNodeSetPtr set;
 
+        if (ctxt->isStream && doc == ctxt->doc) {
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_XPTR_FAILED,
+                          "XPointer expressions not allowed in streaming"
+                           " mode\n", NULL);
+            goto error;
+        }
+
        xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
        if (xptrctxt == NULL) {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_XPTR_FAILED,
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_XPTR_FAILED,
                           "could not create XPointer context\n", NULL);
-           xmlFree(URL);
-           xmlFree(fragment);
-           return(-1);
+            goto error;
        }
        xptr = xmlXPtrEval(fragment, xptrctxt);
        if (xptr == NULL) {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_XPTR_FAILED,
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_XPTR_FAILED,
                           "XPointer evaluation failed: #%s\n",
                           fragment);
            xmlXPathFreeContext(xptrctxt);
-           xmlFree(URL);
-           xmlFree(fragment);
-           return(-1);
+            goto error;
        }
        switch (xptr->type) {
            case XPATH_UNDEFINED:
@@ -1602,23 +1424,18 @@ loaded:
 #endif
            case XPATH_USERS:
            case XPATH_XSLT_TREE:
-               xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                              XML_XINCLUDE_XPTR_RESULT,
+               xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_XPTR_RESULT,
                               "XPointer is not a range: #%s\n",
                               fragment);
                 xmlXPathFreeObject(xptr);
                xmlXPathFreeContext(xptrctxt);
-               xmlFree(URL);
-               xmlFree(fragment);
-               return(-1);
+                goto error;
            case XPATH_NODESET:
                if ((xptr->nodesetval == NULL) ||
                    (xptr->nodesetval->nodeNr <= 0)) {
                     xmlXPathFreeObject(xptr);
                    xmlXPathFreeContext(xptrctxt);
-                   xmlFree(URL);
-                   xmlFree(fragment);
-                   return(-1);
+                    goto error;
                }
 
 #ifdef LIBXML_XPTR_LOCS_ENABLED
@@ -1645,14 +1462,14 @@ loaded:
                        continue;
 
                    case XML_ATTRIBUTE_NODE:
-                       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+                       xmlXIncludeErr(ctxt, ref->elem,
                                       XML_XINCLUDE_XPTR_RESULT,
                                       "XPointer selects an attribute: #%s\n",
                                       fragment);
                        set->nodeTab[i] = NULL;
                        continue;
                    case XML_NAMESPACE_DECL:
-                       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+                       xmlXIncludeErr(ctxt, ref->elem,
                                       XML_XINCLUDE_XPTR_RESULT,
                                       "XPointer selects a namespace: #%s\n",
                                       fragment);
@@ -1667,7 +1484,7 @@ loaded:
                    case XML_ENTITY_DECL:
                    case XML_XINCLUDE_START:
                    case XML_XINCLUDE_END:
-                       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+                       xmlXIncludeErr(ctxt, ref->elem,
                                       XML_XINCLUDE_XPTR_RESULT,
                                   "XPointer selects unexpected nodes: #%s\n",
                                       fragment);
@@ -1677,11 +1494,9 @@ loaded:
                }
            }
        }
-        ctxt->incTab[nr]->inc =
-            xmlXIncludeCopyXPointer(ctxt, ctxt->doc, doc, xptr);
+        ref->inc = xmlXIncludeCopyXPointer(ctxt, xptr);
         xmlXPathFreeObject(xptr);
        xmlXPathFreeContext(xptrctxt);
-       xmlFree(fragment);
     }
 #endif
 
@@ -1699,8 +1514,7 @@ loaded:
         * The base is only adjusted if "necessary", i.e. if the xinclude node
         * has a base specified, or the URL is relative
         */
-       base = xmlGetNsProp(ctxt->incTab[nr]->ref, BAD_CAST "base",
-                       XML_XML_NAMESPACE);
+       base = xmlGetNsProp(ref->elem, BAD_CAST "base", XML_XML_NAMESPACE);
        if (base == NULL) {
            /*
             * No xml:base on the xinclude node, so we check whether the
@@ -1708,19 +1522,18 @@ loaded:
             */
            curBase = xmlBuildRelativeURI(URL, ctxt->base);
            if (curBase == NULL) {      /* Error return */
-               xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                      XML_XINCLUDE_HREF_URI,
+               xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_HREF_URI,
                       "trying to build relative URI from %s\n", URL);
            } else {
                /* If the URI doesn't contain a slash, it's not relative */
-               if (!xmlStrchr(curBase, (xmlChar) '/'))
+               if (!xmlStrchr(curBase, '/'))
                    xmlFree(curBase);
                else
                    base = curBase;
            }
        }
        if (base != NULL) {     /* Adjustment may be needed */
-           node = ctxt->incTab[nr]->inc;
+           node = ref->inc;
            while (node != NULL) {
                /* Only work on element nodes */
                if (node->type == XML_ELEMENT_NODE) {
@@ -1750,7 +1563,7 @@ loaded:
                                relBase = xmlBuildURI(xmlBase, base);
                                if (relBase == NULL) { /* error */
                                    xmlXIncludeErr(ctxt,
-                                               ctxt->incTab[nr]->ref,
+                                               ref->elem,
                                                XML_XINCLUDE_HREF_URI,
                                        "trying to rebuild base from %s\n",
                                                xmlBase);
@@ -1769,40 +1582,40 @@ loaded:
            xmlFree(base);
        }
     }
-    if ((nr < ctxt->incNr) && (ctxt->incTab[nr]->doc != NULL) &&
-       (ctxt->incTab[nr]->count <= 1)) {
-#ifdef DEBUG_XINCLUDE
-        printf("freeing %s\n", ctxt->incTab[nr]->doc->URL);
-#endif
-       xmlFreeDoc(ctxt->incTab[nr]->doc);
-       ctxt->incTab[nr]->doc = NULL;
-    }
+    ret = 0;
+
+error:
     xmlFree(URL);
-    return(0);
+    xmlFree(fragment);
+    return(ret);
 }
 
 /**
  * xmlXIncludeLoadTxt:
  * @ctxt:  the XInclude context
  * @url:  the associated URL
- * @nr:  the xinclude node number
+ * @ref:  an XMLXincludeRefPtr
  *
  * Load the content, and store the result in the XInclude context
  *
  * Returns 0 in case of success, -1 in case of failure
  */
 static int
-xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
+xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
+                   xmlXIncludeRefPtr ref) {
     xmlParserInputBufferPtr buf;
-    xmlNodePtr node;
-    xmlURIPtr uri;
-    xmlChar *URL;
+    xmlNodePtr node = NULL;
+    xmlURIPtr uri = NULL;
+    xmlChar *URL = NULL;
     int i;
+    int ret = -1;
     xmlChar *encoding = NULL;
     xmlCharEncoding enc = (xmlCharEncoding) 0;
-    xmlParserCtxtPtr pctxt;
-    xmlParserInputPtr inputStream;
-    int xinclude_multibyte_fallback_used = 0;
+    xmlParserCtxtPtr pctxt = NULL;
+    xmlParserInputPtr inputStream = NULL;
+    int len;
+    const xmlChar *content;
+
 
     /* Don't read from stdin. */
     if (xmlStrcmp(url, BAD_CAST "-") == 0)
@@ -1813,23 +1626,21 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
      */
     uri = xmlParseURI((const char *)url);
     if (uri == NULL) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI,
+       xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_HREF_URI,
                       "invalid value URI %s\n", url);
-       return(-1);
+       goto error;
     }
     if (uri->fragment != NULL) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_TEXT_FRAGMENT,
+       xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_TEXT_FRAGMENT,
                       "fragment identifier forbidden for text: %s\n",
                       (const xmlChar *) uri->fragment);
-       xmlFreeURI(uri);
-       return(-1);
+       goto error;
     }
     URL = xmlSaveUri(uri);
-    xmlFreeURI(uri);
     if (URL == NULL) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_HREF_URI,
+       xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_HREF_URI,
                       "invalid value URI %s\n", url);
-       return(-1);
+       goto error;
     }
 
     /*
@@ -1837,27 +1648,26 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
      * directly through ctxt->doc.
      */
     if (URL[0] == 0) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                      XML_XINCLUDE_TEXT_DOCUMENT,
+       xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_TEXT_DOCUMENT,
                       "text serialization of document not available\n", NULL);
-       xmlFree(URL);
-       return(-1);
+       goto error;
     }
 
     /*
-     * Prevent reloading twice the document.
+     * Prevent reloading the document twice.
      */
     for (i = 0; i < ctxt->txtNr; i++) {
-       if (xmlStrEqual(URL, ctxt->txturlTab[i])) {
-            node = xmlNewDocText(ctxt->doc, ctxt->txtTab[i]);
+       if (xmlStrEqual(URL, ctxt->txtTab[i].url)) {
+            node = xmlNewDocText(ctxt->doc, ctxt->txtTab[i].text);
            goto loaded;
        }
     }
+
     /*
      * Try to get the encoding if available
      */
-    if ((ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->ref != NULL)) {
-       encoding = xmlGetProp(ctxt->incTab[nr]->ref, XINCLUDE_PARSE_ENCODING);
+    if (ref->elem != NULL) {
+       encoding = xmlGetProp(ref->elem, XINCLUDE_PARSE_ENCODING);
     }
     if (encoding != NULL) {
        /*
@@ -1868,14 +1678,10 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
         */
         enc = xmlParseCharEncoding((const char *) encoding);
        if (enc == XML_CHAR_ENCODING_ERROR) {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_UNKNOWN_ENCODING,
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_UNKNOWN_ENCODING,
                           "encoding %s not supported\n", encoding);
-           xmlFree(encoding);
-           xmlFree(URL);
-           return(-1);
+           goto error;
        }
-       xmlFree(encoding);
     }
 
     /*
@@ -1883,79 +1689,89 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
      */
     pctxt = xmlNewParserCtxt();
     inputStream = xmlLoadExternalEntity((const char*)URL, NULL, pctxt);
-    if(inputStream == NULL) {
-       xmlFreeParserCtxt(pctxt);
-       xmlFree(URL);
-       return(-1);
-    }
+    if(inputStream == NULL)
+       goto error;
     buf = inputStream->buf;
-    if (buf == NULL) {
-       xmlFreeInputStream (inputStream);
-       xmlFreeParserCtxt(pctxt);
-       xmlFree(URL);
-       return(-1);
-    }
+    if (buf == NULL)
+       goto error;
     if (buf->encoder)
        xmlCharEncCloseFunc(buf->encoder);
     buf->encoder = xmlGetCharEncodingHandler(enc);
     node = xmlNewDocText(ctxt->doc, NULL);
+    if (node == NULL) {
+        xmlXIncludeErrMemory(ctxt, ref->elem, NULL);
+       goto error;
+    }
 
     /*
      * Scan all chars from the resource and add the to the node
      */
-xinclude_multibyte_fallback:
-    while (xmlParserInputBufferRead(buf, 128) > 0) {
-       int len;
-       const xmlChar *content;
-
-       content = xmlBufContent(buf->buffer);
-       len = xmlBufLength(buf->buffer);
-       for (i = 0;i < len;) {
-           int cur;
-           int l;
-
-           cur = xmlStringCurrentChar(NULL, &content[i], &l);
-           if (!IS_CHAR(cur)) {
-               /* Handle split multibyte char at buffer boundary */
-               if (((len - i) < 4) && (!xinclude_multibyte_fallback_used)) {
-                   xinclude_multibyte_fallback_used = 1;
-                   xmlBufShrink(buf->buffer, i);
-                   goto xinclude_multibyte_fallback;
-               } else {
-                   xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                                  XML_XINCLUDE_INVALID_CHAR,
-                                  "%s contains invalid char\n", URL);
-                   xmlFreeParserCtxt(pctxt);
-                   xmlFreeParserInputBuffer(buf);
-                   xmlFree(URL);
-                   return(-1);
-               }
-           } else {
-               xinclude_multibyte_fallback_used = 0;
-               xmlNodeAddContentLen(node, &content[i], l);
-           }
-           i += l;
-       }
-       xmlBufShrink(buf->buffer, len);
+    while (xmlParserInputBufferRead(buf, 4096) > 0)
+        ;
+
+    content = xmlBufContent(buf->buffer);
+    len = xmlBufLength(buf->buffer);
+    for (i = 0; i < len;) {
+        int cur;
+        int l;
+
+        l = len - i;
+        cur = xmlGetUTF8Char(&content[i], &l);
+        if ((cur < 0) || (!IS_CHAR(cur))) {
+            xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_INVALID_CHAR,
+                           "%s contains invalid char\n", URL);
+            goto error;
+        }
+
+        i += l;
     }
-    xmlFreeParserCtxt(pctxt);
-    xmlXIncludeAddTxt(ctxt, node->content, URL);
-    xmlFreeInputStream(inputStream);
+
+    xmlNodeAddContentLen(node, content, len);
+
+    if (ctxt->txtNr >= ctxt->txtMax) {
+        xmlXIncludeTxt *tmp;
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+        size_t newSize = ctxt->txtMax ? ctxt->txtMax * 2 : 1;
+#else
+        size_t newSize = ctxt->txtMax ? ctxt->txtMax * 2 : 8;
+#endif
+
+        tmp = xmlRealloc(ctxt->txtTab, sizeof(xmlXIncludeTxt) * newSize);
+        if (tmp == NULL) {
+            xmlXIncludeErrMemory(ctxt, ref->elem,
+                                 "growing XInclude text table");
+           goto error;
+        }
+        ctxt->txtMax = newSize;
+        ctxt->txtTab = tmp;
+    }
+    ctxt->txtTab[ctxt->txtNr].text = xmlStrdup(node->content);
+    ctxt->txtTab[ctxt->txtNr].url = xmlStrdup(URL);
+    ctxt->txtNr++;
 
 loaded:
     /*
      * Add the element as the replacement copy.
      */
-    ctxt->incTab[nr]->inc = node;
+    ref->inc = node;
+    node = NULL;
+    ret = 0;
+
+error:
+    xmlFreeNode(node);
+    xmlFreeInputStream(inputStream);
+    xmlFreeParserCtxt(pctxt);
+    xmlFree(encoding);
+    xmlFreeURI(uri);
     xmlFree(URL);
-    return(0);
+    return(ret);
 }
 
 /**
  * xmlXIncludeLoadFallback:
  * @ctxt:  the XInclude context
  * @fallback:  the fallback node
- * @nr:  the xinclude node number
+ * @ref:  an XMLXincludeRefPtr
  *
  * Load the content of the fallback node, and store the result
  * in the XInclude context
@@ -1963,10 +1779,10 @@ loaded:
  * Returns 0 in case of success, -1 in case of failure
  */
 static int
-xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
-    xmlXIncludeCtxtPtr newctxt;
+xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback,
+                        xmlXIncludeRefPtr ref) {
     int ret = 0;
-    int oldNbErrors = ctxt->nbErrors;
+    int oldNbErrors;
 
     if ((fallback == NULL) || (fallback->type == XML_NAMESPACE_DECL) ||
         (ctxt == NULL))
@@ -1976,29 +1792,17 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
         * It's possible that the fallback also has 'includes'
         * (Bug 129969), so we re-process the fallback just in case
         */
-       newctxt = xmlXIncludeNewContext(ctxt->doc);
-       if (newctxt == NULL)
-           return (-1);
-       newctxt->_private = ctxt->_private;
-       newctxt->base = xmlStrdup(ctxt->base);  /* Inherit the base from the existing context */
-       xmlXIncludeSetFlags(newctxt, ctxt->parseFlags);
-        newctxt->incTotal = ctxt->incTotal;
-        if (xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback, 1) < 0)
-            ret = -1;
-        ctxt->incTotal = newctxt->incTotal;
+        oldNbErrors = ctxt->nbErrors;
+       ref->inc = xmlXIncludeCopyNode(ctxt, fallback, 1);
        if (ctxt->nbErrors > oldNbErrors)
            ret = -1;
-       xmlXIncludeFreeContext(newctxt);
-
-       ctxt->incTab[nr]->inc = xmlDocCopyNodeList(ctxt->doc,
-                                                  fallback->children);
-        if (ctxt->incTab[nr]->inc == NULL)
-            ctxt->incTab[nr]->emptyFb = 1;
+        else if (ref->inc == NULL)
+            ref->emptyFb = 1;
     } else {
-        ctxt->incTab[nr]->inc = NULL;
-       ctxt->incTab[nr]->emptyFb = 1;  /* flag empty callback */
+        ref->inc = NULL;
+       ref->emptyFb = 1;       /* flag empty callback */
     }
-    ctxt->incTab[nr]->fallback = 1;
+    ref->fallback = 1;
     return(ret);
 }
 
@@ -2009,32 +1813,88 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
  ************************************************************************/
 
 /**
- * xmlXIncludePreProcessNode:
+ * xmlXIncludeExpandNode:
  * @ctxt: an XInclude context
  * @node: an XInclude node
  *
- * Implement the XInclude preprocessing, currently just adding the element
- * for further processing.
+ * If the XInclude node wasn't processed yet, create a new RefPtr,
+ * add it to ctxt->incTab and load the included items.
  *
- * Returns the result list or NULL in case of error
+ * Returns the new or existing xmlXIncludeRefPtr, or NULL in case of error.
  */
-static xmlNodePtr
-xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
-    xmlXIncludeAddNode(ctxt, node);
-    return(NULL);
+static xmlXIncludeRefPtr
+xmlXIncludeExpandNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
+    xmlXIncludeRefPtr ref;
+    int i;
+
+    if (ctxt->fatalErr)
+        return(NULL);
+    if (ctxt->depth >= XINCLUDE_MAX_DEPTH) {
+        xmlXIncludeErr(ctxt, node, XML_XINCLUDE_RECURSION,
+                       "maximum recursion depth exceeded\n", NULL);
+        ctxt->fatalErr = 1;
+        return(NULL);
+    }
+
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    /*
+     * The XInclude engine offers no protection against exponential
+     * expansion attacks similar to "billion laughs". Avoid timeouts by
+     * limiting the total number of replacements when fuzzing.
+     *
+     * Unfortuately, a single XInclude can already result in quadratic
+     * behavior:
+     *
+     *     <doc xmlns:xi="http://www.w3.org/2001/XInclude">
+     *       <xi:include xpointer="xpointer(//e)"/>
+     *       <e>
+     *         <e>
+     *           <e>
+     *             <!-- more nested elements -->
+     *           </e>
+     *         </e>
+     *       </e>
+     *     </doc>
+     */
+    if (ctxt->incTotal >= 20)
+        return(NULL);
+    ctxt->incTotal++;
+#endif
+
+    for (i = 0; i < ctxt->incNr; i++) {
+        if (ctxt->incTab[i]->elem == node) {
+            if (ctxt->incTab[i]->expanding) {
+                xmlXIncludeErr(ctxt, node, XML_XINCLUDE_RECURSION,
+                               "inclusion loop detected\n", NULL);
+                return(NULL);
+            }
+            return(ctxt->incTab[i]);
+        }
+    }
+
+    ref = xmlXIncludeAddNode(ctxt, node);
+    if (ref == NULL)
+        return(NULL);
+    ref->expanding = 1;
+    ctxt->depth++;
+    xmlXIncludeLoadNode(ctxt, ref);
+    ctxt->depth--;
+    ref->expanding = 0;
+
+    return(ref);
 }
 
 /**
  * xmlXIncludeLoadNode:
  * @ctxt: an XInclude context
- * @nr: the node number
+ * @ref: an xmlXIncludeRefPtr
  *
  * Find and load the infoset replacement for the given node.
  *
  * Returns 0 if substitution succeeded, -1 if some processing failed
  */
 static int
-xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
+xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
     xmlNodePtr cur;
     xmlChar *href;
     xmlChar *parse;
@@ -2044,11 +1904,9 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
     int xml = 1; /* default Issue 64 */
     int ret;
 
-    if (ctxt == NULL)
-       return(-1);
-    if ((nr < 0) || (nr >= ctxt->incNr))
+    if ((ctxt == NULL) || (ref == NULL))
        return(-1);
-    cur = ctxt->incTab[nr]->ref;
+    cur = ref->elem;
     if (cur == NULL)
        return(-1);
 
@@ -2068,8 +1926,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
        else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT))
            xml = 0;
        else {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_PARSE_VALUE,
+           xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_PARSE_VALUE,
                           "invalid value %s for 'parse'\n", parse);
            if (href != NULL)
                xmlFree(href);
@@ -2103,8 +1960,8 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
            xmlFree(eschref);
     }
     if (URI == NULL) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                      XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL);
+       xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_HREF_URI,
+                       "failed build URL\n", NULL);
        if (parse != NULL)
            xmlFree(parse);
        if (href != NULL)
@@ -2113,11 +1970,6 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
            xmlFree(base);
        return(-1);
     }
-#ifdef DEBUG_XINCLUDE
-    xmlGenericError(xmlGenericErrorContext, "parse: %s\n",
-           xml ? "xml": "text");
-    xmlGenericError(xmlGenericErrorContext, "URI: %s\n", URI);
-#endif
 
     /*
      * Save the base for this include (saving the current one)
@@ -2126,10 +1978,10 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
     ctxt->base = base;
 
     if (xml) {
-       ret = xmlXIncludeLoadDoc(ctxt, URI, nr);
+       ret = xmlXIncludeLoadDoc(ctxt, URI, ref);
        /* xmlXIncludeGetFragment(ctxt, cur, URI); */
     } else {
-       ret = xmlXIncludeLoadTxt(ctxt, URI, nr);
+       ret = xmlXIncludeLoadTxt(ctxt, URI, ref);
     }
 
     /*
@@ -2143,9 +1995,6 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
        /*
         * Time to try a fallback if available
         */
-#ifdef DEBUG_XINCLUDE
-       xmlGenericError(xmlGenericErrorContext, "error looking for fallback\n");
-#endif
        children = cur->children;
        while (children != NULL) {
            if ((children->type == XML_ELEMENT_NODE) &&
@@ -2153,15 +2002,14 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
                (xmlStrEqual(children->name, XINCLUDE_FALLBACK)) &&
                ((xmlStrEqual(children->ns->href, XINCLUDE_NS)) ||
                 (xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) {
-               ret = xmlXIncludeLoadFallback(ctxt, children, nr);
+               ret = xmlXIncludeLoadFallback(ctxt, children, ref);
                break;
            }
            children = children->next;
        }
     }
     if (ret < 0) {
-       xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                      XML_XINCLUDE_NO_FALLBACK,
+       xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_NO_FALLBACK,
                       "could not load %s, and no fallback was found\n",
                       URI);
     }
@@ -2183,27 +2031,25 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
 /**
  * xmlXIncludeIncludeNode:
  * @ctxt: an XInclude context
- * @nr: the node number
+ * @ref: an xmlXIncludeRefPtr
  *
  * Implement the infoset replacement for the given node
  *
  * Returns 0 if substitution succeeded, -1 if some processing failed
  */
 static int
-xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
+xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
     xmlNodePtr cur, end, list, tmp;
 
-    if (ctxt == NULL)
+    if ((ctxt == NULL) || (ref == NULL))
        return(-1);
-    if ((nr < 0) || (nr >= ctxt->incNr))
-       return(-1);
-    cur = ctxt->incTab[nr]->ref;
+    cur = ref->elem;
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
        return(-1);
 
-    list = ctxt->incTab[nr]->inc;
-    ctxt->incTab[nr]->inc = NULL;
-    ctxt->incTab[nr]->emptyFb = 0;
+    list = ref->inc;
+    ref->inc = NULL;
+    ref->emptyFb = 0;
 
     /*
      * Check against the risk of generating a multi-rooted document
@@ -2219,8 +2065,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
            tmp = tmp->next;
        }
        if (nb_elem > 1) {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_MULTIPLE_ROOT,
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_MULTIPLE_ROOT,
                       "XInclude error: would result in multiple root nodes\n",
                           NULL);
             xmlFreeNodeList(list);
@@ -2250,7 +2095,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
         * Change the current node as an XInclude start one, and add an
         * XInclude end one
         */
-        if (ctxt->incTab[nr]->fallback)
+        if (ref->fallback)
             xmlUnsetProp(cur, BAD_CAST "href");
        cur->type = XML_XINCLUDE_START;
         /* Remove fallback children */
@@ -2261,8 +2106,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
         }
        end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL);
        if (end == NULL) {
-           xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
-                          XML_XINCLUDE_BUILD_FAILED,
+           xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_BUILD_FAILED,
                           "failed to build node\n", NULL);
             xmlFreeNodeList(list);
            return(-1);
@@ -2364,9 +2208,7 @@ xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
 /**
  * xmlXIncludeDoProcess:
  * @ctxt: the XInclude processing context
- * @doc: an XML document
  * @tree: the top of the tree to process
- * @skipRoot: don't process the root node of the tree
  *
  * Implement the XInclude substitution on the XML document @doc
  *
@@ -2374,63 +2216,31 @@ xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
  *    or the number of substitutions done.
  */
 static int
-xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree,
-                     int skipRoot) {
+xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree) {
+    xmlXIncludeRefPtr ref;
     xmlNodePtr cur;
     int ret = 0;
     int i, start;
 
-    if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
+    if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
        return(-1);
-    if ((skipRoot) && (tree->children == NULL))
-        return(-1);
     if (ctxt == NULL)
        return(-1);
 
-    if (doc->URL != NULL) {
-       ret = xmlXIncludeURLPush(ctxt, doc->URL);
-       if (ret < 0)
-           return(-1);
-    }
-    start = ctxt->incNr;
-
-    /*
-     * TODO: The phases must run separately for recursive inclusions.
-     *
-     * - Phase 1 should start with top-level XInclude nodes, load documents,
-     *   execute XPointer expressions, then process only the result nodes
-     *   (not whole document, see bug #324081) and only for phase 1
-     *   recursively. We will need a backreference from xmlNodes to
-     *   xmlIncludeRefs to detect references that were already visited.
-     *   This can also be used for proper cycle detection, see bug #344240.
-     *
-     * - Phase 2 should visit all top-level XInclude nodes and expand
-     *   possible subreferences in the replacement recursively.
-     *
-     * - Phase 3 should finally replace the top-level XInclude nodes.
-     *   It could also be run together with phase 2.
-     */
-
     /*
      * First phase: lookup the elements in the document
      */
-    if (skipRoot)
-        cur = tree->children;
-    else
-        cur = tree;
+    start = ctxt->incNr;
+    cur = tree;
     do {
        /* TODO: need to work on entities -> stack */
         if (xmlXIncludeTestNode(ctxt, cur) == 1) {
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+            ref = xmlXIncludeExpandNode(ctxt, cur);
             /*
-             * Avoid superlinear expansion by limiting the total number
-             * of replacements.
+             * Mark direct includes.
              */
-            if (ctxt->incTotal >= 20)
-                return(-1);
-#endif
-            ctxt->incTotal++;
-            xmlXIncludePreProcessNode(ctxt, cur);
+            if (ref != NULL)
+                ref->replace = 1;
         } else if ((cur->children != NULL) &&
                    ((cur->type == XML_DOCUMENT_NODE) ||
                     (cur->type == XML_ELEMENT_NODE))) {
@@ -2449,32 +2259,40 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree,
     } while ((cur != NULL) && (cur != tree));
 
     /*
-     * Second Phase : collect the infosets fragments
+     * Second phase: extend the original document infoset.
      */
-    for (i = start;i < ctxt->incNr; i++) {
-        xmlXIncludeLoadNode(ctxt, i);
+    for (i = start; i < ctxt->incNr; i++) {
+       if (ctxt->incTab[i]->replace != 0) {
+            if ((ctxt->incTab[i]->inc != NULL) ||
+                (ctxt->incTab[i]->emptyFb != 0)) {     /* (empty fallback) */
+                xmlXIncludeIncludeNode(ctxt, ctxt->incTab[i]);
+            }
+            ctxt->incTab[i]->replace = 0;
+        } else {
+            /*
+             * Ignore includes which were added indirectly, for example
+             * inside xi:fallback elements.
+             */
+            if (ctxt->incTab[i]->inc != NULL) {
+                xmlFreeNodeList(ctxt->incTab[i]->inc);
+                ctxt->incTab[i]->inc = NULL;
+            }
+        }
        ret++;
     }
 
-    /*
-     * Third phase: extend the original document infoset.
-     *
-     * Originally we bypassed the inclusion if there were any errors
-     * encountered on any of the XIncludes.  A bug was raised (bug
-     * 132588) requesting that we output the XIncludes without error,
-     * so the check for inc!=NULL || xptr!=NULL was put in.  This may
-     * give some other problems in the future, but for now it seems to
-     * work ok.
-     *
-     */
-    for (i = ctxt->incBase;i < ctxt->incNr; i++) {
-       if ((ctxt->incTab[i]->inc != NULL) ||
-           (ctxt->incTab[i]->emptyFb != 0))    /* (empty fallback) */
-           xmlXIncludeIncludeNode(ctxt, i);
+    if (ctxt->isStream) {
+        /*
+         * incTab references nodes which will eventually be deleted in
+         * streaming mode. The table is only required for XPointer
+         * expressions which aren't allowed in streaming mode.
+         */
+        for (i = 0;i < ctxt->incNr;i++) {
+            xmlXIncludeFreeRef(ctxt->incTab[i]);
+        }
+        ctxt->incNr = 0;
     }
 
-    if (doc->URL != NULL)
-       xmlXIncludeURLPop(ctxt);
     return(ret);
 }
 
@@ -2496,6 +2314,23 @@ xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) {
 }
 
 /**
+ * xmlXIncludeSetStreamingMode:
+ * @ctxt:  an XInclude processing context
+ * @mode:  whether streaming mode should be enabled
+ *
+ * In streaming mode, XPointer expressions aren't allowed.
+ *
+ * Returns 0 in case of success and -1 in case of error.
+ */
+int
+xmlXIncludeSetStreamingMode(xmlXIncludeCtxtPtr ctxt, int mode) {
+    if (ctxt == NULL)
+        return(-1);
+    ctxt->isStream = !!mode;
+    return(0);
+}
+
+/**
  * xmlXIncludeProcessTreeFlagsData:
  * @tree: an XML node
  * @flags: a set of xmlParserOption used for parsing XML includes
@@ -2523,7 +2358,7 @@ xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) {
     ctxt->_private = data;
     ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL);
     xmlXIncludeSetFlags(ctxt, flags);
-    ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree, 0);
+    ret = xmlXIncludeDoProcess(ctxt, tree);
     if ((ret >= 0) && (ctxt->nbErrors > 0))
         ret = -1;
 
@@ -2607,7 +2442,7 @@ xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags) {
        return(-1);
     ctxt->base = xmlNodeGetBase(tree->doc, tree);
     xmlXIncludeSetFlags(ctxt, flags);
-    ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree, 0);
+    ret = xmlXIncludeDoProcess(ctxt, tree);
     if ((ret >= 0) && (ctxt->nbErrors > 0))
        ret = -1;
 
@@ -2647,7 +2482,7 @@ xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
     if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
         (node->doc == NULL) || (ctxt == NULL))
        return(-1);
-    ret = xmlXIncludeDoProcess(ctxt, node->doc, node, 0);
+    ret = xmlXIncludeDoProcess(ctxt, node);
     if ((ret >= 0) && (ctxt->nbErrors > 0))
        ret = -1;
     return(ret);
diff --git a/xlink.c b/xlink.c
index 65715cb..3a77b19 100644 (file)
--- a/xlink.c
+++ b/xlink.c
@@ -19,9 +19,7 @@
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
-#include <libxml/valid.h>
 #include <libxml/xlink.h>
-#include <libxml/globals.h>
 
 #define XLINK_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xlink/namespace/")
 #define XHTML_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xhtml/")
index bda3221..1f82f80 100644 (file)
@@ -84,7 +84,7 @@ while test $# -gt 0; do
     --libs)
         if [ "$2" = "--dynamic" ]; then
             shift
-            libs="@XML_LIBS@"
+            libs="@XML_LIBS@ @XML_PRIVATE_LIBS_NO_SHARED@"
         else
             libs="@XML_LIBS@ @XML_PRIVATE_LIBS@ @MODULE_PLATFORM_LIBS@ @LIBS@"
         fi
diff --git a/xmlIO.c b/xmlIO.c
index 16c29f5..95d2715 100644 (file)
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -15,9 +15,6 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 #  endif
 #endif
 
+#include <libxml/xmlIO.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
-#include <libxml/xmlIO.h>
 #include <libxml/uri.h>
 #include <libxml/nanohttp.h>
 #include <libxml/nanoftp.h>
 #ifdef LIBXML_CATALOG_ENABLED
 #include <libxml/catalog.h>
 #endif
-#include <libxml/globals.h>
 
-#include "buf.h"
-#include "enc.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
+#include "private/io.h"
+#include "private/parser.h"
 
 /* #define VERBOSE_FAILURE */
-/* #define DEBUG_EXTERNAL_ENTITIES */
-/* #define DEBUG_INPUT */
 
-#ifdef DEBUG_INPUT
-#define MINLEN 40
-#else
 #define MINLEN 4000
-#endif
 
 /*
  * Input I/O callback sets
@@ -111,9 +104,6 @@ typedef struct _xmlOutputCallback {
 static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
 static int xmlOutputCallbackNr = 0;
 static int xmlOutputCallbackInitialized = 0;
-
-xmlOutputBufferPtr
-xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
 #endif /* LIBXML_OUTPUT_ENABLED */
 
 /************************************************************************
@@ -214,6 +204,7 @@ __xmlIOWin32UTF8ToWChar(const char *u8String)
 }
 #endif
 
+#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
 /**
  * xmlIOErrMemory:
  * @extra:  extra information
@@ -225,6 +216,7 @@ xmlIOErrMemory(const char *extra)
 {
     __xmlSimpleError(XML_FROM_IO, XML_ERR_NO_MEMORY, NULL, NULL, extra);
 }
+#endif
 
 /**
  * __xmlIOErr:
@@ -720,20 +712,6 @@ xmlCheckFilename (const char *path)
 }
 
 /**
- * xmlInputReadCallbackNop:
- *
- * No Operation xmlInputReadCallback function, does nothing.
- *
- * Returns zero
- */
-int
-xmlInputReadCallbackNop(void *context ATTRIBUTE_UNUSED,
-                        char *buffer ATTRIBUTE_UNUSED,
-                        int len ATTRIBUTE_UNUSED) {
-    return(0);
-}
-
-/**
  * xmlFdRead:
  * @context:  the I/O context
  * @buffer:  where to drop data
@@ -1266,7 +1244,7 @@ xmlGzfileClose (void * context) {
  *             I/O for compressed file accesses                        *
  *                                                                     *
  ************************************************************************/
-#include "xzlib.h"
+#include "private/xzlib.h"
 /**
  * xmlXzfileMatch:
  * @filename:  the URI for matching
@@ -1464,23 +1442,11 @@ append_reverse_ulong( xmlZMemBuff * buff, unsigned long data ) {
 static void
 xmlFreeZMemBuff( xmlZMemBuffPtr buff ) {
 
-#ifdef DEBUG_HTTP
-    int z_err;
-#endif
-
     if ( buff == NULL )
        return;
 
     xmlFree( buff->zbuff );
-#ifdef DEBUG_HTTP
-    z_err = deflateEnd( &buff->zctrl );
-    if ( z_err != Z_OK )
-       xmlGenericError( xmlGenericErrorContext,
-                       "xmlFreeZMemBuff:  Error releasing zlib context:  %d\n",
-                       z_err );
-#else
     deflateEnd( &buff->zctrl );
-#endif
 
     xmlFree( buff );
     return;
@@ -1578,15 +1544,6 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
     cur_used = buff->zctrl.next_out - buff->zbuff;
     new_size = buff->size + ext_amt;
 
-#ifdef DEBUG_HTTP
-    if ( cur_used > new_size )
-       xmlGenericError( xmlGenericErrorContext,
-                       "xmlZMemBuffExtend:  %s\n%s %d bytes.\n",
-                       "Buffer overwrite detected during compressed memory",
-                       "buffer extension.  Overflowed by",
-                       (cur_used - new_size ) );
-#endif
-
     tmp_ptr = xmlRealloc( buff->zbuff, new_size );
     if ( tmp_ptr != NULL ) {
        rc = 0;
@@ -2007,58 +1964,6 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
                                        content_lgth );
 
        if ( http_ctxt != NULL ) {
-#ifdef DEBUG_HTTP
-           /*  If testing/debugging - dump reply with request content  */
-
-           FILE *      tst_file = NULL;
-           char        buffer[ 4096 ];
-           char *      dump_name = NULL;
-           int         avail;
-
-           xmlGenericError( xmlGenericErrorContext,
-                       "xmlNanoHTTPCloseWrite:  HTTP %s to\n%s returned %d.\n",
-                       http_mthd, ctxt->uri,
-                       xmlNanoHTTPReturnCode( http_ctxt ) );
-
-           /*
-           **  Since either content or reply may be gzipped,
-           **  dump them to separate files instead of the
-           **  standard error context.
-           */
-
-           dump_name = tempnam( NULL, "lxml" );
-           if ( dump_name != NULL ) {
-               (void)snprintf( buffer, sizeof(buffer), "%s.content", dump_name );
-
-               tst_file = fopen( buffer, "wb" );
-               if ( tst_file != NULL ) {
-                   xmlGenericError( xmlGenericErrorContext,
-                       "Transmitted content saved in file:  %s\n", buffer );
-
-                   fwrite( http_content, sizeof( char ),
-                                       content_lgth, tst_file );
-                   fclose( tst_file );
-               }
-
-               (void)snprintf( buffer, sizeof(buffer), "%s.reply", dump_name );
-               tst_file = fopen( buffer, "wb" );
-               if ( tst_file != NULL ) {
-                   xmlGenericError( xmlGenericErrorContext,
-                       "Reply content saved in file:  %s\n", buffer );
-
-
-                   while ( (avail = xmlNanoHTTPRead( http_ctxt,
-                                       buffer, sizeof( buffer ) )) > 0 ) {
-
-                       fwrite( buffer, sizeof( char ), avail, tst_file );
-                   }
-
-                   fclose( tst_file );
-               }
-
-               free( dump_name );
-           }
-#endif  /*  DEBUG_HTTP  */
 
            http_rtn = xmlNanoHTTPReturnCode( http_ctxt );
            if ( ( http_rtn >= 200 ) && ( http_rtn < 300 ) )
@@ -2343,10 +2248,9 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
 
     ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
     if (ret == NULL) {
-       xmlIOErrMemory("creating input buffer");
        return(NULL);
     }
-    memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
+    memset(ret, 0, sizeof(xmlParserInputBuffer));
     ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize);
     if (ret->buffer == NULL) {
         xmlFree(ret);
@@ -2382,10 +2286,9 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
 
     ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
     if (ret == NULL) {
-       xmlIOErrMemory("creating output buffer");
        return(NULL);
     }
-    memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
+    memset(ret, 0, sizeof(xmlOutputBuffer));
     ret->buffer = xmlBufCreate();
     if (ret->buffer == NULL) {
         xmlFree(ret);
@@ -2430,10 +2333,9 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
 
     ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
     if (ret == NULL) {
-       xmlIOErrMemory("creating output buffer");
        return(NULL);
     }
-    memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
+    memset(ret, 0, sizeof(xmlOutputBuffer));
     ret->buffer = xmlBufCreate();
     if (ret->buffer == NULL) {
         xmlFree(ret);
@@ -2928,38 +2830,78 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) {
     return(ret);
 }
 
+typedef struct {
+    char *mem;
+    const char *cur;
+    size_t size;
+} xmlMemIOCtxt;
+
+static int
+xmlMemRead(void *vctxt, char *buf, int size) {
+    xmlMemIOCtxt *ctxt = vctxt;
+
+    if ((size_t) size > ctxt->size)
+        size = ctxt->size;
+
+    memcpy(buf, ctxt->cur, size);
+    ctxt->cur += size;
+    ctxt->size -= size;
+
+    return size;
+}
+
+static int
+xmlMemClose(void *vctxt) {
+    xmlMemIOCtxt *ctxt = vctxt;
+
+    if (ctxt->mem != 0)
+        xmlFree(ctxt->mem);
+    xmlFree(ctxt);
+    return(0);
+}
+
 /**
  * xmlParserInputBufferCreateMem:
  * @mem:  the memory input
  * @size:  the length of the memory block
  * @enc:  the charset encoding if known
  *
- * Create a buffered parser input for the progressive parsing for the input
- * from a memory area.
+ * Create a parser input buffer for parsing from a memory area.
  *
- * Returns the new parser input or NULL
+ * This function makes a copy of the whole input buffer. If you are sure
+ * that the contents of the buffer will remain valid until the document
+ * was parsed, you can avoid the copy by using
+ * xmlParserInputBufferCreateStatic.
+ *
+ * The encoding argument is deprecated and should be set to
+ * XML_CHAR_ENCODING_NONE. The encoding can be changed with
+ * xmlSwitchEncoding or xmlSwitchEncodingName later on.
+ *
+ * Returns the new parser input or NULL in case of error.
  */
 xmlParserInputBufferPtr
 xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
-    xmlParserInputBufferPtr ret;
-    int errcode;
+    xmlParserInputBufferPtr buf;
+    xmlMemIOCtxt *ctxt;
+    char *copy;
 
-    if (size < 0) return(NULL);
-    if (mem == NULL) return(NULL);
+    if ((size < 0) || (mem == NULL))
+        return(NULL);
 
-    ret = xmlAllocParserInputBuffer(enc);
-    if (ret != NULL) {
-        ret->context = (void *) mem;
-       ret->readcallback = xmlInputReadCallbackNop;
-       ret->closecallback = NULL;
-       errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size);
-       if (errcode != 0) {
-           xmlFree(ret);
-           return(NULL);
-       }
+    copy = (char *) xmlStrndup((const xmlChar *) mem, size);
+    if (copy == NULL)
+        return(NULL);
+
+    buf = xmlParserInputBufferCreateStatic(copy, size, enc);
+    if (buf == NULL) {
+        xmlFree(copy);
+        return(NULL);
     }
 
-    return(ret);
+    ctxt = buf->context;
+    ctxt->mem = copy;
+
+    return(buf);
 }
 
 /**
@@ -2968,41 +2910,102 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
  * @size:  the length of the memory block
  * @enc:  the charset encoding if known
  *
- * Create a buffered parser input for the progressive parsing for the input
- * from an immutable memory area. This will not copy the memory area to
- * the buffer, but the memory is expected to be available until the end of
- * the parsing, this is useful for example when using mmap'ed file.
+ * Create a parser input buffer for parsing from a memory area.
  *
- * Returns the new parser input or NULL
+ * This functions assumes that the contents of the input buffer remain
+ * valid until the document was parsed. Use xmlParserInputBufferCreateMem
+ * otherwise.
+ *
+ * The encoding argument is deprecated and should be set to
+ * XML_CHAR_ENCODING_NONE. The encoding can be changed with
+ * xmlSwitchEncoding or xmlSwitchEncodingName later on.
+ *
+ * Returns the new parser input or NULL in case of error.
  */
 xmlParserInputBufferPtr
 xmlParserInputBufferCreateStatic(const char *mem, int size,
                                  xmlCharEncoding enc) {
     xmlParserInputBufferPtr ret;
+    xmlMemIOCtxt *ctxt;
 
-    if (size < 0) return(NULL);
-    if (mem == NULL) return(NULL);
+    if ((size < 0) || (mem == NULL))
+        return(NULL);
 
-    ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
-    if (ret == NULL) {
-       xmlIOErrMemory("creating input buffer");
-       return(NULL);
+    ret = xmlAllocParserInputBuffer(enc);
+    if (ret == NULL)
+        return(NULL);
+
+    ctxt = xmlMalloc(sizeof(*ctxt));
+    if (ctxt == NULL) {
+        xmlFreeParserInputBuffer(ret);
+        return(NULL);
     }
-    memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
-    ret->buffer = xmlBufCreateStatic((void *)mem, (size_t) size);
-    if (ret->buffer == NULL) {
-        xmlFree(ret);
-       return(NULL);
+    ctxt->mem = NULL;
+    ctxt->cur = mem;
+    ctxt->size = size;
+
+    ret->context = ctxt;
+    ret->readcallback = xmlMemRead;
+    ret->closecallback = xmlMemClose;
+
+    return(ret);
+}
+
+typedef struct {
+    const xmlChar *str;
+} xmlStringIOCtxt;
+
+static int
+xmlStringRead(void *vctxt, char *buf, int size) {
+    xmlStringIOCtxt *ctxt = vctxt;
+    const xmlChar *zero;
+    size_t len;
+
+    zero = memchr(ctxt->str, 0, size);
+    len = zero ? zero - ctxt->str : size;
+
+    memcpy(buf, ctxt->str, len);
+    ctxt->str += len;
+
+    return(len);
+}
+
+static int
+xmlStringClose(void *vctxt) {
+    xmlFree(vctxt);
+    return(0);
+}
+
+/**
+ * xmlParserInputBufferCreateString:
+ * @str:  a null-terminated string
+ *
+ * Create a buffered parser input for the progressive parsing for the input
+ * from a null-terminated C string.
+ *
+ * Returns the new parser input or NULL
+ */
+xmlParserInputBufferPtr
+xmlParserInputBufferCreateString(const xmlChar *str) {
+    xmlParserInputBufferPtr ret;
+    xmlStringIOCtxt *ctxt;
+
+    if (str == NULL) return(NULL);
+
+    ret = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
+    if (ret == NULL)
+        return(NULL);
+
+    ctxt = xmlMalloc(sizeof(*ctxt));
+    if (ctxt == NULL) {
+        xmlFreeParserInputBuffer(ret);
+        return(NULL);
     }
-    ret->encoder = xmlGetCharEncodingHandler(enc);
-    if (ret->encoder != NULL)
-        ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize);
-    else
-        ret->raw = NULL;
-    ret->compressed = -1;
-    ret->context = (void *) mem;
-    ret->readcallback = NULL;
-    ret->closecallback = NULL;
+    ctxt->str = str;
+
+    ret->context = ctxt;
+    ret->readcallback = xmlStringRead;
+    ret->closecallback = xmlStringClose;
 
     return(ret);
 }
@@ -3159,40 +3162,36 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
     if (len < 0) return(0);
     if ((in == NULL) || (in->error)) return(-1);
     if (in->encoder != NULL) {
-        unsigned int use;
-
         /*
         * Store the data in the incoming raw buffer
         */
         if (in->raw == NULL) {
            in->raw = xmlBufCreate();
+            if (in->raw == NULL) {
+                in->error = XML_ERR_NO_MEMORY;
+                return(-1);
+            }
        }
        ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len);
-       if (ret != 0)
+       if (ret != 0) {
+            in->error = XML_ERR_NO_MEMORY;
            return(-1);
+        }
 
        /*
         * convert as much as possible to the parser reading buffer.
         */
-       use = xmlBufUse(in->raw);
-       nbchars = xmlCharEncInput(in, 1);
-       if (nbchars < 0) {
-           xmlIOErr(XML_IO_ENCODER, NULL);
-           in->error = XML_IO_ENCODER;
+       nbchars = xmlCharEncInput(in);
+       if (nbchars < 0)
            return(-1);
-       }
-       in->rawconsumed += (use - xmlBufUse(in->raw));
     } else {
        nbchars = len;
         ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars);
-       if (ret != 0)
+       if (ret != 0) {
+            in->error = XML_ERR_NO_MEMORY;
            return(-1);
+        }
     }
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext,
-           "I/O: pushed %d chars, buffer %d/%d\n",
-            nbchars, xmlBufUse(in->buffer), xmlBufLength(in->buffer));
-#endif
     return(nbchars);
 }
 
@@ -3226,41 +3225,45 @@ endOfInput (void * context ATTRIBUTE_UNUSED,
  */
 int
 xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
-    char *buffer = NULL;
+    xmlBufPtr buf;
     int res = 0;
-    int nbchars = 0;
 
     if ((in == NULL) || (in->error)) return(-1);
     if ((len <= MINLEN) && (len != 4))
         len = MINLEN;
 
-    if (xmlBufAvail(in->buffer) <= 0) {
-       xmlIOErr(XML_IO_BUFFER_FULL, NULL);
-       in->error = XML_IO_BUFFER_FULL;
-       return(-1);
-    }
-
-    if (xmlBufGrow(in->buffer, len + 1) < 0) {
-        xmlIOErrMemory("growing input buffer");
-        in->error = XML_ERR_NO_MEMORY;
-        return(-1);
+    if (in->encoder == NULL) {
+        if (in->readcallback == NULL)
+            return(0);
+        buf = in->buffer;
+    } else {
+        if (in->raw == NULL) {
+           in->raw = xmlBufCreate();
+       }
+        buf = in->raw;
     }
-    buffer = (char *)xmlBufEnd(in->buffer);
 
     /*
      * Call the read method for this I/O type.
      */
     if (in->readcallback != NULL) {
-       res = in->readcallback(in->context, &buffer[0], len);
+        if (xmlBufGrow(buf, len + 1) < 0) {
+            in->error = XML_ERR_NO_MEMORY;
+            return(-1);
+        }
+
+       res = in->readcallback(in->context, (char *)xmlBufEnd(buf), len);
        if (res <= 0)
            in->readcallback = endOfInput;
-    } else {
-       xmlIOErr(XML_IO_NO_INPUT, NULL);
-       in->error = XML_IO_NO_INPUT;
-       return(-1);
-    }
-    if (res < 0) {
-       return(-1);
+        if (res < 0) {
+            in->error = XML_IO_UNKNOWN;
+            return(-1);
+        }
+
+        if (xmlBufAddLen(buf, res) < 0) {
+            in->error = XML_ERR_NO_MEMORY;
+            return(-1);
+        }
     }
 
     /*
@@ -3273,41 +3276,12 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
 #endif
     }
 
-    len = res;
     if (in->encoder != NULL) {
-        unsigned int use;
-
-        /*
-        * Store the data in the incoming raw buffer
-        */
-        if (in->raw == NULL) {
-           in->raw = xmlBufCreate();
-       }
-       res = xmlBufAdd(in->raw, (const xmlChar *) buffer, len);
-       if (res != 0)
+       res = xmlCharEncInput(in);
+       if (res < 0)
            return(-1);
-
-       /*
-        * convert as much as possible to the parser reading buffer.
-        */
-       use = xmlBufUse(in->raw);
-       nbchars = xmlCharEncInput(in, 1);
-       if (nbchars < 0) {
-           xmlIOErr(XML_IO_ENCODER, NULL);
-           in->error = XML_IO_ENCODER;
-           return(-1);
-       }
-       in->rawconsumed += (use - xmlBufUse(in->raw));
-    } else {
-       nbchars = len;
-        xmlBufAddLen(in->buffer, nbchars);
     }
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext,
-           "I/O: read %d chars, buffer %d\n",
-            nbchars, xmlBufUse(in->buffer));
-#endif
-    return(nbchars);
+    return(res);
 }
 
 /**
@@ -3324,13 +3298,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
  */
 int
 xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) {
-    if ((in == NULL) || (in->error)) return(-1);
-    if (in->readcallback != NULL)
-       return(xmlParserInputBufferGrow(in, len));
-    else if (xmlBufGetAllocationScheme(in->buffer) == XML_BUFFER_ALLOC_IMMUTABLE)
-       return(0);
-    else
-        return(-1);
+    return(xmlParserInputBufferGrow(in, len));
 }
 
 #ifdef LIBXML_OUTPUT_ENABLED
@@ -3438,10 +3406,6 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
     } while (len > 0);
 
 done:
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext,
-           "I/O: wrote %d chars\n", written);
-#endif
     return(written);
 }
 
@@ -3496,7 +3460,7 @@ xmlEscapeContent(unsigned char* out, int *outlen,
            *out++ = '3';
            *out++ = ';';
        } else {
-           *out++ = (unsigned char) *in;
+           *out++ = *in;
        }
        ++in;
     }
@@ -3532,8 +3496,7 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
     int cons;        /* byte from str consumed */
 
     if ((out == NULL) || (out->error) || (str == NULL) ||
-        (out->buffer == NULL) ||
-       (xmlBufGetAllocationScheme(out->buffer) == XML_BUFFER_ALLOC_IMMUTABLE))
+        (out->buffer == NULL))
         return(-1);
     len = strlen((const char *)str);
     if (len < 0) return(0);
@@ -3639,10 +3602,6 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
     } while ((len > 0) && (oldwritten != written));
 
 done:
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext,
-           "I/O: wrote %d chars\n", written);
-#endif
     return(written);
 }
 
@@ -3730,10 +3689,6 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
     else
         out->written += ret;
 
-#ifdef DEBUG_INPUT
-    xmlGenericError(xmlGenericErrorContext,
-           "I/O: flushed %d chars\n", ret);
-#endif
     return(ret);
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
@@ -3843,8 +3798,6 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
                                          "Unknown encoding %s",
                                          BAD_CAST encoding, NULL);
                     }
-                    if (ret->encoding == NULL)
-                        ret->encoding = xmlStrdup(BAD_CAST encoding);
                 }
 #if 0
             } else if (xmlStrstr(BAD_CAST mime, BAD_CAST "html")) {
@@ -3986,10 +3939,6 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
     xmlParserInputPtr ret = NULL;
     xmlChar *resource = NULL;
 
-#ifdef DEBUG_EXTERNAL_ENTITIES
-    xmlGenericError(xmlGenericErrorContext,
-                    "xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
-#endif
     if ((ctxt != NULL) && (ctxt->options & XML_PARSE_NONET)) {
         int options = ctxt->options;
 
@@ -4063,7 +4012,7 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
 
        canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
        if (canonicFilename == NULL) {
-            xmlIOErrMemory("building canonical path\n");
+            xmlErrMemory(ctxt, "building canonical path\n");
            return(NULL);
        }
 
index 9d92611..588802b 100644 (file)
@@ -24,7 +24,6 @@
 #include <libxml/uri.h>
 #include <libxml/catalog.h>
 #include <libxml/parser.h>
-#include <libxml/globals.h>
 
 #if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
 static int shell = 0;
@@ -509,6 +508,9 @@ int main(int argc, char **argv) {
                    xmlACatalogDump(catal, stdout);
                }
                i += 2;
+
+                xmlFreeCatalog(catal);
+                xmlFreeCatalog(super);
            } else {
                if ((!strcmp(argv[i], "-add")) ||
                    (!strcmp(argv[i], "--add"))) {
@@ -595,7 +597,6 @@ int main(int argc, char **argv) {
      * Cleanup and check for memory leaks
      */
     xmlCleanupParser();
-    xmlMemoryDump();
     return(exit_value);
 }
 #else
index b5dfbd0..21dbe7d 100644 (file)
--- a/xmllint.c
+++ b/xmllint.c
 
 #include <string.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <time.h>
+#include <errno.h>
+#include <limits.h>
 
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
@@ -20,9 +23,6 @@
 #ifdef HAVE_SYS_TIMEB_H
 #include <sys/timeb.h>
 #endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
@@ -31,6 +31,8 @@
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
@@ -61,7 +63,6 @@
 #ifdef LIBXML_CATALOG_ENABLED
 #include <libxml/catalog.h>
 #endif
-#include <libxml/globals.h>
 #include <libxml/xmlreader.h>
 #ifdef LIBXML_SCHEMATRON_ENABLED
 #include <libxml/schematron.h>
@@ -112,8 +113,8 @@ static int noenc = 0;
 static int noblanks = 0;
 static int noout = 0;
 static int nowrap = 0;
-#ifdef LIBXML_OUTPUT_ENABLED
 static int format = 0;
+#ifdef LIBXML_OUTPUT_ENABLED
 static const char *output = NULL;
 static int compress = 0;
 static int oldout = 0;
@@ -192,6 +193,7 @@ static const char *xpathquery = NULL;
 static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
 static int sax = 0;
 static int oldxml10 = 0;
+static unsigned maxAmpl = 0;
 
 /************************************************************************
  *                                                                     *
@@ -352,17 +354,14 @@ myMallocFunc(size_t size)
 static void *
 myReallocFunc(void *mem, size_t size)
 {
-    void *ret;
+    size_t oldsize = xmlMemSize(mem);
 
-    ret = xmlMemRealloc(mem, size);
-    if (ret != NULL) {
-        if (xmlMemUsed() > maxmem) {
-            OOM();
-            xmlMemFree(ret);
-            return (NULL);
-        }
+    if (xmlMemUsed() + size - oldsize > (size_t) maxmem) {
+        OOM();
+        return (NULL);
     }
-    return (ret);
+
+    return (xmlMemRealloc(mem, size));
 }
 static char *
 myStrdupFunc(const char *str)
@@ -428,7 +427,7 @@ startTimer(void)
  *           message about the timing performed; format is a printf
  *           type argument
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
+static void LIBXML_ATTR_FORMAT(1,2)
 endTimer(const char *fmt, ...)
 {
     long msec;
@@ -461,7 +460,7 @@ startTimer(void)
 {
     begin = clock();
 }
-static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
+static void LIBXML_ATTR_FORMAT(1,2)
 endTimer(const char *fmt, ...)
 {
     long msec;
@@ -583,7 +582,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
  * Display and format an error messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlHTMLError(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -620,7 +619,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
  * Display and format a warning messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlHTMLWarning(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -658,7 +657,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
  * Display and format an validity error messages, gives file,
  * line, position and extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlHTMLValidityError(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -695,7 +694,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
  * Display and format a validity warning messages, gives file, line,
  * position and extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
 {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -1361,7 +1360,7 @@ commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
  * Display and format a warning messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1384,7 +1383,7 @@ warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
  * Display and format a error messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1407,7 +1406,7 @@ errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
  * Display and format a fatalError messages, gives file, line, position and
  * extra parameters.
  */
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
 {
     va_list args;
@@ -1586,10 +1585,6 @@ static void
 testSAX(const char *filename) {
     xmlSAXHandlerPtr handler;
     const char *user_data = "user_data"; /* mostly for debugging */
-    xmlParserInputBufferPtr buf = NULL;
-    xmlParserInputPtr inputStream;
-    xmlParserCtxtPtr ctxt = NULL;
-    xmlSAXHandlerPtr old_sax = NULL;
 
     callbacks = 0;
 
@@ -1603,24 +1598,22 @@ testSAX(const char *filename) {
         handler = debugSAX2Handler;
     }
 
-    /*
-     * it's not the simplest code but the most generic in term of I/O
-     */
-    buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
-    if (buf == NULL) {
-        goto error;
-    }
-
 #ifdef LIBXML_SCHEMAS_ENABLED
     if (wxschemas != NULL) {
         int ret;
        xmlSchemaValidCtxtPtr vctxt;
+        xmlParserInputBufferPtr buf;
+
+        buf = xmlParserInputBufferCreateFilename(filename,
+                XML_CHAR_ENCODING_NONE);
+        if (buf == NULL)
+            return;
 
        vctxt = xmlSchemaNewValidCtxt(wxschemas);
         if (vctxt == NULL) {
             progresult = XMLLINT_ERR_MEM;
             xmlFreeParserInputBuffer(buf);
-            goto error;
+            return;
         }
        xmlSchemaSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL);
        xmlSchemaValidateSetFilename(vctxt, filename);
@@ -1645,38 +1638,25 @@ testSAX(const char *filename) {
     } else
 #endif
     {
+        xmlParserCtxtPtr ctxt = NULL;
+
        /*
         * Create the parser context amd hook the input
         */
-       ctxt = xmlNewParserCtxt();
+       ctxt = xmlNewSAXParserCtxt(handler, (void *) user_data);
        if (ctxt == NULL) {
             progresult = XMLLINT_ERR_MEM;
-           xmlFreeParserInputBuffer(buf);
-           goto error;
-       }
-       old_sax = ctxt->sax;
-       ctxt->sax = handler;
-       ctxt->userData = (void *) user_data;
-       inputStream = xmlNewIOInputStream(ctxt, buf, XML_CHAR_ENCODING_NONE);
-       if (inputStream == NULL) {
-           xmlFreeParserInputBuffer(buf);
-           goto error;
+           return;
        }
-       inputPush(ctxt, inputStream);
-
-       /* do the parsing */
-       xmlParseDocument(ctxt);
+        if (maxAmpl > 0)
+            xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
+        xmlCtxtReadFile(ctxt, filename, NULL, options);
 
        if (ctxt->myDoc != NULL) {
            fprintf(stderr, "SAX generated a doc !\n");
            xmlFreeDoc(ctxt->myDoc);
            ctxt->myDoc = NULL;
        }
-    }
-
-error:
-    if (ctxt != NULL) {
-        ctxt->sax = old_sax;
         xmlFreeParserCtxt(ctxt);
     }
 }
@@ -1806,15 +1786,6 @@ static void streamFile(char *filename) {
 #endif
        reader = xmlReaderForFile(filename, NULL, options);
 #ifdef LIBXML_PATTERN_ENABLED
-    if (pattern != NULL) {
-        patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
-       if (patternc == NULL) {
-           xmlGenericError(xmlGenericErrorContext,
-                   "Pattern %s failed to compile\n", pattern);
-            progresult = XMLLINT_ERR_SCHEMAPAT;
-           pattern = NULL;
-       }
-    }
     if (patternc != NULL) {
         patstream = xmlPatternGetStreamCtxt(patternc);
        if (patstream != NULL) {
@@ -1830,6 +1801,8 @@ static void streamFile(char *filename) {
 
 
     if (reader != NULL) {
+        if (maxAmpl > 0)
+            xmlTextReaderSetMaxAmplification(reader, maxAmpl);
 #ifdef LIBXML_VALID_ENABLED
        if (valid)
            xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1);
@@ -2046,8 +2019,9 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
             xmlOutputBufferPtr buf;
 
             if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
-                fprintf(stderr, "XPath set is empty\n");
-                progresult = XMLLINT_ERR_XPATH;
+                if (!quiet) {
+                    fprintf(stderr, "XPath set is empty\n");
+                }
                 break;
             }
             buf = xmlOutputBufferCreateFile(stdout, NULL);
@@ -2156,38 +2130,39 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 #ifdef LIBXML_PUSH_ENABLED
     else if ((html) && (push)) {
         FILE *f;
+        int res;
+        char chars[4096];
+        htmlParserCtxtPtr ctxt;
 
         if ((filename[0] == '-') && (filename[1] == 0)) {
             f = stdin;
         } else {
            f = fopen(filename, "rb");
+            if (f == NULL) {
+                fprintf(stderr, "Can't open %s\n", filename);
+                progresult = XMLLINT_ERR_UNCLASS;
+                return;
+            }
         }
-        if (f != NULL) {
-            int res;
-            char chars[4096];
-            htmlParserCtxtPtr ctxt;
 
-            res = fread(chars, 1, 4, f);
-            if (res > 0) {
-                ctxt = htmlCreatePushParserCtxt(NULL, NULL,
-                            chars, res, filename, XML_CHAR_ENCODING_NONE);
-                if (ctxt == NULL) {
-                    progresult = XMLLINT_ERR_MEM;
-                    if (f != stdin)
-                        fclose(f);
-                    return;
-                }
-                htmlCtxtUseOptions(ctxt, options);
-                while ((res = fread(chars, 1, pushsize, f)) > 0) {
-                    htmlParseChunk(ctxt, chars, res, 0);
-                }
-                htmlParseChunk(ctxt, chars, 0, 1);
-                doc = ctxt->myDoc;
-                htmlFreeParserCtxt(ctxt);
-            }
+        res = fread(chars, 1, 4, f);
+        ctxt = htmlCreatePushParserCtxt(NULL, NULL,
+                    chars, res, filename, XML_CHAR_ENCODING_NONE);
+        if (ctxt == NULL) {
+            progresult = XMLLINT_ERR_MEM;
             if (f != stdin)
                 fclose(f);
+            return;
+        }
+        htmlCtxtUseOptions(ctxt, options);
+        while ((res = fread(chars, 1, pushsize, f)) > 0) {
+            htmlParseChunk(ctxt, chars, res, 0);
         }
+        htmlParseChunk(ctxt, chars, 0, 1);
+        doc = ctxt->myDoc;
+        htmlFreeParserCtxt(ctxt);
+        if (f != stdin)
+            fclose(f);
     }
 #endif /* LIBXML_PUSH_ENABLED */
 #ifdef HAVE_MMAP
@@ -2225,46 +2200,48 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
         */
        if (push) {
            FILE *f;
+            int ret;
+            int res, size = 1024;
+            char chars[1024];
+            xmlParserCtxtPtr ctxt;
 
            /* '-' Usually means stdin -<sven@zen.org> */
            if ((filename[0] == '-') && (filename[1] == 0)) {
                f = stdin;
            } else {
                f = fopen(filename, "rb");
+                if (f == NULL) {
+                    fprintf(stderr, "Can't open %s\n", filename);
+                    progresult = XMLLINT_ERR_UNCLASS;
+                    return;
+                }
            }
-           if (f != NULL) {
-               int ret;
-               int res, size = 1024;
-               char chars[1024];
-                xmlParserCtxtPtr ctxt;
 
-               /* if (repeat) size = 1024; */
-               res = fread(chars, 1, 4, f);
-               if (res > 0) {
-                   ctxt = xmlCreatePushParserCtxt(NULL, NULL,
-                               chars, res, filename);
-                    if (ctxt == NULL) {
-                        progresult = XMLLINT_ERR_MEM;
-                        if (f != stdin)
-                            fclose(f);
-                        return;
-                    }
-                   xmlCtxtUseOptions(ctxt, options);
-                   while ((res = fread(chars, 1, size, f)) > 0) {
-                       xmlParseChunk(ctxt, chars, res, 0);
-                   }
-                   xmlParseChunk(ctxt, chars, 0, 1);
-                   doc = ctxt->myDoc;
-                   ret = ctxt->wellFormed;
-                   xmlFreeParserCtxt(ctxt);
-                   if ((!ret) && (!recovery)) {
-                       xmlFreeDoc(doc);
-                       doc = NULL;
-                   }
-               }
+            res = fread(chars, 1, 4, f);
+            ctxt = xmlCreatePushParserCtxt(NULL, NULL,
+                        chars, res, filename);
+            if (ctxt == NULL) {
+                progresult = XMLLINT_ERR_MEM;
                 if (f != stdin)
                     fclose(f);
-           }
+                return;
+            }
+            xmlCtxtUseOptions(ctxt, options);
+            if (maxAmpl > 0)
+                xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
+            while ((res = fread(chars, 1, size, f)) > 0) {
+                xmlParseChunk(ctxt, chars, res, 0);
+            }
+            xmlParseChunk(ctxt, chars, 0, 1);
+            doc = ctxt->myDoc;
+            ret = ctxt->wellFormed;
+            xmlFreeParserCtxt(ctxt);
+            if ((!ret) && (!recovery)) {
+                xmlFreeDoc(doc);
+                doc = NULL;
+            }
+            if (f != stdin)
+                fclose(f);
        } else
 #endif /* LIBXML_PUSH_ENABLED */
         if (testIO) {
@@ -2293,6 +2270,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                     progresult = XMLLINT_ERR_MEM;
                     return;
                 }
+                if (maxAmpl > 0)
+                    xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
             } else {
                 ctxt = rectxt;
             }
@@ -2323,12 +2302,24 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                return;
            }
 
-           if (rectxt == NULL)
-               doc = xmlReadMemory((char *) base, info.st_size,
-                                   filename, NULL, options);
-           else
+           if (rectxt == NULL) {
+                xmlParserCtxtPtr ctxt;
+
+                ctxt = xmlNewParserCtxt();
+                if (ctxt == NULL) {
+                    fprintf(stderr, "out of memory\n");
+                    progresult = XMLLINT_ERR_MEM;
+                    return;
+                }
+                if (maxAmpl > 0)
+                    xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
+                doc = xmlCtxtReadMemory(ctxt, base, info.st_size,
+                                        filename, NULL, options);
+                xmlFreeParserCtxt(ctxt);
+            } else {
                doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
                                        filename, NULL, options);
+            }
 
            munmap((char *) base, info.st_size);
            close(fd);
@@ -2347,6 +2338,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                ctxt = rectxt;
             }
 
+            if (maxAmpl > 0)
+                xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
             doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
 
             if (ctxt->valid == 0)
@@ -2355,16 +2348,22 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                 xmlFreeParserCtxt(ctxt);
 #endif /* LIBXML_VALID_ENABLED */
        } else {
-           if (rectxt != NULL)
+           if (rectxt != NULL) {
                doc = xmlCtxtReadFile(rectxt, filename, NULL, options);
-           else {
-#ifdef LIBXML_SAX1_ENABLED
-                if (sax1)
-                   doc = xmlParseFile(filename);
-               else
-#endif /* LIBXML_SAX1_ENABLED */
-               doc = xmlReadFile(filename, NULL, options);
-           }
+           } else {
+                xmlParserCtxtPtr ctxt;
+
+                ctxt = xmlNewParserCtxt();
+                if (ctxt == NULL) {
+                    fprintf(stderr, "out of memory\n");
+                    progresult = XMLLINT_ERR_MEM;
+                    return;
+                }
+                if (maxAmpl > 0)
+                    xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
+                doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
+                xmlFreeParserCtxt(ctxt);
+            }
        }
     }
 
@@ -2435,6 +2434,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
            startTimer();
        }
        doc = xmlCopyDoc(doc, 1);
+        if (doc == NULL) {
+            progresult = XMLLINT_ERR_MEM;
+            xmlFreeDoc(tmp);
+            return;
+        }
        if (timing) {
            endTimer("Copying");
        }
@@ -2738,7 +2742,6 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                 xmlFreeDtd(dtd);
                 return;
            }
-           cvp->userData = NULL;
            cvp->error    = xmlGenericError;
            cvp->warning  = xmlGenericError;
 
@@ -2776,7 +2779,6 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
        if ((timing) && (!repeat)) {
            startTimer();
        }
-       cvp->userData = NULL;
        cvp->error    = xmlGenericError;
        cvp->warning  = xmlGenericError;
        if (!xmlValidateDocument(cvp, doc)) {
@@ -3083,6 +3085,7 @@ static void usage(FILE *f, const char *name) {
 #ifdef LIBXML_XPATH_ENABLED
     fprintf(f, "\t--xpath expr: evaluate the XPath expression, imply --noout\n");
 #endif
+    fprintf(f, "\t--max-ampl value: set maximum amplification factor\n");
 
     fprintf(f, "\nLibxml project home page: https://gitlab.gnome.org/GNOME/libxml2\n");
 }
@@ -3106,12 +3109,31 @@ static void deregisterNode(xmlNodePtr node)
     nbregister--;
 }
 
+static unsigned long
+parseInteger(const char *ctxt, const char *str,
+             unsigned long min, unsigned long max) {
+    char *strEnd;
+    unsigned long val;
+
+    errno = 0;
+    val = strtoul(str, &strEnd, 10);
+    if (errno == EINVAL || *strEnd != 0) {
+        fprintf(stderr, "%s: invalid integer: %s\n", ctxt, str);
+        exit(XMLLINT_ERR_UNCLASS);
+    }
+    if (errno != 0 || val < min || val > max) {
+        fprintf(stderr, "%s: integer out of range: %s\n", ctxt, str);
+        exit(XMLLINT_ERR_UNCLASS);
+    }
+
+    return(val);
+}
+
 int
 main(int argc, char **argv) {
     int i, acount;
     int files = 0;
     int version = 0;
-    const char* indent;
 
     if (argc <= 1) {
        usage(stderr, argv[0]);
@@ -3125,10 +3147,13 @@ main(int argc, char **argv) {
 
        if ((!strcmp(argv[i], "-maxmem")) ||
            (!strcmp(argv[i], "--maxmem"))) {
-            i++;
-            if ((i >= argc) || (sscanf(argv[i], "%d", &maxmem) != 1)) {
-                maxmem = 0;
-            }
+            i++;
+            if (i >= argc) {
+                fprintf(stderr, "maxmem: missing integer value\n");
+                return(XMLLINT_ERR_UNCLASS);
+            }
+            errno = 0;
+            maxmem = parseInteger("maxmem", argv[i], 0, INT_MAX);
         }
     }
     if (maxmem != 0)
@@ -3164,8 +3189,7 @@ main(int argc, char **argv) {
            options |= XML_PARSE_HUGE;
        } else if ((!strcmp(argv[i], "-noent")) ||
                 (!strcmp(argv[i], "--noent"))) {
-           noent++;
-           options |= XML_PARSE_NOENT;
+           noent = 1;
        } else if ((!strcmp(argv[i], "-noenc")) ||
                 (!strcmp(argv[i], "--noenc"))) {
            noenc++;
@@ -3318,21 +3342,18 @@ main(int argc, char **argv) {
 #endif /* LIBXML_OUTPUT_ENABLED */
        else if ((!strcmp(argv[i], "-nowarning")) ||
                 (!strcmp(argv[i], "--nowarning"))) {
-           xmlGetWarningsDefaultValue = 0;
-           xmlPedanticParserDefault(0);
            options |= XML_PARSE_NOWARNING;
+            options &= ~XML_PARSE_PEDANTIC;
         }
        else if ((!strcmp(argv[i], "-pedantic")) ||
                 (!strcmp(argv[i], "--pedantic"))) {
-           xmlGetWarningsDefaultValue = 1;
-           xmlPedanticParserDefault(1);
            options |= XML_PARSE_PEDANTIC;
+            options &= XML_PARSE_NOWARNING;
         }
 #ifdef LIBXML_DEBUG_ENABLED
        else if ((!strcmp(argv[i], "-debugent")) ||
                 (!strcmp(argv[i], "--debugent"))) {
            debugent++;
-           xmlParserDebugEntities = 1;
        }
 #endif
 #ifdef LIBXML_C14N_ENABLED
@@ -3372,9 +3393,7 @@ main(int argc, char **argv) {
         }
        else if ((!strcmp(argv[i], "-noblanks")) ||
                 (!strcmp(argv[i], "--noblanks"))) {
-           noblanks++;
-           xmlKeepBlanksDefault(0);
-           options |= XML_PARSE_NOBLANKS;
+           noblanks = 1;
         }
        else if ((!strcmp(argv[i], "-maxmem")) ||
                 (!strcmp(argv[i], "--maxmem"))) {
@@ -3382,23 +3401,16 @@ main(int argc, char **argv) {
         }
        else if ((!strcmp(argv[i], "-format")) ||
                 (!strcmp(argv[i], "--format"))) {
-            noblanks++;
 #ifdef LIBXML_OUTPUT_ENABLED
-            format = 1;
+           format = 1;
 #endif /* LIBXML_OUTPUT_ENABLED */
-            xmlKeepBlanksDefault(0);
        }
        else if ((!strcmp(argv[i], "-pretty")) ||
                 (!strcmp(argv[i], "--pretty"))) {
-            i++;
+           i++;
 #ifdef LIBXML_OUTPUT_ENABLED
-       if (argv[i] != NULL) {
-                format = atoi(argv[i]);
-                if (format == 1) {
-                    noblanks++;
-                    xmlKeepBlanksDefault(0);
-                }
-       }
+            if (argv[i] != NULL)
+               format = atoi(argv[i]);
 #endif /* LIBXML_OUTPUT_ENABLED */
        }
 #ifdef LIBXML_READER_ENABLED
@@ -3437,20 +3449,19 @@ main(int argc, char **argv) {
                 (!strcmp(argv[i], "--relaxng"))) {
            i++;
            relaxng = argv[i];
-           noent++;
-           options |= XML_PARSE_NOENT;
+           noent = 1;
        } else if ((!strcmp(argv[i], "-schema")) ||
                 (!strcmp(argv[i], "--schema"))) {
            i++;
            schema = argv[i];
-           noent++;
+           noent = 1;
 #endif
 #ifdef LIBXML_SCHEMATRON_ENABLED
        } else if ((!strcmp(argv[i], "-schematron")) ||
                 (!strcmp(argv[i], "--schematron"))) {
            i++;
            schematron = argv[i];
-           noent++;
+           noent = 1;
 #endif
         } else if ((!strcmp(argv[i], "-nonet")) ||
                    (!strcmp(argv[i], "--nonet"))) {
@@ -3477,6 +3488,14 @@ main(int argc, char **argv) {
                   (!strcmp(argv[i], "--oldxml10"))) {
            oldxml10++;
            options |= XML_PARSE_OLD10;
+       } else if ((!strcmp(argv[i], "-max-ampl")) ||
+                  (!strcmp(argv[i], "--max-ampl"))) {
+            i++;
+            if (i >= argc) {
+                fprintf(stderr, "max-ampl: missing integer value\n");
+                return(XMLLINT_ERR_UNCLASS);
+            }
+            maxAmpl = parseInteger("max-ampl", argv[i], 1, UINT_MAX);
        } else {
            fprintf(stderr, "Unknown option %s\n", argv[i]);
            usage(stderr, argv[0]);
@@ -3499,36 +3518,27 @@ main(int argc, char **argv) {
     }
 #endif
 
-#ifdef LIBXML_SAX1_ENABLED
-    if (sax1)
-        xmlSAXDefaultVersion(1);
-    else
-        xmlSAXDefaultVersion(2);
-#endif /* LIBXML_SAX1_ENABLED */
-
     if (chkregister) {
        xmlRegisterNodeDefault(registerNode);
        xmlDeregisterNodeDefault(deregisterNode);
     }
 
-    indent = getenv("XMLLINT_INDENT");
-    if(indent != NULL) {
-       xmlTreeIndentString = indent;
+#ifdef LIBXML_OUTPUT_ENABLED
+    {
+        const char *indent = getenv("XMLLINT_INDENT");
+        if (indent != NULL) {
+            xmlTreeIndentString = indent;
+        }
     }
-
+#endif
 
     defaultEntityLoader = xmlGetExternalEntityLoader();
     xmlSetExternalEntityLoader(xmllintExternalEntityLoader);
 
-    xmlLineNumbersDefault(1);
-    if (loaddtd != 0)
-       xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
-    if (dtdattrs)
-       xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
-    if (noent != 0) xmlSubstituteEntitiesDefault(1);
-#ifdef LIBXML_VALID_ENABLED
-    if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
-#endif /* LIBXML_VALID_ENABLED */
+    if (noent != 0)
+        options |= XML_PARSE_NOENT;
+    if ((noblanks != 0) || (format == 1))
+        options |= XML_PARSE_NOBLANKS;
     if ((htmlout) && (!nowrap)) {
        xmlGenericError(xmlGenericErrorContext,
          "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
@@ -3551,7 +3561,6 @@ main(int argc, char **argv) {
        xmlSchematronParserCtxtPtr ctxt;
 
         /* forces loading the DTDs */
-        xmlLoadExtDtdDefaultValue |= 1;
        options |= XML_PARSE_DTDLOAD;
        if (timing) {
            startTimer();
@@ -3587,7 +3596,6 @@ main(int argc, char **argv) {
        xmlRelaxNGParserCtxtPtr ctxt;
 
         /* forces loading the DTDs */
-        xmlLoadExtDtdDefaultValue |= 1;
        options |= XML_PARSE_DTDLOAD;
        if (timing) {
            startTimer();
@@ -3717,12 +3725,25 @@ main(int argc, char **argv) {
            continue;
        }
 #endif
+        if ((!strcmp(argv[i], "-max-ampl")) ||
+            (!strcmp(argv[i], "--max-ampl"))) {
+           i++;
+           continue;
+        }
        if ((timing) && (repeat))
            startTimer();
        /* Remember file names.  "-" means stdin.  <sven@zen.org> */
        if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
            if (repeat) {
-               xmlParserCtxtPtr ctxt = NULL;
+               xmlParserCtxtPtr ctxt;
+
+                ctxt = xmlNewParserCtxt();
+                if (ctxt == NULL) {
+                    progresult = XMLLINT_ERR_MEM;
+                    goto error;
+                }
+                if (maxAmpl > 0)
+                    xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
 
                for (acount = 0;acount < repeat;acount++) {
 #ifdef LIBXML_READER_ENABLED
@@ -3733,16 +3754,14 @@ main(int argc, char **argv) {
                         if (sax) {
                            testSAX(argv[i]);
                        } else {
-                           if (ctxt == NULL)
-                               ctxt = xmlNewParserCtxt();
                            parseAndPrintFile(argv[i], ctxt);
                        }
 #ifdef LIBXML_READER_ENABLED
                    }
 #endif /* LIBXML_READER_ENABLED */
                }
-               if (ctxt != NULL)
-                   xmlFreeParserCtxt(ctxt);
+
+               xmlFreeParserCtxt(ctxt);
            } else {
                nbregister = 0;
 
@@ -3797,7 +3816,6 @@ main(int argc, char **argv) {
 
 error:
     xmlCleanupParser();
-    xmlMemoryDump();
 
     return(progresult);
 }
index 892d50c..1e999b1 100644 (file)
@@ -12,8 +12,6 @@
 #include <ctype.h>
 #include <time.h>
 
-/* #define DEBUG_MEMORY */
-
 /**
  * MEM_LIST:
  *
 #endif
 #endif
 
-#include <libxml/globals.h>    /* must come before xmlmemory.h */
 #include <libxml/xmlmemory.h>
 #include <libxml/xmlerror.h>
+#include <libxml/parser.h>
 #include <libxml/threads.h>
 
-static int xmlMemInitialized = 0;
+#include "private/memory.h"
+#include "private/threads.h"
+
 static unsigned long  debugMemSize = 0;
 static unsigned long  debugMemBlocks = 0;
 static unsigned long  debugMaxMemSize = 0;
-static xmlMutexPtr xmlMemMutex = NULL;
+static xmlMutex xmlMemMutex;
 
 void xmlMallocBreakpoint(void);
 
@@ -147,18 +147,13 @@ xmlMallocLoc(size_t size, const char * file, int line)
     MEMHDR *p;
     void *ret;
 
-    if (!xmlMemInitialized) xmlInitMemory();
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Malloc(%d)\n",size);
-#endif
+    xmlInitParser();
 
     TEST_POINT
 
     if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlMallocLoc : Unsigned overflow\n");
-       xmlMemoryDump();
        return(NULL);
     }
 
@@ -167,7 +162,6 @@ xmlMallocLoc(size_t size, const char * file, int line)
     if (!p) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlMallocLoc : Out of free space\n");
-       xmlMemoryDump();
        return(NULL);
     }
     p->mh_tag = MEMTAG;
@@ -175,7 +169,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
     p->mh_type = MALLOC_TYPE;
     p->mh_file = file;
     p->mh_line = line;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     p->mh_number = ++block;
     debugMemSize += size;
     debugMemBlocks++;
@@ -183,12 +177,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
 #ifdef MEM_LIST
     debugmem_list_add(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
-
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Malloc(%d) Ok\n",size);
-#endif
+    xmlMutexUnlock(&xmlMemMutex);
 
     if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
 
@@ -223,18 +212,13 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
     MEMHDR *p;
     void *ret;
 
-    if (!xmlMemInitialized) xmlInitMemory();
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Malloc(%d)\n",size);
-#endif
+    xmlInitParser();
 
     TEST_POINT
 
     if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlMallocAtomicLoc : Unsigned overflow\n");
-       xmlMemoryDump();
        return(NULL);
     }
 
@@ -243,7 +227,6 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
     if (!p) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlMallocAtomicLoc : Out of free space\n");
-       xmlMemoryDump();
        return(NULL);
     }
     p->mh_tag = MEMTAG;
@@ -251,7 +234,7 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
     p->mh_type = MALLOC_ATOMIC_TYPE;
     p->mh_file = file;
     p->mh_line = line;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     p->mh_number = ++block;
     debugMemSize += size;
     debugMemBlocks++;
@@ -259,12 +242,7 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
 #ifdef MEM_LIST
     debugmem_list_add(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
-
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Malloc(%d) Ok\n",size);
-#endif
+    xmlMutexUnlock(&xmlMemMutex);
 
     if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
 
@@ -313,14 +291,11 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
 {
     MEMHDR *p, *tmp;
     unsigned long number;
-#ifdef DEBUG_MEMORY
-    size_t oldsize;
-#endif
 
     if (ptr == NULL)
         return(xmlMallocLoc(size, file, line));
 
-    if (!xmlMemInitialized) xmlInitMemory();
+    xmlInitParser();
     TEST_POINT
 
     p = CLIENT_2_HDR(ptr);
@@ -331,21 +306,17 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
         goto error;
     }
     p->mh_tag = ~MEMTAG;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     debugMemSize -= p->mh_size;
     debugMemBlocks--;
-#ifdef DEBUG_MEMORY
-    oldsize = p->mh_size;
-#endif
 #ifdef MEM_LIST
     debugmem_list_delete(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 
     if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlReallocLoc : Unsigned overflow\n");
-       xmlMemoryDump();
        return(NULL);
     }
 
@@ -368,21 +339,17 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
     p->mh_size = size;
     p->mh_file = file;
     p->mh_line = line;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     debugMemSize += size;
     debugMemBlocks++;
     if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
 #ifdef MEM_LIST
     debugmem_list_add(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 
     TEST_POINT
 
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Realloced(%d to %d) Ok\n", oldsize, size);
-#endif
     return(HDR_2_CLIENT(p));
 
 error:
@@ -415,9 +382,6 @@ xmlMemFree(void *ptr)
 {
     MEMHDR *p;
     char *target;
-#ifdef DEBUG_MEMORY
-    size_t size;
-#endif
 
     if (ptr == NULL)
        return;
@@ -446,26 +410,18 @@ xmlMemFree(void *ptr)
     if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
     p->mh_tag = ~MEMTAG;
     memset(target, -1, p->mh_size);
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     debugMemSize -= p->mh_size;
     debugMemBlocks--;
-#ifdef DEBUG_MEMORY
-    size = p->mh_size;
-#endif
 #ifdef MEM_LIST
     debugmem_list_delete(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 
     free(p);
 
     TEST_POINT
 
-#ifdef DEBUG_MEMORY
-    xmlGenericError(xmlGenericErrorContext,
-           "Freed(%d) Ok\n", size);
-#endif
-
     return;
 
 error:
@@ -493,13 +449,12 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
     size_t size = strlen(str) + 1;
     MEMHDR *p;
 
-    if (!xmlMemInitialized) xmlInitMemory();
+    xmlInitParser();
     TEST_POINT
 
     if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
        xmlGenericError(xmlGenericErrorContext,
                "xmlMemStrdupLoc : Unsigned overflow\n");
-       xmlMemoryDump();
        return(NULL);
     }
 
@@ -512,7 +467,7 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
     p->mh_type = STRDUP_TYPE;
     p->mh_file = file;
     p->mh_line = line;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     p->mh_number = ++block;
     debugMemSize += size;
     debugMemBlocks++;
@@ -520,7 +475,7 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
 #ifdef MEM_LIST
     debugmem_list_add(p);
 #endif
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 
     s = (char *) HDR_2_CLIENT(p);
 
@@ -557,6 +512,27 @@ xmlMemoryStrdup(const char *str) {
 }
 
 /**
+ * xmlMemSize:
+ * @ptr:  pointer to the memory allocation
+ *
+ * Returns the size of a memory allocation.
+ */
+
+size_t
+xmlMemSize(void *ptr) {
+    MEMHDR *p;
+
+    if (ptr == NULL)
+       return(0);
+
+    p = CLIENT_2_HDR(ptr);
+    if (p->mh_tag != MEMTAG)
+        return(0);
+
+    return(p->mh_size);
+}
+
+/**
  * xmlMemUsed:
  *
  * Provides the amount of memory currently allocated
@@ -566,12 +542,7 @@ xmlMemoryStrdup(const char *str) {
 
 int
 xmlMemUsed(void) {
-    int res;
-
-    xmlMutexLock(xmlMemMutex);
-    res = debugMemSize;
-    xmlMutexUnlock(xmlMemMutex);
-    return(res);
+    return(debugMemSize);
 }
 
 /**
@@ -586,74 +557,12 @@ int
 xmlMemBlocks(void) {
     int res;
 
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     res = debugMemBlocks;
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
     return(res);
 }
 
-#ifdef MEM_LIST
-/**
- * xmlMemContentShow:
- * @fp:  a FILE descriptor used as the output file
- * @p:  a memory block header
- *
- * tries to show some content from the memory block
- */
-
-static void
-xmlMemContentShow(FILE *fp, MEMHDR *p)
-{
-    int i,j,k,len;
-    const char *buf;
-
-    if (p == NULL) {
-       fprintf(fp, " NULL");
-       return;
-    }
-    len = p->mh_size;
-    buf = (const char *) HDR_2_CLIENT(p);
-
-    for (i = 0;i < len;i++) {
-        if (buf[i] == 0) break;
-       if (!isprint((unsigned char) buf[i])) break;
-    }
-    if ((i < 4) && ((buf[i] != 0) || (i == 0))) {
-        if (len >= 4) {
-           MEMHDR *q;
-           void *cur;
-
-            for (j = 0;(j < len -3) && (j < 40);j += 4) {
-               cur = *((void **) &buf[j]);
-               q = CLIENT_2_HDR(cur);
-               p = memlist;
-               k = 0;
-               while (p != NULL) {
-                   if (p == q) break;
-                   p = p->mh_next;
-                   if (k++ > 100) break;
-               }
-               if ((p != NULL) && (p == q)) {
-                   fprintf(fp, " pointer to #%lu at index %d",
-                           p->mh_number, j);
-                   return;
-               }
-           }
-       }
-    } else if ((i == 0) && (buf[i] == 0)) {
-        fprintf(fp," null");
-    } else {
-        if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
-       else {
-            fprintf(fp," [");
-           for (j = 0;j < i;j++)
-                fprintf(fp,"%c", buf[j]);
-            fprintf(fp,"]");
-       }
-    }
-}
-#endif
-
 /**
  * xmlMemDisplayLast:
  * @fp:  a FILE descriptor used as the output file, if NULL, the result is
@@ -688,7 +597,7 @@ xmlMemDisplayLast(FILE *fp, long nbBytes)
             nbBytes, debugMemSize, debugMaxMemSize);
     fprintf(fp,"BLOCK  NUMBER   SIZE  TYPE\n");
     idx = 0;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     p = memlist;
     while ((p) && (nbBytes > 0)) {
          fprintf(fp,"%-5u  %6lu %6lu ",idx++,p->mh_number,
@@ -701,7 +610,7 @@ xmlMemDisplayLast(FILE *fp, long nbBytes)
            case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
            default:
                fprintf(fp,"Unknown memory block, may be corrupted");
-               xmlMutexUnlock(xmlMemMutex);
+               xmlMutexUnlock(&xmlMemMutex);
                if (old_fp == NULL)
                    fclose(fp);
                return;
@@ -710,16 +619,12 @@ xmlMemDisplayLast(FILE *fp, long nbBytes)
         if (p->mh_tag != MEMTAG)
              fprintf(fp,"  INVALID");
         nb++;
-       if (nb < 100)
-           xmlMemContentShow(fp, p);
-       else
-           fprintf(fp," skip");
 
         fprintf(fp,"\n");
        nbBytes -= (unsigned long)p->mh_size;
         p = p->mh_next;
     }
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 #else
     fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
 #endif
@@ -765,7 +670,7 @@ xmlMemDisplay(FILE *fp)
             debugMemSize, debugMaxMemSize);
     fprintf(fp,"BLOCK  NUMBER   SIZE  TYPE\n");
     idx = 0;
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     p = memlist;
     while (p) {
          fprintf(fp,"%-5u  %6lu %6lu ",idx++,p->mh_number,
@@ -778,7 +683,7 @@ xmlMemDisplay(FILE *fp)
            case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
            default:
                fprintf(fp,"Unknown memory block, may be corrupted");
-               xmlMutexUnlock(xmlMemMutex);
+               xmlMutexUnlock(&xmlMemMutex);
                if (old_fp == NULL)
                    fclose(fp);
                return;
@@ -787,15 +692,11 @@ xmlMemDisplay(FILE *fp)
         if (p->mh_tag != MEMTAG)
              fprintf(fp,"  INVALID");
         nb++;
-       if (nb < 100)
-           xmlMemContentShow(fp, p);
-       else
-           fprintf(fp," skip");
 
         fprintf(fp,"\n");
         p = p->mh_next;
     }
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 #else
     fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
 #endif
@@ -811,10 +712,6 @@ static void debugmem_list_add(MEMHDR *p)
      p->mh_prev = NULL;
      if (memlist) memlist->mh_prev = p;
      memlist = p;
-#ifdef MEM_LIST_DEBUG
-     if (stderr)
-     Mem_Display(stderr);
-#endif
 }
 
 static void debugmem_list_delete(MEMHDR *p)
@@ -824,10 +721,6 @@ static void debugmem_list_delete(MEMHDR *p)
      if (p->mh_prev)
      p->mh_prev->mh_next = p->mh_next;
      else memlist = p->mh_next;
-#ifdef MEM_LIST_DEBUG
-     if (stderr)
-     Mem_Display(stderr);
-#endif
 }
 
 #endif
@@ -872,7 +765,7 @@ xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
        fprintf(fp,"      MEMORY ALLOCATED : %lu, MAX was %lu\n",
                debugMemSize, debugMaxMemSize);
 #ifdef MEM_LIST
-    xmlMutexLock(xmlMemMutex);
+    xmlMutexLock(&xmlMemMutex);
     if (nr > 0) {
        fprintf(fp,"NUMBER   SIZE  TYPE   WHERE\n");
        p = memlist;
@@ -890,13 +783,12 @@ xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
                fprintf(fp,"%s(%u)", p->mh_file, p->mh_line);
            if (p->mh_tag != MEMTAG)
                fprintf(fp,"  INVALID");
-           xmlMemContentShow(fp, p);
            fprintf(fp,"\n");
            nr--;
            p = p->mh_next;
        }
     }
-    xmlMutexUnlock(xmlMemMutex);
+    xmlMutexUnlock(&xmlMemMutex);
 #endif /* MEM_LIST */
 }
 
@@ -935,28 +827,25 @@ xmlMemoryDump(void)
 /**
  * xmlInitMemory:
  *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
+ * DEPRECATED: Alias for xmlInitParser.
+ */
+int
+xmlInitMemory(void) {
+    xmlInitParser();
+    return(0);
+}
+
+/**
+ * xmlInitMemoryInternal:
  *
  * Initialize the memory layer.
  *
  * Returns 0 on success
  */
-int
-xmlInitMemory(void)
-{
+void
+xmlInitMemoryInternal(void) {
      char *breakpoint;
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlInitMemory()\n");
-#endif
-    /*
-     This is really not good code (see Bug 130419).  Suggestions for
-     improvement will be welcome!
-    */
-     if (xmlMemInitialized) return(-1);
-     xmlMemInitialized = 1;
-     xmlMemMutex = xmlNewMutex();
+     xmlInitMutex(&xmlMemMutex);
 
      breakpoint = getenv("XML_MEM_BREAKPOINT");
      if (breakpoint != NULL) {
@@ -967,39 +856,37 @@ xmlInitMemory(void)
          sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
      }
 
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlInitMemory() Ok\n");
-#endif
-     return(0);
 }
 
 /**
  * xmlCleanupMemory:
  *
- * DEPRECATED: This function will be made private. Call xmlCleanupParser
+ * DEPRECATED: This function is a no-op. Call xmlCleanupParser
  * to free global state but see the warnings there. xmlCleanupParser
  * should be only called once at program exit. In most cases, you don't
  * have call cleanup functions at all.
+ */
+void
+xmlCleanupMemory(void) {
+}
+
+/**
+ * xmlCleanupMemoryInternal:
  *
  * Free up all the memory allocated by the library for its own
  * use. This should not be called by user level code.
  */
 void
-xmlCleanupMemory(void) {
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlCleanupMemory()\n");
-#endif
-    if (xmlMemInitialized == 0)
-        return;
-
-    xmlFreeMutex(xmlMemMutex);
-    xmlMemMutex = NULL;
-    xmlMemInitialized = 0;
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlCleanupMemory() Ok\n");
+xmlCleanupMemoryInternal(void) {
+    /*
+     * Don't clean up mutex on Windows. Global state destructors can call
+     * malloc functions after xmlCleanupParser was called. If memory
+     * debugging is enabled, xmlMemMutex can be used after cleanup.
+     *
+     * See python/tests/thread2.py
+     */
+#if !defined(LIBXML_THREAD_ENABLED) || !defined(_WIN32)
+    xmlCleanupMutex(&xmlMemMutex);
 #endif
 }
 
@@ -1021,10 +908,6 @@ xmlCleanupMemory(void) {
 int
 xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
             xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) {
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlMemSetup()\n");
-#endif
     if (freeFunc == NULL)
        return(-1);
     if (mallocFunc == NULL)
@@ -1038,10 +921,6 @@ xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
     xmlMallocAtomic = mallocFunc;
     xmlRealloc = reallocFunc;
     xmlMemStrdup = strdupFunc;
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlMemSetup() Ok\n");
-#endif
     return(0);
 }
 
@@ -1088,10 +967,6 @@ int
 xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
               xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc,
              xmlStrdupFunc strdupFunc) {
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlGcMemSetup()\n");
-#endif
     if (freeFunc == NULL)
        return(-1);
     if (mallocFunc == NULL)
@@ -1107,10 +982,6 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
     xmlMallocAtomic = mallocAtomicFunc;
     xmlRealloc = reallocFunc;
     xmlMemStrdup = strdupFunc;
-#ifdef DEBUG_MEMORY
-     xmlGenericError(xmlGenericErrorContext,
-            "xmlGcMemSetup() Ok\n");
-#endif
     return(0);
 }
 
index 44eba06..d8bce32 100644 (file)
 #include "libxml.h"
 
 #include <string.h>
+#include <libxml/xmlmodule.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/xmlerror.h>
-#include <libxml/xmlmodule.h>
-#include <libxml/globals.h>
+#include <libxml/xmlstring.h>
+
+#include "private/error.h"
 
 #ifdef LIBXML_MODULES_ENABLED
 
@@ -340,7 +342,7 @@ xmlModulePlatformClose(void *handle)
 static int
 xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
 {
-XML_IGNORE_PEDANTIC_WARNINGS
+XML_IGNORE_FPTR_CAST_WARNINGS
     *symbol = GetProcAddress(handle, name);
     return (NULL == *symbol) ? -1 : 0;
 XML_POP_WARNINGS
@@ -348,112 +350,4 @@ XML_POP_WARNINGS
 
 #endif /* _WIN32 */
 
-#ifdef HAVE_BEOS
-
-#include <kernel/image.h>
-
-/*
- * xmlModulePlatformOpen:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns a handle on success, and zero on error.
- */
-
-static void *
-xmlModulePlatformOpen(const char *name)
-{
-    return (void *) load_add_on(name);
-}
-
-/*
- * xmlModulePlatformClose:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns 0 on success, and non-zero on error.
- */
-
-static int
-xmlModulePlatformClose(void *handle)
-{
-    status_t rc;
-
-    rc = unload_add_on((image_id) handle);
-
-    if (rc == B_OK)
-        return 0;
-    else
-        return -1;
-}
-
-/*
- * xmlModulePlatformSymbol:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns 0 on success and the loaded symbol in result, and -1 on error.
- */
-
-static int
-xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
-{
-    status_t rc;
-
-    rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY, symbol);
-
-    return (rc == B_OK) ? 0 : -1;
-}
-
-#endif /* HAVE_BEOS */
-
-#ifdef HAVE_OS2
-
-#include <os2.h>
-
-/*
- * xmlModulePlatformOpen:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosLoadModule.html
- * returns a handle on success, and zero on error.
- */
-
-static void *
-xmlModulePlatformOpen(const char *name)
-{
-    char errbuf[256];
-    void *handle;
-    int rc;
-
-    rc = DosLoadModule(errbuf, sizeof(errbuf) - 1, name, &handle);
-
-    if (rc)
-        return 0;
-    else
-        return (handle);
-}
-
-/*
- * xmlModulePlatformClose:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosFreeModule.html
- * returns 0 on success, and non-zero on error.
- */
-
-static int
-xmlModulePlatformClose(void *handle)
-{
-    return DosFreeModule(handle);
-}
-
-/*
- * xmlModulePlatformSymbol:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosQueryProcAddr.html
- * returns 0 on success and the loaded symbol in result, and -1 on error.
- */
-
-static int
-xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
-{
-    int rc;
-
-    rc = DosQueryProcAddr(handle, 0, name, symbol);
-
-    return (rc == NO_ERROR) ? 0 : -1;
-}
-
-#endif /* HAVE_OS2 */
-
 #endif /* LIBXML_MODULES_ENABLED */
index b3299ce..1f90330 100644 (file)
 #include <libxml/pattern.h>
 #endif
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/tree.h"
+#ifdef LIBXML_XINCLUDE_ENABLED
+#include "private/xinclude.h"
+#endif
 
 #define MAX_ERR_MSG_SIZE 64000
 
@@ -73,9 +77,6 @@
   #endif
 #endif
 
-/* #define DEBUG_CALLBACKS */
-/* #define DEBUG_READER */
-
 /**
  * TODO:
  *
            "Unimplemented block at %s:%d\n",                           \
             __FILE__, __LINE__);
 
-#ifdef DEBUG_READER
-#define DUMP_READER xmlTextReaderDebug(reader);
-#else
-#define DUMP_READER
-#endif
-
 #define CHUNK_SIZE 512
 /************************************************************************
  *                                                                     *
@@ -501,33 +496,6 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
  *                     The reader core parser                          *
  *                                                                     *
  ************************************************************************/
-#ifdef DEBUG_READER
-static void
-xmlTextReaderDebug(xmlTextReaderPtr reader) {
-    if ((reader == NULL) || (reader->ctxt == NULL)) {
-       fprintf(stderr, "xmlTextReader NULL\n");
-       return;
-    }
-    fprintf(stderr, "xmlTextReader: state %d depth %d ",
-           reader->state, reader->depth);
-    if (reader->node == NULL) {
-       fprintf(stderr, "node = NULL\n");
-    } else {
-       fprintf(stderr, "node %s\n", reader->node->name);
-    }
-    fprintf(stderr, "  input: base %d, cur %d, depth %d: ",
-           reader->base, reader->cur, reader->ctxt->nodeNr);
-    if (reader->input->buffer == NULL) {
-       fprintf(stderr, "buffer is NULL\n");
-    } else {
-#ifdef LIBXML_DEBUG_ENABLED
-       xmlDebugDumpString(stderr,
-               &reader->input->buffer->content[reader->cur]);
-#endif
-       fprintf(stderr, "\n");
-    }
-}
-#endif
 
 /**
  * xmlTextReaderEntPush:
@@ -536,30 +504,23 @@ xmlTextReaderDebug(xmlTextReaderPtr reader) {
  *
  * Pushes a new entity reference node on top of the entities stack
  *
- * Returns 0 in case of error, the index in the stack otherwise
+ * Returns -1 in case of error, the index in the stack otherwise
  */
 static int
 xmlTextReaderEntPush(xmlTextReaderPtr reader, xmlNodePtr value)
 {
-    if (reader->entMax <= 0) {
-       reader->entMax = 10;
-       reader->entTab = (xmlNodePtr *) xmlMalloc(reader->entMax *
-                                                 sizeof(reader->entTab[0]));
-        if (reader->entTab == NULL) {
-            xmlGenericError(xmlGenericErrorContext, "xmlMalloc failed !\n");
-            return (0);
-        }
-    }
     if (reader->entNr >= reader->entMax) {
-        reader->entMax *= 2;
-        reader->entTab =
-            (xmlNodePtr *) xmlRealloc(reader->entTab,
-                                      reader->entMax *
-                                      sizeof(reader->entTab[0]));
-        if (reader->entTab == NULL) {
+        size_t newSize = reader->entMax == 0 ? 10 : reader->entMax * 2;
+        xmlNodePtr *tmp;
+
+        tmp = (xmlNodePtr *) xmlRealloc(reader->entTab,
+                                        newSize * sizeof(*tmp));
+        if (tmp == NULL) {
             xmlGenericError(xmlGenericErrorContext, "xmlRealloc failed !\n");
-            return (0);
+            return (-1);
         }
+        reader->entTab = tmp;
+        reader->entMax = newSize;
     }
     reader->entTab[reader->entNr] = value;
     reader->ent = value;
@@ -605,9 +566,6 @@ xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderStartElement(%s)\n", fullname);
-#endif
     if ((reader != NULL) && (reader->startElement != NULL)) {
        reader->startElement(ctx, fullname, atts);
        if ((ctxt->node != NULL) && (ctxt->input != NULL) &&
@@ -631,9 +589,6 @@ xmlTextReaderEndElement(void *ctx, const xmlChar *fullname) {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderEndElement(%s)\n", fullname);
-#endif
     if ((reader != NULL) && (reader->endElement != NULL)) {
        reader->endElement(ctx, fullname);
     }
@@ -668,9 +623,6 @@ xmlTextReaderStartElementNs(void *ctx,
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderStartElementNs(%s)\n", localname);
-#endif
     if ((reader != NULL) && (reader->startElementNs != NULL)) {
        reader->startElementNs(ctx, localname, prefix, URI, nb_namespaces,
                               namespaces, nb_attributes, nb_defaulted,
@@ -702,9 +654,6 @@ xmlTextReaderEndElementNs(void *ctx,
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderEndElementNs(%s)\n", localname);
-#endif
     if ((reader != NULL) && (reader->endElementNs != NULL)) {
        reader->endElementNs(ctx, localname, prefix, URI);
     }
@@ -725,9 +674,6 @@ xmlTextReaderCharacters(void *ctx, const xmlChar *ch, int len)
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderCharacters()\n");
-#endif
     if ((reader != NULL) && (reader->characters != NULL)) {
        reader->characters(ctx, ch, len);
     }
@@ -747,9 +693,6 @@ xmlTextReaderCDataBlock(void *ctx, const xmlChar *ch, int len)
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     xmlTextReaderPtr reader = ctxt->_private;
 
-#ifdef DEBUG_CALLBACKS
-    printf("xmlTextReaderCDataBlock()\n");
-#endif
     if ((reader != NULL) && (reader->cdataBlock != NULL)) {
        reader->cdataBlock(ctx, ch, len);
     }
@@ -769,7 +712,6 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
     xmlBufPtr inbuf;
     int val, s;
     xmlTextReaderState oldstate;
-    int alloc;
 
     if ((reader->input == NULL) || (reader->input->buffer == NULL))
        return(-1);
@@ -777,7 +719,6 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
     oldstate = reader->state;
     reader->state = XML_TEXTREADER_NONE;
     inbuf = reader->input->buffer;
-    alloc = xmlBufGetAllocationScheme(inbuf);
 
     while (reader->state == XML_TEXTREADER_NONE) {
        if (xmlBufUse(inbuf) < reader->cur + CHUNK_SIZE) {
@@ -786,22 +727,17 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
             */
            if (reader->mode != XML_TEXTREADER_MODE_EOF) {
                val = xmlParserInputBufferRead(reader->input, 4096);
-               if ((val == 0) &&
-                   (alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
+               if (val == 0) {
                    if (xmlBufUse(inbuf) == reader->cur) {
                        reader->mode = XML_TEXTREADER_MODE_EOF;
-                       reader->state = oldstate;
+                        break;
                    }
                } else if (val < 0) {
+                    xmlGenericError(xmlGenericErrorContext,
+                                    "xmlParserInputBufferRead failed\n");
                    reader->mode = XML_TEXTREADER_MODE_EOF;
                    reader->state = oldstate;
-                   if ((oldstate != XML_TEXTREADER_START) ||
-                       (reader->ctxt->myDoc != NULL))
-                       return(val);
-               } else if (val == 0) {
-                   /* mark the end of the stream and process the remains */
-                   reader->mode = XML_TEXTREADER_MODE_EOF;
-                   break;
+                   return(val);
                }
 
            } else
@@ -831,12 +767,13 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
            break;
        }
     }
+    reader->state = oldstate;
 
     /*
      * Discard the consumed input when needed and possible
      */
     if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
-        if (alloc != XML_BUFFER_ALLOC_IMMUTABLE) {
+        if (reader->input->readcallback != NULL) {
            if ((reader->cur >= 4096) &&
                (xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) {
                val = xmlBufShrink(inbuf, reader->cur);
@@ -867,7 +804,6 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
            }
        }
     }
-    reader->state = oldstate;
     if (reader->ctxt->wellFormed == 0) {
        reader->mode = XML_TEXTREADER_MODE_EOF;
         return(-1);
@@ -1034,7 +970,11 @@ xmlTextReaderValidateEntity(xmlTextReaderPtr reader) {
            if ((node->children != NULL) &&
                (node->children->type == XML_ENTITY_DECL) &&
                (node->children->children != NULL)) {
-               xmlTextReaderEntPush(reader, node);
+               if (xmlTextReaderEntPush(reader, node) < 0) {
+                    if (node == oldnode)
+                        break;
+                    goto skip_children;
+                }
                node = node->children->children;
                continue;
            } else {
@@ -1231,10 +1171,6 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
     if (reader->ctxt == NULL)
        return(-1);
 
-#ifdef DEBUG_READER
-    fprintf(stderr, "\nREAD ");
-    DUMP_READER
-#endif
     if (reader->mode == XML_TEXTREADER_MODE_INITIAL) {
        reader->mode = XML_TEXTREADER_MODE_INTERACTIVE;
        /*
@@ -1426,8 +1362,6 @@ get_next_node:
     reader->state = XML_TEXTREADER_BACKTRACK;
 
 node_found:
-    DUMP_READER
-
     /*
      * If we are in the middle of a piece of CDATA make sure it's finished
      */
@@ -1444,6 +1378,7 @@ node_found:
      * Handle XInclude if asked for
      */
     if ((reader->xinclude) && (reader->in_xinclude == 0) &&
+        (reader->state != XML_TEXTREADER_BACKTRACK) &&
         (reader->node != NULL) &&
        (reader->node->type == XML_ELEMENT_NODE) &&
        (reader->node->ns != NULL) &&
@@ -1453,6 +1388,7 @@ node_found:
            reader->xincctxt = xmlXIncludeNewContext(reader->ctxt->myDoc);
            xmlXIncludeSetFlags(reader->xincctxt,
                                reader->parserFlags & (~XML_PARSE_NOXINCNODE));
+            xmlXIncludeSetStreamingMode(reader->xincctxt, 1);
        }
        /*
         * expand that node and process it
@@ -1479,7 +1415,8 @@ node_found:
        if ((reader->node->children != NULL) &&
            (reader->node->children->type == XML_ENTITY_DECL) &&
            (reader->node->children->children != NULL)) {
-           xmlTextReaderEntPush(reader, reader->node);
+           if (xmlTextReaderEntPush(reader, reader->node) < 0)
+                goto get_next_node;
            reader->node = reader->node->children->children;
        }
 #ifdef LIBXML_REGEXP_ENABLED
@@ -3613,7 +3550,7 @@ xmlTextReaderQuoteChar(xmlTextReaderPtr reader) {
     if (reader == NULL)
        return(-1);
     /* TODO maybe lookup the attribute value for " first */
-    return((int) '"');
+    return('"');
 }
 
 /**
@@ -3978,19 +3915,19 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
 #ifdef LIBXML_SCHEMAS_ENABLED
 static char *xmlTextReaderBuildMessage(const char *msg, va_list ap) LIBXML_ATTR_FORMAT(1,0);
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityError(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
 {
     xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
@@ -4013,7 +3950,7 @@ xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
     va_end(ap);
 }
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
 {
     xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
@@ -4037,10 +3974,10 @@ xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
 }
 
 static void
-  xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
+xmlTextReaderStructuredError(void *ctxt, const xmlError *error);
 
 static void
-xmlTextReaderValidityStructuredRelay(void *userData, xmlErrorPtr error)
+xmlTextReaderValidityStructuredRelay(void *userData, const xmlError *error)
 {
     xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
 
@@ -4771,7 +4708,7 @@ xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity,
 }
 
 static void
-xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
+xmlTextReaderStructuredError(void *ctxt, const xmlError *error)
 {
     xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
 
@@ -4782,7 +4719,7 @@ xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
     }
 }
 
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlTextReaderError(void *ctxt, const char *msg, ...)
 {
     va_list ap;
@@ -4795,7 +4732,7 @@ xmlTextReaderError(void *ctxt, const char *msg, ...)
 
 }
 
-static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
+static void LIBXML_ATTR_FORMAT(2,3)
 xmlTextReaderWarning(void *ctxt, const char *msg, ...)
 {
     va_list ap;
@@ -4807,7 +4744,7 @@ xmlTextReaderWarning(void *ctxt, const char *msg, ...)
     va_end(ap);
 }
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityError(void *ctxt, const char *msg, ...)
 {
     va_list ap;
@@ -4827,7 +4764,7 @@ xmlTextReaderValidityError(void *ctxt, const char *msg, ...)
     }
 }
 
-static void XMLCDECL
+static void
 xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...)
 {
     va_list ap;
@@ -5235,6 +5172,19 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
 }
 
 /**
+ * xmlTextReaderSetMaxAmplification:
+ * @reader: an XML reader
+ * @maxAmpl:  maximum amplification factor
+ *
+ * Set the maximum amplification factor. See xmlCtxtSetMaxAmplification.
+ */
+void
+xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, unsigned maxAmpl)
+{
+    xmlCtxtSetMaxAmplification(reader->ctxt, maxAmpl);
+}
+
+/**
  * xmlTextReaderByteConsumed:
  * @reader: an XML reader
  *
@@ -5361,8 +5311,7 @@ xmlReaderForMemory(const char *buffer, int size, const char *URL,
     xmlTextReaderPtr reader;
     xmlParserInputBufferPtr buf;
 
-    buf = xmlParserInputBufferCreateStatic(buffer, size,
-                                      XML_CHAR_ENCODING_NONE);
+    buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
     if (buf == NULL) {
         return (NULL);
     }
@@ -5588,7 +5537,7 @@ xmlReaderNewMemory(xmlTextReaderPtr reader, const char *buffer, int size,
     if (buffer == NULL)
         return (-1);
 
-    input = xmlParserInputBufferCreateStatic(buffer, size,
+    input = xmlParserInputBufferCreateMem(buffer, size,
                                       XML_CHAR_ENCODING_NONE);
     if (input == NULL) {
         return (-1);
index a2a36c4..f434a0c 100644 (file)
@@ -19,8 +19,6 @@
 
 #ifdef LIBXML_REGEXP_ENABLED
 
-/* #define DEBUG_ERR */
-
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
 #include <libxml/xmlautomata.h>
 #include <libxml/xmlunicode.h>
 
+#include "private/error.h"
+#include "private/regexp.h"
+
 #ifndef SIZE_MAX
 #define SIZE_MAX ((size_t) -1)
 #endif
 
-/* #define DEBUG_REGEXP_GRAPH */
-/* #define DEBUG_REGEXP_EXEC */
-/* #define DEBUG_PUSH */
-/* #define DEBUG_COMPACTION */
-
 #define MAX_PUSH 10000000
 
+/*
+ * -2 and -3 are used by xmlValidateElementType for other things.
+ */
+#define XML_REGEXP_OK               0
+#define XML_REGEXP_NOT_FOUND        (-1)
+#define XML_REGEXP_INTERNAL_ERROR   (-4)
+#define XML_REGEXP_OUT_OF_MEMORY    (-5)
+#define XML_REGEXP_INTERNAL_LIMIT   (-6)
+#define XML_REGEXP_INVALID_UTF8     (-7)
+
 #ifdef ERROR
 #undef ERROR
 #endif
@@ -52,7 +58,6 @@
 #define CUR (*(ctxt->cur))
 #define NXT(index) (ctxt->cur[index])
 
-#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
 #define NEXTL(l) ctxt->cur += l;
 #define XML_REG_STRING_SEPARATOR '|'
 /*
@@ -361,8 +366,6 @@ static int xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint);
 static int xmlRegCheckCharacterRange(xmlRegAtomType type, int codepoint,
                   int neg, int start, int end, const xmlChar *blockName);
 
-void xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
-
 /************************************************************************
  *                                                                     *
  *             Regexp memory error handler                             *
@@ -435,7 +438,8 @@ xmlRegCalloc2(size_t dim1, size_t dim2, size_t elemSize) {
     void *ret;
 
     /* Check for overflow */
-    if (dim1 > SIZE_MAX / dim2 / elemSize)
+    if ((dim2 == 0) || (elemSize == 0) ||
+        (dim1 > SIZE_MAX / dim2 / elemSize))
         return (NULL);
     totalSize = dim1 * dim2 * elemSize;
     ret = xmlMalloc(totalSize);
@@ -472,7 +476,11 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
     ret->determinist = ctxt->determinist;
     ret->flags = ctxt->flags;
     if (ret->determinist == -1) {
-        xmlRegexpIsDeterminist(ret);
+        if (xmlRegexpIsDeterminist(ret) < 0) {
+            xmlRegexpErrMemory(ctxt, "checking determinism");
+            xmlFree(ret);
+            return(NULL);
+        }
     }
 
     if ((ret->determinist != 0) &&
@@ -511,9 +519,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
                stateRemap[i] = -1;
            }
        }
-#ifdef DEBUG_COMPACTION
-       printf("Final: %d states\n", nbstates);
-#endif
        stringMap = xmlMalloc(ret->nbAtoms * sizeof(char *));
        if (stringMap == NULL) {
            xmlRegexpErrMemory(ctxt, "compiling regexp");
@@ -563,9 +568,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
                return(NULL);
            }
        }
-#ifdef DEBUG_COMPACTION
-       printf("Final: %d atoms\n", nbatoms);
-#endif
        transitions = (int *) xmlRegCalloc2(nbstates + 1, nbatoms + 1,
                                             sizeof(int));
        if (transitions == NULL) {
@@ -598,7 +600,7 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
 
            for (j = 0;j < state->nbTrans;j++) {
                trans = &(state->trans[j]);
-               if ((trans->to == -1) || (trans->atom == NULL))
+               if ((trans->to < 0) || (trans->atom == NULL))
                    continue;
                 atomno = stringRemap[trans->atom->no];
                if ((trans->atom->data != NULL) && (transdata == NULL)) {
@@ -619,11 +621,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
                if (prev != 0) {
                    if (prev != targetno + 1) {
                        ret->determinist = 0;
-#ifdef DEBUG_COMPACTION
-                       printf("Indet: state %d trans %d, atom %d to %d : %d to %d\n",
-                              i, j, trans->atom->no, trans->to, atomno, targetno);
-                       printf("       previous to is %d\n", prev);
-#endif
                        if (transdata != NULL)
                            xmlFree(transdata);
                        xmlFree(transitions);
@@ -648,18 +645,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
            }
        }
        ret->determinist = 1;
-#ifdef DEBUG_COMPACTION
-       /*
-        * Debug
-        */
-       for (i = 0;i < nbstates;i++) {
-           for (j = 0;j < nbatoms + 1;j++) {
-                printf("%02d ", transitions[i * (nbatoms + 1) + j]);
-           }
-           printf("\n");
-       }
-       printf("\n");
-#endif
        /*
         * Cleanup of the old data
         */
@@ -1189,55 +1174,13 @@ xmlRegPrintState(FILE *output, xmlRegStatePtr state) {
     }
 }
 
-#ifdef DEBUG_REGEXP_GRAPH
-static void
-xmlRegPrintCtxt(FILE *output, xmlRegParserCtxtPtr ctxt) {
-    int i;
-
-    fprintf(output, " ctxt: ");
-    if (ctxt == NULL) {
-       fprintf(output, "NULL\n");
-       return;
-    }
-    fprintf(output, "'%s' ", ctxt->string);
-    if (ctxt->error)
-       fprintf(output, "error ");
-    if (ctxt->neg)
-       fprintf(output, "neg ");
-    fprintf(output, "\n");
-    fprintf(output, "%d atoms:\n", ctxt->nbAtoms);
-    for (i = 0;i < ctxt->nbAtoms; i++) {
-       fprintf(output, " %02d ", i);
-       xmlRegPrintAtom(output, ctxt->atoms[i]);
-    }
-    if (ctxt->atom != NULL) {
-       fprintf(output, "current atom:\n");
-       xmlRegPrintAtom(output, ctxt->atom);
-    }
-    fprintf(output, "%d states:", ctxt->nbStates);
-    if (ctxt->start != NULL)
-       fprintf(output, " start: %d", ctxt->start->no);
-    if (ctxt->end != NULL)
-       fprintf(output, " end: %d", ctxt->end->no);
-    fprintf(output, "\n");
-    for (i = 0;i < ctxt->nbStates; i++) {
-       xmlRegPrintState(output, ctxt->states[i]);
-    }
-    fprintf(output, "%d counters:\n", ctxt->nbCounters);
-    for (i = 0;i < ctxt->nbCounters; i++) {
-       fprintf(output, " %d: min %d max %d\n", i, ctxt->counters[i].min,
-                                               ctxt->counters[i].max);
-    }
-}
-#endif
-
 /************************************************************************
  *                                                                     *
  *              Finite Automata structures manipulations               *
  *                                                                     *
  ************************************************************************/
 
-static void
+static xmlRegRangePtr
 xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
                   int neg, xmlRegAtomType type, int start, int end,
                   xmlChar *blockName) {
@@ -1245,11 +1188,11 @@ xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
 
     if (atom == NULL) {
        ERROR("add range: atom is NULL");
-       return;
+       return(NULL);
     }
     if (atom->type != XML_REGEXP_RANGES) {
        ERROR("add range: atom is not ranges");
-       return;
+       return(NULL);
     }
     if (atom->maxRanges == 0) {
        atom->maxRanges = 4;
@@ -1258,7 +1201,7 @@ xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
        if (atom->ranges == NULL) {
            xmlRegexpErrMemory(ctxt, "adding ranges");
            atom->maxRanges = 0;
-           return;
+           return(NULL);
        }
     } else if (atom->nbRanges >= atom->maxRanges) {
        xmlRegRangePtr *tmp;
@@ -1268,16 +1211,17 @@ xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
        if (tmp == NULL) {
            xmlRegexpErrMemory(ctxt, "adding ranges");
            atom->maxRanges /= 2;
-           return;
+           return(NULL);
        }
        atom->ranges = tmp;
     }
     range = xmlRegNewRange(ctxt, neg, type, start, end);
     if (range == NULL)
-       return;
+       return(NULL);
     range->blockName = blockName;
     atom->ranges[atom->nbRanges++] = range;
 
+    return(range);
 }
 
 static int
@@ -1314,26 +1258,17 @@ xmlRegAtomPush(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) {
        ERROR("atom push: atom is NULL");
        return(-1);
     }
-    if (ctxt->maxAtoms == 0) {
-       ctxt->maxAtoms = 4;
-       ctxt->atoms = (xmlRegAtomPtr *) xmlMalloc(ctxt->maxAtoms *
-                                            sizeof(xmlRegAtomPtr));
-       if (ctxt->atoms == NULL) {
-           xmlRegexpErrMemory(ctxt, "pushing atom");
-           ctxt->maxAtoms = 0;
-           return(-1);
-       }
-    } else if (ctxt->nbAtoms >= ctxt->maxAtoms) {
+    if (ctxt->nbAtoms >= ctxt->maxAtoms) {
+        size_t newSize = ctxt->maxAtoms ? ctxt->maxAtoms * 2 : 4;
        xmlRegAtomPtr *tmp;
-       ctxt->maxAtoms *= 2;
-       tmp = (xmlRegAtomPtr *) xmlRealloc(ctxt->atoms, ctxt->maxAtoms *
-                                            sizeof(xmlRegAtomPtr));
+
+       tmp = xmlRealloc(ctxt->atoms, newSize * sizeof(xmlRegAtomPtr));
        if (tmp == NULL) {
            xmlRegexpErrMemory(ctxt, "allocating counter");
-           ctxt->maxAtoms /= 2;
            return(-1);
        }
        ctxt->atoms = tmp;
+        ctxt->maxAtoms = newSize;
     }
     atom->no = ctxt->nbAtoms;
     ctxt->atoms[ctxt->nbAtoms++] = atom;
@@ -1395,10 +1330,6 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
            (trans->to == target->no) &&
            (trans->counter == counter) &&
            (trans->count == count)) {
-#ifdef DEBUG_REGEXP_GRAPH
-           printf("Ignoring duplicate transition from %d to %d\n",
-                   state->no, target->no);
-#endif
            return;
        }
     }
@@ -1424,19 +1355,6 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
        }
        state->trans = tmp;
     }
-#ifdef DEBUG_REGEXP_GRAPH
-    printf("Add trans from %d to %d ", state->no, target->no);
-    if (count == REGEXP_ALL_COUNTER)
-       printf("all transition\n");
-    else if (count >= 0)
-       printf("count based %d\n", count);
-    else if (counter >= 0)
-       printf("counted %d\n", counter);
-    else if (atom == NULL)
-       printf("epsilon transition\n");
-    else if (atom != NULL)
-        xmlRegPrintAtom(stdout, atom);
-#endif
 
     state->trans[state->nbTrans].atom = atom;
     state->trans[state->nbTrans].to = target->no;
@@ -1447,33 +1365,31 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
     xmlRegStateAddTransTo(ctxt, target, state->no);
 }
 
-static int
-xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
-    if (state == NULL) return(-1);
-    if (ctxt->maxStates == 0) {
-       ctxt->maxStates = 4;
-       ctxt->states = (xmlRegStatePtr *) xmlMalloc(ctxt->maxStates *
-                                            sizeof(xmlRegStatePtr));
-       if (ctxt->states == NULL) {
-           xmlRegexpErrMemory(ctxt, "adding state");
-           ctxt->maxStates = 0;
-           return(-1);
-       }
-    } else if (ctxt->nbStates >= ctxt->maxStates) {
+static xmlRegStatePtr
+xmlRegStatePush(xmlRegParserCtxtPtr ctxt) {
+    xmlRegStatePtr state;
+
+    if (ctxt->nbStates >= ctxt->maxStates) {
+        size_t newSize = ctxt->maxStates ? ctxt->maxStates * 2 : 4;
        xmlRegStatePtr *tmp;
-       ctxt->maxStates *= 2;
-       tmp = (xmlRegStatePtr *) xmlRealloc(ctxt->states, ctxt->maxStates *
-                                            sizeof(xmlRegStatePtr));
+
+       tmp = xmlRealloc(ctxt->states, newSize * sizeof(tmp[0]));
        if (tmp == NULL) {
            xmlRegexpErrMemory(ctxt, "adding state");
-           ctxt->maxStates /= 2;
-           return(-1);
+           return(NULL);
        }
        ctxt->states = tmp;
+       ctxt->maxStates = newSize;
     }
+
+    state = xmlRegNewState(ctxt);
+    if (state == NULL)
+        return(NULL);
+
     state->no = ctxt->nbStates;
     ctxt->states[ctxt->nbStates++] = state;
-    return(0);
+
+    return(state);
 }
 
 /**
@@ -1484,19 +1400,21 @@ xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
  * @lax:
  *
  */
-static void
+static int
 xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt,
                           xmlRegStatePtr from, xmlRegStatePtr to,
                           int lax) {
     if (to == NULL) {
-       to = xmlRegNewState(ctxt);
-       xmlRegStatePush(ctxt, to);
+       to = xmlRegStatePush(ctxt);
+        if (to == NULL)
+            return(-1);
        ctxt->state = to;
     }
     if (lax)
        xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER);
     else
        xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER);
+    return(0);
 }
 
 /**
@@ -1506,15 +1424,17 @@ xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt,
  * @to:  the target state or NULL for building a new one
  *
  */
-static void
+static int
 xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt,
                               xmlRegStatePtr from, xmlRegStatePtr to) {
     if (to == NULL) {
-       to = xmlRegNewState(ctxt);
-       xmlRegStatePush(ctxt, to);
+       to = xmlRegStatePush(ctxt);
+        if (to == NULL)
+            return(-1);
        ctxt->state = to;
     }
     xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1);
+    return(0);
 }
 
 /**
@@ -1525,15 +1445,17 @@ xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt,
  * counter:  the counter for that transition
  *
  */
-static void
+static int
 xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt,
            xmlRegStatePtr from, xmlRegStatePtr to, int counter) {
     if (to == NULL) {
-       to = xmlRegNewState(ctxt);
-       xmlRegStatePush(ctxt, to);
+       to = xmlRegStatePush(ctxt);
+        if (to == NULL)
+            return(-1);
        ctxt->state = to;
     }
     xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1);
+    return(0);
 }
 
 /**
@@ -1544,15 +1466,17 @@ xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt,
  * counter:  the counter for that transition
  *
  */
-static void
+static int
 xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
            xmlRegStatePtr from, xmlRegStatePtr to, int counter) {
     if (to == NULL) {
-       to = xmlRegNewState(ctxt);
-       xmlRegStatePush(ctxt, to);
+       to = xmlRegStatePush(ctxt);
+        if (to == NULL)
+            return(-1);
        ctxt->state = to;
     }
     xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter);
+    return(0);
 }
 
 /**
@@ -1579,9 +1503,6 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
         * this is a subexpression handling one should not need to
         * create a new node except for XML_REGEXP_QUANT_RANGE.
         */
-       if (xmlRegAtomPush(ctxt, atom) < 0) {
-           return(-1);
-       }
        if ((to != NULL) && (atom->stop != to) &&
            (atom->quant != XML_REGEXP_QUANT_RANGE)) {
            /*
@@ -1591,8 +1512,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
 #ifdef DV
        } else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) &&
                   (atom->quant != XML_REGEXP_QUANT_ONCE)) {
-           to = xmlRegNewState(ctxt);
-           xmlRegStatePush(ctxt, to);
+           to = xmlRegStatePush(ctxt, to);
+            if (to == NULL)
+                return(-1);
            ctxt->state = to;
            xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to);
 #endif
@@ -1632,8 +1554,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
                if (to != NULL) {
                    newstate = to;
                } else {
-                   newstate = xmlRegNewState(ctxt);
-                   xmlRegStatePush(ctxt, newstate);
+                   newstate = xmlRegStatePush(ctxt);
+                    if (newstate == NULL)
+                        return(-1);
                }
 
                /*
@@ -1661,10 +1584,14 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
                    copy->max = 0;
 
                    if (xmlFAGenerateTransitions(ctxt, atom->start, NULL, copy)
-                       < 0)
+                       < 0) {
+                        xmlRegFreeAtom(copy);
                        return(-1);
+                    }
                    inter = ctxt->state;
                    counter = xmlRegGetCounter(ctxt);
+                    if (counter < 0)
+                        return(-1);
                    ctxt->counters[counter].min = atom->min - 1;
                    ctxt->counters[counter].max = atom->max - 1;
                    /* count the number of times we see it again */
@@ -1683,6 +1610,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
                     * epsilon transition.
                     */
                    counter = xmlRegGetCounter(ctxt);
+                    if (counter < 0)
+                        return(-1);
                    ctxt->counters[counter].min = atom->min - 1;
                    ctxt->counters[counter].max = atom->max - 1;
                    /* allow a way out based on the count */
@@ -1705,6 +1634,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
            default:
                break;
        }
+       if (xmlRegAtomPush(ctxt, atom) < 0)
+           return(-1);
        return(0);
     }
     if ((atom->min == 0) && (atom->max == 0) &&
@@ -1713,12 +1644,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
         * we can discard the atom and generate an epsilon transition instead
         */
        if (to == NULL) {
-           to = xmlRegNewState(ctxt);
-           if (to != NULL)
-               xmlRegStatePush(ctxt, to);
-           else {
+           to = xmlRegStatePush(ctxt);
+           if (to == NULL)
                return(-1);
-           }
        }
        xmlFAGenerateEpsilonTransition(ctxt, from, to);
        ctxt->state = to;
@@ -1726,12 +1654,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
        return(0);
     }
     if (to == NULL) {
-       to = xmlRegNewState(ctxt);
-       if (to != NULL)
-           xmlRegStatePush(ctxt, to);
-       else {
+       to = xmlRegStatePush(ctxt);
+       if (to == NULL)
            return(-1);
-       }
     }
     end = to;
     if ((atom->quant == XML_REGEXP_QUANT_MULT) ||
@@ -1743,18 +1668,12 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
         */
         xmlRegStatePtr tmp;
 
-       tmp = xmlRegNewState(ctxt);
-       if (tmp != NULL)
-           xmlRegStatePush(ctxt, tmp);
-       else {
+       tmp = xmlRegStatePush(ctxt);
+        if (tmp == NULL)
            return(-1);
-       }
        xmlFAGenerateEpsilonTransition(ctxt, tmp, to);
        to = tmp;
     }
-    if (xmlRegAtomPush(ctxt, atom) < 0) {
-       return(-1);
-    }
     if ((atom->quant == XML_REGEXP_QUANT_RANGE) &&
         (atom->min == 0) && (atom->max > 0)) {
        nullable = 1;
@@ -1785,6 +1704,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
        default:
            break;
     }
+    if (xmlRegAtomPush(ctxt, atom) < 0)
+       return(-1);
     return(0);
 }
 
@@ -1803,9 +1724,6 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
     xmlRegStatePtr from;
     xmlRegStatePtr to;
 
-#ifdef DEBUG_REGEXP_GRAPH
-    printf("xmlFAReduceEpsilonTransitions(%d, %d)\n", fromnr, tonr);
-#endif
     from = ctxt->states[fromnr];
     if (from == NULL)
        return;
@@ -1818,56 +1736,67 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
 
     to->mark = XML_REGEXP_MARK_VISITED;
     if (to->type == XML_REGEXP_FINAL_STATE) {
-#ifdef DEBUG_REGEXP_GRAPH
-       printf("State %d is final, so %d becomes final\n", tonr, fromnr);
-#endif
        from->type = XML_REGEXP_FINAL_STATE;
     }
     for (transnr = 0;transnr < to->nbTrans;transnr++) {
-        if (to->trans[transnr].to < 0)
+        xmlRegTransPtr t1 = &to->trans[transnr];
+        int tcounter;
+
+        if (t1->to < 0)
            continue;
-       if (to->trans[transnr].atom == NULL) {
+        if (t1->counter >= 0) {
+            /* assert(counter < 0); */
+            tcounter = t1->counter;
+        } else {
+            tcounter = counter;
+        }
+       if (t1->atom == NULL) {
            /*
             * Don't remove counted transitions
             * Don't loop either
             */
-           if (to->trans[transnr].to != fromnr) {
-               if (to->trans[transnr].count >= 0) {
-                   int newto = to->trans[transnr].to;
-
-                   xmlRegStateAddTrans(ctxt, from, NULL,
-                                       ctxt->states[newto],
-                                       -1, to->trans[transnr].count);
+           if (t1->to != fromnr) {
+               if (t1->count >= 0) {
+                   xmlRegStateAddTrans(ctxt, from, NULL, ctxt->states[t1->to],
+                                       -1, t1->count);
                } else {
-#ifdef DEBUG_REGEXP_GRAPH
-                   printf("Found epsilon trans %d from %d to %d\n",
-                          transnr, tonr, to->trans[transnr].to);
-#endif
-                   if (to->trans[transnr].counter >= 0) {
-                       xmlFAReduceEpsilonTransitions(ctxt, fromnr,
-                                             to->trans[transnr].to,
-                                             to->trans[transnr].counter);
-                   } else {
-                       xmlFAReduceEpsilonTransitions(ctxt, fromnr,
-                                             to->trans[transnr].to,
-                                             counter);
-                   }
+                    xmlFAReduceEpsilonTransitions(ctxt, fromnr, t1->to,
+                                                  tcounter);
                }
            }
        } else {
-           int newto = to->trans[transnr].to;
-
-           if (to->trans[transnr].counter >= 0) {
-               xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
-                                   ctxt->states[newto],
-                                   to->trans[transnr].counter, -1);
-           } else {
-               xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
-                                   ctxt->states[newto], counter, -1);
-           }
+            xmlRegStateAddTrans(ctxt, from, t1->atom,
+                                ctxt->states[t1->to], tcounter, -1);
        }
     }
+}
+
+/**
+ * xmlFAFinishReduceEpsilonTransitions:
+ * @ctxt:  a regexp parser context
+ * @fromnr:  the from state
+ * @tonr:  the to state
+ * @counter:  should that transition be associated to a counted
+ *
+ */
+static void
+xmlFAFinishReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int tonr) {
+    int transnr;
+    xmlRegStatePtr to;
+
+    to = ctxt->states[tonr];
+    if (to == NULL)
+       return;
+    if ((to->mark == XML_REGEXP_MARK_START) ||
+       (to->mark == XML_REGEXP_MARK_NORMAL))
+       return;
+
     to->mark = XML_REGEXP_MARK_NORMAL;
+    for (transnr = 0;transnr < to->nbTrans;transnr++) {
+       xmlRegTransPtr t1 = &to->trans[transnr];
+       if ((t1->to >= 0) && (t1->atom == NULL))
+            xmlFAFinishReduceEpsilonTransitions(ctxt, t1->to);
+    }
 }
 
 /**
@@ -1914,23 +1843,11 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
            newto = state->trans[0].to;
 
             if (state->type == XML_REGEXP_START_STATE) {
-#ifdef DEBUG_REGEXP_GRAPH
-               printf("Found simple epsilon trans from start %d to %d\n",
-                      statenr, newto);
-#endif
             } else {
-#ifdef DEBUG_REGEXP_GRAPH
-               printf("Found simple epsilon trans from %d to %d\n",
-                      statenr, newto);
-#endif
                for (i = 0;i < state->nbTransTo;i++) {
                    tmp = ctxt->states[state->transTo[i]];
                    for (j = 0;j < tmp->nbTrans;j++) {
                        if (tmp->trans[j].to == statenr) {
-#ifdef DEBUG_REGEXP_GRAPH
-                           printf("Changed transition %d on %d to go to %d\n",
-                                  j, tmp->no, newto);
-#endif
                            tmp->trans[j].to = -1;
                            xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom,
                                                ctxt->states[newto],
@@ -1972,9 +1889,6 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
     for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
        state = ctxt->states[statenr];
        if ((state != NULL) && (state->type == XML_REGEXP_UNREACH_STATE)) {
-#ifdef DEBUG_REGEXP_GRAPH
-           printf("Removed unreachable state %d\n", statenr);
-#endif
            xmlRegFreeState(state);
            ctxt->states[statenr] = NULL;
        }
@@ -2003,28 +1917,16 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
                (state->trans[transnr].to >= 0)) {
                if (state->trans[transnr].to == statenr) {
                    state->trans[transnr].to = -1;
-#ifdef DEBUG_REGEXP_GRAPH
-                   printf("Removed loopback epsilon trans %d on %d\n",
-                          transnr, statenr);
-#endif
                } else if (state->trans[transnr].count < 0) {
                    int newto = state->trans[transnr].to;
 
-#ifdef DEBUG_REGEXP_GRAPH
-                   printf("Found epsilon trans %d from %d to %d\n",
-                          transnr, statenr, newto);
-#endif
                    has_epsilon = 1;
                    state->trans[transnr].to = -2;
                    state->mark = XML_REGEXP_MARK_START;
                    xmlFAReduceEpsilonTransitions(ctxt, statenr,
                                      newto, state->trans[transnr].counter);
+                   xmlFAFinishReduceEpsilonTransitions(ctxt, newto);
                    state->mark = XML_REGEXP_MARK_NORMAL;
-#ifdef DEBUG_REGEXP_GRAPH
-               } else {
-                   printf("Found counted transition %d on %d\n",
-                          transnr, statenr);
-#endif
                }
            }
        }
@@ -2098,9 +2000,6 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
     for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
        state = ctxt->states[statenr];
        if ((state != NULL) && (state->reached == XML_REGEXP_MARK_NORMAL)) {
-#ifdef DEBUG_REGEXP_GRAPH
-           printf("Removed unreachable state %d\n", statenr);
-#endif
            xmlRegFreeState(state);
            ctxt->states[statenr] = NULL;
        }
@@ -2626,7 +2525,7 @@ not_determinist:
  */
 static int
 xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
-                        int to, xmlRegAtomPtr atom) {
+                       int fromnr, int tonr, xmlRegAtomPtr atom) {
     int ret = 1;
     int res;
     int transnr, nbTrans;
@@ -2651,22 +2550,23 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
        /*
         * check transitions conflicting with the one looked at
         */
+        if ((t1->to < 0) || (t1->to == fromnr))
+            continue;
        if (t1->atom == NULL) {
-           if (t1->to < 0)
-               continue;
            state->markd = XML_REGEXP_MARK_VISITED;
            res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
-                                          to, atom);
+                                         fromnr, tonr, atom);
            if (res == 0) {
                ret = 0;
                /* t1->nd = 1; */
            }
            continue;
        }
-       if (t1->to != to)
-           continue;
        if (xmlFACompareAtoms(t1->atom, atom, deep)) {
-           ret = 0;
+            /* Treat equal transitions as deterministic. */
+            if ((t1->to != tonr) ||
+                (!xmlFAEqualAtoms(t1->atom, atom, deep)))
+                ret = 0;
            /* mark the transition as non-deterministic */
            t1->nd = 1;
        }
@@ -2715,10 +2615,6 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
     int ret = 1;
     int deep = 1;
 
-#ifdef DEBUG_REGEXP_GRAPH
-    printf("xmlFAComputesDeterminism\n");
-    xmlRegPrintCtxt(stdout, ctxt);
-#endif
     if (ctxt->determinist != -1)
        return(ctxt->determinist);
 
@@ -2744,11 +2640,11 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
                /* t1->nd = 1; */
                continue;
            }
-           if (t1->to == -1) /* eliminated */
+           if (t1->to < 0) /* eliminated */
                continue;
            for (i = 0;i < transnr;i++) {
                t2 = &(state->trans[i]);
-               if (t2->to == -1) /* eliminated */
+               if (t2->to < 0) /* eliminated */
                    continue;
                if (t2->atom != NULL) {
                    if (t1->to == t2->to) {
@@ -2786,11 +2682,11 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
            if (t1->atom == NULL) {
                continue;
            }
-           if (t1->to == -1) /* eliminated */
+           if (t1->to < 0) /* eliminated */
                continue;
            for (i = 0;i < transnr;i++) {
                t2 = &(state->trans[i]);
-               if (t2->to == -1) /* eliminated */
+               if (t2->to < 0) /* eliminated */
                    continue;
                if (t2->atom != NULL) {
                     /*
@@ -2798,29 +2694,39 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
                      * find transitions which indicate a conflict
                      */
                    if (xmlFACompareAtoms(t1->atom, t2->atom, 1)) {
-                       ret = 0;
+                        /*
+                         * Treat equal counter transitions that couldn't be
+                         * eliminated as deterministic.
+                         */
+                        if ((t1->to != t2->to) ||
+                            (t1->counter == t2->counter) ||
+                            (!xmlFAEqualAtoms(t1->atom, t2->atom, deep)))
+                            ret = 0;
                        /* mark the transitions as non-deterministic ones */
                        t1->nd = 1;
                        t2->nd = 1;
                        last = t1;
                    }
-               } else if (t1->to != -1) {
+               } else {
+                    int res;
+
                    /*
                     * do the closure in case of remaining specific
                     * epsilon transitions like choices or all
                     */
-                   ret = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
-                                                  t2->to, t2->atom);
-                    xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t1->to]);
+                   res = xmlFARecurseDeterminism(ctxt, ctxt->states[t2->to],
+                                                 statenr, t1->to, t1->atom);
+                    xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t2->to]);
                    /* don't shortcut the computation so all non deterministic
                       transition get marked down
                    if (ret == 0)
                        return(0);
                     */
-                   if (ret == 0) {
+                   if (res == 0) {
                        t1->nd = 1;
                        /* t2->nd = 1; */
                        last = t1;
+                        ret = 0;
                    }
                }
            }
@@ -3139,33 +3045,11 @@ xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) {
  *                                                                     *
  ************************************************************************/
 
-#ifdef DEBUG_REGEXP_EXEC
-static void
-xmlFARegDebugExec(xmlRegExecCtxtPtr exec) {
-    printf("state: %d:%d:idx %d", exec->state->no, exec->transno, exec->index);
-    if (exec->inputStack != NULL) {
-       int i;
-       printf(": ");
-       for (i = 0;(i < 3) && (i < exec->inputStackNr);i++)
-           printf("%s ", (const char *)
-                  exec->inputStack[exec->inputStackNr - (i + 1)].value);
-    } else {
-       printf(": %s", &(exec->inputString[exec->index]));
-    }
-    printf("\n");
-}
-#endif
-
 static void
 xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
-#ifdef DEBUG_REGEXP_EXEC
-    printf("saving ");
-    exec->transno++;
-    xmlFARegDebugExec(exec);
-    exec->transno--;
-#endif
 #ifdef MAX_PUSH
     if (exec->nbPush > MAX_PUSH) {
+        exec->status = XML_REGEXP_INTERNAL_LIMIT;
         return;
     }
     exec->nbPush++;
@@ -3178,6 +3062,7 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
        if (exec->rollbacks == NULL) {
            xmlRegexpErrMemory(NULL, "saving regexp");
            exec->maxRollbacks = 0;
+            exec->status = XML_REGEXP_OUT_OF_MEMORY;
            return;
        }
        memset(exec->rollbacks, 0,
@@ -3192,6 +3077,7 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
        if (tmp == NULL) {
            xmlRegexpErrMemory(NULL, "saving regexp");
            exec->maxRollbacks /= 2;
+            exec->status = XML_REGEXP_OUT_OF_MEMORY;
            return;
        }
        exec->rollbacks = tmp;
@@ -3207,7 +3093,7 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
                xmlMalloc(exec->comp->nbCounters * sizeof(int));
            if (exec->rollbacks[exec->nbRollbacks].counts == NULL) {
                xmlRegexpErrMemory(NULL, "saving regexp");
-               exec->status = -5;
+               exec->status = XML_REGEXP_OUT_OF_MEMORY;
                return;
            }
        }
@@ -3219,11 +3105,10 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
 
 static void
 xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
+    if (exec->status != XML_REGEXP_OK)
+        return;
     if (exec->nbRollbacks <= 0) {
-       exec->status = -1;
-#ifdef DEBUG_REGEXP_EXEC
-       printf("rollback failed on empty stack\n");
-#endif
+       exec->status = XML_REGEXP_NOT_FOUND;
        return;
     }
     exec->nbRollbacks--;
@@ -3233,7 +3118,7 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
     if (exec->comp->nbCounters > 0) {
        if (exec->rollbacks[exec->nbRollbacks].counts == NULL) {
            fprintf(stderr, "exec save: allocation failed");
-           exec->status = -6;
+           exec->status = XML_REGEXP_INTERNAL_ERROR;
            return;
        }
        if (exec->counts) {
@@ -3241,11 +3126,6 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
               exec->comp->nbCounters * sizeof(int));
        }
     }
-
-#ifdef DEBUG_REGEXP_EXEC
-    printf("restored ");
-    xmlFARegDebugExec(exec);
-#endif
 }
 
 /************************************************************************
@@ -3267,7 +3147,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
     exec->maxRollbacks = 0;
     exec->nbRollbacks = 0;
     exec->rollbacks = NULL;
-    exec->status = 0;
+    exec->status = XML_REGEXP_OK;
     exec->comp = comp;
     exec->state = comp->states[0];
     exec->transno = 0;
@@ -3278,12 +3158,12 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
        exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int));
        if (exec->counts == NULL) {
            xmlRegexpErrMemory(NULL, "running regexp");
-           return(-1);
+           return(XML_REGEXP_OUT_OF_MEMORY);
        }
         memset(exec->counts, 0, comp->nbCounters * sizeof(int));
     } else
        exec->counts = NULL;
-    while ((exec->status == 0) && (exec->state != NULL) &&
+    while ((exec->status == XML_REGEXP_OK) && (exec->state != NULL) &&
           ((exec->inputString[exec->index] != 0) ||
            ((exec->state != NULL) &&
             (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
@@ -3327,7 +3207,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                xmlRegCounterPtr counter;
 
                if (exec->counts == NULL) {
-                   exec->status = -1;
+                   exec->status = XML_REGEXP_INTERNAL_ERROR;
                    goto error;
                }
                /*
@@ -3336,19 +3216,21 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
 
                count = exec->counts[trans->count];
                counter = &exec->comp->counters[trans->count];
-#ifdef DEBUG_REGEXP_EXEC
-               printf("testing count %d: val %d, min %d, max %d\n",
-                      trans->count, count, counter->min,  counter->max);
-#endif
                ret = ((count >= counter->min) && (count <= counter->max));
                if ((ret) && (counter->min != counter->max))
                    deter = 0;
            } else if (atom == NULL) {
                fprintf(stderr, "epsilon transition left at runtime\n");
-               exec->status = -2;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            } else if (exec->inputString[exec->index] != 0) {
-                codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len);
+                len = 4;
+                codepoint = xmlGetUTF8Char(&exec->inputString[exec->index],
+                                           &len);
+                if (codepoint < 0) {
+                    exec->status = XML_REGEXP_INVALID_UTF8;
+                    goto error;
+                }
                ret = xmlRegCheckCharacter(atom, codepoint);
                if ((ret == 1) && (atom->min >= 0) && (atom->max > 0)) {
                    xmlRegStatePtr to = comp->states[trans->to];
@@ -3365,7 +3247,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                        if ((exec->counts == NULL) ||
                            (exec->comp == NULL) ||
                            (exec->comp->counters == NULL)) {
-                           exec->status = -1;
+                           exec->status = XML_REGEXP_INTERNAL_ERROR;
                            goto error;
                        }
                        counter = &exec->comp->counters[trans->counter];
@@ -3375,11 +3257,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                     /* Save before incrementing */
                    if (exec->state->nbTrans > exec->transno + 1) {
                        xmlFARegExecSave(exec);
+                        if (exec->status != XML_REGEXP_OK)
+                            goto error;
                    }
                    if (trans->counter >= 0) {
-#ifdef DEBUG_REGEXP_EXEC
-                       printf("Increasing count %d\n", trans->counter);
-#endif
                        exec->counts[trans->counter]++;
                    }
                    exec->transcount = 1;
@@ -3408,11 +3289,18 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                            exec->transno = -1; /* trick */
                            exec->state = to;
                            xmlFARegExecSave(exec);
+                            if (exec->status != XML_REGEXP_OK)
+                                goto error;
                            exec->transno = transno;
                            exec->state = state;
                        }
-                       codepoint = CUR_SCHAR(&(exec->inputString[exec->index]),
-                                             len);
+                        len = 4;
+                        codepoint = xmlGetUTF8Char(
+                                &exec->inputString[exec->index], &len);
+                        if (codepoint < 0) {
+                            exec->status = XML_REGEXP_INVALID_UTF8;
+                            goto error;
+                        }
                        ret = xmlRegCheckCharacter(atom, codepoint);
                        exec->transcount++;
                    } while (ret == 1);
@@ -3430,12 +3318,9 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                    }
                    if (trans->counter >= 0) {
                        if (exec->counts == NULL) {
-                           exec->status = -1;
+                           exec->status = XML_REGEXP_INTERNAL_ERROR;
                            goto error;
                        }
-#ifdef DEBUG_REGEXP_EXEC
-                       printf("Decreasing count %d\n", trans->counter);
-#endif
                        exec->counts[trans->counter]--;
                    }
                } else if ((ret == 0) && (atom->min == 0) && (atom->max > 0)) {
@@ -3458,15 +3343,9 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                if ((trans->nd == 1) ||
                    ((trans->count >= 0) && (deter == 0) &&
                     (exec->state->nbTrans > exec->transno + 1))) {
-#ifdef DEBUG_REGEXP_EXEC
-                   if (trans->nd == 1)
-                       printf("Saving on nd transition atom %d for %c at %d\n",
-                              trans->atom->no, codepoint, exec->index);
-                   else
-                       printf("Saving on counted transition count %d for %c at %d\n",
-                              trans->count, codepoint, exec->index);
-#endif
                    xmlFARegExecSave(exec);
+                    if (exec->status != XML_REGEXP_OK)
+                        goto error;
                }
                if (trans->counter >= 0) {
                    xmlRegCounterPtr counter;
@@ -3475,32 +3354,22 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                    if ((exec->counts == NULL) ||
                        (exec->comp == NULL) ||
                        (exec->comp->counters == NULL)) {
-                       exec->status = -1;
+                       exec->status = XML_REGEXP_INTERNAL_ERROR;
                        goto error;
                    }
                    counter = &exec->comp->counters[trans->counter];
                    if (exec->counts[trans->counter] >= counter->max)
                        continue; /* for loop on transitions */
-#ifdef DEBUG_REGEXP_EXEC
-                   printf("Increasing count %d\n", trans->counter);
-#endif
                    exec->counts[trans->counter]++;
                }
                if ((trans->count >= 0) &&
                    (trans->count < REGEXP_ALL_COUNTER)) {
                    if (exec->counts == NULL) {
-                       exec->status = -1;
+                       exec->status = XML_REGEXP_INTERNAL_ERROR;
                        goto error;
                    }
-#ifdef DEBUG_REGEXP_EXEC
-                   printf("resetting count %d on transition\n",
-                          trans->count);
-#endif
                    exec->counts[trans->count] = 0;
                }
-#ifdef DEBUG_REGEXP_EXEC
-               printf("entering state %d\n", trans->to);
-#endif
                exec->state = comp->states[trans->to];
                exec->transno = 0;
                if (trans->atom != NULL) {
@@ -3508,7 +3377,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
                }
                goto progress;
            } else if (ret < 0) {
-               exec->status = -4;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            }
        }
@@ -3518,10 +3387,6 @@ rollback:
             * Failed to find a way out
             */
            exec->determinist = 0;
-#ifdef DEBUG_REGEXP_EXEC
-           printf("rollback from state %d on %d:%c\n", exec->state->no,
-                  codepoint,codepoint);
-#endif
            xmlFARegExecRollBack(exec);
        }
 progress:
@@ -3539,16 +3404,13 @@ error:
        xmlFree(exec->rollbacks);
     }
     if (exec->state == NULL)
-        return(-1);
+        return(XML_REGEXP_INTERNAL_ERROR);
     if (exec->counts != NULL)
        xmlFree(exec->counts);
-    if (exec->status == 0)
+    if (exec->status == XML_REGEXP_OK)
        return(1);
-    if (exec->status == -1) {
-       if (exec->nbPush > MAX_PUSH)
-           return(-1);
+    if (exec->status == XML_REGEXP_NOT_FOUND)
        return(0);
-    }
     return(exec->status);
 }
 
@@ -3557,9 +3419,6 @@ error:
  *     Progressive interface to the verifier one atom at a time        *
  *                                                                     *
  ************************************************************************/
-#ifdef DEBUG_ERR
-static void testerr(xmlRegExecCtxtPtr exec);
-#endif
 
 /**
  * xmlRegNewExecCtxt:
@@ -3592,7 +3451,7 @@ xmlRegNewExecCtxt(xmlRegexpPtr comp, xmlRegExecCallbacks callback, void *data) {
     exec->maxRollbacks = 0;
     exec->nbRollbacks = 0;
     exec->rollbacks = NULL;
-    exec->status = 0;
+    exec->status = XML_REGEXP_OK;
     exec->comp = comp;
     if (comp->compact == NULL)
        exec->state = comp->states[0];
@@ -3667,9 +3526,6 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
 static void
 xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value,
                            void *data) {
-#ifdef DEBUG_PUSH
-    printf("saving value: %d:%s\n", exec->inputStackNr, value);
-#endif
     if (exec->inputStackMax == 0) {
        exec->inputStackMax = 4;
        exec->inputStack = (xmlRegInputTokenPtr)
@@ -3782,10 +3638,6 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
        return(0);
     }
 
-#ifdef DEBUG_PUSH
-    printf("value pushed: %s\n", value);
-#endif
-
     /*
      * Examine all outside transitions from current state
      */
@@ -3799,9 +3651,6 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
                    exec->callback(exec->data, value,
                          comp->transdata[state * comp->nbstrings + i], data);
                }
-#ifdef DEBUG_PUSH
-               printf("entering state %d\n", target);
-#endif
                if (comp->compact[target * (comp->nbstrings + 1)] ==
                    XML_REGEXP_SINK_STATE)
                    goto error;
@@ -3817,19 +3666,13 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
      * Failed to find an exit transition out from current state for the
      * current token
      */
-#ifdef DEBUG_PUSH
-    printf("failed to find a transition for %s on state %d\n", value, state);
-#endif
 error:
     if (exec->errString != NULL)
         xmlFree(exec->errString);
     exec->errString = xmlStrdup(value);
     exec->errStateNo = state;
-    exec->status = -1;
-#ifdef DEBUG_ERR
-    testerr(exec);
-#endif
-    return(-1);
+    exec->status = XML_REGEXP_NOT_FOUND;
+    return(XML_REGEXP_NOT_FOUND);
 }
 
 /**
@@ -3857,7 +3700,7 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
        return(-1);
     if (exec->comp == NULL)
        return(-1);
-    if (exec->status != 0)
+    if (exec->status != XML_REGEXP_OK)
        return(exec->status);
 
     if (exec->comp->compact != NULL)
@@ -3869,9 +3712,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
        final = 1;
     }
 
-#ifdef DEBUG_PUSH
-    printf("value pushed: %s\n", value);
-#endif
     /*
      * If we have an active rollback stack push the new value there
      * and get back to where we were left
@@ -3880,12 +3720,9 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
        xmlFARegExecSaveInputString(exec, value, data);
        value = exec->inputStack[exec->index].value;
        data = exec->inputStack[exec->index].data;
-#ifdef DEBUG_PUSH
-       printf("value loaded: %s\n", value);
-#endif
     }
 
-    while ((exec->status == 0) &&
+    while ((exec->status == XML_REGEXP_OK) &&
           ((value != NULL) ||
            ((final == 1) &&
             (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
@@ -3913,9 +3750,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
 
                ret = 0;
 
-#ifdef DEBUG_PUSH
-               printf("testing all lax %d\n", trans->count);
-#endif
                /*
                 * Check all counted transitions from the current state
                 */
@@ -3951,9 +3785,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
 
                ret = 1;
 
-#ifdef DEBUG_PUSH
-               printf("testing all %d\n", trans->count);
-#endif
                /*
                 * Check all counted transitions from the current state
                 */
@@ -3978,14 +3809,10 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
 
                count = exec->counts[trans->count];
                counter = &exec->comp->counters[trans->count];
-#ifdef DEBUG_PUSH
-               printf("testing count %d: val %d, min %d, max %d\n",
-                      trans->count, count, counter->min,  counter->max);
-#endif
                ret = ((count >= counter->min) && (count <= counter->max));
            } else if (atom == NULL) {
                fprintf(stderr, "epsilon transition left at runtime\n");
-               exec->status = -2;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            } else if (value != NULL) {
                ret = xmlRegStrEqualWildcard(atom->valuep, value);
@@ -4027,9 +3854,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
                        exec->index++;
                        value = exec->inputStack[exec->index].value;
                        data = exec->inputStack[exec->index].data;
-#ifdef DEBUG_PUSH
-                       printf("value loaded: %s\n", value);
-#endif
 
                        /*
                         * End of input: stop here
@@ -4084,22 +3908,12 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
                    xmlFARegExecSave(exec);
                }
                if (trans->counter >= 0) {
-#ifdef DEBUG_PUSH
-                   printf("Increasing count %d\n", trans->counter);
-#endif
                    exec->counts[trans->counter]++;
                }
                if ((trans->count >= 0) &&
                    (trans->count < REGEXP_ALL_COUNTER)) {
-#ifdef DEBUG_REGEXP_EXEC
-                   printf("resetting count %d on transition\n",
-                          trans->count);
-#endif
                    exec->counts[trans->count] = 0;
                }
-#ifdef DEBUG_PUSH
-               printf("entering state %d\n", trans->to);
-#endif
                 if ((exec->comp->states[trans->to] != NULL) &&
                    (exec->comp->states[trans->to]->type ==
                     XML_REGEXP_SINK_STATE)) {
@@ -4122,27 +3936,18 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
                        if (exec->index < exec->inputStackNr) {
                            value = exec->inputStack[exec->index].value;
                            data = exec->inputStack[exec->index].data;
-#ifdef DEBUG_PUSH
-                           printf("value loaded: %s\n", value);
-#endif
                        } else {
                            value = NULL;
                            data = NULL;
-#ifdef DEBUG_PUSH
-                           printf("end of input\n");
-#endif
                        }
                    } else {
                        value = NULL;
                        data = NULL;
-#ifdef DEBUG_PUSH
-                       printf("end of input\n");
-#endif
                    }
                }
                goto progress;
            } else if (ret < 0) {
-               exec->status = -4;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            }
        }
@@ -4169,12 +3974,10 @@ rollback:
             */
            exec->determinist = 0;
            xmlFARegExecRollBack(exec);
-           if ((exec->inputStack != NULL ) && (exec->status == 0)) {
+           if ((exec->inputStack != NULL ) &&
+                (exec->status == XML_REGEXP_OK)) {
                value = exec->inputStack[exec->index].value;
                data = exec->inputStack[exec->index].data;
-#ifdef DEBUG_PUSH
-               printf("value loaded: %s\n", value);
-#endif
            }
        }
        continue;
@@ -4182,14 +3985,9 @@ progress:
         progress = 1;
        continue;
     }
-    if (exec->status == 0) {
+    if (exec->status == XML_REGEXP_OK) {
         return(exec->state->type == XML_REGEXP_FINAL_STATE);
     }
-#ifdef DEBUG_ERR
-    if (exec->status < 0) {
-       testerr(exec);
-    }
-#endif
     return(exec->status);
 }
 
@@ -4233,7 +4031,7 @@ xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
        return(-1);
     if (exec->comp == NULL)
        return(-1);
-    if (exec->status != 0)
+    if (exec->status != XML_REGEXP_OK)
        return(exec->status);
 
     if (value2 == NULL)
@@ -4245,7 +4043,7 @@ xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
     if (150 < lenn + lenp + 2) {
        str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
        if (str == NULL) {
-           exec->status = -1;
+           exec->status = XML_REGEXP_OUT_OF_MEMORY;
            return(-1);
        }
     } else {
@@ -4474,7 +4272,7 @@ xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string,
     if (exec == NULL)
         return(-1);
     if (string != NULL) {
-        if (exec->status != 0)
+        if (exec->status != XML_REGEXP_OK)
            *string = exec->errString;
        else
            *string = NULL;
@@ -4482,17 +4280,6 @@ xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string,
     return(xmlRegExecGetValues(exec, 1, nbval, nbneg, values, terminal));
 }
 
-#ifdef DEBUG_ERR
-static void testerr(xmlRegExecCtxtPtr exec) {
-    const xmlChar *string;
-    xmlChar *values[5];
-    int nb = 5;
-    int nbneg;
-    int terminal;
-    xmlRegExecErrInfo(exec, &string, &nb, &nbneg, &values[0], &terminal);
-}
-#endif
-
 #if 0
 static int
 xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
@@ -4503,10 +4290,10 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
 
     if (exec == NULL)
        return(-1);
-    if (exec->status != 0)
+    if (exec->status != XML_REGEXP_OK)
        return(exec->status);
 
-    while ((exec->status == 0) &&
+    while ((exec->status == XML_REGEXP_OK) &&
           ((exec->inputString[exec->index] != 0) ||
            (exec->state->type != XML_REGEXP_FINAL_STATE))) {
 
@@ -4535,14 +4322,10 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
 
                count = exec->counts[trans->count];
                counter = &exec->comp->counters[trans->count];
-#ifdef DEBUG_REGEXP_EXEC
-               printf("testing count %d: val %d, min %d, max %d\n",
-                      trans->count, count, counter->min,  counter->max);
-#endif
                ret = ((count >= counter->min) && (count <= counter->max));
            } else if (atom == NULL) {
                fprintf(stderr, "epsilon transition left at runtime\n");
-               exec->status = -2;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            } else if (exec->inputString[exec->index] != 0) {
                 codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len);
@@ -4612,20 +4395,11 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
                 * restart count for expressions like this ((abc){2})*
                 */
                if (trans->count >= 0) {
-#ifdef DEBUG_REGEXP_EXEC
-                   printf("Reset count %d\n", trans->count);
-#endif
                    exec->counts[trans->count] = 0;
                }
                if (trans->counter >= 0) {
-#ifdef DEBUG_REGEXP_EXEC
-                   printf("Increasing count %d\n", trans->counter);
-#endif
                    exec->counts[trans->counter]++;
                }
-#ifdef DEBUG_REGEXP_EXEC
-               printf("entering state %d\n", trans->to);
-#endif
                exec->state = exec->comp->states[trans->to];
                exec->transno = 0;
                if (trans->atom != NULL) {
@@ -4633,7 +4407,7 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
                }
                goto progress;
            } else if (ret < 0) {
-               exec->status = -4;
+               exec->status = XML_REGEXP_INTERNAL_ERROR;
                break;
            }
        }
@@ -4668,7 +4442,12 @@ xmlFAIsChar(xmlRegParserCtxtPtr ctxt) {
     int cur;
     int len;
 
-    cur = CUR_SCHAR(ctxt->cur, len);
+    len = 4;
+    cur = xmlGetUTF8Char(ctxt->cur, &len);
+    if (cur < 0) {
+        ERROR("Invalid UTF-8");
+        return(0);
+    }
     if ((cur == '.') || (cur == '\\') || (cur == '?') ||
        (cur == '*') || (cur == '+') || (cur == '(') ||
        (cur == ')') || (cur == '|') || (cur == 0x5B) ||
@@ -4892,11 +4671,16 @@ xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) {
     }
     if (ctxt->atom == NULL) {
        ctxt->atom = xmlRegNewAtom(ctxt, type);
-       if (ctxt->atom != NULL)
-           ctxt->atom->valuep = blockName;
+        if (ctxt->atom == NULL) {
+            xmlFree(blockName);
+            return;
+        }
+       ctxt->atom->valuep = blockName;
     } else if (ctxt->atom->type == XML_REGEXP_RANGES) {
-        xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
-                          type, 0, 0, blockName);
+        if (xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
+                               type, 0, 0, blockName) == NULL) {
+            xmlFree(blockName);
+        }
     }
 }
 
@@ -5151,7 +4935,12 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
        end = start;
         len = 1;
     } else if ((cur != 0x5B) && (cur != 0x5D)) {
-        end = start = CUR_SCHAR(ctxt->cur, len);
+        len = 4;
+        end = start = xmlGetUTF8Char(ctxt->cur, &len);
+        if (start < 0) {
+            ERROR("Invalid UTF-8");
+            return;
+        }
     } else {
        ERROR("Expecting a char range");
        return;
@@ -5190,7 +4979,12 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
        }
         len = 1;
     } else if ((cur != '\0') && (cur != 0x5B) && (cur != 0x5D)) {
-        end = CUR_SCHAR(ctxt->cur, len);
+        len = 4;
+        end = xmlGetUTF8Char(ctxt->cur, &len);
+        if (end < 0) {
+            ERROR("Invalid UTF-8");
+            return;
+        }
     } else {
        ERROR("Expecting the end of a char range");
        return;
@@ -5405,7 +5199,12 @@ xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
        ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL);
        if (ctxt->atom == NULL)
            return(-1);
-       codepoint = CUR_SCHAR(ctxt->cur, len);
+        len = 4;
+        codepoint = xmlGetUTF8Char(ctxt->cur, &len);
+        if (codepoint < 0) {
+            ERROR("Invalid UTF-8");
+            return(-1);
+        }
        ctxt->atom->codepoint = codepoint;
        NEXTL(len);
        return(1);
@@ -5500,8 +5299,12 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
        xmlFAGenerateEpsilonTransition(ctxt, previous, to);
     } else {
        if (xmlFAGenerateTransitions(ctxt, previous,
-               (CUR=='|' || CUR==')' || CUR==0) ? to : NULL, ctxt->atom) < 0)
+               (CUR=='|' || CUR==')' || CUR==0) ? to : NULL,
+                ctxt->atom) < 0) {
+            xmlRegFreeAtom(ctxt->atom);
+            ctxt->atom = NULL;
            return(-1);
+        }
        previous = ctxt->state;
        ctxt->atom = NULL;
     }
@@ -5510,8 +5313,11 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
        if (ret != 0) {
            if (xmlFAGenerateTransitions(ctxt, previous,
                    (CUR=='|' || CUR==')' || CUR==0) ? to : NULL,
-                    ctxt->atom) < 0)
-                   return(-1);
+                    ctxt->atom) < 0) {
+                xmlRegFreeAtom(ctxt->atom);
+                ctxt->atom = NULL;
+                return(-1);
+            }
            previous = ctxt->state;
            ctxt->atom = NULL;
        }
@@ -5535,9 +5341,6 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
     ctxt->end = NULL;
     xmlFAParseBranch(ctxt, NULL);
     if (top) {
-#ifdef DEBUG_REGEXP_GRAPH
-       printf("State %d is final\n", ctxt->state->no);
-#endif
        ctxt->state->type = XML_REGEXP_FINAL_STATE;
     }
     if (CUR != '|') {
@@ -5612,27 +5415,30 @@ xmlRegexpPrint(FILE *output, xmlRegexpPtr regexp) {
  */
 xmlRegexpPtr
 xmlRegexpCompile(const xmlChar *regexp) {
-    xmlRegexpPtr ret;
+    xmlRegexpPtr ret = NULL;
     xmlRegParserCtxtPtr ctxt;
 
+    if (regexp == NULL)
+        return(NULL);
+
     ctxt = xmlRegNewParserCtxt(regexp);
     if (ctxt == NULL)
        return(NULL);
 
     /* initialize the parser */
+    ctxt->state = xmlRegStatePush(ctxt);
+    if (ctxt->state == NULL)
+        goto error;
+    ctxt->start = ctxt->state;
     ctxt->end = NULL;
-    ctxt->start = ctxt->state = xmlRegNewState(ctxt);
-    xmlRegStatePush(ctxt, ctxt->start);
 
     /* parse the expression building an automata */
     xmlFAParseRegExp(ctxt, 1);
     if (CUR != 0) {
        ERROR("xmlFAParseRegExp: extra characters");
     }
-    if (ctxt->error != 0) {
-       xmlRegFreeParserCtxt(ctxt);
-       return(NULL);
-    }
+    if (ctxt->error != 0)
+        goto error;
     ctxt->end = ctxt->state;
     ctxt->start->type = XML_REGEXP_START_STATE;
     ctxt->end->type = XML_REGEXP_FINAL_STATE;
@@ -5641,11 +5447,11 @@ xmlRegexpCompile(const xmlChar *regexp) {
     xmlFAEliminateEpsilonTransitions(ctxt);
 
 
-    if (ctxt->error != 0) {
-       xmlRegFreeParserCtxt(ctxt);
-       return(NULL);
-    }
+    if (ctxt->error != 0)
+        goto error;
     ret = xmlRegEpxFromParse(ctxt);
+
+error:
     xmlRegFreeParserCtxt(ctxt);
     return(ret);
 }
@@ -5770,18 +5576,15 @@ xmlNewAutomata(void) {
        return(NULL);
 
     /* initialize the parser */
-    ctxt->end = NULL;
-    ctxt->start = ctxt->state = xmlRegNewState(ctxt);
-    if (ctxt->start == NULL) {
+    ctxt->state = xmlRegStatePush(ctxt);
+    if (ctxt->state == NULL) {
        xmlFreeAutomata(ctxt);
        return(NULL);
     }
+    ctxt->start = ctxt->state;
+    ctxt->end = NULL;
+
     ctxt->start->type = XML_REGEXP_START_STATE;
-    if (xmlRegStatePush(ctxt, ctxt->start) < 0) {
-        xmlRegFreeState(ctxt->start);
-       xmlFreeAutomata(ctxt);
-       return(NULL);
-    }
     ctxt->flags = 0;
 
     return(ctxt);
@@ -6044,6 +5847,8 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
        return(NULL);
     if ((token2 == NULL) || (*token2 == 0)) {
        atom->valuep = xmlStrdup(token);
+        if (atom->valuep == NULL)
+            goto error;
     } else {
        int lenn, lenp;
        xmlChar *str;
@@ -6052,10 +5857,8 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
        lenp = strlen((char *) token);
 
        str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
-       if (str == NULL) {
-           xmlRegFreeAtom(atom);
-           return(NULL);
-       }
+       if (str == NULL)
+           goto error;
        memcpy(&str[0], token, lenp);
        str[lenp] = '|';
        memcpy(&str[lenp + 1], token2, lenn);
@@ -6074,16 +5877,20 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
      * associate a counter to the transition.
      */
     counter = xmlRegGetCounter(am);
+    if (counter < 0)
+        goto error;
     am->counters[counter].min = min;
     am->counters[counter].max = max;
 
     /* xmlFAGenerateTransitions(am, from, to, atom); */
     if (to == NULL) {
-        to = xmlRegNewState(am);
-       xmlRegStatePush(am, to);
+       to = xmlRegStatePush(am);
+        if (to == NULL)
+            goto error;
     }
     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
-    xmlRegAtomPush(am, atom);
+    if (xmlRegAtomPush(am, atom) < 0)
+        goto error;
     am->state = to;
 
     if (to == NULL)
@@ -6093,6 +5900,10 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
     if (min == 0)
        xmlFAGenerateEpsilonTransition(am, from, to);
     return(to);
+
+error:
+    xmlRegFreeAtom(atom);
+    return(NULL);
 }
 
 /**
@@ -6129,6 +5940,8 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
     if (atom == NULL)
        return(NULL);
     atom->valuep = xmlStrdup(token);
+    if (atom->valuep == NULL)
+        goto error;
     atom->data = data;
     if (min == 0)
        atom->min = 1;
@@ -6140,16 +5953,20 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
      * associate a counter to the transition.
      */
     counter = xmlRegGetCounter(am);
+    if (counter < 0)
+        goto error;
     am->counters[counter].min = min;
     am->counters[counter].max = max;
 
     /* xmlFAGenerateTransitions(am, from, to, atom); */
     if (to == NULL) {
-        to = xmlRegNewState(am);
-       xmlRegStatePush(am, to);
+       to = xmlRegStatePush(am);
+        if (to == NULL)
+            goto error;
     }
     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
-    xmlRegAtomPush(am, atom);
+    if (xmlRegAtomPush(am, atom) < 0)
+        goto error;
     am->state = to;
 
     if (to == NULL)
@@ -6159,6 +5976,10 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
     if (min == 0)
        xmlFAGenerateEpsilonTransition(am, from, to);
     return(to);
+
+error:
+    xmlRegFreeAtom(atom);
+    return(NULL);
 }
 
 /**
@@ -6199,6 +6020,8 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
        return(NULL);
     if ((token2 == NULL) || (*token2 == 0)) {
        atom->valuep = xmlStrdup(token);
+        if (atom->valuep == NULL)
+            goto error;
     } else {
        int lenn, lenp;
        xmlChar *str;
@@ -6207,10 +6030,8 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
        lenp = strlen((char *) token);
 
        str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
-       if (str == NULL) {
-           xmlRegFreeAtom(atom);
-           return(NULL);
-       }
+       if (str == NULL)
+           goto error;
        memcpy(&str[0], token, lenp);
        str[lenp] = '|';
        memcpy(&str[lenp + 1], token2, lenn);
@@ -6226,18 +6047,26 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
      * associate a counter to the transition.
      */
     counter = xmlRegGetCounter(am);
+    if (counter < 0)
+        goto error;
     am->counters[counter].min = 1;
     am->counters[counter].max = 1;
 
     /* xmlFAGenerateTransitions(am, from, to, atom); */
     if (to == NULL) {
-       to = xmlRegNewState(am);
-       xmlRegStatePush(am, to);
+       to = xmlRegStatePush(am);
+        if (to == NULL)
+            goto error;
     }
     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
-    xmlRegAtomPush(am, atom);
+    if (xmlRegAtomPush(am, atom) < 0)
+        goto error;
     am->state = to;
     return(to);
+
+error:
+    xmlRegFreeAtom(atom);
+    return(NULL);
 }
 
 
@@ -6285,18 +6114,26 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
      * associate a counter to the transition.
      */
     counter = xmlRegGetCounter(am);
+    if (counter < 0)
+        goto error;
     am->counters[counter].min = 1;
     am->counters[counter].max = 1;
 
     /* xmlFAGenerateTransitions(am, from, to, atom); */
     if (to == NULL) {
-       to = xmlRegNewState(am);
-       xmlRegStatePush(am, to);
+       to = xmlRegStatePush(am);
+        if (to == NULL)
+            goto error;
     }
     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
-    xmlRegAtomPush(am, atom);
+    if (xmlRegAtomPush(am, atom) < 0)
+        goto error;
     am->state = to;
     return(to);
+
+error:
+    xmlRegFreeAtom(atom);
+    return(NULL);
 }
 
 /**
@@ -6309,13 +6146,9 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
  */
 xmlAutomataStatePtr
 xmlAutomataNewState(xmlAutomataPtr am) {
-    xmlAutomataStatePtr to;
-
     if (am == NULL)
        return(NULL);
-    to = xmlRegNewState(am);
-    xmlRegStatePush(am, to);
-    return(to);
+    return(xmlRegStatePush(am));
 }
 
 /**
@@ -6572,8 +6405,6 @@ xmlExpFreeCtxt(xmlExpCtxtPtr ctxt) {
  ************************************************************************/
 #define MAX_NODES 10000
 
-/* #define DEBUG_DERIV */
-
 /*
  * TODO:
  * - Wildcards
@@ -7248,14 +7079,8 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
            return(forbiddenExp);
        case XML_EXP_ATOM:
            if (exp->exp_str == str) {
-#ifdef DEBUG_DERIV
-               printf("deriv atom: equal => Empty\n");
-#endif
                ret = emptyExp;
            } else {
-#ifdef DEBUG_DERIV
-               printf("deriv atom: mismatch => forbid\n");
-#endif
                /* TODO wildcards here */
                ret = forbiddenExp;
            }
@@ -7263,9 +7088,6 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
        case XML_EXP_OR: {
            xmlExpNodePtr tmp;
 
-#ifdef DEBUG_DERIV
-           printf("deriv or: => or(derivs)\n");
-#endif
            tmp = xmlExpStringDeriveInt(ctxt, exp->exp_left, str);
            if (tmp == NULL) {
                return(NULL);
@@ -7280,23 +7102,14 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
            return(ret);
        }
        case XML_EXP_SEQ:
-#ifdef DEBUG_DERIV
-           printf("deriv seq: starting with left\n");
-#endif
            ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str);
            if (ret == NULL) {
                return(NULL);
            } else if (ret == forbiddenExp) {
                if (IS_NILLABLE(exp->exp_left)) {
-#ifdef DEBUG_DERIV
-                   printf("deriv seq: left failed but nillable\n");
-#endif
                    ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str);
                }
            } else {
-#ifdef DEBUG_DERIV
-               printf("deriv seq: left match => sequence\n");
-#endif
                exp->exp_right->ref++;
                ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right,
                                         NULL, 0, 0);
@@ -7312,9 +7125,6 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
            if (ret == NULL)
                return(NULL);
            if (ret == forbiddenExp) {
-#ifdef DEBUG_DERIV
-               printf("deriv count: pattern mismatch => forbid\n");
-#endif
                return(ret);
            }
            if (exp->exp_max == 1)
@@ -7331,14 +7141,8 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
            tmp = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL,
                                     NULL, min, max);
            if (ret == emptyExp) {
-#ifdef DEBUG_DERIV
-               printf("deriv count: match to empty => new count\n");
-#endif
                return(tmp);
            }
-#ifdef DEBUG_DERIV
-           printf("deriv count: match => sequence with new count\n");
-#endif
            return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, tmp,
                                      NULL, 0, 0));
        }
@@ -7447,17 +7251,11 @@ xmlExpDivide(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub,
                *mult = tmp;
            else
                xmlExpFree(ctxt, tmp);
-#ifdef DEBUG_DERIV
-           printf("Divide succeeded %d\n", i);
-#endif
            return(i);
        }
        xmlExpFree(ctxt, tmp);
        xmlExpFree(ctxt, tmp2);
     }
-#ifdef DEBUG_DERIV
-    printf("Divide failed\n");
-#endif
     return(0);
 }
 
@@ -7483,25 +7281,16 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
      * amount, then the derivation is empty
      */
     if ((exp == sub) && (exp->c_max >= 0)) {
-#ifdef DEBUG_DERIV
-        printf("Equal(exp, sub) and finite -> Empty\n");
-#endif
         return(emptyExp);
     }
     /*
      * decompose sub sequence first
      */
     if (sub->type == XML_EXP_EMPTY) {
-#ifdef DEBUG_DERIV
-        printf("Empty(sub) -> Empty\n");
-#endif
        exp->ref++;
         return(exp);
     }
     if (sub->type == XML_EXP_SEQ) {
-#ifdef DEBUG_DERIV
-        printf("Seq(sub) -> decompose\n");
-#endif
         tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left);
        if (tmp == NULL)
            return(NULL);
@@ -7512,9 +7301,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
        return(ret);
     }
     if (sub->type == XML_EXP_OR) {
-#ifdef DEBUG_DERIV
-        printf("Or(sub) -> decompose\n");
-#endif
         tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left);
        if (tmp == forbiddenExp)
            return(tmp);
@@ -7528,36 +7314,21 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
        return(xmlExpHashGetEntry(ctxt, XML_EXP_OR, tmp, ret, NULL, 0, 0));
     }
     if (!xmlExpCheckCard(exp, sub)) {
-#ifdef DEBUG_DERIV
-        printf("CheckCard(exp, sub) failed -> Forbid\n");
-#endif
         return(forbiddenExp);
     }
     switch (exp->type) {
         case XML_EXP_EMPTY:
            if (sub == emptyExp)
                return(emptyExp);
-#ifdef DEBUG_DERIV
-           printf("Empty(exp) -> Forbid\n");
-#endif
            return(forbiddenExp);
         case XML_EXP_FORBID:
-#ifdef DEBUG_DERIV
-           printf("Forbid(exp) -> Forbid\n");
-#endif
            return(forbiddenExp);
         case XML_EXP_ATOM:
            if (sub->type == XML_EXP_ATOM) {
                /* TODO: handle wildcards */
                if (exp->exp_str == sub->exp_str) {
-#ifdef DEBUG_DERIV
-                   printf("Atom match -> Empty\n");
-#endif
                    return(emptyExp);
                 }
-#ifdef DEBUG_DERIV
-               printf("Atom mismatch -> Forbid\n");
-#endif
                return(forbiddenExp);
            }
            if ((sub->type == XML_EXP_COUNT) &&
@@ -7565,32 +7336,17 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                (sub->exp_left->type == XML_EXP_ATOM)) {
                /* TODO: handle wildcards */
                if (exp->exp_str == sub->exp_left->exp_str) {
-#ifdef DEBUG_DERIV
-                   printf("Atom match -> Empty\n");
-#endif
                    return(emptyExp);
                }
-#ifdef DEBUG_DERIV
-               printf("Atom mismatch -> Forbid\n");
-#endif
                return(forbiddenExp);
            }
-#ifdef DEBUG_DERIV
-           printf("Complex exp vs Atom -> Forbid\n");
-#endif
            return(forbiddenExp);
         case XML_EXP_SEQ:
            /* try to get the sequence consumed only if possible */
            if (xmlExpCheckCard(exp->exp_left, sub)) {
                /* See if the sequence can be consumed directly */
-#ifdef DEBUG_DERIV
-               printf("Seq trying left only\n");
-#endif
                ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub);
                if ((ret != forbiddenExp) && (ret != NULL)) {
-#ifdef DEBUG_DERIV
-                   printf("Seq trying left only worked\n");
-#endif
                    /*
                     * TODO: assumption here that we are determinist
                     *       i.e. we won't get to a nillable exp left
@@ -7602,25 +7358,15 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                    return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret,
                                              exp->exp_right, NULL, 0, 0));
                }
-#ifdef DEBUG_DERIV
-           } else {
-               printf("Seq: left too short\n");
-#endif
            }
            /* Try instead to decompose */
            if (sub->type == XML_EXP_COUNT) {
                int min, max;
 
-#ifdef DEBUG_DERIV
-               printf("Seq: sub is a count\n");
-#endif
                ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left);
                if (ret == NULL)
                    return(NULL);
                if (ret != forbiddenExp) {
-#ifdef DEBUG_DERIV
-                   printf("Seq , Count match on left\n");
-#endif
                    if (sub->exp_max < 0)
                        max = -1;
                    else
@@ -7651,9 +7397,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
            /* we made no progress on structured operations */
            break;
         case XML_EXP_OR:
-#ifdef DEBUG_DERIV
-           printf("Or , trying both side\n");
-#endif
            ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub);
            if (ret == NULL)
                return(NULL);
@@ -7676,15 +7419,9 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                if (tmp == forbiddenExp) {
                    int mult;
 
-#ifdef DEBUG_DERIV
-                   printf("Count, Count inner don't subsume\n");
-#endif
                    mult = xmlExpDivide(ctxt, sub->exp_left, exp->exp_left,
                                        NULL, &tmp);
                    if (mult <= 0) {
-#ifdef DEBUG_DERIV
-                       printf("Count, Count not multiple => forbidden\n");
-#endif
                         return(forbiddenExp);
                    }
                    if (sub->exp_max == -1) {
@@ -7695,17 +7432,11 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                            else
                                min = exp->exp_min - sub->exp_min * mult;
                        } else {
-#ifdef DEBUG_DERIV
-                           printf("Count, Count finite can't subsume infinite\n");
-#endif
                             xmlExpFree(ctxt, tmp);
                            return(forbiddenExp);
                        }
                    } else {
                        if (exp->exp_max == -1) {
-#ifdef DEBUG_DERIV
-                           printf("Infinite loop consume mult finite loop\n");
-#endif
                            if (exp->exp_min > sub->exp_min * mult) {
                                max = -1;
                                min = exp->exp_min - sub->exp_min * mult;
@@ -7715,9 +7446,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                            }
                        } else {
                            if (exp->exp_max < sub->exp_max * mult) {
-#ifdef DEBUG_DERIV
-                               printf("loops max mult mismatch => forbidden\n");
-#endif
                                xmlExpFree(ctxt, tmp);
                                return(forbiddenExp);
                            }
@@ -7733,30 +7461,18 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                     * TODO: loop here to try to grow if working on finite
                     *       blocks.
                     */
-#ifdef DEBUG_DERIV
-                   printf("Count, Count remain not nillable => forbidden\n");
-#endif
                    xmlExpFree(ctxt, tmp);
                    return(forbiddenExp);
                } else if (sub->exp_max == -1) {
                    if (exp->exp_max == -1) {
                        if (exp->exp_min <= sub->exp_min) {
-#ifdef DEBUG_DERIV
-                           printf("Infinite loops Okay => COUNT(0,Inf)\n");
-#endif
                             max = -1;
                            min = 0;
                        } else {
-#ifdef DEBUG_DERIV
-                           printf("Infinite loops min => Count(X,Inf)\n");
-#endif
                             max = -1;
                            min = exp->exp_min - sub->exp_min;
                        }
                    } else if (exp->exp_min > sub->exp_min) {
-#ifdef DEBUG_DERIV
-                       printf("loops min mismatch 1 => forbidden ???\n");
-#endif
                        xmlExpFree(ctxt, tmp);
                        return(forbiddenExp);
                    } else {
@@ -7765,9 +7481,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                    }
                } else {
                    if (exp->exp_max == -1) {
-#ifdef DEBUG_DERIV
-                       printf("Infinite loop consume finite loop\n");
-#endif
                        if (exp->exp_min > sub->exp_min) {
                            max = -1;
                            min = exp->exp_min - sub->exp_min;
@@ -7777,9 +7490,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                        }
                    } else {
                        if (exp->exp_max < sub->exp_max) {
-#ifdef DEBUG_DERIV
-                           printf("loops max mismatch => forbidden\n");
-#endif
                            xmlExpFree(ctxt, tmp);
                            return(forbiddenExp);
                        }
@@ -7790,9 +7500,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
                        max = exp->exp_max - sub->exp_max;
                    }
                }
-#ifdef DEBUG_DERIV
-               printf("loops match => SEQ(COUNT())\n");
-#endif
                exp->exp_left->ref++;
                tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left,
                                          NULL, NULL, min, max);
@@ -7807,9 +7514,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
            if (tmp == NULL)
                return(NULL);
            if (tmp == forbiddenExp) {
-#ifdef DEBUG_DERIV
-               printf("loop mismatch => forbidden\n");
-#endif
                return(forbiddenExp);
            }
            if (exp->exp_min > 0)
@@ -7821,9 +7525,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
            else
                max = exp->exp_max - 1;
 
-#ifdef DEBUG_DERIV
-           printf("loop match => SEQ(COUNT())\n");
-#endif
            exp->exp_left->ref++;
            tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left,
                                      NULL, NULL, min, max);
@@ -7835,9 +7536,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
        }
     }
 
-#ifdef DEBUG_DERIV
-    printf("Fallback to derivative\n");
-#endif
     if (IS_NILLABLE(sub)) {
         if (!(IS_NILLABLE(exp)))
            return(forbiddenExp);
@@ -7935,15 +7633,9 @@ xmlExpExpDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
      * O(1) speedups
      */
     if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) {
-#ifdef DEBUG_DERIV
-       printf("Sub nillable and not exp : can't subsume\n");
-#endif
         return(forbiddenExp);
     }
     if (xmlExpCheckCard(exp, sub) == 0) {
-#ifdef DEBUG_DERIV
-       printf("sub generate longer sequences than exp : can't subsume\n");
-#endif
         return(forbiddenExp);
     }
     return(xmlExpExpDeriveInt(ctxt, exp, sub));
@@ -7975,22 +7667,12 @@ xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
      * O(1) speedups
      */
     if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) {
-#ifdef DEBUG_DERIV
-       printf("Sub nillable and not exp : can't subsume\n");
-#endif
         return(0);
     }
     if (xmlExpCheckCard(exp, sub) == 0) {
-#ifdef DEBUG_DERIV
-       printf("sub generate longer sequences than exp : can't subsume\n");
-#endif
         return(0);
     }
     tmp = xmlExpExpDeriveInt(ctxt, exp, sub);
-#ifdef DEBUG_DERIV
-    printf("Result derivation :\n");
-    PRINT_EXP(tmp);
-#endif
     if (tmp == NULL)
         return(-1);
     if (tmp == forbiddenExp)
index 9b42c66..125853f 100644 (file)
--- a/xmlsave.c
+++ b/xmlsave.c
 
 #include <libxml/HTMLtree.h>
 
-#include "buf.h"
-#include "enc.h"
-#include "save.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
+#include "private/save.h"
 
-/************************************************************************
- *                                                                     *
- *                     XHTML detection                                 *
- *                                                                     *
- ************************************************************************/
-#define XHTML_STRICT_PUBLIC_ID BAD_CAST \
-   "-//W3C//DTD XHTML 1.0 Strict//EN"
-#define XHTML_STRICT_SYSTEM_ID BAD_CAST \
-   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
-#define XHTML_FRAME_PUBLIC_ID BAD_CAST \
-   "-//W3C//DTD XHTML 1.0 Frameset//EN"
-#define XHTML_FRAME_SYSTEM_ID BAD_CAST \
-   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"
-#define XHTML_TRANS_PUBLIC_ID BAD_CAST \
-   "-//W3C//DTD XHTML 1.0 Transitional//EN"
-#define XHTML_TRANS_SYSTEM_ID BAD_CAST \
-   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+#ifdef LIBXML_OUTPUT_ENABLED
 
 #define XHTML_NS_NAME BAD_CAST "http://www.w3.org/1999/xhtml"
-/**
- * xmlIsXHTML:
- * @systemID:  the system identifier
- * @publicID:  the public identifier
- *
- * Try to find if the document correspond to an XHTML DTD
- *
- * Returns 1 if true, 0 if not and -1 in case of error
- */
-int
-xmlIsXHTML(const xmlChar *systemID, const xmlChar *publicID) {
-    if ((systemID == NULL) && (publicID == NULL))
-       return(-1);
-    if (publicID != NULL) {
-       if (xmlStrEqual(publicID, XHTML_STRICT_PUBLIC_ID)) return(1);
-       if (xmlStrEqual(publicID, XHTML_FRAME_PUBLIC_ID)) return(1);
-       if (xmlStrEqual(publicID, XHTML_TRANS_PUBLIC_ID)) return(1);
-    }
-    if (systemID != NULL) {
-       if (xmlStrEqual(systemID, XHTML_STRICT_SYSTEM_ID)) return(1);
-       if (xmlStrEqual(systemID, XHTML_FRAME_SYSTEM_ID)) return(1);
-       if (xmlStrEqual(systemID, XHTML_TRANS_SYSTEM_ID)) return(1);
-    }
-    return(0);
-}
-
-#ifdef LIBXML_OUTPUT_ENABLED
 
 #define TODO                                                           \
     xmlGenericError(xmlGenericErrorContext,                            \
@@ -463,7 +421,7 @@ xmlAttrSerializeContent(xmlOutputBufferPtr buf, xmlAttrPtr attr)
  *
  * This will dump the content of the notation table as an XML DTD definition
  */
-void
+static void
 xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table) {
     xmlBufferPtr buffer;
 
@@ -487,7 +445,7 @@ xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table) {
  * This will dump the content of the element declaration as an XML
  * DTD definition
  */
-void
+static void
 xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem) {
     xmlBufferPtr buffer;
 
@@ -511,7 +469,7 @@ xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem) {
  * This will dump the content of the attribute declaration as an XML
  * DTD definition
  */
-void
+static void
 xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr) {
     xmlBufferPtr buffer;
 
@@ -534,7 +492,7 @@ xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr) {
  *
  * This will dump the content of the entity table as an XML DTD definition
  */
-void
+static void
 xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent) {
     xmlBufferPtr buffer;
 
@@ -595,7 +553,6 @@ static void
 xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur);
 #endif
 static void xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur);
-void xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
 static int xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur);
 
 /**
@@ -1890,7 +1847,7 @@ xmlSaveDoc(xmlSaveCtxtPtr ctxt, xmlDocPtr doc)
 /**
  * xmlSaveTree:
  * @ctxt:  a document saving context
- * @node:  the top node of the subtree to save
+ * @cur:  the top node of the subtree to save
  *
  * Save a subtree starting at the node parameter to a saving context
  * TODO: The function is not fully implemented yet as it does not return the
@@ -2178,7 +2135,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
     xmlBufBackToBuffer(buffer);
     if (ret > INT_MAX)
         return(-1);
-    return((int) ret);
+    return(ret);
 }
 
 /**
@@ -2209,17 +2166,9 @@ xmlBufNodeDump(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
     xmlInitParser();
 
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlNodeDump : node == NULL\n");
-#endif
         return (-1);
     }
     if (buf == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlNodeDump : buf == NULL\n");
-#endif
         return (-1);
     }
     outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
@@ -2261,18 +2210,8 @@ xmlElemDump(FILE * f, xmlDocPtr doc, xmlNodePtr cur)
     xmlInitParser();
 
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlElemDump : cur == NULL\n");
-#endif
         return;
     }
-#ifdef DEBUG_TREE
-    if (doc == NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlElemDump : doc == NULL\n");
-    }
-#endif
 
     outbuf = xmlOutputBufferCreateFile(f, NULL);
     if (outbuf == NULL)
@@ -2317,6 +2256,8 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
     int is_xhtml = 0;
 #endif
 
+    (void) doc;
+
     xmlInitParser();
 
     if ((buf == NULL) || (cur == NULL)) return;
@@ -2406,6 +2347,7 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
 
     if ((out_buff = xmlAllocOutputBuffer(conv_hdlr)) == NULL ) {
         xmlSaveErrMemory("creating buffer");
+        xmlCharEncCloseFunc(conv_hdlr);
         return;
     }
 
@@ -2509,10 +2451,6 @@ xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) {
     int ret;
 
     if (cur == NULL) {
-#ifdef DEBUG_TREE
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlDocDump : document == NULL\n");
-#endif
        return(-1);
     }
     encoding = (const char *) cur->encoding;
index f31d3d1..d276faf 100644 (file)
 #include <libxml/xmlreader.h>
 #endif
 
-/* #define DEBUG 1 */
-
-/* #define DEBUG_CONTENT 1 */
-
-/* #define DEBUG_TYPE 1 */
-
-/* #define DEBUG_CONTENT_REGEXP 1 */
-
-/* #define DEBUG_AUTOMATA 1 */
-
-/* #define DEBUG_IDC */
-
-/* #define DEBUG_IDC_NODE_TABLE */
+#include "private/error.h"
+#include "private/string.h"
 
 /* #define WXS_ELEM_DECL_CONS_ENABLED */
 
-#ifdef DEBUG_IDC
- #ifndef DEBUG_IDC_NODE_TABLE
-  #define DEBUG_IDC_NODE_TABLE
- #endif
-#endif
-
 /* #define ENABLE_PARTICLE_RESTRICTION 1 */
 
 #define ENABLE_REDEFINE
@@ -305,10 +288,20 @@ static const xmlChar *xmlNamespaceNs = (const xmlChar *)
 #define WXS_SCHEMA(ctx) (ctx)->schema
 
 #define WXS_ADD_LOCAL(ctx, item) \
-    xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)->locals), 10, item)
+    do { \
+        if (xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)->locals), 10, item) < 0) { \
+            xmlFree(item); \
+            item = NULL; \
+        } \
+    } while (0)
 
 #define WXS_ADD_GLOBAL(ctx, item) \
-    xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)->globals), 5, item)
+    do { \
+        if (xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)->globals), 5, item) < 0) { \
+            xmlFree(item); \
+            item = NULL; \
+        } \
+    } while (0)
 
 #define WXS_ADD_PENDING(ctx, item) \
     xmlSchemaAddItemSize(&((ctx)->constructor->pending), 10, item)
@@ -2130,8 +2123,14 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
                    (vctxt->parserCtxt != NULL) &&
                    (vctxt->parserCtxt->input != NULL)) {
                    file = vctxt->parserCtxt->input->filename;
-                   line = vctxt->parserCtxt->input->line;
-                   col = vctxt->parserCtxt->input->col;
+                    if (vctxt->inode != NULL) {
+                       line = vctxt->inode->nodeLine;
+                        col = 0;
+                    } else {
+                        /* This is inaccurate. */
+                       line = vctxt->parserCtxt->input->line;
+                       col = vctxt->parserCtxt->input->col;
+                    }
                }
            } else {
                /*
@@ -3407,23 +3406,17 @@ xmlSchemaItemListClear(xmlSchemaItemListPtr list)
 static int
 xmlSchemaItemListAdd(xmlSchemaItemListPtr list, void *item)
 {
-    if (list->items == NULL) {
-       list->items = (void **) xmlMalloc(
-           20 * sizeof(void *));
-       if (list->items == NULL) {
-           xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
-           return(-1);
-       }
-       list->sizeItems = 20;
-    } else if (list->sizeItems <= list->nbItems) {
-       list->sizeItems *= 2;
-       list->items = (void **) xmlRealloc(list->items,
-           list->sizeItems * sizeof(void *));
-       if (list->items == NULL) {
+    if (list->sizeItems <= list->nbItems) {
+        void **tmp;
+        size_t newSize = list->sizeItems == 0 ? 20 : list->sizeItems * 2;
+
+       tmp = (void **) xmlRealloc(list->items, newSize * sizeof(void *));
+       if (tmp == NULL) {
            xmlSchemaPErrMemory(NULL, "growing item list", NULL);
-           list->sizeItems = 0;
            return(-1);
        }
+        list->items = tmp;
+       list->sizeItems = newSize;
     }
     list->items[list->nbItems++] = item;
     return(0);
@@ -3445,14 +3438,17 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list,
        }
        list->sizeItems = initialSize;
     } else if (list->sizeItems <= list->nbItems) {
+        void **tmp;
+
        list->sizeItems *= 2;
-       list->items = (void **) xmlRealloc(list->items,
+       tmp = (void **) xmlRealloc(list->items,
            list->sizeItems * sizeof(void *));
-       if (list->items == NULL) {
+       if (tmp == NULL) {
            xmlSchemaPErrMemory(NULL, "growing item list", NULL);
-           list->sizeItems = 0;
+           list->sizeItems /= 2;
            return(-1);
        }
+        list->items = tmp;
     }
     list->items[list->nbItems++] = item;
     return(0);
@@ -3461,23 +3457,17 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list,
 static int
 xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx)
 {
-    if (list->items == NULL) {
-       list->items = (void **) xmlMalloc(
-           20 * sizeof(void *));
-       if (list->items == NULL) {
-           xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
-           return(-1);
-       }
-       list->sizeItems = 20;
-    } else if (list->sizeItems <= list->nbItems) {
-       list->sizeItems *= 2;
-       list->items = (void **) xmlRealloc(list->items,
-           list->sizeItems * sizeof(void *));
-       if (list->items == NULL) {
+    if (list->sizeItems <= list->nbItems) {
+        void **tmp;
+        size_t newSize = list->sizeItems == 0 ? 20 : list->sizeItems * 2;
+
+       tmp = (void **) xmlRealloc(list->items, newSize * sizeof(void *));
+       if (tmp == NULL) {
            xmlSchemaPErrMemory(NULL, "growing item list", NULL);
-           list->sizeItems = 0;
            return(-1);
        }
+        list->items = tmp;
+       list->sizeItems = newSize;
     }
     /*
     * Just append if the index is greater/equal than the item count.
@@ -3645,12 +3635,12 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
     ret->type = type;
     ret->globals = xmlSchemaItemListCreate();
     if (ret->globals == NULL) {
-       xmlFree(ret);
+       xmlSchemaBucketFree(ret);
        return(NULL);
     }
     ret->locals = xmlSchemaItemListCreate();
     if (ret->locals == NULL) {
-       xmlFree(ret);
+       xmlSchemaBucketFree(ret);
        return(NULL);
     }
     /*
@@ -3739,7 +3729,10 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
                return(NULL);
            }
        }
-       xmlSchemaItemListAdd(mainSchema->includes, ret);
+       if (xmlSchemaItemListAdd(mainSchema->includes, ret) < 0) {
+           xmlSchemaBucketFree(ret);
+           return(NULL);
+        }
     }
     /*
     * Add to list of all buckets; this is used for lookup
@@ -3758,8 +3751,7 @@ xmlSchemaAddItemSize(xmlSchemaItemListPtr *list, int initialSize, void *item)
        if (*list == NULL)
            return(-1);
     }
-    xmlSchemaItemListAddSize(*list, initialSize, item);
-    return(0);
+    return(xmlSchemaItemListAddSize(*list, initialSize, item));
 }
 
 /**
@@ -3797,6 +3789,8 @@ xmlSchemaFreeNotation(xmlSchemaNotationPtr nota)
 {
     if (nota == NULL)
         return;
+    if (nota->annot != NULL)
+       xmlSchemaFreeAnnot(nota->annot);
     xmlFree(nota);
 }
 
@@ -4606,83 +4600,6 @@ xmlSchemaDump(FILE * output, xmlSchemaPtr schema)
     xmlHashScanFull(schema->elemDecl, xmlSchemaElementDump, output);
 }
 
-#ifdef DEBUG_IDC_NODE_TABLE
-/**
- * xmlSchemaDebugDumpIDCTable:
- * @vctxt: the WXS validation context
- *
- * Displays the current IDC table for debug purposes.
- */
-static void
-xmlSchemaDebugDumpIDCTable(FILE * output,
-                          const xmlChar *namespaceName,
-                          const xmlChar *localName,
-                          xmlSchemaPSVIIDCBindingPtr bind)
-{
-    xmlChar *str = NULL;
-    const xmlChar *value;
-    xmlSchemaPSVIIDCNodePtr tab;
-    xmlSchemaPSVIIDCKeyPtr key;
-    int i, j, res;
-
-    fprintf(output, "IDC: TABLES on '%s'\n",
-       xmlSchemaFormatQName(&str, namespaceName, localName));
-    FREE_AND_NULL(str)
-
-    if (bind == NULL)
-       return;
-    do {
-       fprintf(output, "IDC:   BINDING '%s' (%d)\n",
-           xmlSchemaGetComponentQName(&str,
-               bind->definition), bind->nbNodes);
-       FREE_AND_NULL(str)
-       for (i = 0; i < bind->nbNodes; i++) {
-           tab = bind->nodeTable[i];
-           fprintf(output, "         ( ");
-           for (j = 0; j < bind->definition->nbFields; j++) {
-               key = tab->keys[j];
-               if ((key != NULL) && (key->val != NULL)) {
-                   res = xmlSchemaGetCanonValue(key->val, &value);
-                   if (res >= 0)
-                       fprintf(output, "'%s' ", value);
-                   else
-                       fprintf(output, "CANON-VALUE-FAILED ");
-                   if (res == 0)
-                       FREE_AND_NULL(value)
-               } else if (key != NULL)
-                   fprintf(output, "(no val), ");
-               else
-                   fprintf(output, "(key missing), ");
-           }
-           fprintf(output, ")\n");
-       }
-       if (bind->dupls && bind->dupls->nbItems) {
-           fprintf(output, "IDC:     dupls (%d):\n", bind->dupls->nbItems);
-           for (i = 0; i < bind->dupls->nbItems; i++) {
-               tab = bind->dupls->items[i];
-               fprintf(output, "         ( ");
-               for (j = 0; j < bind->definition->nbFields; j++) {
-                   key = tab->keys[j];
-                   if ((key != NULL) && (key->val != NULL)) {
-                       res = xmlSchemaGetCanonValue(key->val, &value);
-                       if (res >= 0)
-                           fprintf(output, "'%s' ", value);
-                       else
-                           fprintf(output, "CANON-VALUE-FAILED ");
-                       if (res == 0)
-                           FREE_AND_NULL(value)
-                   } else if (key != NULL)
-                   fprintf(output, "(no val), ");
-                       else
-                           fprintf(output, "(key missing), ");
-               }
-               fprintf(output, ")\n");
-           }
-       }
-       bind = bind->next;
-    } while (bind != NULL);
-}
-#endif /* DEBUG_IDC */
 #endif /* LIBXML_OUTPUT_ENABLED */
 
 /************************************************************************
@@ -4757,6 +4674,8 @@ xmlSchemaGetNodeContent(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node)
        val = xmlStrdup((xmlChar *)"");
     ret = xmlDictLookup(ctxt->dict, val, -1);
     xmlFree(val);
+    if (ret == NULL)
+        xmlSchemaPErrMemory(ctxt, "getting node content", node);
     return(ret);
 }
 
@@ -4836,15 +4755,6 @@ xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name,
        WXS_FIND_GLOBAL_ITEM(elemDecl)
     }
 exit:
-#ifdef DEBUG
-    if (ret == NULL) {
-        if (nsName == NULL)
-            fprintf(stderr, "Unable to lookup element decl. %s", name);
-        else
-            fprintf(stderr, "Unable to lookup element decl. %s:%s", name,
-                    nsName);
-    }
-#endif
     return (ret);
 }
 
@@ -4883,15 +4793,6 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name,
     }
 exit:
 
-#ifdef DEBUG
-    if (ret == NULL) {
-        if (nsName == NULL)
-            fprintf(stderr, "Unable to lookup type %s", name);
-        else
-            fprintf(stderr, "Unable to lookup type %s:%s", name,
-                    nsName);
-    }
-#endif
     return (ret);
 }
 
@@ -4917,15 +4818,6 @@ xmlSchemaGetAttributeDecl(xmlSchemaPtr schema, const xmlChar * name,
        WXS_FIND_GLOBAL_ITEM(attrDecl)
     }
 exit:
-#ifdef DEBUG
-    if (ret == NULL) {
-        if (nsName == NULL)
-            fprintf(stderr, "Unable to lookup attribute %s", name);
-        else
-            fprintf(stderr, "Unable to lookup attribute %s:%s", name,
-                    nsName);
-    }
-#endif
     return (ret);
 }
 
@@ -4957,15 +4849,6 @@ exit:
        ret = ret->redef;
     }
     */
-#ifdef DEBUG
-    if (ret == NULL) {
-        if (nsName == NULL)
-            fprintf(stderr, "Unable to lookup attribute group %s", name);
-        else
-            fprintf(stderr, "Unable to lookup attribute group %s:%s", name,
-                    nsName);
-    }
-#endif
     return (ret);
 }
 
@@ -4992,15 +4875,6 @@ xmlSchemaGetGroup(xmlSchemaPtr schema, const xmlChar * name,
     }
 exit:
 
-#ifdef DEBUG
-    if (ret == NULL) {
-        if (nsName == NULL)
-            fprintf(stderr, "Unable to lookup group %s", name);
-        else
-            fprintf(stderr, "Unable to lookup group %s:%s", name,
-                    nsName);
-    }
-#endif
     return (ret);
 }
 
@@ -5590,9 +5464,6 @@ xmlSchemaAddParticle(xmlSchemaParserCtxtPtr ctxt,
     if (ctxt == NULL)
         return (NULL);
 
-#ifdef DEBUG
-    fprintf(stderr, "Adding particle component\n");
-#endif
     ret = (xmlSchemaParticlePtr)
        xmlMalloc(sizeof(xmlSchemaParticle));
     if (ret == NULL) {
@@ -6100,6 +5971,8 @@ xmlGetMaxOccurs(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
     if (attr == NULL)
        return (def);
     val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
+    if (val == NULL)
+        return (def);
 
     if (xmlStrEqual(val, (const xmlChar *) "unbounded")) {
        if (max != UNBOUNDED) {
@@ -6174,6 +6047,8 @@ xmlGetMinOccurs(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
     if (attr == NULL)
        return (def);
     val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
+    if (val == NULL)
+       return (def);
     cur = val;
     while (IS_BLANK_CH(*cur))
         cur++;
@@ -6846,6 +6721,8 @@ xmlSchemaParseWildcardNs(xmlSchemaParserCtxtPtr ctxt,
      */
     attr = xmlSchemaGetPropNode(node, "namespace");
     ns = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
+    if (ns == NULL)
+        return (-1);
     if ((attr == NULL) || (xmlStrEqual(ns, BAD_CAST "##any")))
        wildc->any = 1;
     else if (xmlStrEqual(ns, BAD_CAST "##other")) {
@@ -8994,6 +8871,8 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
        xmlSchemaQNameRefPtr ref;
 
        cur = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
+        if (cur == NULL)
+            return (-1);
        type->base = cur;
        do {
            while (IS_BLANK_CH(*cur))
@@ -9004,6 +8883,11 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
            if (end == cur)
                break;
            tmp = xmlStrndup(cur, end - cur);
+            if (tmp == NULL) {
+                xmlSchemaPErrMemory(ctxt, "xmlSchemaParseUnion, "
+                    "duplicating type name", NULL);
+                return (-1);
+            }
            if (xmlSchemaPValAttrNodeQNameValue(ctxt, schema,
                NULL, attr, BAD_CAST tmp, &nsName, &localName) == 0) {
                /*
@@ -9014,6 +8898,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
                if (link == NULL) {
                    xmlSchemaPErrMemory(ctxt, "xmlSchemaParseUnion, "
                        "allocating a type link", NULL);
+                   FREE_AND_NULL(tmp)
                    return (-1);
                }
                link->type = NULL;
@@ -10660,7 +10545,7 @@ doc_load:
        * TODO: (2.2) is not supported.
        */
        if (doc == NULL) {
-           xmlErrorPtr lerr;
+           const xmlError *lerr;
            lerr = xmlGetLastError();
            /*
            * Check if this a parser error, or if the document could
@@ -11149,17 +11034,6 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
            * differ from the resulting namespace.
            */
            isChameleon = 1;
-           if (bucket->parsed &&
-               bucket->origTargetNamespace != NULL) {
-               xmlSchemaCustomErr(ACTXT_CAST pctxt,
-                   XML_SCHEMAP_SRC_INCLUDE,
-                   node, NULL,
-                   "The target namespace of the included/redefined schema "
-                   "'%s' has to be absent or the same as the "
-                   "including/redefining schema's target namespace",
-                   schemaLocation, NULL);
-               goto exit_error;
-           }
            bucket->targetNamespace = pctxt->targetNamespace;
        }
     }
@@ -13240,10 +13114,6 @@ xmlSchemaBuildContentModel(xmlSchemaTypePtr type,
        (type->contentType != XML_SCHEMA_CONTENT_MIXED)))
        return;
 
-#ifdef DEBUG_CONTENT
-    xmlGenericError(xmlGenericErrorContext,
-                    "Building content model for %s\n", name);
-#endif
     ctxt->am = NULL;
     ctxt->am = xmlNewAutomata();
     if (ctxt->am == NULL) {
@@ -13270,11 +13140,6 @@ xmlSchemaBuildContentModel(xmlSchemaTypePtr type,
            WXS_BASIC_CAST type, type->node,
            "The content model is not determinist", NULL);
     } else {
-#ifdef DEBUG_CONTENT_REGEXP
-        xmlGenericError(xmlGenericErrorContext,
-                        "Content model of %s:\n", type->name);
-        xmlRegexpPrint(stderr, type->contModel);
-#endif
     }
     ctxt->state = NULL;
     xmlFreeAutomata(ctxt->am);
@@ -13345,8 +13210,19 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl,
            * declaration `resolved` to by the `actual value`
            * of the substitutionGroup [attribute], if present"
            */
-           if (elemDecl->subtypes == NULL)
-               elemDecl->subtypes = substHead->subtypes;
+           if (elemDecl->subtypes == NULL) {
+                if (substHead->subtypes == NULL) {
+                    /*
+                     * This can happen with self-referencing substitution
+                     * groups. The cycle will be detected later, but we have
+                     * to set subtypes to avoid null-pointer dereferences.
+                     */
+                   elemDecl->subtypes = xmlSchemaGetBuiltInType(
+                            XML_SCHEMAS_ANYTYPE);
+                } else {
+                   elemDecl->subtypes = substHead->subtypes;
+                }
+            }
        }
     }
     /*
@@ -14536,6 +14412,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
            {
                PERROR_INT("xmlSchemaFixupTypeAttributeUses",
                "failed to expand attributes");
+                return(-1);
            }
            if (pctxt->attrProhibs->nbItems != 0)
                prohibs = pctxt->attrProhibs;
@@ -14546,6 +14423,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
            {
                PERROR_INT("xmlSchemaFixupTypeAttributeUses",
                "failed to expand attributes");
+                return(-1);
            }
        }
     }
@@ -18125,59 +18003,6 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt,
     return(0);
 }
 
-#ifdef DEBUG_TYPE
-static void
-xmlSchemaDebugFixedType(xmlSchemaParserCtxtPtr pctxt,
-                      xmlSchemaTypePtr type)
-{
-    if (type->node != NULL) {
-        xmlGenericError(xmlGenericErrorContext,
-                        "Type of %s : %s:%d :", name,
-                        type->node->doc->URL,
-                        xmlGetLineNo(type->node));
-    } else {
-        xmlGenericError(xmlGenericErrorContext, "Type of %s :", name);
-    }
-    if ((WXS_IS_SIMPLE(type)) || (WXS_IS_COMPLEX(type))) {
-       switch (type->contentType) {
-           case XML_SCHEMA_CONTENT_SIMPLE:
-               xmlGenericError(xmlGenericErrorContext, "simple\n");
-               break;
-           case XML_SCHEMA_CONTENT_ELEMENTS:
-               xmlGenericError(xmlGenericErrorContext, "elements\n");
-               break;
-           case XML_SCHEMA_CONTENT_UNKNOWN:
-               xmlGenericError(xmlGenericErrorContext, "unknown !!!\n");
-               break;
-           case XML_SCHEMA_CONTENT_EMPTY:
-               xmlGenericError(xmlGenericErrorContext, "empty\n");
-               break;
-           case XML_SCHEMA_CONTENT_MIXED:
-               if (xmlSchemaIsParticleEmptiable((xmlSchemaParticlePtr)
-                   type->subtypes))
-                   xmlGenericError(xmlGenericErrorContext,
-                       "mixed as emptiable particle\n");
-               else
-                   xmlGenericError(xmlGenericErrorContext, "mixed\n");
-               break;
-               /* Removed, since not used. */
-               /*
-               case XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS:
-               xmlGenericError(xmlGenericErrorContext, "mixed or elems\n");
-               break;
-               */
-           case XML_SCHEMA_CONTENT_BASIC:
-               xmlGenericError(xmlGenericErrorContext, "basic\n");
-               break;
-           default:
-               xmlGenericError(xmlGenericErrorContext,
-                   "not registered !!!\n");
-               break;
-       }
-    }
-}
-#endif
-
 /*
 * 3.14.6 Constraints on Simple Type Definition Schema Components
 */
@@ -18260,17 +18085,11 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
     xmlSchemaTypeFixupOptimFacets(type);
 
 exit_error:
-#ifdef DEBUG_TYPE
-    xmlSchemaDebugFixedType(pctxt, type);
-#endif
     if (olderrs != pctxt->nberrors)
        return(pctxt->err);
     return(0);
 
 exit_failure:
-#ifdef DEBUG_TYPE
-    xmlSchemaDebugFixedType(pctxt, type);
-#endif
     return(-1);
 }
 
@@ -18608,7 +18427,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
                        "allowed to appear inside other model groups",
                        NULL, NULL);
 
-               } else if (! dummySequence) {
+               } else if ((!dummySequence) && (baseType->subtypes != NULL)) {
                    xmlSchemaTreeItemPtr effectiveContent =
                        (xmlSchemaTreeItemPtr) type->subtypes;
                    /*
@@ -18692,9 +18511,6 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
     res = xmlSchemaCheckCTComponent(pctxt, type);
     HFAILURE HERROR
 
-#ifdef DEBUG_TYPE
-    xmlSchemaDebugFixedType(pctxt, type);
-#endif
     if (olderrs != pctxt->nberrors)
        return(pctxt->err);
     else
@@ -18702,16 +18518,10 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
 
 exit_error:
     type->flags |= XML_SCHEMAS_TYPE_INTERNAL_INVALID;
-#ifdef DEBUG_TYPE
-    xmlSchemaDebugFixedType(pctxt, type);
-#endif
     return(pctxt->err);
 
 exit_failure:
     type->flags |= XML_SCHEMAS_TYPE_INTERNAL_INVALID;
-#ifdef DEBUG_TYPE
-    xmlSchemaDebugFixedType(pctxt, type);
-#endif
     return(-1);
 }
 
@@ -19946,7 +19756,8 @@ xmlSchemaCheckElemSubstGroup(xmlSchemaParserCtxtPtr ctxt,
            /*
            * The set of all {derivation method}s involved in the derivation
            */
-           while ((type != NULL) && (type != headType)) {
+           while ((type != NULL) && (type != headType) &&
+                   (type != type->baseType)) {
                if ((WXS_IS_EXTENSION(type)) &&
                    ((methSet & XML_SCHEMAS_TYPE_BLOCK_RESTRICTION) == 0))
                    methSet |= XML_SCHEMAS_TYPE_BLOCK_EXTENSION;
@@ -21432,7 +21243,8 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
     * the API; i.e. not automatically by the validated instance document.
     */
 
-    xmlSchemaInitTypes();
+    if (xmlSchemaInitTypes() < 0)
+        return (NULL);
 
     if (ctxt == NULL)
         return (NULL);
@@ -21452,7 +21264,7 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
     if (ctxt->constructor == NULL) {
        ctxt->constructor = xmlSchemaConstructionCtxtCreate(ctxt->dict);
        if (ctxt->constructor == NULL)
-           return(NULL);
+           goto exit_failure;
        /* Take ownership of the constructor to be able to free it. */
        ctxt->ownsConstructor = 1;
     }
@@ -21861,7 +21673,6 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
 {
     const xmlChar *cur, *end;
     const xmlChar *nsname = NULL, *location;
-    int count = 0;
     int ret = 0;
     xmlSchemaAttrInfoPtr iattr;
 
@@ -21896,7 +21707,7 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
                end++;
            if (end == cur)
                break;
-           count++; /* TODO: Don't use the schema's dict. */
+           /* TODO: Don't use the schema's dict. */
            nsname = xmlDictLookup(vctxt->schema->dict, cur, end - cur);
            cur = end;
        }
@@ -21923,7 +21734,7 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
            }
            break;
        }
-       count++; /* TODO: Don't use the schema's dict. */
+       /* TODO: Don't use the schema's dict. */
        location = xmlDictLookup(vctxt->schema->dict, cur, end - cur);
        cur = end;
        ret = xmlSchemaAssembleByLocation(vctxt, vctxt->schema,
@@ -22589,10 +22400,6 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt,
     sto->sel = sel;
     sto->nbHistory = 0;
 
-#ifdef DEBUG_IDC
-    xmlGenericError(xmlGenericErrorContext, "IDC:   STO push '%s'\n",
-       sto->sel->xpath);
-#endif
     return (0);
 }
 
@@ -22618,30 +22425,12 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
 
     if (nodeType == XML_ATTRIBUTE_NODE)
        depth++;
-#ifdef DEBUG_IDC
-    {
-       xmlChar *str = NULL;
-       xmlGenericError(xmlGenericErrorContext,
-           "IDC: EVAL on %s, depth %d, type %d\n",
-           xmlSchemaFormatQName(&str, vctxt->inode->nsName,
-               vctxt->inode->localName), depth, nodeType);
-       FREE_AND_NULL(str)
-    }
-#endif
     /*
     * Process all active XPath state objects.
     */
     first = vctxt->xpathStates;
     sto = first;
     while (sto != head) {
-#ifdef DEBUG_IDC
-       if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR)
-           xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] selector '%s'\n",
-               sto->matcher->aidc->def->name, sto->sel->xpath);
-       else
-           xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] field '%s'\n",
-               sto->matcher->aidc->def->name, sto->sel->xpath);
-#endif
        if (nodeType == XML_ELEMENT_NODE)
            res = xmlStreamPush((xmlStreamCtxtPtr) sto->xpathCtxt,
                vctxt->inode->localName, vctxt->inode->nsName);
@@ -22659,10 +22448,6 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
        /*
        * Full match.
        */
-#ifdef DEBUG_IDC
-       xmlGenericError(xmlGenericErrorContext, "IDC:     "
-           "MATCH\n");
-#endif
        /*
        * Register a match in the state object history.
        */
@@ -22686,21 +22471,12 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
        }
        sto->history[sto->nbHistory++] = depth;
 
-#ifdef DEBUG_IDC
-       xmlGenericError(xmlGenericErrorContext, "IDC:       push match '%d'\n",
-           vctxt->depth);
-#endif
-
        if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
            xmlSchemaIDCSelectPtr sel;
            /*
            * Activate state objects for the IDC fields of
            * the IDC selector.
            */
-#ifdef DEBUG_IDC
-           xmlGenericError(xmlGenericErrorContext, "IDC:     "
-               "activating field states\n");
-#endif
            sel = sto->matcher->aidc->def->fields;
            while (sel != NULL) {
                if (xmlSchemaIDCAddStateObject(vctxt, sto->matcher,
@@ -22712,10 +22488,6 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
            /*
            * An IDC key node was found by the IDC field.
            */
-#ifdef DEBUG_IDC
-           xmlGenericError(xmlGenericErrorContext,
-               "IDC:     key found\n");
-#endif
            /*
            * Notify that the character value of this node is
            * needed.
@@ -22848,16 +22620,6 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
        return (0);
     sto = vctxt->xpathStates;
 
-#ifdef DEBUG_IDC
-    {
-       xmlChar *str = NULL;
-       xmlGenericError(xmlGenericErrorContext,
-           "IDC: BACK on %s, depth %d\n",
-           xmlSchemaFormatQName(&str, vctxt->inode->nsName,
-               vctxt->inode->localName), vctxt->depth);
-       FREE_AND_NULL(str)
-    }
-#endif
     /*
     * Evaluate the state objects.
     */
@@ -22868,10 +22630,6 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
                "calling xmlStreamPop()");
            return (-1);
        }
-#ifdef DEBUG_IDC
-       xmlGenericError(xmlGenericErrorContext, "IDC:   stream pop '%s'\n",
-           sto->sel->xpath);
-#endif
        if (sto->nbHistory == 0)
            goto deregister_check;
 
@@ -22986,7 +22744,7 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
                } else if (pos >= matcher->sizeKeySeqs) {
                    int i = matcher->sizeKeySeqs;
 
-                   matcher->sizeKeySeqs *= 2;
+                   matcher->sizeKeySeqs = pos * 2;
                    matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
                        xmlRealloc(matcher->keySeqs,
                        matcher->sizeKeySeqs *
@@ -23330,10 +23088,6 @@ deregister_check:
        * Deregister state objects if they reach the depth of creation.
        */
        if ((sto->nbHistory == 0) && (sto->depth == depth)) {
-#ifdef DEBUG_IDC
-           xmlGenericError(xmlGenericErrorContext, "IDC:   STO pop '%s'\n",
-               sto->sel->xpath);
-#endif
            if (vctxt->xpathStates != sto) {
                VERROR_INT("xmlSchemaXPathProcessHistory",
                    "The state object to be removed is not the first "
@@ -23378,16 +23132,6 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
     if (idc == NULL)
        return (0);
 
-#ifdef DEBUG_IDC
-    {
-       xmlChar *str = NULL;
-       xmlGenericError(xmlGenericErrorContext,
-           "IDC: REGISTER on %s, depth %d\n",
-           (char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName,
-               vctxt->inode->localName), vctxt->depth);
-       FREE_AND_NULL(str)
-    }
-#endif
     if (vctxt->inode->idcMatchers != NULL) {
        VERROR_INT("xmlSchemaIDCRegisterMatchers",
            "The chain of IDC matchers is expected to be empty");
@@ -23472,9 +23216,6 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
        matcher->depth = vctxt->depth;
        matcher->aidc = aidc;
        matcher->idcType = aidc->def->type;
-#ifdef DEBUG_IDC
-       xmlGenericError(xmlGenericErrorContext, "IDC:   register matcher\n");
-#endif
        /*
        * Init the automaton state object.
        */
@@ -26185,25 +25926,6 @@ xmlSchemaVContentModelCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
     xmlSchemaElementPtr item = (xmlSchemaElementPtr) transdata;
     xmlSchemaNodeInfoPtr inode = (xmlSchemaNodeInfoPtr) inputdata;
     inode->decl = item;
-#ifdef DEBUG_CONTENT
-    {
-       xmlChar *str = NULL;
-
-       if (item->type == XML_SCHEMA_TYPE_ELEMENT) {
-           xmlGenericError(xmlGenericErrorContext,
-               "AUTOMATON callback for '%s' [declaration]\n",
-               xmlSchemaFormatQName(&str,
-               inode->localName, inode->nsName));
-       } else {
-           xmlGenericError(xmlGenericErrorContext,
-                   "AUTOMATON callback for '%s' [wildcard]\n",
-                   xmlSchemaFormatQName(&str,
-                   inode->localName, inode->nsName));
-
-       }
-       FREE_AND_NULL(str)
-    }
-#endif
 }
 
 static int
@@ -26294,10 +26016,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
                        "failed to create a regex context");
                    goto internal_error;
                }
-#ifdef DEBUG_AUTOMATA
-               xmlGenericError(xmlGenericErrorContext,
-                   "AUTOMATON create on '%s'\n", inode->localName);
-#endif
            }
 
            /*
@@ -26305,11 +26023,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
             */
            if (INODE_NILLED(inode)) {
                ret = 0;
-#ifdef DEBUG_AUTOMATA
-               xmlGenericError(xmlGenericErrorContext,
-                   "AUTOMATON succeeded on nilled '%s'\n",
-                   inode->localName);
-#endif
                 goto skip_nilled;
            }
 
@@ -26331,21 +26044,11 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
                    XML_SCHEMAV_ELEMENT_CONTENT, NULL, NULL,
                    "Missing child element(s)",
                    nbval, nbneg, values);
-#ifdef DEBUG_AUTOMATA
-               xmlGenericError(xmlGenericErrorContext,
-                   "AUTOMATON missing ERROR on '%s'\n",
-                   inode->localName);
-#endif
            } else {
                /*
                * Content model is satisfied.
                */
                ret = 0;
-#ifdef DEBUG_AUTOMATA
-               xmlGenericError(xmlGenericErrorContext,
-                   "AUTOMATON succeeded on '%s'\n",
-                   inode->localName);
-#endif
            }
 
        }
@@ -26648,12 +26351,6 @@ end_elem:
     * Merge/free the IDC table.
     */
     if (inode->idcTable != NULL) {
-#ifdef DEBUG_IDC_NODE_TABLE
-       xmlSchemaDebugDumpIDCTable(stdout,
-           inode->nsName,
-           inode->localName,
-           inode->idcTable);
-#endif
        if ((vctxt->depth > 0) &&
            (vctxt->hasKeyrefs || vctxt->createIDCNodeTables))
        {
@@ -26845,10 +26542,6 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
                    return (-1);
                }
                pielem->regexCtxt = regexCtxt;
-#ifdef DEBUG_AUTOMATA
-               xmlGenericError(xmlGenericErrorContext, "AUTOMATA create on '%s'\n",
-                   pielem->localName);
-#endif
            }
 
            /*
@@ -26863,16 +26556,6 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
                vctxt->inode->localName,
                vctxt->inode->nsName,
                vctxt->inode);
-#ifdef DEBUG_AUTOMATA
-           if (ret < 0)
-               xmlGenericError(xmlGenericErrorContext,
-               "AUTOMATON push ERROR for '%s' on '%s'\n",
-               vctxt->inode->localName, pielem->localName);
-           else
-               xmlGenericError(xmlGenericErrorContext,
-               "AUTOMATON push OK for '%s' on '%s'\n",
-               vctxt->inode->localName, pielem->localName);
-#endif
            if (vctxt->err == XML_SCHEMAV_INTERNAL) {
                VERROR_INT("xmlSchemaValidateChildElem",
                    "calling xmlRegExecPushString2()");
@@ -28691,7 +28374,7 @@ commentSplit(void *ctx, const xmlChar *value)
  * Varargs error callbacks to the user application, harder ...
  */
 
-static void XMLCDECL
+static void
 warningSplit(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
     xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
     if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
@@ -28699,7 +28382,7 @@ warningSplit(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
        TODO
     }
 }
-static void XMLCDECL
+static void
 errorSplit(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
     xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
     if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
@@ -28707,7 +28390,7 @@ errorSplit(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
        TODO
     }
 }
-static void XMLCDECL
+static void
 fatalErrorSplit(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
     xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
     if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
@@ -29043,6 +28726,55 @@ xmlSchemaValidateStreamLocator(void *ctx, const char **file,
 }
 
 /**
+ * xmlSchemaValidateStreamInternal:
+ * @ctxt:  a schema validation context
+ * @pctxt:  a parser context
+ *
+ * Returns 0 if the document is schemas valid, a positive error code
+ *     number otherwise and -1 in case of internal or API error.
+ */
+static int
+xmlSchemaValidateStreamInternal(xmlSchemaValidCtxtPtr ctxt,
+                                 xmlParserCtxtPtr pctxt) {
+    xmlSchemaSAXPlugPtr plug = NULL;
+    int ret;
+
+    pctxt->linenumbers = 1;
+    xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
+
+    ctxt->parserCtxt = pctxt;
+    ctxt->input = pctxt->input->buf;
+
+    /*
+     * Plug the validation and launch the parsing
+     */
+    plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData));
+    if (plug == NULL) {
+        ret = -1;
+       goto done;
+    }
+    ctxt->input = pctxt->input->buf;
+    ctxt->sax = pctxt->sax;
+    ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
+    ret = xmlSchemaVStart(ctxt);
+
+    if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
+       ret = ctxt->parserCtxt->errNo;
+       if (ret == 0)
+           ret = 1;
+    }
+
+done:
+    ctxt->parserCtxt = NULL;
+    ctxt->sax = NULL;
+    ctxt->input = NULL;
+    if (plug != NULL) {
+        xmlSchemaSAXUnplug(plug);
+    }
+    return (ret);
+}
+
+/**
  * xmlSchemaValidateStream:
  * @ctxt:  a schema validation context
  * @input:  the input to use for reading the data
@@ -29062,8 +28794,6 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
                         xmlParserInputBufferPtr input, xmlCharEncoding enc,
                         xmlSAXHandlerPtr sax, void *user_data)
 {
-    xmlSchemaSAXPlugPtr plug = NULL;
-    xmlSAXHandlerPtr old_sax = NULL;
     xmlParserCtxtPtr pctxt = NULL;
     xmlParserInputPtr inputStream = NULL;
     int ret;
@@ -29074,18 +28804,22 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
     /*
      * prepare the parser
      */
-    pctxt = xmlNewParserCtxt();
-    if (pctxt == NULL)
-        return (-1);
-    old_sax = pctxt->sax;
-    pctxt->sax = sax;
-    pctxt->userData = user_data;
+    if (sax != NULL) {
+        pctxt = xmlNewSAXParserCtxt(sax, user_data);
+        if (pctxt == NULL)
+            return (-1);
+    } else {
+        pctxt = xmlNewParserCtxt();
+        if (pctxt == NULL)
+            return (-1);
+        /* We really want pctxt->sax to be NULL here. */
+        xmlFree(pctxt->sax);
+        pctxt->sax = NULL;
+    }
 #if 0
     if (options)
         xmlCtxtUseOptions(pctxt, options);
 #endif
-    pctxt->linenumbers = 1;
-    xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
 
     inputStream = xmlNewIOInputStream(pctxt, input, enc);;
     if (inputStream == NULL) {
@@ -29093,39 +28827,14 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
        goto done;
     }
     inputPush(pctxt, inputStream);
-    ctxt->parserCtxt = pctxt;
-    ctxt->input = input;
 
-    /*
-     * Plug the validation and launch the parsing
-     */
-    plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData));
-    if (plug == NULL) {
-        ret = -1;
-       goto done;
-    }
-    ctxt->input = input;
     ctxt->enc = enc;
-    ctxt->sax = pctxt->sax;
-    ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
-    ret = xmlSchemaVStart(ctxt);
 
-    if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
-       ret = ctxt->parserCtxt->errNo;
-       if (ret == 0)
-           ret = 1;
-    }
+    ret = xmlSchemaValidateStreamInternal(ctxt, pctxt);
 
 done:
-    ctxt->parserCtxt = NULL;
-    ctxt->sax = NULL;
-    ctxt->input = NULL;
-    if (plug != NULL) {
-        xmlSchemaSAXUnplug(plug);
-    }
     /* cleanup */
     if (pctxt != NULL) {
-       pctxt->sax = old_sax;
        xmlFreeParserCtxt(pctxt);
     }
     return (ret);
@@ -29149,17 +28858,19 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
                      int options ATTRIBUTE_UNUSED)
 {
     int ret;
-    xmlParserInputBufferPtr input;
+    xmlParserCtxtPtr pctxt = NULL;
 
     if ((ctxt == NULL) || (filename == NULL))
         return (-1);
 
-    input = xmlParserInputBufferCreateFilename(filename,
-       XML_CHAR_ENCODING_NONE);
-    if (input == NULL)
+    pctxt = xmlCreateURLParserCtxt(filename, 0);
+    if (pctxt == NULL)
        return (-1);
-    ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
-       NULL, NULL);
+    /* We really want pctxt->sax to be NULL here. */
+    xmlFree(pctxt->sax);
+    pctxt->sax = NULL;
+    ret = xmlSchemaValidateStreamInternal(ctxt, pctxt);
+    xmlFreeParserCtxt(pctxt);
     return (ret);
 }
 
index 26c033d..de95d94 100644 (file)
@@ -17,6 +17,7 @@
 
 #ifdef LIBXML_SCHEMAS_ENABLED
 
+#include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <float.h>
@@ -25,7 +26,6 @@
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/hash.h>
-#include <libxml/valid.h>
 #include <libxml/xpath.h>
 #include <libxml/uri.h>
 
@@ -33,7 +33,7 @@
 #include <libxml/schemasInternals.h>
 #include <libxml/xmlschemastypes.h>
 
-#define DEBUG
+#include "private/error.h"
 
 #ifndef LIBXML_XPATH_ENABLED
 extern double xmlXPathNAN;
@@ -383,18 +383,61 @@ xmlSchemaAddParticle(void)
     return (ret);
 }
 
+static void
+xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xmlSchemaFreeType((xmlSchemaTypePtr) type);
+}
+
+/**
+ * xmlSchemaCleanupTypesInternal:
+ *
+ * Cleanup the default XML Schemas type library
+ */
+static void
+xmlSchemaCleanupTypesInternal(void) {
+    xmlSchemaParticlePtr particle;
+
+    /*
+    * Free xs:anyType.
+    */
+    if (xmlSchemaTypeAnyTypeDef != NULL) {
+        /* Attribute wildcard. */
+        xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard);
+        /* Content type. */
+        particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes;
+        /* Wildcard. */
+        xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
+            particle->children->children->children);
+        xmlFree((xmlSchemaParticlePtr) particle->children->children);
+        /* Sequence model group. */
+        xmlFree((xmlSchemaModelGroupPtr) particle->children);
+        xmlFree((xmlSchemaParticlePtr) particle);
+        xmlSchemaTypeAnyTypeDef->subtypes = NULL;
+        xmlSchemaTypeAnyTypeDef = NULL;
+    }
+
+    xmlHashFree(xmlSchemaTypesBank, xmlSchemaFreeTypeEntry);
+    xmlSchemaTypesBank = NULL;
+    /* Note that the xmlSchemaType*Def pointers aren't set to NULL. */
+}
+
 /*
  * xmlSchemaInitTypes:
  *
  * Initialize the default XML Schemas type library
+ *
+ * Returns 0 on success, -1 on error.
  */
-void
+int
 xmlSchemaInitTypes(void)
 {
     if (xmlSchemaTypesInitialized != 0)
-        return;
+        return (0);
     xmlSchemaTypesBank = xmlHashCreate(40);
-
+    if (xmlSchemaTypesBank == NULL) {
+       xmlSchemaTypeErrMemory(NULL, NULL);
+        goto error;
+    }
 
     /*
     * 3.4.7 Built-in Complex Type Definition
@@ -402,6 +445,8 @@ xmlSchemaInitTypes(void)
     xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType",
                                                      XML_SCHEMAS_ANYTYPE,
                                                     NULL);
+    if (xmlSchemaTypeAnyTypeDef == NULL)
+        goto error;
     xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef;
     xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
     /*
@@ -415,14 +460,14 @@ xmlSchemaInitTypes(void)
        /* First particle. */
        particle = xmlSchemaAddParticle();
        if (particle == NULL)
-           return;
+           goto error;
        xmlSchemaTypeAnyTypeDef->subtypes = (xmlSchemaTypePtr) particle;
        /* Sequence model group. */
        sequence = (xmlSchemaModelGroupPtr)
            xmlMalloc(sizeof(xmlSchemaModelGroup));
        if (sequence == NULL) {
            xmlSchemaTypeErrMemory(NULL, "allocating model group component");
-           return;
+           goto error;
        }
        memset(sequence, 0, sizeof(xmlSchemaModelGroup));
        sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
@@ -430,7 +475,7 @@ xmlSchemaInitTypes(void)
        /* Second particle. */
        particle = xmlSchemaAddParticle();
        if (particle == NULL)
-           return;
+           goto error;
        particle->minOccurs = 0;
        particle->maxOccurs = UNBOUNDED;
        sequence->children = (xmlSchemaTreeItemPtr) particle;
@@ -438,7 +483,7 @@ xmlSchemaInitTypes(void)
        wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard));
        if (wild == NULL) {
            xmlSchemaTypeErrMemory(NULL, "allocating wildcard component");
-           return;
+           goto error;
        }
        memset(wild, 0, sizeof(xmlSchemaWildcard));
        wild->type = XML_SCHEMA_TYPE_ANY;
@@ -452,7 +497,7 @@ xmlSchemaInitTypes(void)
        if (wild == NULL) {
            xmlSchemaTypeErrMemory(NULL, "could not create an attribute "
                "wildcard on anyType");
-           return;
+           goto error;
        }
        memset(wild, 0, sizeof(xmlSchemaWildcard));
        wild->any = 1;
@@ -462,66 +507,106 @@ xmlSchemaInitTypes(void)
     xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
                                                            XML_SCHEMAS_ANYSIMPLETYPE,
                                                           xmlSchemaTypeAnyTypeDef);
+    if (xmlSchemaTypeAnySimpleTypeDef == NULL)
+        goto error;
     /*
     * primitive datatypes
     */
     xmlSchemaTypeStringDef = xmlSchemaInitBasicType("string",
                                                     XML_SCHEMAS_STRING,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeStringDef == NULL)
+        goto error;
     xmlSchemaTypeDecimalDef = xmlSchemaInitBasicType("decimal",
                                                      XML_SCHEMAS_DECIMAL,
                                                     xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeDecimalDef == NULL)
+        goto error;
     xmlSchemaTypeDateDef = xmlSchemaInitBasicType("date",
                                                   XML_SCHEMAS_DATE,
                                                  xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeDateDef == NULL)
+        goto error;
     xmlSchemaTypeDatetimeDef = xmlSchemaInitBasicType("dateTime",
                                                       XML_SCHEMAS_DATETIME,
                                                      xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeDatetimeDef == NULL)
+        goto error;
     xmlSchemaTypeTimeDef = xmlSchemaInitBasicType("time",
                                                   XML_SCHEMAS_TIME,
                                                  xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeTimeDef == NULL)
+        goto error;
     xmlSchemaTypeGYearDef = xmlSchemaInitBasicType("gYear",
                                                    XML_SCHEMAS_GYEAR,
                                                   xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeGYearDef == NULL)
+        goto error;
     xmlSchemaTypeGYearMonthDef = xmlSchemaInitBasicType("gYearMonth",
                                                         XML_SCHEMAS_GYEARMONTH,
                                                        xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeGYearMonthDef == NULL)
+        goto error;
     xmlSchemaTypeGMonthDef = xmlSchemaInitBasicType("gMonth",
                                                     XML_SCHEMAS_GMONTH,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeGMonthDef == NULL)
+        goto error;
     xmlSchemaTypeGMonthDayDef = xmlSchemaInitBasicType("gMonthDay",
                                                        XML_SCHEMAS_GMONTHDAY,
                                                       xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeGMonthDayDef == NULL)
+        goto error;
     xmlSchemaTypeGDayDef = xmlSchemaInitBasicType("gDay",
                                                   XML_SCHEMAS_GDAY,
                                                  xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeGDayDef == NULL)
+        goto error;
     xmlSchemaTypeDurationDef = xmlSchemaInitBasicType("duration",
                                                       XML_SCHEMAS_DURATION,
                                                      xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeDurationDef == NULL)
+        goto error;
     xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float",
                                                    XML_SCHEMAS_FLOAT,
                                                   xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeFloatDef == NULL)
+        goto error;
     xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double",
                                                     XML_SCHEMAS_DOUBLE,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeDoubleDef == NULL)
+        goto error;
     xmlSchemaTypeBooleanDef = xmlSchemaInitBasicType("boolean",
                                                      XML_SCHEMAS_BOOLEAN,
                                                     xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeBooleanDef == NULL)
+        goto error;
     xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI",
                                                     XML_SCHEMAS_ANYURI,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeAnyURIDef == NULL)
+        goto error;
     xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType("hexBinary",
                                                      XML_SCHEMAS_HEXBINARY,
                                                     xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeHexBinaryDef == NULL)
+        goto error;
     xmlSchemaTypeBase64BinaryDef
         = xmlSchemaInitBasicType("base64Binary", XML_SCHEMAS_BASE64BINARY,
        xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeBase64BinaryDef == NULL)
+        goto error;
     xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION",
                                                     XML_SCHEMAS_NOTATION,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeNotationDef == NULL)
+        goto error;
     xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName",
                                                    XML_SCHEMAS_QNAME,
                                                   xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeQNameDef == NULL)
+        goto error;
 
     /*
      * derived datatypes
@@ -529,69 +614,113 @@ xmlSchemaInitTypes(void)
     xmlSchemaTypeIntegerDef = xmlSchemaInitBasicType("integer",
                                                      XML_SCHEMAS_INTEGER,
                                                     xmlSchemaTypeDecimalDef);
+    if (xmlSchemaTypeIntegerDef == NULL)
+        goto error;
     xmlSchemaTypeNonPositiveIntegerDef =
         xmlSchemaInitBasicType("nonPositiveInteger",
                                XML_SCHEMAS_NPINTEGER,
                               xmlSchemaTypeIntegerDef);
+    if (xmlSchemaTypeNonPositiveIntegerDef == NULL)
+        goto error;
     xmlSchemaTypeNegativeIntegerDef =
         xmlSchemaInitBasicType("negativeInteger", XML_SCHEMAS_NINTEGER,
        xmlSchemaTypeNonPositiveIntegerDef);
+    if (xmlSchemaTypeNegativeIntegerDef == NULL)
+        goto error;
     xmlSchemaTypeLongDef =
         xmlSchemaInitBasicType("long", XML_SCHEMAS_LONG,
        xmlSchemaTypeIntegerDef);
+    if (xmlSchemaTypeLongDef == NULL)
+        goto error;
     xmlSchemaTypeIntDef = xmlSchemaInitBasicType("int", XML_SCHEMAS_INT,
        xmlSchemaTypeLongDef);
+    if (xmlSchemaTypeIntDef == NULL)
+        goto error;
     xmlSchemaTypeShortDef = xmlSchemaInitBasicType("short",
                                                    XML_SCHEMAS_SHORT,
                                                   xmlSchemaTypeIntDef);
+    if (xmlSchemaTypeShortDef == NULL)
+        goto error;
     xmlSchemaTypeByteDef = xmlSchemaInitBasicType("byte",
                                                   XML_SCHEMAS_BYTE,
                                                  xmlSchemaTypeShortDef);
+    if (xmlSchemaTypeByteDef == NULL)
+        goto error;
     xmlSchemaTypeNonNegativeIntegerDef =
         xmlSchemaInitBasicType("nonNegativeInteger",
                                XML_SCHEMAS_NNINTEGER,
                               xmlSchemaTypeIntegerDef);
+    if (xmlSchemaTypeNonNegativeIntegerDef == NULL)
+        goto error;
     xmlSchemaTypeUnsignedLongDef =
         xmlSchemaInitBasicType("unsignedLong", XML_SCHEMAS_ULONG,
        xmlSchemaTypeNonNegativeIntegerDef);
+    if (xmlSchemaTypeUnsignedLongDef == NULL)
+        goto error;
     xmlSchemaTypeUnsignedIntDef =
         xmlSchemaInitBasicType("unsignedInt", XML_SCHEMAS_UINT,
        xmlSchemaTypeUnsignedLongDef);
+    if (xmlSchemaTypeUnsignedIntDef == NULL)
+        goto error;
     xmlSchemaTypeUnsignedShortDef =
         xmlSchemaInitBasicType("unsignedShort", XML_SCHEMAS_USHORT,
        xmlSchemaTypeUnsignedIntDef);
+    if (xmlSchemaTypeUnsignedShortDef == NULL)
+        goto error;
     xmlSchemaTypeUnsignedByteDef =
         xmlSchemaInitBasicType("unsignedByte", XML_SCHEMAS_UBYTE,
        xmlSchemaTypeUnsignedShortDef);
+    if (xmlSchemaTypeUnsignedByteDef == NULL)
+        goto error;
     xmlSchemaTypePositiveIntegerDef =
         xmlSchemaInitBasicType("positiveInteger", XML_SCHEMAS_PINTEGER,
        xmlSchemaTypeNonNegativeIntegerDef);
+    if (xmlSchemaTypePositiveIntegerDef == NULL)
+        goto error;
     xmlSchemaTypeNormStringDef = xmlSchemaInitBasicType("normalizedString",
                                                         XML_SCHEMAS_NORMSTRING,
                                                        xmlSchemaTypeStringDef);
+    if (xmlSchemaTypeNormStringDef == NULL)
+        goto error;
     xmlSchemaTypeTokenDef = xmlSchemaInitBasicType("token",
                                                    XML_SCHEMAS_TOKEN,
                                                   xmlSchemaTypeNormStringDef);
+    if (xmlSchemaTypeTokenDef == NULL)
+        goto error;
     xmlSchemaTypeLanguageDef = xmlSchemaInitBasicType("language",
                                                       XML_SCHEMAS_LANGUAGE,
                                                      xmlSchemaTypeTokenDef);
+    if (xmlSchemaTypeLanguageDef == NULL)
+        goto error;
     xmlSchemaTypeNameDef = xmlSchemaInitBasicType("Name",
                                                   XML_SCHEMAS_NAME,
                                                  xmlSchemaTypeTokenDef);
+    if (xmlSchemaTypeNameDef == NULL)
+        goto error;
     xmlSchemaTypeNmtokenDef = xmlSchemaInitBasicType("NMTOKEN",
                                                      XML_SCHEMAS_NMTOKEN,
                                                     xmlSchemaTypeTokenDef);
+    if (xmlSchemaTypeNmtokenDef == NULL)
+        goto error;
     xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName",
                                                     XML_SCHEMAS_NCNAME,
                                                    xmlSchemaTypeNameDef);
+    if (xmlSchemaTypeNCNameDef == NULL)
+        goto error;
     xmlSchemaTypeIdDef = xmlSchemaInitBasicType("ID", XML_SCHEMAS_ID,
                                                    xmlSchemaTypeNCNameDef);
+    if (xmlSchemaTypeIdDef == NULL)
+        goto error;
     xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF",
                                                    XML_SCHEMAS_IDREF,
                                                   xmlSchemaTypeNCNameDef);
+    if (xmlSchemaTypeIdrefDef == NULL)
+        goto error;
     xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY",
                                                     XML_SCHEMAS_ENTITY,
                                                    xmlSchemaTypeNCNameDef);
+    if (xmlSchemaTypeEntityDef == NULL)
+        goto error;
     /*
     * Derived list types.
     */
@@ -599,25 +728,31 @@ xmlSchemaInitTypes(void)
     xmlSchemaTypeEntitiesDef = xmlSchemaInitBasicType("ENTITIES",
                                                       XML_SCHEMAS_ENTITIES,
                                                      xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeEntitiesDef == NULL)
+        goto error;
     xmlSchemaTypeEntitiesDef->subtypes = xmlSchemaTypeEntityDef;
     /* IDREFS */
     xmlSchemaTypeIdrefsDef = xmlSchemaInitBasicType("IDREFS",
                                                     XML_SCHEMAS_IDREFS,
                                                    xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeIdrefsDef == NULL)
+        goto error;
     xmlSchemaTypeIdrefsDef->subtypes = xmlSchemaTypeIdrefDef;
 
     /* NMTOKENS */
     xmlSchemaTypeNmtokensDef = xmlSchemaInitBasicType("NMTOKENS",
                                                       XML_SCHEMAS_NMTOKENS,
                                                      xmlSchemaTypeAnySimpleTypeDef);
+    if (xmlSchemaTypeNmtokensDef == NULL)
+        goto error;
     xmlSchemaTypeNmtokensDef->subtypes = xmlSchemaTypeNmtokenDef;
 
     xmlSchemaTypesInitialized = 1;
-}
+    return (0);
 
-static void
-xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
-    xmlSchemaFreeType((xmlSchemaTypePtr) type);
+error:
+    xmlSchemaCleanupTypesInternal();
+    return (-1);
 }
 
 /**
@@ -626,34 +761,16 @@ xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
  * DEPRECATED: This function will be made private. Call xmlCleanupParser
  * to free global state but see the warnings there. xmlCleanupParser
  * should be only called once at program exit. In most cases, you don't
- * have call cleanup functions at all.
+ * have to call cleanup functions at all.
  *
  * Cleanup the default XML Schemas type library
  */
 void
 xmlSchemaCleanupTypes(void) {
-    if (xmlSchemaTypesInitialized == 0)
-       return;
-    /*
-    * Free xs:anyType.
-    */
-    {
-       xmlSchemaParticlePtr particle;
-       /* Attribute wildcard. */
-       xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard);
-       /* Content type. */
-       particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes;
-       /* Wildcard. */
-       xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
-           particle->children->children->children);
-       xmlFree((xmlSchemaParticlePtr) particle->children->children);
-       /* Sequence model group. */
-       xmlFree((xmlSchemaModelGroupPtr) particle->children);
-       xmlFree((xmlSchemaParticlePtr) particle);
-       xmlSchemaTypeAnyTypeDef->subtypes = NULL;
+    if (xmlSchemaTypesInitialized != 0) {
+        xmlSchemaCleanupTypesInternal();
+        xmlSchemaTypesInitialized = 0;
     }
-    xmlHashFree(xmlSchemaTypesBank, xmlSchemaFreeTypeEntry);
-    xmlSchemaTypesInitialized = 0;
 }
 
 /**
@@ -748,8 +865,9 @@ xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType)
 xmlSchemaTypePtr
 xmlSchemaGetBuiltInType(xmlSchemaValType type)
 {
-    if (xmlSchemaTypesInitialized == 0)
-       xmlSchemaInitTypes();
+    if ((xmlSchemaTypesInitialized == 0) &&
+       (xmlSchemaInitTypes() < 0))
+        return (NULL);
     switch (type) {
 
        case XML_SCHEMAS_ANYSIMPLETYPE:
@@ -1081,8 +1199,9 @@ xmlSchemaFreeValue(xmlSchemaValPtr value) {
  */
 xmlSchemaTypePtr
 xmlSchemaGetPredefinedType(const xmlChar *name, const xmlChar *ns) {
-    if (xmlSchemaTypesInitialized == 0)
-       xmlSchemaInitTypes();
+    if ((xmlSchemaTypesInitialized == 0) &&
+       (xmlSchemaInitTypes() < 0))
+        return (NULL);
     if (name == NULL)
        return(NULL);
     return((xmlSchemaTypePtr) xmlHashLookup2(xmlSchemaTypesBank, name, ns));
@@ -1178,25 +1297,6 @@ static const long dayInLeapYearByMonth[12] =
                 dayInLeapYearByMonth[month - 1] :              \
                 dayInYearByMonth[month - 1]) + day)
 
-#ifdef DEBUG
-#define DEBUG_DATE(dt)                                                  \
-    xmlGenericError(xmlGenericErrorContext,                             \
-        "type=%o %04ld-%02u-%02uT%02u:%02u:%03f",                       \
-        dt->type,dt->value.date.year,dt->value.date.mon,                \
-        dt->value.date.day,dt->value.date.hour,dt->value.date.min,      \
-        dt->value.date.sec);                                            \
-    if (dt->value.date.tz_flag)                                         \
-        if (dt->value.date.tzo != 0)                                    \
-            xmlGenericError(xmlGenericErrorContext,                     \
-                "%+05d\n",dt->value.date.tzo);                          \
-        else                                                            \
-            xmlGenericError(xmlGenericErrorContext, "Z\n");             \
-    else                                                                \
-        xmlGenericError(xmlGenericErrorContext,"\n")
-#else
-#define DEBUG_DATE(dt)
-#endif
-
 /**
  * _xmlSchemaParseGYear:
  * @dt:  pointer to a date structure
@@ -2251,8 +2351,9 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
     xmlChar *norm = NULL;
     int ret = 0;
 
-    if (xmlSchemaTypesInitialized == 0)
-        xmlSchemaInitTypes();
+    if ((xmlSchemaTypesInitialized == 0) &&
+       (xmlSchemaInitTypes() < 0))
+        return (-1);
     if (type == NULL)
         return (-1);
 
@@ -3034,6 +3135,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
                            value = norm;
                    }
                    tmpval = xmlStrdup(value);
+                    if (tmpval == NULL)
+                        goto error;
                    for (cur = tmpval; *cur; ++cur) {
                        if (*cur < 32 || *cur >= 127 || *cur == ' ' ||
                            *cur == '<' || *cur == '>' || *cur == '"' ||
@@ -3220,8 +3323,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
                     if (v == NULL)
                         goto error;
                     base =
-                        (xmlChar *) xmlMallocAtomic((i + pad + 1) *
-                                                    sizeof(xmlChar));
+                        (xmlChar *) xmlMallocAtomic(i + pad + 1);
                     if (base == NULL) {
                        xmlSchemaTypeErrMemory(node, "allocating base64 data");
                         xmlFree(v);
@@ -4141,9 +4243,15 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
 
         if (!y->value.date.tz_flag) {
             p1 = xmlSchemaDateNormalize(x, 0);
+            if (p1 == NULL)
+                return -2;
             p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
             /* normalize y + 14:00 */
             q1 = xmlSchemaDateNormalize(y, (14 * SECS_PER_HOUR));
+            if (q1 == NULL) {
+               xmlSchemaFreeValue(p1);
+                return -2;
+            }
 
             q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
             if (p1d < q1d) {
@@ -4162,6 +4270,11 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
                    int ret = 0;
                     /* normalize y - 14:00 */
                     q2 = xmlSchemaDateNormalize(y, -(14 * SECS_PER_HOUR));
+                    if (q2 == NULL) {
+                        xmlSchemaFreeValue(p1);
+                        xmlSchemaFreeValue(q1);
+                        return -2;
+                    }
                     q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day;
                     if (p1d > q2d)
                         ret = 1;
@@ -4185,10 +4298,16 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
         }
     } else if (y->value.date.tz_flag) {
         q1 = xmlSchemaDateNormalize(y, 0);
+        if (q1 == NULL)
+            return -2;
         q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
 
         /* normalize x - 14:00 */
         p1 = xmlSchemaDateNormalize(x, -(14 * SECS_PER_HOUR));
+        if (p1 == NULL) {
+           xmlSchemaFreeValue(q1);
+            return -2;
+        }
         p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
 
         if (p1d < q1d) {
@@ -4207,6 +4326,11 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
                int ret = 0;
                 /* normalize x + 14:00 */
                 p2 = xmlSchemaDateNormalize(x, (14 * SECS_PER_HOUR));
+                if (p2 == NULL) {
+                    xmlSchemaFreeValue(p1);
+                    xmlSchemaFreeValue(q1);
+                    return -2;
+                }
                 p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day;
 
                 if (p2d > q1d) {
@@ -4236,9 +4360,15 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
     if (x->type == y->type) {
         int ret = 0;
         q1 = xmlSchemaDateNormalize(y, 0);
+        if (q1 == NULL)
+            return -2;
         q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
 
         p1 = xmlSchemaDateNormalize(x, 0);
+        if (p1 == NULL) {
+           xmlSchemaFreeValue(q1);
+            return -2;
+        }
         p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
 
         if (p1d < q1d) {
index 46301c3..d9e16d7 100644 (file)
@@ -23,6 +23,9 @@
 #include <libxml/parserInternals.h>
 #include <libxml/xmlstring.h>
 
+#include "private/parser.h"
+#include "private/string.h"
+
 /************************************************************************
  *                                                                      *
  *                Commodity functions to handle xmlChars                *
@@ -43,12 +46,11 @@ xmlStrndup(const xmlChar *cur, int len) {
     xmlChar *ret;
 
     if ((cur == NULL) || (len < 0)) return(NULL);
-    ret = (xmlChar *) xmlMallocAtomic(((size_t) len + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1);
     if (ret == NULL) {
-        xmlErrMemory(NULL, NULL);
         return(NULL);
     }
-    memcpy(ret, cur, len * sizeof(xmlChar));
+    memcpy(ret, cur, len);
     ret[len] = 0;
     return(ret);
 }
@@ -88,12 +90,12 @@ xmlCharStrndup(const char *cur, int len) {
     xmlChar *ret;
 
     if ((cur == NULL) || (len < 0)) return(NULL);
-    ret = (xmlChar *) xmlMallocAtomic(((size_t) len + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1);
     if (ret == NULL) {
-        xmlErrMemory(NULL, NULL);
         return(NULL);
     }
     for (i = 0;i < len;i++) {
+        /* Explicit sign change */
         ret[i] = (xmlChar) cur[i];
         if (ret[i] == 0) return(ret);
     }
@@ -457,12 +459,11 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
     size = xmlStrlen(cur);
     if ((size < 0) || (size > INT_MAX - len))
         return(NULL);
-    ret = (xmlChar *) xmlRealloc(cur, ((size_t) size + len + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlRealloc(cur, (size_t) size + len + 1);
     if (ret == NULL) {
-        xmlErrMemory(NULL, NULL);
         return(cur);
     }
-    memcpy(&ret[size], add, len * sizeof(xmlChar));
+    memcpy(&ret[size], add, len);
     ret[size + len] = 0;
     return(ret);
 }
@@ -497,13 +498,12 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
     size = xmlStrlen(str1);
     if ((size < 0) || (size > INT_MAX - len))
         return(NULL);
-    ret = (xmlChar *) xmlMalloc(((size_t) size + len + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMalloc((size_t) size + len + 1);
     if (ret == NULL) {
-        xmlErrMemory(NULL, NULL);
         return(xmlStrndup(str1, size));
     }
-    memcpy(ret, str1, size * sizeof(xmlChar));
-    memcpy(&ret[size], str2, len * sizeof(xmlChar));
+    memcpy(ret, str1, size);
+    memcpy(&ret[size], str2, len);
     ret[size + len] = 0;
     return(ret);
 }
@@ -543,7 +543,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
  *
  * Returns the number of characters written to @buf or -1 if an error occurs.
  */
-int XMLCDECL
+int
 xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
     va_list args;
     int ret;
@@ -712,47 +712,47 @@ xmlGetUTF8Char(const unsigned char *utf, int *len) {
         goto error;
     if (len == NULL)
         goto error;
-    if (*len < 1)
-        goto error;
 
     c = utf[0];
-    if (c & 0x80) {
-        if (*len < 2)
+    if (c < 0x80) {
+        if (*len < 1)
             goto error;
-        if ((utf[1] & 0xc0) != 0x80)
+        /* 1-byte code */
+        *len = 1;
+    } else {
+        if ((*len < 2) || ((utf[1] & 0xc0) != 0x80))
             goto error;
-        if ((c & 0xe0) == 0xe0) {
-            if (*len < 3)
+        if (c < 0xe0) {
+            if (c < 0xc2)
                 goto error;
-            if ((utf[2] & 0xc0) != 0x80)
+            /* 2-byte code */
+            *len = 2;
+            c = (c & 0x1f) << 6;
+            c |= utf[1] & 0x3f;
+        } else {
+            if ((*len < 3) || ((utf[2] & 0xc0) != 0x80))
                 goto error;
-            if ((c & 0xf0) == 0xf0) {
-                if (*len < 4)
+            if (c < 0xf0) {
+                /* 3-byte code */
+                *len = 3;
+                c = (c & 0xf) << 12;
+                c |= (utf[1] & 0x3f) << 6;
+                c |= utf[2] & 0x3f;
+                if ((c < 0x800) || ((c >= 0xd800) && (c < 0xe000)))
                     goto error;
-                if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
+            } else {
+                if ((*len < 4) || ((utf[3] & 0xc0) != 0x80))
                     goto error;
                 *len = 4;
                 /* 4-byte code */
-                c = (utf[0] & 0x7) << 18;
+                c = (c & 0x7) << 18;
                 c |= (utf[1] & 0x3f) << 12;
                 c |= (utf[2] & 0x3f) << 6;
                 c |= utf[3] & 0x3f;
-            } else {
-              /* 3-byte code */
-                *len = 3;
-                c = (utf[0] & 0xf) << 12;
-                c |= (utf[1] & 0x3f) << 6;
-                c |= utf[2] & 0x3f;
+                if ((c < 0x10000) || (c >= 0x110000))
+                    goto error;
             }
-        } else {
-          /* 2-byte code */
-            *len = 2;
-            c = (utf[0] & 0x1f) << 6;
-            c |= utf[1] & 0x3f;
         }
-    } else {
-        /* 1-byte code */
-        *len = 1;
     }
     return(c);
 
@@ -871,11 +871,11 @@ xmlUTF8Strndup(const xmlChar *utf, int len) {
 
     if ((utf == NULL) || (len < 0)) return(NULL);
     i = xmlUTF8Strsize(utf, len);
-    ret = (xmlChar *) xmlMallocAtomic(((size_t) i + 1) * sizeof(xmlChar));
+    ret = (xmlChar *) xmlMallocAtomic((size_t) i + 1);
     if (ret == NULL) {
         return(NULL);
     }
-    memcpy(ret, utf, i * sizeof(xmlChar));
+    memcpy(ret, utf, i);
     ret[i] = 0;
     return(ret);
 }
@@ -1022,13 +1022,12 @@ xmlEscapeFormatString(xmlChar **msg)
     if ((count > INT_MAX) || (msgLen > INT_MAX - count))
         return(NULL);
     resultLen = msgLen + count + 1;
-    result = (xmlChar *) xmlMallocAtomic(resultLen * sizeof(xmlChar));
+    result = (xmlChar *) xmlMallocAtomic(resultLen);
     if (result == NULL) {
         /* Clear *msg to prevent format string vulnerabilities in
            out-of-memory situations. */
         xmlFree(*msg);
         *msg = NULL;
-        xmlErrMemory(NULL, NULL);
         return(NULL);
     }
 
index 85c1955..ad6e00c 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/uri.h>
 #include <libxml/HTMLtree.h>
+#include <libxml/SAX2.h>
 
 #ifdef LIBXML_WRITER_ENABLED
 
 #include <libxml/xmlwriter.h>
 
-#include "buf.h"
-#include "enc.h"
-#include "save.h"
+#include "private/buf.h"
+#include "private/enc.h"
+#include "private/error.h"
+#include "private/save.h"
 
 #define B64LINELEN 72
 #define B64CRLF "\r\n"
@@ -188,7 +190,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
                         "xmlNewTextWriter : out of memory!\n");
         return NULL;
     }
-    memset(ret, 0, (size_t) sizeof(xmlTextWriter));
+    memset(ret, 0, sizeof(xmlTextWriter));
 
     ret->nodes = xmlListCreate(xmlFreeTextWriterStackEntry,
                                xmlCmpTextWriterStackEntry);
@@ -708,7 +710,11 @@ xmlTextWriterEndDocument(xmlTextWriterPtr writer)
         sum += count;
     }
 
-    sum += xmlTextWriterFlush(writer);
+    count = xmlTextWriterFlush(writer);
+    if (count < 0)
+        return -1;
+    sum += count;
+
 
     return sum;
 }
@@ -863,7 +869,7 @@ xmlTextWriterEndComment(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
                                 const char *format, ...)
 {
@@ -1291,7 +1297,7 @@ xmlTextWriterFullEndElement(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, const char *format,
                             ...)
 {
@@ -1417,7 +1423,7 @@ xmlTextWriterWriteRaw(xmlTextWriterPtr writer, const xmlChar * content)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatString(xmlTextWriterPtr writer, const char *format,
                                ...)
 {
@@ -1963,7 +1969,7 @@ xmlTextWriterEndAttribute(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
                                   const xmlChar * name, const char *format,
                                   ...)
@@ -2058,7 +2064,7 @@ xmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar * name,
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
                                     const xmlChar * prefix,
                                     const xmlChar * name,
@@ -2166,7 +2172,7 @@ xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer,
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
                                 const xmlChar * name, const char *format,
                                 ...)
@@ -2263,7 +2269,7 @@ xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name,
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
                                   const xmlChar * prefix,
                                   const xmlChar * name,
@@ -2520,7 +2526,7 @@ xmlTextWriterEndPI(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, const xmlChar * target,
                            const char *format, ...)
 {
@@ -2735,7 +2741,7 @@ xmlTextWriterEndCDATA(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, const char *format,
                               ...)
 {
@@ -3044,7 +3050,7 @@ xmlTextWriterEndDTD(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
                             const xmlChar * name,
                             const xmlChar * pubid,
@@ -3288,7 +3294,7 @@ xmlTextWriterEndDTDElement(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
                                    const xmlChar * name,
                                    const char *format, ...)
@@ -3525,7 +3531,7 @@ xmlTextWriterEndDTDAttlist(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
                                    const xmlChar * name,
                                    const char *format, ...)
@@ -3783,7 +3789,7 @@ xmlTextWriterEndDTDEntity(xmlTextWriterPtr writer)
  *
  * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
  */
-int XMLCDECL
+int
 xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
                                           int pe,
                                           const xmlChar * name,
diff --git a/xpath.c b/xpath.c
index fbee6a5..83e0652 100644 (file)
--- a/xpath.c
+++ b/xpath.c
@@ -31,7 +31,6 @@
 
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
-#include <libxml/valid.h>
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/parserInternals.h>
 #endif
 #include <libxml/xmlerror.h>
 #include <libxml/threads.h>
-#include <libxml/globals.h>
 #ifdef LIBXML_PATTERN_ENABLED
 #include <libxml/pattern.h>
 #endif
 
-#include "buf.h"
+#include "private/buf.h"
+#include "private/error.h"
+#include "private/xpath.h"
 
 #ifdef LIBXML_PATTERN_ENABLED
 #define XPATH_STREAMING
 #define XP_OPTIMIZED_FILTER_FIRST
 
 /*
-* XP_DEBUG_OBJ_USAGE:
-* Internal flag to enable tracking of how much XPath objects have been
-* created.
-*/
-/* #define XP_DEBUG_OBJ_USAGE */
-
-/*
  * XPATH_MAX_STEPS:
  * when compiling an XPath expression we arbitrary limit the maximum
  * number of step operation in the compiled expression. 1000000 is
  */
 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 #define XPATH_MAX_RECURSION_DEPTH 500
+#elif defined(_WIN32)
+/* Windows typically limits stack size to 1MB. */
+#define XPATH_MAX_RECURSION_DEPTH 1000
 #else
 #define XPATH_MAX_RECURSION_DEPTH 5000
 #endif
  * any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT)
  */
 
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+
+/************************************************************************
+ *                                                                     *
+ *                     Floating point stuff                            *
+ *                                                                     *
+ ************************************************************************/
+
+double xmlXPathNAN = 0.0;
+double xmlXPathPINF = 0.0;
+double xmlXPathNINF = 0.0;
+
+/**
+ * xmlXPathInit:
+ *
+ * DEPRECATED: Alias for xmlInitParser.
+ */
+void
+xmlXPathInit(void) {
+    xmlInitParser();
+}
+
+/**
+ * xmlInitXPathInternal:
+ *
+ * Initialize the XPath environment
+ */
+ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
+void
+xmlInitXPathInternal(void) {
+#if defined(NAN) && defined(INFINITY)
+    xmlXPathNAN = NAN;
+    xmlXPathPINF = INFINITY;
+    xmlXPathNINF = -INFINITY;
+#else
+    /* MSVC doesn't allow division by zero in constant expressions. */
+    double zero = 0.0;
+    xmlXPathNAN = 0.0 / zero;
+    xmlXPathPINF = 1.0 / zero;
+    xmlXPathNINF = -xmlXPathPINF;
+#endif
+}
+
+/**
+ * xmlXPathIsNaN:
+ * @val:  a double value
+ *
+ * Checks whether a double is a NaN.
+ *
+ * Returns 1 if the value is a NaN, 0 otherwise
+ */
+int
+xmlXPathIsNaN(double val) {
+#ifdef isnan
+    return isnan(val);
+#else
+    return !(val == val);
+#endif
+}
+
+/**
+ * xmlXPathIsInf:
+ * @val:  a double value
+ *
+ * Checks whether a double is an infinity.
+ *
+ * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
+ */
+int
+xmlXPathIsInf(double val) {
+#ifdef isinf
+    return isinf(val) ? (val > 0 ? 1 : -1) : 0;
+#else
+    if (val >= xmlXPathPINF)
+        return 1;
+    if (val <= -xmlXPathPINF)
+        return -1;
+    return 0;
+#endif
+}
+
+#endif /* SCHEMAS or XPATH */
+
+#ifdef LIBXML_XPATH_ENABLED
+
+/*
+ * TODO: when compatibility allows remove all "fake node libxslt" strings
+ *       the test should just be name[0] = ' '
+ */
+
+static xmlNs xmlXPathXMLNamespaceStruct = {
+    NULL,
+    XML_NAMESPACE_DECL,
+    XML_XML_NAMESPACE,
+    BAD_CAST "xml",
+    NULL,
+    NULL
+};
+static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
+#ifndef LIBXML_THREAD_ENABLED
+/*
+ * Optimizer is disabled only when threaded apps are detected while
+ * the library ain't compiled for thread safety.
+ */
+static int xmlXPathDisableOptimizer = 0;
+#endif
+
+static void
+xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes);
+
 #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
 /**
  * xmlXPathCmpNodesExt:
@@ -467,107 +573,6 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
 #include "timsort.h"
 #endif /* WITH_TIM_SORT */
 
-#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-
-/************************************************************************
- *                                                                     *
- *                     Floating point stuff                            *
- *                                                                     *
- ************************************************************************/
-
-double xmlXPathNAN = 0.0;
-double xmlXPathPINF = 0.0;
-double xmlXPathNINF = 0.0;
-
-/**
- * xmlXPathInit:
- *
- * DEPRECATED: This function will be made private. Call xmlInitParser to
- * initialize the library.
- *
- * Initialize the XPath environment
- */
-ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
-void
-xmlXPathInit(void) {
-#if defined(NAN) && defined(INFINITY)
-    xmlXPathNAN = NAN;
-    xmlXPathPINF = INFINITY;
-    xmlXPathNINF = -INFINITY;
-#else
-    /* MSVC doesn't allow division by zero in constant expressions. */
-    double zero = 0.0;
-    xmlXPathNAN = 0.0 / zero;
-    xmlXPathPINF = 1.0 / zero;
-    xmlXPathNINF = -xmlXPathPINF;
-#endif
-}
-
-/**
- * xmlXPathIsNaN:
- * @val:  a double value
- *
- * Returns 1 if the value is a NaN, 0 otherwise
- */
-int
-xmlXPathIsNaN(double val) {
-#ifdef isnan
-    return isnan(val);
-#else
-    return !(val == val);
-#endif
-}
-
-/**
- * xmlXPathIsInf:
- * @val:  a double value
- *
- * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
- */
-int
-xmlXPathIsInf(double val) {
-#ifdef isinf
-    return isinf(val) ? (val > 0 ? 1 : -1) : 0;
-#else
-    if (val >= xmlXPathPINF)
-        return 1;
-    if (val <= -xmlXPathPINF)
-        return -1;
-    return 0;
-#endif
-}
-
-#endif /* SCHEMAS or XPATH */
-
-#ifdef LIBXML_XPATH_ENABLED
-
-/*
- * TODO: when compatibility allows remove all "fake node libxslt" strings
- *       the test should just be name[0] = ' '
- */
-#ifdef DEBUG_XPATH_EXPRESSION
-#define DEBUG_STEP
-#define DEBUG_EXPR
-#define DEBUG_EVAL_COUNTS
-#endif
-
-static xmlNs xmlXPathXMLNamespaceStruct = {
-    NULL,
-    XML_NAMESPACE_DECL,
-    XML_XML_NAMESPACE,
-    BAD_CAST "xml",
-    NULL,
-    NULL
-};
-static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
-#ifndef LIBXML_THREAD_ENABLED
-/*
- * Optimizer is disabled only when threaded apps are detected while
- * the library ain't compiled for thread safety.
- */
-static int xmlXPathDisableOptimizer = 0;
-#endif
-
 /************************************************************************
  *                                                                     *
  *                     Error handling routines                         *
@@ -700,6 +705,9 @@ xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
                        "%s", xmlXPathErrorMessages[error]);
        return;
     }
+    /* Only report the first error */
+    if (ctxt->error != 0)
+        return;
     ctxt->error = error;
     if (ctxt->context == NULL) {
        __xmlRaiseError(NULL, NULL, NULL,
@@ -805,32 +813,30 @@ xmlPointerListAddSize(xmlPointerListPtr list,
                       void *item,
                       int initialSize)
 {
-    if (list->items == NULL) {
-       if (initialSize <= 0)
-           initialSize = 1;
-       list->items = (void **) xmlMalloc(initialSize * sizeof(void *));
-       if (list->items == NULL) {
-           xmlXPathErrMemory(NULL,
-               "xmlPointerListCreate: allocating item\n");
-           return(-1);
-       }
-       list->number = 0;
-       list->size = initialSize;
-    } else if (list->size <= list->number) {
-        if (list->size > 50000000) {
-           xmlXPathErrMemory(NULL,
-               "xmlPointerListAddSize: re-allocating item\n");
-            return(-1);
+    if (list->size <= list->number) {
+        void **tmp;
+        size_t newSize;
+
+        if (list->size == 0) {
+            if (initialSize <= 0)
+                initialSize = 1;
+            newSize = initialSize;
+        } else {
+            if (list->size > 50000000) {
+                xmlXPathErrMemory(NULL,
+                    "xmlPointerListAddSize: re-allocating item\n");
+                return(-1);
+            }
+           newSize = list->size * 2;
         }
-       list->size *= 2;
-       list->items = (void **) xmlRealloc(list->items,
-           list->size * sizeof(void *));
-       if (list->items == NULL) {
+       tmp = (void **) xmlRealloc(list->items, newSize * sizeof(void *));
+       if (tmp == NULL) {
            xmlXPathErrMemory(NULL,
                "xmlPointerListAddSize: re-allocating item\n");
-           list->size = 0;
            return(-1);
        }
+        list->items = tmp;
+        list->size = newSize;
     }
     list->items[list->number++] = item;
     return(0);
@@ -966,10 +972,6 @@ struct _xmlXPathCompExpr {
     int last;                  /* index of last step in expression */
     xmlChar *expr;             /* the expression being computed */
     xmlDictPtr dict;           /* the dictionary to use if any */
-#ifdef DEBUG_EVAL_COUNTS
-    int nb;
-    xmlChar *string;
-#endif
 #ifdef XPATH_STREAMING
     xmlPatternPtr stream;
 #endif
@@ -1028,9 +1030,6 @@ xmlXPathNewCompExpr(void) {
     }
     memset(cur->steps, 0, cur->maxStep * sizeof(xmlXPathStepOp));
     cur->last = -1;
-#ifdef DEBUG_EVAL_COUNTS
-    cur->nb = 0;
-#endif
     return(cur);
 }
 
@@ -1073,11 +1072,6 @@ xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp)
     if (comp->steps != NULL) {
         xmlFree(comp->steps);
     }
-#ifdef DEBUG_EVAL_COUNTS
-    if (comp->string != NULL) {
-        xmlFree(comp->string);
-    }
-#endif
 #ifdef XPATH_STREAMING
     if (comp->stream != NULL) {
         xmlFreePatternList(comp->stream);
@@ -1224,33 +1218,6 @@ struct _xmlXPathContextCache {
     int maxBoolean;
     int maxNumber;
     int maxMisc;
-#ifdef XP_DEBUG_OBJ_USAGE
-    int dbgCachedAll;
-    int dbgCachedNodeset;
-    int dbgCachedString;
-    int dbgCachedBool;
-    int dbgCachedNumber;
-    int dbgCachedPoint;
-    int dbgCachedRange;
-    int dbgCachedLocset;
-    int dbgCachedUsers;
-    int dbgCachedXSLTTree;
-    int dbgCachedUndefined;
-
-
-    int dbgReusedAll;
-    int dbgReusedNodeset;
-    int dbgReusedString;
-    int dbgReusedBool;
-    int dbgReusedNumber;
-    int dbgReusedPoint;
-    int dbgReusedRange;
-    int dbgReusedLocset;
-    int dbgReusedUsers;
-    int dbgReusedXSLTTree;
-    int dbgReusedUndefined;
-
-#endif
 };
 
 /************************************************************************
@@ -1707,478 +1674,6 @@ xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
     }
 }
 
-#ifdef XP_DEBUG_OBJ_USAGE
-
-/*
-* XPath object usage related debugging variables.
-*/
-static int xmlXPathDebugObjCounterUndefined = 0;
-static int xmlXPathDebugObjCounterNodeset = 0;
-static int xmlXPathDebugObjCounterBool = 0;
-static int xmlXPathDebugObjCounterNumber = 0;
-static int xmlXPathDebugObjCounterString = 0;
-static int xmlXPathDebugObjCounterPoint = 0;
-static int xmlXPathDebugObjCounterRange = 0;
-static int xmlXPathDebugObjCounterLocset = 0;
-static int xmlXPathDebugObjCounterUsers = 0;
-static int xmlXPathDebugObjCounterXSLTTree = 0;
-static int xmlXPathDebugObjCounterAll = 0;
-
-static int xmlXPathDebugObjTotalUndefined = 0;
-static int xmlXPathDebugObjTotalNodeset = 0;
-static int xmlXPathDebugObjTotalBool = 0;
-static int xmlXPathDebugObjTotalNumber = 0;
-static int xmlXPathDebugObjTotalString = 0;
-static int xmlXPathDebugObjTotalPoint = 0;
-static int xmlXPathDebugObjTotalRange = 0;
-static int xmlXPathDebugObjTotalLocset = 0;
-static int xmlXPathDebugObjTotalUsers = 0;
-static int xmlXPathDebugObjTotalXSLTTree = 0;
-static int xmlXPathDebugObjTotalAll = 0;
-
-static int xmlXPathDebugObjMaxUndefined = 0;
-static int xmlXPathDebugObjMaxNodeset = 0;
-static int xmlXPathDebugObjMaxBool = 0;
-static int xmlXPathDebugObjMaxNumber = 0;
-static int xmlXPathDebugObjMaxString = 0;
-static int xmlXPathDebugObjMaxPoint = 0;
-static int xmlXPathDebugObjMaxRange = 0;
-static int xmlXPathDebugObjMaxLocset = 0;
-static int xmlXPathDebugObjMaxUsers = 0;
-static int xmlXPathDebugObjMaxXSLTTree = 0;
-static int xmlXPathDebugObjMaxAll = 0;
-
-static void
-xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
-{
-    if (ctxt != NULL) {
-       if (ctxt->cache != NULL) {
-           xmlXPathContextCachePtr cache =
-               (xmlXPathContextCachePtr) ctxt->cache;
-
-           cache->dbgCachedAll = 0;
-           cache->dbgCachedNodeset = 0;
-           cache->dbgCachedString = 0;
-           cache->dbgCachedBool = 0;
-           cache->dbgCachedNumber = 0;
-           cache->dbgCachedPoint = 0;
-           cache->dbgCachedRange = 0;
-           cache->dbgCachedLocset = 0;
-           cache->dbgCachedUsers = 0;
-           cache->dbgCachedXSLTTree = 0;
-           cache->dbgCachedUndefined = 0;
-
-           cache->dbgReusedAll = 0;
-           cache->dbgReusedNodeset = 0;
-           cache->dbgReusedString = 0;
-           cache->dbgReusedBool = 0;
-           cache->dbgReusedNumber = 0;
-           cache->dbgReusedPoint = 0;
-           cache->dbgReusedRange = 0;
-           cache->dbgReusedLocset = 0;
-           cache->dbgReusedUsers = 0;
-           cache->dbgReusedXSLTTree = 0;
-           cache->dbgReusedUndefined = 0;
-       }
-    }
-
-    xmlXPathDebugObjCounterUndefined = 0;
-    xmlXPathDebugObjCounterNodeset = 0;
-    xmlXPathDebugObjCounterBool = 0;
-    xmlXPathDebugObjCounterNumber = 0;
-    xmlXPathDebugObjCounterString = 0;
-    xmlXPathDebugObjCounterPoint = 0;
-    xmlXPathDebugObjCounterRange = 0;
-    xmlXPathDebugObjCounterLocset = 0;
-    xmlXPathDebugObjCounterUsers = 0;
-    xmlXPathDebugObjCounterXSLTTree = 0;
-    xmlXPathDebugObjCounterAll = 0;
-
-    xmlXPathDebugObjTotalUndefined = 0;
-    xmlXPathDebugObjTotalNodeset = 0;
-    xmlXPathDebugObjTotalBool = 0;
-    xmlXPathDebugObjTotalNumber = 0;
-    xmlXPathDebugObjTotalString = 0;
-    xmlXPathDebugObjTotalPoint = 0;
-    xmlXPathDebugObjTotalRange = 0;
-    xmlXPathDebugObjTotalLocset = 0;
-    xmlXPathDebugObjTotalUsers = 0;
-    xmlXPathDebugObjTotalXSLTTree = 0;
-    xmlXPathDebugObjTotalAll = 0;
-
-    xmlXPathDebugObjMaxUndefined = 0;
-    xmlXPathDebugObjMaxNodeset = 0;
-    xmlXPathDebugObjMaxBool = 0;
-    xmlXPathDebugObjMaxNumber = 0;
-    xmlXPathDebugObjMaxString = 0;
-    xmlXPathDebugObjMaxPoint = 0;
-    xmlXPathDebugObjMaxRange = 0;
-    xmlXPathDebugObjMaxLocset = 0;
-    xmlXPathDebugObjMaxUsers = 0;
-    xmlXPathDebugObjMaxXSLTTree = 0;
-    xmlXPathDebugObjMaxAll = 0;
-
-}
-
-static void
-xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
-                             xmlXPathObjectType objType)
-{
-    int isCached = 0;
-
-    if (ctxt != NULL) {
-       if (ctxt->cache != NULL) {
-           xmlXPathContextCachePtr cache =
-               (xmlXPathContextCachePtr) ctxt->cache;
-
-           isCached = 1;
-
-           cache->dbgReusedAll++;
-           switch (objType) {
-               case XPATH_UNDEFINED:
-                   cache->dbgReusedUndefined++;
-                   break;
-               case XPATH_NODESET:
-                   cache->dbgReusedNodeset++;
-                   break;
-               case XPATH_BOOLEAN:
-                   cache->dbgReusedBool++;
-                   break;
-               case XPATH_NUMBER:
-                   cache->dbgReusedNumber++;
-                   break;
-               case XPATH_STRING:
-                   cache->dbgReusedString++;
-                   break;
-#ifdef LIBXML_XPTR_LOCS_ENABLED
-               case XPATH_POINT:
-                   cache->dbgReusedPoint++;
-                   break;
-               case XPATH_RANGE:
-                   cache->dbgReusedRange++;
-                   break;
-               case XPATH_LOCATIONSET:
-                   cache->dbgReusedLocset++;
-                   break;
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
-               case XPATH_USERS:
-                   cache->dbgReusedUsers++;
-                   break;
-               case XPATH_XSLT_TREE:
-                   cache->dbgReusedXSLTTree++;
-                   break;
-               default:
-                   break;
-           }
-       }
-    }
-
-    switch (objType) {
-       case XPATH_UNDEFINED:
-           if (! isCached)
-               xmlXPathDebugObjTotalUndefined++;
-           xmlXPathDebugObjCounterUndefined++;
-           if (xmlXPathDebugObjCounterUndefined >
-               xmlXPathDebugObjMaxUndefined)
-               xmlXPathDebugObjMaxUndefined =
-                   xmlXPathDebugObjCounterUndefined;
-           break;
-       case XPATH_NODESET:
-           if (! isCached)
-               xmlXPathDebugObjTotalNodeset++;
-           xmlXPathDebugObjCounterNodeset++;
-           if (xmlXPathDebugObjCounterNodeset >
-               xmlXPathDebugObjMaxNodeset)
-               xmlXPathDebugObjMaxNodeset =
-                   xmlXPathDebugObjCounterNodeset;
-           break;
-       case XPATH_BOOLEAN:
-           if (! isCached)
-               xmlXPathDebugObjTotalBool++;
-           xmlXPathDebugObjCounterBool++;
-           if (xmlXPathDebugObjCounterBool >
-               xmlXPathDebugObjMaxBool)
-               xmlXPathDebugObjMaxBool =
-                   xmlXPathDebugObjCounterBool;
-           break;
-       case XPATH_NUMBER:
-           if (! isCached)
-               xmlXPathDebugObjTotalNumber++;
-           xmlXPathDebugObjCounterNumber++;
-           if (xmlXPathDebugObjCounterNumber >
-               xmlXPathDebugObjMaxNumber)
-               xmlXPathDebugObjMaxNumber =
-                   xmlXPathDebugObjCounterNumber;
-           break;
-       case XPATH_STRING:
-           if (! isCached)
-               xmlXPathDebugObjTotalString++;
-           xmlXPathDebugObjCounterString++;
-           if (xmlXPathDebugObjCounterString >
-               xmlXPathDebugObjMaxString)
-               xmlXPathDebugObjMaxString =
-                   xmlXPathDebugObjCounterString;
-           break;
-#ifdef LIBXML_XPTR_LOCS_ENABLED
-       case XPATH_POINT:
-           if (! isCached)
-               xmlXPathDebugObjTotalPoint++;
-           xmlXPathDebugObjCounterPoint++;
-           if (xmlXPathDebugObjCounterPoint >
-               xmlXPathDebugObjMaxPoint)
-               xmlXPathDebugObjMaxPoint =
-                   xmlXPathDebugObjCounterPoint;
-           break;
-       case XPATH_RANGE:
-           if (! isCached)
-               xmlXPathDebugObjTotalRange++;
-           xmlXPathDebugObjCounterRange++;
-           if (xmlXPathDebugObjCounterRange >
-               xmlXPathDebugObjMaxRange)
-               xmlXPathDebugObjMaxRange =
-                   xmlXPathDebugObjCounterRange;
-           break;
-       case XPATH_LOCATIONSET:
-           if (! isCached)
-               xmlXPathDebugObjTotalLocset++;
-           xmlXPathDebugObjCounterLocset++;
-           if (xmlXPathDebugObjCounterLocset >
-               xmlXPathDebugObjMaxLocset)
-               xmlXPathDebugObjMaxLocset =
-                   xmlXPathDebugObjCounterLocset;
-           break;
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
-       case XPATH_USERS:
-           if (! isCached)
-               xmlXPathDebugObjTotalUsers++;
-           xmlXPathDebugObjCounterUsers++;
-           if (xmlXPathDebugObjCounterUsers >
-               xmlXPathDebugObjMaxUsers)
-               xmlXPathDebugObjMaxUsers =
-                   xmlXPathDebugObjCounterUsers;
-           break;
-       case XPATH_XSLT_TREE:
-           if (! isCached)
-               xmlXPathDebugObjTotalXSLTTree++;
-           xmlXPathDebugObjCounterXSLTTree++;
-           if (xmlXPathDebugObjCounterXSLTTree >
-               xmlXPathDebugObjMaxXSLTTree)
-               xmlXPathDebugObjMaxXSLTTree =
-                   xmlXPathDebugObjCounterXSLTTree;
-           break;
-       default:
-           break;
-    }
-    if (! isCached)
-       xmlXPathDebugObjTotalAll++;
-    xmlXPathDebugObjCounterAll++;
-    if (xmlXPathDebugObjCounterAll >
-       xmlXPathDebugObjMaxAll)
-       xmlXPathDebugObjMaxAll =
-           xmlXPathDebugObjCounterAll;
-}
-
-static void
-xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
-                             xmlXPathObjectType objType)
-{
-    int isCached = 0;
-
-    if (ctxt != NULL) {
-       if (ctxt->cache != NULL) {
-           xmlXPathContextCachePtr cache =
-               (xmlXPathContextCachePtr) ctxt->cache;
-
-           isCached = 1;
-
-           cache->dbgCachedAll++;
-           switch (objType) {
-               case XPATH_UNDEFINED:
-                   cache->dbgCachedUndefined++;
-                   break;
-               case XPATH_NODESET:
-                   cache->dbgCachedNodeset++;
-                   break;
-               case XPATH_BOOLEAN:
-                   cache->dbgCachedBool++;
-                   break;
-               case XPATH_NUMBER:
-                   cache->dbgCachedNumber++;
-                   break;
-               case XPATH_STRING:
-                   cache->dbgCachedString++;
-                   break;
-#ifdef LIBXML_XPTR_LOCS_ENABLED
-               case XPATH_POINT:
-                   cache->dbgCachedPoint++;
-                   break;
-               case XPATH_RANGE:
-                   cache->dbgCachedRange++;
-                   break;
-               case XPATH_LOCATIONSET:
-                   cache->dbgCachedLocset++;
-                   break;
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
-               case XPATH_USERS:
-                   cache->dbgCachedUsers++;
-                   break;
-               case XPATH_XSLT_TREE:
-                   cache->dbgCachedXSLTTree++;
-                   break;
-               default:
-                   break;
-           }
-
-       }
-    }
-    switch (objType) {
-       case XPATH_UNDEFINED:
-           xmlXPathDebugObjCounterUndefined--;
-           break;
-       case XPATH_NODESET:
-           xmlXPathDebugObjCounterNodeset--;
-           break;
-       case XPATH_BOOLEAN:
-           xmlXPathDebugObjCounterBool--;
-           break;
-       case XPATH_NUMBER:
-           xmlXPathDebugObjCounterNumber--;
-           break;
-       case XPATH_STRING:
-           xmlXPathDebugObjCounterString--;
-           break;
-#ifdef LIBXML_XPTR_LOCS_ENABLED
-       case XPATH_POINT:
-           xmlXPathDebugObjCounterPoint--;
-           break;
-       case XPATH_RANGE:
-           xmlXPathDebugObjCounterRange--;
-           break;
-       case XPATH_LOCATIONSET:
-           xmlXPathDebugObjCounterLocset--;
-           break;
-#endif /* LIBXML_XPTR_LOCS_ENABLED */
-       case XPATH_USERS:
-           xmlXPathDebugObjCounterUsers--;
-           break;
-       case XPATH_XSLT_TREE:
-           xmlXPathDebugObjCounterXSLTTree--;
-           break;
-       default:
-           break;
-    }
-    xmlXPathDebugObjCounterAll--;
-}
-
-static void
-xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
-{
-    int reqAll, reqNodeset, reqString, reqBool, reqNumber,
-       reqXSLTTree, reqUndefined;
-    int caAll = 0, caNodeset = 0, caString = 0, caBool = 0,
-       caNumber = 0, caXSLTTree = 0, caUndefined = 0;
-    int reAll = 0, reNodeset = 0, reString = 0, reBool = 0,
-       reNumber = 0, reXSLTTree = 0, reUndefined = 0;
-    int leftObjs = xmlXPathDebugObjCounterAll;
-
-    reqAll = xmlXPathDebugObjTotalAll;
-    reqNodeset = xmlXPathDebugObjTotalNodeset;
-    reqString = xmlXPathDebugObjTotalString;
-    reqBool = xmlXPathDebugObjTotalBool;
-    reqNumber = xmlXPathDebugObjTotalNumber;
-    reqXSLTTree = xmlXPathDebugObjTotalXSLTTree;
-    reqUndefined = xmlXPathDebugObjTotalUndefined;
-
-    printf("# XPath object usage:\n");
-
-    if (ctxt != NULL) {
-       if (ctxt->cache != NULL) {
-           xmlXPathContextCachePtr cache =
-               (xmlXPathContextCachePtr) ctxt->cache;
-
-           reAll = cache->dbgReusedAll;
-           reqAll += reAll;
-           reNodeset = cache->dbgReusedNodeset;
-           reqNodeset += reNodeset;
-           reString = cache->dbgReusedString;
-           reqString += reString;
-           reBool = cache->dbgReusedBool;
-           reqBool += reBool;
-           reNumber = cache->dbgReusedNumber;
-           reqNumber += reNumber;
-           reXSLTTree = cache->dbgReusedXSLTTree;
-           reqXSLTTree += reXSLTTree;
-           reUndefined = cache->dbgReusedUndefined;
-           reqUndefined += reUndefined;
-
-           caAll = cache->dbgCachedAll;
-           caBool = cache->dbgCachedBool;
-           caNodeset = cache->dbgCachedNodeset;
-           caString = cache->dbgCachedString;
-           caNumber = cache->dbgCachedNumber;
-           caXSLTTree = cache->dbgCachedXSLTTree;
-           caUndefined = cache->dbgCachedUndefined;
-
-           if (cache->nodesetObjs)
-               leftObjs -= cache->nodesetObjs->number;
-           if (cache->stringObjs)
-               leftObjs -= cache->stringObjs->number;
-           if (cache->booleanObjs)
-               leftObjs -= cache->booleanObjs->number;
-           if (cache->numberObjs)
-               leftObjs -= cache->numberObjs->number;
-           if (cache->miscObjs)
-               leftObjs -= cache->miscObjs->number;
-       }
-    }
-
-    printf("# all\n");
-    printf("#   total  : %d\n", reqAll);
-    printf("#   left  : %d\n", leftObjs);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalAll);
-    printf("#   reused : %d\n", reAll);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxAll);
-
-    printf("# node-sets\n");
-    printf("#   total  : %d\n", reqNodeset);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalNodeset);
-    printf("#   reused : %d\n", reNodeset);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxNodeset);
-
-    printf("# strings\n");
-    printf("#   total  : %d\n", reqString);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalString);
-    printf("#   reused : %d\n", reString);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxString);
-
-    printf("# booleans\n");
-    printf("#   total  : %d\n", reqBool);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalBool);
-    printf("#   reused : %d\n", reBool);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxBool);
-
-    printf("# numbers\n");
-    printf("#   total  : %d\n", reqNumber);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalNumber);
-    printf("#   reused : %d\n", reNumber);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxNumber);
-
-    printf("# XSLT result tree fragments\n");
-    printf("#   total  : %d\n", reqXSLTTree);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalXSLTTree);
-    printf("#   reused : %d\n", reXSLTTree);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxXSLTTree);
-
-    printf("# undefined\n");
-    printf("#   total  : %d\n", reqUndefined);
-    printf("#   created: %d\n", xmlXPathDebugObjTotalUndefined);
-    printf("#   reused : %d\n", reUndefined);
-    printf("#   max    : %d\n", xmlXPathDebugObjMaxUndefined);
-
-}
-
-#endif /* XP_DEBUG_OBJ_USAGE */
-
 #endif /* LIBXML_DEBUG_ENABLED */
 
 /************************************************************************
@@ -2204,7 +1699,7 @@ xmlXPathNewCache(void)
         xmlXPathErrMemory(NULL, "creating object cache\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathContextCache));
+    memset(ret, 0 , sizeof(xmlXPathContextCache));
     ret->maxNodeset = 100;
     ret->maxString = 100;
     ret->maxBoolean = 100;
@@ -2234,9 +1729,6 @@ xmlXPathCacheFreeObjectList(xmlPointerListPtr list)
            xmlFree(obj->nodesetval);
        }
        xmlFree(obj);
-#ifdef XP_DEBUG_OBJ_USAGE
-       xmlXPathDebugObjCounterAll--;
-#endif
     }
     xmlPointerListFree(list);
 }
@@ -2323,6 +1815,8 @@ xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
  * Wrap the Nodeset @val in a new xmlXPathObjectPtr
  *
  * Returns the created or reused object.
+ *
+ * In case of error the node set is destroyed and NULL is returned.
  */
 static xmlXPathObjectPtr
 xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
@@ -2340,9 +1834,6 @@ xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
                cache->miscObjs->items[--cache->miscObjs->number];
            ret->type = XPATH_NODESET;
            ret->nodesetval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
-#endif
            return(ret);
        }
     }
@@ -2377,9 +1868,6 @@ xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
                cache->stringObjs->items[--cache->stringObjs->number];
            ret->type = XPATH_STRING;
            ret->stringval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
            return(ret);
        } else if ((cache->miscObjs != NULL) &&
            (cache->miscObjs->number != 0))
@@ -2393,9 +1881,6 @@ xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
 
            ret->type = XPATH_STRING;
            ret->stringval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
            return(ret);
        }
     }
@@ -2441,32 +1926,29 @@ xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
                    ret->nodesetval->nodeNr = 1;
                }
            }
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
-#endif
            return(ret);
        } else if ((cache->miscObjs != NULL) &&
            (cache->miscObjs->number != 0))
        {
            xmlXPathObjectPtr ret;
+            xmlNodeSetPtr set;
            /*
            * Fallback to misc-cache.
            */
 
+           set = xmlXPathNodeSetCreate(val);
+           if (set == NULL) {
+               ctxt->lastError.domain = XML_FROM_XPATH;
+               ctxt->lastError.code = XML_ERR_NO_MEMORY;
+               return(NULL);
+           }
+
            ret = (xmlXPathObjectPtr)
                cache->miscObjs->items[--cache->miscObjs->number];
 
            ret->type = XPATH_NODESET;
            ret->boolval = 0;
-           ret->nodesetval = xmlXPathNodeSetCreate(val);
-           if (ret->nodesetval == NULL) {
-               ctxt->lastError.domain = XML_FROM_XPATH;
-               ctxt->lastError.code = XML_ERR_NO_MEMORY;
-               return(NULL);
-           }
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
-#endif
+           ret->nodesetval = set;
            return(ret);
        }
     }
@@ -2474,17 +1956,17 @@ xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
 }
 
 /**
- * xmlXPathCacheNewCString:
+ * xmlXPathCacheNewString:
  * @ctxt: the XPath context
- * @val:  the char * value
+ * @val:  the xmlChar * value
  *
- * This is the cached version of xmlXPathNewCString().
+ * This is the cached version of xmlXPathNewString().
  * Acquire an xmlXPathObjectPtr of type string and of value @val
  *
  * Returns the created or reused object.
  */
 static xmlXPathObjectPtr
-xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
+xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
 {
     if ((ctxt != NULL) && (ctxt->cache)) {
        xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
@@ -2493,87 +1975,60 @@ xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
            (cache->stringObjs->number != 0))
        {
            xmlXPathObjectPtr ret;
+            xmlChar *copy;
+
+            if (val == NULL)
+                val = BAD_CAST "";
+            copy = xmlStrdup(val);
+            if (copy == NULL) {
+                xmlXPathErrMemory(ctxt, NULL);
+                return(NULL);
+            }
 
            ret = (xmlXPathObjectPtr)
                cache->stringObjs->items[--cache->stringObjs->number];
-
            ret->type = XPATH_STRING;
-           ret->stringval = xmlStrdup(BAD_CAST val);
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
+            ret->stringval = copy;
            return(ret);
        } else if ((cache->miscObjs != NULL) &&
            (cache->miscObjs->number != 0))
        {
            xmlXPathObjectPtr ret;
+            xmlChar *copy;
+
+            if (val == NULL)
+                val = BAD_CAST "";
+            copy = xmlStrdup(val);
+            if (copy == NULL) {
+                xmlXPathErrMemory(ctxt, NULL);
+                return(NULL);
+            }
 
            ret = (xmlXPathObjectPtr)
                cache->miscObjs->items[--cache->miscObjs->number];
 
            ret->type = XPATH_STRING;
-           ret->stringval = xmlStrdup(BAD_CAST val);
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
+            ret->stringval = copy;
            return(ret);
        }
     }
-    return(xmlXPathNewCString(val));
+    return(xmlXPathNewString(val));
 }
 
 /**
- * xmlXPathCacheNewString:
+ * xmlXPathCacheNewCString:
  * @ctxt: the XPath context
- * @val:  the xmlChar * value
+ * @val:  the char * value
  *
- * This is the cached version of xmlXPathNewString().
+ * This is the cached version of xmlXPathNewCString().
  * Acquire an xmlXPathObjectPtr of type string and of value @val
  *
  * Returns the created or reused object.
  */
 static xmlXPathObjectPtr
-xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
+xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
 {
-    if ((ctxt != NULL) && (ctxt->cache)) {
-       xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
-
-       if ((cache->stringObjs != NULL) &&
-           (cache->stringObjs->number != 0))
-       {
-           xmlXPathObjectPtr ret;
-
-           ret = (xmlXPathObjectPtr)
-               cache->stringObjs->items[--cache->stringObjs->number];
-           ret->type = XPATH_STRING;
-           if (val != NULL)
-               ret->stringval = xmlStrdup(val);
-           else
-               ret->stringval = xmlStrdup((const xmlChar *)"");
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
-           return(ret);
-       } else if ((cache->miscObjs != NULL) &&
-           (cache->miscObjs->number != 0))
-       {
-           xmlXPathObjectPtr ret;
-
-           ret = (xmlXPathObjectPtr)
-               cache->miscObjs->items[--cache->miscObjs->number];
-
-           ret->type = XPATH_STRING;
-           if (val != NULL)
-               ret->stringval = xmlStrdup(val);
-           else
-               ret->stringval = xmlStrdup((const xmlChar *)"");
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
-#endif
-           return(ret);
-       }
-    }
-    return(xmlXPathNewString(val));
+    return xmlXPathCacheNewString(ctxt, BAD_CAST val);
 }
 
 /**
@@ -2601,9 +2056,6 @@ xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
                cache->booleanObjs->items[--cache->booleanObjs->number];
            ret->type = XPATH_BOOLEAN;
            ret->boolval = (val != 0);
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
-#endif
            return(ret);
        } else if ((cache->miscObjs != NULL) &&
            (cache->miscObjs->number != 0))
@@ -2615,9 +2067,6 @@ xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
 
            ret->type = XPATH_BOOLEAN;
            ret->boolval = (val != 0);
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
-#endif
            return(ret);
        }
     }
@@ -2649,9 +2098,6 @@ xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
                cache->numberObjs->items[--cache->numberObjs->number];
            ret->type = XPATH_NUMBER;
            ret->floatval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
-#endif
            return(ret);
        } else if ((cache->miscObjs != NULL) &&
            (cache->miscObjs->number != 0))
@@ -2663,9 +2109,6 @@ xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
 
            ret->type = XPATH_NUMBER;
            ret->floatval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-           xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
-#endif
            return(ret);
        }
     }
@@ -2693,9 +2136,6 @@ xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
 
     switch (val->type) {
     case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext, "STRING: undefined\n");
-#endif
        break;
     case XPATH_NODESET:
     case XPATH_XSLT_TREE:
@@ -2813,42 +2253,6 @@ xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
  ************************************************************************/
 
 /**
- * xmlXPathSetFrame:
- * @ctxt: an XPath parser context
- *
- * Set the callee evaluation frame
- *
- * Returns the previous frame value to be restored once done
- */
-static int
-xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) {
-    int ret;
-
-    if (ctxt == NULL)
-        return(0);
-    ret = ctxt->valueFrame;
-    ctxt->valueFrame = ctxt->valueNr;
-    return(ret);
-}
-
-/**
- * xmlXPathPopFrame:
- * @ctxt: an XPath parser context
- * @frame: the previous frame value
- *
- * Remove the callee evaluation frame
- */
-static void
-xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) {
-    if (ctxt == NULL)
-        return;
-    if (ctxt->valueNr < ctxt->valueFrame) {
-        xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
-    }
-    ctxt->valueFrame = frame;
-}
-
-/**
  * valuePop:
  * @ctxt: an XPath evaluation context
  *
@@ -2864,11 +2268,6 @@ valuePop(xmlXPathParserContextPtr ctxt)
     if ((ctxt == NULL) || (ctxt->valueNr <= 0))
         return (NULL);
 
-    if (ctxt->valueNr <= ctxt->valueFrame) {
-        xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
-        return (NULL);
-    }
-
     ctxt->valueNr--;
     if (ctxt->valueNr > 0)
         ctxt->value = ctxt->valueTab[ctxt->valueNr - 1];
@@ -2887,6 +2286,8 @@ valuePop(xmlXPathParserContextPtr ctxt)
  * a memory error is recorded in the parser context.
  *
  * Returns the number of items on the value stack, or -1 in case of error.
+ *
+ * The object is destroyed in case of error.
  */
 int
 valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
@@ -2905,6 +2306,7 @@ valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
 
         if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) {
             xmlXPathPErrMemory(ctxt, "XPath stack depth limit reached\n");
+            xmlXPathFreeObject(value);
             return (-1);
         }
         tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
@@ -2912,6 +2314,7 @@ valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
                                              sizeof(ctxt->valueTab[0]));
         if (tmp == NULL) {
             xmlXPathPErrMemory(ctxt, "pushing value\n");
+            xmlXPathFreeObject(value);
             return (-1);
         }
         ctxt->valueMax *= 2;
@@ -3097,7 +2500,7 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
 #define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
 
 #define COPY_BUF(l,b,i,v)                                              \
-    if (l == 1) b[i++] = (xmlChar) v;                                  \
+    if (l == 1) b[i++] = v;                                            \
     else i += xmlCopyChar(l,&b[i],v)
 
 #define NEXTL(l)  ctxt->cur += l
@@ -3304,7 +2707,7 @@ xmlXPathOrderDocElems(xmlDocPtr doc) {
            }
        } while (cur != NULL);
     }
-    return((long) count);
+    return(count);
 }
 
 /**
@@ -3580,7 +2983,7 @@ xmlXPathNodeSetCreate(xmlNodePtr val) {
         xmlXPathErrMemory(NULL, "creating nodeset\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlNodeSet));
+    memset(ret, 0 , sizeof(xmlNodeSet));
     if (val != NULL) {
         ret->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
                                             sizeof(xmlNodePtr));
@@ -3590,14 +2993,17 @@ xmlXPathNodeSetCreate(xmlNodePtr val) {
            return(NULL);
        }
        memset(ret->nodeTab, 0 ,
-              XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+              XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
         ret->nodeMax = XML_NODESET_DEFAULT;
        if (val->type == XML_NAMESPACE_DECL) {
            xmlNsPtr ns = (xmlNsPtr) val;
+            xmlNodePtr nsNode = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
 
-            /* TODO: Check memory error. */
-           ret->nodeTab[ret->nodeNr++] =
-               xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
+            if (nsNode == NULL) {
+                xmlXPathFreeNodeSet(ret);
+                return(NULL);
+            }
+           ret->nodeTab[ret->nodeNr++] = nsNode;
        } else
            ret->nodeTab[ret->nodeNr++] = val;
     }
@@ -3654,7 +3060,7 @@ xmlXPathNodeSetContains (xmlNodeSetPtr cur, xmlNodePtr val) {
 int
 xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
     int i;
-
+    xmlNodePtr nsNode;
 
     if ((cur == NULL) || (ns == NULL) || (node == NULL) ||
         (ns->type != XML_NAMESPACE_DECL) ||
@@ -3684,7 +3090,7 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
            return(-1);
        }
        memset(cur->nodeTab, 0 ,
-              XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+              XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
         cur->nodeMax = XML_NODESET_DEFAULT;
     } else if (cur->nodeNr == cur->nodeMax) {
         xmlNodePtr *temp;
@@ -3702,8 +3108,10 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
         cur->nodeMax *= 2;
        cur->nodeTab = temp;
     }
-    /* TODO: Check memory error. */
-    cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs(node, ns);
+    nsNode = xmlXPathNodeSetDupNs(node, ns);
+    if(nsNode == NULL)
+        return(-1);
+    cur->nodeTab[cur->nodeNr++] = nsNode;
     return(0);
 }
 
@@ -3740,7 +3148,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
            return(-1);
        }
        memset(cur->nodeTab, 0 ,
-              XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+              XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
         cur->nodeMax = XML_NODESET_DEFAULT;
     } else if (cur->nodeNr == cur->nodeMax) {
         xmlNodePtr *temp;
@@ -3760,10 +3168,11 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
     }
     if (val->type == XML_NAMESPACE_DECL) {
        xmlNsPtr ns = (xmlNsPtr) val;
+        xmlNodePtr nsNode = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
 
-        /* TODO: Check memory error. */
-       cur->nodeTab[cur->nodeNr++] =
-           xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
+        if (nsNode == NULL)
+            return(-1);
+       cur->nodeTab[cur->nodeNr++] = nsNode;
     } else
        cur->nodeTab[cur->nodeNr++] = val;
     return(0);
@@ -3795,7 +3204,7 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
            return(-1);
        }
        memset(cur->nodeTab, 0 ,
-              XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+              XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
         cur->nodeMax = XML_NODESET_DEFAULT;
     } else if (cur->nodeNr == cur->nodeMax) {
         xmlNodePtr *temp;
@@ -3815,10 +3224,11 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
     }
     if (val->type == XML_NAMESPACE_DECL) {
        xmlNsPtr ns = (xmlNsPtr) val;
+        xmlNodePtr nsNode = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
 
-        /* TODO: Check memory error. */
-       cur->nodeTab[cur->nodeNr++] =
-           xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
+        if (nsNode == NULL)
+            return(-1);
+       cur->nodeTab[cur->nodeNr++] = nsNode;
     } else
        cur->nodeTab[cur->nodeNr++] = val;
     return(0);
@@ -3833,6 +3243,8 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
  * if @val1 is NULL, a new set is created and copied from @val2
  *
  * Returns @val1 once extended or NULL in case of error.
+ *
+ * Frees @val1 in case of error.
  */
 xmlNodeSetPtr
 xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
@@ -3842,35 +3254,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
-       *  those nasty namespace nodes need to be added with
-       *  xmlXPathNodeSetDupNs() to the set; thus a pure
-       *  memcpy is not possible.
-       *  If there was a flag on the nodesetval, indicating that
-       *  some temporary nodes are in, that would be helpful.
-       */
-       /*
-       * Optimization: Create an equally sized node-set
-       * and memcpy the content.
-       */
-       val1 = xmlXPathNodeSetCreateSize(val2->nodeNr);
-       if (val1 == NULL)
-           return(NULL);
-       if (val2->nodeNr != 0) {
-           if (val2->nodeNr == 1)
-               *(val1->nodeTab) = *(val2->nodeTab);
-           else {
-               memcpy(val1->nodeTab, val2->nodeTab,
-                   val2->nodeNr * sizeof(xmlNodePtr));
-           }
-           val1->nodeNr = val2->nodeNr;
-       }
-       return(val1);
-#endif
+        if (val1 == NULL)
+            return (NULL);
     }
 
     /* @@ with_ns to check whether namespace nodes should be looked at @@ */
@@ -3909,38 +3294,43 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
                                                    sizeof(xmlNodePtr));
            if (val1->nodeTab == NULL) {
                xmlXPathErrMemory(NULL, "merging nodeset\n");
-               return(NULL);
+               goto error;
            }
            memset(val1->nodeTab, 0 ,
-                  XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+                  XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
            val1->nodeMax = XML_NODESET_DEFAULT;
        } else if (val1->nodeNr == val1->nodeMax) {
            xmlNodePtr *temp;
 
             if (val1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
                 xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
-                return(NULL);
+                goto error;
             }
            temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * 2 *
                                             sizeof(xmlNodePtr));
            if (temp == NULL) {
                xmlXPathErrMemory(NULL, "merging nodeset\n");
-               return(NULL);
+               goto error;
            }
            val1->nodeTab = temp;
            val1->nodeMax *= 2;
        }
        if (n2->type == XML_NAMESPACE_DECL) {
            xmlNsPtr ns = (xmlNsPtr) n2;
+            xmlNodePtr nsNode = xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
 
-            /* TODO: Check memory error. */
-           val1->nodeTab[val1->nodeNr++] =
-               xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
+            if (nsNode == NULL)
+                goto error;
+           val1->nodeTab[val1->nodeNr++] = nsNode;
        } else
            val1->nodeTab[val1->nodeNr++] = n2;
     }
 
     return(val1);
+
+error:
+    xmlXPathFreeNodeSet(val1);
+    return(NULL);
 }
 
 
@@ -3953,6 +3343,8 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
  * Checks for duplicate nodes. Clears set2.
  *
  * Returns @set1 once extended or NULL in case of error.
+ *
+ * Frees @set1 in case of error.
  */
 static xmlNodeSetPtr
 xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
@@ -3981,7 +3373,6 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
                        /*
                        * Free the namespace node.
                        */
-                       set2->nodeTab[i] = NULL;
                        xmlXPathNodeSetFreeNs((xmlNsPtr) n2);
                        goto skip_node;
                    }
@@ -3995,34 +3386,39 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
                    XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
                if (set1->nodeTab == NULL) {
                    xmlXPathErrMemory(NULL, "merging nodeset\n");
-                   return(NULL);
+                   goto error;
                }
                memset(set1->nodeTab, 0,
-                   XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+                   XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
                set1->nodeMax = XML_NODESET_DEFAULT;
            } else if (set1->nodeNr >= set1->nodeMax) {
                xmlNodePtr *temp;
 
                 if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
                     xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
-                    return(NULL);
+                    goto error;
                 }
                temp = (xmlNodePtr *) xmlRealloc(
                    set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));
                if (temp == NULL) {
                    xmlXPathErrMemory(NULL, "merging nodeset\n");
-                   return(NULL);
+                   goto error;
                }
                set1->nodeTab = temp;
                set1->nodeMax *= 2;
            }
            set1->nodeTab[set1->nodeNr++] = n2;
 skip_node:
-           {}
+            set2->nodeTab[i] = NULL;
        }
     }
     set2->nodeNr = 0;
     return(set1);
+
+error:
+    xmlXPathFreeNodeSet(set1);
+    xmlXPathNodeSetClear(set2, 1);
+    return(NULL);
 }
 
 /**
@@ -4034,6 +3430,8 @@ skip_node:
  * Doesn't check for duplicate nodes. Clears set2.
  *
  * Returns @set1 once extended or NULL in case of error.
+ *
+ * Frees @set1 in case of error.
  */
 static xmlNodeSetPtr
 xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
@@ -4049,32 +3447,38 @@ xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
                    XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
                if (set1->nodeTab == NULL) {
                    xmlXPathErrMemory(NULL, "merging nodeset\n");
-                   return(NULL);
+                   goto error;
                }
                memset(set1->nodeTab, 0,
-                   XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
+                   XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
                set1->nodeMax = XML_NODESET_DEFAULT;
            } else if (set1->nodeNr >= set1->nodeMax) {
                xmlNodePtr *temp;
 
                 if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
                     xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
-                    return(NULL);
+                    goto error;
                 }
                temp = (xmlNodePtr *) xmlRealloc(
                    set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));
                if (temp == NULL) {
                    xmlXPathErrMemory(NULL, "merging nodeset\n");
-                   return(NULL);
+                   goto error;
                }
                set1->nodeTab = temp;
                set1->nodeMax *= 2;
            }
            set1->nodeTab[set1->nodeNr++] = n2;
+            set2->nodeTab[i] = NULL;
        }
     }
     set2->nodeNr = 0;
     return(set1);
+
+error:
+    xmlXPathFreeNodeSet(set1);
+    xmlXPathNodeSetClear(set2, 1);
+    return(NULL);
 }
 
 /**
@@ -4098,11 +3502,6 @@ xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val) {
         if (cur->nodeTab[i] == val) break;
 
     if (i >= cur->nodeNr) {    /* not found */
-#ifdef DEBUG
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlXPathNodeSetDel: Node %s wasn't found in NodeList\n",
-               val->name);
-#endif
         return;
     }
     if ((cur->nodeTab[i] != NULL) &&
@@ -4252,47 +3651,6 @@ xmlXPathFreeValueTree(xmlNodeSetPtr obj) {
     xmlFree(obj);
 }
 
-#if defined(DEBUG) || defined(DEBUG_STEP)
-/**
- * xmlGenericErrorContextNodeSet:
- * @output:  a FILE * for the output
- * @obj:  the xmlNodeSetPtr to display
- *
- * Quick display of a NodeSet
- */
-void
-xmlGenericErrorContextNodeSet(FILE *output, xmlNodeSetPtr obj) {
-    int i;
-
-    if (output == NULL) output = xmlGenericErrorContext;
-    if (obj == NULL)  {
-        fprintf(output, "NodeSet == NULL !\n");
-       return;
-    }
-    if (obj->nodeNr == 0) {
-        fprintf(output, "NodeSet is empty\n");
-       return;
-    }
-    if (obj->nodeTab == NULL) {
-       fprintf(output, " nodeTab == NULL !\n");
-       return;
-    }
-    for (i = 0; i < obj->nodeNr; i++) {
-        if (obj->nodeTab[i] == NULL) {
-           fprintf(output, " NULL !\n");
-           return;
-        }
-       if ((obj->nodeTab[i]->type == XML_DOCUMENT_NODE) ||
-           (obj->nodeTab[i]->type == XML_HTML_DOCUMENT_NODE))
-           fprintf(output, " /");
-       else if (obj->nodeTab[i]->name == NULL)
-           fprintf(output, " noname!");
-       else fprintf(output, " %s", obj->nodeTab[i]->name);
-    }
-    fprintf(output, "\n");
-}
-#endif
-
 /**
  * xmlXPathNewNodeSet:
  * @val:  the NodePtr value
@@ -4311,15 +3669,12 @@ xmlXPathNewNodeSet(xmlNodePtr val) {
         xmlXPathErrMemory(NULL, "creating nodeset\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_NODESET;
     ret->boolval = 0;
     /* TODO: Check memory error. */
     ret->nodesetval = xmlXPathNodeSetCreate(val);
     /* @@ with_ns to check whether namespace nodes should be looked at @@ */
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_NODESET);
-#endif
     return(ret);
 }
 
@@ -4341,14 +3696,11 @@ xmlXPathNewValueTree(xmlNodePtr val) {
         xmlXPathErrMemory(NULL, "creating result value tree\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_XSLT_TREE;
     ret->boolval = 1;
     ret->user = (void *) val;
     ret->nodesetval = xmlXPathNodeSetCreate(val);
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_XSLT_TREE);
-#endif
     return(ret);
 }
 
@@ -4392,6 +3744,8 @@ xmlXPathNewNodeSetList(xmlNodeSetPtr val)
  * Wrap the Nodeset @val in a new xmlXPathObjectPtr
  *
  * Returns the newly created object.
+ *
+ * In case of error the node set is destroyed and NULL is returned.
  */
 xmlXPathObjectPtr
 xmlXPathWrapNodeSet(xmlNodeSetPtr val) {
@@ -4400,14 +3754,12 @@ xmlXPathWrapNodeSet(xmlNodeSetPtr val) {
     ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
     if (ret == NULL) {
         xmlXPathErrMemory(NULL, "creating node set object\n");
+        xmlXPathFreeNodeSet(val);
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_NODESET;
     ret->nodesetval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_NODESET);
-#endif
     return(ret);
 }
 
@@ -4421,9 +3773,6 @@ xmlXPathWrapNodeSet(xmlNodeSetPtr val) {
 void
 xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj) {
     if (obj == NULL) return;
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageReleased(NULL, obj->type);
-#endif
     xmlFree(obj);
 }
 
@@ -4532,16 +3881,23 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
        cur = xmlXPathNodeSetItem(nodes, i);
        strval = xmlXPathCastNodeToString(cur);
        if (xmlHashLookup(hash, strval) == NULL) {
-           xmlHashAddEntry(hash, strval, strval);
-            /* TODO: Propagate memory error. */
+           if (xmlHashAddEntry(hash, strval, strval) < 0) {
+                xmlFree(strval);
+                goto error;
+            }
            if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
-               break;
+               goto error;
        } else {
            xmlFree(strval);
        }
     }
     xmlHashFree(hash, xmlHashDefaultDeallocator);
     return(ret);
+
+error:
+    xmlHashFree(hash, xmlHashDefaultDeallocator);
+    xmlXPathFreeNodeSet(ret);
+    return(NULL);
 }
 
 /**
@@ -4854,7 +4210,7 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
        return(-1);
     if (f == NULL)
         return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
-XML_IGNORE_PEDANTIC_WARNINGS
+XML_IGNORE_FPTR_CAST_WARNINGS
     return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
 XML_POP_WARNINGS
 }
@@ -4937,7 +4293,7 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
     if (ctxt->funcHash == NULL)
        return(NULL);
 
-XML_IGNORE_PEDANTIC_WARNINGS
+XML_IGNORE_FPTR_CAST_WARNINGS
     ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
 XML_POP_WARNINGS
     return(ret);
@@ -5118,6 +4474,8 @@ xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
 int
 xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
                           const xmlChar *ns_uri) {
+    xmlChar *copy;
+
     if (ctxt == NULL)
        return(-1);
     if (prefix == NULL)
@@ -5132,8 +4490,17 @@ xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
     if (ns_uri == NULL)
         return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
                                  xmlHashDefaultDeallocator));
-    return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
-                             xmlHashDefaultDeallocator));
+
+    copy = xmlStrdup(ns_uri);
+    if (copy == NULL)
+        return(-1);
+    if (xmlHashUpdateEntry(ctxt->nsHash, prefix, copy,
+                           xmlHashDefaultDeallocator) < 0) {
+        xmlFree(copy);
+        return(-1);
+    }
+
+    return(0);
 }
 
 /**
@@ -5211,12 +4578,9 @@ xmlXPathNewFloat(double val) {
         xmlXPathErrMemory(NULL, "creating float object\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_NUMBER;
     ret->floatval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_NUMBER);
-#endif
     return(ret);
 }
 
@@ -5237,12 +4601,9 @@ xmlXPathNewBoolean(int val) {
         xmlXPathErrMemory(NULL, "creating boolean object\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_BOOLEAN;
     ret->boolval = (val != 0);
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_BOOLEAN);
-#endif
     return(ret);
 }
 
@@ -5263,15 +4624,15 @@ xmlXPathNewString(const xmlChar *val) {
         xmlXPathErrMemory(NULL, "creating string object\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_STRING;
-    if (val != NULL)
-       ret->stringval = xmlStrdup(val);
-    else
-       ret->stringval = xmlStrdup((const xmlChar *)"");
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING);
-#endif
+    if (val == NULL)
+        val = BAD_CAST "";
+    ret->stringval = xmlStrdup(val);
+    if (ret->stringval == NULL) {
+        xmlFree(ret);
+        return(NULL);
+    }
     return(ret);
 }
 
@@ -5282,6 +4643,8 @@ xmlXPathNewString(const xmlChar *val) {
  * Wraps the @val string into an XPath object.
  *
  * Returns the newly created object.
+ *
+ * Frees @val in case of error.
  */
 xmlXPathObjectPtr
 xmlXPathWrapString (xmlChar *val) {
@@ -5290,14 +4653,12 @@ xmlXPathWrapString (xmlChar *val) {
     ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
     if (ret == NULL) {
         xmlXPathErrMemory(NULL, "creating string object\n");
+        xmlFree(val);
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_STRING;
     ret->stringval = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING);
-#endif
     return(ret);
 }
 
@@ -5311,20 +4672,7 @@ xmlXPathWrapString (xmlChar *val) {
  */
 xmlXPathObjectPtr
 xmlXPathNewCString(const char *val) {
-    xmlXPathObjectPtr ret;
-
-    ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
-    if (ret == NULL) {
-        xmlXPathErrMemory(NULL, "creating string object\n");
-       return(NULL);
-    }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
-    ret->type = XPATH_STRING;
-    ret->stringval = xmlStrdup(BAD_CAST val);
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_STRING);
-#endif
-    return(ret);
+    return(xmlXPathNewString(BAD_CAST val));
 }
 
 /**
@@ -5357,12 +4705,9 @@ xmlXPathWrapExternal (void *val) {
         xmlXPathErrMemory(NULL, "creating user object\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_USERS;
     ret->user = val;
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, XPATH_USERS);
-#endif
     return(ret);
 }
 
@@ -5386,10 +4731,7 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
         xmlXPathErrMemory(NULL, "copying object\n");
        return(NULL);
     }
-    memcpy(ret, val , (size_t) sizeof(xmlXPathObject));
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageRequested(NULL, val->type);
-#endif
+    memcpy(ret, val , sizeof(xmlXPathObject));
     switch (val->type) {
        case XPATH_BOOLEAN:
        case XPATH_NUMBER:
@@ -5400,6 +4742,10 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
            break;
        case XPATH_STRING:
            ret->stringval = xmlStrdup(val->stringval);
+            if (ret->stringval == NULL) {
+                xmlFree(ret);
+                return(NULL);
+            }
            break;
        case XPATH_XSLT_TREE:
 #if 0
@@ -5493,9 +4839,6 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
        if (obj->stringval != NULL)
            xmlFree(obj->stringval);
     }
-#ifdef XP_DEBUG_OBJ_USAGE
-    xmlXPathDebugObjUsageReleased(NULL, obj->type);
-#endif
     xmlFree(obj);
 }
 
@@ -5594,11 +4937,6 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
            goto free_obj;
 
 obj_cached:
-
-#ifdef XP_DEBUG_OBJ_USAGE
-       xmlXPathDebugObjUsageReleased(ctxt, obj->type);
-#endif
-
        if (obj->nodesetval != NULL) {
            xmlNodeSetPtr tmpset = obj->nodesetval;
 
@@ -5639,9 +4977,6 @@ free_obj:
        */
        if (obj->nodesetval != NULL)
            xmlXPathFreeNodeSet(obj->nodesetval);
-#ifdef XP_DEBUG_OBJ_USAGE
-       xmlXPathDebugObjUsageReleased(NULL, obj->type);
-#endif
        xmlFree(obj);
     }
     return;
@@ -5758,9 +5093,6 @@ xmlXPathCastToString(xmlXPathObjectPtr val) {
        return(xmlStrdup((const xmlChar *) ""));
     switch (val->type) {
        case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-           xmlGenericError(xmlGenericErrorContext, "String: undefined\n");
-#endif
            ret = xmlStrdup((const xmlChar *) "");
            break;
         case XPATH_NODESET:
@@ -5807,9 +5139,6 @@ xmlXPathConvertString(xmlXPathObjectPtr val) {
 
     switch (val->type) {
     case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext, "STRING: undefined\n");
-#endif
        break;
     case XPATH_NODESET:
     case XPATH_XSLT_TREE:
@@ -5927,9 +5256,6 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
        return(xmlXPathNAN);
     switch (val->type) {
     case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
-#endif
        ret = xmlXPathNAN;
        break;
     case XPATH_NODESET:
@@ -6041,9 +5367,6 @@ xmlXPathCastToBoolean (xmlXPathObjectPtr val) {
        return(0);
     switch (val->type) {
     case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext, "BOOLEAN: undefined\n");
-#endif
        ret = 0;
        break;
     case XPATH_NODESET:
@@ -6118,7 +5441,7 @@ xmlXPathNewContext(xmlDocPtr doc) {
         xmlXPathErrMemory(NULL, "creating context\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathContext));
+    memset(ret, 0 , sizeof(xmlXPathContext));
     ret->doc = doc;
     ret->node = NULL;
 
@@ -6226,7 +5549,7 @@ xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
         xmlXPathErrMemory(ctxt, "creating parser context\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext));
+    memset(ret, 0 , sizeof(xmlXPathParserContext));
     ret->cur = ret->base = str;
     ret->context = ctxt;
 
@@ -6262,7 +5585,7 @@ xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
         xmlXPathErrMemory(ctxt, "creating evaluation context\n");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext));
+    memset(ret, 0 , sizeof(xmlXPathParserContext));
 
     /* Allocate the value stack */
     ret->valueTab = (xmlXPathObjectPtr *)
@@ -6275,7 +5598,6 @@ xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
     ret->valueNr = 0;
     ret->valueMax = 10;
     ret->value = NULL;
-    ret->valueFrame = 0;
 
     ret->context = ctxt;
     ret->comp = comp;
@@ -6360,16 +5682,14 @@ xmlXPathNodeValHash(xmlNodePtr node) {
                return(0);
            if (string[0] == 0)
                return(0);
-           return(((unsigned int) string[0]) +
-                  (((unsigned int) string[1]) << 8));
+           return(string[0] + (string[1] << 8));
        case XML_NAMESPACE_DECL:
            string = ((xmlNsPtr)node)->href;
            if (string == NULL)
                return(0);
            if (string[0] == 0)
                return(0);
-           return(((unsigned int) string[0]) +
-                  (((unsigned int) string[1]) << 8));
+           return(string[0] + (string[1] << 8));
        case XML_ATTRIBUTE_NODE:
            tmp = ((xmlAttrPtr) node)->children;
            break;
@@ -6391,24 +5711,24 @@ xmlXPathNodeValHash(xmlNodePtr node) {
        }
        if ((string != NULL) && (string[0] != 0)) {
            if (len == 1) {
-               return(ret + (((unsigned int) string[0]) << 8));
+               return(ret + (string[0] << 8));
            }
            if (string[1] == 0) {
                len = 1;
-               ret = (unsigned int) string[0];
+               ret = string[0];
            } else {
-               return(((unsigned int) string[0]) +
-                      (((unsigned int) string[1]) << 8));
+               return(string[0] + (string[1] << 8));
            }
        }
        /*
         * Skip to next node
         */
-       if ((tmp->children != NULL) && (tmp->type != XML_DTD_NODE)) {
-           if (tmp->children->type != XML_ENTITY_DECL) {
-               tmp = tmp->children;
-               continue;
-           }
+        if ((tmp->children != NULL) &&
+            (tmp->type != XML_DTD_NODE) &&
+            (tmp->type != XML_ENTITY_REF_NODE) &&
+            (tmp->children->type != XML_ENTITY_DECL)) {
+            tmp = tmp->children;
+            continue;
        }
        if (tmp == node)
            break;
@@ -6447,11 +5767,10 @@ xmlXPathNodeValHash(xmlNodePtr node) {
 static unsigned int
 xmlXPathStringHash(const xmlChar * string) {
     if (string == NULL)
-       return((unsigned int) 0);
+       return(0);
     if (string[0] == 0)
        return(0);
-    return(((unsigned int) string[0]) +
-          (((unsigned int) string[1]) << 8));
+    return(string[0] + (string[1] << 8));
 }
 
 /**
@@ -6814,6 +6133,7 @@ xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt,
                valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2));
                xmlFree(str2);
                xmlXPathNumberFunction(ctxt, 1);
+                CHECK_ERROR0;
                val = valuePop(ctxt);
                v = val->floatval;
                xmlXPathReleaseObject(ctxt->context, val);
@@ -6968,25 +6288,12 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
      */
     switch (arg1->type) {
         case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-           xmlGenericError(xmlGenericErrorContext,
-                   "Equal: undefined\n");
-#endif
            break;
         case XPATH_BOOLEAN:
            switch (arg2->type) {
                case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Equal: undefined\n");
-#endif
                    break;
                case XPATH_BOOLEAN:
-#ifdef DEBUG_EXPR
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Equal: %d boolean %d \n",
-                           arg1->boolval, arg2->boolval);
-#endif
                    ret = (arg1->boolval == arg2->boolval);
                    break;
                case XPATH_NUMBER:
@@ -7016,10 +6323,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
         case XPATH_NUMBER:
            switch (arg2->type) {
                case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Equal: undefined\n");
-#endif
                    break;
                case XPATH_BOOLEAN:
                    ret = (arg2->boolval==
@@ -7029,6 +6332,8 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
                    valuePush(ctxt, arg2);
                    xmlXPathNumberFunction(ctxt, 1);
                    arg2 = valuePop(ctxt);
+                    if (ctxt->error)
+                        break;
                     /* Falls through. */
                case XPATH_NUMBER:
                    /* Hand check NaN and Infinity equalities */
@@ -7075,10 +6380,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
         case XPATH_STRING:
            switch (arg2->type) {
                case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-                   xmlGenericError(xmlGenericErrorContext,
-                           "Equal: undefined\n");
-#endif
                    break;
                case XPATH_BOOLEAN:
                    if ((arg1->stringval == NULL) ||
@@ -7094,6 +6395,8 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
                    valuePush(ctxt, arg1);
                    xmlXPathNumberFunction(ctxt, 1);
                    arg1 = valuePop(ctxt);
+                    if (ctxt->error)
+                        break;
                    /* Hand check NaN and Infinity equalities */
                    if (xmlXPathIsNaN(arg1->floatval) ||
                            xmlXPathIsNaN(arg2->floatval)) {
@@ -7177,10 +6480,6 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
     }
 
     if (arg1 == arg2) {
-#ifdef DEBUG_EXPR
-        xmlGenericError(xmlGenericErrorContext,
-               "Equal: by pointer\n");
-#endif
        xmlXPathFreeObject(arg1);
         return(1);
     }
@@ -7200,10 +6499,6 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
        }
        switch (arg2->type) {
            case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-               xmlGenericError(xmlGenericErrorContext,
-                       "Equal: undefined\n");
-#endif
                break;
            case XPATH_NODESET:
            case XPATH_XSLT_TREE:
@@ -7264,10 +6559,6 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
     }
 
     if (arg1 == arg2) {
-#ifdef DEBUG_EXPR
-        xmlGenericError(xmlGenericErrorContext,
-               "NotEqual: by pointer\n");
-#endif
        xmlXPathReleaseObject(ctxt->context, arg1);
         return(0);
     }
@@ -7287,10 +6578,6 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
        }
        switch (arg2->type) {
            case XPATH_UNDEFINED:
-#ifdef DEBUG_EXPR
-               xmlGenericError(xmlGenericErrorContext,
-                       "NotEqual: undefined\n");
-#endif
                break;
            case XPATH_NODESET:
            case XPATH_XSLT_TREE:
@@ -7393,21 +6680,13 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
        xmlXPathNumberFunction(ctxt, 1);
        arg1 = valuePop(ctxt);
     }
-    if (arg1->type != XPATH_NUMBER) {
-       xmlXPathFreeObject(arg1);
-       xmlXPathFreeObject(arg2);
-       XP_ERROR0(XPATH_INVALID_OPERAND);
-    }
     if (arg2->type != XPATH_NUMBER) {
        valuePush(ctxt, arg2);
        xmlXPathNumberFunction(ctxt, 1);
        arg2 = valuePop(ctxt);
     }
-    if (arg2->type != XPATH_NUMBER) {
-       xmlXPathReleaseObject(ctxt->context, arg1);
-       xmlXPathReleaseObject(ctxt->context, arg2);
-       XP_ERROR0(XPATH_INVALID_OPERAND);
-    }
+    if (ctxt->error)
+        goto error;
     /*
      * Add tests for infinity and nan
      * => feedback on 3.4 for Inf and NaN
@@ -7457,6 +6736,7 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
            }
        }
     }
+error:
     xmlXPathReleaseObject(ctxt->context, arg1);
     xmlXPathReleaseObject(ctxt->context, arg2);
     return(ret);
@@ -8489,10 +7769,6 @@ xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) {
        valuePush(ctxt,
            xmlXPathCacheNewFloat(ctxt->context,
                (double) ctxt->context->contextSize));
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext,
-               "last() : %d\n", ctxt->context->contextSize);
-#endif
     } else {
        XP_ERROR(XPATH_INVALID_CTXT_SIZE);
     }
@@ -8516,10 +7792,6 @@ xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) {
        valuePush(ctxt,
              xmlXPathCacheNewFloat(ctxt->context,
                (double) ctxt->context->proximityPosition));
-#ifdef DEBUG_EXPR
-       xmlGenericError(xmlGenericErrorContext, "position() : %d\n",
-               ctxt->context->proximityPosition);
-#endif
     } else {
        XP_ERROR(XPATH_INVALID_CTXT_POSITION);
     }
@@ -8842,9 +8114,8 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
                                     NULL, 0);
                    if (fullname == cur->nodesetval->nodeTab[i]->name)
                        fullname = xmlStrdup(cur->nodesetval->nodeTab[i]->name);
-                   if (fullname == NULL) {
-                       XP_ERROR(XPATH_MEMORY_ERROR);
-                   }
+                   if (fullname == NULL)
+                        xmlXPathPErrMemory(ctxt, NULL);
                    valuePush(ctxt, xmlXPathCacheWrapString(
                        ctxt->context, fullname));
                 }
@@ -9196,7 +8467,7 @@ xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
   if (target) {
     point = xmlStrstr(str->stringval, find->stringval);
     if (point) {
-      offset = (int)(point - str->stringval);
+      offset = point - str->stringval;
       xmlBufAdd(target, str->stringval, offset);
     }
     valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
@@ -9239,7 +8510,7 @@ xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
   if (target) {
     point = xmlStrstr(str->stringval, find->stringval);
     if (point) {
-      offset = (int)(point - str->stringval) + xmlStrlen(find->stringval);
+      offset = point - str->stringval + xmlStrlen(find->stringval);
       xmlBufAdd(target, &str->stringval[offset],
                   xmlStrlen(str->stringval) - offset);
     }
@@ -9336,7 +8607,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
     xmlXPathObjectPtr to;
     xmlBufPtr target;
     int offset, max;
-    xmlChar ch;
+    int ch;
     const xmlChar *point;
     xmlChar *cptr;
 
@@ -9742,7 +9013,7 @@ xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
     } else {
        /* 1-byte code */
        *len = 1;
-       return((int) *cur);
+       return(*cur);
     }
 encoding_error:
     /*
@@ -9924,7 +9195,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
             if (len > XML_MAX_NAME_LENGTH) {
                 XP_ERRORNULL(XPATH_EXPR_ERROR);
             }
-           buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
+           buffer = (xmlChar *) xmlMallocAtomic(max);
            if (buffer == NULL) {
                XP_ERRORNULL(XPATH_MEMORY_ERROR);
            }
@@ -9941,8 +9212,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
                         XP_ERRORNULL(XPATH_EXPR_ERROR);
                     }
                    max *= 2;
-                   tmp = (xmlChar *) xmlRealloc(buffer,
-                                                max * sizeof(xmlChar));
+                   tmp = (xmlChar *) xmlRealloc(buffer, max);
                    if (tmp == NULL) {
                         xmlFree(buffer);
                        XP_ERRORNULL(XPATH_MEMORY_ERROR);
@@ -9994,13 +9264,13 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
 #endif
     if (cur == NULL) return(0);
     while (IS_BLANK_CH(*cur)) cur++;
-    if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
-        return(xmlXPathNAN);
-    }
     if (*cur == '-') {
        isneg = 1;
        cur++;
     }
+    if ((*cur != '.') && ((*cur < '0') || (*cur > '9'))) {
+        return(xmlXPathNAN);
+    }
 
 #ifdef __GNUC__
     /*
@@ -10257,7 +9527,10 @@ xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
     } else {
        XP_ERROR(XPATH_START_LITERAL_ERROR);
     }
-    if (ret == NULL) return;
+    if (ret == NULL) {
+        xmlXPathPErrMemory(ctxt, NULL);
+        return;
+    }
     lit = xmlXPathCacheNewString(ctxt->context, ret);
     if (lit == NULL) {
        ctxt->error = XPATH_MEMORY_ERROR;
@@ -10363,14 +9636,6 @@ xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
        XP_ERROR(XPATH_EXPR_ERROR);
     }
     SKIP_BLANKS;
-#ifdef DEBUG_EXPR
-    if (prefix == NULL)
-       xmlGenericError(xmlGenericErrorContext, "Calling function %s\n",
-                       name);
-    else
-       xmlGenericError(xmlGenericErrorContext, "Calling function %s:%s\n",
-                       prefix, name);
-#endif
 
     if (CUR != '(') {
        xmlFree(name);
@@ -10587,10 +9852,6 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
        SKIP_BLANKS;
        name = xmlXPathScanName(ctxt);
        if ((name != NULL) && (xmlStrstr(name, (xmlChar *) "::") != NULL)) {
-#ifdef DEBUG_STEP
-           xmlGenericError(xmlGenericErrorContext,
-                   "PathExpr: Axis\n");
-#endif
            lc = 1;
            xmlFree(name);
        } else if (name != NULL) {
@@ -10600,29 +9861,17 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
            while (NXT(len) != 0) {
                if (NXT(len) == '/') {
                    /* element name */
-#ifdef DEBUG_STEP
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PathExpr: AbbrRelLocation\n");
-#endif
                    lc = 1;
                    break;
                } else if (IS_BLANK_CH(NXT(len))) {
                    /* ignore blanks */
                    ;
                } else if (NXT(len) == ':') {
-#ifdef DEBUG_STEP
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PathExpr: AbbrRelLocation\n");
-#endif
                    lc = 1;
                    break;
                } else if ((NXT(len) == '(')) {
                    /* Node Type or Function */
                    if (xmlXPathIsNodeType(name)) {
-#ifdef DEBUG_STEP
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PathExpr: Type search\n");
-#endif
                        lc = 1;
 #ifdef LIBXML_XPTR_LOCS_ENABLED
                     } else if (ctxt->xptr &&
@@ -10630,19 +9879,11 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
                         lc = 1;
 #endif
                    } else {
-#ifdef DEBUG_STEP
-                       xmlGenericError(xmlGenericErrorContext,
-                               "PathExpr: function call\n");
-#endif
                        lc = 0;
                    }
                     break;
                } else if ((NXT(len) == '[')) {
                    /* element name */
-#ifdef DEBUG_STEP
-                   xmlGenericError(xmlGenericErrorContext,
-                           "PathExpr: AbbrRelLocation\n");
-#endif
                    lc = 1;
                    break;
                } else if ((NXT(len) == '<') || (NXT(len) == '>') ||
@@ -10656,10 +9897,6 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
                len++;
            }
            if (NXT(len) == 0) {
-#ifdef DEBUG_STEP
-               xmlGenericError(xmlGenericErrorContext,
-                       "PathExpr: AbbrRelLocation\n");
-#endif
                /* element name */
                lc = 1;
            }
@@ -11370,20 +10607,6 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
                xmlXPathErr(ctxt, XPATH_UNDEF_PREFIX_ERROR);
            }
        }
-#ifdef DEBUG_STEP
-       xmlGenericError(xmlGenericErrorContext,
-               "Basis : computing new set\n");
-#endif
-
-#ifdef DEBUG_STEP
-       xmlGenericError(xmlGenericErrorContext, "Basis : ");
-       if (ctxt->value == NULL)
-           xmlGenericError(xmlGenericErrorContext, "no value\n");
-       else if (ctxt->value->nodesetval == NULL)
-           xmlGenericError(xmlGenericErrorContext, "Empty\n");
-       else
-           xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
-#endif
 
 #ifdef LIBXML_XPTR_LOCS_ENABLED
 eval_predicates:
@@ -11407,16 +10630,6 @@ eval_predicates:
             xmlFree(name);
         }
     }
-#ifdef DEBUG_STEP
-    xmlGenericError(xmlGenericErrorContext, "Step : ");
-    if (ctxt->value == NULL)
-       xmlGenericError(xmlGenericErrorContext, "no value\n");
-    else if (ctxt->value->nodesetval == NULL)
-       xmlGenericError(xmlGenericErrorContext, "Empty\n");
-    else
-       xmlGenericErrorContextNodeSet(xmlGenericErrorContext,
-               ctxt->value->nodesetval);
-#endif
 }
 
 /**
@@ -11518,93 +10731,6 @@ xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) {
 static int
 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op);
 
-#ifdef DEBUG_STEP
-static void
-xmlXPathDebugDumpStepAxis(xmlXPathStepOpPtr op,
-                         int nbNodes)
-{
-    xmlGenericError(xmlGenericErrorContext, "new step : ");
-    switch (op->value) {
-        case AXIS_ANCESTOR:
-            xmlGenericError(xmlGenericErrorContext, "axis 'ancestors' ");
-            break;
-        case AXIS_ANCESTOR_OR_SELF:
-            xmlGenericError(xmlGenericErrorContext,
-                            "axis 'ancestors-or-self' ");
-            break;
-        case AXIS_ATTRIBUTE:
-            xmlGenericError(xmlGenericErrorContext, "axis 'attributes' ");
-            break;
-        case AXIS_CHILD:
-            xmlGenericError(xmlGenericErrorContext, "axis 'child' ");
-            break;
-        case AXIS_DESCENDANT:
-            xmlGenericError(xmlGenericErrorContext, "axis 'descendant' ");
-            break;
-        case AXIS_DESCENDANT_OR_SELF:
-            xmlGenericError(xmlGenericErrorContext,
-                            "axis 'descendant-or-self' ");
-            break;
-        case AXIS_FOLLOWING:
-            xmlGenericError(xmlGenericErrorContext, "axis 'following' ");
-            break;
-        case AXIS_FOLLOWING_SIBLING:
-            xmlGenericError(xmlGenericErrorContext,
-                            "axis 'following-siblings' ");
-            break;
-        case AXIS_NAMESPACE:
-            xmlGenericError(xmlGenericErrorContext, "axis 'namespace' ");
-            break;
-        case AXIS_PARENT:
-            xmlGenericError(xmlGenericErrorContext, "axis 'parent' ");
-            break;
-        case AXIS_PRECEDING:
-            xmlGenericError(xmlGenericErrorContext, "axis 'preceding' ");
-            break;
-        case AXIS_PRECEDING_SIBLING:
-            xmlGenericError(xmlGenericErrorContext,
-                            "axis 'preceding-sibling' ");
-            break;
-        case AXIS_SELF:
-            xmlGenericError(xmlGenericErrorContext, "axis 'self' ");
-            break;
-    }
-    xmlGenericError(xmlGenericErrorContext,
-       " context contains %d nodes\n", nbNodes);
-    switch (op->value2) {
-        case NODE_TEST_NONE:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for none !!!\n");
-            break;
-        case NODE_TEST_TYPE:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for type %d\n", op->value3);
-            break;
-        case NODE_TEST_PI:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for PI !!!\n");
-            break;
-        case NODE_TEST_ALL:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for *\n");
-            break;
-        case NODE_TEST_NS:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for namespace %s\n",
-                            op->value5);
-            break;
-        case NODE_TEST_NAME:
-            xmlGenericError(xmlGenericErrorContext,
-                            "           searching for name %s\n", op->value5);
-            if (op->value4)
-                xmlGenericError(xmlGenericErrorContext,
-                                "           with namespace %s\n", op->value4);
-            break;
-    }
-    xmlGenericError(xmlGenericErrorContext, "Testing : ");
-}
-#endif /* DEBUG_STEP */
-
 /**
  * xmlXPathNodeSetFilter:
  * @ctxt:  the XPath Parser context
@@ -11995,9 +11121,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
     const xmlChar *name = op->value5;
     const xmlChar *URI = NULL;
 
-#ifdef DEBUG_STEP
-    int nbMatches = 0, prevMatches = 0;
-#endif
     int total = 0, hasNsNodes = 0;
     /* The popped object holding the context nodes */
     xmlXPathObjectPtr obj;
@@ -12122,11 +11245,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
             break;
     }
 
-#ifdef DEBUG_STEP
-    xmlXPathDebugDumpStepAxis(op,
-       (obj->nodesetval != NULL) ? obj->nodesetval->nodeNr : 0);
-#endif
-
     if (next == NULL) {
        xmlXPathReleaseObject(xpctxt, obj);
         return(0);
@@ -12260,10 +11378,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
 
             total++;
 
-#ifdef DEBUG_STEP
-            xmlGenericError(xmlGenericErrorContext, " %s", cur->name);
-#endif
-
            switch (test) {
                 case NODE_TEST_NONE:
                    total = 0;
@@ -12450,11 +11564,6 @@ first_hit: /* ---------------------------------------------------------- */
            outSeq = mergeAndClear(outSeq, seq);
        break;
 
-#ifdef DEBUG_STEP
-       if (seq != NULL)
-           nbMatches += seq->nodeNr;
-#endif
-
 apply_predicates: /* --------------------------------------------------- */
         if (ctxt->error != XPATH_EXPRESSION_OK)
            goto error;
@@ -12566,12 +11675,6 @@ error:
         xpctxt->tmpNsList = NULL;
     }
 
-#ifdef DEBUG_STEP
-    xmlGenericError(xmlGenericErrorContext,
-       "\nExamined %d nodes, found %d nodes at that step\n",
-       total, nbMatches);
-#endif
-
     return(total);
 }
 
@@ -12862,6 +11965,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
 {
     int total = 0;
     xmlXPathCompExprPtr comp;
+    xmlXPathObjectPtr obj;
     xmlNodeSetPtr set;
 
     CHECK_ERROR0;
@@ -12929,13 +12033,20 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
     }
 #endif /* LIBXML_XPTR_LOCS_ENABLED */
 
+    /*
+     * In case of errors, xmlXPathNodeSetFilter can pop additional nodes from
+     * the stack. We have to temporarily remove the nodeset object from the
+     * stack to avoid freeing it prematurely.
+     */
     CHECK_TYPE0(XPATH_NODESET);
-    set = ctxt->value->nodesetval;
+    obj = valuePop(ctxt);
+    set = obj->nodesetval;
     if (set != NULL) {
         xmlXPathNodeSetFilter(ctxt, set, op->ch2, 1, 1, 1);
         if (set->nodeNr > 0)
             *first = set->nodeTab[0];
     }
+    valuePush(ctxt, obj);
 
     return (total);
 }
@@ -13152,20 +12263,17 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                int i;
                 int frame;
 
-                frame = xmlXPathSetFrame(ctxt);
+                frame = ctxt->valueNr;
                 if (op->ch1 != -1) {
                     total +=
                         xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
-                    if (ctxt->error != XPATH_EXPRESSION_OK) {
-                        xmlXPathPopFrame(ctxt, frame);
+                    if (ctxt->error != XPATH_EXPRESSION_OK)
                         break;
-                    }
                 }
-               if (ctxt->valueNr < ctxt->valueFrame + op->value) {
+               if (ctxt->valueNr < frame + op->value) {
                    xmlGenericError(xmlGenericErrorContext,
                            "xmlXPathCompOpEval: parameter error\n");
                    ctxt->error = XPATH_INVALID_OPERAND;
-                    xmlXPathPopFrame(ctxt, frame);
                    break;
                }
                for (i = 0; i < op->value; i++) {
@@ -13173,7 +12281,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                        xmlGenericError(xmlGenericErrorContext,
                                "xmlXPathCompOpEval: parameter error\n");
                        ctxt->error = XPATH_INVALID_OPERAND;
-                        xmlXPathPopFrame(ctxt, frame);
                        break;
                    }
                 }
@@ -13192,7 +12299,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                             xmlGenericError(xmlGenericErrorContext,
             "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
                                     (char *)op->value4, (char *)op->value5);
-                            xmlXPathPopFrame(ctxt, frame);
                             ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
                             break;
                         }
@@ -13216,9 +12322,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                 ctxt->context->function = oldFunc;
                 ctxt->context->functionURI = oldFuncURI;
                 if ((ctxt->error == XPATH_EXPRESSION_OK) &&
-                    (ctxt->valueNr != ctxt->valueFrame + 1))
+                    (ctxt->valueNr != frame + 1))
                     XP_ERROR0(XPATH_STACK_ERROR);
-                xmlXPathPopFrame(ctxt, frame);
                 break;
             }
         case XPATH_OP_ARG:
@@ -13233,6 +12338,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
             break;
         case XPATH_OP_PREDICATE:
         case XPATH_OP_FILTER:{
+                xmlXPathObjectPtr obj;
                 xmlNodeSetPtr set;
 
                 /*
@@ -13347,11 +12453,19 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                 }
 #endif /* LIBXML_XPTR_LOCS_ENABLED */
 
+                /*
+                 * In case of errors, xmlXPathNodeSetFilter can pop additional
+                 * nodes from the stack. We have to temporarily remove the
+                 * nodeset object from the stack to avoid freeing it
+                 * prematurely.
+                 */
                 CHECK_TYPE0(XPATH_NODESET);
-                set = ctxt->value->nodesetval;
+                obj = valuePop(ctxt);
+                set = obj->nodesetval;
                 if (set != NULL)
                     xmlXPathNodeSetFilter(ctxt, set, op->ch2,
                                           1, set->nodeNr, 1);
+                valuePush(ctxt, obj);
                 break;
             }
         case XPATH_OP_SORT:
@@ -13645,8 +12759,6 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
     xmlNodePtr cur = NULL, limit = NULL;
     xmlStreamCtxtPtr patstream = NULL;
 
-    int nb_nodes = 0;
-
     if ((ctxt == NULL) || (comp == NULL))
         return(-1);
     max_depth = xmlPatternMaxDepth(comp);
@@ -13763,8 +12875,6 @@ next_node:
             ctxt->opCount++;
         }
 
-        nb_nodes++;
-
        switch (cur->type) {
            case XML_ELEMENT_NODE:
            case XML_TEXT_NODE:
@@ -13856,11 +12966,6 @@ scan_children:
 
 done:
 
-#if 0
-    printf("stream eval: checked %d nodes selected %d\n",
-           nb_nodes, retObj->nodesetval->nodeNr);
-#endif
-
     if (patstream)
        xmlFreeStreamCtxt(patstream);
     return(0);
@@ -13899,7 +13004,6 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
        ctxt->valueNr = 0;
        ctxt->valueMax = 10;
        ctxt->value = NULL;
-        ctxt->valueFrame = 0;
     }
 #ifdef XPATH_STREAMING
     if (ctxt->comp->stream) {
@@ -14114,6 +13218,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
            comp = xmlXPathNewCompExpr();
            if (comp == NULL) {
                xmlXPathErrMemory(ctxt, "allocating streamable expression\n");
+               xmlFreePattern(stream);
                return(NULL);
            }
            comp->stream = stream;
@@ -14267,10 +13372,6 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
 
     if (comp != NULL) {
        comp->expr = xmlStrdup(str);
-#ifdef DEBUG_EVAL_COUNTS
-       comp->string = xmlStrdup(str);
-       comp->nb = 0;
-#endif
     }
     return(comp);
 }
@@ -14327,14 +13428,9 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
        xmlXPathDisableOptimizer = 1;
 #endif
 
-#ifdef DEBUG_EVAL_COUNTS
-    comp->nb++;
-    if ((comp->string != NULL) && (comp->nb > 100)) {
-       fprintf(stderr, "100 x %s\n", comp->string);
-       comp->nb = 0;
-    }
-#endif
     pctxt = xmlXPathCompParserContext(comp, ctxt);
+    if (pctxt == NULL)
+        return(-1);
     res = xmlXPathRunEval(pctxt, toBool);
 
     if (pctxt->error != XPATH_EXPRESSION_OK) {
index ba1e31e..6e1e5f4 100644 (file)
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/xmlerror.h>
-#include <libxml/globals.h>
 
 #ifdef LIBXML_XPTR_ENABLED
 
 /* Add support of the xmlns() xpointer scheme to initialize the namespaces */
 #define XPTR_XMLNS_SCHEME
 
-/* #define DEBUG_RANGES */
-#ifdef DEBUG_RANGES
-#ifdef LIBXML_DEBUG_ENABLED
-#include <libxml/debugXML.h>
-#endif
-#endif
+#include "private/error.h"
 
 #define TODO                                                           \
     xmlGenericError(xmlGenericErrorContext,                            \
@@ -266,7 +260,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int indx) {
         xmlXPtrErrMemory("allocating point");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_POINT;
     ret->user = (void *) node;
     ret->index = indx;
@@ -586,7 +580,7 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
         xmlXPtrErrMemory("allocating locationset");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlLocationSet));
+    memset(ret, 0 , sizeof(xmlLocationSet));
     if (val != NULL) {
         ret->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
                                             sizeof(xmlXPathObjectPtr));
@@ -596,7 +590,7 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
            return(NULL);
        }
        memset(ret->locTab, 0 ,
-              XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
+              XML_RANGESET_DEFAULT * sizeof(xmlXPathObjectPtr));
         ret->locMax = XML_RANGESET_DEFAULT;
        ret->locTab[ret->locNr++] = val;
     }
@@ -638,7 +632,7 @@ xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
            return;
        }
        memset(cur->locTab, 0 ,
-              XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
+              XML_RANGESET_DEFAULT * sizeof(xmlXPathObjectPtr));
         cur->locMax = XML_RANGESET_DEFAULT;
     } else if (cur->locNr == cur->locMax) {
         xmlXPathObjectPtr *temp;
@@ -703,10 +697,6 @@ xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
         if (cur->locTab[i] == val) break;
 
     if (i >= cur->locNr) {
-#ifdef DEBUG
-        xmlGenericError(xmlGenericErrorContext,
-               "xmlXPtrLocationSetDel: Range wasn't found in RangeList\n");
-#endif
         return;
     }
     cur->locNr--;
@@ -771,7 +761,7 @@ xmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end) {
         xmlXPtrErrMemory("allocating locationset");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0 , sizeof(xmlXPathObject));
     ret->type = XPATH_LOCATIONSET;
     if (end == NULL)
        ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewCollapsedRange(start));
@@ -798,7 +788,7 @@ xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set) {
         xmlXPtrErrMemory("allocating locationset");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0, sizeof(xmlXPathObject));
     ret->type = XPATH_LOCATIONSET;
     if (set != NULL) {
        int i;
@@ -834,7 +824,7 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
         xmlXPtrErrMemory("allocating locationset");
        return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+    memset(ret, 0, sizeof(xmlXPathObject));
     ret->type = XPATH_LOCATIONSET;
     ret->user = (void *) val;
     return(ret);
@@ -967,7 +957,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
 
     len = xmlStrlen(ctxt->cur);
     len++;
-    buffer = (xmlChar *) xmlMallocAtomic(len * sizeof (xmlChar));
+    buffer = (xmlChar *) xmlMallocAtomic(len);
     if (buffer == NULL) {
         xmlXPtrErrMemory("allocating buffer");
         xmlFree(name);
@@ -1246,7 +1236,6 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
        ctxt->valueNr = 0;
        ctxt->valueMax = 10;
        ctxt->value = NULL;
-       ctxt->valueFrame = 0;
     }
     SKIP_BLANKS;
     if (CUR == '/') {
@@ -2423,13 +2412,6 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
            if (len >= pos + stringlen) {
                match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
                if (match) {
-#ifdef DEBUG_RANGES
-                   xmlGenericError(xmlGenericErrorContext,
-                           "found range %d bytes at index %d of ->",
-                           stringlen, pos + 1);
-                   xmlDebugDumpString(stdout, cur->content);
-                   xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
                    *end = cur;
                    *endindex = pos + stringlen;
                    return(1);
@@ -2440,13 +2422,6 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
                 int sub = len - pos;
                match = (!xmlStrncmp(&cur->content[pos], string, sub));
                if (match) {
-#ifdef DEBUG_RANGES
-                   xmlGenericError(xmlGenericErrorContext,
-                           "found subrange %d bytes at index %d of ->",
-                           sub, pos + 1);
-                   xmlDebugDumpString(stdout, cur->content);
-                   xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
                     string = &string[sub];
                    stringlen -= sub;
                } else {
@@ -2506,13 +2481,6 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
                    str = xmlStrchr(&cur->content[pos], first);
                    if (str != NULL) {
                        pos = (str - (xmlChar *)(cur->content));
-#ifdef DEBUG_RANGES
-                       xmlGenericError(xmlGenericErrorContext,
-                               "found '%c' at index %d of ->",
-                               first, pos + 1);
-                       xmlDebugDumpString(stdout, cur->content);
-                       xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
                        if (xmlXPtrMatchString(string, cur, pos + 1,
                                               end, endindex)) {
                            *start = cur;
@@ -2529,13 +2497,6 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
                     * character of the string-value and after the final
                     * character.
                     */
-#ifdef DEBUG_RANGES
-                   xmlGenericError(xmlGenericErrorContext,
-                           "found '' at index %d of ->",
-                           pos + 1);
-                   xmlDebugDumpString(stdout, cur->content);
-                   xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
                    *start = cur;
                    *startindex = pos + 1;
                    *end = cur;
@@ -2785,25 +2746,12 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
      * the list of location set corresponding to that search
      */
     for (i = 0;i < oldset->locNr;i++) {
-#ifdef DEBUG_RANGES
-       xmlXPathDebugDumpObject(stdout, oldset->locTab[i], 0);
-#endif
 
        xmlXPtrGetStartPoint(oldset->locTab[i], &start, &startindex);
        xmlXPtrGetEndPoint(oldset->locTab[i], &end, &endindex);
        xmlXPtrAdvanceChar(&start, &startindex, 0);
        xmlXPtrGetLastChar(&end, &endindex);
 
-#ifdef DEBUG_RANGES
-       xmlGenericError(xmlGenericErrorContext,
-               "from index %d of ->", startindex);
-       xmlDebugDumpString(stdout, start->content);
-       xmlGenericError(xmlGenericErrorContext, "\n");
-       xmlGenericError(xmlGenericErrorContext,
-               "to index %d of ->", endindex);
-       xmlDebugDumpString(stdout, end->content);
-       xmlGenericError(xmlGenericErrorContext, "\n");
-#endif
        do {
             fend = end;
             fendindex = endindex;
diff --git a/xstc/.gitignore b/xstc/.gitignore
new file mode 100644 (file)
index 0000000..e8c51fd
--- /dev/null
@@ -0,0 +1,3 @@
+/*-test.py
+/Tests
+/xsts-*.tar.gz
index 921820b..09490d1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys, os
 import libxml2
@@ -11,7 +11,7 @@ mainXSD = str()
 signature = str()
 dictXSD = dict()
 
-def gatherFiles():     
+def gatherFiles():
     for file in filenames:
         if (file[-5] in ["a", "b", "c"]) and (file[-3:] == 'xsd'):
             # newfilename = string.replace(filename, ' ', '_')
@@ -26,74 +26,73 @@ def gatherFiles():
 
 def debugMsg(text):
     #pass
-    print "DEBUG:", text
-    
-    
-def fixup():      
+    print("DEBUG:", text)
+
+
+def fixup():
     for mainXSD in dictXSD:
-        debugMsg("fixing '%s'..." % mainXSD)   
-       schemaDoc = None
-       xpmainCtx = None        
+        debugMsg("fixing '%s'..." % mainXSD)
+        schemaDoc = None
+        xpmainCtx = None
         # Load the schema document.
         schemaFile = os.path.join(baseDir, mainXSD)
         schemaDoc = libxml2.parseFile(schemaFile)
-       if (schemaDoc is None):
-           print "ERROR: doc '%s' not found" % mainXSD
+        if (schemaDoc is None):
+            print("ERROR: doc '%s' not found" % mainXSD)
             sys.exit(1)
-       try:    
-           xpmainCtx = schemaDoc.xpathNewContext()
-            xpmainCtx.xpathRegisterNs("xs", "http://www.w3.org/2001/XMLSchema");               
+        try:
+            xpmainCtx = schemaDoc.xpathNewContext()
+            xpmainCtx.xpathRegisterNs("xs", "http://www.w3.org/2001/XMLSchema")
             xpres = xpmainCtx.xpathEval("/xs:schema")
             if len(xpres) == 0:
-                print "ERROR: doc '%s' has no <schema> element" % mainXSD
+                print("ERROR: doc '%s' has no <schema> element" % mainXSD)
                 sys.exit(1)
-           schemaElem = xpres[0]  
-           schemaNs = schemaElem.ns()
-           # Select all <import>s.
-           xpres = xpmainCtx.xpathEval("/xs:schema/xs:import") 
-           if len(xpres) != 0:
-               for elem in xpres:
-                   loc = elem.noNsProp("schemaLocation")
-                   if (loc is not None):
-                       debugMsg("  imports '%s'" % loc)
-                       if loc in dictXSD[mainXSD]:
-                           dictXSD[mainXSD].remove(loc)                        
-           for loc in dictXSD[mainXSD]:            
-               # Read out the targetNamespace.
-               impTargetNs = None
-               impFile = os.path.join(baseDir, loc)
-               impDoc = libxml2.parseFile(impFile)
-               try:
+            schemaElem = xpres[0]
+            schemaNs = schemaElem.ns()
+            # Select all <import>s.
+            xpres = xpmainCtx.xpathEval("/xs:schema/xs:import")
+            if len(xpres) != 0:
+                for elem in xpres:
+                    loc = elem.noNsProp("schemaLocation")
+                    if (loc is not None):
+                        debugMsg("  imports '%s'" % loc)
+                        if loc in dictXSD[mainXSD]:
+                            dictXSD[mainXSD].remove(loc)
+            for loc in dictXSD[mainXSD]:
+                # Read out the targetNamespace.
+                impTargetNs = None
+                impFile = os.path.join(baseDir, loc)
+                impDoc = libxml2.parseFile(impFile)
+                try:
                     xpimpCtx = impDoc.xpathNewContext()
-                   try:
+                    try:
                         xpimpCtx.setContextDoc(impDoc)
-                       xpimpCtx.xpathRegisterNs("xs", "http://www.w3.org/2001/XMLSchema");  
-                       xpres = xpimpCtx.xpathEval("/xs:schema")
-                       impTargetNs = xpres[0].noNsProp("targetNamespace")
-                   finally:
+                        xpimpCtx.xpathRegisterNs("xs", "http://www.w3.org/2001/XMLSchema")
+                        xpres = xpimpCtx.xpathEval("/xs:schema")
+                        impTargetNs = xpres[0].noNsProp("targetNamespace")
+                    finally:
                         xpimpCtx.xpathFreeContext()
-               finally:
+                finally:
                     impDoc.freeDoc()
-                       
-               # Add the <import>.
-               debugMsg("  adding <import namespace='%s' schemaLocation='%s'/>" % (impTargetNs, loc))
-               newElem = schemaDoc.newDocNode(schemaNs, "import", None)
-               if (impTargetNs is not None):
+
+                # Add the <import>.
+                debugMsg("  adding <import namespace='%s' schemaLocation='%s'/>" % (impTargetNs, loc))
+                newElem = schemaDoc.newDocNode(schemaNs, "import", None)
+                if (impTargetNs is not None):
                     newElem.newProp("namespace", impTargetNs)
-               newElem.newProp("schemaLocation", loc)
-               if schemaElem.children is not None:
+                newElem.newProp("schemaLocation", loc)
+                if schemaElem.children is not None:
                     schemaElem.children.addPrevSibling(newElem)
                 schemaDoc.saveFile(schemaFile)
-       finally:
+        finally:
             xpmainCtx.xpathFreeContext()
             schemaDoc.freeDoc()
-           
+
 try:
     gatherFiles()
     fixup()
 finally:
     libxml2.cleanupParser()
     if libxml2.debugMemory(1) != 0:
-        print "Memory leak %d bytes" % (libxml2.debugMemory(1))
-        libxml2.dumpMemory()
+        print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
 
index 7b119bd..cf4a8a1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 #
 # This is the MS subset of the W3C test suite for XML Schemas.
diff --git a/xzlib.c b/xzlib.c
index c13e17d..b5d35da 100644 (file)
--- a/xzlib.c
+++ b/xzlib.c
@@ -14,9 +14,6 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
@@ -25,6 +22,8 @@
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (_WIN32)
+#include <io.h>
 #endif
 #ifdef LIBXML_ZLIB_ENABLED
 #include <zlib.h>
@@ -33,7 +32,7 @@
 #include <lzma.h>
 #endif
 
-#include "xzlib.h"
+#include "private/xzlib.h"
 #include <libxml/xmlmemory.h>
 
 /* values for xz_state how */
@@ -134,6 +133,7 @@ static xzFile
 xz_open(const char *path, int fd, const char *mode ATTRIBUTE_UNUSED)
 {
     xz_statep state;
+    off_t offset;
 
     /* allocate xzFile structure to return */
     state = xmlMalloc(sizeof(xz_state));
@@ -168,9 +168,11 @@ xz_open(const char *path, int fd, const char *mode ATTRIBUTE_UNUSED)
     }
 
     /* save the current position for rewinding (only if reading) */
-    state->start = lseek(state->fd, 0, SEEK_CUR);
-    if (state->start == (uint64_t) - 1)
+    offset = lseek(state->fd, 0, SEEK_CUR);
+    if (offset == -1)
         state->start = 0;
+    else
+        state->start = offset;
 
     /* initialize stream */
     xz_reset(state);
@@ -214,11 +216,12 @@ xzFile
 __libxml2_xzdopen(int fd, const char *mode)
 {
     char *path;                 /* identifier for error messages */
+    size_t path_size = 7 + 3 * sizeof(int);
     xzFile xz;
 
-    if (fd == -1 || (path = xmlMalloc(7 + 3 * sizeof(int))) == NULL)
+    if (fd == -1 || (path = xmlMalloc(path_size)) == NULL)
         return NULL;
-    sprintf(path, "<fd:%d>", fd);       /* for debugging */
+    snprintf(path, path_size, "<fd:%d>", fd);       /* for debugging */
     xz = xz_open(path, fd, mode);
     xmlFree(path);
     return xz;
diff --git a/xzlib.h b/xzlib.h
deleted file mode 100644 (file)
index 7b1df15..0000000
--- a/xzlib.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * xzlib.h: header for the front end for the transparent support of lzma
- *          compression at the I/O layer
- *
- * See Copyright for the status of this software.
- *
- * Anders F Bjorklund <afb@users.sourceforge.net>
- */
-
-#ifndef LIBXML2_XZLIB_H
-#define LIBXML2_XZLIB_H
-typedef void *xzFile;           /* opaque lzma file descriptor */
-
-xzFile __libxml2_xzopen(const char *path, const char *mode);
-xzFile __libxml2_xzdopen(int fd, const char *mode);
-int __libxml2_xzread(xzFile file, void *buf, unsigned len);
-int __libxml2_xzclose(xzFile file);
-int __libxml2_xzcompressed(xzFile f);
-#endif /* LIBXML2_XZLIB_H */