[LIBXML2] Update to version 2.9.8. CORE-15280

This commit is contained in:
Thomas Faber 2018-12-01 11:57:57 +01:00
parent 61fed54064
commit 5bb277a54b
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
37 changed files with 545 additions and 493 deletions

View file

@ -129,9 +129,14 @@ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
* If iconv is supported, there are two extra fields. * If iconv is supported, there are two extra fields.
*/ */
#ifdef LIBXML_ICU_ENABLED #ifdef LIBXML_ICU_ENABLED
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
#define ICU_PIVOT_BUF_SIZE 1024
struct _uconv_t { struct _uconv_t {
UConverter *uconv; /* for conversion between an encoding and UTF-16 */ UConverter *uconv; /* for conversion between an encoding and UTF-16 */
UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
UChar *pivot_source;
UChar *pivot_target;
}; };
typedef struct _uconv_t uconv_t; typedef struct _uconv_t uconv_t;
#endif #endif

View file

@ -66,7 +66,7 @@ extern "C" {
* *
* Callback to free data from a hash. * Callback to free data from a hash.
*/ */
typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name); typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
/** /**
* xmlHashCopier: * xmlHashCopier:
* @payload: the data in the hash * @payload: the data in the hash
@ -76,7 +76,7 @@ typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
* *
* Returns a copy of the data or NULL in case of error. * Returns a copy of the data or NULL in case of error.
*/ */
typedef void *(*xmlHashCopier)(void *payload, xmlChar *name); typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);
/** /**
* xmlHashScanner: * xmlHashScanner:
* @payload: the data in the hash * @payload: the data in the hash
@ -85,7 +85,7 @@ typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
* *
* Callback when scanning data in a hash with the simple scanner. * Callback when scanning data in a hash with the simple scanner.
*/ */
typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name); typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);
/** /**
* xmlHashScannerFull: * xmlHashScannerFull:
* @payload: the data in the hash * @payload: the data in the hash
@ -111,6 +111,9 @@ XMLPUBFUN xmlHashTablePtr XMLCALL
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlHashFree (xmlHashTablePtr table, xmlHashFree (xmlHashTablePtr table,
xmlHashDeallocator f); xmlHashDeallocator f);
XMLPUBFUN void XMLCALL
xmlHashDefaultDeallocator(void *entry,
const xmlChar *name);
/* /*
* Add a new entry to the hash table. * Add a new entry to the hash table.

View file

@ -49,7 +49,7 @@ typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
* *
* Returns 0 to stop walking the list, 1 otherwise. * Returns 0 to stop walking the list, 1 otherwise.
*/ */
typedef int (*xmlListWalker) (const void *data, const void *user); typedef int (*xmlListWalker) (const void *data, void *user);
/* Creation/Deletion */ /* Creation/Deletion */
XMLPUBFUN xmlListPtr XMLCALL XMLPUBFUN xmlListPtr XMLCALL
@ -110,11 +110,11 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlListWalk (xmlListPtr l, xmlListWalk (xmlListPtr l,
xmlListWalker walker, xmlListWalker walker,
const void *user); void *user);
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlListReverseWalk (xmlListPtr l, xmlListReverseWalk (xmlListPtr l,
xmlListWalker walker, xmlListWalker walker,
const void *user); void *user);
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlListMerge (xmlListPtr l1, xmlListMerge (xmlListPtr l1,
xmlListPtr l2); xmlListPtr l2);

View file

