mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:03:07 +00:00
[LIBXML2] Update to version 2.10.0. CORE-17766
This commit is contained in:
parent
608bbe1136
commit
911153da10
80 changed files with 2351 additions and 20735 deletions
210
sdk/lib/3rdparty/libxml2/xmlreader.c
vendored
210
sdk/lib/3rdparty/libxml2/xmlreader.c
vendored
|
@ -20,13 +20,8 @@
|
|||
#ifdef LIBXML_READER_ENABLED
|
||||
#include <string.h> /* for memset() only ! */
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
|
@ -228,116 +223,6 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader);
|
|||
static void xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur);
|
||||
static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur);
|
||||
|
||||
/**
|
||||
* xmlFreeID:
|
||||
* @not: A id
|
||||
*
|
||||
* Deallocate the memory used by an id definition
|
||||
*/
|
||||
static void
|
||||
xmlFreeID(xmlIDPtr id) {
|
||||
xmlDictPtr dict = NULL;
|
||||
|
||||
if (id == NULL) return;
|
||||
|
||||
if (id->doc != NULL)
|
||||
dict = id->doc->dict;
|
||||
|
||||
if (id->value != NULL)
|
||||
DICT_FREE(id->value)
|
||||
if (id->name != NULL)
|
||||
DICT_FREE(id->name)
|
||||
xmlFree(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderRemoveID:
|
||||
* @doc: the document
|
||||
* @attr: the attribute
|
||||
*
|
||||
* Remove the given attribute from the ID table maintained internally.
|
||||
*
|
||||
* Returns -1 if the lookup failed and 0 otherwise
|
||||
*/
|
||||
static int
|
||||
xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
|
||||
xmlIDTablePtr table;
|
||||
xmlIDPtr id;
|
||||
xmlChar *ID;
|
||||
|
||||
if (doc == NULL) return(-1);
|
||||
if (attr == NULL) return(-1);
|
||||
table = (xmlIDTablePtr) doc->ids;
|
||||
if (table == NULL)
|
||||
return(-1);
|
||||
|
||||
ID = xmlNodeListGetString(doc, attr->children, 1);
|
||||
if (ID == NULL)
|
||||
return(-1);
|
||||
id = xmlHashLookup(table, ID);
|
||||
xmlFree(ID);
|
||||
if (id == NULL || id->attr != attr) {
|
||||
return(-1);
|
||||
}
|
||||
id->name = attr->name;
|
||||
attr->name = NULL;
|
||||
id->attr = NULL;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderWalkRemoveRef:
|
||||
* @data: Contents of current link
|
||||
* @user: Value supplied by the user
|
||||
*
|
||||
* Returns 0 to abort the walk or 1 to continue
|
||||
*/
|
||||
static int
|
||||
xmlTextReaderWalkRemoveRef(const void *data, void *user)
|
||||
{
|
||||
xmlRefPtr ref = (xmlRefPtr)data;
|
||||
xmlAttrPtr attr = (xmlAttrPtr)user;
|
||||
|
||||
if (ref->attr == attr) { /* Matched: remove and terminate walk */
|
||||
ref->name = xmlStrdup(attr->name);
|
||||
ref->attr = NULL;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderRemoveRef:
|
||||
* @doc: the document
|
||||
* @attr: the attribute
|
||||
*
|
||||
* Remove the given attribute from the Ref table maintained internally.
|
||||
*
|
||||
* Returns -1 if the lookup failed and 0 otherwise
|
||||
*/
|
||||
static int
|
||||
xmlTextReaderRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
|
||||
xmlListPtr ref_list;
|
||||
xmlRefTablePtr table;
|
||||
xmlChar *ID;
|
||||
|
||||
if (doc == NULL) return(-1);
|
||||
if (attr == NULL) return(-1);
|
||||
table = (xmlRefTablePtr) doc->refs;
|
||||
if (table == NULL)
|
||||
return(-1);
|
||||
|
||||
ID = xmlNodeListGetString(doc, attr->children, 1);
|
||||
if (ID == NULL)
|
||||
return(-1);
|
||||
ref_list = xmlHashLookup(table, ID);
|
||||
xmlFree(ID);
|
||||
if(ref_list == NULL)
|
||||
return (-1);
|
||||
xmlListWalk(ref_list, xmlTextReaderWalkRemoveRef, attr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderFreeProp:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
|
@ -358,15 +243,6 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
|
|||
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
|
||||
xmlDeregisterNodeDefaultValue((xmlNodePtr) cur);
|
||||
|
||||
/* Check for ID removal -> leading to invalid references ! */
|
||||
if ((cur->parent != NULL) && (cur->parent->doc != NULL)) {
|
||||
if (xmlIsID(cur->parent->doc, cur->parent, cur))
|
||||
xmlTextReaderRemoveID(cur->parent->doc, cur);
|
||||
if (((cur->parent->doc->intSubset != NULL) ||
|
||||
(cur->parent->doc->extSubset != NULL)) &&
|
||||
(xmlIsRef(cur->parent->doc, cur->parent, cur)))
|
||||
xmlTextReaderRemoveRef(cur->parent->doc, cur);
|
||||
}
|
||||
if (cur->children != NULL)
|
||||
xmlTextReaderFreeNodeList(reader, cur->children);
|
||||
|
||||
|
@ -570,22 +446,6 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xmlTextReaderFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) {
|
||||
xmlFreeID((xmlIDPtr) id);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderFreeIDTable:
|
||||
* @table: An id table
|
||||
*
|
||||
* Deallocate the memory used by an ID hash table.
|
||||
*/
|
||||
static void
|
||||
xmlTextReaderFreeIDTable(xmlIDTablePtr table) {
|
||||
xmlHashFree(table, xmlTextReaderFreeIDTableEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderFreeDoc:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
|
@ -605,7 +465,7 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
|
|||
/*
|
||||
* Do this before freeing the children list to avoid ID lookups
|
||||
*/
|
||||
if (cur->ids != NULL) xmlTextReaderFreeIDTable((xmlIDTablePtr) cur->ids);
|
||||
if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
|
||||
cur->ids = NULL;
|
||||
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
|
||||
cur->refs = NULL;
|
||||
|
@ -1320,6 +1180,7 @@ xmlTextReaderCollectSiblings(xmlNodePtr node)
|
|||
buffer = xmlBufferCreate();
|
||||
if (buffer == NULL)
|
||||
return NULL;
|
||||
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
|
||||
for ( ; node != NULL; node = node->next) {
|
||||
switch (node->type) {
|
||||
|
@ -1524,9 +1385,6 @@ get_next_node:
|
|||
reader->node = reader->node->parent;
|
||||
if ((reader->node == NULL) ||
|
||||
(reader->node->type == XML_DOCUMENT_NODE) ||
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
(reader->node->type == XML_DOCB_DOCUMENT_NODE) ||
|
||||
#endif
|
||||
(reader->node->type == XML_HTML_DOCUMENT_NODE)) {
|
||||
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
|
||||
val = xmlParseChunk(reader->ctxt, "", 0, 1);
|
||||
|
@ -1776,11 +1634,14 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
|
|||
buff = xmlBufferCreate();
|
||||
if (buff == NULL)
|
||||
return NULL;
|
||||
xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
for (cur_node = reader->node->children; cur_node != NULL;
|
||||
cur_node = cur_node->next) {
|
||||
/* XXX: Why is the node copied? */
|
||||
node = xmlDocCopyNode(cur_node, doc, 1);
|
||||
/* XXX: Why do we need a second buffer? */
|
||||
buff2 = xmlBufferCreate();
|
||||
xmlBufferSetAllocationScheme(buff2, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) {
|
||||
xmlFreeNode(node);
|
||||
xmlBufferFree(buff2);
|
||||
|
@ -1830,6 +1691,7 @@ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
|
|||
node = xmlDocCopyNode(node, doc, 1);
|
||||
}
|
||||
buff = xmlBufferCreate();
|
||||
xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
if (xmlNodeDump(buff, doc, node, 0, 0) == -1) {
|
||||
xmlFreeNode(node);
|
||||
xmlBufferFree(buff);
|
||||
|
@ -2160,7 +2022,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
|||
}
|
||||
/* no operation on a reader should require a huge buffer */
|
||||
xmlBufSetAllocationScheme(ret->buffer,
|
||||
XML_BUFFER_ALLOC_BOUNDED);
|
||||
XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
||||
if (ret->sax == NULL) {
|
||||
xmlBufFree(ret->buffer);
|
||||
|
@ -2319,36 +2181,16 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
|
|||
xmlFree(reader->patternTab);
|
||||
}
|
||||
#endif
|
||||
if (reader->faketext != NULL) {
|
||||
xmlFreeNode(reader->faketext);
|
||||
}
|
||||
if (reader->mode != XML_TEXTREADER_MODE_CLOSED)
|
||||
xmlTextReaderClose(reader);
|
||||
if (reader->ctxt != NULL) {
|
||||
if (reader->dict == reader->ctxt->dict)
|
||||
reader->dict = NULL;
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if ((reader->ctxt->vctxt.vstateTab != NULL) &&
|
||||
(reader->ctxt->vctxt.vstateMax > 0)){
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
while (reader->ctxt->vctxt.vstateNr > 0)
|
||||
xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
|
||||
#endif /* LIBXML_REGEXP_ENABLED */
|
||||
xmlFree(reader->ctxt->vctxt.vstateTab);
|
||||
reader->ctxt->vctxt.vstateTab = NULL;
|
||||
reader->ctxt->vctxt.vstateMax = 0;
|
||||
}
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
if (reader->ctxt->myDoc != NULL) {
|
||||
if (reader->preserve == 0)
|
||||
xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc);
|
||||
reader->ctxt->myDoc = NULL;
|
||||
}
|
||||
if (reader->allocs & XML_TEXTREADER_CTXT)
|
||||
xmlFreeParserCtxt(reader->ctxt);
|
||||
}
|
||||
if (reader->sax != NULL)
|
||||
xmlFree(reader->sax);
|
||||
if ((reader->input != NULL) && (reader->allocs & XML_TEXTREADER_INPUT))
|
||||
xmlFreeParserInputBuffer(reader->input);
|
||||
if (reader->buffer != NULL)
|
||||
xmlBufFree(reader->buffer);
|
||||
if (reader->entTab != NULL)
|
||||
|
@ -2379,7 +2221,23 @@ xmlTextReaderClose(xmlTextReaderPtr reader) {
|
|||
reader->node = NULL;
|
||||
reader->curnode = NULL;
|
||||
reader->mode = XML_TEXTREADER_MODE_CLOSED;
|
||||
if (reader->faketext != NULL) {
|
||||
xmlFreeNode(reader->faketext);
|
||||
reader->faketext = NULL;
|
||||
}
|
||||
if (reader->ctxt != NULL) {
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if ((reader->ctxt->vctxt.vstateTab != NULL) &&
|
||||
(reader->ctxt->vctxt.vstateMax > 0)){
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
while (reader->ctxt->vctxt.vstateNr > 0)
|
||||
xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
|
||||
#endif /* LIBXML_REGEXP_ENABLED */
|
||||
xmlFree(reader->ctxt->vctxt.vstateTab);
|
||||
reader->ctxt->vctxt.vstateTab = NULL;
|
||||
reader->ctxt->vctxt.vstateMax = 0;
|
||||
}
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
xmlStopParser(reader->ctxt);
|
||||
if (reader->ctxt->myDoc != NULL) {
|
||||
if (reader->preserve == 0)
|
||||
|
@ -3118,9 +2976,6 @@ xmlTextReaderNodeType(xmlTextReaderPtr reader) {
|
|||
return(XML_READER_TYPE_COMMENT);
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
return(XML_READER_TYPE_DOCUMENT);
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
return(XML_READER_TYPE_DOCUMENT_FRAGMENT);
|
||||
|
@ -3275,9 +3130,6 @@ xmlTextReaderName(xmlTextReaderPtr reader) {
|
|||
return(xmlStrdup(BAD_CAST "#comment"));
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
return(xmlStrdup(BAD_CAST "#document"));
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
return(xmlStrdup(BAD_CAST "#document-fragment"));
|
||||
|
@ -3346,9 +3198,6 @@ xmlTextReaderConstName(xmlTextReaderPtr reader) {
|
|||
return(CONSTSTR(BAD_CAST "#comment"));
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
return(CONSTSTR(BAD_CAST "#document"));
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
return(CONSTSTR(BAD_CAST "#document-fragment"));
|
||||
|
@ -3707,7 +3556,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
|
|||
return (NULL);
|
||||
}
|
||||
xmlBufSetAllocationScheme(reader->buffer,
|
||||
XML_BUFFER_ALLOC_BOUNDED);
|
||||
XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
} else
|
||||
xmlBufEmpty(reader->buffer);
|
||||
xmlBufGetNodeContent(reader->buffer, node);
|
||||
|
@ -3717,7 +3566,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
|
|||
xmlBufFree(reader->buffer);
|
||||
reader->buffer = xmlBufCreateSize(100);
|
||||
xmlBufSetAllocationScheme(reader->buffer,
|
||||
XML_BUFFER_ALLOC_BOUNDED);
|
||||
XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
ret = BAD_CAST "";
|
||||
}
|
||||
return(ret);
|
||||
|
@ -5231,7 +5080,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
|||
}
|
||||
/* no operation on a reader should require a huge buffer */
|
||||
xmlBufSetAllocationScheme(reader->buffer,
|
||||
XML_BUFFER_ALLOC_BOUNDED);
|
||||
XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
if (reader->sax == NULL)
|
||||
reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
||||
if (reader->sax == NULL) {
|
||||
|
@ -6028,6 +5877,5 @@ main(int argc, char **argv)
|
|||
}
|
||||
#endif
|
||||
#endif /* NOT_USED_YET */
|
||||
#define bottom_xmlreader
|
||||
#include "elfgcchack.h"
|
||||
|
||||
#endif /* LIBXML_READER_ENABLED */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue