Merge tag 'v2.14.2' into HEAD
* Release v2.14.2
* Update README.fuchsia to new libxml2 version.
* Merge via 'git merge -X theirs v2.14.2'.
* Regenerate config with './autogen.sh --without-lzma'
Bug: 414072443
Change-Id: If2c14c0dd12a506204d6faf837eccf1343ae1e9d
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/libxml2/+/1272071
Reviewed-by: Dzmitry Yatsushkevich <dmitryya@google.com>
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000..ac6ecc0
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,171 @@
+# Copyright 2017 The Fuchsia Authors. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This is the configuration needed to use libxml2.
+config("libxml2_config") {
+ include_dirs = [ "include" ]
+}
+
+# This is the configuration used to build libxml2 itself. It should not be needed outside of this
+# library.
+#
+# This has to be a config instead of flags directly specified on the libxml2 target so the -Wno-*
+# flags are ordered after the -Werror flags from the default configs.
+config("libxml2_private_config") {
+ visibility = [ ":*" ]
+ cflags = [
+ "-Wno-conversion",
+ "-Wno-empty-body",
+ "-Wno-enum-compare",
+ "-Wno-implicit-fallthrough",
+ "-Wno-incompatible-pointer-types",
+ "-Wno-misleading-indentation",
+ "-Wno-missing-field-initializers",
+ "-Wno-self-assign",
+ "-Wno-sign-compare",
+ "-Wno-tautological-pointer-compare",
+ "-Wno-unused-function",
+ "-Wno-unused-but-set-variable",
+ ]
+ defines = [
+ "HAVE_CONFIG_H",
+ "_REENTRANT",
+ ]
+ if (is_linux) {
+ defines += [ "_GNU_SOURCE" ]
+ }
+}
+
+target(default_library_type, "libxml2") {
+ sources = [
+ "HTMLparser.c",
+ "HTMLtree.c",
+ "SAX.c",
+ "SAX2.c",
+ "buf.c",
+ "c14n.c",
+ "catalog.c",
+ "config.h",
+ "chvalid.c",
+ "debugXML.c",
+ "dict.c",
+ "encoding.c",
+ "entities.c",
+ "error.c",
+ "globals.c",
+ "hash.c",
+ "include/libxml/DOCBparser.h",
+ "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",
+ "include/libxml/xmlwriter.h",
+ "include/libxml/xpath.h",
+ "include/libxml/xpathInternals.h",
+ "include/libxml/xpointer.h",
+ "legacy.c",
+ "list.c",
+ "nanoftp.c",
+ "nanohttp.c",
+ "parser.c",
+ "parserInternals.c",
+ "pattern.c",
+ "relaxng.c",
+ "schematron.c",
+ "threads.c",
+ "tree.c",
+ "uri.c",
+ "valid.c",
+ "xinclude.c",
+ "xlink.c",
+ "xmlIO.c",
+ "xmlmemory.c",
+ "xmlmodule.c",
+ "xmlreader.c",
+ "xmlregexp.c",
+ "xmlsave.c",
+ "xmlschemas.c",
+ "xmlschemastypes.c",
+ "xmlstring.c",
+ "xmlunicode.c",
+ "xmlwriter.c",
+ "xpath.c",
+ "xpointer.c",
+ "xzlib.c",
+ ]
+
+ public_configs = [ ":libxml2_config" ]
+ configs -= [ "//build/config:symbol_visibility_hidden" ]
+ configs += [ ":libxml2_private_config" ]
+
+ if (is_linux) {
+ libs = [ "dl" ]
+ } else if (is_mac) {
+ libs = [ "iconv" ]
+ }
+
+ deps = [ "//third_party/zlib" ]
+}
diff --git a/Makefile.am b/Makefile.am
index 6f98144..cff88d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -219,7 +219,7 @@
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libxml-2.0.pc
+nodist_pkgconfig_DATA = libxml-2.0.pc
cmakedir = $(libdir)/cmake/libxml2
cmake_DATA = libxml2-config.cmake
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..2845e24
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,2 @@
+include /src/virtualization/OWNERS
+include /src/connectivity/weave/OWNERS
\ No newline at end of file
diff --git a/README.fuchsia b/README.fuchsia
new file mode 100644
index 0000000..9638600
--- /dev/null
+++ b/README.fuchsia
@@ -0,0 +1,14 @@
+Name: libxml2
+URL: http://xmlsoft.org/
+License: MIT
+License File: Copyright
+Upstream Git: https://github.com/GNOME/libxml2
+Version: 2.14.2
+Description:
+
+This is the Fuchsia build of libxml2 based off of upstream's v2.14.2 release.
+
+Local Modifications:
+- The 'config.h' and 'include/libxml2/xmlversion.h' files are generated via the
+ 'autogen.sh' script, then modified manually and included in the build. The default
+ configuration is used with the exception of disabling LZMA support.
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..b91758d
--- /dev/null
+++ b/config.h
@@ -0,0 +1,112 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the declaration of 'getentropy', and to 0 if you
+ don't. */
+#define HAVE_DECL_GETENTROPY 1
+
+/* Define to 1 if you have the declaration of 'glob', and to 0 if you don't.
+ */
+#define HAVE_DECL_GLOB 1
+
+/* Define to 1 if you have the declaration of 'mmap', and to 0 if you don't.
+ */
+#define HAVE_DECL_MMAP 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Have dlopen based dso */
+#define HAVE_DLOPEN /**/
+
+/* Define to 1 if the system has the `destructor' function attribute */
+#define HAVE_FUNC_ATTRIBUTE_DESTRUCTOR 1
+
+/* getentropy */
+#define HAVE_GETENTROPY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define if history library is available */
+/* #undef HAVE_LIBHISTORY */
+
+/* Define if readline library is available */
+/* #undef HAVE_LIBREADLINE */
+
+/* Define to 1 if you have the <lzma.h> header file. */
+/* #undef HAVE_LZMA_H */
+
+/* Define to 1 if you have the <poll.h> header file. */
+/* #undef HAVE_POLL_H */
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Have shl_load based dso */
+/* #undef HAVE_SHLLOAD */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #undef HAVE_ZLIB_H */
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "libxml2"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libxml2"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libxml2 2.14.2"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libxml2"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "2.14.2"
+
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "2.14.2"
+
+/* System configuration directory (/etc) */
+#define XML_SYSCONFDIR "/usr/local/etc"
+
+/* TLS specifier */
+/* #undef XML_THREAD_LOCAL */
diff --git a/configure.ac b/configure.ac
index d21ebfe..855639f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -309,6 +309,10 @@
AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_have_decl_glob" = "yes")
+AC_CHECK_DECL([getentropy],
+ [AC_DEFINE([HAVE_GETENTROPY], [1], [getentropy])], [],
+ [#include <sys/random.h>])
+
dnl
dnl Checks for inet libraries
dnl
diff --git a/include/libxml/xmlversion.h b/include/libxml/xmlversion.h
new file mode 100644
index 0000000..7a5ecbd
--- /dev/null
+++ b/include/libxml/xmlversion.h
@@ -0,0 +1,332 @@
+/*
+ * Summary: compile-time version information
+ * Description: compile-time version information for the XML library
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_VERSION_H__
+#define __XML_VERSION_H__
+
+/**
+ * LIBXML_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXML_DOTTED_VERSION "2.14.2"
+
+/**
+ * LIBXML_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXML_VERSION 21402
+
+/**
+ * LIBXML_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXML_VERSION_STRING "21402"
+
+/**
+ * LIBXML_VERSION_EXTRA:
+ *
+ * extra version information, used to show a git commit description
+ */
+#define LIBXML_VERSION_EXTRA "-GITv2.14.2-198-g5f13b6b3"
+
+/**
+ * LIBXML_TEST_VERSION:
+ *
+ * Macro to check that the libxml version in use is compatible with
+ * the version the software has been compiled against
+ */
+#define LIBXML_TEST_VERSION xmlCheckVersion(21402);
+
+/**
+ * LIBXML_THREAD_ENABLED:
+ *
+ * Whether the thread support is configured in
+ */
+#if 1
+#define LIBXML_THREAD_ENABLED
+#endif
+
+/**
+ * LIBXML_THREAD_ALLOC_ENABLED:
+ *
+ * Whether the allocation hooks are per-thread
+ */
+#if 0
+#define LIBXML_THREAD_ALLOC_ENABLED
+#endif
+
+/**
+ * LIBXML_TREE_ENABLED:
+ *
+ * Always enabled since 2.14.0
+ */
+#define LIBXML_TREE_ENABLED
+
+/**
+ * LIBXML_OUTPUT_ENABLED:
+ *
+ * Whether the serialization/saving support is configured in
+ */
+#if 1
+#define LIBXML_OUTPUT_ENABLED
+#endif
+
+/**
+ * LIBXML_PUSH_ENABLED:
+ *
+ * Whether the push parsing interfaces are configured in
+ */
+#if 1
+#define LIBXML_PUSH_ENABLED
+#endif
+
+/**
+ * LIBXML_READER_ENABLED:
+ *
+ * Whether the xmlReader parsing interface is configured in
+ */
+#if 1
+#define LIBXML_READER_ENABLED
+#endif
+
+/**
+ * LIBXML_PATTERN_ENABLED:
+ *
+ * Whether the xmlPattern node selection interface is configured in
+ */
+#if 1
+#define LIBXML_PATTERN_ENABLED
+#endif
+
+/**
+ * LIBXML_WRITER_ENABLED:
+ *
+ * Whether the xmlWriter saving interface is configured in
+ */
+#if 1
+#define LIBXML_WRITER_ENABLED
+#endif
+
+/**
+ * LIBXML_SAX1_ENABLED:
+ *
+ * Whether the older SAX1 interface is configured in
+ */
+#if 1
+#define LIBXML_SAX1_ENABLED
+#endif
+
+/**
+ * LIBXML_HTTP_ENABLED:
+ *
+ * Whether the HTTP support is configured in
+ */
+#if 0
+#define LIBXML_HTTP_ENABLED
+#endif
+
+/**
+ * LIBXML_VALID_ENABLED:
+ *
+ * Whether the DTD validation support is configured in
+ */
+#if 1
+#define LIBXML_VALID_ENABLED
+#endif
+
+/**
+ * LIBXML_HTML_ENABLED:
+ *
+ * Whether the HTML support is configured in
+ */
+#if 1
+#define LIBXML_HTML_ENABLED
+#endif
+
+/**
+ * LIBXML_LEGACY_ENABLED:
+ *
+ * Removed in 2.14
+ */
+#undef LIBXML_LEGACY_ENABLED
+
+/**
+ * LIBXML_C14N_ENABLED:
+ *
+ * Whether the Canonicalization support is configured in
+ */
+#if 1
+#define LIBXML_C14N_ENABLED
+#endif
+
+/**
+ * LIBXML_CATALOG_ENABLED:
+ *
+ * Whether the Catalog support is configured in
+ */
+#if 1
+#define LIBXML_CATALOG_ENABLED
+#endif
+
+/**
+ * LIBXML_XPATH_ENABLED:
+ *
+ * Whether XPath is configured in
+ */
+#if 1
+#define LIBXML_XPATH_ENABLED
+#endif
+
+/**
+ * LIBXML_XPTR_ENABLED:
+ *
+ * Whether XPointer is configured in
+ */
+#if 1
+#define LIBXML_XPTR_ENABLED
+#endif
+
+/**
+ * LIBXML_XINCLUDE_ENABLED:
+ *
+ * Whether XInclude is configured in
+ */
+#if 1
+#define LIBXML_XINCLUDE_ENABLED
+#endif
+
+/**
+ * LIBXML_ICONV_ENABLED:
+ *
+ * Whether iconv support is available
+ */
+#if 1
+#define LIBXML_ICONV_ENABLED
+#endif
+
+/**
+ * LIBXML_ICU_ENABLED:
+ *
+ * Whether icu support is available
+ */
+#if 0
+#define LIBXML_ICU_ENABLED
+#endif
+
+/**
+ * LIBXML_ISO8859X_ENABLED:
+ *
+ * Whether ISO-8859-* support is made available in case iconv is not
+ */
+#if 1
+#define LIBXML_ISO8859X_ENABLED
+#endif
+
+/**
+ * LIBXML_DEBUG_ENABLED:
+ *
+ * Whether Debugging module is configured in
+ */
+#if 1
+#define LIBXML_DEBUG_ENABLED
+#endif
+
+/**
+ * LIBXML_UNICODE_ENABLED:
+ *
+ * Removed in 2.14
+ */
+#undef LIBXML_UNICODE_ENABLED
+
+/**
+ * LIBXML_REGEXP_ENABLED:
+ *
+ * Whether the regular expressions interfaces are compiled in
+ */
+#if 1
+#define LIBXML_REGEXP_ENABLED
+#endif
+
+/**
+ * LIBXML_AUTOMATA_ENABLED:
+ *
+ * Whether the automata interfaces are compiled in
+ */
+#if 1
+#define LIBXML_AUTOMATA_ENABLED
+#endif
+
+/**
+ * LIBXML_RELAXNG_ENABLED:
+ *
+ * Whether the RelaxNG validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_RELAXNG_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMAS_ENABLED:
+ *
+ * Whether the Schemas validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMAS_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMATRON_ENABLED:
+ *
+ * Whether the Schematron validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMATRON_ENABLED
+#endif
+
+/**
+ * LIBXML_MODULES_ENABLED:
+ *
+ * Whether the module interfaces are compiled in
+ */
+#if 1
+#define LIBXML_MODULES_ENABLED
+/**
+ * LIBXML_MODULE_EXTENSION:
+ *
+ * the string suffix used by dynamic modules (usually shared libraries)
+ */
+#define LIBXML_MODULE_EXTENSION ".so"
+#endif
+
+/**
+ * LIBXML_ZLIB_ENABLED:
+ *
+ * Whether the Zlib support is compiled in
+ */
+#if 0
+#define LIBXML_ZLIB_ENABLED
+#endif
+
+/**
+ * LIBXML_LZMA_ENABLED:
+ *
+ * Whether the Lzma support is compiled in
+ */
+#if 0
+#define LIBXML_LZMA_ENABLED
+#endif
+
+#include <libxml/xmlexports.h>
+
+#endif
+
+
diff --git a/include/private/io.h b/include/private/io.h
index d6af99f..13aa102 100644
--- a/include/private/io.h
+++ b/include/private/io.h
@@ -35,6 +35,9 @@
XML_HIDDEN xmlParserErrors
xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlParserInputFlags flags);
+XML_HIDDEN int
+xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip);
+
#ifdef LIBXML_OUTPUT_ENABLED
XML_HIDDEN void
xmlOutputBufferWriteQuotedString(xmlOutputBufferPtr buf,
diff --git a/libxml.h b/libxml.h
index f2fcb45..52126fb 100644
--- a/libxml.h
+++ b/libxml.h
@@ -34,6 +34,7 @@
#else
#define XML_HAS_ATTRIBUTE(x) 0
#endif
+#include <libxml/xmlstring.h>
#if __STDC_VERSION__ >= 199901L
#define XML_INLINE inline
diff --git a/parser.c b/parser.c
index d8d590f..bbbd4a8 100644
--- a/parser.c
+++ b/parser.c
@@ -141,6 +141,8 @@
* *
************************************************************************/
+#define XML_MAX_HUGE_LENGTH 1000000000
+
#define XML_PARSER_BIG_ENTITY 1000
#define XML_PARSER_LOT_ENTITY 5000
@@ -14162,6 +14164,7 @@
const char *URL, const char *encoding, int options)
{
xmlParserInputPtr input;
+ int inputFlags;
if (ctxt == NULL)
return(NULL);
diff --git a/parserInternals.c b/parserInternals.c
index af2dfd9..c838ccb 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -331,7 +331,7 @@
if (level == XML_ERR_WARNING) {
if (ctxt->nbWarnings >= XML_MAX_ERRORS)
- return;
+ goto done;
ctxt->nbWarnings += 1;
} else {
/* Report at least one fatal error. */
@@ -389,6 +389,7 @@
return;
}
+done:
if (level >= XML_ERR_ERROR)
ctxt->errNo = code;
if (level == XML_ERR_FATAL) {
@@ -573,6 +574,9 @@
/* Don't grow memory buffers. */
if ((buf->encoder == NULL) && (buf->readcallback == NULL))
return(0);
+ /* Don't grow memory buffers. */
+ if ((buf->encoder == NULL) && (buf->readcallback == NULL))
+ return(0);
if (buf->error != 0)
return(-1);
diff --git a/testparser.c b/testparser.c
index 85fee9b..f8f05d9 100644
--- a/testparser.c
+++ b/testparser.c
@@ -317,6 +317,26 @@
}
#endif
+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) {
diff --git a/tree.c b/tree.c
index 7454b07..e425452 100644
--- a/tree.c
+++ b/tree.c
@@ -4382,6 +4382,8 @@
doc->intSubset = newSubset;
return(ret);
error:
+ if (linkedSubset != 0)
+ xmlUnlinkNode((xmlNodePtr) doc->intSubset);
xmlFreeNodeList(ret);
if (newSubset != NULL)
xmlFreeDtd(newSubset);
diff --git a/xinclude.c b/xinclude.c
index 1508918..be5cec6 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1339,6 +1339,7 @@
done:
#endif
+done:
ret = 0;
error:
diff --git a/xmlIO.c b/xmlIO.c
index 206efa7..d353426 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -1037,6 +1037,97 @@
return(1);
}
+int
+xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
+ int copy;
+
+ (void) unzip;
+
+#ifdef LIBXML_LZMA_ENABLED
+ if (unzip) {
+ xzFile xzStream;
+ off_t pos;
+
+ pos = lseek(fd, 0, SEEK_CUR);
+
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
+
+ xzStream = __libxml2_xzdopen("?", copy, "rb");
+
+ if (xzStream == NULL) {
+ close(copy);
+ } else {
+ if ((__libxml2_xzcompressed(xzStream) > 0) ||
+ /* Try to rewind if not gzip compressed */
+ (pos < 0) ||
+ (lseek(fd, pos, SEEK_SET) < 0)) {
+ /*
+ * If a file isn't seekable, we pipe uncompressed
+ * input through xzlib.
+ */
+ buf->context = xzStream;
+ buf->readcallback = xmlXzfileRead;
+ buf->closecallback = xmlXzfileClose;
+ buf->compressed = 1;
+
+ return(XML_ERR_OK);
+ }
+
+ xmlXzfileClose(xzStream);
+ }
+ }
+#endif /* LIBXML_LZMA_ENABLED */
+
+#ifdef LIBXML_ZLIB_ENABLED
+ if (unzip) {
+ gzFile gzStream;
+ off_t pos;
+
+ pos = lseek(fd, 0, SEEK_CUR);
+
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
+
+ gzStream = gzdopen(copy, "rb");
+
+ if (gzStream == NULL) {
+ close(copy);
+ } else {
+ if ((gzdirect(gzStream) == 0) ||
+ /* Try to rewind if not gzip compressed */
+ (pos < 0) ||
+ (lseek(fd, pos, SEEK_SET) < 0)) {
+ /*
+ * If a file isn't seekable, we pipe uncompressed
+ * input through zlib.
+ */
+ buf->context = gzStream;
+ buf->readcallback = xmlGzfileRead;
+ buf->closecallback = xmlGzfileClose;
+ buf->compressed = 1;
+
+ return(XML_ERR_OK);
+ }
+
+ xmlGzfileClose(gzStream);
+ }
+ }
+#endif /* LIBXML_ZLIB_ENABLED */
+
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
+
+ buf->context = (void *) (ptrdiff_t) copy;
+ buf->readcallback = xmlFdRead;
+ buf->closecallback = xmlFdClose;
+
+ return(XML_ERR_OK);
+}
+
/**
* xmlInputFromFd:
* @buf: parser input buffer
diff --git a/xmllint.c b/xmllint.c
index 19f3116..4e39511 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -91,6 +91,9 @@
/* Internal parser option */
#define XML_PARSE_UNZIP (1 << 24)
+/* Internal parser option */
+#define XML_PARSE_UNZIP (1 << 24)
+
typedef enum {
XMLLINT_RETURN_OK = 0, /* No error */
XMLLINT_ERR_UNCLASS = 1, /* Unclassified */