@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* *
* the version string like "1.2.3" * the version string like "1.2.3"
*/ */
#define LIBXML_DOTTED_VERSION "2.9.7" #define LIBXML_DOTTED_VERSION "2.9.8"
/** /**
* LIBXML_VERSION: * LIBXML_VERSION:
* *
* the version number: 1.2.3 value is 10203 * the version number: 1.2.3 value is 10203
*/ */
#define LIBXML_VERSION 20907 #define LIBXML_VERSION 20908
/** /**
* LIBXML_VERSION_STRING: * LIBXML_VERSION_STRING:
* *
* the version number string, 1.2.3 value is "10203" * the version number string, 1.2.3 value is "10203"
*/ */
#define LIBXML_VERSION_STRING "20907" #define LIBXML_VERSION_STRING "20908"
/** /**
* LIBXML_VERSION_EXTRA: * LIBXML_VERSION_EXTRA:
* *
* extra version information, used to show a CVS compilation * extra version information, used to show a CVS compilation
*/ */
#define LIBXML_VERSION_EXTRA "-GITv2.9.7-rc1" #define LIBXML_VERSION_EXTRA "-GITv2.9.8-rc1-2-gd910e99c3"
/** /**
* LIBXML_TEST_VERSION: * LIBXML_TEST_VERSION:
@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro to check that the libxml version in use is compatible with * Macro to check that the libxml version in use is compatible with
* the version the software has been compiled against * the version the software has been compiled against
*/ */
#define LIBXML_TEST_VERSION xmlCheckVersion(20907); #define LIBXML_TEST_VERSION xmlCheckVersion(20908);
#ifndef VMS #ifndef VMS
#if 0 #if 0
@ -410,9 +410,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
/** /**
* ATTRIBUTE_UNUSED: * ATTRIBUTE_UNUSED:

View file

@ -410,9 +410,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
/** /**
* ATTRIBUTE_UNUSED: * ATTRIBUTE_UNUSED:

View file

@ -26,7 +26,7 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif
@ -3635,7 +3635,7 @@ htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
*/ */
processed = ctxt->input->cur - ctxt->input->base; processed = ctxt->input->cur - ctxt->input->base;
xmlBufShrink(ctxt->input->buf->buffer, processed); xmlBufShrink(ctxt->input->buf->buffer, processed);
nbchars = xmlCharEncInput(ctxt->input->buf, 1); nbchars = xmlCharEncInput(ctxt->input->buf, 0);
if (nbchars < 0) { if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING, htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"htmlCheckEncoding: encoder error\n", "htmlCheckEncoding: encoder error\n",
@ -6674,7 +6674,7 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
xmlInitNodeInfoSeq(&ctxt->node_seq); xmlInitNodeInfoSeq(&ctxt->node_seq);
if (ctxt->attsDefault != NULL) { if (ctxt->attsDefault != NULL) {
xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree); xmlHashFree(ctxt->attsDefault, xmlHashDefaultDeallocator);
ctxt->attsDefault = NULL; ctxt->attsDefault = NULL;
} }
if (ctxt->attsSpecial != NULL) { if (ctxt->attsSpecial != NULL) {

View file

@ -89,7 +89,7 @@ static int xmlExcC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur,
xmlNsPtr ns, xmlNsPtr ns,
xmlC14NCtxPtr ctx); xmlC14NCtxPtr ctx);
static int xmlC14NIsNodeInNodeset (xmlNodeSetPtr nodes, static int xmlC14NIsNodeInNodeset (void *user_data,
xmlNodePtr node, xmlNodePtr node,
xmlNodePtr parent); xmlNodePtr parent);
@ -252,7 +252,8 @@ xmlC14NErr(xmlC14NCtxPtr ctxt, xmlNodePtr node, int error,
#define XML_NAMESPACES_DEFAULT 16 #define XML_NAMESPACES_DEFAULT 16
static int static int
xmlC14NIsNodeInNodeset(xmlNodeSetPtr nodes, xmlNodePtr node, xmlNodePtr parent) { xmlC14NIsNodeInNodeset(void *user_data, xmlNodePtr node, xmlNodePtr parent) {
xmlNodeSetPtr nodes = (xmlNodeSetPtr) user_data;
if((nodes != NULL) && (node != NULL)) { if((nodes != NULL) && (node != NULL)) {
if(node->type != XML_NAMESPACE_DECL) { if(node->type != XML_NAMESPACE_DECL) {
return(xmlXPathNodeSetContains(nodes, node)); return(xmlXPathNodeSetContains(nodes, node));
@ -513,8 +514,10 @@ xmlC14NIsXmlNs(xmlNsPtr ns)
* Returns -1 if ns1 < ns2, 0 if ns1 == ns2 or 1 if ns1 > ns2. * Returns -1 if ns1 < ns2, 0 if ns1 == ns2 or 1 if ns1 > ns2.
*/ */
static int static int
xmlC14NNsCompare(xmlNsPtr ns1, xmlNsPtr ns2) xmlC14NNsCompare(const void *data1, const void *data2)
{ {
const xmlNsPtr ns1 = (const xmlNsPtr) data1;
const xmlNsPtr ns2 = (const xmlNsPtr) data2;
if (ns1 == ns2) if (ns1 == ns2)
return (0); return (0);
if (ns1 == NULL) if (ns1 == NULL)
@ -559,6 +562,11 @@ xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx)
return (1); return (1);
} }
static int
xmlC14NPrintNamespacesWalker(const void *ns, void *ctx) {
return xmlC14NPrintNamespaces((const xmlNsPtr) ns, (xmlC14NCtxPtr) ctx);
}
/** /**
* xmlC14NProcessNamespacesAxis: * xmlC14NProcessNamespacesAxis:
* @ctx: the C14N context * @ctx: the C14N context
@ -615,7 +623,7 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/* /*
* Create a sorted list to store element namespaces * Create a sorted list to store element namespaces
*/ */
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare); list = xmlListCreate(NULL, xmlC14NNsCompare);
if (list == NULL) { if (list == NULL) {
xmlC14NErrInternal("creating namespaces list (c14n)"); xmlC14NErrInternal("creating namespaces list (c14n)");
return (-1); return (-1);
@ -663,7 +671,7 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/* /*
* print out all elements from list * print out all elements from list
*/ */
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx); xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
/* /*
* Cleanup * Cleanup
@ -728,7 +736,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/* /*
* Create a sorted list to store element namespaces * Create a sorted list to store element namespaces
*/ */
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare); list = xmlListCreate(NULL, xmlC14NNsCompare);
if (list == NULL) { if (list == NULL) {
xmlC14NErrInternal("creating namespaces list (exc c14n)"); xmlC14NErrInternal("creating namespaces list (exc c14n)");
return (-1); return (-1);
@ -840,7 +848,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/* /*
* print out all elements from list * print out all elements from list
*/ */
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx); xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
/* /*
* Cleanup * Cleanup
@ -879,8 +887,10 @@ xmlC14NIsXmlAttr(xmlAttrPtr attr)
* Returns -1 if attr1 < attr2, 0 if attr1 == attr2 or 1 if attr1 > attr2. * Returns -1 if attr1 < attr2, 0 if attr1 == attr2 or 1 if attr1 > attr2.
*/ */
static int static int
xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2) xmlC14NAttrsCompare(const void *data1, const void *data2)
{ {
const xmlAttrPtr attr1 = (const xmlAttrPtr) data1;
const xmlAttrPtr attr2 = (const xmlAttrPtr) data2;
int ret = 0; int ret = 0;
/* /*
@ -931,8 +941,10 @@ xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
* Returns 1 on success or 0 on fail. * Returns 1 on success or 0 on fail.
*/ */
static int static int
xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx) xmlC14NPrintAttrs(const void *data, void *user)
{ {
const xmlAttrPtr attr = (const xmlAttrPtr) data;
xmlC14NCtxPtr ctx = (xmlC14NCtxPtr) user;
xmlChar *value; xmlChar *value;
xmlChar *buffer; xmlChar *buffer;
@ -1142,7 +1154,7 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
/* /*
* Create a sorted list to store element attributes * Create a sorted list to store element attributes
*/ */
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NAttrsCompare); list = xmlListCreate(NULL, xmlC14NAttrsCompare);
if (list == NULL) { if (list == NULL) {
xmlC14NErrInternal("creating attributes list"); xmlC14NErrInternal("creating attributes list");
return (-1); return (-1);
@ -1331,7 +1343,7 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
/* /*
* print out all elements from list * print out all elements from list
*/ */
xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx); xmlListWalk(list, xmlC14NPrintAttrs, (void *) ctx);
/* /*
* Cleanup * Cleanup
@ -1964,7 +1976,7 @@ xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
int mode, xmlChar ** inclusive_ns_prefixes, int mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf) { int with_comments, xmlOutputBufferPtr buf) {
return(xmlC14NExecute(doc, return(xmlC14NExecute(doc,
(xmlC14NIsVisibleCallback)xmlC14NIsNodeInNodeset, xmlC14NIsNodeInNodeset,
nodes, nodes,
mode, mode,
inclusive_ns_prefixes, inclusive_ns_prefixes,
@ -2077,7 +2089,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
xmlC14NErrParam("saving doc"); xmlC14NErrParam("saving doc");
return (-1); return (-1);
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (compression < 0) if (compression < 0)
compression = xmlGetCompressMode(); compression = xmlGetCompressMode();
#endif #endif

View file

@ -319,12 +319,13 @@ xmlFreeCatalogEntryList(xmlCatalogEntryPtr ret);
/** /**
* xmlFreeCatalogEntry: * xmlFreeCatalogEntry:
* @ret: a Catalog entry * @payload: a Catalog entry
* *
* Free the memory allocated to a Catalog entry * Free the memory allocated to a Catalog entry
*/ */
static void static void
xmlFreeCatalogEntry(xmlCatalogEntryPtr ret) { xmlFreeCatalogEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlCatalogEntryPtr ret = (xmlCatalogEntryPtr) payload;
if (ret == NULL) if (ret == NULL)
return; return;
/* /*
@ -367,20 +368,22 @@ xmlFreeCatalogEntryList(xmlCatalogEntryPtr ret) {
while (ret != NULL) { while (ret != NULL) {
next = ret->next; next = ret->next;
xmlFreeCatalogEntry(ret); xmlFreeCatalogEntry(ret, NULL);
ret = next; ret = next;
} }
} }
/** /**
* xmlFreeCatalogHashEntryList: * xmlFreeCatalogHashEntryList:
* @ret: a Catalog entry list * @payload: a Catalog entry list
* *
* Free the memory allocated to list of Catalog entries from the * Free the memory allocated to list of Catalog entries from the
* catalog file hash. * catalog file hash.
*/ */
static void static void
xmlFreeCatalogHashEntryList(xmlCatalogEntryPtr catal) { xmlFreeCatalogHashEntryList(void *payload,
const xmlChar *name ATTRIBUTE_UNUSED) {
xmlCatalogEntryPtr catal = (xmlCatalogEntryPtr) payload;
xmlCatalogEntryPtr children, next; xmlCatalogEntryPtr children, next;
if (catal == NULL) if (catal == NULL)
@ -391,11 +394,11 @@ xmlFreeCatalogHashEntryList(xmlCatalogEntryPtr catal) {
next = children->next; next = children->next;
children->dealloc = 0; children->dealloc = 0;
children->children = NULL; children->children = NULL;
xmlFreeCatalogEntry(children); xmlFreeCatalogEntry(children, NULL);
children = next; children = next;
} }
catal->dealloc = 0; catal->dealloc = 0;
xmlFreeCatalogEntry(catal); xmlFreeCatalogEntry(catal, NULL);
} }
/** /**
@ -440,8 +443,7 @@ xmlFreeCatalog(xmlCatalogPtr catal) {
if (catal->xml != NULL) if (catal->xml != NULL)
xmlFreeCatalogEntryList(catal->xml); xmlFreeCatalogEntryList(catal->xml);
if (catal->sgml != NULL) if (catal->sgml != NULL)
xmlHashFree(catal->sgml, xmlHashFree(catal->sgml, xmlFreeCatalogEntry);
(xmlHashDeallocator) xmlFreeCatalogEntry);
xmlFree(catal); xmlFree(catal);
} }
@ -460,7 +462,10 @@ xmlFreeCatalog(xmlCatalogPtr catal) {
* Serialize an SGML Catalog entry * Serialize an SGML Catalog entry
*/ */
static void static void
xmlCatalogDumpEntry(xmlCatalogEntryPtr entry, FILE *out) { xmlCatalogDumpEntry(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED) {
xmlCatalogEntryPtr entry = (xmlCatalogEntryPtr) payload;
FILE *out = (FILE *) data;
if ((entry == NULL) || (out == NULL)) if ((entry == NULL) || (out == NULL))
return; return;
switch (entry->type) { switch (entry->type) {
@ -723,7 +728,10 @@ BAD_CAST "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd");
* Convert one entry from the catalog * Convert one entry from the catalog
*/ */
static void static void
xmlCatalogConvertEntry(xmlCatalogEntryPtr entry, xmlCatalogPtr catal) { xmlCatalogConvertEntry(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED) {
xmlCatalogEntryPtr entry = (xmlCatalogEntryPtr) payload;
xmlCatalogPtr catal = (xmlCatalogPtr) data;
if ((entry == NULL) || (catal == NULL) || (catal->sgml == NULL) || if ((entry == NULL) || (catal == NULL) || (catal->sgml == NULL) ||
(catal->xml == NULL)) (catal->xml == NULL))
return; return;
@ -756,8 +764,7 @@ xmlCatalogConvertEntry(xmlCatalogEntryPtr entry, xmlCatalogPtr catal) {
entry->type = XML_CATA_CATALOG; entry->type = XML_CATA_CATALOG;
break; break;
default: default:
xmlHashRemoveEntry(catal->sgml, entry->name, xmlHashRemoveEntry(catal->sgml, entry->name, xmlFreeCatalogEntry);
(xmlHashDeallocator) xmlFreeCatalogEntry);
return; return;
} }
/* /*
@ -797,9 +804,7 @@ xmlConvertSGMLCatalog(xmlCatalogPtr catal) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"Converting SGML catalog to XML\n"); "Converting SGML catalog to XML\n");
} }
xmlHashScan(catal->sgml, xmlHashScan(catal->sgml, xmlCatalogConvertEntry, &catal);
(xmlHashScanner) xmlCatalogConvertEntry,
&catal);
return(0); return(0);
} }
@ -2486,7 +2491,7 @@ xmlParseSGMLCatalog(xmlCatalogPtr catal, const xmlChar *value,
NULL, XML_CATA_PREFER_NONE, NULL); NULL, XML_CATA_PREFER_NONE, NULL);
res = xmlHashAddEntry(catal->sgml, name, entry); res = xmlHashAddEntry(catal->sgml, name, entry);
if (res < 0) { if (res < 0) {
xmlFreeCatalogEntry(entry); xmlFreeCatalogEntry(entry, NULL);
} }
xmlFree(filename); xmlFree(filename);
} }
@ -2499,7 +2504,7 @@ xmlParseSGMLCatalog(xmlCatalogPtr catal, const xmlChar *value,
XML_CATA_PREFER_NONE, NULL); XML_CATA_PREFER_NONE, NULL);
res = xmlHashAddEntry(catal->sgml, sysid, entry); res = xmlHashAddEntry(catal->sgml, sysid, entry);
if (res < 0) { if (res < 0) {
xmlFreeCatalogEntry(entry); xmlFreeCatalogEntry(entry, NULL);
} }
} else { } else {
xmlChar *filename; xmlChar *filename;
@ -2937,8 +2942,7 @@ xmlACatalogDump(xmlCatalogPtr catal, FILE *out) {
if (catal->type == XML_XML_CATALOG_TYPE) { if (catal->type == XML_XML_CATALOG_TYPE) {
xmlDumpXMLCatalog(out, catal->xml); xmlDumpXMLCatalog(out, catal->xml);
} else { } else {
xmlHashScan(catal->sgml, xmlHashScan(catal->sgml, xmlCatalogDumpEntry, out);
(xmlHashScanner) xmlCatalogDumpEntry, out);
} }
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
@ -3002,8 +3006,7 @@ xmlACatalogRemove(xmlCatalogPtr catal, const xmlChar *value) {
if (catal->type == XML_XML_CATALOG_TYPE) { if (catal->type == XML_XML_CATALOG_TYPE) {
res = xmlDelXMLCatalog(catal->xml, value); res = xmlDelXMLCatalog(catal->xml, value);
} else { } else {
res = xmlHashRemoveEntry(catal->sgml, value, res = xmlHashRemoveEntry(catal->sgml, value, xmlFreeCatalogEntry);
(xmlHashDeallocator) xmlFreeCatalogEntry);
if (res == 0) if (res == 0)
res = 1; res = 1;
} }
@ -3284,8 +3287,7 @@ xmlCatalogCleanup(void) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"Catalogs cleanup\n"); "Catalogs cleanup\n");
if (xmlCatalogXMLFiles != NULL) if (xmlCatalogXMLFiles != NULL)
xmlHashFree(xmlCatalogXMLFiles, xmlHashFree(xmlCatalogXMLFiles, xmlFreeCatalogHashEntryList);
(xmlHashDeallocator)xmlFreeCatalogHashEntryList);
xmlCatalogXMLFiles = NULL; xmlCatalogXMLFiles = NULL;
if (xmlDefaultCatalog != NULL) if (xmlDefaultCatalog != NULL)
xmlFreeCatalog(xmlDefaultCatalog); xmlFreeCatalog(xmlDefaultCatalog);

View file

@ -4,9 +4,6 @@
/* Type cast for the gethostbyname() argument */ /* Type cast for the gethostbyname() argument */
#define GETHOSTBYNAME_ARG_CAST #define GETHOSTBYNAME_ARG_CAST
/* Define to 1 if you have the <ansidecl.h> header file. */
/* #undef HAVE_ANSIDECL_H */
/* Define to 1 if you have the <arpa/inet.h> header file. */ /* Define to 1 if you have the <arpa/inet.h> header file. */
/* #undef HAVE_ARPA_INET_H */ /* #undef HAVE_ARPA_INET_H */
@ -16,9 +13,6 @@
/* Whether struct sockaddr::__ss_family exists */ /* Whether struct sockaddr::__ss_family exists */
/* #undef HAVE_BROKEN_SS_FAMILY */ /* #undef HAVE_BROKEN_SS_FAMILY */
/* Define to 1 if you have the `class' function. */
/* #undef HAVE_CLASS */
/* Define to 1 if you have the <ctype.h> header file. */ /* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1 #define HAVE_CTYPE_H 1
@ -40,24 +34,12 @@
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1 #define HAVE_FCNTL_H 1
/* Define to 1 if you have the `finite' function. */
#define HAVE_FINITE 1
/* Define to 1 if you have the <float.h> header file. */ /* Define to 1 if you have the <float.h> header file. */
#define HAVE_FLOAT_H 1 #define HAVE_FLOAT_H 1
/* Define to 1 if you have the `fpclass' function. */
#define HAVE_FPCLASS 1
/* Define to 1 if you have the `fprintf' function. */ /* Define to 1 if you have the `fprintf' function. */
#define HAVE_FPRINTF 1 #define HAVE_FPRINTF 1
/* Define to 1 if you have the `fp_class' function. */
/* #undef HAVE_FP_CLASS */
/* Define to 1 if you have the <fp_class.h> header file. */
/* #undef HAVE_FP_CLASS_H */
/* Define to 1 if you have the `ftime' function. */ /* Define to 1 if you have the `ftime' function. */
#define HAVE_FTIME 1 #define HAVE_FTIME 1
@ -67,9 +49,6 @@
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
/* #undef HAVE_GETTIMEOFDAY */ /* #undef HAVE_GETTIMEOFDAY */
/* Define to 1 if you have the <ieeefp.h> header file. */
/* #undef HAVE_IEEEFP_H */
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1 #define HAVE_INTTYPES_H 1
@ -82,24 +61,15 @@
/* Define if isnan is there */ /* Define if isnan is there */
#define HAVE_ISNAN /**/ #define HAVE_ISNAN /**/
/* Define to 1 if you have the `isnand' function. */
/* #undef HAVE_ISNAND */
/* Define if history library is there (-lhistory) */ /* Define if history library is there (-lhistory) */
/* #undef HAVE_LIBHISTORY */ /* #undef HAVE_LIBHISTORY */
/* Have compression library */
/* #undef HAVE_LIBLZMA */
/* Define if pthread library is there (-lpthread) */ /* Define if pthread library is there (-lpthread) */
/* #undef HAVE_LIBPTHREAD */ /* #undef HAVE_LIBPTHREAD */
/* Define if readline library is there (-lreadline) */ /* Define if readline library is there (-lreadline) */
/* #undef HAVE_LIBREADLINE */ /* #undef HAVE_LIBREADLINE */
/* Have compression library */
/* #undef HAVE_LIBZ */
/* Define to 1 if you have the <limits.h> header file. */ /* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
@ -129,9 +99,6 @@
# undef /**/ HAVE_MMAP # undef /**/ HAVE_MMAP
#endif #endif
/* Define to 1 if you have the <nan.h> header file. */
/* #undef HAVE_NAN_H */
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */ /* #undef HAVE_NDIR_H */
@ -195,12 +162,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1 #define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the `strftime' function. */ /* Define to 1 if you have the `strftime' function. */
#define HAVE_STRFTIME 1 #define HAVE_STRFTIME 1
@ -210,9 +171,6 @@
/* Define to 1 if you have the <string.h> header file. */ /* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
/* Define to 1 if you have the `strndup' function. */
/* #undef HAVE_STRNDUP */
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/ */
/* #undef HAVE_SYS_DIR_H */ /* #undef HAVE_SYS_DIR_H */
@ -266,9 +224,6 @@
/* Define to 1 if you have the <zlib.h> header file. */ /* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1 #define HAVE_ZLIB_H 1
/* Define to 1 if you have the `_stat' function. */
#define HAVE__STAT 1
/* Whether __va_copy() is available */ /* Whether __va_copy() is available */
#define HAVE___VA_COPY 1 #define HAVE___VA_COPY 1
@ -312,7 +267,7 @@
/* #undef VA_LIST_IS_ARRAY */ /* #undef VA_LIST_IS_ARRAY */
/* Version number of package */ /* Version number of package */
#define VERSION "2.9.2" #define VERSION "2.9.8"
/* Determine what socket length (socklen_t) data type is */ /* Determine what socket length (socklen_t) data type is */
#define XML_SOCKLEN_T int #define XML_SOCKLEN_T int

View file

@ -1229,8 +1229,11 @@ xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
} }
static void static void
xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt) xmlCtxtDumpEntityCallback(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED)
{ {
xmlEntityPtr cur = (xmlEntityPtr) payload;
xmlDebugCtxtPtr ctxt = (xmlDebugCtxtPtr) data;
if (cur == NULL) { if (cur == NULL) {
if (!ctxt->check) if (!ctxt->check)
fprintf(ctxt->output, "Entity is NULL"); fprintf(ctxt->output, "Entity is NULL");
@ -1289,8 +1292,7 @@ xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
if (!ctxt->check) if (!ctxt->check)
fprintf(ctxt->output, "Entities in internal subset\n"); fprintf(ctxt->output, "Entities in internal subset\n");
xmlHashScan(table, (xmlHashScanner) xmlCtxtDumpEntityCallback, xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
ctxt);
} else } else
fprintf(ctxt->output, "No entities in internal subset\n"); fprintf(ctxt->output, "No entities in internal subset\n");
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) { if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
@ -1299,8 +1301,7 @@ xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
if (!ctxt->check) if (!ctxt->check)
fprintf(ctxt->output, "Entities in external subset\n"); fprintf(ctxt->output, "Entities in external subset\n");
xmlHashScan(table, (xmlHashScanner) xmlCtxtDumpEntityCallback, xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
ctxt);
} else if (!ctxt->check) } else if (!ctxt->check)
fprintf(ctxt->output, "No entities in external subset\n"); fprintf(ctxt->output, "No entities in external subset\n");
} }

View file

@ -110,6 +110,9 @@ openIcuConverter(const char* name, int toUnicode)
if (conv == NULL) if (conv == NULL)
return NULL; return NULL;
conv->pivot_source = conv->pivot_buf;
conv->pivot_target = conv->pivot_buf;
conv->uconv = ucnv_open(name, &status); conv->uconv = ucnv_open(name, &status);
if (U_FAILURE(status)) if (U_FAILURE(status))
goto error; goto error;
@ -1850,6 +1853,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
* @outlen: the length of @out * @outlen: the length of @out
* @in: a pointer to an array of ISO Latin 1 chars * @in: a pointer to an array of ISO Latin 1 chars
* @inlen: the length of @in * @inlen: the length of @in
* @flush: if true, indicates end of input
* *
* Returns 0 if success, or * Returns 0 if success, or
* -1 by lack of space, or * -1 by lack of space, or
@ -1863,7 +1867,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
*/ */
static int static int
xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen, xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen) { const unsigned char *in, int *inlen, int flush) {
const char *ucv_in = (const char *) in; const char *ucv_in = (const char *) in;
char *ucv_out = (char *) out; char *ucv_out = (char *) out;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
@ -1873,33 +1877,31 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
return(-1); return(-1);
} }
/*
* TODO(jungshik)
* 1. is ucnv_convert(To|From)Algorithmic better?
* 2. had we better use an explicit pivot buffer?
* 3. error returned comes from 'fromUnicode' only even
* when toUnicode is true !
*/
if (toUnicode) { if (toUnicode) {
/* encoding => UTF-16 => UTF-8 */ /* encoding => UTF-16 => UTF-8 */
ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen, ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
&ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL, &ucv_in, ucv_in + *inlen, cd->pivot_buf,
0, TRUE, &err); &cd->pivot_source, &cd->pivot_target,
cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
} else { } else {
/* UTF-8 => UTF-16 => encoding */ /* UTF-8 => UTF-16 => encoding */
ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen, ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
&ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL, &ucv_in, ucv_in + *inlen, cd->pivot_buf,
0, TRUE, &err); &cd->pivot_source, &cd->pivot_target,
cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err);
} }
*inlen = ucv_in - (const char*) in; *inlen = ucv_in - (const char*) in;
*outlen = ucv_out - (char *) out; *outlen = ucv_out - (char *) out;
if (U_SUCCESS(err)) 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 0;
}
if (err == U_BUFFER_OVERFLOW_ERROR) if (err == U_BUFFER_OVERFLOW_ERROR)
return -1; return -1;
if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND) if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
return -2; return -2;
/* if (err == U_TRUNCATED_CHAR_FOUND) */
return -3; return -3;
} }
#endif /* LIBXML_ICU_ENABLED */ #endif /* LIBXML_ICU_ENABLED */
@ -1912,8 +1914,9 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
static int static int
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen) { int *outlen, const unsigned char *in, int *inlen, int flush) {
int ret; int ret;
(void)flush;
if (handler->input != NULL) { if (handler->input != NULL) {
ret = handler->input(out, outlen, in, inlen); ret = handler->input(out, outlen, in, inlen);
@ -1925,7 +1928,8 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
#endif /* LIBXML_ICONV_ENABLED */ #endif /* LIBXML_ICONV_ENABLED */
#ifdef LIBXML_ICU_ENABLED #ifdef LIBXML_ICU_ENABLED
else if (handler->uconv_in != NULL) { else if (handler->uconv_in != NULL) {
ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen); ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen,
flush);
} }
#endif /* LIBXML_ICU_ENABLED */ #endif /* LIBXML_ICU_ENABLED */
else { else {
@ -1953,7 +1957,8 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
#endif /* LIBXML_ICONV_ENABLED */ #endif /* LIBXML_ICONV_ENABLED */
#ifdef LIBXML_ICU_ENABLED #ifdef LIBXML_ICU_ENABLED
else if (handler->uconv_out != NULL) { else if (handler->uconv_out != NULL) {
ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen); ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen,
TRUE);
} }
#endif /* LIBXML_ICU_ENABLED */ #endif /* LIBXML_ICU_ENABLED */
else { else {
@ -2015,7 +2020,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
} }
ret = xmlEncInputChunk(handler, &out->content[out->use], &written, ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
in->content, &toconv); in->content, &toconv, 0);
xmlBufferShrink(in, toconv); xmlBufferShrink(in, toconv);
out->use += written; out->use += written;
out->content[out->use] = 0; out->content[out->use] = 0;
@ -2133,7 +2138,7 @@ xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
c_in = toconv; c_in = toconv;
c_out = written; c_out = written;
ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out, ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
xmlBufContent(in), &c_in); xmlBufContent(in), &c_in, 0);
xmlBufShrink(in, c_in); xmlBufShrink(in, c_in);
xmlBufAddLen(out, c_out); xmlBufAddLen(out, c_out);
if (ret == -1) if (ret == -1)
@ -2231,7 +2236,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
c_in = toconv; c_in = toconv;
c_out = written; c_out = written;
ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out, ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
xmlBufContent(in), &c_in); xmlBufContent(in), &c_in, flush);
xmlBufShrink(in, c_in); xmlBufShrink(in, c_in);
xmlBufAddLen(out, c_out); xmlBufAddLen(out, c_out);
if (ret == -1) if (ret == -1)
@ -2317,7 +2322,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
written = out->size - out->use - 1; written = out->size - out->use - 1;
} }
ret = xmlEncInputChunk(handler, &out->content[out->use], &written, ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
in->content, &toconv); in->content, &toconv, 1);
xmlBufferShrink(in, toconv); xmlBufferShrink(in, toconv);
out->use += written; out->use += written;
out->content[out->use] = 0; out->content[out->use] = 0;

View file

@ -885,10 +885,9 @@ xmlCreateEntitiesTable(void) {
* Deallocate the memory used by an entities in the hash table. * Deallocate the memory used by an entities in the hash table.
*/ */
static void static void
xmlFreeEntityWrapper(xmlEntityPtr entity, xmlFreeEntityWrapper(void *entity, const xmlChar *name ATTRIBUTE_UNUSED) {
const xmlChar *name ATTRIBUTE_UNUSED) {
if (entity != NULL) if (entity != NULL)
xmlFreeEntity(entity); xmlFreeEntity((xmlEntityPtr) entity);
} }
/** /**
@ -899,7 +898,7 @@ xmlFreeEntityWrapper(xmlEntityPtr entity,
*/ */
void void
xmlFreeEntitiesTable(xmlEntitiesTablePtr table) { xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeEntityWrapper); xmlHashFree(table, xmlFreeEntityWrapper);
} }
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
@ -911,8 +910,9 @@ xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
* *
* Returns the new xmlEntitiesPtr or NULL in case of error. * Returns the new xmlEntitiesPtr or NULL in case of error.
*/ */
static xmlEntityPtr static void *
xmlCopyEntity(xmlEntityPtr ent) { xmlCopyEntity(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlEntityPtr ent = (xmlEntityPtr) payload;
xmlEntityPtr cur; xmlEntityPtr cur;
cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity)); cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
@ -949,7 +949,7 @@ xmlCopyEntity(xmlEntityPtr ent) {
*/ */
xmlEntitiesTablePtr xmlEntitiesTablePtr
xmlCopyEntitiesTable(xmlEntitiesTablePtr table) { xmlCopyEntitiesTable(xmlEntitiesTablePtr table) {
return(xmlHashCopy(table, (xmlHashCopier) xmlCopyEntity)); return(xmlHashCopy(table, xmlCopyEntity));
} }
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
@ -1090,8 +1090,9 @@ xmlDumpEntityDecl(xmlBufferPtr buf, xmlEntityPtr ent) {
* When using the hash table scan function, arguments need to be reversed * When using the hash table scan function, arguments need to be reversed
*/ */
static void static void
xmlDumpEntityDeclScan(xmlEntityPtr ent, xmlBufferPtr buf) { xmlDumpEntityDeclScan(void *ent, void *buf,
xmlDumpEntityDecl(buf, ent); const xmlChar *name ATTRIBUTE_UNUSED) {
xmlDumpEntityDecl((xmlBufferPtr) buf, (xmlEntityPtr) ent);
} }
/** /**
@ -1103,7 +1104,7 @@ xmlDumpEntityDeclScan(xmlEntityPtr ent, xmlBufferPtr buf) {
*/ */
void void
xmlDumpEntitiesTable(xmlBufferPtr buf, xmlEntitiesTablePtr table) { xmlDumpEntitiesTable(xmlBufferPtr buf, xmlEntitiesTablePtr table) {
xmlHashScan(table, (xmlHashScanner)xmlDumpEntityDeclScan, buf); xmlHashScan(table, xmlDumpEntityDeclScan, buf);
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
#define bottom_entities #define bottom_entities

View file

@ -92,7 +92,7 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
* *
* The variable holding the libxml free() implementation * The variable holding the libxml free() implementation
*/ */
xmlFreeFunc xmlFree = (xmlFreeFunc) free; xmlFreeFunc xmlFree = free;
/** /**
* xmlMalloc: * xmlMalloc:
* @size: the size requested in bytes * @size: the size requested in bytes
@ -101,7 +101,7 @@ xmlFreeFunc xmlFree = (xmlFreeFunc) free;
* *
* Returns a pointer to the newly allocated block or NULL in case of error * Returns a pointer to the newly allocated block or NULL in case of error
*/ */
xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc; xmlMallocFunc xmlMalloc = malloc;
/** /**
* xmlMallocAtomic: * xmlMallocAtomic:
* @size: the size requested in bytes * @size: the size requested in bytes
@ -112,7 +112,7 @@ xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
* *
* Returns a pointer to the newly allocated block or NULL in case of error * Returns a pointer to the newly allocated block or NULL in case of error
*/ */
xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc; xmlMallocFunc xmlMallocAtomic = malloc;
/** /**
* xmlRealloc: * xmlRealloc:
* @mem: an already allocated block of memory * @mem: an already allocated block of memory
@ -122,7 +122,19 @@ xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
* *
* Returns a pointer to the newly reallocated block or NULL in case of error * Returns a pointer to the newly reallocated block or NULL in case of error
*/ */
xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc; xmlReallocFunc xmlRealloc = realloc;
/**
* xmlPosixStrdup
* @cur: the input char *
*
* a strdup implementation with a type signature matching POSIX
*
* Returns a new xmlChar * or NULL
*/
static char *
xmlPosixStrdup(const char *cur) {
return((char*) xmlCharStrdup(cur));
}
/** /**
* xmlMemStrdup: * xmlMemStrdup:
* @str: a zero terminated string * @str: a zero terminated string
@ -131,7 +143,7 @@ xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
* *
* Returns the copy of the string or NULL in case of error * Returns the copy of the string or NULL in case of error
*/ */
xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */ #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
#include <libxml/threads.h> #include <libxml/threads.h>

View file

@ -360,6 +360,18 @@ xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
xmlFree(table); xmlFree(table);
} }
/**
* xmlHashDefaultDeallocator:
* @entry: the hash table entry
* @name: the entry's name
*
* Free a hash table entry with xmlFree.
*/
void
xmlHashDefaultDeallocator(void *entry, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFree(entry);
}
/** /**
* xmlHashAddEntry: * xmlHashAddEntry:
* @table: the hash table * @table: the hash table
@ -912,8 +924,11 @@ void
xmlHashScan3(xmlHashTablePtr table, const xmlChar *name, xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3, const xmlChar *name2, const xmlChar *name3,
xmlHashScanner f, void *data) { xmlHashScanner f, void *data) {
xmlHashScanFull3 (table, name, name2, name3, stubData stubdata;
(xmlHashScannerFull) f, data); stubdata.data = data;
stubdata.hashscanner = f;
xmlHashScanFull3(table, name, name2, name3, stubHashScannerFull,
&stubdata);
} }
/** /**

View file

@ -13,7 +13,6 @@
#include "wincecompat.h" #include "wincecompat.h"
#else #else
#define HAVE_SYS_STAT_H #define HAVE_SYS_STAT_H
#define HAVE__STAT
#define HAVE_STAT #define HAVE_STAT
#define HAVE_STDLIB_H #define HAVE_STDLIB_H
#define HAVE_TIME_H #define HAVE_TIME_H

View file

@ -60,6 +60,18 @@ int vfprintf(FILE *, const char *, va_list);
#include "trio.h" #include "trio.h"
#endif #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
#endif
/* /*
* Internal variable indicating if a callback has been registered for * Internal variable indicating if a callback has been registered for
* node creation/destruction. It avoids spending a lot of time in locking * node creation/destruction. It avoids spending a lot of time in locking
@ -96,7 +108,7 @@ int __xmlRandom(void);
#endif #endif
XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg); XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg);
int xmlNop(void); int xmlInputReadCallbackNop(void *context, char *buffer, int len);
#ifdef IN_LIBXML #ifdef IN_LIBXML
#ifdef __GNUC__ #ifdef __GNUC__

View file

@ -673,7 +673,7 @@ xmlListSort(xmlListPtr l)
* apply the walker function to it * apply the walker function to it
*/ */
void void
xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user) {
xmlLinkPtr lk; xmlLinkPtr lk;
if ((l == NULL) || (walker == NULL)) if ((l == NULL) || (walker == NULL))
@ -694,7 +694,7 @@ xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
* apply the walker function to it * apply the walker function to it
*/ */
void void
xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, void *user) {
xmlLinkPtr lk; xmlLinkPtr lk;
if ((l == NULL) || (walker == NULL)) if ((l == NULL) || (walker == NULL))

View file

@ -63,7 +63,7 @@
#ifdef HAVE_STRINGS_H #ifdef HAVE_STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif
@ -145,7 +145,7 @@ typedef struct xmlNanoHTTPCtxt {
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */ char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
char *encoding; /* encoding extracted from the contentType */ char *encoding; /* encoding extracted from the contentType */
char *mimeType; /* Mime-Type extracted from the contentType */ char *mimeType; /* Mime-Type extracted from the contentType */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
z_stream *strm; /* Zlib stream object */ z_stream *strm; /* Zlib stream object */
int usesGzip; /* "Content-Encoding: gzip" was detected */ int usesGzip; /* "Content-Encoding: gzip" was detected */
#endif #endif
@ -434,7 +434,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType);
if (ctxt->location != NULL) xmlFree(ctxt->location); if (ctxt->location != NULL) xmlFree(ctxt->location);
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (ctxt->strm != NULL) { if (ctxt->strm != NULL) {
inflateEnd(ctxt->strm); inflateEnd(ctxt->strm);
xmlFree(ctxt->strm); xmlFree(ctxt->strm);
@ -817,7 +817,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
if (ctxt->authHeader != NULL) if (ctxt->authHeader != NULL)
xmlFree(ctxt->authHeader); xmlFree(ctxt->authHeader);
ctxt->authHeader = xmlMemStrdup(cur); ctxt->authHeader = xmlMemStrdup(cur);
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
} else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) { } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) {
cur += 17; cur += 17;
while ((*cur == ' ') || (*cur == '\t')) cur++; while ((*cur == ' ') || (*cur == '\t')) cur++;
@ -1273,7 +1273,7 @@ xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) {
int int
xmlNanoHTTPRead(void *ctx, void *dest, int len) { xmlNanoHTTPRead(void *ctx, void *dest, int len) {
xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
int bytes_read = 0; int bytes_read = 0;
int orig_avail_in; int orig_avail_in;
int z_ret; int z_ret;
@ -1283,7 +1283,7 @@ xmlNanoHTTPRead(void *ctx, void *dest, int len) {
if (dest == NULL) return(-1); if (dest == NULL) return(-1);
if (len <= 0) return(0); if (len <= 0) return(0);
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (ctxt->usesGzip == 1) { if (ctxt->usesGzip == 1) {
if (ctxt->strm == NULL) return(0); if (ctxt->strm == NULL) return(0);
@ -1424,7 +1424,7 @@ retry:
/* 1 for '?' */ /* 1 for '?' */
blen += strlen(ctxt->query) + 1; blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24; blen += strlen(method) + strlen(ctxt->path) + 24;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/* reserve for possible 'Accept-Encoding: gzip' string */ /* reserve for possible 'Accept-Encoding: gzip' string */
blen += 23; blen += 23;
#endif #endif
@ -1468,7 +1468,7 @@ retry:
ctxt->hostname, ctxt->port); ctxt->hostname, ctxt->port);
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n"); p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n");
#endif #endif

View file

@ -83,12 +83,6 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#ifdef HAVE_LZMA_H
#include <lzma.h>
#endif
#include "buf.h" #include "buf.h"
#include "enc.h" #include "enc.h"
@ -155,7 +149,7 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
rep = xmlStringDecodeEntities(ctxt, ent->content, rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, 0, 0, 0); XML_SUBSTITUTE_REF, 0, 0, 0);
--ctxt->depth; --ctxt->depth;
if (ctxt->errNo == XML_ERR_ENTITY_LOOP) { if ((rep == NULL) || (ctxt->errNo == XML_ERR_ENTITY_LOOP)) {
ent->content[0] = 0; ent->content[0] = 0;
} }
@ -2086,7 +2080,8 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) || if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) ||
(curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) && (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) &&
((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) && ((ctxt->input->buf) &&
(ctxt->input->buf->readcallback != xmlInputReadCallbackNop)) &&
((ctxt->options & XML_PARSE_HUGE) == 0)) { ((ctxt->options & XML_PARSE_HUGE) == 0)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup"); xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
xmlHaltParser(ctxt); xmlHaltParser(ctxt);
@ -3375,9 +3370,9 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
*/ */
ctxt->input->cur -= l; ctxt->input->cur -= l;
GROW; GROW;
ctxt->input->cur += l;
if (ctxt->instate == XML_PARSER_EOF) if (ctxt->instate == XML_PARSER_EOF)
return(NULL); return(NULL);
ctxt->input->cur += l;
c = CUR_CHAR(l); c = CUR_CHAR(l);
} }
} }
@ -7194,6 +7189,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
(ret != XML_WAR_UNDECLARED_ENTITY)) { (ret != XML_WAR_UNDECLARED_ENTITY)) {
xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
"Entity '%s' failed to parse\n", ent->name); "Entity '%s' failed to parse\n", ent->name);
if (ent->content != NULL)
ent->content[0] = 0;
xmlParserEntityCheck(ctxt, 0, ent, 0); xmlParserEntityCheck(ctxt, 0, ent, 0);
} else if (list != NULL) { } else if (list != NULL) {
xmlFreeNodeList(list); xmlFreeNodeList(list);
@ -12221,6 +12218,7 @@ xmldecl_done:
/* TODO 2.6.0 */ /* TODO 2.6.0 */
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"xmlParseChunk: encoder error\n"); "xmlParseChunk: encoder error\n");
xmlHaltParser(ctxt);
return(XML_ERR_INVALID_ENCODING); return(XML_ERR_INVALID_ENCODING);
} }
xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current); xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
@ -13369,6 +13367,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
ctxt->userData = ctxt; ctxt->userData = ctxt;
if (ctxt->dict != NULL) xmlDictFree(ctxt->dict); if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
ctxt->dict = oldctxt->dict; ctxt->dict = oldctxt->dict;
ctxt->input_id = oldctxt->input_id + 1;
ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3); ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5); ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36); ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
@ -13622,6 +13621,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
xmlDetectSAX2(ctxt); xmlDetectSAX2(ctxt);
ctxt->myDoc = doc; ctxt->myDoc = doc;
/* parsing in context, i.e. as within existing content */ /* parsing in context, i.e. as within existing content */
ctxt->input_id = 2;
ctxt->instate = XML_PARSER_CONTENT; ctxt->instate = XML_PARSER_CONTENT;
fake = xmlNewComment(NULL); fake = xmlNewComment(NULL);
@ -13834,6 +13834,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
newDoc->oldNs = doc->oldNs; newDoc->oldNs = doc->oldNs;
} }
ctxt->instate = XML_PARSER_CONTENT; ctxt->instate = XML_PARSER_CONTENT;
ctxt->input_id = 2;
ctxt->depth = depth; ctxt->depth = depth;
/* /*
@ -13994,6 +13995,11 @@ xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
if (pctx != NULL) { if (pctx != NULL) {
ctxt->options = pctx->options; ctxt->options = pctx->options;
ctxt->_private = pctx->_private; 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;
} }
uri = xmlBuildURI(URL, base); uri = xmlBuildURI(URL, base);
@ -14875,7 +14881,7 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
xmlInitNodeInfoSeq(&ctxt->node_seq); xmlInitNodeInfoSeq(&ctxt->node_seq);
if (ctxt->attsDefault != NULL) { if (ctxt->attsDefault != NULL) {
xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree); xmlHashFree(ctxt->attsDefault, xmlHashDefaultDeallocator);
ctxt->attsDefault = NULL; ctxt->attsDefault = NULL;
} }
if (ctxt->attsSpecial != NULL) { if (ctxt->attsSpecial != NULL) {

View file

@ -32,7 +32,7 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif
@ -1214,7 +1214,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
/* /*
* convert as much as possible of the buffer * convert as much as possible of the buffer
*/ */
nbchars = xmlCharEncInput(input->buf, 1); nbchars = xmlCharEncInput(input->buf, 0);
} else { } else {
/* /*
* convert just enough to get * convert just enough to get
@ -1795,7 +1795,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab); if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs); if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
if (ctxt->attsDefault != NULL) if (ctxt->attsDefault != NULL)
xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree); xmlHashFree(ctxt->attsDefault, xmlHashDefaultDeallocator);
if (ctxt->attsSpecial != NULL) if (ctxt->attsSpecial != NULL)
xmlHashFree(ctxt->attsSpecial, NULL); xmlHashFree(ctxt->attsSpecial, NULL);
if (ctxt->freeElems != NULL) { if (ctxt->freeElems != NULL) {

View file

@ -2729,9 +2729,10 @@ static xmlHashTablePtr xmlRelaxNGRegisteredTypes = NULL;
* Free the structure associated to the type library * Free the structure associated to the type library
*/ */
static void static void
xmlRelaxNGFreeTypeLibrary(xmlRelaxNGTypeLibraryPtr lib, xmlRelaxNGFreeTypeLibrary(void *payload,
const xmlChar * namespace ATTRIBUTE_UNUSED) const xmlChar * namespace ATTRIBUTE_UNUSED)
{ {
xmlRelaxNGTypeLibraryPtr lib = (xmlRelaxNGTypeLibraryPtr) payload;
if (lib == NULL) if (lib == NULL)
return; return;
if (lib->namespace != NULL) if (lib->namespace != NULL)
@ -2842,8 +2843,7 @@ xmlRelaxNGCleanupTypes(void)
xmlSchemaCleanupTypes(); xmlSchemaCleanupTypes();
if (xmlRelaxNGTypeInitialized == 0) if (xmlRelaxNGTypeInitialized == 0)
return; return;
xmlHashFree(xmlRelaxNGRegisteredTypes, (xmlHashDeallocator) xmlHashFree(xmlRelaxNGRegisteredTypes, xmlRelaxNGFreeTypeLibrary);
xmlRelaxNGFreeTypeLibrary);
xmlRelaxNGTypeInitialized = 0; xmlRelaxNGTypeInitialized = 0;
} }
@ -4311,10 +4311,11 @@ xmlRelaxNGCheckGroupAttrs(xmlRelaxNGParserCtxtPtr ctxt,
* algorithm * algorithm
*/ */
static void static void
xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def, xmlRelaxNGComputeInterleaves(void *payload, void *data,
xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * name ATTRIBUTE_UNUSED)
xmlChar * name ATTRIBUTE_UNUSED)
{ {
xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
xmlRelaxNGDefinePtr cur, *tmp; xmlRelaxNGDefinePtr cur, *tmp;
xmlRelaxNGPartitionPtr partitions = NULL; xmlRelaxNGPartitionPtr partitions = NULL;
@ -4663,7 +4664,7 @@ xmlRelaxNGParseDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
* Import import one references into the current grammar * Import import one references into the current grammar
*/ */
static void static void
xmlRelaxNGParseImportRef(void *payload, void *data, xmlChar *name) { xmlRelaxNGParseImportRef(void *payload, void *data, const xmlChar *name) {
xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data; xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload; xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
int tmp; int tmp;
@ -5670,10 +5671,10 @@ xmlRelaxNGParseGrammarContent(xmlRelaxNGParserCtxtPtr ctxt,
* element of a given grammar using the same name. * element of a given grammar using the same name.
*/ */
static void static void
xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref, xmlRelaxNGCheckReference(void *payload, void *data, const xmlChar * name)
xmlRelaxNGParserCtxtPtr ctxt,
const xmlChar * name)
{ {
xmlRelaxNGDefinePtr ref = (xmlRelaxNGDefinePtr) payload;
xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
xmlRelaxNGGrammarPtr grammar; xmlRelaxNGGrammarPtr grammar;
xmlRelaxNGDefinePtr def, cur; xmlRelaxNGDefinePtr def, cur;
@ -5726,9 +5727,10 @@ xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref,
* element of a given grammar using the same name. * element of a given grammar using the same name.
*/ */
static void static void
xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define, xmlRelaxNGCheckCombine(void *payload, void *data, const xmlChar * name)
xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * name)
{ {
xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) payload;
xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
xmlChar *combine; xmlChar *combine;
int choiceOrInterleave = -1; int choiceOrInterleave = -1;
int missing = 0; int missing = 0;
@ -6611,16 +6613,14 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
*/ */
xmlRelaxNGCombineStart(ctxt, ret); xmlRelaxNGCombineStart(ctxt, ret);
if (ret->defs != NULL) { if (ret->defs != NULL) {
xmlHashScan(ret->defs, (xmlHashScanner) xmlRelaxNGCheckCombine, xmlHashScan(ret->defs, xmlRelaxNGCheckCombine, ctxt);
ctxt);
} }
/* /*
* link together defines and refs in this grammar * link together defines and refs in this grammar
*/ */
if (ret->refs != NULL) { if (ret->refs != NULL) {
xmlHashScan(ret->refs, (xmlHashScanner) xmlRelaxNGCheckReference, xmlHashScan(ret->refs, xmlRelaxNGCheckReference, ctxt);
ctxt);
} }
@ -7551,8 +7551,7 @@ xmlRelaxNGParse(xmlRelaxNGParserCtxtPtr ctxt)
* try to preprocess interleaves * try to preprocess interleaves
*/ */
if (ctxt->interleaves != NULL) { if (ctxt->interleaves != NULL) {
xmlHashScan(ctxt->interleaves, xmlHashScan(ctxt->interleaves, xmlRelaxNGComputeInterleaves, ctxt);
(xmlHashScanner) xmlRelaxNGComputeInterleaves, ctxt);
} }
/* /*

View file

@ -47,10 +47,13 @@
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 303) && \
defined(__GLIBC__) && defined(__linux__)
static int libxml_is_threaded = -1; static int libxml_is_threaded = -1;
#if defined(__GNUC__) && defined(__GLIBC__)
#ifdef __linux__ #define XML_PTHREAD_WEAK
#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
#pragma weak pthread_once #pragma weak pthread_once
#pragma weak pthread_getspecific #pragma weak pthread_getspecific
#pragma weak pthread_setspecific #pragma weak pthread_setspecific
@ -68,9 +71,13 @@ static int libxml_is_threaded = -1;
#pragma weak pthread_key_create #pragma weak pthread_key_create
#pragma weak pthread_key_delete #pragma weak pthread_key_delete
#pragma weak pthread_cond_signal #pragma weak pthread_cond_signal
#endif
#endif /* __linux__ */ #else /* __GNUC__, __GLIBC__, __linux__ */
#endif /* defined(__GNUC__) && defined(__GLIBC__) */
static int libxml_is_threaded = 1;
#endif /* __GNUC__, __GLIBC__, __linux__ */
#endif /* HAVE_PTHREAD_H */ #endif /* HAVE_PTHREAD_H */
/* /*
@ -422,8 +429,11 @@ __xmlGlobalInitMutexLock(void)
/* Make sure the global init lock is initialized and then lock it. */ /* Make sure the global init lock is initialized and then lock it. */
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
/* The mutex is statically initialized, so we just lock it. */ /* The mutex is statically initialized, so we just lock it. */
if (pthread_mutex_lock != NULL) #ifdef XML_PTHREAD_WEAK
pthread_mutex_lock(&global_init_lock); if (pthread_mutex_lock == NULL)
return;
#endif /* XML_PTHREAD_WEAK */
pthread_mutex_lock(&global_init_lock);
#elif defined HAVE_WIN32_THREADS #elif defined HAVE_WIN32_THREADS
LPCRITICAL_SECTION cs; LPCRITICAL_SECTION cs;
@ -492,8 +502,11 @@ void
__xmlGlobalInitMutexUnlock(void) __xmlGlobalInitMutexUnlock(void)
{ {
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
if (pthread_mutex_unlock != NULL) #ifdef XML_PTHREAD_WEAK
pthread_mutex_unlock(&global_init_lock); if (pthread_mutex_unlock == NULL)
return;
#endif /* XML_PTHREAD_WEAK */
pthread_mutex_unlock(&global_init_lock);
#elif defined HAVE_WIN32_THREADS #elif defined HAVE_WIN32_THREADS
if (global_init_lock != NULL) { if (global_init_lock != NULL) {
LeaveCriticalSection(global_init_lock); LeaveCriticalSection(global_init_lock);
@ -845,6 +858,7 @@ void
xmlInitThreads(void) xmlInitThreads(void)
{ {
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
#ifdef XML_PTHREAD_WEAK
if (libxml_is_threaded == -1) { if (libxml_is_threaded == -1) {
if ((pthread_once != NULL) && if ((pthread_once != NULL) &&
(pthread_getspecific != NULL) && (pthread_getspecific != NULL) &&
@ -870,6 +884,7 @@ xmlInitThreads(void)
libxml_is_threaded = 0; libxml_is_threaded = 0;
} }
} }
#endif /* XML_PTHREAD_WEAK */
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) #elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
InitializeCriticalSection(&cleanup_helpers_cs); InitializeCriticalSection(&cleanup_helpers_cs);
#endif #endif
@ -896,7 +911,7 @@ xmlCleanupThreads(void)
xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n"); xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n");
#endif #endif
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
if ((libxml_is_threaded) && (pthread_key_delete != NULL)) if (libxml_is_threaded != 0)
pthread_key_delete(globalkey); pthread_key_delete(globalkey);
once_control = once_control_init; once_control = once_control_init;
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) #elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))

View file

@ -27,7 +27,7 @@
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif

View file

@ -1597,6 +1597,11 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
return(ret); return(ret);
} }
static void
xmlFreeElementTableEntry(void *elem, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeElement((xmlElementPtr) elem);
}
/** /**
* xmlFreeElementTable: * xmlFreeElementTable:
* @table: An element table * @table: An element table
@ -1605,7 +1610,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
*/ */
void void
xmlFreeElementTable(xmlElementTablePtr table) { xmlFreeElementTable(xmlElementTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeElement); xmlHashFree(table, xmlFreeElementTableEntry);
} }
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
@ -1617,8 +1622,9 @@ xmlFreeElementTable(xmlElementTablePtr table) {
* *
* Returns the new xmlElementPtr or NULL in case of error. * Returns the new xmlElementPtr or NULL in case of error.
*/ */
static xmlElementPtr static void *
xmlCopyElement(xmlElementPtr elem) { xmlCopyElement(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlElementPtr elem = (xmlElementPtr) payload;
xmlElementPtr cur; xmlElementPtr cur;
cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
@ -1653,8 +1659,7 @@ xmlCopyElement(xmlElementPtr elem) {
*/ */
xmlElementTablePtr xmlElementTablePtr
xmlCopyElementTable(xmlElementTablePtr table) { xmlCopyElementTable(xmlElementTablePtr table) {
return((xmlElementTablePtr) xmlHashCopy(table, return((xmlElementTablePtr) xmlHashCopy(table, xmlCopyElement));
(xmlHashCopier) xmlCopyElement));
} }
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
@ -1728,8 +1733,9 @@ xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
* the arguments. * the arguments.
*/ */
static void static void
xmlDumpElementDeclScan(xmlElementPtr elem, xmlBufferPtr buf) { xmlDumpElementDeclScan(void *elem, void *buf,
xmlDumpElementDecl(buf, elem); const xmlChar *name ATTRIBUTE_UNUSED) {
xmlDumpElementDecl((xmlBufferPtr) buf, (xmlElementPtr) elem);
} }
/** /**
@ -1743,7 +1749,7 @@ void
xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) { xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) {
if ((buf == NULL) || (table == NULL)) if ((buf == NULL) || (table == NULL))
return; return;
xmlHashScan(table, (xmlHashScanner) xmlDumpElementDeclScan, buf); xmlHashScan(table, xmlDumpElementDeclScan, buf);
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
@ -2143,6 +2149,11 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
return(ret); return(ret);
} }
static void
xmlFreeAttributeTableEntry(void *attr, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeAttribute((xmlAttributePtr) attr);
}
/** /**
* xmlFreeAttributeTable: * xmlFreeAttributeTable:
* @table: An attribute table * @table: An attribute table
@ -2151,7 +2162,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
*/ */
void void
xmlFreeAttributeTable(xmlAttributeTablePtr table) { xmlFreeAttributeTable(xmlAttributeTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeAttribute); xmlHashFree(table, xmlFreeAttributeTableEntry);
} }
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
@ -2163,8 +2174,9 @@ xmlFreeAttributeTable(xmlAttributeTablePtr table) {
* *
* Returns the new xmlAttributePtr or NULL in case of error. * Returns the new xmlAttributePtr or NULL in case of error.
*/ */
static xmlAttributePtr static void *
xmlCopyAttribute(xmlAttributePtr attr) { xmlCopyAttribute(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlAttributePtr attr = (xmlAttributePtr) payload;
xmlAttributePtr cur; xmlAttributePtr cur;
cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute)); cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
@ -2198,8 +2210,7 @@ xmlCopyAttribute(xmlAttributePtr attr) {
*/ */
xmlAttributeTablePtr xmlAttributeTablePtr
xmlCopyAttributeTable(xmlAttributeTablePtr table) { xmlCopyAttributeTable(xmlAttributeTablePtr table) {
return((xmlAttributeTablePtr) xmlHashCopy(table, return((xmlAttributeTablePtr) xmlHashCopy(table, xmlCopyAttribute));
(xmlHashCopier) xmlCopyAttribute));
} }
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
@ -2294,8 +2305,9 @@ xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
* This is used with the hash scan function - just reverses arguments * This is used with the hash scan function - just reverses arguments
*/ */
static void static void
xmlDumpAttributeDeclScan(xmlAttributePtr attr, xmlBufferPtr buf) { xmlDumpAttributeDeclScan(void *attr, void *buf,
xmlDumpAttributeDecl(buf, attr); const xmlChar *name ATTRIBUTE_UNUSED) {
xmlDumpAttributeDecl((xmlBufferPtr) buf, (xmlAttributePtr) attr);
} }
/** /**
@ -2309,7 +2321,7 @@ void
xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) { xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) {
if ((buf == NULL) || (table == NULL)) if ((buf == NULL) || (table == NULL))
return; return;
xmlHashScan(table, (xmlHashScanner) xmlDumpAttributeDeclScan, buf); xmlHashScan(table, xmlDumpAttributeDeclScan, buf);
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
@ -2415,6 +2427,11 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
return(ret); return(ret);
} }
static void
xmlFreeNotationTableEntry(void *nota, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeNotation((xmlNotationPtr) nota);
}
/** /**
* xmlFreeNotationTable: * xmlFreeNotationTable:
* @table: An notation table * @table: An notation table
@ -2423,7 +2440,7 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
*/ */
void void
xmlFreeNotationTable(xmlNotationTablePtr table) { xmlFreeNotationTable(xmlNotationTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeNotation); xmlHashFree(table, xmlFreeNotationTableEntry);
} }
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
@ -2435,8 +2452,9 @@ xmlFreeNotationTable(xmlNotationTablePtr table) {
* *
* Returns the new xmlNotationPtr or NULL in case of error. * Returns the new xmlNotationPtr or NULL in case of error.
*/ */
static xmlNotationPtr static void *
xmlCopyNotation(xmlNotationPtr nota) { xmlCopyNotation(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlNotationPtr nota = (xmlNotationPtr) payload;
xmlNotationPtr cur; xmlNotationPtr cur;
cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation)); cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
@ -2469,8 +2487,7 @@ xmlCopyNotation(xmlNotationPtr nota) {
*/ */
xmlNotationTablePtr xmlNotationTablePtr
xmlCopyNotationTable(xmlNotationTablePtr table) { xmlCopyNotationTable(xmlNotationTablePtr table) {
return((xmlNotationTablePtr) xmlHashCopy(table, return((xmlNotationTablePtr) xmlHashCopy(table, xmlCopyNotation));
(xmlHashCopier) xmlCopyNotation));
} }
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
@ -2510,8 +2527,9 @@ xmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) {
* This is called with the hash scan function, and just reverses args * This is called with the hash scan function, and just reverses args
*/ */
static void static void
xmlDumpNotationDeclScan(xmlNotationPtr nota, xmlBufferPtr buf) { xmlDumpNotationDeclScan(void *nota, void *buf,
xmlDumpNotationDecl(buf, nota); const xmlChar *name ATTRIBUTE_UNUSED) {
xmlDumpNotationDecl((xmlBufferPtr) buf, (xmlNotationPtr) nota);
} }
/** /**
@ -2525,7 +2543,7 @@ void
xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) { xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
if ((buf == NULL) || (table == NULL)) if ((buf == NULL) || (table == NULL))
return; return;
xmlHashScan(table, (xmlHashScanner) xmlDumpNotationDeclScan, buf); xmlHashScan(table, xmlDumpNotationDeclScan, buf);
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
@ -2653,6 +2671,11 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
return(ret); return(ret);
} }
static void
xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeID((xmlIDPtr) id);
}
/** /**
* xmlFreeIDTable: * xmlFreeIDTable:
* @table: An id table * @table: An id table
@ -2661,7 +2684,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
*/ */
void void
xmlFreeIDTable(xmlIDTablePtr table) { xmlFreeIDTable(xmlIDTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeID); xmlHashFree(table, xmlFreeIDTableEntry);
} }
/** /**
@ -2761,7 +2784,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
return(-1); return(-1);
} }
xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID); xmlHashRemoveEntry(table, ID, xmlFreeIDTableEntry);
xmlFree(ID); xmlFree(ID);
attr->atype = 0; attr->atype = 0;
return(0); return(0);
@ -2845,13 +2868,14 @@ xmlFreeRef(xmlLinkPtr lk) {
} }
/** /**
* xmlFreeRefList: * xmlFreeRefTableEntry:
* @list_ref: A list of references. * @list_ref: A list of references.
* *
* Deallocate the memory used by a list of references * Deallocate the memory used by a list of references
*/ */
static void static void
xmlFreeRefList(xmlListPtr list_ref) { xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlListPtr list_ref = (xmlListPtr) payload;
if (list_ref == NULL) return; if (list_ref == NULL) return;
xmlListDelete(list_ref); xmlListDelete(list_ref);
} }
@ -2864,7 +2888,7 @@ xmlFreeRefList(xmlListPtr list_ref) {
* Returns 0 to abort the walk or 1 to continue * Returns 0 to abort the walk or 1 to continue
*/ */
static int static int
xmlWalkRemoveRef(const void *data, const void *user) xmlWalkRemoveRef(const void *data, void *user)
{ {
xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr; xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr;
xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap; xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap;
@ -3002,7 +3026,7 @@ failed:
*/ */
void void
xmlFreeRefTable(xmlRefTablePtr table) { xmlFreeRefTable(xmlRefTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeRefList); xmlHashFree(table, xmlFreeRefTableEntry);
} }
/** /**
@ -3099,8 +3123,7 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
/*If the list is empty then remove the list entry in the hash */ /*If the list is empty then remove the list entry in the hash */
if (xmlListEmpty(ref_list)) if (xmlListEmpty(ref_list))
xmlHashUpdateEntry(table, ID, NULL, (xmlHashDeallocator) xmlHashUpdateEntry(table, ID, NULL, xmlFreeRefTableEntry);
xmlFreeRefList);
xmlFree(ID); xmlFree(ID);
return(0); return(0);
} }
@ -4096,8 +4119,10 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
} }
static void static void
xmlValidateAttributeIdCallback(xmlAttributePtr attr, int *count, xmlValidateAttributeIdCallback(void *payload, void *data,
const xmlChar* name ATTRIBUTE_UNUSED) { const xmlChar *name ATTRIBUTE_UNUSED) {
xmlAttributePtr attr = (xmlAttributePtr) payload;
int *count = (int *) data;
if (attr->atype == XML_ATTRIBUTE_ID) (*count)++; if (attr->atype == XML_ATTRIBUTE_ID) (*count)++;
} }
@ -4169,7 +4194,7 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
nbId = 0; nbId = 0;
if (doc->intSubset != NULL) { if (doc->intSubset != NULL) {
table = (xmlAttributeTablePtr) doc->intSubset->attributes; table = (xmlAttributeTablePtr) doc->intSubset->attributes;
xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner) xmlHashScan3(table, NULL, NULL, attr->elem,
xmlValidateAttributeIdCallback, &nbId); xmlValidateAttributeIdCallback, &nbId);
} }
} }
@ -6530,7 +6555,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
* Returns 0 to abort the walk or 1 to continue * Returns 0 to abort the walk or 1 to continue
*/ */
static int static int
xmlWalkValidateList(const void *data, const void *user) xmlWalkValidateList(const void *data, void *user)
{ {
xmlValidateMemoPtr memo = (xmlValidateMemoPtr)user; xmlValidateMemoPtr memo = (xmlValidateMemoPtr)user;
xmlValidateRef((xmlRefPtr)data, memo->ctxt, memo->name); xmlValidateRef((xmlRefPtr)data, memo->ctxt, memo->name);
@ -6545,8 +6570,9 @@ xmlWalkValidateList(const void *data, const void *user)
* *
*/ */
static void static void
xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt, xmlValidateCheckRefCallback(void *payload, void *data, const xmlChar *name) {
const xmlChar *name) { xmlListPtr ref_list = (xmlListPtr) payload;
xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data;
xmlValidateMemo memo; xmlValidateMemo memo;
if (ref_list == NULL) if (ref_list == NULL)
@ -6602,7 +6628,7 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
table = (xmlRefTablePtr) doc->refs; table = (xmlRefTablePtr) doc->refs;
ctxt->doc = doc; ctxt->doc = doc;
ctxt->valid = 1; ctxt->valid = 1;
xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt); xmlHashScan(table, xmlValidateCheckRefCallback, ctxt);
ctxt->finishDtd = save; ctxt->finishDtd = save;
return(ctxt->valid); return(ctxt->valid);
@ -6659,8 +6685,10 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
} }
static void static void
xmlValidateNotationCallback(xmlEntityPtr cur, xmlValidCtxtPtr ctxt, xmlValidateNotationCallback(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED) { const xmlChar *name ATTRIBUTE_UNUSED) {
xmlEntityPtr cur = (xmlEntityPtr) payload;
xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data;
if (cur == NULL) if (cur == NULL)
return; return;
if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
@ -6678,8 +6706,10 @@ xmlValidateNotationCallback(xmlEntityPtr cur, xmlValidCtxtPtr ctxt,
} }
static void static void
xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt, xmlValidateAttributeCallback(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED) { const xmlChar *name ATTRIBUTE_UNUSED) {
xmlAttributePtr cur = (xmlAttributePtr) payload;
xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data;
int ret; int ret;
xmlDocPtr doc; xmlDocPtr doc;
xmlElementPtr elem = NULL; xmlElementPtr elem = NULL;
@ -6778,22 +6808,20 @@ xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
dtd = doc->intSubset; dtd = doc->intSubset;
if ((dtd != NULL) && (dtd->attributes != NULL)) { if ((dtd != NULL) && (dtd->attributes != NULL)) {
table = (xmlAttributeTablePtr) dtd->attributes; table = (xmlAttributeTablePtr) dtd->attributes;
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt); xmlHashScan(table, xmlValidateAttributeCallback, ctxt);
} }
if ((dtd != NULL) && (dtd->entities != NULL)) { if ((dtd != NULL) && (dtd->entities != NULL)) {
entities = (xmlEntitiesTablePtr) dtd->entities; entities = (xmlEntitiesTablePtr) dtd->entities;
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback, xmlHashScan(entities, xmlValidateNotationCallback, ctxt);
ctxt);
} }
dtd = doc->extSubset; dtd = doc->extSubset;
if ((dtd != NULL) && (dtd->attributes != NULL)) { if ((dtd != NULL) && (dtd->attributes != NULL)) {
table = (xmlAttributeTablePtr) dtd->attributes; table = (xmlAttributeTablePtr) dtd->attributes;
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt); xmlHashScan(table, xmlValidateAttributeCallback, ctxt);
} }
if ((dtd != NULL) && (dtd->entities != NULL)) { if ((dtd != NULL) && (dtd->entities != NULL)) {
entities = (xmlEntitiesTablePtr) dtd->entities; entities = (xmlEntitiesTablePtr) dtd->entities;
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback, xmlHashScan(entities, xmlValidateNotationCallback, ctxt);
ctxt);
} }
return(ctxt->valid); return(ctxt->valid);
} }

View file

@ -1261,8 +1261,10 @@ struct _xmlXIncludeMergeData {
* Inplements the merge of one entity * Inplements the merge of one entity
*/ */
static void static void
xmlXIncludeMergeEntity(xmlEntityPtr ent, xmlXIncludeMergeDataPtr data, xmlXIncludeMergeEntity(void *payload, void *vdata,
xmlChar *name ATTRIBUTE_UNUSED) { const xmlChar *name ATTRIBUTE_UNUSED) {
xmlEntityPtr ent = (xmlEntityPtr) payload;
xmlXIncludeMergeDataPtr data = (xmlXIncludeMergeDataPtr) vdata;
xmlEntityPtr ret, prev; xmlEntityPtr ret, prev;
xmlDocPtr doc; xmlDocPtr doc;
xmlXIncludeCtxtPtr ctxt; xmlXIncludeCtxtPtr ctxt;
@ -1367,7 +1369,7 @@ xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
data.doc = doc; data.doc = doc;
xmlHashScan((xmlHashTablePtr) source->entities, xmlHashScan((xmlHashTablePtr) source->entities,
(xmlHashScanner) xmlXIncludeMergeEntity, &data); xmlXIncludeMergeEntity, &data);
} }
source = from->extSubset; source = from->extSubset;
if ((source != NULL) && (source->entities != NULL)) { if ((source != NULL) && (source->entities != NULL)) {
@ -1382,7 +1384,7 @@ xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
if ((!xmlStrEqual(target->ExternalID, source->ExternalID)) && if ((!xmlStrEqual(target->ExternalID, source->ExternalID)) &&
(!xmlStrEqual(target->SystemID, source->SystemID))) { (!xmlStrEqual(target->SystemID, source->SystemID))) {
xmlHashScan((xmlHashTablePtr) source->entities, xmlHashScan((xmlHashTablePtr) source->entities,
(xmlHashScanner) xmlXIncludeMergeEntity, &data); xmlXIncludeMergeEntity, &data);
} }
} }
return(0); return(0);

View file

@ -28,7 +28,7 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif

View file

@ -33,17 +33,20 @@
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif
#ifdef HAVE_LZMA_H #ifdef LIBXML_LZMA_ENABLED
#include <lzma.h> #include <lzma.h>
#endif #endif
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
//#define WIN32_LEAN_AND_MEAN #ifdef __REACTOS__
//#include <windows.h>
#include <winnls.h> #include <winnls.h>
#else /* __REACTOS__ */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif /* __REACTOS__ */
#endif #endif
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
@ -598,7 +601,7 @@ xmlWrapOpenUtf8(const char *path,int mode)
return fd; return fd;
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
static gzFile static gzFile
xmlWrapGzOpenUtf8(const char *path, const char *mode) xmlWrapGzOpenUtf8(const char *path, const char *mode)
{ {
@ -704,14 +707,16 @@ xmlCheckFilename (const char *path)
} }
/** /**
* xmlNop: * xmlInputReadCallbackNop:
* *
* No Operation function, does nothing, no input * No Operation xmlInputReadCallback function, does nothing.
* *
* Returns zero * Returns zero
*/ */
int int
xmlNop(void) { xmlInputReadCallbackNop(void *context ATTRIBUTE_UNUSED,
char *buffer ATTRIBUTE_UNUSED,
int len ATTRIBUTE_UNUSED) {
return(0); return(0);
} }
@ -1037,7 +1042,7 @@ xmlBufferWrite (void * context, const char * buffer, int len) {
} }
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/************************************************************************ /************************************************************************
* * * *
* I/O for compressed file accesses * * I/O for compressed file accesses *
@ -1240,7 +1245,7 @@ xmlGzfileClose (void * context) {
if (ret < 0) xmlIOErr(0, "gzclose()"); if (ret < 0) xmlIOErr(0, "gzclose()");
return(ret); return(ret);
} }
#endif /* HAVE_ZLIB_H */ #endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_LZMA_ENABLED #ifdef LIBXML_LZMA_ENABLED
/************************************************************************ /************************************************************************
@ -1379,7 +1384,7 @@ typedef struct xmlIOHTTPWriteCtxt_
} xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr; } xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#define DFLT_WBITS ( -15 ) #define DFLT_WBITS ( -15 )
#define DFLT_MEM_LVL ( 8 ) #define DFLT_MEM_LVL ( 8 )
@ -1707,7 +1712,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
return ( zlgth ); return ( zlgth );
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
#endif /* HAVE_ZLIB_H */ #endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
/** /**
@ -1726,7 +1731,7 @@ xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
if ( ctxt->doc_buff != NULL ) { if ( ctxt->doc_buff != NULL ) {
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 ) { if ( ctxt->compression > 0 ) {
xmlFreeZMemBuff( ctxt->doc_buff ); xmlFreeZMemBuff( ctxt->doc_buff );
} }
@ -1813,7 +1818,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression ATTRIBUTE_UNUSED)
* ** is being used to avoid pushing the data to disk and back. * ** is being used to avoid pushing the data to disk and back.
*/ */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9)) { if ((compression > 0) && (compression <= 9)) {
ctxt->compression = compression; ctxt->compression = compression;
@ -1893,7 +1898,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
/* Use gzwrite or fwrite as previously setup in the open call */ /* Use gzwrite or fwrite as previously setup in the open call */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 ) if ( ctxt->compression > 0 )
len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len ); len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len );
@ -1957,7 +1962,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
/* Retrieve the content from the appropriate buffer */ /* Retrieve the content from the appropriate buffer */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ( ctxt->compression > 0 ) { if ( ctxt->compression > 0 ) {
content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content ); content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content );
@ -2228,10 +2233,10 @@ xmlRegisterDefaultInputCallbacks(void) {
xmlRegisterInputCallbacks(xmlFileMatch, xmlFileOpen, xmlRegisterInputCallbacks(xmlFileMatch, xmlFileOpen,
xmlFileRead, xmlFileClose); xmlFileRead, xmlFileClose);
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen, xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
xmlGzfileRead, xmlGzfileClose); xmlGzfileRead, xmlGzfileClose);
#endif /* HAVE_ZLIB_H */ #endif /* LIBXML_ZLIB_ENABLED */
#ifdef LIBXML_LZMA_ENABLED #ifdef LIBXML_LZMA_ENABLED
xmlRegisterInputCallbacks(xmlXzfileMatch, xmlXzfileOpen, xmlRegisterInputCallbacks(xmlXzfileMatch, xmlXzfileOpen,
xmlXzfileRead, xmlXzfileClose); xmlXzfileRead, xmlXzfileClose);
@ -2273,7 +2278,7 @@ xmlRegisterDefaultOutputCallbacks (void) {
uncompressed ones except opening if existing then closing uncompressed ones except opening if existing then closing
and saving with same compression ratio ... a pain. and saving with same compression ratio ... a pain.
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
xmlRegisterOutputCallbacks(xmlGzfileMatch, xmlGzfileOpen, xmlRegisterOutputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
xmlGzfileWrite, xmlGzfileClose); xmlGzfileWrite, xmlGzfileClose);
#endif #endif
@ -2563,7 +2568,7 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
ret->context = context; ret->context = context;
ret->readcallback = xmlInputCallbackTable[i].readcallback; ret->readcallback = xmlInputCallbackTable[i].readcallback;
ret->closecallback = xmlInputCallbackTable[i].closecallback; ret->closecallback = xmlInputCallbackTable[i].closecallback;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ((xmlInputCallbackTable[i].opencallback == xmlGzfileOpen) && if ((xmlInputCallbackTable[i].opencallback == xmlGzfileOpen) &&
(strcmp(URI, "-") != 0)) { (strcmp(URI, "-") != 0)) {
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
@ -2627,7 +2632,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
int i = 0; int i = 0;
void *context = NULL; void *context = NULL;
char *unescaped = NULL; char *unescaped = NULL;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
int is_file_uri = 1; int is_file_uri = 1;
#endif #endif
@ -2638,7 +2643,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
puri = xmlParseURI(URI); puri = xmlParseURI(URI);
if (puri != NULL) { if (puri != NULL) {
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ((puri->scheme != NULL) && if ((puri->scheme != NULL) &&
(!xmlStrEqual(BAD_CAST puri->scheme, BAD_CAST "file"))) (!xmlStrEqual(BAD_CAST puri->scheme, BAD_CAST "file")))
is_file_uri = 0; is_file_uri = 0;
@ -2658,7 +2663,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
* try with an unescaped version of the URI * try with an unescaped version of the URI
*/ */
if (unescaped != NULL) { if (unescaped != NULL) {
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) { if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(unescaped, compression); context = xmlGzfileOpenW(unescaped, compression);
if (context != NULL) { if (context != NULL) {
@ -2676,7 +2681,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
if ((xmlOutputCallbackTable[i].matchcallback != NULL) && if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
(xmlOutputCallbackTable[i].matchcallback(unescaped) != 0)) { (xmlOutputCallbackTable[i].matchcallback(unescaped) != 0)) {
#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H) #if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
/* Need to pass compression parameter into HTTP open calls */ /* Need to pass compression parameter into HTTP open calls */
if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch) if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
context = xmlIOHTTPOpenW(unescaped, compression); context = xmlIOHTTPOpenW(unescaped, compression);
@ -2695,7 +2700,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
* filename * filename
*/ */
if (context == NULL) { if (context == NULL) {
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) { if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(URI, compression); context = xmlGzfileOpenW(URI, compression);
if (context != NULL) { if (context != NULL) {
@ -2712,7 +2717,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
if ((xmlOutputCallbackTable[i].matchcallback != NULL) && if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
(xmlOutputCallbackTable[i].matchcallback(URI) != 0)) { (xmlOutputCallbackTable[i].matchcallback(URI) != 0)) {
#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H) #if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
/* Need to pass compression parameter into HTTP open calls */ /* Need to pass compression parameter into HTTP open calls */
if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch) if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
context = xmlIOHTTPOpenW(URI, compression); context = xmlIOHTTPOpenW(URI, compression);
@ -2842,10 +2847,8 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
if (buffer == NULL) return(NULL); if (buffer == NULL) return(NULL);
ret = xmlOutputBufferCreateIO((xmlOutputWriteCallback) ret = xmlOutputBufferCreateIO(xmlBufferWrite, NULL, (void *) buffer,
xmlBufferWrite, encoder);
(xmlOutputCloseCallback)
NULL, (void *) buffer, encoder);
return(ret); return(ret);
} }
@ -2933,7 +2936,7 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
ret = xmlAllocParserInputBuffer(enc); ret = xmlAllocParserInputBuffer(enc);
if (ret != NULL) { if (ret != NULL) {
ret->context = (void *) mem; ret->context = (void *) mem;
ret->readcallback = (xmlInputReadCallback) xmlNop; ret->readcallback = xmlInputReadCallbackNop;
ret->closecallback = NULL; ret->closecallback = NULL;
errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size); errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size);
if (errcode != 0) { if (errcode != 0) {
@ -3158,7 +3161,7 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
* convert as much as possible to the parser reading buffer. * convert as much as possible to the parser reading buffer.
*/ */
use = xmlBufUse(in->raw); use = xmlBufUse(in->raw);
nbchars = xmlCharEncInput(in, 1); nbchars = xmlCharEncInput(in, 0);
if (nbchars < 0) { if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL); xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER; in->error = XML_IO_ENCODER;
@ -3274,7 +3277,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
* convert as much as possible to the parser reading buffer. * convert as much as possible to the parser reading buffer.
*/ */
use = xmlBufUse(in->raw); use = xmlBufUse(in->raw);
nbchars = xmlCharEncInput(in, 1); nbchars = xmlCharEncInput(in, 0);
if (nbchars < 0) { if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL); xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER; in->error = XML_IO_ENCODER;

View file

@ -814,13 +814,14 @@ xmlShellReadline(char *prompt) {
* * * *
************************************************************************/ ************************************************************************/
static int myRead(FILE *f, char * buf, int len) { static int myRead(void *f, char *buf, int len) {
return(fread(buf, 1, len, f)); return(fread(buf, 1, len, (FILE *) f));
} }
static void myClose(FILE *f) { static int myClose(void *context) {
if (f != stdin) { FILE *f = (FILE *) context;
fclose(f); if (f == stdin)
} return(0);
return(fclose(f));
} }
/************************************************************************ /************************************************************************
@ -2303,14 +2304,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
#endif #endif
if (f != NULL) { if (f != NULL) {
if (rectxt == NULL) if (rectxt == NULL)
doc = xmlReadIO((xmlInputReadCallback) myRead, doc = xmlReadIO(myRead, myClose, f, filename, NULL,
(xmlInputCloseCallback) myClose, f, options);
filename, NULL, options);
else else
doc = xmlCtxtReadIO(rectxt, doc = xmlCtxtReadIO(rectxt, myRead, myClose, f,
(xmlInputReadCallback) myRead, filename, NULL, options);
(xmlInputCloseCallback) myClose, f,
filename, NULL, options);
} else } else
doc = NULL; doc = NULL;
} }
@ -3017,7 +3015,7 @@ static void usage(FILE *f, const char *name) {
fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n"); fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n");
fprintf(f, "\t--insert : ad-hoc test for valid insertions\n"); fprintf(f, "\t--insert : ad-hoc test for valid insertions\n");
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
fprintf(f, "\t--compress : turn on gzip compression of output\n"); fprintf(f, "\t--compress : turn on gzip compression of output\n");
#endif #endif
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
@ -3297,7 +3295,7 @@ main(int argc, char **argv) {
} }
#endif #endif
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
else if ((!strcmp(argv[i], "-compress")) || else if ((!strcmp(argv[i], "-compress")) ||
(!strcmp(argv[i], "--compress"))) { (!strcmp(argv[i], "--compress"))) {
compress++; compress++;

View file

@ -340,6 +340,7 @@ xmlModulePlatformClose(void *handle)
static int static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{ {
XML_IGNORE_PEDANTIC_WARNINGS
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
/* /*
* GetProcAddressA seems only available on WinCE * GetProcAddressA seems only available on WinCE
@ -349,6 +350,7 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
*symbol = GetProcAddress(handle, name); *symbol = GetProcAddress(handle, name);
#endif #endif
return (NULL == *symbol) ? -1 : 0; return (NULL == *symbol) ? -1 : 0;
XML_POP_WARNINGS
} }
#endif /* _WIN32 */ #endif /* _WIN32 */

View file

@ -491,6 +491,11 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
} }
} }
static void
xmlTextReaderFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeID((xmlIDPtr) id);
}
/** /**
* xmlTextReaderFreeIDTable: * xmlTextReaderFreeIDTable:
* @table: An id table * @table: An id table
@ -499,7 +504,7 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
*/ */
static void static void
xmlTextReaderFreeIDTable(xmlIDTablePtr table) { xmlTextReaderFreeIDTable(xmlIDTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlFreeID); xmlHashFree(table, xmlTextReaderFreeIDTableEntry);
} }
/** /**

View file

@ -1595,31 +1595,31 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
if (cur->properties != NULL) if (cur->properties != NULL)
xhtmlAttrListDumpOutput(ctxt, cur->properties); xhtmlAttrListDumpOutput(ctxt, cur->properties);
if ((cur->type == XML_ELEMENT_NODE) && if ((cur->type == XML_ELEMENT_NODE) &&
(cur->parent != NULL) && (cur->parent != NULL) &&
(cur->parent->parent == (xmlNodePtr) cur->doc) && (cur->parent->parent == (xmlNodePtr) cur->doc) &&
xmlStrEqual(cur->name, BAD_CAST"head") && xmlStrEqual(cur->name, BAD_CAST"head") &&
xmlStrEqual(cur->parent->name, BAD_CAST"html")) { xmlStrEqual(cur->parent->name, BAD_CAST"html")) {
tmp = cur->children; tmp = cur->children;
while (tmp != NULL) { while (tmp != NULL) {
if (xmlStrEqual(tmp->name, BAD_CAST"meta")) { if (xmlStrEqual(tmp->name, BAD_CAST"meta")) {
xmlChar *httpequiv; xmlChar *httpequiv;
httpequiv = xmlGetProp(tmp, BAD_CAST"http-equiv"); httpequiv = xmlGetProp(tmp, BAD_CAST"http-equiv");
if (httpequiv != NULL) { if (httpequiv != NULL) {
if (xmlStrcasecmp(httpequiv, BAD_CAST"Content-Type") == 0) { if (xmlStrcasecmp(httpequiv, BAD_CAST"Content-Type") == 0) {
xmlFree(httpequiv); xmlFree(httpequiv);
break; break;
} }
xmlFree(httpequiv); xmlFree(httpequiv);
} }
} }
tmp = tmp->next; tmp = tmp->next;
} }
if (tmp == NULL) if (tmp == NULL)
addmeta = 1; addmeta = 1;
} }
if ((cur->type == XML_ELEMENT_NODE) && (cur->children == NULL)) { if ((cur->type == XML_ELEMENT_NODE) && (cur->children == NULL)) {
if (((cur->ns == NULL) || (cur->ns->prefix == NULL)) && if (((cur->ns == NULL) || (cur->ns->prefix == NULL)) &&
@ -2704,7 +2704,7 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
return(-1); return(-1);
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (cur->compression < 0) cur->compression = xmlGetCompressMode(); if (cur->compression < 0) cur->compression = xmlGetCompressMode();
#endif #endif
/* /*

View file

@ -2842,7 +2842,7 @@ xmlSchemaPResCompAttrErr(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaFormatItemForReport(&des, NULL, ownerItem, ownerElem); xmlSchemaFormatItemForReport(&des, NULL, ownerItem, ownerElem);
if (refTypeStr == NULL) if (refTypeStr == NULL)
refTypeStr = (const char *) xmlSchemaItemTypeToStr(refType); refTypeStr = (const char *) xmlSchemaItemTypeToStr(refType);
xmlSchemaPErrExt(ctxt, ownerElem, error, xmlSchemaPErrExt(ctxt, ownerElem, error,
NULL, NULL, NULL, NULL, NULL, NULL,
"%s, attribute '%s': The QName value '%s' does not resolve to a(n) " "%s, attribute '%s': The QName value '%s' does not resolve to a(n) "
"%s.\n", BAD_CAST des, BAD_CAST name, "%s.\n", BAD_CAST des, BAD_CAST name,
@ -3565,6 +3565,12 @@ xmlSchemaBucketFree(xmlSchemaBucketPtr bucket)
xmlFree(bucket); xmlFree(bucket);
} }
static void
xmlSchemaBucketFreeEntry(void *bucket, const xmlChar *name ATTRIBUTE_UNUSED)
{
xmlSchemaBucketFree((xmlSchemaBucketPtr) bucket);
}
static xmlSchemaBucketPtr static xmlSchemaBucketPtr
xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
int type, const xmlChar *targetNamespace) int type, const xmlChar *targetNamespace)
@ -4159,8 +4165,7 @@ xmlSchemaFree(xmlSchemaPtr schema)
xmlHashFree(schema->idcDef, NULL); xmlHashFree(schema->idcDef, NULL);
if (schema->schemasImports != NULL) if (schema->schemasImports != NULL)
xmlHashFree(schema->schemasImports, xmlHashFree(schema->schemasImports, xmlSchemaBucketFreeEntry);
(xmlHashDeallocator) xmlSchemaBucketFree);
if (schema->includes != NULL) { if (schema->includes != NULL) {
xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes; xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;
int i; int i;
@ -4196,11 +4201,13 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output); /* forward */
* Dump the element * Dump the element
*/ */
static void static void
xmlSchemaElementDump(xmlSchemaElementPtr elem, FILE * output, xmlSchemaElementDump(void *payload, void *data,
const xmlChar * name ATTRIBUTE_UNUSED, const xmlChar * name ATTRIBUTE_UNUSED,
const xmlChar * namespace ATTRIBUTE_UNUSED, const xmlChar * namespace ATTRIBUTE_UNUSED,
const xmlChar * context ATTRIBUTE_UNUSED) const xmlChar * context ATTRIBUTE_UNUSED)
{ {
xmlSchemaElementPtr elem = (xmlSchemaElementPtr) payload;
FILE *output = (FILE *) data;
if (elem == NULL) if (elem == NULL)
return; return;
@ -4515,6 +4522,13 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output)
#endif #endif
} }
static void
xmlSchemaTypeDumpEntry(void *type, void *output,
const xmlChar *name ATTRIBUTE_UNUSED)
{
xmlSchemaTypeDump((xmlSchemaTypePtr) type, (FILE *) output);
}
/** /**
* xmlSchemaDump: * xmlSchemaDump:
* @output: the file output * @output: the file output
@ -4543,10 +4557,8 @@ xmlSchemaDump(FILE * output, xmlSchemaPtr schema)
fprintf(output, "\n"); fprintf(output, "\n");
if (schema->annot != NULL) if (schema->annot != NULL)
xmlSchemaAnnotDump(output, schema->annot); xmlSchemaAnnotDump(output, schema->annot);
xmlHashScan(schema->typeDecl, (xmlHashScanner) xmlSchemaTypeDump, xmlHashScan(schema->typeDecl, xmlSchemaTypeDumpEntry, output);
output); xmlHashScanFull(schema->elemDecl, xmlSchemaElementDump, output);
xmlHashScanFull(schema->elemDecl,
(xmlHashScannerFull) xmlSchemaElementDump, output);
} }
#ifdef DEBUG_IDC_NODE_TABLE #ifdef DEBUG_IDC_NODE_TABLE
@ -5706,6 +5718,12 @@ xmlSchemaSubstGroupFree(xmlSchemaSubstGroupPtr group)
xmlFree(group); xmlFree(group);
} }
static void
xmlSchemaSubstGroupFreeEntry(void *group, const xmlChar *name ATTRIBUTE_UNUSED)
{
xmlSchemaSubstGroupFree((xmlSchemaSubstGroupPtr) group);
}
static xmlSchemaSubstGroupPtr static xmlSchemaSubstGroupPtr
xmlSchemaSubstGroupAdd(xmlSchemaParserCtxtPtr pctxt, xmlSchemaSubstGroupAdd(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaElementPtr head) xmlSchemaElementPtr head)
@ -7373,8 +7391,8 @@ attr_next:
*/ */
if (defValue != NULL) if (defValue != NULL)
use->defValue = defValue; use->defValue = defValue;
if (defValueType == WXS_ATTR_DEF_VAL_FIXED) if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
use->flags |= XML_SCHEMA_ATTR_USE_FIXED; use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
} }
check_children: check_children:
@ -9918,8 +9936,7 @@ xmlSchemaConstructionCtxtFree(xmlSchemaConstructionCtxtPtr con)
if (con->pending != NULL) if (con->pending != NULL)
xmlSchemaItemListFree(con->pending); xmlSchemaItemListFree(con->pending);
if (con->substGroups != NULL) if (con->substGroups != NULL)
xmlHashFree(con->substGroups, xmlHashFree(con->substGroups, xmlSchemaSubstGroupFreeEntry);
(xmlHashDeallocator) xmlSchemaSubstGroupFree);
if (con->redefs != NULL) if (con->redefs != NULL)
xmlSchemaRedefListFree(con->redefs); xmlSchemaRedefListFree(con->redefs);
if (con->dict != NULL) if (con->dict != NULL)
@ -21293,8 +21310,7 @@ exit:
con->bucket = oldbucket; con->bucket = oldbucket;
con->pending->nbItems = 0; con->pending->nbItems = 0;
if (con->substGroups != NULL) { if (con->substGroups != NULL) {
xmlHashFree(con->substGroups, xmlHashFree(con->substGroups, xmlSchemaSubstGroupFreeEntry);
(xmlHashDeallocator) xmlSchemaSubstGroupFree);
con->substGroups = NULL; con->substGroups = NULL;
} }
if (con->redefs != NULL) { if (con->redefs != NULL) {
@ -22002,9 +22018,11 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt,
* Returns the item, or NULL on internal errors. * Returns the item, or NULL on internal errors.
*/ */
static void static void
xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef, xmlSchemaAugmentIDC(void *payload, void *data,
xmlSchemaValidCtxtPtr vctxt) const xmlChar *name ATTRIBUTE_UNUSED)
{ {
xmlSchemaIDCPtr idcDef = (xmlSchemaIDCPtr) payload;
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) data;
xmlSchemaIDCAugPtr aidc; xmlSchemaIDCAugPtr aidc;
aidc = (xmlSchemaIDCAugPtr) xmlMalloc(sizeof(xmlSchemaIDCAug)); aidc = (xmlSchemaIDCAugPtr) xmlMalloc(sizeof(xmlSchemaIDCAug));
@ -22038,10 +22056,12 @@ xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef,
* Creates an augmented IDC definition for the imported schema. * Creates an augmented IDC definition for the imported schema.
*/ */
static void static void
xmlSchemaAugmentImportedIDC(xmlSchemaImportPtr imported, xmlSchemaValidCtxtPtr vctxt, xmlChar *name ATTRIBUTE_UNUSED) { xmlSchemaAugmentImportedIDC(void *payload, void *data,
const xmlChar *name ATTRIBUTE_UNUSED) {
xmlSchemaImportPtr imported = (xmlSchemaImportPtr) payload;
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) data;
if (imported->schema->idcDef != NULL) { if (imported->schema->idcDef != NULL) {
xmlHashScan(imported->schema->idcDef , xmlHashScan(imported->schema->idcDef, xmlSchemaAugmentIDC, vctxt);
(xmlHashScanner) xmlSchemaAugmentIDC, vctxt);
} }
} }
@ -25966,11 +25986,12 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
} }
static void static void
xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED, xmlSchemaVContentModelCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
const xmlChar * name ATTRIBUTE_UNUSED, const xmlChar * name ATTRIBUTE_UNUSED,
xmlSchemaElementPtr item, void *transdata, void *inputdata)
xmlSchemaNodeInfoPtr inode)
{ {
xmlSchemaElementPtr item = (xmlSchemaElementPtr) transdata;
xmlSchemaNodeInfoPtr inode = (xmlSchemaNodeInfoPtr) inputdata;
inode->decl = item; inode->decl = item;
#ifdef DEBUG_CONTENT #ifdef DEBUG_CONTENT
{ {
@ -26075,8 +26096,7 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
*/ */
inode->regexCtxt = inode->regexCtxt =
xmlRegNewExecCtxt(inode->typeDef->contModel, xmlRegNewExecCtxt(inode->typeDef->contModel,
(xmlRegExecCallbacks) xmlSchemaVContentModelCallback, xmlSchemaVContentModelCallback, vctxt);
vctxt);
if (inode->regexCtxt == NULL) { if (inode->regexCtxt == NULL) {
VERROR_INT("xmlSchemaValidatorPopElem", VERROR_INT("xmlSchemaValidatorPopElem",
"failed to create a regex context"); "failed to create a regex context");
@ -26624,8 +26644,7 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
* Create the regex context. * Create the regex context.
*/ */
regexCtxt = xmlRegNewExecCtxt(ptype->contModel, regexCtxt = xmlRegNewExecCtxt(ptype->contModel,
(xmlRegExecCallbacks) xmlSchemaVContentModelCallback, xmlSchemaVContentModelCallback, vctxt);
vctxt);
if (regexCtxt == NULL) { if (regexCtxt == NULL) {
VERROR_INT("xmlSchemaValidateChildElem", VERROR_INT("xmlSchemaValidateChildElem",
"failed to create a regex context"); "failed to create a regex context");
@ -26885,7 +26904,8 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt)
* Augment the IDC definitions for the main schema and all imported ones * Augment the IDC definitions for the main schema and all imported ones
* NOTE: main schema is the first in the imported list * NOTE: main schema is the first in the imported list
*/ */
xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt); xmlHashScan(vctxt->schema->schemasImports, xmlSchemaAugmentImportedIDC,
vctxt);
} }
if (vctxt->depth > 0) { if (vctxt->depth > 0) {
/* /*
@ -27817,7 +27837,7 @@ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
{ {
if (ctxt == NULL) if (ctxt == NULL)
return; return;
ctxt->serror = serror; ctxt->serror = serror;
ctxt->error = NULL; ctxt->error = NULL;
ctxt->warning = NULL; ctxt->warning = NULL;
ctxt->errCtxt = ctx; ctxt->errCtxt = ctx;
@ -28127,7 +28147,8 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
* Augment the IDC definitions for the main schema and all imported ones * Augment the IDC definitions for the main schema and all imported ones
* NOTE: main schema if the first in the imported list * NOTE: main schema if the first in the imported list
*/ */
xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt); xmlHashScan(vctxt->schema->schemasImports, xmlSchemaAugmentImportedIDC,
vctxt);
return(0); return(0);
} }

View file

@ -619,6 +619,11 @@ xmlSchemaInitTypes(void)
xmlSchemaTypesInitialized = 1; xmlSchemaTypesInitialized = 1;
} }
static void
xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlSchemaFreeType((xmlSchemaTypePtr) type);
}
/** /**
* xmlSchemaCleanupTypes: * xmlSchemaCleanupTypes:
* *
@ -646,7 +651,7 @@ xmlSchemaCleanupTypes(void) {
xmlFree((xmlSchemaParticlePtr) particle); xmlFree((xmlSchemaParticlePtr) particle);
xmlSchemaTypeAnyTypeDef->subtypes = NULL; xmlSchemaTypeAnyTypeDef->subtypes = NULL;
} }
xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType); xmlHashFree(xmlSchemaTypesBank, xmlSchemaFreeTypeEntry);
xmlSchemaTypesInitialized = 0; xmlSchemaTypesInitialized = 0;
} }

View file

@ -110,7 +110,7 @@ static void xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk);
static int xmlCmpTextWriterNsStackEntry(const void *data0, static int xmlCmpTextWriterNsStackEntry(const void *data0,
const void *data1); const void *data1);
static int xmlTextWriterWriteDocCallback(void *context, static int xmlTextWriterWriteDocCallback(void *context,
const xmlChar * str, int len); const char *str, int len);
static int xmlTextWriterCloseDocCallback(void *context); static int xmlTextWriterCloseDocCallback(void *context);
static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0); static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0);
@ -190,9 +190,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
} }
memset(ret, 0, (size_t) sizeof(xmlTextWriter)); memset(ret, 0, (size_t) sizeof(xmlTextWriter));
ret->nodes = xmlListCreate((xmlListDeallocator) ret->nodes = xmlListCreate(xmlFreeTextWriterStackEntry,
xmlFreeTextWriterStackEntry,
(xmlListDataCompare)
xmlCmpTextWriterStackEntry); xmlCmpTextWriterStackEntry);
if (ret->nodes == NULL) { if (ret->nodes == NULL) {
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
@ -201,9 +199,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
return NULL; return NULL;
} }
ret->nsstack = xmlListCreate((xmlListDeallocator) ret->nsstack = xmlListCreate(xmlFreeTextWriterNsStackEntry,
xmlFreeTextWriterNsStackEntry,
(xmlListDataCompare)
xmlCmpTextWriterNsStackEntry); xmlCmpTextWriterNsStackEntry);
if (ret->nsstack == NULL) { if (ret->nsstack == NULL) {
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
@ -329,9 +325,7 @@ xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt,
return NULL; return NULL;
} }
out = xmlOutputBufferCreateIO((xmlOutputWriteCallback) out = xmlOutputBufferCreateIO(xmlTextWriterWriteDocCallback,
xmlTextWriterWriteDocCallback,
(xmlOutputCloseCallback)
xmlTextWriterCloseDocCallback, xmlTextWriterCloseDocCallback,
(void *) ctxt, NULL); (void *) ctxt, NULL);
if (out == NULL) { if (out == NULL) {
@ -4422,12 +4416,12 @@ xmlCmpTextWriterNsStackEntry(const void *data0, const void *data1)
* Returns -1, 0, 1 * Returns -1, 0, 1
*/ */
static int static int
xmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len) xmlTextWriterWriteDocCallback(void *context, const char *str, int len)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context;
int rc; int rc;
if ((rc = xmlParseChunk(ctxt, (const char *) str, len, 0)) != 0) { if ((rc = xmlParseChunk(ctxt, str, len, 0)) != 0) {
xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR,
"xmlTextWriterWriteDocCallback : XML error %d !\n", "xmlTextWriterWriteDocCallback : XML error %d !\n",
rc); rc);
@ -4453,7 +4447,7 @@ xmlTextWriterCloseDocCallback(void *context)
if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) { if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) {
xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR,
"xmlTextWriterWriteDocCallback : XML error %d !\n", "xmlTextWriterCloseDocCallback : XML error %d !\n",
rc); rc);
return -1; return -1;
} }

View file

@ -477,84 +477,66 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
* * * *
************************************************************************/ ************************************************************************/
#ifndef TRIO_REPLACE_STDIO #ifndef NAN
#define TRIO_PUBLIC static #define NAN (0.0 / 0.0)
#endif #endif
#include "trionan.c"
/* #ifndef INFINITY
* The lack of portability of this section of the libc is annoying ! #define INFINITY HUGE_VAL
*/ #endif
double xmlXPathNAN = 0;
double xmlXPathPINF = 1; double xmlXPathNAN = NAN;
double xmlXPathNINF = -1; double xmlXPathPINF = INFINITY;
static double xmlXPathNZERO = 0; /* not exported from headers */ double xmlXPathNINF = -INFINITY;
static int xmlXPathInitialized = 0;
/** /**
* xmlXPathInit: * xmlXPathInit:
* *
* Initialize the XPath environment * Initialize the XPath environment
*
* Does nothing but must be kept as public function.
*/ */
void void
xmlXPathInit(void) { xmlXPathInit(void) {
if (xmlXPathInitialized) return;
xmlXPathPINF = trio_pinf();
xmlXPathNINF = trio_ninf();
xmlXPathNAN = trio_nan();
xmlXPathNZERO = trio_nzero();
xmlXPathInitialized = 1;
} }
/** /**
* xmlXPathIsNaN: * xmlXPathIsNaN:
* @val: a double value * @val: a double value
* *
* Provides a portable isnan() function to detect whether a double
* is a NotaNumber. Based on trio code
* http://sourceforge.net/projects/ctrio/
*
* Returns 1 if the value is a NaN, 0 otherwise * Returns 1 if the value is a NaN, 0 otherwise
*/ */
int int
xmlXPathIsNaN(double val) { xmlXPathIsNaN(double val) {
return(trio_isnan(val)); #ifdef isnan
return isnan(val);
#else
return !(val == val);
#endif
} }
/** /**
* xmlXPathIsInf: * xmlXPathIsInf:
* @val: a double value * @val: a double value
* *
* Provides a portable isinf() function to detect whether a double * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
* is a +Infinite or -Infinite. Based on trio code
* http://sourceforge.net/projects/ctrio/
*
* Returns 1 vi the value is +Infinite, -1 if -Infinite, 0 otherwise
*/ */
int int
xmlXPathIsInf(double val) { xmlXPathIsInf(double val) {
return(trio_isinf(val)); #ifdef isinf
return isinf(val) ? (val > 0 ? 1 : -1) : 0;
#else
if (val >= HUGE_VAL)
return 1;
if (val <= -HUGE_VAL)
return -1;
return 0;
#endif
} }
#endif /* SCHEMAS or XPATH */ #endif /* SCHEMAS or XPATH */
#ifdef LIBXML_XPATH_ENABLED
/**
* xmlXPathGetSign:
* @val: a double value
*
* Provides a portable function to detect the sign of a double
* Modified from trio code
* http://sourceforge.net/projects/ctrio/
*
* Returns 1 if the value is Negative, 0 if positive
*/
static int
xmlXPathGetSign(double val) {
return(trio_signbit(val));
}
#ifdef LIBXML_XPATH_ENABLED
/* /*
* TODO: when compatibility allows remove all "fake node libxslt" strings * TODO: when compatibility allows remove all "fake node libxslt" strings
@ -978,6 +960,8 @@ static int
xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt, xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op, xmlXPathStepOpPtr op,
int isPredicate); int isPredicate);
static void
xmlXPathFreeObjectEntry(void *obj, const xmlChar *name);
/************************************************************************ /************************************************************************
* * * *
@ -1421,7 +1405,8 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
default: default:
if (xmlXPathIsNaN(cur->floatval)) { if (xmlXPathIsNaN(cur->floatval)) {
fprintf(output, "Object is a number : NaN\n"); fprintf(output, "Object is a number : NaN\n");
} else if (cur->floatval == 0 && xmlXPathGetSign(cur->floatval) != 0) { } else if (cur->floatval == 0) {
/* Omit sign for negative zero. */
fprintf(output, "Object is a number : 0\n"); fprintf(output, "Object is a number : 0\n");
} else { } else {
fprintf(output, "Object is a number : %0g\n", cur->floatval); fprintf(output, "Object is a number : %0g\n", cur->floatval);
@ -3117,7 +3102,8 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
if (xmlXPathIsNaN(number)) { if (xmlXPathIsNaN(number)) {
if (buffersize > (int)sizeof("NaN")) if (buffersize > (int)sizeof("NaN"))
snprintf(buffer, buffersize, "NaN"); snprintf(buffer, buffersize, "NaN");
} else if (number == 0 && xmlXPathGetSign(number) != 0) { } else if (number == 0) {
/* Omit sign for negative zero. */
snprintf(buffer, buffersize, "0"); snprintf(buffer, buffersize, "0");
} else if ((number > INT_MIN) && (number < INT_MAX) && } else if ((number > INT_MIN) && (number < INT_MAX) &&
(number == (int) number)) { (number == (int) number)) {
@ -4582,7 +4568,7 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
xmlFree(strval); xmlFree(strval);
} }
} }
xmlHashFree(hash, (xmlHashDeallocator) xmlFree); xmlHashFree(hash, xmlHashDefaultDeallocator);
return(ret); return(ret);
} }
@ -4894,7 +4880,9 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
return(-1); return(-1);
if (f == NULL) if (f == NULL)
return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL)); return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f))); XML_IGNORE_PEDANTIC_WARNINGS
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
XML_POP_WARNINGS
} }
/** /**
@ -4975,7 +4963,9 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
if (ctxt->funcHash == NULL) if (ctxt->funcHash == NULL)
return(NULL); return(NULL);
XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri); XML_IGNORE_PEDANTIC_WARNINGS
ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
XML_POP_WARNINGS
return(ret); return(ret);
} }
@ -5044,10 +5034,9 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
return(-1); return(-1);
if (value == NULL) if (value == NULL)
return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri, return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
(xmlHashDeallocator)xmlXPathFreeObject)); xmlXPathFreeObjectEntry));
return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri, return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
(void *) value, (void *) value, xmlXPathFreeObjectEntry));
(xmlHashDeallocator)xmlXPathFreeObject));
} }
/** /**
@ -5137,7 +5126,7 @@ xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
if (ctxt == NULL) if (ctxt == NULL)
return; return;
xmlHashFree(ctxt->varHash, (xmlHashDeallocator)xmlXPathFreeObject); xmlHashFree(ctxt->varHash, xmlXPathFreeObjectEntry);
ctxt->varHash = NULL; ctxt->varHash = NULL;
} }
@ -5168,9 +5157,9 @@ xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
return(-1); return(-1);
if (ns_uri == NULL) if (ns_uri == NULL)
return(xmlHashRemoveEntry(ctxt->nsHash, prefix, return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
(xmlHashDeallocator)xmlFree)); xmlHashDefaultDeallocator));
return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri), return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
(xmlHashDeallocator)xmlFree)); xmlHashDefaultDeallocator));
} }
/** /**
@ -5219,7 +5208,7 @@ xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) {
if (ctxt == NULL) if (ctxt == NULL)
return; return;
xmlHashFree(ctxt->nsHash, (xmlHashDeallocator)xmlFree); xmlHashFree(ctxt->nsHash, xmlHashDefaultDeallocator);
ctxt->nsHash = NULL; ctxt->nsHash = NULL;
} }
@ -5533,6 +5522,11 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
xmlFree(obj); xmlFree(obj);
} }
static void
xmlXPathFreeObjectEntry(void *obj, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlXPathFreeObject((xmlXPathObjectPtr) obj);
}
/** /**
* xmlXPathReleaseObject: * xmlXPathReleaseObject:
* @obj: the xmlXPathObjectPtr to free or to cache * @obj: the xmlXPathObjectPtr to free or to cache
@ -5722,7 +5716,8 @@ xmlXPathCastNumberToString (double val) {
default: default:
if (xmlXPathIsNaN(val)) { if (xmlXPathIsNaN(val)) {
ret = xmlStrdup((const xmlChar *) "NaN"); ret = xmlStrdup((const xmlChar *) "NaN");
} else if (val == 0 && xmlXPathGetSign(val) != 0) { } else if (val == 0) {
/* Omit sign for negative zero. */
ret = xmlStrdup((const xmlChar *) "0"); ret = xmlStrdup((const xmlChar *) "0");
} else { } else {
/* could be improved */ /* could be improved */
@ -5904,10 +5899,10 @@ xmlXPathCastNodeToNumber (xmlNodePtr node) {
double ret; double ret;
if (node == NULL) if (node == NULL)
return(xmlXPathNAN); return(NAN);
strval = xmlXPathCastNodeToString(node); strval = xmlXPathCastNodeToString(node);
if (strval == NULL) if (strval == NULL)
return(xmlXPathNAN); return(NAN);
ret = xmlXPathCastStringToNumber(strval); ret = xmlXPathCastStringToNumber(strval);
xmlFree(strval); xmlFree(strval);
@ -5928,7 +5923,7 @@ xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns) {
double ret; double ret;
if (ns == NULL) if (ns == NULL)
return(xmlXPathNAN); return(NAN);
str = xmlXPathCastNodeSetToString(ns); str = xmlXPathCastNodeSetToString(ns);
ret = xmlXPathCastStringToNumber(str); ret = xmlXPathCastStringToNumber(str);
xmlFree(str); xmlFree(str);
@ -5948,13 +5943,13 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
double ret = 0.0; double ret = 0.0;
if (val == NULL) if (val == NULL)
return(xmlXPathNAN); return(NAN);
switch (val->type) { switch (val->type) {
case XPATH_UNDEFINED: case XPATH_UNDEFINED:
#ifdef DEGUB_EXPR #ifdef DEGUB_EXPR
xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n"); xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
#endif #endif
ret = xmlXPathNAN; ret = NAN;
break; break;
case XPATH_NODESET: case XPATH_NODESET:
case XPATH_XSLT_TREE: case XPATH_XSLT_TREE:
@ -5974,7 +5969,7 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
TODO; TODO;
ret = xmlXPathNAN; ret = NAN;
break; break;
} }
return(ret); return(ret);
@ -7478,20 +7473,7 @@ xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return; if ((ctxt == NULL) || (ctxt->context == NULL)) return;
CAST_TO_NUMBER; CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER); CHECK_TYPE(XPATH_NUMBER);
if (xmlXPathIsNaN(ctxt->value->floatval)) ctxt->value->floatval = -ctxt->value->floatval;
ctxt->value->floatval=xmlXPathNAN;
else if (xmlXPathIsInf(ctxt->value->floatval) == 1)
ctxt->value->floatval=xmlXPathNINF;
else if (xmlXPathIsInf(ctxt->value->floatval) == -1)
ctxt->value->floatval=xmlXPathPINF;
else if (ctxt->value->floatval == 0) {
if (xmlXPathGetSign(ctxt->value->floatval) == 0)
ctxt->value->floatval = xmlXPathNZERO;
else
ctxt->value->floatval = 0;
}
else
ctxt->value->floatval = - ctxt->value->floatval;
} }
/** /**
@ -7583,25 +7565,7 @@ xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
xmlXPathReleaseObject(ctxt->context, arg); xmlXPathReleaseObject(ctxt->context, arg);
CAST_TO_NUMBER; CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER); CHECK_TYPE(XPATH_NUMBER);
if (xmlXPathIsNaN(val) || xmlXPathIsNaN(ctxt->value->floatval)) ctxt->value->floatval /= val;
ctxt->value->floatval = xmlXPathNAN;
else if (val == 0 && xmlXPathGetSign(val) != 0) {
if (ctxt->value->floatval == 0)
ctxt->value->floatval = xmlXPathNAN;
else if (ctxt->value->floatval > 0)
ctxt->value->floatval = xmlXPathNINF;
else if (ctxt->value->floatval < 0)
ctxt->value->floatval = xmlXPathPINF;
}
else if (val == 0) {
if (ctxt->value->floatval == 0)
ctxt->value->floatval = xmlXPathNAN;
else if (ctxt->value->floatval > 0)
ctxt->value->floatval = xmlXPathPINF;
else if (ctxt->value->floatval < 0)
ctxt->value->floatval = xmlXPathNINF;
} else
ctxt->value->floatval /= val;
} }
/** /**
@ -7626,7 +7590,7 @@ xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
CHECK_TYPE(XPATH_NUMBER); CHECK_TYPE(XPATH_NUMBER);
arg1 = ctxt->value->floatval; arg1 = ctxt->value->floatval;
if (arg2 == 0) if (arg2 == 0)
ctxt->value->floatval = xmlXPathNAN; ctxt->value->floatval = NAN;
else { else {
ctxt->value->floatval = fmod(arg1, arg2); ctxt->value->floatval = fmod(arg1, arg2);
} }
@ -9745,13 +9709,9 @@ xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
f = ctxt->value->floatval; f = ctxt->value->floatval;
/* Test for zero to keep negative zero unchanged. */ if ((f >= -0.5) && (f < 0.5)) {
if ((xmlXPathIsNaN(f)) || (f == 0.0)) /* Handles negative zero. */
return; ctxt->value->floatval *= 0.0;
if ((f >= -0.5) && (f < 0.0)) {
/* Negative zero. */
ctxt->value->floatval = xmlXPathNZERO;
} }
else { else {
double rounded = floor(f); double rounded = floor(f);
@ -10098,7 +10058,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
if (cur == NULL) return(0); if (cur == NULL) return(0);
while (IS_BLANK_CH(*cur)) cur++; while (IS_BLANK_CH(*cur)) cur++;
if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) { if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
return(xmlXPathNAN); return(NAN);
} }
if (*cur == '-') { if (*cur == '-') {
isneg = 1; isneg = 1;
@ -10134,7 +10094,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
cur++; cur++;
if (((*cur < '0') || (*cur > '9')) && (!ok)) { if (((*cur < '0') || (*cur > '9')) && (!ok)) {
return(xmlXPathNAN); return(NAN);
} }
while (*cur == '0') { while (*cur == '0') {
frac = frac + 1; frac = frac + 1;
@ -10167,7 +10127,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
} }
} }
while (IS_BLANK_CH(*cur)) cur++; while (IS_BLANK_CH(*cur)) cur++;
if (*cur != 0) return(xmlXPathNAN); if (*cur != 0) return(NAN);
if (isneg) ret = -ret; if (isneg) ret = -ret;
if (is_exponent_negative) exponent = -exponent; if (is_exponent_negative) exponent = -exponent;
ret *= pow(10.0, (double)exponent); ret *= pow(10.0, (double)exponent);
@ -12426,7 +12386,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
default: default:
break; break;
} }
} else if (cur->type == type) { } else if (cur->type == (xmlElementType) type) {
if (cur->type == XML_NAMESPACE_DECL) if (cur->type == XML_NAMESPACE_DECL)
XP_TEST_HIT_NS XP_TEST_HIT_NS
else else

View file

@ -467,8 +467,6 @@ xmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end) {
return(NULL); return(NULL);
if (end == NULL) if (end == NULL)
return(NULL); return(NULL);
if (start->type != XPATH_POINT)
return(NULL);
if (end->type != XPATH_POINT) if (end->type != XPATH_POINT)
return(NULL); return(NULL);

View file

@ -31,10 +31,10 @@
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h> #include <zlib.h>
#endif #endif
#ifdef HAVE_LZMA_H #ifdef LIBXML_LZMA_ENABLED
#include <lzma.h> #include <lzma.h>
#endif #endif
@ -76,7 +76,7 @@ typedef struct {
char padding1[32]; /* padding allowing to cope with possible char padding1[32]; /* padding allowing to cope with possible
extensions of above structure without extensions of above structure without
too much side effect */ too much side effect */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/* zlib inflate or deflate stream */ /* zlib inflate or deflate stream */
z_stream zstrm; /* stream structure in-place (not a pointer) */ z_stream zstrm; /* stream structure in-place (not a pointer) */
#endif #endif
@ -130,7 +130,7 @@ xz_reset(xz_statep state)
xz_error(state, LZMA_OK, NULL); /* clear error */ xz_error(state, LZMA_OK, NULL); /* clear error */
state->pos = 0; /* no uncompressed data yet */ state->pos = 0; /* no uncompressed data yet */
state->strm.avail_in = 0; /* no input data yet */ state->strm.avail_in = 0; /* no input data yet */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
state->zstrm.avail_in = 0; /* no input data yet */ state->zstrm.avail_in = 0; /* no input data yet */
#endif #endif
} }
@ -272,7 +272,7 @@ xz_avail(xz_statep state)
return 0; return 0;
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
static int static int
xz_avail_zstrm(xz_statep state) xz_avail_zstrm(xz_statep state)
{ {
@ -349,7 +349,7 @@ is_format_lzma(xz_statep state)
return 1; return 1;
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/* Get next byte from input, or -1 if end or error. */ /* Get next byte from input, or -1 if end or error. */
#define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \ #define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \
@ -415,7 +415,7 @@ xz_head(xz_statep state)
xz_error(state, LZMA_MEM_ERROR, "out of memory"); xz_error(state, LZMA_MEM_ERROR, "out of memory");
return -1; return -1;
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/* allocate inflate memory */ /* allocate inflate memory */
state->zstrm.zalloc = Z_NULL; state->zstrm.zalloc = Z_NULL;
state->zstrm.zfree = Z_NULL; state->zstrm.zfree = Z_NULL;
@ -449,7 +449,7 @@ xz_head(xz_statep state)
state->direct = 0; state->direct = 0;
return 0; return 0;
} }
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
/* look for the gzip magic header bytes 31 and 139 */ /* look for the gzip magic header bytes 31 and 139 */
if (strm->next_in[0] == 31) { if (strm->next_in[0] == 31) {
strm->avail_in--; strm->avail_in--;
@ -550,7 +550,7 @@ xz_decomp(xz_statep state)
action = LZMA_FINISH; action = LZMA_FINISH;
/* decompress and handle errors */ /* decompress and handle errors */
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (state->how == GZIP) { if (state->how == GZIP) {
state->zstrm.avail_in = (uInt) state->strm.avail_in; state->zstrm.avail_in = (uInt) state->strm.avail_in;
state->zstrm.next_in = (Bytef *) state->strm.next_in; state->zstrm.next_in = (Bytef *) state->strm.next_in;
@ -592,13 +592,13 @@ xz_decomp(xz_statep state)
/* update available output and crc check value */ /* update available output and crc check value */
state->have = had - strm->avail_out; state->have = had - strm->avail_out;
state->next = strm->next_out - state->have; state->next = strm->next_out - state->have;
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
state->zstrm.adler = state->zstrm.adler =
crc32(state->zstrm.adler, state->next, state->have); crc32(state->zstrm.adler, state->next, state->have);
#endif #endif
if (ret == LZMA_STREAM_END) { if (ret == LZMA_STREAM_END) {
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (state->how == GZIP) { if (state->how == GZIP) {
if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) { if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
xz_error(state, LZMA_DATA_ERROR, "unexpected end of file"); xz_error(state, LZMA_DATA_ERROR, "unexpected end of file");
@ -788,7 +788,7 @@ __libxml2_xzclose(xzFile file)
/* free memory and close file */ /* free memory and close file */
if (state->size) { if (state->size) {
lzma_end(&(state->strm)); lzma_end(&(state->strm));
#ifdef HAVE_ZLIB_H #ifdef LIBXML_ZLIB_ENABLED
if (state->init == 1) if (state->init == 1)
inflateEnd(&(state->zstrm)); inflateEnd(&(state->zstrm));
state->init = 0; state->init = 0;