mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
xml2: Import upstream release 2.12.8.
This commit is contained in:
parent
530b3f1694
commit
9d34c44d84
Notes:
Alexandre Julliard
2024-10-17 23:51:32 +02:00
Approved-by: Nikolay Sivov (@nsivov) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6674
78 changed files with 6774 additions and 10531 deletions
|
@ -49,15 +49,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
||||
|
||||
/* not defined in older versions */
|
||||
#define XML_SAVE_FORMAT 1
|
||||
#define XML_SAVE_NO_DECL 2
|
||||
#define XML_SAVE_NO_EMPTY 4
|
||||
#define XML_SAVE_NO_XHTML 8
|
||||
#define XML_SAVE_XHTML 16
|
||||
#define XML_SAVE_AS_XML 32
|
||||
#define XML_SAVE_AS_HTML 64
|
||||
|
||||
static const WCHAR PropertySelectionLanguageW[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0};
|
||||
static const WCHAR PropertySelectionNamespacesW[] = {'S','e','l','e','c','t','i','o','n','N','a','m','e','s','p','a','c','e','s',0};
|
||||
static const WCHAR PropertyProhibitDTDW[] = {'P','r','o','h','i','b','i','t','D','T','D',0};
|
||||
|
@ -502,13 +493,14 @@ static void LIBXML2_LOG_CALLBACK sax_warning(void* ctx, char const* msg, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
static void sax_serror(void* ctx, xmlErrorPtr err)
|
||||
static void sax_serror(void* ctx, const xmlError* err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(doparse, err);
|
||||
}
|
||||
|
||||
static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding encoding)
|
||||
{
|
||||
char *ctx_encoding;
|
||||
xmlDocPtr doc = NULL;
|
||||
xmlParserCtxtPtr pctx;
|
||||
static xmlSAXHandler sax_handler = {
|
||||
|
@ -573,6 +565,8 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding
|
|||
pctx->myDoc = NULL;
|
||||
}
|
||||
pctx->sax = NULL;
|
||||
ctx_encoding = (char *)pctx->encoding;
|
||||
pctx->encoding = NULL;
|
||||
xmlFreeParserCtxt(pctx);
|
||||
|
||||
/* TODO: put this in one of the SAX callbacks */
|
||||
|
@ -589,9 +583,9 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding
|
|||
sprintf(buff, "version=\"%s\"", doc->version ? (char*)doc->version : "1.0");
|
||||
xmlNodeAddContent( node, xmlbuff );
|
||||
|
||||
if (doc->encoding)
|
||||
if (ctx_encoding)
|
||||
{
|
||||
sprintf(buff, " encoding=\"%s\"", doc->encoding);
|
||||
sprintf(buff, " encoding=\"%s\"", ctx_encoding);
|
||||
xmlNodeAddContent( node, xmlbuff );
|
||||
}
|
||||
|
||||
|
@ -604,6 +598,7 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding
|
|||
xmldoc_link_xmldecl( doc, node );
|
||||
}
|
||||
|
||||
xmlFree( ctx_encoding );
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg,
|
|||
wine_dbg_log(dbcl, &__wine_dbch_msxml, caller, "%s", buff);
|
||||
}
|
||||
|
||||
void wineXmlCallbackError(char const* caller, xmlErrorPtr err)
|
||||
void wineXmlCallbackError(char const* caller, const xmlError* err)
|
||||
{
|
||||
enum __wine_debug_class dbcl;
|
||||
|
||||
|
@ -167,7 +167,7 @@ static int to_utf8(int cp, unsigned char *out, int *outlen, const unsigned char
|
|||
WCHAR *tmp;
|
||||
int len = 0;
|
||||
|
||||
if (!in || !inlen) goto done;
|
||||
if (!in || !inlen || !*inlen) goto done;
|
||||
|
||||
len = MultiByteToWideChar(cp, 0, (const char *)in, *inlen, NULL, 0);
|
||||
tmp = malloc(len * sizeof(WCHAR));
|
||||
|
@ -187,7 +187,7 @@ static int from_utf8(int cp, unsigned char *out, int *outlen, const unsigned cha
|
|||
WCHAR *tmp;
|
||||
int len = 0;
|
||||
|
||||
if (!in || !inlen) goto done;
|
||||
if (!in || !inlen || !*inlen) goto done;
|
||||
|
||||
len = MultiByteToWideChar(CP_UTF8, 0, (const char *)in, *inlen, NULL, 0);
|
||||
tmp = malloc(len * sizeof(WCHAR));
|
||||
|
@ -365,10 +365,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
|
|||
case DLL_PROCESS_ATTACH:
|
||||
xmlInitParser();
|
||||
|
||||
/* Set the default indent character to a single tab,
|
||||
for this thread and as default for new threads */
|
||||
/* Set the default indent character to a single tab */
|
||||
xmlTreeIndentString = "\t";
|
||||
xmlThrDefTreeIndentString("\t");
|
||||
|
||||
/* Register callbacks for loading XML files */
|
||||
if(xmlRegisterInputCallbacks(wineXmlMatchCallback, wineXmlOpenCallback,
|
||||
|
|
|
@ -165,7 +165,7 @@ extern MSXML_VERSION xmldoc_version( xmlDocPtr doc );
|
|||
extern HRESULT XMLElement_create( xmlNodePtr node, LPVOID *ppObj, BOOL own );
|
||||
|
||||
extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap);
|
||||
extern void wineXmlCallbackError(char const* caller, xmlErrorPtr err);
|
||||
extern void wineXmlCallbackError(char const* caller, const xmlError* err);
|
||||
|
||||
#define LIBXML2_LOG_CALLBACK WINAPIV __WINE_PRINTF_ATTR(2,3)
|
||||
|
||||
|
|
|
@ -2503,18 +2503,9 @@ static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int siz
|
|||
|
||||
if (size >= 4)
|
||||
{
|
||||
const unsigned char *buff = (unsigned char*)buffer;
|
||||
|
||||
encoding = xmlDetectCharEncoding((xmlChar*)buffer, 4);
|
||||
enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
|
||||
TRACE("detected encoding: %s\n", enc_name);
|
||||
/* skip BOM, parser won't switch encodings and so won't skip it on its own */
|
||||
if ((encoding == XML_CHAR_ENCODING_UTF8) &&
|
||||
buff[0] == 0xEF && buff[1] == 0xBB && buff[2] == 0xBF)
|
||||
{
|
||||
buffer += 3;
|
||||
size -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* if libxml2 detection failed try to guess */
|
||||
|
|
|
@ -243,7 +243,7 @@ static void LIBXML2_LOG_CALLBACK parser_warning(void* ctx, char const* msg, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
static void parser_serror(void* ctx, xmlErrorPtr err)
|
||||
static void parser_serror(void* ctx, const xmlError* err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(Schema_parse, err);
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ static void LIBXML2_LOG_CALLBACK validate_warning(void* ctx, char const* msg, ..
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
static void validate_serror(void* ctx, xmlErrorPtr err)
|
||||
static void validate_serror(void* ctx, const xmlError* err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(Schema_validate_tree, err);
|
||||
}
|
||||
|
|
|
@ -756,7 +756,7 @@ static void XSLPattern_OP_IGEq(xmlXPathParserContextPtr pctx, int nargs)
|
|||
xmlFree(arg2);
|
||||
}
|
||||
|
||||
static void query_serror(void* ctx, xmlErrorPtr err)
|
||||
static void query_serror(void* ctx, const xmlError* err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(domselection_create, err);
|
||||
}
|
||||
|
|
|
@ -11008,8 +11008,8 @@ static void test_load(void)
|
|||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
|
||||
hr = IXMLDOMDocument_load(doc, src, &b);
|
||||
todo_wine ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(b == VARIANT_FALSE, "got %d\n", b);
|
||||
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
|
||||
ok(b == VARIANT_FALSE, "got %d\n", b);
|
||||
|
||||
VariantClear(&src);
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ L"<Schema xmlns='urn:schemas-microsoft-com:xml-data'\n"
|
|||
" <ElementType name='uuidData' content='textOnly' dt:type='uuid'/>\n"
|
||||
"\n"
|
||||
" <ElementType name='Name' content='textOnly' dt:type='nmtoken'/>\n"
|
||||
" <ElementType name='Value' content='eltOnly' order='many'>\n"
|
||||
" <ElementType name='Value' content='eltOnly' order='many' model='closed'>\n"
|
||||
" <element type='base64Data'/>\n"
|
||||
" <element type='hexData'/>\n"
|
||||
" <element type='boolData'/>\n"
|
||||
|
@ -153,11 +153,11 @@ L"<Schema xmlns='urn:schemas-microsoft-com:xml-data'\n"
|
|||
" <element type='uriData'/>\n"
|
||||
" <element type='uuidData'/>\n"
|
||||
" </ElementType>\n"
|
||||
" <ElementType name='Property' content='eltOnly' order='seq'>\n"
|
||||
" <ElementType name='Property' content='eltOnly' order='seq' model='closed'>\n"
|
||||
" <element type='Name'/>\n"
|
||||
" <element type='Value'/>\n"
|
||||
" </ElementType>\n"
|
||||
" <ElementType name='Properties' content='eltOnly'>\n"
|
||||
" <ElementType name='Properties' content='eltOnly' model='closed'>\n"
|
||||
" <element type='Property' minOccurs='0' maxOccurs='*'/>\n"
|
||||
" </ElementType>\n"
|
||||
"</Schema>";
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef __XSLPATTERN__
|
||||
#define __XSLPATTERN__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,10 +19,8 @@
|
|||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/entities.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/uri.h>
|
||||
|
||||
#include "private/buf.h"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <libxml/uri.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/SAX2.h>
|
||||
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
|
|
400
libs/xml2/SAX2.c
400
libs/xml2/SAX2.c
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <libxml/SAX2.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
|
@ -22,19 +23,14 @@
|
|||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/debugXML.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/SAX.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#include "private/error.h"
|
||||
#include "private/parser.h"
|
||||
#include "private/tree.h"
|
||||
|
||||
/* #define DEBUG_SAX2 */
|
||||
/* #define DEBUG_SAX2_TREE */
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
*
|
||||
|
@ -331,11 +327,6 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlDtdPtr dtd;
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2InternalSubset(%s, %s, %s)\n",
|
||||
name, ExternalID, SystemID);
|
||||
#endif
|
||||
|
||||
if (ctxt->myDoc == NULL)
|
||||
return;
|
||||
|
@ -368,11 +359,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2ExternalSubset(%s, %s, %s)\n",
|
||||
name, ExternalID, SystemID);
|
||||
#endif
|
||||
if (((ExternalID != NULL) || (SystemID != NULL)) &&
|
||||
(((ctxt->validate) || (ctxt->loadsubset != 0)) &&
|
||||
(ctxt->wellFormed && ctxt->myDoc))) {
|
||||
|
@ -384,8 +370,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
int oldinputMax;
|
||||
xmlParserInputPtr *oldinputTab;
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlCharEncoding enc;
|
||||
int oldcharset;
|
||||
const xmlChar *oldencoding;
|
||||
int oldprogressive;
|
||||
unsigned long consumed;
|
||||
|
@ -410,7 +394,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
oldinputNr = ctxt->inputNr;
|
||||
oldinputMax = ctxt->inputMax;
|
||||
oldinputTab = ctxt->inputTab;
|
||||
oldcharset = ctxt->charset;
|
||||
oldencoding = ctxt->encoding;
|
||||
oldprogressive = ctxt->progressive;
|
||||
ctxt->encoding = NULL;
|
||||
|
@ -425,7 +408,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
ctxt->inputNr = oldinputNr;
|
||||
ctxt->inputMax = oldinputMax;
|
||||
ctxt->inputTab = oldinputTab;
|
||||
ctxt->charset = oldcharset;
|
||||
ctxt->encoding = oldencoding;
|
||||
ctxt->progressive = oldprogressive;
|
||||
return;
|
||||
|
@ -435,14 +417,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
ctxt->input = NULL;
|
||||
xmlPushInput(ctxt, input);
|
||||
|
||||
/*
|
||||
* On the fly encoding conversion if needed
|
||||
*/
|
||||
if (ctxt->input->length >= 4) {
|
||||
enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
|
||||
if (input->filename == NULL)
|
||||
input->filename = (char *) xmlCanonicPath(SystemID);
|
||||
input->line = 1;
|
||||
|
@ -484,7 +458,6 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
|
|||
ctxt->inputNr = oldinputNr;
|
||||
ctxt->inputMax = oldinputMax;
|
||||
ctxt->inputTab = oldinputTab;
|
||||
ctxt->charset = oldcharset;
|
||||
if ((ctxt->encoding != NULL) &&
|
||||
((ctxt->dict == NULL) ||
|
||||
(!xmlDictOwns(ctxt->dict, ctxt->encoding))))
|
||||
|
@ -525,11 +498,6 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
|
|||
|
||||
URI = xmlBuildURI(systemId, (const xmlChar *) base);
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2ResolveEntity(%s, %s)\n", publicId, systemId);
|
||||
#endif
|
||||
|
||||
ret = xmlLoadExternalEntity((const char *) URI,
|
||||
(const char *) publicId, ctxt);
|
||||
if (URI != NULL)
|
||||
|
@ -553,10 +521,6 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
|
|||
xmlEntityPtr ret = NULL;
|
||||
|
||||
if (ctx == NULL) return(NULL);
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2GetEntity(%s)\n", name);
|
||||
#endif
|
||||
|
||||
if (ctxt->inSubset == 0) {
|
||||
ret = xmlGetPredefinedEntity(name);
|
||||
|
@ -603,10 +567,6 @@ xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
|
|||
xmlEntityPtr ret;
|
||||
|
||||
if (ctx == NULL) return(NULL);
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2GetParameterEntity(%s)\n", name);
|
||||
#endif
|
||||
|
||||
ret = xmlGetParameterEntity(ctxt->myDoc, name);
|
||||
return(ret);
|
||||
|
@ -632,11 +592,6 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2EntityDecl(%s, %d, %s, %s, %s)\n",
|
||||
name, type, publicId, systemId, content);
|
||||
#endif
|
||||
if (ctxt->inSubset == 1) {
|
||||
ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
|
||||
systemId, content);
|
||||
|
@ -709,11 +664,6 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
|
|||
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2AttributeDecl(%s, %s, %d, %d, %s, ...)\n",
|
||||
elem, fullname, type, def, defaultValue);
|
||||
#endif
|
||||
if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) &&
|
||||
(type != XML_ATTRIBUTE_ID)) {
|
||||
/*
|
||||
|
@ -779,11 +729,6 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
|
|||
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2ElementDecl(%s, %d, ...)\n", name, type);
|
||||
#endif
|
||||
|
||||
if (ctxt->inSubset == 1)
|
||||
elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
|
||||
name, (xmlElementTypeVal) type, content);
|
||||
|
@ -828,11 +773,6 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
|
|||
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2NotationDecl(%s, %s, %s)\n", name, publicId, systemId);
|
||||
#endif
|
||||
|
||||
if ((publicId == NULL) && (systemId == NULL)) {
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
|
||||
"SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n",
|
||||
|
@ -877,11 +817,6 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
|
|||
xmlEntityPtr ent;
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2UnparsedEntityDecl(%s, %s, %s, %s)\n",
|
||||
name, publicId, systemId, notationName);
|
||||
#endif
|
||||
if (ctxt->inSubset == 1) {
|
||||
ent = xmlAddDocEntity(ctxt->myDoc, name,
|
||||
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,
|
||||
|
@ -940,11 +875,6 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
|
|||
void
|
||||
xmlSAX2SetDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2SetDocumentLocator()\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -961,10 +891,6 @@ xmlSAX2StartDocument(void *ctx)
|
|||
|
||||
if (ctx == NULL) return;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2StartDocument()\n");
|
||||
#endif
|
||||
if (ctxt->html) {
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (ctxt->myDoc == NULL)
|
||||
|
@ -990,10 +916,6 @@ xmlSAX2StartDocument(void *ctx)
|
|||
if (ctxt->options & XML_PARSE_OLD10)
|
||||
doc->properties |= XML_DOC_OLD10;
|
||||
doc->parseFlags = ctxt->options;
|
||||
if (ctxt->encoding != NULL)
|
||||
doc->encoding = xmlStrdup(ctxt->encoding);
|
||||
else
|
||||
doc->encoding = NULL;
|
||||
doc->standalone = ctxt->standalone;
|
||||
} else {
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
|
||||
|
@ -1022,10 +944,8 @@ void
|
|||
xmlSAX2EndDocument(void *ctx)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2EndDocument()\n");
|
||||
#endif
|
||||
xmlDocPtr doc;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if (ctxt->validate && ctxt->wellFormed &&
|
||||
|
@ -1033,23 +953,15 @@ xmlSAX2EndDocument(void *ctx)
|
|||
ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
|
||||
/*
|
||||
* Grab the encoding if it was added on-the-fly
|
||||
*/
|
||||
if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
|
||||
(ctxt->myDoc->encoding == NULL)) {
|
||||
ctxt->myDoc->encoding = ctxt->encoding;
|
||||
ctxt->encoding = NULL;
|
||||
}
|
||||
if ((ctxt->inputTab != NULL) &&
|
||||
(ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) &&
|
||||
(ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
|
||||
(ctxt->myDoc->encoding == NULL)) {
|
||||
ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
|
||||
}
|
||||
if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
|
||||
(ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
|
||||
ctxt->myDoc->charset = ctxt->charset;
|
||||
doc = ctxt->myDoc;
|
||||
if ((doc != NULL) && (doc->encoding == NULL)) {
|
||||
const xmlChar *encoding = xmlGetActualEncoding(ctxt);
|
||||
|
||||
if (encoding != NULL) {
|
||||
doc->encoding = xmlStrdup(encoding);
|
||||
if (doc->encoding == NULL)
|
||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2EndDocument");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1612,11 +1524,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||
int i;
|
||||
|
||||
if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return;
|
||||
parent = ctxt->node;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2StartElement(%s)\n", fullname);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* First check on validity:
|
||||
|
@ -1654,14 +1561,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
|
||||
return;
|
||||
}
|
||||
if (ctxt->myDoc->children == NULL) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name);
|
||||
#endif
|
||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||
} else if (parent == NULL) {
|
||||
parent = ctxt->myDoc->children;
|
||||
}
|
||||
ctxt->nodemem = -1;
|
||||
if (ctxt->linenumbers) {
|
||||
if (ctxt->input != NULL) {
|
||||
|
@ -1672,12 +1571,14 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize parent before pushing node */
|
||||
parent = ctxt->node;
|
||||
if (parent == NULL)
|
||||
parent = (xmlNodePtr) ctxt->myDoc;
|
||||
|
||||
/*
|
||||
* We are parsing a new node.
|
||||
*/
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
|
||||
#endif
|
||||
if (nodePush(ctxt, ret) < 0) {
|
||||
xmlUnlinkNode(ret);
|
||||
xmlFreeNode(ret);
|
||||
|
@ -1689,22 +1590,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||
/*
|
||||
* Link the child element
|
||||
*/
|
||||
if (parent != NULL) {
|
||||
if (parent->type == XML_ELEMENT_NODE) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding child %s to %s\n", name, parent->name);
|
||||
#endif
|
||||
xmlAddChild(parent, ret);
|
||||
} else {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding sibling %s to ", name);
|
||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||
#endif
|
||||
xmlAddSibling(parent, ret);
|
||||
}
|
||||
}
|
||||
xmlAddChild(parent, ret);
|
||||
|
||||
if (!ctxt->html) {
|
||||
/*
|
||||
|
@ -1819,16 +1705,8 @@ void
|
|||
xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlNodePtr cur;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
cur = ctxt->node;
|
||||
#ifdef DEBUG_SAX
|
||||
if (name == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(NULL)\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name);
|
||||
#endif
|
||||
|
||||
ctxt->nodemem = -1;
|
||||
|
||||
|
@ -1836,16 +1714,13 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
|||
if (ctxt->validate && ctxt->wellFormed &&
|
||||
ctxt->myDoc && ctxt->myDoc->intSubset)
|
||||
ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
|
||||
cur);
|
||||
ctxt->node);
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
|
||||
|
||||
/*
|
||||
* end of parsing of this node.
|
||||
*/
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name);
|
||||
#endif
|
||||
nodePop(ctxt);
|
||||
}
|
||||
#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLED || LIBXML_LEGACY_ENABLED */
|
||||
|
@ -1921,18 +1796,6 @@ skip:
|
|||
} else
|
||||
ret->content = (xmlChar *) intern;
|
||||
|
||||
if (ctxt->linenumbers) {
|
||||
if (ctxt->input != NULL) {
|
||||
if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
|
||||
ret->line = ctxt->input->line;
|
||||
else {
|
||||
ret->line = USHRT_MAX;
|
||||
if (ctxt->options & XML_PARSE_BIG_LINES)
|
||||
ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
||||
xmlRegisterNodeDefaultValue(ret);
|
||||
return(ret);
|
||||
|
@ -1982,8 +1845,10 @@ decode:
|
|||
* The default handling is to convert the attribute into an
|
||||
* DOM subtree and past it in a new xmlAttr element added to
|
||||
* the element.
|
||||
*
|
||||
* Returns the new attribute or NULL in case of error.
|
||||
*/
|
||||
static void
|
||||
static xmlAttrPtr
|
||||
xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
||||
const xmlChar * localname,
|
||||
const xmlChar * prefix,
|
||||
|
@ -1997,8 +1862,12 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
|||
/*
|
||||
* Note: if prefix == NULL, the attribute is not in the default namespace
|
||||
*/
|
||||
if (prefix != NULL)
|
||||
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
|
||||
if (prefix != NULL) {
|
||||
namespace = xmlParserNsLookupSax(ctxt, prefix);
|
||||
if ((namespace == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
|
||||
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate the node
|
||||
|
@ -2007,43 +1876,38 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
|||
ret = ctxt->freeAttrs;
|
||||
ctxt->freeAttrs = ret->next;
|
||||
ctxt->freeAttrsNr--;
|
||||
memset(ret, 0, sizeof(xmlAttr));
|
||||
ret->type = XML_ATTRIBUTE_NODE;
|
||||
|
||||
ret->parent = ctxt->node;
|
||||
ret->doc = ctxt->myDoc;
|
||||
ret->ns = namespace;
|
||||
|
||||
if (ctxt->dictNames)
|
||||
ret->name = localname;
|
||||
else
|
||||
ret->name = xmlStrdup(localname);
|
||||
|
||||
/* link at the end to preserve order, TODO speed up with a last */
|
||||
if (ctxt->node->properties == NULL) {
|
||||
ctxt->node->properties = ret;
|
||||
} else {
|
||||
xmlAttrPtr prev = ctxt->node->properties;
|
||||
|
||||
while (prev->next != NULL) prev = prev->next;
|
||||
prev->next = ret;
|
||||
ret->prev = prev;
|
||||
}
|
||||
|
||||
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
||||
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
|
||||
} else {
|
||||
if (ctxt->dictNames)
|
||||
ret = xmlNewNsPropEatName(ctxt->node, namespace,
|
||||
(xmlChar *) localname, NULL);
|
||||
else
|
||||
ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(ctxt, "xmlSAX2AttributeNs");
|
||||
return;
|
||||
}
|
||||
ret = xmlMalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
xmlSAX2ErrMemory(ctxt, NULL);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
memset(ret, 0, sizeof(xmlAttr));
|
||||
ret->type = XML_ATTRIBUTE_NODE;
|
||||
|
||||
/*
|
||||
* xmlParseBalancedChunkMemoryRecover had a bug that could result in
|
||||
* a mismatch between ctxt->node->doc and ctxt->myDoc. We use
|
||||
* ctxt->node->doc here, but we should somehow make sure that the
|
||||
* document pointers match.
|
||||
*/
|
||||
|
||||
/* assert(ctxt->node->doc == ctxt->myDoc); */
|
||||
|
||||
ret->parent = ctxt->node;
|
||||
ret->doc = ctxt->node->doc;
|
||||
ret->ns = namespace;
|
||||
|
||||
if (ctxt->dictNames)
|
||||
ret->name = localname;
|
||||
else
|
||||
ret->name = xmlStrdup(localname);
|
||||
|
||||
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
||||
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
|
||||
|
||||
if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
|
||||
xmlNodePtr tmp;
|
||||
|
||||
|
@ -2174,15 +2038,11 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
|||
*
|
||||
* Open issue: normalization of the value.
|
||||
*/
|
||||
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if (xmlValidateNCName(content, 1) != 0) {
|
||||
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
|
||||
"xml:id : attribute value %s is not an NCName\n",
|
||||
(const char *) content, NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
|
||||
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
|
||||
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
|
||||
|
@ -2192,6 +2052,8 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
|||
}
|
||||
if (dup != NULL)
|
||||
xmlFree(dup);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2231,7 +2093,6 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
int i, j;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
parent = ctxt->node;
|
||||
/*
|
||||
* First check on validity:
|
||||
*/
|
||||
|
@ -2309,9 +2170,6 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
if (parent == NULL) {
|
||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||
}
|
||||
/*
|
||||
* Build the namespace list
|
||||
*/
|
||||
|
@ -2336,6 +2194,9 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
xmlParserNsUpdateSax(ctxt, pref, ns);
|
||||
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
|
||||
ctxt->myDoc && ctxt->myDoc->intSubset) {
|
||||
|
@ -2346,6 +2207,11 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
}
|
||||
ctxt->nodemem = -1;
|
||||
|
||||
/* Initialize parent before pushing node */
|
||||
parent = ctxt->node;
|
||||
if (parent == NULL)
|
||||
parent = (xmlNodePtr) ctxt->myDoc;
|
||||
|
||||
/*
|
||||
* We are parsing a new node.
|
||||
*/
|
||||
|
@ -2358,13 +2224,7 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
/*
|
||||
* Link the child element
|
||||
*/
|
||||
if (parent != NULL) {
|
||||
if (parent->type == XML_ELEMENT_NODE) {
|
||||
xmlAddChild(parent, ret);
|
||||
} else {
|
||||
xmlAddSibling(parent, ret);
|
||||
}
|
||||
}
|
||||
xmlAddChild(parent, ret);
|
||||
|
||||
/*
|
||||
* Insert the defaulted attributes from the DTD only if requested:
|
||||
|
@ -2378,7 +2238,7 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
* Note that, if prefix is NULL, this searches for the default Ns
|
||||
*/
|
||||
if ((URI != NULL) && (ret->ns == NULL)) {
|
||||
ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
|
||||
ret->ns = xmlParserNsLookupSax(ctxt, prefix);
|
||||
if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
|
||||
ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
|
||||
}
|
||||
|
@ -2404,7 +2264,11 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
* process all the other attributes
|
||||
*/
|
||||
if (nb_attributes > 0) {
|
||||
xmlAttrPtr prev = NULL;
|
||||
|
||||
for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
|
||||
xmlAttrPtr attr = NULL;
|
||||
|
||||
/*
|
||||
* Handle the rare case of an undefined attribute prefix
|
||||
*/
|
||||
|
@ -2415,23 +2279,38 @@ xmlSAX2StartElementNs(void *ctx,
|
|||
fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
|
||||
attributes[j]);
|
||||
if (fullname != NULL) {
|
||||
xmlSAX2AttributeNs(ctxt, fullname, NULL,
|
||||
attributes[j+3], attributes[j+4]);
|
||||
continue;
|
||||
attr = xmlSAX2AttributeNs(ctxt, fullname, NULL,
|
||||
attributes[j+3],
|
||||
attributes[j+4]);
|
||||
goto have_attr;
|
||||
}
|
||||
} else {
|
||||
lname = xmlBuildQName(attributes[j], attributes[j+1],
|
||||
NULL, 0);
|
||||
if (lname != NULL) {
|
||||
xmlSAX2AttributeNs(ctxt, lname, NULL,
|
||||
attributes[j+3], attributes[j+4]);
|
||||
attr = xmlSAX2AttributeNs(ctxt, lname, NULL,
|
||||
attributes[j+3],
|
||||
attributes[j+4]);
|
||||
xmlFree(lname);
|
||||
continue;
|
||||
goto have_attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
|
||||
attributes[j+3], attributes[j+4]);
|
||||
attr = xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
|
||||
attributes[j+3], attributes[j+4]);
|
||||
have_attr:
|
||||
if (attr == NULL)
|
||||
continue;
|
||||
|
||||
/* link at the end to preserve order */
|
||||
if (prev == NULL) {
|
||||
ctxt->node->properties = attr;
|
||||
} else {
|
||||
prev->next = attr;
|
||||
attr->prev = prev;
|
||||
}
|
||||
|
||||
prev = attr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2503,18 +2382,7 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
|
|||
xmlNodePtr ret;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2Reference(%s)\n", name);
|
||||
#endif
|
||||
if (name[0] == '#')
|
||||
ret = xmlNewCharRef(ctxt->myDoc, name);
|
||||
else
|
||||
ret = xmlNewReference(ctxt->myDoc, name);
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
|
||||
#endif
|
||||
ret = xmlNewReference(ctxt->myDoc, name);
|
||||
if (xmlAddChild(ctxt->node, ret) == NULL) {
|
||||
xmlFreeNode(ret);
|
||||
}
|
||||
|
@ -2536,10 +2404,6 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
|||
xmlNodePtr lastChild;
|
||||
|
||||
if (ctxt == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len);
|
||||
#endif
|
||||
/*
|
||||
* Handle the data if any. If there is no child
|
||||
* add it as content, otherwise if the last child is text,
|
||||
|
@ -2547,17 +2411,9 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
|||
*/
|
||||
|
||||
if (ctxt->node == NULL) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"add chars: ctxt->node == NULL !\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
lastChild = ctxt->node->last;
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"add chars to %s \n", ctxt->node->name);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Here we needed an accelerator mechanism in case of very large
|
||||
|
@ -2656,6 +2512,19 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((lastChild != NULL) &&
|
||||
(type == XML_TEXT_NODE) &&
|
||||
(ctxt->linenumbers) &&
|
||||
(ctxt->input != NULL)) {
|
||||
if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
|
||||
lastChild->line = ctxt->input->line;
|
||||
else {
|
||||
lastChild->line = USHRT_MAX;
|
||||
if (ctxt->options & XML_PARSE_BIG_LINES)
|
||||
lastChild->psvi = (void *) (ptrdiff_t) ctxt->input->line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2684,11 +2553,6 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
|
|||
void
|
||||
xmlSAX2IgnorableWhitespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2IgnorableWhitespace(%.30s, %d)\n", ch, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2709,10 +2573,6 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
|
|||
|
||||
if (ctx == NULL) return;
|
||||
parent = ctxt->node;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data);
|
||||
#endif
|
||||
|
||||
ret = xmlNewDocPI(ctxt->myDoc, target, data);
|
||||
if (ret == NULL) return;
|
||||
|
@ -2733,25 +2593,12 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
|
|||
return;
|
||||
}
|
||||
if (parent == NULL) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Setting PI %s as root\n", target);
|
||||
#endif
|
||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||
return;
|
||||
}
|
||||
if (parent->type == XML_ELEMENT_NODE) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding PI %s child to %s\n", target, parent->name);
|
||||
#endif
|
||||
xmlAddChild(parent, ret);
|
||||
} else {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding PI %s sibling to ", target);
|
||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||
#endif
|
||||
xmlAddSibling(parent, ret);
|
||||
}
|
||||
}
|
||||
|
@ -2772,9 +2619,6 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
|
|||
|
||||
if (ctx == NULL) return;
|
||||
parent = ctxt->node;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Comment(%s)\n", value);
|
||||
#endif
|
||||
ret = xmlNewDocComment(ctxt->myDoc, value);
|
||||
if (ret == NULL) return;
|
||||
if (ctxt->linenumbers) {
|
||||
|
@ -2794,25 +2638,12 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
|
|||
return;
|
||||
}
|
||||
if (parent == NULL) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Setting xmlSAX2Comment as root\n");
|
||||
#endif
|
||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||
return;
|
||||
}
|
||||
if (parent->type == XML_ELEMENT_NODE) {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding xmlSAX2Comment child to %s\n", parent->name);
|
||||
#endif
|
||||
xmlAddChild(parent, ret);
|
||||
} else {
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding xmlSAX2Comment sibling to ");
|
||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||
#endif
|
||||
xmlAddSibling(parent, ret);
|
||||
}
|
||||
}
|
||||
|
@ -2874,20 +2705,23 @@ xmlSAXVersion(xmlSAXHandler *hdlr, int version)
|
|||
{
|
||||
if (hdlr == NULL) return(-1);
|
||||
if (version == 2) {
|
||||
hdlr->startElement = NULL;
|
||||
hdlr->endElement = NULL;
|
||||
hdlr->startElementNs = xmlSAX2StartElementNs;
|
||||
hdlr->endElementNs = xmlSAX2EndElementNs;
|
||||
hdlr->serror = NULL;
|
||||
hdlr->initialized = XML_SAX2_MAGIC;
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
} else if (version == 1) {
|
||||
hdlr->startElement = xmlSAX2StartElement;
|
||||
hdlr->endElement = xmlSAX2EndElement;
|
||||
hdlr->initialized = 1;
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
} else
|
||||
return(-1);
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
hdlr->startElement = xmlSAX2StartElement;
|
||||
hdlr->endElement = xmlSAX2EndElement;
|
||||
#else
|
||||
hdlr->startElement = NULL;
|
||||
hdlr->endElement = NULL;
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
hdlr->internalSubset = xmlSAX2InternalSubset;
|
||||
hdlr->externalSubset = xmlSAX2ExternalSubset;
|
||||
hdlr->isStandalone = xmlSAX2IsStandalone;
|
||||
|
|
113
libs/xml2/buf.c
113
libs/xml2/buf.c
|
@ -20,8 +20,6 @@
|
|||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
|
||||
|
||||
|
@ -225,10 +223,6 @@ xmlBufDetach(xmlBufPtr buf) {
|
|||
int
|
||||
xmlBufGetAllocationScheme(xmlBufPtr buf) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufGetAllocationScheme: buf == NULL\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
return(buf->alloc);
|
||||
|
@ -247,10 +241,6 @@ int
|
|||
xmlBufSetAllocationScheme(xmlBufPtr buf,
|
||||
xmlBufferAllocationScheme scheme) {
|
||||
if ((buf == NULL) || (buf->error != 0)) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufSetAllocationScheme: buf == NULL or in error\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
if (buf->alloc == XML_BUFFER_ALLOC_IO)
|
||||
|
@ -285,10 +275,6 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
|
|||
void
|
||||
xmlBufFree(xmlBufPtr buf) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufFree: buf == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -479,17 +465,9 @@ xmlBufDump(FILE *file, xmlBufPtr buf) {
|
|||
size_t ret;
|
||||
|
||||
if ((buf == NULL) || (buf->error != 0)) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufDump: buf == NULL or in error\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
if (buf->content == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufDump: buf->content == NULL\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
CHECK_COMPAT(buf)
|
||||
|
@ -785,10 +763,6 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
|
|||
CHECK_COMPAT(buf)
|
||||
|
||||
if (len < -1) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufAdd: len < 0\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
if (len == 0) return 0;
|
||||
|
@ -882,10 +856,6 @@ xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string) {
|
|||
CHECK_COMPAT(buf)
|
||||
if (xmlStrchr(string, '\"')) {
|
||||
if (xmlStrchr(string, '\'')) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufWriteQuotedString: string contains quote and double-quotes !\n");
|
||||
#endif
|
||||
xmlBufCCat(buf, "\"");
|
||||
base = cur = string;
|
||||
while(*cur != 0){
|
||||
|
@ -1047,57 +1017,6 @@ xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer) {
|
|||
*/
|
||||
int
|
||||
xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input) {
|
||||
if ((input == NULL) || (buf == NULL) || (buf->error))
|
||||
return(-1);
|
||||
CHECK_COMPAT(buf)
|
||||
input->base = input->cur = buf->content;
|
||||
input->end = &buf->content[buf->use];
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlBufGetInputBase:
|
||||
* @buf: an xmlBufPtr
|
||||
* @input: an xmlParserInputPtr
|
||||
*
|
||||
* Get the base of the @input relative to the beginning of the buffer
|
||||
*
|
||||
* Returns the size_t corresponding to the displacement
|
||||
*/
|
||||
size_t
|
||||
xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input) {
|
||||
size_t base;
|
||||
|
||||
if ((input == NULL) || (buf == NULL) || (buf->error))
|
||||
return(0);
|
||||
CHECK_COMPAT(buf)
|
||||
base = input->base - buf->content;
|
||||
/*
|
||||
* We could do some pointer arithmetic checks but that's probably
|
||||
* sufficient.
|
||||
*/
|
||||
if (base > buf->size) {
|
||||
xmlBufOverflowError(buf, "Input reference outside of the buffer");
|
||||
base = 0;
|
||||
}
|
||||
return(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlBufSetInputBaseCur:
|
||||
* @buf: an xmlBufPtr
|
||||
* @input: an xmlParserInputPtr
|
||||
* @base: the base value relative to the beginning of the buffer
|
||||
* @cur: the cur value relative to the beginning of the buffer
|
||||
*
|
||||
* Update the input to use the base and cur relative to the buffer
|
||||
* after a possible reallocation of its content
|
||||
*
|
||||
* Returns -1 in case of error, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
|
||||
size_t base, size_t cur) {
|
||||
if (input == NULL)
|
||||
return(-1);
|
||||
if ((buf == NULL) || (buf->error)) {
|
||||
|
@ -1105,9 +1024,37 @@ xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
|
|||
return(-1);
|
||||
}
|
||||
CHECK_COMPAT(buf)
|
||||
input->base = &buf->content[base];
|
||||
input->cur = input->base + cur;
|
||||
input->base = input->cur = buf->content;
|
||||
input->end = &buf->content[buf->use];
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlBufUpdateInput:
|
||||
* @buf: an xmlBufPtr
|
||||
* @input: an xmlParserInputPtr
|
||||
* @pos: the cur value relative to the beginning of the buffer
|
||||
*
|
||||
* Update the input to use the base and cur relative to the buffer
|
||||
* after a possible reallocation of its content
|
||||
*
|
||||
* Returns -1 in case of error, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlBufUpdateInput(xmlBufPtr buf, xmlParserInputPtr input, size_t pos) {
|
||||
if (input == NULL)
|
||||
return(-1);
|
||||
/*
|
||||
* TODO: It might be safer to keep using the buffer content if there
|
||||
* was an error.
|
||||
*/
|
||||
if ((buf == NULL) || (buf->error)) {
|
||||
input->base = input->cur = input->end = BAD_CAST "";
|
||||
return(-1);
|
||||
}
|
||||
CHECK_COMPAT(buf)
|
||||
input->base = buf->content;
|
||||
input->cur = input->base + pos;
|
||||
input->end = &buf->content[buf->use];
|
||||
return(0);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <libxml/catalog.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#include "private/buf.h"
|
||||
#include "private/error.h"
|
||||
|
|
|
@ -18,12 +18,10 @@
|
|||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/debugXML.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/uri.h>
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
|
1434
libs/xml2/dict.c
1434
libs/xml2/dict.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,6 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/dict.h>
|
||||
|
||||
#include "private/entities.h"
|
||||
|
@ -114,7 +113,7 @@ xmlEntitiesWarn(xmlParserErrors code, const char *msg, const xmlChar *str1)
|
|||
/*
|
||||
* xmlFreeEntity : clean-up an entity record.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
xmlFreeEntity(xmlEntityPtr entity)
|
||||
{
|
||||
xmlDictPtr dict = NULL;
|
||||
|
@ -718,8 +717,6 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
|
|||
(((cur[0] & 0xF8) == 0xF8))) {
|
||||
xmlEntitiesErr(XML_CHECK_NOT_UTF8,
|
||||
"xmlEncodeEntities: input not UTF-8");
|
||||
if (doc != NULL)
|
||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
ptr = buf;
|
||||
|
@ -751,8 +748,6 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
|
|||
if ((l == 1) || (!IS_CHAR(val))) {
|
||||
xmlEntitiesErr(XML_ERR_INVALID_CHAR,
|
||||
"xmlEncodeEntities: char out of range\n");
|
||||
if (doc != NULL)
|
||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
ptr = buf;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#include "private/error.h"
|
||||
|
||||
|
@ -881,9 +880,9 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||
* Get the last global error registered. This is per thread if compiled
|
||||
* with thread support.
|
||||
*
|
||||
* Returns NULL if no error occurred or a pointer to the error
|
||||
* Returns a pointer to the error
|
||||
*/
|
||||
xmlErrorPtr
|
||||
const xmlError *
|
||||
xmlGetLastError(void)
|
||||
{
|
||||
if (xmlLastError.code == XML_ERR_OK)
|
||||
|
@ -940,7 +939,7 @@ xmlResetLastError(void)
|
|||
*
|
||||
* Returns NULL if no error occurred or a pointer to the error
|
||||
*/
|
||||
xmlErrorPtr
|
||||
const xmlError *
|
||||
xmlCtxtGetLastError(void *ctx)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
|
@ -982,7 +981,7 @@ xmlCtxtResetLastError(void *ctx)
|
|||
* Returns 0 in case of success and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
|
||||
xmlCopyError(const xmlError *from, xmlErrorPtr to) {
|
||||
char *message, *file, *str1, *str2, *str3;
|
||||
|
||||
if ((from == NULL) || (to == NULL))
|
||||
|
|
1239
libs/xml2/globals.c
1239
libs/xml2/globals.c
File diff suppressed because it is too large
Load diff
1855
libs/xml2/hash.c
1855
libs/xml2/hash.c
File diff suppressed because it is too large
Load diff
|
@ -80,6 +80,23 @@ struct _htmlEntityDesc {
|
|||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
#define XML_GLOBALS_HTML \
|
||||
XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
|
||||
#else
|
||||
#define XML_GLOBALS_HTML
|
||||
#endif
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_HTML
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
*/
|
||||
|
@ -316,5 +333,11 @@ XMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;
|
|||
}
|
||||
#endif
|
||||
|
||||
#else /* LIBXML_HTML_ENABLED */
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_HTML
|
||||
/** DOC_ENABLE */
|
||||
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
#endif /* __HTML_PARSER_H__ */
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#ifndef __XML_SAX_H__
|
||||
#define __XML_SAX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#ifndef __XML_SAX2_H__
|
||||
#define __XML_SAX2_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XML_ENC_ERR_SUCCESS = 0,
|
||||
XML_ENC_ERR_SPACE = -1,
|
||||
XML_ENC_ERR_INPUT = -2,
|
||||
XML_ENC_ERR_PARTIAL = -3,
|
||||
XML_ENC_ERR_INTERNAL = -4,
|
||||
XML_ENC_ERR_MEMORY = -5
|
||||
} xmlCharEncError;
|
||||
|
||||
/*
|
||||
* xmlCharEncoding:
|
||||
*
|
||||
|
@ -142,14 +151,6 @@ struct _xmlCharEncodingHandler {
|
|||
#endif /* LIBXML_ICU_ENABLED */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Interfaces for encoding handlers.
|
||||
*/
|
||||
|
@ -194,20 +195,21 @@ XMLPUBFUN xmlCharEncoding
|
|||
xmlDetectCharEncoding (const unsigned char *in,
|
||||
int len);
|
||||
|
||||
struct _xmlBuffer;
|
||||
XMLPUBFUN int
|
||||
xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
struct _xmlBuffer *out,
|
||||
struct _xmlBuffer *in);
|
||||
|
||||
XMLPUBFUN int
|
||||
xmlCharEncInFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
struct _xmlBuffer *out,
|
||||
struct _xmlBuffer *in);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int
|
||||
xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
struct _xmlBuffer *out,
|
||||
struct _xmlBuffer *in);
|
||||
XMLPUBFUN int
|
||||
xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
#define __XML_ENTITIES_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#define XML_TREE_INTERNALS
|
||||
#include <libxml/tree.h>
|
||||
#undef XML_TREE_INTERNALS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -85,6 +87,8 @@ XMLPUBFUN xmlEntityPtr
|
|||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
XMLPUBFUN void
|
||||
xmlFreeEntity (xmlEntityPtr entity);
|
||||
XMLPUBFUN xmlEntityPtr
|
||||
xmlAddDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
|
|
|
@ -1,526 +1,38 @@
|
|||
/*
|
||||
* Summary: interface for all global variables of the library
|
||||
* Description: all the global variables and thread handling for
|
||||
* those variables is handled by this module.
|
||||
*
|
||||
* The bottom of this file is automatically generated by build_glob.py
|
||||
* based on the description file global.data
|
||||
* Description: Deprecated, don't use
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_GLOBALS_H
|
||||
#define __XML_GLOBALS_H
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
/*
|
||||
* This file was required to access global variables until version v2.12.0.
|
||||
*
|
||||
* These includes are for backward compatibility.
|
||||
*/
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/SAX2.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/xmlsave.h>
|
||||
#include <libxml/threads.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void xmlInitGlobals(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void xmlCleanupGlobals(void);
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to read from
|
||||
* @enc: the requested source encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable input method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlParserInputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
|
||||
/**
|
||||
* xmlOutputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to write to
|
||||
* @enc: the requested target encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable output method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlOutputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
||||
xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
||||
xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);
|
||||
|
||||
/*
|
||||
* Externally global symbols which need to be protected for backwards
|
||||
* compatibility support.
|
||||
*/
|
||||
|
||||
#undef htmlDefaultSAXHandler
|
||||
#undef oldXMLWDcompatibility
|
||||
#undef xmlBufferAllocScheme
|
||||
#undef xmlDefaultBufferSize
|
||||
#undef xmlDefaultSAXHandler
|
||||
#undef xmlDefaultSAXLocator
|
||||
#undef xmlDoValidityCheckingDefaultValue
|
||||
#undef xmlFree
|
||||
#undef xmlGenericError
|
||||
#undef xmlStructuredError
|
||||
#undef xmlGenericErrorContext
|
||||
#undef xmlStructuredErrorContext
|
||||
#undef xmlGetWarningsDefaultValue
|
||||
#undef xmlIndentTreeOutput
|
||||
#undef xmlTreeIndentString
|
||||
#undef xmlKeepBlanksDefaultValue
|
||||
#undef xmlLineNumbersDefaultValue
|
||||
#undef xmlLoadExtDtdDefaultValue
|
||||
#undef xmlMalloc
|
||||
#undef xmlMallocAtomic
|
||||
#undef xmlMemStrdup
|
||||
#undef xmlParserDebugEntities
|
||||
#undef xmlParserVersion
|
||||
#undef xmlPedanticParserDefaultValue
|
||||
#undef xmlRealloc
|
||||
#undef xmlSaveNoEmptyTags
|
||||
#undef xmlSubstituteEntitiesDefaultValue
|
||||
#undef xmlRegisterNodeDefaultValue
|
||||
#undef xmlDeregisterNodeDefaultValue
|
||||
#undef xmlLastError
|
||||
#undef xmlParserInputBufferCreateFilenameValue
|
||||
#undef xmlOutputBufferCreateFilenameValue
|
||||
|
||||
/**
|
||||
* xmlRegisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the registration callback of a created node
|
||||
*/
|
||||
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
|
||||
/**
|
||||
* xmlDeregisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the deregistration callback of a discarded node
|
||||
*/
|
||||
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
||||
|
||||
typedef struct _xmlGlobalState xmlGlobalState;
|
||||
typedef xmlGlobalState *xmlGlobalStatePtr;
|
||||
struct _xmlGlobalState
|
||||
{
|
||||
const char *xmlParserVersion;
|
||||
|
||||
xmlSAXLocator xmlDefaultSAXLocator;
|
||||
xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
xmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */
|
||||
xmlSAXHandlerV1 htmlDefaultSAXHandler;
|
||||
|
||||
xmlFreeFunc xmlFree;
|
||||
xmlMallocFunc xmlMalloc;
|
||||
xmlStrdupFunc xmlMemStrdup;
|
||||
xmlReallocFunc xmlRealloc;
|
||||
|
||||
xmlGenericErrorFunc xmlGenericError;
|
||||
xmlStructuredErrorFunc xmlStructuredError;
|
||||
void *xmlGenericErrorContext;
|
||||
|
||||
int oldXMLWDcompatibility;
|
||||
|
||||
xmlBufferAllocationScheme xmlBufferAllocScheme;
|
||||
int xmlDefaultBufferSize;
|
||||
|
||||
int xmlSubstituteEntitiesDefaultValue;
|
||||
int xmlDoValidityCheckingDefaultValue;
|
||||
int xmlGetWarningsDefaultValue;
|
||||
int xmlKeepBlanksDefaultValue;
|
||||
int xmlLineNumbersDefaultValue;
|
||||
int xmlLoadExtDtdDefaultValue;
|
||||
int xmlParserDebugEntities;
|
||||
int xmlPedanticParserDefaultValue;
|
||||
|
||||
int xmlSaveNoEmptyTags;
|
||||
int xmlIndentTreeOutput;
|
||||
const char *xmlTreeIndentString;
|
||||
|
||||
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||
|
||||
xmlMallocFunc xmlMallocAtomic;
|
||||
xmlError xmlLastError;
|
||||
|
||||
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||
|
||||
void *xmlStructuredErrorContext;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/threads.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void xmlInitializeGlobalState(xmlGlobalStatePtr gs);
|
||||
|
||||
XMLPUBFUN void xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
|
||||
|
||||
XMLPUBFUN void xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
|
||||
|
||||
XMLPUBFUN xmlRegisterNodeFunc xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
||||
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
||||
xmlThrDefParserInputBufferCreateFilenameDefault(
|
||||
xmlParserInputBufferCreateFilenameFunc func);
|
||||
|
||||
/*
|
||||
* In general the memory allocation entry points are not kept
|
||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||
* - xmlMalloc
|
||||
* - xmlMallocAtomic
|
||||
* - xmlRealloc
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
/** DOC_DISABLE */
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlMallocFunc * __xmlMalloc(void);
|
||||
#define xmlMalloc \
|
||||
(*(__xmlMalloc()))
|
||||
#else
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlMallocFunc * __xmlMallocAtomic(void);
|
||||
#define xmlMallocAtomic \
|
||||
(*(__xmlMallocAtomic()))
|
||||
#else
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlReallocFunc * __xmlRealloc(void);
|
||||
#define xmlRealloc \
|
||||
(*(__xmlRealloc()))
|
||||
#else
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlFreeFunc * __xmlFree(void);
|
||||
#define xmlFree \
|
||||
(*(__xmlFree()))
|
||||
#else
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlStrdupFunc * __xmlMemStrdup(void);
|
||||
#define xmlMemStrdup \
|
||||
(*(__xmlMemStrdup()))
|
||||
#else
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif
|
||||
|
||||
/** DOC_ENABLE */
|
||||
#else /* !LIBXML_THREAD_ALLOC_ENABLED */
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif /* LIBXML_THREAD_ALLOC_ENABLED */
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlSAXHandlerV1 * __htmlDefaultSAXHandler(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define htmlDefaultSAXHandler \
|
||||
(*(__htmlDefaultSAXHandler()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlError * __xmlLastError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLastError \
|
||||
(*(__xmlLastError()))
|
||||
#else
|
||||
XMLPUBVAR xmlError xmlLastError;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Everything starting from the line below is
|
||||
* Automatically generated by build_glob.py.
|
||||
* Do not modify the previous line.
|
||||
*/
|
||||
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int * __oldXMLWDcompatibility(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define oldXMLWDcompatibility \
|
||||
(*(__oldXMLWDcompatibility()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR int oldXMLWDcompatibility;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlBufferAllocationScheme * __xmlBufferAllocScheme(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlBufferAllocScheme \
|
||||
(*(__xmlBufferAllocScheme()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
|
||||
#endif
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlBufferAllocationScheme
|
||||
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int * __xmlDefaultBufferSize(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultBufferSize \
|
||||
(*(__xmlDefaultBufferSize()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR int xmlDefaultBufferSize;
|
||||
#endif
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int xmlThrDefDefaultBufferSize(int v);
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlSAXHandlerV1 * __xmlDefaultSAXHandler(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultSAXHandler \
|
||||
(*(__xmlDefaultSAXHandler()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlSAXLocator * __xmlDefaultSAXLocator(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultSAXLocator \
|
||||
(*(__xmlDefaultSAXLocator()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN int * __xmlDoValidityCheckingDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDoValidityCheckingDefaultValue \
|
||||
(*(__xmlDoValidityCheckingDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlDoValidityCheckingDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefDoValidityCheckingDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN xmlGenericErrorFunc * __xmlGenericError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGenericError \
|
||||
(*(__xmlGenericError()))
|
||||
#else
|
||||
XMLPUBVAR xmlGenericErrorFunc xmlGenericError;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlStructuredErrorFunc * __xmlStructuredError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlStructuredError \
|
||||
(*(__xmlStructuredError()))
|
||||
#else
|
||||
XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void * * __xmlGenericErrorContext(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGenericErrorContext \
|
||||
(*(__xmlGenericErrorContext()))
|
||||
#else
|
||||
XMLPUBVAR void * xmlGenericErrorContext;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void * * __xmlStructuredErrorContext(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlStructuredErrorContext \
|
||||
(*(__xmlStructuredErrorContext()))
|
||||
#else
|
||||
XMLPUBVAR void * xmlStructuredErrorContext;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN int * __xmlGetWarningsDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGetWarningsDefaultValue \
|
||||
(*(__xmlGetWarningsDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlGetWarningsDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefGetWarningsDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * __xmlIndentTreeOutput(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlIndentTreeOutput \
|
||||
(*(__xmlIndentTreeOutput()))
|
||||
#else
|
||||
XMLPUBVAR int xmlIndentTreeOutput;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefIndentTreeOutput(int v);
|
||||
|
||||
XMLPUBFUN const char * * __xmlTreeIndentString(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlTreeIndentString \
|
||||
(*(__xmlTreeIndentString()))
|
||||
#else
|
||||
XMLPUBVAR const char * xmlTreeIndentString;
|
||||
#endif
|
||||
XMLPUBFUN const char * xmlThrDefTreeIndentString(const char * v);
|
||||
|
||||
XMLPUBFUN int * __xmlKeepBlanksDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlKeepBlanksDefaultValue \
|
||||
(*(__xmlKeepBlanksDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlKeepBlanksDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefKeepBlanksDefaultValue(int v);
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int * __xmlLineNumbersDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLineNumbersDefaultValue \
|
||||
(*(__xmlLineNumbersDefaultValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR int xmlLineNumbersDefaultValue;
|
||||
#endif
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int xmlThrDefLineNumbersDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * __xmlLoadExtDtdDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLoadExtDtdDefaultValue \
|
||||
(*(__xmlLoadExtDtdDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlLoadExtDtdDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefLoadExtDtdDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * __xmlParserDebugEntities(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserDebugEntities \
|
||||
(*(__xmlParserDebugEntities()))
|
||||
#else
|
||||
XMLPUBVAR int xmlParserDebugEntities;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefParserDebugEntities(int v);
|
||||
|
||||
XMLPUBFUN const char * * __xmlParserVersion(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserVersion \
|
||||
(*(__xmlParserVersion()))
|
||||
#else
|
||||
XMLPUBVAR const char * xmlParserVersion;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int * __xmlPedanticParserDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlPedanticParserDefaultValue \
|
||||
(*(__xmlPedanticParserDefaultValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR int xmlPedanticParserDefaultValue;
|
||||
#endif
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int xmlThrDefPedanticParserDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * __xmlSaveNoEmptyTags(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlSaveNoEmptyTags \
|
||||
(*(__xmlSaveNoEmptyTags()))
|
||||
#else
|
||||
XMLPUBVAR int xmlSaveNoEmptyTags;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefSaveNoEmptyTags(int v);
|
||||
|
||||
XMLPUBFUN int * __xmlSubstituteEntitiesDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlSubstituteEntitiesDefaultValue \
|
||||
(*(__xmlSubstituteEntitiesDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlSubstituteEntitiesDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int xmlThrDefSubstituteEntitiesDefaultValue(int v);
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlRegisterNodeFunc * __xmlRegisterNodeDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlRegisterNodeDefaultValue \
|
||||
(*(__xmlRegisterNodeDefaultValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlDeregisterNodeFunc * __xmlDeregisterNodeDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDeregisterNodeDefaultValue \
|
||||
(*(__xmlDeregisterNodeDefaultValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * \
|
||||
__xmlParserInputBufferCreateFilenameValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserInputBufferCreateFilenameValue \
|
||||
(*(__xmlParserInputBufferCreateFilenameValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||
#endif
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc * __xmlOutputBufferCreateFilenameValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlOutputBufferCreateFilenameValue \
|
||||
(*(__xmlOutputBufferCreateFilenameValue()))
|
||||
#else
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||
#endif
|
||||
XML_DEPRECATED XMLPUBFUN void
|
||||
xmlInitializeGlobalState(xmlGlobalStatePtr gs);
|
||||
XML_DEPRECATED XMLPUBFUN
|
||||
xmlGlobalStatePtr xmlGetGlobalState(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#ifndef __XML_HASH_H__
|
||||
#define __XML_HASH_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -21,18 +25,6 @@ extern "C" {
|
|||
typedef struct _xmlHashTable xmlHashTable;
|
||||
typedef xmlHashTable *xmlHashTablePtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/dict.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Recent version of gcc produce a warning when a function pointer is assigned
|
||||
* to an object pointer, or vice versa. The following macro is a dirty hack
|
||||
|
@ -55,7 +47,6 @@ extern "C" {
|
|||
|
||||
#define XML_CAST_FPTR(fptr) fptr
|
||||
|
||||
|
||||
/*
|
||||
* function types:
|
||||
*/
|
||||
|
@ -104,131 +95,136 @@ typedef void (*xmlHashScannerFull)(void *payload, void *data,
|
|||
* Constructor and destructor.
|
||||
*/
|
||||
XMLPUBFUN xmlHashTablePtr
|
||||
xmlHashCreate (int size);
|
||||
xmlHashCreate (int size);
|
||||
XMLPUBFUN xmlHashTablePtr
|
||||
xmlHashCreateDict(int size,
|
||||
xmlHashCreateDict (int size,
|
||||
xmlDictPtr dict);
|
||||
XMLPUBFUN void
|
||||
xmlHashFree (xmlHashTablePtr table,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashFree (xmlHashTablePtr hash,
|
||||
xmlHashDeallocator dealloc);
|
||||
XMLPUBFUN void
|
||||
xmlHashDefaultDeallocator(void *entry,
|
||||
xmlHashDefaultDeallocator(void *entry,
|
||||
const xmlChar *name);
|
||||
|
||||
/*
|
||||
* Add a new entry to the hash table.
|
||||
*/
|
||||
XMLPUBFUN int
|
||||
xmlHashAddEntry (xmlHashTablePtr table,
|
||||
xmlHashAddEntry (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
void *userdata);
|
||||
XMLPUBFUN int
|
||||
xmlHashUpdateEntry(xmlHashTablePtr table,
|
||||
xmlHashUpdateEntry (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashDeallocator dealloc);
|
||||
XMLPUBFUN int
|
||||
xmlHashAddEntry2(xmlHashTablePtr table,
|
||||
xmlHashAddEntry2 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata);
|
||||
XMLPUBFUN int
|
||||
xmlHashUpdateEntry2(xmlHashTablePtr table,
|
||||
xmlHashUpdateEntry2 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashDeallocator dealloc);
|
||||
XMLPUBFUN int
|
||||
xmlHashAddEntry3(xmlHashTablePtr table,
|
||||
xmlHashAddEntry3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata);
|
||||
XMLPUBFUN int
|
||||
xmlHashUpdateEntry3(xmlHashTablePtr table,
|
||||
xmlHashUpdateEntry3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashDeallocator dealloc);
|
||||
|
||||
/*
|
||||
* Remove an entry from the hash table.
|
||||
*/
|
||||
XMLPUBFUN int
|
||||
xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashRemoveEntry (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
xmlHashDeallocator dealloc);
|
||||
XMLPUBFUN int
|
||||
xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, xmlHashDeallocator f);
|
||||
xmlHashRemoveEntry2 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
xmlHashDeallocator dealloc);
|
||||
XMLPUBFUN int
|
||||
xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashDeallocator f);
|
||||
xmlHashRemoveEntry3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashDeallocator dealloc);
|
||||
|
||||
/*
|
||||
* Retrieve the userdata.
|
||||
* Retrieve the payload.
|
||||
*/
|
||||
XMLPUBFUN void *
|
||||
xmlHashLookup (xmlHashTablePtr table,
|
||||
xmlHashLookup (xmlHashTablePtr hash,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void *
|
||||
xmlHashLookup2 (xmlHashTablePtr table,
|
||||
xmlHashLookup2 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2);
|
||||
XMLPUBFUN void *
|
||||
xmlHashLookup3 (xmlHashTablePtr table,
|
||||
xmlHashLookup3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3);
|
||||
XMLPUBFUN void *
|
||||
xmlHashQLookup (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN void *
|
||||
xmlHashQLookup2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
xmlHashQLookup (xmlHashTablePtr hash,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *prefix2);
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void *
|
||||
xmlHashQLookup3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
xmlHashQLookup2 (xmlHashTablePtr hash,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix2,
|
||||
const xmlChar *name3,
|
||||
const xmlChar *prefix3);
|
||||
const xmlChar *name2);
|
||||
XMLPUBFUN void *
|
||||
xmlHashQLookup3 (xmlHashTablePtr hash,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix2,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *prefix3,
|
||||
const xmlChar *name3);
|
||||
|
||||
/*
|
||||
* Helpers.
|
||||
*/
|
||||
XMLPUBFUN xmlHashTablePtr
|
||||
xmlHashCopy (xmlHashTablePtr table,
|
||||
xmlHashCopier f);
|
||||
xmlHashCopy (xmlHashTablePtr hash,
|
||||
xmlHashCopier copy);
|
||||
XMLPUBFUN int
|
||||
xmlHashSize (xmlHashTablePtr table);
|
||||
xmlHashSize (xmlHashTablePtr hash);
|
||||
XMLPUBFUN void
|
||||
xmlHashScan (xmlHashTablePtr table,
|
||||
xmlHashScanner f,
|
||||
xmlHashScan (xmlHashTablePtr hash,
|
||||
xmlHashScanner scan,
|
||||
void *data);
|
||||
XMLPUBFUN void
|
||||
xmlHashScan3 (xmlHashTablePtr table,
|
||||
xmlHashScan3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScanner f,
|
||||
xmlHashScanner scan,
|
||||
void *data);
|
||||
XMLPUBFUN void
|
||||
xmlHashScanFull (xmlHashTablePtr table,
|
||||
xmlHashScannerFull f,
|
||||
xmlHashScanFull (xmlHashTablePtr hash,
|
||||
xmlHashScannerFull scan,
|
||||
void *data);
|
||||
XMLPUBFUN void
|
||||
xmlHashScanFull3(xmlHashTablePtr table,
|
||||
xmlHashScanFull3 (xmlHashTablePtr hash,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScannerFull f,
|
||||
xmlHashScannerFull scan,
|
||||
void *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
#if defined(LIBXML_FTP_ENABLED)
|
||||
|
||||
/* Needed for portability to Windows 64 bits */
|
||||
#if defined(_WIN32)
|
||||
|
@ -182,5 +182,5 @@ XMLPUBFUN int
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
#endif /* defined(LIBXML_FTP_ENABLED) || defined(LIBXML_LEGACY_ENABLED) */
|
||||
#endif /* __NANO_FTP_H__ */
|
||||
|
|
|
@ -11,13 +11,21 @@
|
|||
#define __XML_PARSER_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#define XML_TREE_INTERNALS
|
||||
#include <libxml/tree.h>
|
||||
#undef XML_TREE_INTERNALS
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/entities.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
/* for compatibility */
|
||||
#include <libxml/SAX2.h>
|
||||
#include <libxml/threads.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -63,9 +71,9 @@ struct _xmlParserInput {
|
|||
int col; /* Current column */
|
||||
unsigned long consumed; /* How many xmlChars already consumed */
|
||||
xmlParserInputDeallocate free; /* function to deallocate the base */
|
||||
const xmlChar *encoding; /* the encoding string for entity */
|
||||
const xmlChar *encoding; /* unused */
|
||||
const xmlChar *version; /* the version string for entity */
|
||||
int standalone; /* Was that entity marked standalone */
|
||||
int flags; /* Flags */
|
||||
int id; /* an unique identifier for the entity */
|
||||
unsigned long parentConsumed; /* consumed bytes from parents */
|
||||
xmlEntityPtr entity; /* entity, if any */
|
||||
|
@ -122,7 +130,8 @@ typedef enum {
|
|||
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
|
||||
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
|
||||
XML_PARSER_IGNORE, /* within an IGNORED section */
|
||||
XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
|
||||
XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */
|
||||
XML_PARSER_XML_DECL /* before XML decl (but after BOM) */
|
||||
} xmlParserInputState;
|
||||
|
||||
/**
|
||||
|
@ -165,6 +174,8 @@ typedef enum {
|
|||
} xmlParserMode;
|
||||
|
||||
typedef struct _xmlStartTag xmlStartTag;
|
||||
typedef struct _xmlParserNsData xmlParserNsData;
|
||||
typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
|
||||
|
||||
/**
|
||||
* xmlParserCtxt:
|
||||
|
@ -245,8 +256,7 @@ struct _xmlParserCtxt {
|
|||
|
||||
int depth; /* to prevent entity substitution loops */
|
||||
xmlParserInputPtr entity; /* used to check entities boundaries */
|
||||
int charset; /* encoding of the in-memory content
|
||||
actually an xmlCharEncoding */
|
||||
int charset; /* unused */
|
||||
int nodelen; /* Those two fields are there to */
|
||||
int nodemem; /* Speed up large node parsing */
|
||||
int pedantic; /* signal pedantic warnings */
|
||||
|
@ -276,7 +286,7 @@ struct _xmlParserCtxt {
|
|||
int nsNr; /* the number of inherited namespaces */
|
||||
int nsMax; /* the size of the arrays */
|
||||
const xmlChar * *nsTab; /* the array of prefix/namespace name */
|
||||
int *attallocs; /* which attribute were allocated */
|
||||
unsigned *attallocs; /* which attribute were allocated */
|
||||
xmlStartTag *pushTab; /* array of data for push */
|
||||
xmlHashTablePtr attsDefault; /* defaulted attributes if any */
|
||||
xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
|
||||
|
@ -312,6 +322,11 @@ struct _xmlParserCtxt {
|
|||
int endCheckState; /* quote state for push parser */
|
||||
unsigned short nbErrors; /* number of errors */
|
||||
unsigned short nbWarnings; /* number of warnings */
|
||||
unsigned maxAmpl; /* maximum amplification factor */
|
||||
|
||||
xmlParserNsData *nsdb; /* namespace database */
|
||||
unsigned attrHashMax; /* allocated size */
|
||||
xmlAttrHashBucket *attrHash; /* atttribute hash table */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -732,6 +747,19 @@ struct _xmlSAXHandler {
|
|||
setDocumentLocatorSAXFunc setDocumentLocator;
|
||||
startDocumentSAXFunc startDocument;
|
||||
endDocumentSAXFunc endDocument;
|
||||
/*
|
||||
* `startElement` and `endElement` are only used by the legacy SAX1
|
||||
* interface and should not be used in new software. If you really
|
||||
* have to enable SAX1, the preferred way is set the `initialized`
|
||||
* member to 1 instead of XML_SAX2_MAGIC.
|
||||
*
|
||||
* For backward compatibility, it's also possible to set the
|
||||
* `startElementNs` and `endElementNs` handlers to NULL.
|
||||
*
|
||||
* You can also set the XML_PARSE_SAX1 parser option, but versions
|
||||
* older than 2.12.0 will probably crash if this option is provided
|
||||
* together with custom SAX callbacks.
|
||||
*/
|
||||
startElementSAXFunc startElement;
|
||||
endElementSAXFunc endElement;
|
||||
referenceSAXFunc reference;
|
||||
|
@ -745,8 +773,14 @@ struct _xmlSAXHandler {
|
|||
getParameterEntitySAXFunc getParameterEntity;
|
||||
cdataBlockSAXFunc cdataBlock;
|
||||
externalSubsetSAXFunc externalSubset;
|
||||
/*
|
||||
* `initialized` should always be set to XML_SAX2_MAGIC to enable the
|
||||
* modern SAX2 interface.
|
||||
*/
|
||||
unsigned int initialized;
|
||||
/* The following fields are extensions available only on version 2 */
|
||||
/*
|
||||
* The following members are only used by the SAX2 interface.
|
||||
*/
|
||||
void *_private;
|
||||
startElementNsSAX2Func startElementNs;
|
||||
endElementNsSAX2Func endElementNs;
|
||||
|
@ -804,18 +838,78 @@ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
|
|||
const char *ID,
|
||||
xmlParserCtxtPtr context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
|
||||
XMLPUBVAR const char *const xmlParserVersion;
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
/* backward compatibility */
|
||||
XMLPUBFUN const char *const *__xmlParserVersion(void);
|
||||
#endif
|
||||
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/globals.h>
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_PARSER_CORE \
|
||||
XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
|
||||
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
#define XML_GLOBALS_PARSER_OUTPUT \
|
||||
XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
|
||||
XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
|
||||
XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
|
||||
#else
|
||||
#define XML_GLOBALS_PARSER_OUTPUT
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
#define XML_GLOBALS_PARSER_SAX1 \
|
||||
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
|
||||
#else
|
||||
#define XML_GLOBALS_PARSER_SAX1
|
||||
#endif
|
||||
|
||||
#define XML_GLOBALS_PARSER \
|
||||
XML_GLOBALS_PARSER_CORE \
|
||||
XML_GLOBALS_PARSER_OUTPUT \
|
||||
XML_GLOBALS_PARSER_SAX1
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_PARSER
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
|
||||
#define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
|
||||
#define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
|
||||
#define xmlDoValidityCheckingDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
|
||||
#define xmlGetWarningsDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
|
||||
#define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
|
||||
#define xmlLineNumbersDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
|
||||
#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
|
||||
#define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
|
||||
#define xmlPedanticParserDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
|
||||
#define xmlSubstituteEntitiesDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
#define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
|
||||
#define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
|
||||
#define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
|
||||
#endif
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* Init/Cleanup
|
||||
|
@ -824,6 +918,12 @@ XMLPUBFUN void
|
|||
xmlInitParser (void);
|
||||
XMLPUBFUN void
|
||||
xmlCleanupParser (void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
xmlInitGlobals (void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
xmlCleanupGlobals (void);
|
||||
|
||||
/*
|
||||
* Input functions
|
||||
|
@ -849,16 +949,32 @@ XMLPUBFUN xmlDocPtr
|
|||
xmlParseMemory (const char *buffer,
|
||||
int size);
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
XMLPUBFUN int
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlSubstituteEntitiesDefault(int val);
|
||||
XMLPUBFUN int
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefSubstituteEntitiesDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlKeepBlanksDefault (int val);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefKeepBlanksDefaultValue(int v);
|
||||
XMLPUBFUN void
|
||||
xmlStopParser (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlPedanticParserDefault(int val);
|
||||
XMLPUBFUN int
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefPedanticParserDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlLineNumbersDefault (int val);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefLineNumbersDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefDoValidityCheckingDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefGetWarningsDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefLoadExtDtdDefaultValue(int v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefParserDebugEntities(int v);
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
/*
|
||||
|
@ -1149,6 +1265,9 @@ XMLPUBFUN int
|
|||
XMLPUBFUN int
|
||||
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
|
||||
unsigned maxAmpl);
|
||||
XMLPUBFUN xmlDocPtr
|
||||
xmlReadDoc (const xmlChar *cur,
|
||||
const char *URL,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/chvalid.h>
|
||||
#include <libxml/SAX2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#define __XML_RELAX_NG__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <libxml/xmlregexp.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -29,13 +29,9 @@ typedef xmlMutex *xmlMutexPtr;
|
|||
typedef struct _xmlRMutex xmlRMutex;
|
||||
typedef xmlRMutex *xmlRMutexPtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/globals.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
XMLPUBFUN int
|
||||
xmlCheckThreadLocalStorage(void);
|
||||
|
||||
XMLPUBFUN xmlMutexPtr
|
||||
xmlNewMutex (void);
|
||||
XMLPUBFUN void
|
||||
|
@ -73,13 +69,10 @@ XMLPUBFUN int
|
|||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
xmlCleanupThreads(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlGlobalStatePtr
|
||||
xmlGetGlobalState(void);
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \
|
||||
!defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
|
||||
defined(LIBXML_STATIC_FOR_DLL)
|
||||
int
|
||||
xmlDllMain(void *hinstDLL, unsigned long fdwReason,
|
||||
void *lpvReserved);
|
||||
|
|
|
@ -9,6 +9,15 @@
|
|||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef XML_TREE_INTERNALS
|
||||
|
||||
/*
|
||||
* Emulate circular dependency for backward compatibility
|
||||
*/
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#else /* XML_TREE_INTERNALS */
|
||||
|
||||
#ifndef __XML_TREE_H__
|
||||
#define __XML_TREE_H__
|
||||
|
||||
|
@ -16,6 +25,8 @@
|
|||
#include <limits.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlregexp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -329,14 +340,6 @@ typedef enum {
|
|||
XML_ELEMENT_TYPE_ELEMENT
|
||||
} xmlElementTypeVal;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/xmlregexp.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlElement:
|
||||
*
|
||||
|
@ -573,12 +576,11 @@ struct _xmlDoc {
|
|||
struct _xmlDtd *extSubset; /* the document external subset */
|
||||
struct _xmlNs *oldNs; /* Global namespace, the old way */
|
||||
const xmlChar *version; /* the XML version string */
|
||||
const xmlChar *encoding; /* external initial encoding, if any */
|
||||
const xmlChar *encoding; /* actual encoding, if any */
|
||||
void *ids; /* Hash table for ID attributes if any */
|
||||
void *refs; /* Hash table for IDREFs attributes if any */
|
||||
const xmlChar *URL; /* The URI for that document */
|
||||
int charset; /* Internal flag for charset handling,
|
||||
actually an xmlCharEncoding */
|
||||
int charset; /* unused */
|
||||
struct _xmlDict *dict; /* dict used to allocate names or NULL */
|
||||
void *psvi; /* for type/PSVI information */
|
||||
int parseFlags; /* set of xmlParserOption used to parse the
|
||||
|
@ -630,6 +632,22 @@ struct _xmlDOMWrapCtxt {
|
|||
xmlDOMWrapAcquireNsFunction getNsForNodeFunc;
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlRegisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the registration callback of a created node
|
||||
*/
|
||||
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
|
||||
|
||||
/**
|
||||
* xmlDeregisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the deregistration callback of a discarded node
|
||||
*/
|
||||
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
||||
|
||||
/**
|
||||
* xmlChildrenNode:
|
||||
*
|
||||
|
@ -654,18 +672,34 @@ struct _xmlDOMWrapCtxt {
|
|||
* Variables.
|
||||
*/
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_TREE \
|
||||
XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
|
||||
XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
|
||||
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
|
||||
XML_DEPRECATED)
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_TREE
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlBufferAllocScheme XML_GLOBAL_MACRO(xmlBufferAllocScheme)
|
||||
#define xmlDefaultBufferSize XML_GLOBAL_MACRO(xmlDefaultBufferSize)
|
||||
#define xmlRegisterNodeDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlRegisterNodeDefaultValue)
|
||||
#define xmlDeregisterNodeDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlDeregisterNodeDefaultValue)
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* Some helper functions
|
||||
*/
|
||||
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
|
||||
defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \
|
||||
defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \
|
||||
defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \
|
||||
defined(LIBXML_LEGACY_ENABLED)
|
||||
XMLPUBFUN int
|
||||
xmlValidateNCName (const xmlChar *value,
|
||||
int space);
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
||||
XMLPUBFUN int
|
||||
|
@ -1303,12 +1337,25 @@ XMLPUBFUN xmlNodePtr
|
|||
XMLPUBFUN xmlNodePtr
|
||||
xmlPreviousElementSibling (xmlNodePtr node);
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlRegisterNodeFunc
|
||||
xmlRegisterNodeDefault (xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc
|
||||
xmlDeregisterNodeDefault (xmlDeregisterNodeFunc func);
|
||||
XMLPUBFUN xmlRegisterNodeFunc
|
||||
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc
|
||||
xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||
|
||||
XML_DEPRECATED XMLPUBFUN xmlBufferAllocationScheme
|
||||
xmlThrDefBufferAllocScheme (xmlBufferAllocationScheme v);
|
||||
XML_DEPRECATED XMLPUBFUN int
|
||||
xmlThrDefDefaultBufferSize (int v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#ifndef __XML_PARSER_H__
|
||||
#include <libxml/xmlmemory.h>
|
||||
#endif
|
||||
|
||||
#endif /* __XML_TREE_H__ */
|
||||
|
||||
#endif /* XML_TREE_INTERNALS */
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#ifndef __XML_URI_H__
|
||||
#define __XML_URI_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#define XML_TREE_INTERNALS
|
||||
#include <libxml/tree.h>
|
||||
#undef XML_TREE_INTERNALS
|
||||
#include <libxml/list.h>
|
||||
#include <libxml/xmlautomata.h>
|
||||
#include <libxml/xmlregexp.h>
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/encoding.h>
|
||||
#define XML_TREE_INTERNALS
|
||||
#include <libxml/tree.h>
|
||||
#undef XML_TREE_INTERNALS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -110,18 +114,35 @@ typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
|
|||
typedef int (*xmlOutputCloseCallback) (void * context);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* xmlParserInputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to read from
|
||||
* @enc: the requested source encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable input method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlParserInputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlParserInputBufferPtr
|
||||
(*xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc);
|
||||
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/encoding.h>
|
||||
/**
|
||||
* xmlOutputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to write to
|
||||
* @enc: the requested target encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable output method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlOutputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlOutputBufferPtr
|
||||
(*xmlOutputBufferCreateFilenameFunc)(const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder, int compression);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct _xmlParserInputBuffer {
|
||||
void* context;
|
||||
xmlInputReadCallback readcallback;
|
||||
|
@ -152,6 +173,25 @@ struct _xmlOutputBuffer {
|
|||
};
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_IO \
|
||||
XML_OP(xmlParserInputBufferCreateFilenameValue, \
|
||||
xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
|
||||
XML_OP(xmlOutputBufferCreateFilenameValue, \
|
||||
xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_IO
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlParserInputBufferCreateFilenameValue \
|
||||
XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
|
||||
#define xmlOutputBufferCreateFilenameValue \
|
||||
XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* Interfaces for input
|
||||
*/
|
||||
|
@ -178,7 +218,6 @@ XMLPUBFUN xmlParserInputBufferPtr
|
|||
XMLPUBFUN xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateMem (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateStatic (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
|
@ -349,7 +388,7 @@ XMLPUBFUN int
|
|||
/**
|
||||
* Default 'ftp://' protocol callbacks
|
||||
*/
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
#if defined(LIBXML_FTP_ENABLED)
|
||||
XMLPUBFUN int
|
||||
xmlIOFTPMatch (const char *filename);
|
||||
XMLPUBFUN void *
|
||||
|
@ -360,7 +399,20 @@ XMLPUBFUN int
|
|||
int len);
|
||||
XMLPUBFUN int
|
||||
xmlIOFTPClose (void * context);
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
#endif /* defined(LIBXML_FTP_ENABLED) */
|
||||
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
||||
xmlParserInputBufferCreateFilenameDefault(
|
||||
xmlParserInputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
||||
xmlOutputBufferCreateFilenameDefault(
|
||||
xmlOutputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
||||
xmlThrDefOutputBufferCreateFilenameDefault(
|
||||
xmlOutputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
||||
xmlThrDefParserInputBufferCreateFilenameDefault(
|
||||
xmlParserInputBufferCreateFilenameFunc func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifndef __XML_ERROR_H__
|
||||
#define __XML_ERROR_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -210,6 +210,7 @@ typedef enum {
|
|||
XML_ERR_NAME_TOO_LONG, /* 110 */
|
||||
XML_ERR_USER_STOP, /* 111 */
|
||||
XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */
|
||||
XML_WAR_ENCODING_MISMATCH, /* 113 */
|
||||
XML_NS_ERR_XML_NAMESPACE = 200,
|
||||
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
|
||||
XML_NS_ERR_QNAME, /* 202 */
|
||||
|
@ -855,7 +856,28 @@ typedef void (*xmlGenericErrorFunc) (void *ctx,
|
|||
* Signature of the function to use when there is an error and
|
||||
* the module handles the new error reporting mechanism.
|
||||
*/
|
||||
typedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);
|
||||
typedef void (*xmlStructuredErrorFunc) (void *userData, const xmlError *error);
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_ERROR \
|
||||
XML_OP(xmlLastError, xmlError, XML_DEPRECATED) \
|
||||
XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlGenericErrorContext, void *, XML_NO_ATTR) \
|
||||
XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlStructuredErrorContext, void *, XML_NO_ATTR)
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_ERROR
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlLastError XML_GLOBAL_MACRO(xmlLastError)
|
||||
#define xmlGenericError XML_GLOBAL_MACRO(xmlGenericError)
|
||||
#define xmlGenericErrorContext XML_GLOBAL_MACRO(xmlGenericErrorContext)
|
||||
#define xmlStructuredError XML_GLOBAL_MACRO(xmlStructuredError)
|
||||
#define xmlStructuredErrorContext XML_GLOBAL_MACRO(xmlStructuredErrorContext)
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* Use the following function to reset the two global variables
|
||||
|
@ -864,6 +886,9 @@ typedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);
|
|||
XMLPUBFUN void
|
||||
xmlSetGenericErrorFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XMLPUBFUN void
|
||||
xmlThrDefSetGenericErrorFunc(void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler);
|
||||
|
@ -871,6 +896,9 @@ XMLPUBFUN void
|
|||
XMLPUBFUN void
|
||||
xmlSetStructuredErrorFunc (void *ctx,
|
||||
xmlStructuredErrorFunc handler);
|
||||
XMLPUBFUN void
|
||||
xmlThrDefSetStructuredErrorFunc(void *ctx,
|
||||
xmlStructuredErrorFunc handler);
|
||||
/*
|
||||
* Default message routines used by SAX and Valid context for error
|
||||
* and warning reporting.
|
||||
|
@ -891,26 +919,27 @@ XMLPUBFUN void
|
|||
xmlParserValidityWarning (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
struct _xmlParserInput;
|
||||
XMLPUBFUN void
|
||||
xmlParserPrintFileInfo (xmlParserInputPtr input);
|
||||
xmlParserPrintFileInfo (struct _xmlParserInput *input);
|
||||
XMLPUBFUN void
|
||||
xmlParserPrintFileContext (xmlParserInputPtr input);
|
||||
xmlParserPrintFileContext (struct _xmlParserInput *input);
|
||||
|
||||
/*
|
||||
* Extended error information routines
|
||||
*/
|
||||
XMLPUBFUN xmlErrorPtr
|
||||
XMLPUBFUN const xmlError *
|
||||
xmlGetLastError (void);
|
||||
XMLPUBFUN void
|
||||
xmlResetLastError (void);
|
||||
XMLPUBFUN xmlErrorPtr
|
||||
XMLPUBFUN const xmlError *
|
||||
xmlCtxtGetLastError (void *ctx);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtResetLastError (void *ctx);
|
||||
XMLPUBFUN void
|
||||
xmlResetError (xmlErrorPtr err);
|
||||
XMLPUBFUN int
|
||||
xmlCopyError (xmlErrorPtr from,
|
||||
xmlCopyError (const xmlError *from,
|
||||
xmlErrorPtr to);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -15,32 +15,6 @@
|
|||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
/**
|
||||
* DEBUG_MEMORY:
|
||||
*
|
||||
* DEBUG_MEMORY replaces the allocator with a collect and debug
|
||||
* shell to the libc allocator.
|
||||
* DEBUG_MEMORY should only be activated when debugging
|
||||
* libxml i.e. if libxml has been configured with --with-debug-mem too.
|
||||
*/
|
||||
/* #define DEBUG_MEMORY_FREED */
|
||||
/* #define DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef DEBUG_MEMORY
|
||||
#define DEBUG_MEMORY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DEBUG_MEMORY_LOCATION:
|
||||
*
|
||||
* DEBUG_MEMORY_LOCATION should be activated only when debugging
|
||||
* libxml i.e. if libxml has been configured with --with-debug-mem too.
|
||||
*/
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -87,13 +61,41 @@ typedef void *(*xmlReallocFunc)(void *mem, size_t size);
|
|||
typedef char *(*xmlStrdupFunc)(const char *str);
|
||||
|
||||
/*
|
||||
* The 4 interfaces used for all memory handling within libxml.
|
||||
LIBXML_DLL_IMPORT xmlFreeFunc xmlFree;
|
||||
LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;
|
||||
LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;
|
||||
LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;
|
||||
LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;
|
||||
* In general the memory allocation entry points are not kept
|
||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||
* - xmlMalloc
|
||||
* - xmlMallocAtomic
|
||||
* - xmlRealloc
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
/** DOC_DISABLE */
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#define XML_GLOBALS_ALLOC \
|
||||
XML_OP(xmlMalloc, xmlMallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlRealloc, xmlReallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlFree, xmlFreeFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_NO_ATTR)
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_ALLOC
|
||||
#undef XML_OP
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
|
||||
#define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
|
||||
#define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
|
||||
#define xmlFree XML_GLOBAL_MACRO(xmlFree)
|
||||
#define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
|
||||
#endif
|
||||
#else
|
||||
#define XML_GLOBALS_ALLOC
|
||||
/** DOC_ENABLE */
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The way to overload the existing functions.
|
||||
|
@ -171,6 +173,7 @@ XMLPUBFUN char *
|
|||
xmlMemStrdupLoc (const char *str, const char *file, int line);
|
||||
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
/**
|
||||
* xmlMalloc:
|
||||
|
@ -212,17 +215,10 @@ XMLPUBFUN char *
|
|||
#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
|
||||
|
||||
#endif /* DEBUG_MEMORY_LOCATION */
|
||||
/** DOC_ENABLE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef __XML_GLOBALS_H
|
||||
#ifndef __XML_THREADS_H__
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __DEBUG_MEMORY_ALLOC__ */
|
||||
|
||||
|
|
|
@ -12,11 +12,14 @@
|
|||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
#include <libxml/relaxng.h>
|
||||
#include <libxml/xmlschemas.h>
|
||||
#endif
|
||||
/* for compatibility */
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -121,6 +124,9 @@ XMLPUBFUN int
|
|||
xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||
xmlParserInputBufferPtr input, const char *URL,
|
||||
const char *encoding, int options);
|
||||
XMLPUBFUN void
|
||||
xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,
|
||||
unsigned maxAmpl);
|
||||
|
||||
/*
|
||||
* Iterators
|
||||
|
@ -425,4 +431,3 @@ XMLPUBFUN void
|
|||
#endif
|
||||
|
||||
#endif /* __XML_XMLREADER_H__ */
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
#ifndef __XML_REGEXP_H__
|
||||
#define __XML_REGEXP_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
|
||||
|
@ -36,15 +38,6 @@ typedef xmlRegexp *xmlRegexpPtr;
|
|||
typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
|
||||
typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/dict.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The POSIX like API
|
||||
*/
|
||||
|
|
|
@ -79,10 +79,17 @@ XMLPUBFUN int
|
|||
XMLPUBFUN int
|
||||
xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt,
|
||||
xmlCharEncodingOutputFunc escape);
|
||||
|
||||
XMLPUBFUN int
|
||||
xmlThrDefIndentTreeOutput(int v);
|
||||
XMLPUBFUN const char *
|
||||
xmlThrDefTreeIndentString(const char * v);
|
||||
XMLPUBFUN int
|
||||
xmlThrDefSaveNoEmptyTags(int v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
#endif /* __XML_XMLSAVE_H__ */
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -29,21 +29,21 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
|||
*
|
||||
* the version string like "1.2.3"
|
||||
*/
|
||||
#define LIBXML_DOTTED_VERSION "2.11.7"
|
||||
#define LIBXML_DOTTED_VERSION "2.12.8"
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION:
|
||||
*
|
||||
* the version number: 1.2.3 value is 10203
|
||||
*/
|
||||
#define LIBXML_VERSION 21107
|
||||
#define LIBXML_VERSION 21208
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION_STRING:
|
||||
*
|
||||
* the version number string, 1.2.3 value is "10203"
|
||||
*/
|
||||
#define LIBXML_VERSION_STRING "21107"
|
||||
#define LIBXML_VERSION_STRING "21208"
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION_EXTRA:
|
||||
|
@ -58,7 +58,7 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
|||
* Macro to check that the libxml version in use is compatible with
|
||||
* the version the software has been compiled against
|
||||
*/
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(21107);
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(21208);
|
||||
|
||||
#ifndef VMS
|
||||
#if 0
|
||||
|
@ -449,43 +449,27 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
|||
#endif
|
||||
|
||||
#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
|
||||
#define XML_POP_WARNINGS \
|
||||
#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 800)
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
|
||||
#else
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wpedantic\"")
|
||||
#endif
|
||||
#define XML_POP_WARNINGS \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS
|
||||
#define XML_POP_WARNINGS
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS
|
||||
#define XML_POP_WARNINGS
|
||||
#endif
|
||||
|
||||
/** DOC_ENABLE */
|
||||
#else /* ! __GNUC__ */
|
||||
/**
|
||||
* ATTRIBUTE_UNUSED:
|
||||
*
|
||||
* Macro used to signal to GCC unused function parameters
|
||||
*/
|
||||
#define ATTRIBUTE_UNUSED
|
||||
/**
|
||||
* LIBXML_ATTR_ALLOC_SIZE:
|
||||
*
|
||||
* Macro used to indicate to GCC this is an allocator function
|
||||
*/
|
||||
#define LIBXML_ATTR_ALLOC_SIZE(x)
|
||||
/**
|
||||
* LIBXML_ATTR_FORMAT:
|
||||
*
|
||||
* Macro used to indicate to GCC the parameter are printf like
|
||||
*/
|
||||
#define LIBXML_ATTR_FORMAT(fmt,args)
|
||||
/**
|
||||
* XML_DEPRECATED:
|
||||
*
|
||||
* Macro used to indicate that a function, variable, type or struct member
|
||||
* is deprecated.
|
||||
*/
|
||||
#ifndef XML_DEPRECATED
|
||||
# if defined (IN_LIBXML) || !defined (_MSC_VER)
|
||||
# define XML_DEPRECATED
|
||||
|
@ -494,21 +478,11 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
|||
# define XML_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
#endif
|
||||
/**
|
||||
* LIBXML_IGNORE_FPTR_CAST_WARNINGS:
|
||||
*
|
||||
* Macro used to ignore pointer cast warnings that can't be worked around.
|
||||
*/
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1400)
|
||||
# define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push))
|
||||
#else
|
||||
# define XML_IGNORE_FPTR_CAST_WARNINGS
|
||||
#endif
|
||||
/**
|
||||
* XML_POP_WARNINGS:
|
||||
*
|
||||
* Macro used to restore warnings state.
|
||||
*/
|
||||
#ifndef XML_POP_WARNINGS
|
||||
# if defined (_MSC_VER) && (_MSC_VER >= 1400)
|
||||
# define XML_POP_WARNINGS __pragma(warning(pop))
|
||||
|
@ -518,6 +492,17 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
|||
#endif
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#define XML_NO_ATTR
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBFUN type *__##name(void);
|
||||
#define XML_GLOBAL_MACRO(name) (*__##name())
|
||||
#else
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBVAR type name;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -400,7 +400,7 @@ struct _xmlXPathParserContext {
|
|||
int xptr; /* it this an XPointer expression */
|
||||
xmlNodePtr ancestor; /* used for walking preceding axis */
|
||||
|
||||
int valueFrame; /* unused */
|
||||
int valueFrame; /* always zero for compatibility */
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef __XML_XPATH_INTERNALS_H__
|
||||
#define __XML_XPATH_INTERNALS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
|
@ -297,7 +298,7 @@ XMLPUBFUN void *
|
|||
if (ctxt == NULL) return; \
|
||||
if (nargs != (x)) \
|
||||
XP_ERROR(XPATH_INVALID_ARITY); \
|
||||
if (ctxt->valueNr < ctxt->valueFrame + (x)) \
|
||||
if (ctxt->valueNr < (x)) \
|
||||
XP_ERROR(XPATH_STACK_ERROR);
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_XPTR_LOCS_ENABLED
|
||||
#if defined(LIBXML_XPTR_LOCS_ENABLED)
|
||||
/*
|
||||
* A Location Set
|
||||
*/
|
||||
|
@ -105,7 +105,7 @@ XML_DEPRECATED
|
|||
XMLPUBFUN void
|
||||
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
|
||||
int val);
|
||||
#endif /* LIBXML_XPTR_LOCS_ENABLED */
|
||||
#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
|
||||
|
||||
/*
|
||||
* Functions.
|
||||
|
@ -117,7 +117,8 @@ XMLPUBFUN xmlXPathContextPtr
|
|||
XMLPUBFUN xmlXPathObjectPtr
|
||||
xmlXPtrEval (const xmlChar *str,
|
||||
xmlXPathContextPtr ctx);
|
||||
#ifdef LIBXML_XPTR_LOCS_ENABLED
|
||||
|
||||
#if defined(LIBXML_XPTR_LOCS_ENABLED)
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
|
||||
|
@ -128,7 +129,7 @@ XMLPUBFUN xmlNodePtr
|
|||
XML_DEPRECATED
|
||||
XMLPUBFUN void
|
||||
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
|
||||
#endif /* LIBXML_XPTR_LOCS_ENABLED */
|
||||
#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -61,10 +61,7 @@ xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
|
|||
|
||||
XML_HIDDEN int
|
||||
xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
|
||||
XML_HIDDEN size_t
|
||||
xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
|
||||
XML_HIDDEN int
|
||||
xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
|
||||
size_t base, size_t cur);
|
||||
xmlBufUpdateInput(xmlBufPtr buf, xmlParserInputPtr input, size_t pos);
|
||||
|
||||
#endif /* XML_BUF_H_PRIVATE__ */
|
||||
|
|
|
@ -1,11 +1,72 @@
|
|||
#ifndef XML_DICT_H_PRIVATE__
|
||||
#define XML_DICT_H_PRIVATE__
|
||||
|
||||
XML_HIDDEN int
|
||||
__xmlInitializeDict(void);
|
||||
#include <libxml/dict.h>
|
||||
|
||||
/*
|
||||
* Values are ANDed with 0xFFFFFFFF to support platforms where
|
||||
* unsigned is larger than 32 bits. With 32-bit unsigned values,
|
||||
* modern compilers should optimize the operation away.
|
||||
*/
|
||||
|
||||
#define HASH_ROL(x,n) ((x) << (n) | ((x) & 0xFFFFFFFF) >> (32 - (n)))
|
||||
#define HASH_ROR(x,n) (((x) & 0xFFFFFFFF) >> (n) | (x) << (32 - (n)))
|
||||
|
||||
/*
|
||||
* GoodOAAT: One of a smallest non-multiplicative One-At-a-Time functions
|
||||
* that passes SMHasher.
|
||||
*
|
||||
* Author: Sokolov Yura aka funny-falcon
|
||||
*/
|
||||
|
||||
#define HASH_INIT(h1, h2, seed) \
|
||||
do { \
|
||||
h1 = seed ^ 0x3b00; \
|
||||
h2 = HASH_ROL(seed, 15); \
|
||||
} while (0)
|
||||
|
||||
#define HASH_UPDATE(h1, h2, ch) \
|
||||
do { \
|
||||
h1 += ch; \
|
||||
h1 += h1 << 3; \
|
||||
h2 += h1; \
|
||||
h2 = HASH_ROL(h2, 7); \
|
||||
h2 += h2 << 2; \
|
||||
} while (0)
|
||||
|
||||
/* Result is in h2 */
|
||||
#define HASH_FINISH(h1, h2) \
|
||||
do { \
|
||||
h1 ^= h2; \
|
||||
h1 += HASH_ROL(h2, 14); \
|
||||
h2 ^= h1; h2 += HASH_ROR(h1, 6); \
|
||||
h1 ^= h2; h1 += HASH_ROL(h2, 5); \
|
||||
h2 ^= h1; h2 += HASH_ROR(h1, 8); \
|
||||
h2 &= 0xFFFFFFFF; \
|
||||
} while (0)
|
||||
|
||||
typedef struct {
|
||||
unsigned hashValue;
|
||||
const xmlChar *name;
|
||||
} xmlHashedString;
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlInitDictInternal(void);
|
||||
XML_HIDDEN void
|
||||
xmlCleanupDictInternal(void);
|
||||
XML_HIDDEN int
|
||||
__xmlRandom(void);
|
||||
|
||||
XML_HIDDEN unsigned
|
||||
xmlDictComputeHash(const xmlDict *dict, const xmlChar *string);
|
||||
XML_HIDDEN unsigned
|
||||
xmlDictCombineHash(unsigned v1, unsigned v2);
|
||||
XML_HIDDEN xmlHashedString
|
||||
xmlDictLookupHashed(xmlDictPtr dict, const xmlChar *name, int len);
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlInitRandom(void);
|
||||
XML_HIDDEN void
|
||||
xmlCleanupRandom(void);
|
||||
XML_HIDDEN unsigned
|
||||
xmlRandom(void);
|
||||
|
||||
#endif /* XML_DICT_H_PRIVATE__ */
|
||||
|
|
|
@ -9,9 +9,9 @@ xmlInitEncodingInternal(void);
|
|||
|
||||
XML_HIDDEN int
|
||||
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
|
||||
int *outlen, const unsigned char *in, int *inlen, int flush);
|
||||
int *outlen, const unsigned char *in, int *inlen);
|
||||
XML_HIDDEN int
|
||||
xmlCharEncInput(xmlParserInputBufferPtr input, int flush);
|
||||
xmlCharEncInput(xmlParserInputBufferPtr input);
|
||||
XML_HIDDEN int
|
||||
xmlCharEncOutput(xmlOutputBufferPtr output, int init);
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
struct _xmlNode;
|
||||
|
||||
XML_HIDDEN void
|
||||
__xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||
xmlGenericErrorFunc channel, void *data, void *ctx,
|
||||
|
@ -12,7 +14,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
|||
const char *str2, const char *str3, int int1, int col,
|
||||
const char *msg, ...) LIBXML_ATTR_FORMAT(16,17);
|
||||
XML_HIDDEN void
|
||||
__xmlSimpleError(int domain, int code, xmlNodePtr node,
|
||||
__xmlSimpleError(int domain, int code, struct _xmlNode *node,
|
||||
const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0);
|
||||
XML_HIDDEN void
|
||||
xmlGenericErrorDefaultFunc(void *ctx, const char *msg,
|
||||
|
|
|
@ -11,6 +11,9 @@ XML_HIDDEN void
|
|||
__xmlLoaderErr(void *ctx, const char *msg,
|
||||
const char *filename) LIBXML_ATTR_FORMAT(2,0);
|
||||
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateString(const xmlChar *str);
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XML_HIDDEN xmlOutputBufferPtr
|
||||
xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
|
||||
|
|
|
@ -17,9 +17,23 @@
|
|||
*/
|
||||
#define XML_VCTXT_USE_PCTXT (1u << 1)
|
||||
|
||||
#define XML_INPUT_HAS_ENCODING (1u << 0)
|
||||
#define XML_INPUT_AUTO_ENCODING (7u << 1)
|
||||
#define XML_INPUT_AUTO_UTF8 (1u << 1)
|
||||
#define XML_INPUT_AUTO_UTF16LE (2u << 1)
|
||||
#define XML_INPUT_AUTO_UTF16BE (3u << 1)
|
||||
#define XML_INPUT_AUTO_OTHER (4u << 1)
|
||||
#define XML_INPUT_USES_ENC_DECL (1u << 4)
|
||||
#define XML_INPUT_ENCODING_ERROR (1u << 5)
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra);
|
||||
XML_HIDDEN void
|
||||
xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
|
||||
XML_HIDDEN void LIBXML_ATTR_FORMAT(3,0)
|
||||
xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||
const char *msg, const xmlChar *str1, const xmlChar *str2);
|
||||
XML_HIDDEN void
|
||||
__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
|
||||
const char *msg, const xmlChar *str1,
|
||||
const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0);
|
||||
|
@ -30,4 +44,25 @@ xmlParserGrow(xmlParserCtxtPtr ctxt);
|
|||
XML_HIDDEN void
|
||||
xmlParserShrink(xmlParserCtxtPtr ctxt);
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlDetectEncoding(xmlParserCtxtPtr ctxt);
|
||||
XML_HIDDEN void
|
||||
xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding);
|
||||
XML_HIDDEN const xmlChar *
|
||||
xmlGetActualEncoding(xmlParserCtxtPtr ctxt);
|
||||
|
||||
XML_HIDDEN xmlParserNsData *
|
||||
xmlParserNsCreate(void);
|
||||
XML_HIDDEN void
|
||||
xmlParserNsFree(xmlParserNsData *nsdb);
|
||||
/*
|
||||
* These functions allow SAX handlers to attach extra data to namespaces
|
||||
* efficiently and should be made public.
|
||||
*/
|
||||
XML_HIDDEN int
|
||||
xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
|
||||
void *saxData);
|
||||
XML_HIDDEN void *
|
||||
xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix);
|
||||
|
||||
#endif /* XML_PARSER_H_PRIVATE__ */
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#elif defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#ifndef HAVE_COMPILER_TLS
|
||||
#include <process.h>
|
||||
#endif
|
||||
#define HAVE_WIN32_THREADS
|
||||
#endif
|
||||
#endif
|
||||
|
@ -30,18 +27,6 @@ struct _xmlMutex {
|
|||
#endif
|
||||
};
|
||||
|
||||
XML_HIDDEN void
|
||||
__xmlGlobalInitMutexLock(void);
|
||||
XML_HIDDEN void
|
||||
__xmlGlobalInitMutexUnlock(void);
|
||||
XML_HIDDEN void
|
||||
__xmlGlobalInitMutexDestroy(void);
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlInitThreadsInternal(void);
|
||||
XML_HIDDEN void
|
||||
xmlCleanupThreadsInternal(void);
|
||||
|
||||
XML_HIDDEN void
|
||||
xmlInitMutex(xmlMutexPtr mutex);
|
||||
XML_HIDDEN void
|
||||
|
|
|
@ -59,4 +59,12 @@
|
|||
#define ATTRIBUTE_NO_SANITIZE(arg)
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#define ATTRIBUTE_NO_SANITIZE_INTEGER \
|
||||
ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") \
|
||||
ATTRIBUTE_NO_SANITIZE("unsigned-shift-base")
|
||||
#else
|
||||
#define ATTRIBUTE_NO_SANITIZE_INTEGER
|
||||
#endif
|
||||
|
||||
#endif /* ! __XML_LIBXML_H__ */
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/list.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
/*
|
||||
* Type definition are kept internal
|
||||
|
|
3456
libs/xml2/parser.c
3456
libs/xml2/parser.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -27,18 +27,15 @@
|
|||
#include "libxml.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libxml/pattern.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/pattern.h>
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
|
||||
/* #define DEBUG_STREAMING */
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
|
@ -935,7 +932,6 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
|
|||
|
||||
if (IS_BLANK_CH(CUR)) {
|
||||
ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL);
|
||||
XML_PAT_FREE_STRING(ctxt, prefix);
|
||||
ctxt->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
@ -960,12 +956,12 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
|
|||
ERROR5(NULL, NULL, NULL,
|
||||
"xmlCompileAttributeTest : no namespace bound to prefix %s\n",
|
||||
prefix);
|
||||
XML_PAT_FREE_STRING(ctxt, prefix);
|
||||
ctxt->error = 1;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
XML_PAT_FREE_STRING(ctxt, prefix);
|
||||
XML_PAT_FREE_STRING(ctxt, name);
|
||||
name = NULL;
|
||||
if (token == NULL) {
|
||||
if (CUR == '*') {
|
||||
NEXT;
|
||||
|
@ -984,6 +980,8 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
|
|||
}
|
||||
return;
|
||||
error:
|
||||
if (name != NULL)
|
||||
XML_PAT_FREE_STRING(ctxt, name);
|
||||
if (URL != NULL)
|
||||
XML_PAT_FREE_STRING(ctxt, URL)
|
||||
if (token != NULL)
|
||||
|
@ -1415,62 +1413,6 @@ error_unfinished:
|
|||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifdef DEBUG_STREAMING
|
||||
static void
|
||||
xmlDebugStreamComp(xmlStreamCompPtr stream) {
|
||||
int i;
|
||||
|
||||
if (stream == NULL) {
|
||||
printf("Stream: NULL\n");
|
||||
return;
|
||||
}
|
||||
printf("Stream: %d steps\n", stream->nbStep);
|
||||
for (i = 0;i < stream->nbStep;i++) {
|
||||
if (stream->steps[i].ns != NULL) {
|
||||
printf("{%s}", stream->steps[i].ns);
|
||||
}
|
||||
if (stream->steps[i].name == NULL) {
|
||||
printf("* ");
|
||||
} else {
|
||||
printf("%s ", stream->steps[i].name);
|
||||
}
|
||||
if (stream->steps[i].flags & XML_STREAM_STEP_ROOT)
|
||||
printf("root ");
|
||||
if (stream->steps[i].flags & XML_STREAM_STEP_DESC)
|
||||
printf("// ");
|
||||
if (stream->steps[i].flags & XML_STREAM_STEP_FINAL)
|
||||
printf("final ");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
static void
|
||||
xmlDebugStreamCtxt(xmlStreamCtxtPtr ctxt, int match) {
|
||||
int i;
|
||||
|
||||
if (ctxt == NULL) {
|
||||
printf("Stream: NULL\n");
|
||||
return;
|
||||
}
|
||||
printf("Stream: level %d, %d states: ", ctxt->level, ctxt->nbState);
|
||||
if (match)
|
||||
printf("matches\n");
|
||||
else
|
||||
printf("\n");
|
||||
for (i = 0;i < ctxt->nbState;i++) {
|
||||
if (ctxt->states[2 * i] < 0)
|
||||
printf(" %d: free\n", i);
|
||||
else {
|
||||
printf(" %d: step %d, level %d", i, ctxt->states[2 * i],
|
||||
ctxt->states[(2 * i) + 1]);
|
||||
if (ctxt->comp->steps[ctxt->states[2 * i]].flags &
|
||||
XML_STREAM_STEP_DESC)
|
||||
printf(" //\n");
|
||||
else
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* xmlNewStreamComp:
|
||||
* @size: the number of expected steps
|
||||
|
@ -1729,9 +1671,6 @@ xmlStreamCompile(xmlPatternPtr comp) {
|
|||
stream->steps[s].flags |= XML_STREAM_STEP_FINAL;
|
||||
if (root)
|
||||
stream->steps[0].flags |= XML_STREAM_STEP_ROOT;
|
||||
#ifdef DEBUG_STREAMING
|
||||
xmlDebugStreamComp(stream);
|
||||
#endif
|
||||
comp->stream = stream;
|
||||
return(0);
|
||||
error:
|
||||
|
@ -1852,9 +1791,6 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
|
|||
int ret = 0, err = 0, final = 0, tmp, i, m, match, stepNr, desc;
|
||||
xmlStreamCompPtr comp;
|
||||
xmlStreamStep step;
|
||||
#ifdef DEBUG_STREAMING
|
||||
xmlStreamCtxtPtr orig = stream;
|
||||
#endif
|
||||
|
||||
if ((stream == NULL) || (stream->nbState < 0))
|
||||
return(-1);
|
||||
|
@ -2172,9 +2108,6 @@ stream_next:
|
|||
|
||||
if (err > 0)
|
||||
ret = -1;
|
||||
#ifdef DEBUG_STREAMING
|
||||
xmlDebugStreamCtxt(orig, ret);
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,30 +51,6 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
|
|||
(xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
|
||||
|
||||
|
||||
#if 0
|
||||
#define DEBUG 1
|
||||
|
||||
#define DEBUG_GRAMMAR 1
|
||||
|
||||
#define DEBUG_CONTENT 1
|
||||
|
||||
#define DEBUG_TYPE 1
|
||||
|
||||
#define DEBUG_VALID 1
|
||||
|
||||
#define DEBUG_INTERLEAVE 1
|
||||
|
||||
#define DEBUG_LIST 1
|
||||
|
||||
#define DEBUG_INCLUDE 1
|
||||
|
||||
#define DEBUG_ERROR 1
|
||||
|
||||
#define DEBUG_COMPILE 1
|
||||
|
||||
#define DEBUG_PROGRESSIVE 1
|
||||
#endif
|
||||
|
||||
#define MAX_ERROR 5
|
||||
|
||||
#define TODO \
|
||||
|
@ -1527,15 +1503,6 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
|
|||
xmlNodePtr tmp, tmp2;
|
||||
xmlChar *name2;
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
if (name == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Elimination of <include> start from %s\n", URL);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Elimination of <include> define %s from %s\n",
|
||||
name, URL);
|
||||
#endif
|
||||
tmp = target;
|
||||
while (tmp != NULL) {
|
||||
tmp2 = tmp->next;
|
||||
|
@ -1563,18 +1530,11 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
|
|||
|
||||
if (xmlStrEqual
|
||||
(inc->doc->children->name, BAD_CAST "grammar")) {
|
||||
#ifdef DEBUG_INCLUDE
|
||||
href = xmlGetProp(tmp, BAD_CAST "href");
|
||||
#endif
|
||||
if (xmlRelaxNGRemoveRedefine(ctxt, href,
|
||||
xmlDocGetRootElement(inc->doc)->children,
|
||||
name) == 1) {
|
||||
found = 1;
|
||||
}
|
||||
#ifdef DEBUG_INCLUDE
|
||||
if (href != NULL)
|
||||
xmlFree(href);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (xmlRelaxNGRemoveRedefine(ctxt, URL, tmp->children, name) == 1) {
|
||||
|
@ -1608,11 +1568,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
|
|||
int i;
|
||||
xmlNodePtr root, cur;
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGLoadInclude(%s)\n", URL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* check against recursion in the stack
|
||||
*/
|
||||
|
@ -1634,9 +1589,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
|
|||
"xmlRelaxNG: could not load %s\n", URL, NULL);
|
||||
return (NULL);
|
||||
}
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Parsed %s Okay\n", URL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate the document structures and register it first.
|
||||
|
@ -1674,9 +1626,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
|
|||
* Some preprocessing of the document content, this include recursing
|
||||
* in the include stack.
|
||||
*/
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "cleanup of %s\n", URL);
|
||||
#endif
|
||||
|
||||
doc = xmlRelaxNGCleanupDoc(ctxt, doc);
|
||||
if (doc == NULL) {
|
||||
|
@ -1689,9 +1638,6 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
|
|||
*/
|
||||
xmlRelaxNGIncludePop(ctxt);
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Checking of %s\n", URL);
|
||||
#endif
|
||||
/*
|
||||
* Check that the top element is a grammar
|
||||
*/
|
||||
|
@ -1783,10 +1729,6 @@ xmlRelaxNGValidErrorPush(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
{
|
||||
xmlRelaxNGValidErrorPtr cur;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pushing error %d at %d on stack\n", err, ctxt->errNr);
|
||||
#endif
|
||||
if (ctxt->errTab == NULL) {
|
||||
ctxt->errMax = 8;
|
||||
ctxt->errNr = 0;
|
||||
|
@ -2261,9 +2203,6 @@ xmlRelaxNGShowValidError(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
if (ctxt->flags & FLAGS_NOERROR)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
xmlGenericError(xmlGenericErrorContext, "Show error %d\n", err);
|
||||
#endif
|
||||
msg = xmlRelaxNGGetErrorString(err, arg1, arg2);
|
||||
if (msg == NULL)
|
||||
return;
|
||||
|
@ -2288,10 +2227,6 @@ xmlRelaxNGPopErrors(xmlRelaxNGValidCtxtPtr ctxt, int level)
|
|||
int i;
|
||||
xmlRelaxNGValidErrorPtr err;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pop errors till level %d\n", level);
|
||||
#endif
|
||||
for (i = level; i < ctxt->errNr; i++) {
|
||||
err = &ctxt->errTab[i];
|
||||
if (err->flags & ERROR_IS_DUP) {
|
||||
|
@ -2321,10 +2256,6 @@ xmlRelaxNGDumpValidError(xmlRelaxNGValidCtxtPtr ctxt)
|
|||
int i, j, k;
|
||||
xmlRelaxNGValidErrorPtr err, dup;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Dumping error stack %d errors\n", ctxt->errNr);
|
||||
#endif
|
||||
for (i = 0, k = 0; i < ctxt->errNr; i++) {
|
||||
err = &ctxt->errTab[i];
|
||||
if (k < MAX_ERROR) {
|
||||
|
@ -2375,9 +2306,6 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
if (ctxt->flags & FLAGS_NOERROR)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
xmlGenericError(xmlGenericErrorContext, "Adding error %d\n", err);
|
||||
#endif
|
||||
/*
|
||||
* generate the error directly
|
||||
*/
|
||||
|
@ -2937,21 +2865,6 @@ xmlRelaxNGIsCompilable(xmlRelaxNGDefinePtr def)
|
|||
}
|
||||
if ((ret == 1) && !(def->dflags &= IS_NOT_COMPILABLE))
|
||||
def->dflags |= IS_COMPILABLE;
|
||||
#ifdef DEBUG_COMPILE
|
||||
if (ret == 1) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"element content for %s is compilable\n",
|
||||
def->name);
|
||||
} else if (ret == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"element content for %s is not compilable\n",
|
||||
def->name);
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Problem in RelaxNGIsCompilable for element %s\n",
|
||||
def->name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* All elements return a compilable status unless they
|
||||
|
@ -3013,21 +2926,6 @@ xmlRelaxNGIsCompilable(xmlRelaxNGDefinePtr def)
|
|||
def->dflags |= IS_NOT_COMPILABLE;
|
||||
if (ret == 1)
|
||||
def->dflags |= IS_COMPILABLE;
|
||||
#ifdef DEBUG_COMPILE
|
||||
if (ret == 1) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"RelaxNGIsCompilable %s : true\n",
|
||||
xmlRelaxNGDefName(def));
|
||||
} else if (ret == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"RelaxNGIsCompilable %s : false\n",
|
||||
xmlRelaxNGDefName(def));
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Problem in RelaxNGIsCompilable %s\n",
|
||||
xmlRelaxNGDefName(def));
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -3113,11 +3011,6 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
|
|||
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
||||
def->contModel = xmlAutomataCompile(ctxt->am);
|
||||
if (!xmlRegexpIsDeterminist(def->contModel)) {
|
||||
#ifdef DEBUG_COMPILE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Content model not determinist %s\n",
|
||||
def->name);
|
||||
#endif
|
||||
/*
|
||||
* we can only use the automata if it is determinist
|
||||
*/
|
||||
|
@ -3282,24 +3175,6 @@ xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
|
|||
if ((def->dflags & IS_COMPILABLE) && (def->depth != -25)) {
|
||||
ctxt->am = NULL;
|
||||
ret = xmlRelaxNGCompile(ctxt, def);
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
if (ret == 0) {
|
||||
if (def->type == XML_RELAXNG_START)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"compiled the start\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"compiled element %s\n", def->name);
|
||||
} else {
|
||||
if (def->type == XML_RELAXNG_START)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"failed to compile the start\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"failed to compile element %s\n",
|
||||
def->name);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
@ -4359,19 +4234,12 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
|
|||
if (ctxt->nbErrors != 0)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_INTERLEAVE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGComputeInterleaves(%s)\n", name);
|
||||
#endif
|
||||
cur = def->content;
|
||||
while (cur != NULL) {
|
||||
nbchild++;
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_INTERLEAVE
|
||||
xmlGenericError(xmlGenericErrorContext, " %d child\n", nbchild);
|
||||
#endif
|
||||
groups = (xmlRelaxNGInterleaveGroupPtr *)
|
||||
xmlMalloc(nbchild * sizeof(xmlRelaxNGInterleaveGroupPtr));
|
||||
if (groups == NULL)
|
||||
|
@ -4390,9 +4258,6 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
|
|||
nbgroups++;
|
||||
cur = cur->next;
|
||||
}
|
||||
#ifdef DEBUG_INTERLEAVE
|
||||
xmlGenericError(xmlGenericErrorContext, " %d groups\n", nbgroups);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Let's check that all rules makes a partitions according to 7.4
|
||||
|
@ -5019,11 +4884,6 @@ xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
|
|||
xmlRelaxNGGrammarPtr grammar, old;
|
||||
xmlRelaxNGGrammarPtr oldparent;
|
||||
|
||||
#ifdef DEBUG_GRAMMAR
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Found <grammar> pattern\n");
|
||||
#endif
|
||||
|
||||
oldparent = ctxt->parentgrammar;
|
||||
old = ctxt->grammar;
|
||||
ctxt->parentgrammar = old;
|
||||
|
@ -5809,11 +5669,6 @@ xmlRelaxNGCheckCombine(void *payload, void *data, const xmlChar * name)
|
|||
|
||||
cur = cur->nextHash;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGCheckCombine(): merging %s defines: %d\n",
|
||||
name, choiceOrInterleave);
|
||||
#endif
|
||||
if (choiceOrInterleave == -1)
|
||||
choiceOrInterleave = 0;
|
||||
cur = xmlRelaxNGNewDefine(ctxt, define->node);
|
||||
|
@ -5939,11 +5794,6 @@ xmlRelaxNGCombineStart(xmlRelaxNGParserCtxtPtr ctxt,
|
|||
|
||||
cur = cur->next;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGCombineStart(): merging <start>: %d\n",
|
||||
choiceOrInterleave);
|
||||
#endif
|
||||
if (choiceOrInterleave == -1)
|
||||
choiceOrInterleave = 0;
|
||||
cur = xmlRelaxNGNewDefine(ctxt, starts->node);
|
||||
|
@ -6609,10 +6459,6 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
|
|||
{
|
||||
xmlRelaxNGGrammarPtr ret, tmp, old;
|
||||
|
||||
#ifdef DEBUG_GRAMMAR
|
||||
xmlGenericError(xmlGenericErrorContext, "Parsing a new grammar\n");
|
||||
#endif
|
||||
|
||||
ret = xmlRelaxNGNewGrammar(ctxt);
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
|
@ -6741,11 +6587,6 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
|
|||
XML_RELAXNG_IN_START, XML_RELAXNG_NOOP);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (schema == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGParseDocument() failed\n");
|
||||
#endif
|
||||
|
||||
return (schema);
|
||||
}
|
||||
|
@ -7971,10 +7812,6 @@ xmlRelaxNGValidateCompiledCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
|
|||
xmlRelaxNGDefinePtr define = (xmlRelaxNGDefinePtr) transdata;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG_COMPILE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Compiled callback for: '%s'\n", token);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
fprintf(stderr, "callback on %s missing context\n", token);
|
||||
return;
|
||||
|
@ -8181,10 +8018,6 @@ xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec
|
|||
xmlNodePtr node;
|
||||
int ret = 0, oldflags;
|
||||
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Progressive callback for: '%s'\n", token);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
fprintf(stderr, "callback on %s missing context\n", token);
|
||||
return;
|
||||
|
@ -8224,11 +8057,6 @@ xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec
|
|||
/*
|
||||
* this node cannot be validated in a streamable fashion
|
||||
*/
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Element '%s' validation is not streamable\n",
|
||||
token);
|
||||
#endif
|
||||
ctxt->pstate = 0;
|
||||
ctxt->pdef = define;
|
||||
return;
|
||||
|
@ -8325,9 +8153,6 @@ xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
if ((ctxt == NULL) || (elem == NULL))
|
||||
return (-1);
|
||||
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext, "PushElem %s\n", elem->name);
|
||||
#endif
|
||||
if (ctxt->elem == 0) {
|
||||
xmlRelaxNGPtr schema;
|
||||
xmlRelaxNGGrammarPtr grammar;
|
||||
|
@ -8376,11 +8201,6 @@ xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
else
|
||||
ret = 1;
|
||||
}
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
if (ret < 0)
|
||||
xmlGenericError(xmlGenericErrorContext, "PushElem %s failed\n",
|
||||
elem->name);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -8403,10 +8223,6 @@ xmlRelaxNGValidatePushCData(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
if ((ctxt == NULL) || (ctxt->elem == NULL) || (data == NULL))
|
||||
return (-1);
|
||||
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext, "CDATA %s %d\n", data, len);
|
||||
#endif
|
||||
|
||||
while (*data != 0) {
|
||||
if (!IS_BLANK_CH(*data))
|
||||
break;
|
||||
|
@ -8418,9 +8234,6 @@ xmlRelaxNGValidatePushCData(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
ret = xmlRegExecPushString(ctxt->elem, BAD_CAST "#text", ctxt);
|
||||
if (ret < 0) {
|
||||
VALID_ERR2(XML_RELAXNG_ERR_TEXTWRONG, BAD_CAST " TODO ");
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext, "CDATA failed\n");
|
||||
#endif
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
@ -8447,9 +8260,6 @@ xmlRelaxNGValidatePopElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
|
||||
if ((ctxt == NULL) || (ctxt->elem == NULL) || (elem == NULL))
|
||||
return (-1);
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext, "PopElem %s\n", elem->name);
|
||||
#endif
|
||||
/*
|
||||
* verify that we reached a terminal state of the content model.
|
||||
*/
|
||||
|
@ -8467,11 +8277,6 @@ xmlRelaxNGValidatePopElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
ret = 1;
|
||||
}
|
||||
xmlRegFreeExecCtxt(exec);
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
if (ret < 0)
|
||||
xmlGenericError(xmlGenericErrorContext, "PopElem %s failed\n",
|
||||
elem->name);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -8496,9 +8301,6 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
|
||||
if ((ctxt == NULL) || (ctxt->pdef == NULL) || (elem == NULL))
|
||||
return (-1);
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
xmlGenericError(xmlGenericErrorContext, "FullElem %s\n", elem->name);
|
||||
#endif
|
||||
state = xmlRelaxNGNewValidState(ctxt, elem->parent);
|
||||
if (state == NULL) {
|
||||
return (-1);
|
||||
|
@ -8513,11 +8315,6 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
ret = 1;
|
||||
xmlRelaxNGFreeValidState(ctxt, ctxt->state);
|
||||
ctxt->state = NULL;
|
||||
#ifdef DEBUG_PROGRESSIVE
|
||||
if (ret < 0)
|
||||
xmlGenericError(xmlGenericErrorContext, "FullElem %s failed\n",
|
||||
elem->name);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -8847,10 +8644,6 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
xmlRelaxNGDefinePtr list = define->content;
|
||||
xmlChar *oldvalue, *oldend, *val, *cur;
|
||||
|
||||
#ifdef DEBUG_LIST
|
||||
int nb_values = 0;
|
||||
#endif
|
||||
|
||||
oldvalue = ctxt->state->value;
|
||||
oldend = ctxt->state->endvalue;
|
||||
|
||||
|
@ -8867,20 +8660,11 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
if (IS_BLANK_CH(*cur)) {
|
||||
*cur = 0;
|
||||
cur++;
|
||||
#ifdef DEBUG_LIST
|
||||
nb_values++;
|
||||
#endif
|
||||
while (IS_BLANK_CH(*cur))
|
||||
*cur++ = 0;
|
||||
} else
|
||||
cur++;
|
||||
}
|
||||
#ifdef DEBUG_LIST
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"list value: '%s' found %d items\n",
|
||||
oldvalue, nb_values);
|
||||
nb_values = 0;
|
||||
#endif
|
||||
ctxt->state->endvalue = cur;
|
||||
cur = val;
|
||||
while ((*cur == 0) && (cur != ctxt->state->endvalue))
|
||||
|
@ -8893,16 +8677,8 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
ctxt->state->value = NULL;
|
||||
ret = xmlRelaxNGValidateValue(ctxt, list);
|
||||
if (ret != 0) {
|
||||
#ifdef DEBUG_LIST
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Failed to validate value: '%s' with %d rule\n",
|
||||
ctxt->state->value, nb_values);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG_LIST
|
||||
nb_values++;
|
||||
#endif
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
|
@ -9166,11 +8942,6 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGValidateAttribute(%s): %d\n",
|
||||
define->name, ret);
|
||||
#endif
|
||||
} else {
|
||||
for (i = 0; i < ctxt->state->nbAttrs; i++) {
|
||||
tmp = ctxt->state->attrs[i];
|
||||
|
@ -9203,17 +8974,6 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (define->ns != NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGValidateAttribute(nsName ns = %s): %d\n",
|
||||
define->ns, ret);
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGValidateAttribute(anyName): %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return (ret);
|
||||
|
@ -9895,18 +9655,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
} else {
|
||||
node = NULL;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < ctxt->depth; i++)
|
||||
xmlGenericError(xmlGenericErrorContext, " ");
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Start validating %s ", xmlRelaxNGDefName(define));
|
||||
if (define->name != NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, "%s ", define->name);
|
||||
if ((node != NULL) && (node->name != NULL))
|
||||
xmlGenericError(xmlGenericErrorContext, "on %s\n", node->name);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
ctxt->depth++;
|
||||
switch (define->type) {
|
||||
case XML_RELAXNG_EMPTY:
|
||||
|
@ -10025,11 +9773,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
ctxt->states = tmpstates;
|
||||
xmlRelaxNGFreeValidState(ctxt, nstate);
|
||||
|
||||
#ifdef DEBUG_COMPILE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Validating content of '%s' : %d\n",
|
||||
define->name, tmp);
|
||||
#endif
|
||||
if (tmp != 0)
|
||||
ret = -1;
|
||||
|
||||
|
@ -10147,21 +9890,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
xmlRelaxNGPopErrors(ctxt, errNr);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGValidateDefinition(): validated %s : %d",
|
||||
node->name, ret);
|
||||
if (oldstate == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, ": no state\n");
|
||||
else if (oldstate->seq == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, ": done\n");
|
||||
else if (oldstate->seq->type == XML_ELEMENT_NODE)
|
||||
xmlGenericError(xmlGenericErrorContext, ": next elem %s\n",
|
||||
oldstate->seq->name);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, ": next %s %d\n",
|
||||
oldstate->seq->name, oldstate->seq->type);
|
||||
#endif
|
||||
break;
|
||||
case XML_RELAXNG_OPTIONAL:{
|
||||
errNr = ctxt->errNr;
|
||||
|
@ -10620,18 +10348,6 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
|
|||
break;
|
||||
}
|
||||
ctxt->depth--;
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < ctxt->depth; i++)
|
||||
xmlGenericError(xmlGenericErrorContext, " ");
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Validating %s ", xmlRelaxNGDefName(define));
|
||||
if (define->name != NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, "%s ", define->name);
|
||||
if (ret == 0)
|
||||
xmlGenericError(xmlGenericErrorContext, "succeeded\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, "failed\n");
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -10830,14 +10546,6 @@ xmlRelaxNGValidateDocument(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc)
|
|||
}
|
||||
if (ret != 0)
|
||||
xmlRelaxNGDumpValidError(ctxt);
|
||||
#ifdef DEBUG
|
||||
else if (ctxt->errNr != 0) {
|
||||
ctxt->error(ctxt->userData,
|
||||
"%d Extra error messages left on stack !\n",
|
||||
ctxt->errNr);
|
||||
xmlRelaxNGDumpValidError(ctxt);
|
||||
}
|
||||
#endif
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if (ctxt->idref == 1) {
|
||||
xmlValidCtxt vctxt;
|
||||
|
|
|
@ -14,16 +14,25 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/parser.h>
|
||||
#ifdef LIBXML_CATALOG_ENABLED
|
||||
#include <libxml/catalog.h>
|
||||
#endif
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
#include <libxml/xmlschemastypes.h>
|
||||
#include <libxml/relaxng.h>
|
||||
#endif
|
||||
|
||||
#if defined(SOLARIS)
|
||||
#include <note.h>
|
||||
#endif
|
||||
|
||||
#include "private/dict.h"
|
||||
#include "private/enc.h"
|
||||
#include "private/globals.h"
|
||||
#include "private/memory.h"
|
||||
#include "private/threads.h"
|
||||
|
||||
/* #define DEBUG_THREADS */
|
||||
#include "private/xpath.h"
|
||||
|
||||
#if defined(HAVE_POSIX_THREADS) && \
|
||||
defined(__GLIBC__) && \
|
||||
|
@ -60,10 +69,6 @@
|
|||
* configure.ac can probably be removed.
|
||||
*/
|
||||
|
||||
#pragma weak pthread_getspecific
|
||||
#pragma weak pthread_setspecific
|
||||
#pragma weak pthread_key_create
|
||||
#pragma weak pthread_key_delete
|
||||
#pragma weak pthread_mutex_init
|
||||
#pragma weak pthread_mutex_destroy
|
||||
#pragma weak pthread_mutex_lock
|
||||
|
@ -73,8 +78,6 @@
|
|||
#pragma weak pthread_cond_wait
|
||||
#pragma weak pthread_equal
|
||||
#pragma weak pthread_self
|
||||
#pragma weak pthread_key_create
|
||||
#pragma weak pthread_key_delete
|
||||
#pragma weak pthread_cond_signal
|
||||
|
||||
#define XML_PTHREAD_WEAK
|
||||
|
@ -113,27 +116,6 @@ struct _xmlRMutex {
|
|||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* This module still has some internal static data.
|
||||
* - xmlLibraryLock a global lock
|
||||
* - globalkey used for per-thread data
|
||||
*/
|
||||
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
static pthread_key_t globalkey;
|
||||
static pthread_t mainthread;
|
||||
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
#if defined(HAVE_COMPILER_TLS)
|
||||
static __declspec(thread) xmlGlobalState tlstate;
|
||||
static __declspec(thread) int tlstate_inited = 0;
|
||||
#else /* HAVE_COMPILER_TLS */
|
||||
static DWORD globalkey = TLS_OUT_OF_INDEXES;
|
||||
#endif /* HAVE_COMPILER_TLS */
|
||||
static DWORD mainthread;
|
||||
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
|
||||
#endif
|
||||
|
||||
static xmlRMutexPtr xmlLibraryLock = NULL;
|
||||
|
||||
/**
|
||||
|
@ -369,275 +351,6 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlGlobalInitMutexLock
|
||||
*
|
||||
* Makes sure that the global initialization mutex is initialized and
|
||||
* locks it.
|
||||
*/
|
||||
void
|
||||
__xmlGlobalInitMutexLock(void)
|
||||
{
|
||||
/* Make sure the global init lock is initialized and then lock it. */
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#ifdef XML_PTHREAD_WEAK
|
||||
if (pthread_mutex_lock == NULL)
|
||||
return;
|
||||
#else
|
||||
if (XML_IS_THREADED() == 0)
|
||||
return;
|
||||
#endif
|
||||
/* The mutex is statically initialized, so we just lock it. */
|
||||
pthread_mutex_lock(&global_init_lock);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
LPCRITICAL_SECTION cs;
|
||||
|
||||
/* Create a new critical section */
|
||||
if (global_init_lock == NULL) {
|
||||
cs = malloc(sizeof(CRITICAL_SECTION));
|
||||
if (cs == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGlobalInitMutexLock: out of memory\n");
|
||||
return;
|
||||
}
|
||||
InitializeCriticalSection(cs);
|
||||
|
||||
/* Swap it into the global_init_lock */
|
||||
#ifdef InterlockedCompareExchangePointer
|
||||
InterlockedCompareExchangePointer((void **) &global_init_lock,
|
||||
cs, NULL);
|
||||
#else /* Use older void* version */
|
||||
InterlockedCompareExchange((void **) &global_init_lock,
|
||||
(void *) cs, NULL);
|
||||
#endif /* InterlockedCompareExchangePointer */
|
||||
|
||||
/* If another thread successfully recorded its critical
|
||||
* section in the global_init_lock then discard the one
|
||||
* allocated by this thread. */
|
||||
if (global_init_lock != cs) {
|
||||
DeleteCriticalSection(cs);
|
||||
free(cs);
|
||||
}
|
||||
}
|
||||
|
||||
/* Lock the chosen critical section */
|
||||
EnterCriticalSection(global_init_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
__xmlGlobalInitMutexUnlock(void)
|
||||
{
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#ifdef XML_PTHREAD_WEAK
|
||||
if (pthread_mutex_lock == NULL)
|
||||
return;
|
||||
#else
|
||||
if (XML_IS_THREADED() == 0)
|
||||
return;
|
||||
#endif
|
||||
pthread_mutex_unlock(&global_init_lock);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
if (global_init_lock != NULL) {
|
||||
LeaveCriticalSection(global_init_lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlGlobalInitMutexDestroy
|
||||
*
|
||||
* Makes sure that the global initialization mutex is destroyed before
|
||||
* application termination.
|
||||
*/
|
||||
void
|
||||
__xmlGlobalInitMutexDestroy(void)
|
||||
{
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
if (global_init_lock != NULL) {
|
||||
DeleteCriticalSection(global_init_lock);
|
||||
free(global_init_lock);
|
||||
global_init_lock = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Per thread global state handling *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#ifdef xmlLastError
|
||||
#undef xmlLastError
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlFreeGlobalState:
|
||||
* @state: a thread global state
|
||||
*
|
||||
* xmlFreeGlobalState() is called when a thread terminates with a non-NULL
|
||||
* global state. It is is used here to reclaim memory resources.
|
||||
*/
|
||||
static void
|
||||
xmlFreeGlobalState(void *state)
|
||||
{
|
||||
xmlGlobalState *gs = (xmlGlobalState *) state;
|
||||
|
||||
/* free any memory allocated in the thread's xmlLastError */
|
||||
xmlResetError(&(gs->xmlLastError));
|
||||
free(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNewGlobalState:
|
||||
*
|
||||
* xmlNewGlobalState() allocates a global state. This structure is used to
|
||||
* hold all data for use by a thread when supporting backwards compatibility
|
||||
* of libxml2 to pre-thread-safe behaviour.
|
||||
*
|
||||
* Returns the newly allocated xmlGlobalStatePtr or NULL in case of error
|
||||
*/
|
||||
static xmlGlobalStatePtr
|
||||
xmlNewGlobalState(void)
|
||||
{
|
||||
xmlGlobalState *gs;
|
||||
|
||||
gs = malloc(sizeof(xmlGlobalState));
|
||||
if (gs == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGetGlobalState: out of memory\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
memset(gs, 0, sizeof(xmlGlobalState));
|
||||
xmlInitializeGlobalState(gs);
|
||||
return (gs);
|
||||
}
|
||||
#endif /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
#if !defined(HAVE_COMPILER_TLS)
|
||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
||||
typedef struct _xmlGlobalStateCleanupHelperParams {
|
||||
HANDLE thread;
|
||||
void *memory;
|
||||
} xmlGlobalStateCleanupHelperParams;
|
||||
|
||||
static void
|
||||
xmlGlobalStateCleanupHelper(void *p)
|
||||
{
|
||||
xmlGlobalStateCleanupHelperParams *params =
|
||||
(xmlGlobalStateCleanupHelperParams *) p;
|
||||
WaitForSingleObject(params->thread, INFINITE);
|
||||
CloseHandle(params->thread);
|
||||
xmlFreeGlobalState(params->memory);
|
||||
free(params);
|
||||
_endthread();
|
||||
}
|
||||
#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
|
||||
|
||||
typedef struct _xmlGlobalStateCleanupHelperParams {
|
||||
void *memory;
|
||||
struct _xmlGlobalStateCleanupHelperParams *prev;
|
||||
struct _xmlGlobalStateCleanupHelperParams *next;
|
||||
} xmlGlobalStateCleanupHelperParams;
|
||||
|
||||
static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
|
||||
static CRITICAL_SECTION cleanup_helpers_cs;
|
||||
|
||||
#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
|
||||
#endif /* HAVE_COMPILER_TLS */
|
||||
#endif /* HAVE_WIN32_THREADS */
|
||||
|
||||
/**
|
||||
* xmlGetGlobalState:
|
||||
*
|
||||
* DEPRECATED: Internal function, do not use.
|
||||
*
|
||||
* xmlGetGlobalState() is called to retrieve the global state for a thread.
|
||||
*
|
||||
* Returns the thread global state or NULL in case of error
|
||||
*/
|
||||
xmlGlobalStatePtr
|
||||
xmlGetGlobalState(void)
|
||||
{
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
xmlGlobalState *globalval;
|
||||
|
||||
if (XML_IS_THREADED() == 0)
|
||||
return (NULL);
|
||||
|
||||
if ((globalval = (xmlGlobalState *)
|
||||
pthread_getspecific(globalkey)) == NULL) {
|
||||
xmlGlobalState *tsd = xmlNewGlobalState();
|
||||
if (tsd == NULL)
|
||||
return(NULL);
|
||||
|
||||
pthread_setspecific(globalkey, tsd);
|
||||
return (tsd);
|
||||
}
|
||||
return (globalval);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
#if defined(HAVE_COMPILER_TLS)
|
||||
if (!tlstate_inited) {
|
||||
tlstate_inited = 1;
|
||||
xmlInitializeGlobalState(&tlstate);
|
||||
}
|
||||
return &tlstate;
|
||||
#else /* HAVE_COMPILER_TLS */
|
||||
xmlGlobalState *globalval;
|
||||
xmlGlobalStateCleanupHelperParams *p;
|
||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
||||
globalval = (xmlGlobalState *) TlsGetValue(globalkey);
|
||||
#else
|
||||
p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
|
||||
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
||||
#endif
|
||||
if (globalval == NULL) {
|
||||
xmlGlobalState *tsd = xmlNewGlobalState();
|
||||
|
||||
if (tsd == NULL)
|
||||
return(NULL);
|
||||
p = (xmlGlobalStateCleanupHelperParams *)
|
||||
malloc(sizeof(xmlGlobalStateCleanupHelperParams));
|
||||
if (p == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGetGlobalState: out of memory\n");
|
||||
xmlFreeGlobalState(tsd);
|
||||
return(NULL);
|
||||
}
|
||||
p->memory = tsd;
|
||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
||||
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
|
||||
GetCurrentProcess(), &p->thread, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
TlsSetValue(globalkey, tsd);
|
||||
_beginthread(xmlGlobalStateCleanupHelper, 0, p);
|
||||
#else
|
||||
EnterCriticalSection(&cleanup_helpers_cs);
|
||||
if (cleanup_helpers_head != NULL) {
|
||||
cleanup_helpers_head->prev = p;
|
||||
}
|
||||
p->next = cleanup_helpers_head;
|
||||
p->prev = NULL;
|
||||
cleanup_helpers_head = p;
|
||||
TlsSetValue(globalkey, p);
|
||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
||||
#endif
|
||||
|
||||
return (tsd);
|
||||
}
|
||||
return (globalval);
|
||||
#endif /* HAVE_COMPILER_TLS */
|
||||
#else
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Library wide thread interfaces *
|
||||
|
@ -675,34 +388,6 @@ xmlGetThreadId(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlIsMainThread:
|
||||
*
|
||||
* DEPRECATED: Internal function, do not use.
|
||||
*
|
||||
* xmlIsMainThread() check whether the current thread is the main thread.
|
||||
*
|
||||
* Returns 1 if the current thread is the main thread, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlIsMainThread(void)
|
||||
{
|
||||
xmlInitParser();
|
||||
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
|
||||
#endif
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
if (XML_IS_THREADED() == 0)
|
||||
return (1);
|
||||
return (pthread_equal(mainthread,pthread_self()));
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
return (mainthread == GetCurrentThreadId());
|
||||
#else
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlLockLibrary:
|
||||
*
|
||||
|
@ -712,9 +397,6 @@ xmlIsMainThread(void)
|
|||
void
|
||||
xmlLockLibrary(void)
|
||||
{
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n");
|
||||
#endif
|
||||
xmlRMutexLock(xmlLibraryLock);
|
||||
}
|
||||
|
||||
|
@ -727,9 +409,6 @@ xmlLockLibrary(void)
|
|||
void
|
||||
xmlUnlockLibrary(void)
|
||||
{
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n");
|
||||
#endif
|
||||
xmlRMutexUnlock(xmlLibraryLock);
|
||||
}
|
||||
|
||||
|
@ -745,14 +424,44 @@ xmlInitThreads(void)
|
|||
}
|
||||
|
||||
/**
|
||||
* xmlInitThreadsInternal:
|
||||
* xmlCleanupThreads:
|
||||
*
|
||||
* Used to to initialize all the thread related data.
|
||||
* DEPRECATED: This function is a no-op. Call xmlCleanupParser
|
||||
* to free global state but see the warnings there. xmlCleanupParser
|
||||
* should be only called once at program exit. In most cases, you don't
|
||||
* have call cleanup functions at all.
|
||||
*/
|
||||
void
|
||||
xmlInitThreadsInternal(void)
|
||||
xmlCleanupThreads(void)
|
||||
{
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Library wide initialization *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
static int xmlParserInitialized = 0;
|
||||
static int xmlParserInnerInitialized = 0;
|
||||
|
||||
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlGlobalInitMutexLock
|
||||
*
|
||||
* Makes sure that the global initialization mutex is initialized and
|
||||
* locks it.
|
||||
*/
|
||||
static void
|
||||
xmlGlobalInitMutexLock(void) {
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
|
||||
#ifdef XML_PTHREAD_WEAK
|
||||
/*
|
||||
* This is somewhat unreliable since libpthread could be loaded
|
||||
|
@ -761,10 +470,6 @@ xmlInitThreadsInternal(void)
|
|||
*/
|
||||
if (libxml_is_threaded == -1)
|
||||
libxml_is_threaded =
|
||||
(pthread_getspecific != NULL) &&
|
||||
(pthread_setspecific != NULL) &&
|
||||
(pthread_key_create != NULL) &&
|
||||
(pthread_key_delete != NULL) &&
|
||||
(pthread_mutex_init != NULL) &&
|
||||
(pthread_mutex_destroy != NULL) &&
|
||||
(pthread_mutex_lock != NULL) &&
|
||||
|
@ -779,136 +484,198 @@ xmlInitThreadsInternal(void)
|
|||
/* (pthread_equal != NULL) && */
|
||||
(pthread_self != NULL) &&
|
||||
(pthread_cond_signal != NULL);
|
||||
if (libxml_is_threaded == 0)
|
||||
return;
|
||||
#endif /* XML_PTHREAD_WEAK */
|
||||
pthread_key_create(&globalkey, xmlFreeGlobalState);
|
||||
mainthread = pthread_self();
|
||||
#elif defined(HAVE_WIN32_THREADS)
|
||||
#if !defined(HAVE_COMPILER_TLS)
|
||||
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
||||
InitializeCriticalSection(&cleanup_helpers_cs);
|
||||
#endif
|
||||
globalkey = TlsAlloc();
|
||||
#endif
|
||||
mainthread = GetCurrentThreadId();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCleanupThreads:
|
||||
*
|
||||
* DEPRECATED: This function is a no-op. Call xmlCleanupParser
|
||||
* to free global state but see the warnings there. xmlCleanupParser
|
||||
* should be only called once at program exit. In most cases, you don't
|
||||
* have call cleanup functions at all.
|
||||
*/
|
||||
void
|
||||
xmlCleanupThreads(void)
|
||||
{
|
||||
}
|
||||
/* The mutex is statically initialized, so we just lock it. */
|
||||
if (XML_IS_THREADED() != 0)
|
||||
pthread_mutex_lock(&global_init_lock);
|
||||
|
||||
/**
|
||||
* xmlCleanupThreadsInternal:
|
||||
*
|
||||
* Used to to cleanup all the thread related data.
|
||||
*/
|
||||
void
|
||||
xmlCleanupThreadsInternal(void)
|
||||
{
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#ifdef XML_PTHREAD_WEAK
|
||||
if (libxml_is_threaded == 0)
|
||||
return;
|
||||
#endif /* XML_PTHREAD_WEAK */
|
||||
pthread_key_delete(globalkey);
|
||||
#elif defined(HAVE_WIN32_THREADS)
|
||||
#if !defined(HAVE_COMPILER_TLS)
|
||||
if (globalkey != TLS_OUT_OF_INDEXES) {
|
||||
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
||||
xmlGlobalStateCleanupHelperParams *p;
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
|
||||
EnterCriticalSection(&cleanup_helpers_cs);
|
||||
p = cleanup_helpers_head;
|
||||
while (p != NULL) {
|
||||
xmlGlobalStateCleanupHelperParams *temp = p;
|
||||
LPCRITICAL_SECTION cs;
|
||||
|
||||
p = p->next;
|
||||
xmlFreeGlobalState(temp->memory);
|
||||
free(temp);
|
||||
/* Create a new critical section */
|
||||
if (global_init_lock == NULL) {
|
||||
cs = malloc(sizeof(CRITICAL_SECTION));
|
||||
if (cs == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGlobalInitMutexLock: out of memory\n");
|
||||
return;
|
||||
}
|
||||
InitializeCriticalSection(cs);
|
||||
|
||||
/* Swap it into the global_init_lock */
|
||||
#ifdef InterlockedCompareExchangePointer
|
||||
InterlockedCompareExchangePointer((void **) &global_init_lock,
|
||||
cs, NULL);
|
||||
#else /* Use older void* version */
|
||||
InterlockedCompareExchange((void **) &global_init_lock,
|
||||
(void *) cs, NULL);
|
||||
#endif /* InterlockedCompareExchangePointer */
|
||||
|
||||
/* If another thread successfully recorded its critical
|
||||
* section in the global_init_lock then discard the one
|
||||
* allocated by this thread. */
|
||||
if (global_init_lock != cs) {
|
||||
DeleteCriticalSection(cs);
|
||||
free(cs);
|
||||
}
|
||||
cleanup_helpers_head = 0;
|
||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
||||
#endif
|
||||
TlsFree(globalkey);
|
||||
globalkey = TLS_OUT_OF_INDEXES;
|
||||
}
|
||||
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
||||
DeleteCriticalSection(&cleanup_helpers_cs);
|
||||
#endif
|
||||
|
||||
/* Lock the chosen critical section */
|
||||
EnterCriticalSection(global_init_lock);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
xmlGlobalInitMutexUnlock(void) {
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
if (XML_IS_THREADED() != 0)
|
||||
pthread_mutex_unlock(&global_init_lock);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
if (global_init_lock != NULL)
|
||||
LeaveCriticalSection(global_init_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* DllMain:
|
||||
* @hinstDLL: handle to DLL instance
|
||||
* @fdwReason: Reason code for entry
|
||||
* @lpvReserved: generic pointer (depends upon reason code)
|
||||
* xmlGlobalInitMutexDestroy
|
||||
*
|
||||
* Entry point for Windows library. It is being used to free thread-specific
|
||||
* storage.
|
||||
*
|
||||
* Returns TRUE always
|
||||
* Makes sure that the global initialization mutex is destroyed before
|
||||
* application termination.
|
||||
*/
|
||||
static void
|
||||
xmlGlobalInitMutexDestroy(void) {
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
||||
#if defined(LIBXML_STATIC_FOR_DLL)
|
||||
int
|
||||
xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason,
|
||||
ATTRIBUTE_UNUSED void *lpvReserved)
|
||||
#else
|
||||
/* declare to avoid "no previous prototype for 'DllMain'" warning */
|
||||
/* Note that we do NOT want to include this function declaration in
|
||||
a public header because it's meant to be called by Windows itself,
|
||||
not a program that uses this library. This also has to be exported. */
|
||||
|
||||
XMLPUBFUN BOOL WINAPI
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved);
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
|
||||
ATTRIBUTE_UNUSED LPVOID lpvReserved)
|
||||
#endif
|
||||
{
|
||||
switch (fdwReason) {
|
||||
case DLL_THREAD_DETACH:
|
||||
if (globalkey != TLS_OUT_OF_INDEXES) {
|
||||
xmlGlobalState *globalval = NULL;
|
||||
xmlGlobalStateCleanupHelperParams *p =
|
||||
(xmlGlobalStateCleanupHelperParams *)
|
||||
TlsGetValue(globalkey);
|
||||
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
||||
if (globalval) {
|
||||
xmlFreeGlobalState(globalval);
|
||||
TlsSetValue(globalkey, NULL);
|
||||
}
|
||||
if (p) {
|
||||
EnterCriticalSection(&cleanup_helpers_cs);
|
||||
if (p == cleanup_helpers_head)
|
||||
cleanup_helpers_head = p->next;
|
||||
else
|
||||
p->prev->next = p->next;
|
||||
if (p->next != NULL)
|
||||
p->next->prev = p->prev;
|
||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
if (global_init_lock != NULL) {
|
||||
DeleteCriticalSection(global_init_lock);
|
||||
free(global_init_lock);
|
||||
global_init_lock = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlInitParser:
|
||||
*
|
||||
* Initialization function for the XML parser.
|
||||
*
|
||||
* Call once from the main thread before using the library in
|
||||
* multithreaded programs.
|
||||
*/
|
||||
void
|
||||
xmlInitParser(void) {
|
||||
/*
|
||||
* Note that the initialization code must not make memory allocations.
|
||||
*/
|
||||
if (xmlParserInitialized != 0)
|
||||
return;
|
||||
|
||||
xmlGlobalInitMutexLock();
|
||||
|
||||
if (xmlParserInnerInitialized == 0) {
|
||||
#if defined(_WIN32) && \
|
||||
!defined(LIBXML_THREAD_ALLOC_ENABLED) && \
|
||||
(!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
||||
if (xmlFree == free)
|
||||
atexit(xmlCleanupParser);
|
||||
#endif
|
||||
|
||||
xmlInitMemoryInternal(); /* Should come second */
|
||||
xmlInitGlobalsInternal();
|
||||
xmlInitRandom();
|
||||
xmlInitDictInternal();
|
||||
xmlInitEncodingInternal();
|
||||
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
||||
xmlInitXPathInternal();
|
||||
#endif
|
||||
|
||||
xmlRegisterDefaultInputCallbacks();
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
xmlRegisterDefaultOutputCallbacks();
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
xmlParserInnerInitialized = 1;
|
||||
}
|
||||
|
||||
xmlGlobalInitMutexUnlock();
|
||||
|
||||
xmlParserInitialized = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCleanupParser:
|
||||
*
|
||||
* This function name is somewhat misleading. It does not clean up
|
||||
* parser state, it cleans up memory allocated by the library itself.
|
||||
* It is a cleanup function for the XML library. It tries to reclaim all
|
||||
* related global memory allocated for the library processing.
|
||||
* It doesn't deallocate any document related memory. One should
|
||||
* call xmlCleanupParser() only when the process has finished using
|
||||
* the library and all XML/HTML documents built with it.
|
||||
* See also xmlInitParser() which has the opposite function of preparing
|
||||
* the library for operations.
|
||||
*
|
||||
* WARNING: if your application is multithreaded or has plugin support
|
||||
* calling this may crash the application if another thread or
|
||||
* a plugin is still using libxml2. It's sometimes very hard to
|
||||
* guess if libxml2 is in use in the application, some libraries
|
||||
* or plugins may use it without notice. In case of doubt abstain
|
||||
* from calling this function or do it just before calling exit()
|
||||
* to avoid leak reports from valgrind !
|
||||
*/
|
||||
void
|
||||
xmlCleanupParser(void) {
|
||||
if (!xmlParserInitialized)
|
||||
return;
|
||||
|
||||
/* These functions can call xmlFree. */
|
||||
|
||||
xmlCleanupCharEncodingHandlers();
|
||||
#ifdef LIBXML_CATALOG_ENABLED
|
||||
xmlCatalogCleanup();
|
||||
#endif
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
xmlSchemaCleanupTypes();
|
||||
xmlRelaxNGCleanupTypes();
|
||||
#endif
|
||||
|
||||
/* These functions should never call xmlFree. */
|
||||
|
||||
xmlCleanupInputCallbacks();
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
xmlCleanupOutputCallbacks();
|
||||
#endif
|
||||
|
||||
xmlCleanupDictInternal();
|
||||
xmlCleanupRandom();
|
||||
xmlCleanupGlobalsInternal();
|
||||
/*
|
||||
* Must come last. On Windows, xmlCleanupGlobalsInternal can call
|
||||
* xmlFree which uses xmlMemMutex in debug mode.
|
||||
*/
|
||||
xmlCleanupMemoryInternal();
|
||||
|
||||
xmlGlobalInitMutexDestroy();
|
||||
|
||||
xmlParserInitialized = 0;
|
||||
xmlParserInnerInitialized = 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_ATTRIBUTE_DESTRUCTOR) && \
|
||||
!defined(LIBXML_THREAD_ALLOC_ENABLED) && \
|
||||
!defined(LIBXML_STATIC) && \
|
||||
!defined(_WIN32)
|
||||
static void
|
||||
ATTRIBUTE_DESTRUCTOR
|
||||
xmlDestructor(void) {
|
||||
/*
|
||||
* Calling custom deallocation functions in a destructor can cause
|
||||
* problems, for example with Nokogiri.
|
||||
*/
|
||||
if (xmlFree == free)
|
||||
xmlCleanupParser();
|
||||
}
|
||||
#endif
|
||||
|
|
300
libs/xml2/tree.c
300
libs/xml2/tree.c
|
@ -28,15 +28,13 @@
|
|||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/entities.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/globals.h>
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
#include <libxml/HTMLtree.h>
|
||||
#endif
|
||||
|
@ -142,9 +140,6 @@ static int xmlCheckDTD = 1;
|
|||
#define IS_STR_XML(str) ((str != NULL) && (str[0] == 'x') && \
|
||||
(str[1] == 'm') && (str[2] == 'l') && (str[3] == 0))
|
||||
|
||||
/* #define DEBUG_BUFFER */
|
||||
/* #define DEBUG_TREE */
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Functions to move to entities.c once the *
|
||||
|
@ -357,7 +352,6 @@ xmlSplitQName3(const xmlChar *name, int *len) {
|
|||
|
||||
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
|
||||
|
||||
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
|
||||
/**
|
||||
* xmlValidateNCName:
|
||||
* @value: the value to check
|
||||
|
@ -429,7 +423,6 @@ try_complex:
|
|||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
||||
/**
|
||||
|
@ -805,10 +798,6 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
|
|||
void
|
||||
xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
||||
if (node == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSetNs: node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if ((node->type == XML_ELEMENT_NODE) ||
|
||||
|
@ -825,10 +814,6 @@ xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
|||
void
|
||||
xmlFreeNs(xmlNsPtr cur) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeNs : ns == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (cur->href != NULL) xmlFree((char *) cur->href);
|
||||
|
@ -846,10 +831,6 @@ void
|
|||
xmlFreeNsList(xmlNsPtr cur) {
|
||||
xmlNsPtr next;
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeNsList : ns == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
while (cur != NULL) {
|
||||
|
@ -877,12 +858,6 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
|
|||
xmlDtdPtr cur;
|
||||
|
||||
if ((doc != NULL) && (doc->extSubset != NULL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewDtd(%s): document %s already have a DTD %s\n",
|
||||
/* !!! */ (char *) name, doc->name,
|
||||
/* !!! */ (char *)doc->extSubset->name);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -951,12 +926,6 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
|
|||
xmlDtdPtr cur;
|
||||
|
||||
if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
|
||||
"xmlCreateIntSubset(): document %s already have an internal subset\n",
|
||||
doc->name);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -1210,10 +1179,6 @@ xmlFreeDoc(xmlDocPtr cur) {
|
|||
xmlDictPtr dict = NULL;
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeDoc : document == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1965,10 +1930,6 @@ xmlAttrPtr
|
|||
xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewProp : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -1991,10 +1952,6 @@ xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
|||
const xmlChar *value) {
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNsProp : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2016,10 +1973,6 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
|
|||
const xmlChar *value) {
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNsPropEatName : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2045,10 +1998,6 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
|
|||
xmlAttrPtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewDocProp : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2143,17 +2092,9 @@ int
|
|||
xmlRemoveProp(xmlAttrPtr cur) {
|
||||
xmlAttrPtr tmp;
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRemoveProp : cur == NULL\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
if (cur->parent == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRemoveProp : cur->parent == NULL\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
tmp = cur->parent->properties;
|
||||
|
@ -2174,10 +2115,6 @@ xmlRemoveProp(xmlAttrPtr cur) {
|
|||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRemoveProp : attribute not owned by its node\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -2195,10 +2132,6 @@ xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) {
|
|||
xmlNodePtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewPI : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2260,10 +2193,6 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
|
|||
xmlNodePtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNode : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2304,10 +2233,6 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
|
|||
xmlNodePtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNode : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2526,18 +2451,10 @@ xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns,
|
|||
xmlNodePtr cur, prev;
|
||||
|
||||
if (parent == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewTextChild : parent == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewTextChild : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -2961,18 +2878,10 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
|||
xmlNodePtr cur, prev;
|
||||
|
||||
if (parent == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewChild : parent == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewChild : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -3089,25 +2998,13 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
|
|||
xmlNodePtr
|
||||
xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddNextSibling : cur == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddNextSibling : elem == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (cur == elem) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddNextSibling : cur == elem\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -3169,25 +3066,13 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
|||
xmlNodePtr
|
||||
xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddPrevSibling : cur == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddPrevSibling : elem == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (cur == elem) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddPrevSibling : cur == elem\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -3249,26 +3134,14 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
|||
xmlNodePtr parent;
|
||||
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddSibling : cur == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddSibling : elem == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (cur == elem) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddSibling : cur == elem\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -3327,27 +3200,15 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
|||
xmlNodePtr prev;
|
||||
|
||||
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddChildList : parent == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddChildList : child == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if ((cur->doc != NULL) && (parent->doc != NULL) &&
|
||||
(cur->doc != parent->doc)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Elements moved to a different document\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3419,26 +3280,14 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
|||
xmlNodePtr prev;
|
||||
|
||||
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddChild : parent == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddChild : child == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (parent == cur) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlAddChild : parent == cur\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
/*
|
||||
|
@ -3541,10 +3390,6 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
|||
xmlNodePtr
|
||||
xmlGetLastChild(const xmlNode *parent) {
|
||||
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGetLastChild : parent == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
return(parent->last);
|
||||
|
@ -3909,10 +3754,6 @@ xmlFreeNode(xmlNodePtr cur) {
|
|||
void
|
||||
xmlUnlinkNode(xmlNodePtr cur) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlUnlinkNode : node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (cur->type == XML_NAMESPACE_DECL)
|
||||
|
@ -3989,10 +3830,6 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
|||
if (old == cur) return(NULL);
|
||||
if ((old == NULL) || (old->type == XML_NAMESPACE_DECL) ||
|
||||
(old->parent == NULL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlReplaceNode : old == NULL or without parent\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||
|
@ -4003,17 +3840,9 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
|||
return(old);
|
||||
}
|
||||
if ((old->type==XML_ATTRIBUTE_NODE) && (cur->type!=XML_ATTRIBUTE_NODE)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlReplaceNode : Trying to replace attribute node with other node type\n");
|
||||
#endif
|
||||
return(old);
|
||||
}
|
||||
if ((cur->type==XML_ATTRIBUTE_NODE) && (old->type!=XML_ATTRIBUTE_NODE)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlReplaceNode : Trying to replace a non-attribute node with attribute node\n");
|
||||
#endif
|
||||
return(old);
|
||||
}
|
||||
xmlUnlinkNode(cur);
|
||||
|
@ -4066,10 +3895,6 @@ xmlCopyNamespace(xmlNsPtr cur) {
|
|||
ret = xmlNewNs(NULL, cur->href, cur->prefix);
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlCopyNamespace: invalid type %d\n", cur->type);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
|
@ -4381,7 +4206,10 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
|
|||
/*
|
||||
* Humm, we are copying an element whose namespace is defined
|
||||
* out of the new tree scope. Search it in the original tree
|
||||
* and add it at the top of the new tree
|
||||
* and add it at the top of the new tree.
|
||||
*
|
||||
* TODO: Searching the original tree seems unnecessary. We
|
||||
* already have a namespace URI.
|
||||
*/
|
||||
ns = xmlSearchNs(node->doc, node, node->ns->prefix);
|
||||
if (ns != NULL) {
|
||||
|
@ -4389,8 +4217,8 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
|
|||
|
||||
while (root->parent != NULL) root = root->parent;
|
||||
ret->ns = xmlNewNs(root, ns->href, ns->prefix);
|
||||
} else {
|
||||
ret->ns = xmlNewReconciledNs(doc, ret, node->ns);
|
||||
} else {
|
||||
ret->ns = xmlNewReconciledNs(doc, ret, node->ns);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
@ -4473,6 +4301,8 @@ xmlNodePtr
|
|||
xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
|
||||
xmlNodePtr ret = NULL;
|
||||
xmlNodePtr p = NULL,q;
|
||||
xmlDtdPtr newSubset = NULL;
|
||||
int linkedSubset = 0;
|
||||
|
||||
while (node != NULL) {
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
|
@ -4481,14 +4311,15 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
|
|||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
if (doc->intSubset == NULL) {
|
||||
if ((doc->intSubset == NULL) && (newSubset == NULL)) {
|
||||
q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
|
||||
if (q == NULL) goto error;
|
||||
q->doc = doc;
|
||||
q->parent = parent;
|
||||
doc->intSubset = (xmlDtdPtr) q;
|
||||
newSubset = (xmlDtdPtr) q;
|
||||
xmlAddChild(parent, q);
|
||||
} else {
|
||||
linkedSubset = 1;
|
||||
q = (xmlNodePtr) doc->intSubset;
|
||||
xmlAddChild(parent, q);
|
||||
}
|
||||
|
@ -4507,8 +4338,12 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
|
|||
}
|
||||
node = node->next;
|
||||
}
|
||||
if ((doc != NULL) && (newSubset != NULL))
|
||||
doc->intSubset = newSubset;
|
||||
return(ret);
|
||||
error:
|
||||
if (linkedSubset != 0)
|
||||
xmlUnlinkNode((xmlNodePtr) doc->intSubset);
|
||||
xmlFreeNodeList(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
@ -5771,10 +5606,6 @@ xmlNodeGetContent(const xmlNode *cur)
|
|||
void
|
||||
xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeSetContent : node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
switch (cur->type) {
|
||||
|
@ -5844,10 +5675,6 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
|
|||
void
|
||||
xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeSetContentLen : node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
switch (cur->type) {
|
||||
|
@ -5914,10 +5741,6 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
|
|||
void
|
||||
xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeAddContentLen : node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (len <= 0) return;
|
||||
|
@ -5988,10 +5811,6 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
|
|||
int len;
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeAddContent : node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (content == NULL) return;
|
||||
|
@ -6357,17 +6176,9 @@ xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
|
|||
int counter = 1;
|
||||
|
||||
if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewReconciledNs : tree == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewReconciledNs : ns == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
/*
|
||||
|
@ -7114,10 +6925,6 @@ xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) {
|
|||
(node->type != XML_CDATA_SECTION_NODE) &&
|
||||
(node->type != XML_COMMENT_NODE) &&
|
||||
(node->type != XML_PI_NODE)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlTextConcat: node is not text nor CDATA\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
/* need to check if content is currently in the dictionary */
|
||||
|
@ -7235,7 +7042,7 @@ xmlBufferDetach(xmlBufferPtr buf) {
|
|||
* @mem: the memory area
|
||||
* @size: the size in byte
|
||||
*
|
||||
* Create an XML buffer initialized with bytes.
|
||||
* Returns an XML buffer initialized with bytes.
|
||||
*/
|
||||
xmlBufferPtr
|
||||
xmlBufferCreateStatic(void *mem, size_t size) {
|
||||
|
@ -7256,10 +7063,6 @@ void
|
|||
xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||
xmlBufferAllocationScheme scheme) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferSetAllocationScheme: buf == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (buf->alloc == XML_BUFFER_ALLOC_IO) return;
|
||||
|
@ -7279,10 +7082,6 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
|||
void
|
||||
xmlBufferFree(xmlBufferPtr buf) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferFree: buf == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7426,17 +7225,9 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
|
|||
size_t ret;
|
||||
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferDump: buf == NULL\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
if (buf->content == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferDump: buf->content == NULL\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
if (file == NULL)
|
||||
|
@ -7618,10 +7409,6 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
|
|||
return -1;
|
||||
}
|
||||
if (len < -1) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferAdd: len < 0\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
if (len == 0) return 0;
|
||||
|
@ -7670,17 +7457,9 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
|
|||
if (buf == NULL)
|
||||
return(-1);
|
||||
if (str == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferAddHead: str == NULL\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
if (len < -1) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferAddHead: len < 0\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
if (len == 0) return 0;
|
||||
|
@ -7805,10 +7584,6 @@ xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
|
|||
return;
|
||||
if (xmlStrchr(string, '\"')) {
|
||||
if (xmlStrchr(string, '\'')) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferWriteQuotedString: string contains quote and double-quotes !\n");
|
||||
#endif
|
||||
xmlBufferCCat(buf, "\"");
|
||||
base = cur = string;
|
||||
while(*cur != 0){
|
||||
|
@ -10270,3 +10045,44 @@ xmlIsXHTML(const xmlChar *systemID, const xmlChar *publicID) {
|
|||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Node callbacks *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlRegisterNodeDefault:
|
||||
* @func: function pointer to the new RegisterNodeFunc
|
||||
*
|
||||
* Registers a callback for node creation
|
||||
*
|
||||
* Returns the old value of the registration function
|
||||
*/
|
||||
xmlRegisterNodeFunc
|
||||
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
|
||||
{
|
||||
xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
|
||||
|
||||
__xmlRegisterCallbacks = 1;
|
||||
xmlRegisterNodeDefaultValue = func;
|
||||
return(old);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlDeregisterNodeDefault:
|
||||
* @func: function pointer to the new DeregisterNodeFunc
|
||||
*
|
||||
* Registers a callback for node destruction
|
||||
*
|
||||
* Returns the previous value of the deregistration function
|
||||
*/
|
||||
xmlDeregisterNodeFunc
|
||||
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
|
||||
{
|
||||
xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
|
||||
|
||||
__xmlRegisterCallbacks = 1;
|
||||
xmlDeregisterNodeDefaultValue = func;
|
||||
return(old);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
#include "private/error.h"
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/list.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#include "private/error.h"
|
||||
#include "private/parser.h"
|
||||
|
@ -29,8 +28,6 @@
|
|||
static xmlElementPtr
|
||||
xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
||||
int create);
|
||||
/* #define DEBUG_VALID_ALGO */
|
||||
/* #define DEBUG_REGEXP_ALGO */
|
||||
|
||||
#define TODO \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
|
@ -465,151 +462,6 @@ nodeVPop(xmlValidCtxtPtr ctxt)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VALID_ALGO
|
||||
static void
|
||||
xmlValidPrintNode(xmlNodePtr cur) {
|
||||
if (cur == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "null");
|
||||
return;
|
||||
}
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "%s ", cur->name);
|
||||
break;
|
||||
case XML_TEXT_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "text ");
|
||||
break;
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "cdata ");
|
||||
break;
|
||||
case XML_ENTITY_REF_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "&%s; ", cur->name);
|
||||
break;
|
||||
case XML_PI_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "pi(%s) ", cur->name);
|
||||
break;
|
||||
case XML_COMMENT_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "comment ");
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?attr? ");
|
||||
break;
|
||||
case XML_ENTITY_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?ent? ");
|
||||
break;
|
||||
case XML_DOCUMENT_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?doc? ");
|
||||
break;
|
||||
case XML_DOCUMENT_TYPE_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?doctype? ");
|
||||
break;
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?frag? ");
|
||||
break;
|
||||
case XML_NOTATION_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?nota? ");
|
||||
break;
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?html? ");
|
||||
break;
|
||||
case XML_DTD_NODE:
|
||||
xmlGenericError(xmlGenericErrorContext, "?dtd? ");
|
||||
break;
|
||||
case XML_ELEMENT_DECL:
|
||||
xmlGenericError(xmlGenericErrorContext, "?edecl? ");
|
||||
break;
|
||||
case XML_ATTRIBUTE_DECL:
|
||||
xmlGenericError(xmlGenericErrorContext, "?adecl? ");
|
||||
break;
|
||||
case XML_ENTITY_DECL:
|
||||
xmlGenericError(xmlGenericErrorContext, "?entdecl? ");
|
||||
break;
|
||||
case XML_NAMESPACE_DECL:
|
||||
xmlGenericError(xmlGenericErrorContext, "?nsdecl? ");
|
||||
break;
|
||||
case XML_XINCLUDE_START:
|
||||
xmlGenericError(xmlGenericErrorContext, "incstart ");
|
||||
break;
|
||||
case XML_XINCLUDE_END:
|
||||
xmlGenericError(xmlGenericErrorContext, "incend ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xmlValidPrintNodeList(xmlNodePtr cur) {
|
||||
if (cur == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, "null ");
|
||||
while (cur != NULL) {
|
||||
xmlValidPrintNode(cur);
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xmlValidDebug(xmlNodePtr cur, xmlElementContentPtr cont) {
|
||||
char expr[5000];
|
||||
|
||||
expr[0] = 0;
|
||||
xmlGenericError(xmlGenericErrorContext, "valid: ");
|
||||
xmlValidPrintNodeList(cur);
|
||||
xmlGenericError(xmlGenericErrorContext, "against ");
|
||||
xmlSnprintfElementContent(expr, 5000, cont, 1);
|
||||
xmlGenericError(xmlGenericErrorContext, "%s\n", expr);
|
||||
}
|
||||
|
||||
static void
|
||||
xmlValidDebugState(xmlValidStatePtr state) {
|
||||
xmlGenericError(xmlGenericErrorContext, "(");
|
||||
if (state->cont == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext, "null,");
|
||||
else
|
||||
switch (state->cont->type) {
|
||||
case XML_ELEMENT_CONTENT_PCDATA:
|
||||
xmlGenericError(xmlGenericErrorContext, "pcdata,");
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_ELEMENT:
|
||||
xmlGenericError(xmlGenericErrorContext, "%s,",
|
||||
state->cont->name);
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_SEQ:
|
||||
xmlGenericError(xmlGenericErrorContext, "seq,");
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_OR:
|
||||
xmlGenericError(xmlGenericErrorContext, "or,");
|
||||
break;
|
||||
}
|
||||
xmlValidPrintNode(state->node);
|
||||
xmlGenericError(xmlGenericErrorContext, ",%d,%X,%d)",
|
||||
state->depth, state->occurs, state->state);
|
||||
}
|
||||
|
||||
static void
|
||||
xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
|
||||
int i, j;
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "state: ");
|
||||
xmlValidDebugState(ctxt->vstate);
|
||||
xmlGenericError(xmlGenericErrorContext, " stack: %d ",
|
||||
ctxt->vstateNr - 1);
|
||||
for (i = 0, j = ctxt->vstateNr - 1;(i < 3) && (j > 0);i++,j--)
|
||||
xmlValidDebugState(&ctxt->vstateTab[j]);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
}
|
||||
|
||||
/*****
|
||||
#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
|
||||
*****/
|
||||
|
||||
#define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt);
|
||||
#define DEBUG_VALID_MSG(m) \
|
||||
xmlGenericError(xmlGenericErrorContext, "%s\n", m);
|
||||
|
||||
#else
|
||||
#define DEBUG_VALID_STATE(n,c)
|
||||
#define DEBUG_VALID_MSG(m)
|
||||
#endif
|
||||
|
||||
/* TODO: use hash table for accesses to elem and attribute definitions */
|
||||
|
||||
|
||||
|
@ -828,9 +680,6 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
|||
XML_DTD_CONTENT_NOT_DETERMINIST,
|
||||
"Content model of %s is not deterministic: %s\n",
|
||||
elem->name, BAD_CAST expr, NULL);
|
||||
#ifdef DEBUG_REGEXP_ALGO
|
||||
xmlRegexpPrint(stderr, elem->contModel);
|
||||
#endif
|
||||
ctxt->valid = 0;
|
||||
ctxt->state = NULL;
|
||||
xmlFreeAutomata(ctxt->am);
|
||||
|
@ -4892,13 +4741,10 @@ cont:
|
|||
* epsilon transition, go directly to the analysis phase
|
||||
*/
|
||||
if (STATE == ROLLBACK_PARENT) {
|
||||
DEBUG_VALID_MSG("restored parent branch");
|
||||
DEBUG_VALID_STATE(NODE, CONT)
|
||||
ret = 1;
|
||||
goto analyze;
|
||||
}
|
||||
|
||||
DEBUG_VALID_STATE(NODE, CONT)
|
||||
/*
|
||||
* we may have to save a backup state here. This is the equivalent
|
||||
* of handling epsilon transition in NFAs.
|
||||
|
@ -4910,7 +4756,6 @@ cont:
|
|||
((CONT->ocur == XML_ELEMENT_CONTENT_MULT) ||
|
||||
(CONT->ocur == XML_ELEMENT_CONTENT_OPT) ||
|
||||
((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURRENCE)))) {
|
||||
DEBUG_VALID_MSG("saving parent branch");
|
||||
if (vstateVPush(ctxt, CONT, NODE, DEPTH, OCCURS, ROLLBACK_PARENT) < 0)
|
||||
return(0);
|
||||
}
|
||||
|
@ -4922,12 +4767,10 @@ cont:
|
|||
switch (CONT->type) {
|
||||
case XML_ELEMENT_CONTENT_PCDATA:
|
||||
if (NODE == NULL) {
|
||||
DEBUG_VALID_MSG("pcdata failed no node");
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
if (NODE->type == XML_TEXT_NODE) {
|
||||
DEBUG_VALID_MSG("pcdata found, skip to next");
|
||||
/*
|
||||
* go to next element in the content model
|
||||
* skipping ignorable elems
|
||||
|
@ -4945,14 +4788,12 @@ cont:
|
|||
ret = 1;
|
||||
break;
|
||||
} else {
|
||||
DEBUG_VALID_MSG("pcdata failed");
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_ELEMENT:
|
||||
if (NODE == NULL) {
|
||||
DEBUG_VALID_MSG("element failed no node");
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -4968,7 +4809,6 @@ cont:
|
|||
}
|
||||
}
|
||||
if (ret == 1) {
|
||||
DEBUG_VALID_MSG("element found, skip to next");
|
||||
/*
|
||||
* go to next element in the content model
|
||||
* skipping ignorable elems
|
||||
|
@ -4984,7 +4824,6 @@ cont:
|
|||
(NODE->type != XML_TEXT_NODE) &&
|
||||
(NODE->type != XML_CDATA_SECTION_NODE)));
|
||||
} else {
|
||||
DEBUG_VALID_MSG("element failed");
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -5017,7 +4856,6 @@ cont:
|
|||
/*
|
||||
* save the second branch 'or' branch
|
||||
*/
|
||||
DEBUG_VALID_MSG("saving 'or' branch");
|
||||
if (vstateVPush(ctxt, CONT->c2, NODE, DEPTH + 1,
|
||||
OCCURS, ROLLBACK_OR) < 0)
|
||||
return(-1);
|
||||
|
@ -5059,7 +4897,6 @@ cont:
|
|||
* At this point handle going up in the tree
|
||||
*/
|
||||
if (ret == -1) {
|
||||
DEBUG_VALID_MSG("error found returning");
|
||||
return(ret);
|
||||
}
|
||||
analyze:
|
||||
|
@ -5074,9 +4911,7 @@ analyze:
|
|||
|
||||
case XML_ELEMENT_CONTENT_ONCE:
|
||||
cur = ctxt->vstate->node;
|
||||
DEBUG_VALID_MSG("Once branch failed, rollback");
|
||||
if (vstateVPop(ctxt) < 0 ) {
|
||||
DEBUG_VALID_MSG("exhaustion, failed");
|
||||
return(0);
|
||||
}
|
||||
if (cur != ctxt->vstate->node)
|
||||
|
@ -5085,69 +4920,50 @@ analyze:
|
|||
case XML_ELEMENT_CONTENT_PLUS:
|
||||
if (OCCURRENCE == 0) {
|
||||
cur = ctxt->vstate->node;
|
||||
DEBUG_VALID_MSG("Plus branch failed, rollback");
|
||||
if (vstateVPop(ctxt) < 0 ) {
|
||||
DEBUG_VALID_MSG("exhaustion, failed");
|
||||
return(0);
|
||||
}
|
||||
if (cur != ctxt->vstate->node)
|
||||
determinist = -3;
|
||||
goto cont;
|
||||
}
|
||||
DEBUG_VALID_MSG("Plus branch found");
|
||||
ret = 1;
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_MULT:
|
||||
#ifdef DEBUG_VALID_ALGO
|
||||
if (OCCURRENCE == 0) {
|
||||
DEBUG_VALID_MSG("Mult branch failed");
|
||||
} else {
|
||||
DEBUG_VALID_MSG("Mult branch found");
|
||||
}
|
||||
#endif
|
||||
ret = 1;
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_OPT:
|
||||
DEBUG_VALID_MSG("Option branch failed");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (CONT->ocur) {
|
||||
case XML_ELEMENT_CONTENT_OPT:
|
||||
DEBUG_VALID_MSG("Option branch succeeded");
|
||||
ret = 1;
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_ONCE:
|
||||
DEBUG_VALID_MSG("Once branch succeeded");
|
||||
ret = 1;
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_PLUS:
|
||||
if (STATE == ROLLBACK_PARENT) {
|
||||
DEBUG_VALID_MSG("Plus branch rollback");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
if (NODE == NULL) {
|
||||
DEBUG_VALID_MSG("Plus branch exhausted");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
DEBUG_VALID_MSG("Plus branch succeeded, continuing");
|
||||
SET_OCCURRENCE;
|
||||
goto cont;
|
||||
case XML_ELEMENT_CONTENT_MULT:
|
||||
if (STATE == ROLLBACK_PARENT) {
|
||||
DEBUG_VALID_MSG("Mult branch rollback");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
if (NODE == NULL) {
|
||||
DEBUG_VALID_MSG("Mult branch exhausted");
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
DEBUG_VALID_MSG("Mult branch succeeded, continuing");
|
||||
/* SET_OCCURRENCE; */
|
||||
goto cont;
|
||||
}
|
||||
|
@ -5164,33 +4980,26 @@ analyze:
|
|||
|
||||
switch (CONT->parent->type) {
|
||||
case XML_ELEMENT_CONTENT_PCDATA:
|
||||
DEBUG_VALID_MSG("Error: parent pcdata");
|
||||
return(-1);
|
||||
case XML_ELEMENT_CONTENT_ELEMENT:
|
||||
DEBUG_VALID_MSG("Error: parent element");
|
||||
return(-1);
|
||||
case XML_ELEMENT_CONTENT_OR:
|
||||
if (ret == 1) {
|
||||
DEBUG_VALID_MSG("Or succeeded");
|
||||
CONT = CONT->parent;
|
||||
DEPTH--;
|
||||
} else {
|
||||
DEBUG_VALID_MSG("Or failed");
|
||||
CONT = CONT->parent;
|
||||
DEPTH--;
|
||||
}
|
||||
break;
|
||||
case XML_ELEMENT_CONTENT_SEQ:
|
||||
if (ret == 0) {
|
||||
DEBUG_VALID_MSG("Sequence failed");
|
||||
CONT = CONT->parent;
|
||||
DEPTH--;
|
||||
} else if (CONT == CONT->parent->c1) {
|
||||
DEBUG_VALID_MSG("Sequence testing 2nd branch");
|
||||
CONT = CONT->parent->c2;
|
||||
goto cont;
|
||||
} else {
|
||||
DEBUG_VALID_MSG("Sequence succeeded");
|
||||
CONT = CONT->parent;
|
||||
DEPTH--;
|
||||
}
|
||||
|
@ -5200,9 +5009,7 @@ analyze:
|
|||
xmlNodePtr cur;
|
||||
|
||||
cur = ctxt->vstate->node;
|
||||
DEBUG_VALID_MSG("Failed, remaining input, rollback");
|
||||
if (vstateVPop(ctxt) < 0 ) {
|
||||
DEBUG_VALID_MSG("exhaustion, failed");
|
||||
return(0);
|
||||
}
|
||||
if (cur != ctxt->vstate->node)
|
||||
|
@ -5213,9 +5020,7 @@ analyze:
|
|||
xmlNodePtr cur;
|
||||
|
||||
cur = ctxt->vstate->node;
|
||||
DEBUG_VALID_MSG("Failure, rollback");
|
||||
if (vstateVPop(ctxt) < 0 ) {
|
||||
DEBUG_VALID_MSG("exhaustion, failed");
|
||||
return(0);
|
||||
}
|
||||
if (cur != ctxt->vstate->node)
|
||||
|
@ -5454,7 +5259,6 @@ fail:
|
|||
* Build a minimal representation of this node content
|
||||
* sufficient to run the validation process on it
|
||||
*/
|
||||
DEBUG_VALID_MSG("Found an entity reference, linearizing");
|
||||
cur = child;
|
||||
while (cur != NULL) {
|
||||
switch (cur->type) {
|
||||
|
@ -6460,7 +6264,7 @@ name_ok:
|
|||
* xmlValidateElement:
|
||||
* @ctxt: the validation context
|
||||
* @doc: a document instance
|
||||
* @elem: an element instance
|
||||
* @root: an element instance
|
||||
*
|
||||
* Try to validate the subtree under an element
|
||||
*
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
|
@ -34,13 +33,6 @@
|
|||
|
||||
#define XINCLUDE_MAX_DEPTH 40
|
||||
|
||||
/* #define DEBUG_XINCLUDE */
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
#include <libxml/debugXML.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* XInclude context handling *
|
||||
|
@ -222,9 +214,6 @@ static void
|
|||
xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) {
|
||||
if (ref == NULL)
|
||||
return;
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Freeing ref\n");
|
||||
#endif
|
||||
if (ref->URI != NULL)
|
||||
xmlFree(ref->URI);
|
||||
if (ref->fragment != NULL)
|
||||
|
@ -247,9 +236,6 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
|
|||
xmlNodePtr elem) {
|
||||
xmlXIncludeRefPtr ret;
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "New ref %s\n", URI);
|
||||
#endif
|
||||
ret = (xmlXIncludeRefPtr) xmlMalloc(sizeof(xmlXIncludeRef));
|
||||
if (ret == NULL) {
|
||||
xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
|
||||
|
@ -264,19 +250,13 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
|
|||
ret->elem = elem;
|
||||
ret->xml = 0;
|
||||
ret->inc = NULL;
|
||||
if (ctxt->incMax == 0) {
|
||||
ctxt->incMax = 4;
|
||||
ctxt->incTab = (xmlXIncludeRefPtr *) xmlMalloc(ctxt->incMax *
|
||||
sizeof(ctxt->incTab[0]));
|
||||
if (ctxt->incTab == NULL) {
|
||||
xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
|
||||
xmlXIncludeFreeRef(ret);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
if (ctxt->incNr >= ctxt->incMax) {
|
||||
xmlXIncludeRefPtr *tmp;
|
||||
size_t newSize = ctxt->incMax * 2;
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
size_t newSize = ctxt->incMax ? ctxt->incMax * 2 : 1;
|
||||
#else
|
||||
size_t newSize = ctxt->incMax ? ctxt->incMax * 2 : 4;
|
||||
#endif
|
||||
|
||||
tmp = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
|
||||
newSize * sizeof(ctxt->incTab[0]));
|
||||
|
@ -286,7 +266,7 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
|
|||
return(NULL);
|
||||
}
|
||||
ctxt->incTab = tmp;
|
||||
ctxt->incMax *= 2;
|
||||
ctxt->incMax = newSize;
|
||||
}
|
||||
ctxt->incTab[ctxt->incNr++] = ret;
|
||||
return(ret);
|
||||
|
@ -304,9 +284,6 @@ xmlXIncludeCtxtPtr
|
|||
xmlXIncludeNewContext(xmlDocPtr doc) {
|
||||
xmlXIncludeCtxtPtr ret;
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "New context\n");
|
||||
#endif
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
ret = (xmlXIncludeCtxtPtr) xmlMalloc(sizeof(xmlXIncludeCtxt));
|
||||
|
@ -334,9 +311,6 @@ void
|
|||
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
|
||||
int i;
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Freeing context\n");
|
||||
#endif
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
if (ctxt->urlTab != NULL) {
|
||||
|
@ -463,9 +437,6 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
if (cur == NULL)
|
||||
return(NULL);
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Add node\n");
|
||||
#endif
|
||||
/*
|
||||
* read the attributes
|
||||
*/
|
||||
|
@ -1271,9 +1242,6 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
int saveFlags;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Loading doc %s\n", url);
|
||||
#endif
|
||||
/*
|
||||
* Check the URL and remove any fragment identifier
|
||||
*/
|
||||
|
@ -1314,9 +1282,6 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
*/
|
||||
for (i = 0; i < ctxt->urlNr; i++) {
|
||||
if (xmlStrEqual(URL, ctxt->urlTab[i].url)) {
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
printf("Already loaded %s\n", URL);
|
||||
#endif
|
||||
if (ctxt->urlTab[i].expanding) {
|
||||
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_RECURSION,
|
||||
"inclusion loop detected\n", NULL);
|
||||
|
@ -1332,9 +1297,6 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
/*
|
||||
* Load it.
|
||||
*/
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
printf("loading %s\n", URL);
|
||||
#endif
|
||||
#ifdef LIBXML_XPTR_ENABLED
|
||||
/*
|
||||
* If this is an XPointer evaluation, we want to assure that
|
||||
|
@ -1355,7 +1317,11 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
/* Also cache NULL docs */
|
||||
if (ctxt->urlNr >= ctxt->urlMax) {
|
||||
xmlXIncludeDoc *tmp;
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
size_t newSize = ctxt->urlMax ? ctxt->urlMax * 2 : 1;
|
||||
#else
|
||||
size_t newSize = ctxt->urlMax ? ctxt->urlMax * 2 : 8;
|
||||
#endif
|
||||
|
||||
tmp = xmlRealloc(ctxt->urlTab, sizeof(xmlXIncludeDoc) * newSize);
|
||||
if (tmp == NULL) {
|
||||
|
@ -1749,8 +1715,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
int cur;
|
||||
int l;
|
||||
|
||||
cur = xmlStringCurrentChar(NULL, &content[i], &l);
|
||||
if (!IS_CHAR(cur)) {
|
||||
l = len - i;
|
||||
cur = xmlGetUTF8Char(&content[i], &l);
|
||||
if ((cur < 0) || (!IS_CHAR(cur))) {
|
||||
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_INVALID_CHAR,
|
||||
"%s contains invalid char\n", URL);
|
||||
goto error;
|
||||
|
@ -1763,7 +1730,11 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
|
|||
|
||||
if (ctxt->txtNr >= ctxt->txtMax) {
|
||||
xmlXIncludeTxt *tmp;
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
size_t newSize = ctxt->txtMax ? ctxt->txtMax * 2 : 1;
|
||||
#else
|
||||
size_t newSize = ctxt->txtMax ? ctxt->txtMax * 2 : 8;
|
||||
#endif
|
||||
|
||||
tmp = xmlRealloc(ctxt->txtTab, sizeof(xmlXIncludeTxt) * newSize);
|
||||
if (tmp == NULL) {
|
||||
|
@ -1870,6 +1841,20 @@ xmlXIncludeExpandNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
|
|||
* The XInclude engine offers no protection against exponential
|
||||
* expansion attacks similar to "billion laughs". Avoid timeouts by
|
||||
* limiting the total number of replacements when fuzzing.
|
||||
*
|
||||
* Unfortuately, a single XInclude can already result in quadratic
|
||||
* behavior:
|
||||
*
|
||||
* <doc xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
* <xi:include xpointer="xpointer(//e)"/>
|
||||
* <e>
|
||||
* <e>
|
||||
* <e>
|
||||
* <!-- more nested elements -->
|
||||
* </e>
|
||||
* </e>
|
||||
* </e>
|
||||
* </doc>
|
||||
*/
|
||||
if (ctxt->incTotal >= 20)
|
||||
return(NULL);
|
||||
|
@ -1985,11 +1970,6 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
|
|||
xmlFree(base);
|
||||
return(-1);
|
||||
}
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "parse: %s\n",
|
||||
xml ? "xml": "text");
|
||||
xmlGenericError(xmlGenericErrorContext, "URI: %s\n", URI);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Save the base for this include (saving the current one)
|
||||
|
@ -2015,9 +1995,6 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
|
|||
/*
|
||||
* Time to try a fallback if available
|
||||
*/
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "error looking for fallback\n");
|
||||
#endif
|
||||
children = cur->children;
|
||||
while (children != NULL) {
|
||||
if ((children->type == XML_ELEMENT_NODE) &&
|
||||
|
|
|
@ -50,10 +50,10 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/nanohttp.h>
|
||||
#include <libxml/nanoftp.h>
|
||||
|
@ -61,7 +61,6 @@
|
|||
#ifdef LIBXML_CATALOG_ENABLED
|
||||
#include <libxml/catalog.h>
|
||||
#endif
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#include "private/buf.h"
|
||||
#include "private/enc.h"
|
||||
|
@ -70,14 +69,8 @@
|
|||
#include "private/parser.h"
|
||||
|
||||
/* #define VERBOSE_FAILURE */
|
||||
/* #define DEBUG_EXTERNAL_ENTITIES */
|
||||
/* #define DEBUG_INPUT */
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
#define MINLEN 40
|
||||
#else
|
||||
#define MINLEN 4000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Input I/O callback sets
|
||||
|
@ -211,6 +204,7 @@ __xmlIOWin32UTF8ToWChar(const char *u8String)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
|
||||
/**
|
||||
* xmlIOErrMemory:
|
||||
* @extra: extra information
|
||||
|
@ -222,6 +216,7 @@ xmlIOErrMemory(const char *extra)
|
|||
{
|
||||
__xmlSimpleError(XML_FROM_IO, XML_ERR_NO_MEMORY, NULL, NULL, extra);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* __xmlIOErr:
|
||||
|
@ -1447,23 +1442,11 @@ append_reverse_ulong( xmlZMemBuff * buff, unsigned long data ) {
|
|||
static void
|
||||
xmlFreeZMemBuff( xmlZMemBuffPtr buff ) {
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
int z_err;
|
||||
#endif
|
||||
|
||||
if ( buff == NULL )
|
||||
return;
|
||||
|
||||
xmlFree( buff->zbuff );
|
||||
#ifdef DEBUG_HTTP
|
||||
z_err = deflateEnd( &buff->zctrl );
|
||||
if ( z_err != Z_OK )
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"xmlFreeZMemBuff: Error releasing zlib context: %d\n",
|
||||
z_err );
|
||||
#else
|
||||
deflateEnd( &buff->zctrl );
|
||||
#endif
|
||||
|
||||
xmlFree( buff );
|
||||
return;
|
||||
|
@ -1561,15 +1544,6 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
|
|||
cur_used = buff->zctrl.next_out - buff->zbuff;
|
||||
new_size = buff->size + ext_amt;
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
if ( cur_used > new_size )
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"xmlZMemBuffExtend: %s\n%s %d bytes.\n",
|
||||
"Buffer overwrite detected during compressed memory",
|
||||
"buffer extension. Overflowed by",
|
||||
(cur_used - new_size ) );
|
||||
#endif
|
||||
|
||||
tmp_ptr = xmlRealloc( buff->zbuff, new_size );
|
||||
if ( tmp_ptr != NULL ) {
|
||||
rc = 0;
|
||||
|
@ -1990,57 +1964,6 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
|
|||
content_lgth );
|
||||
|
||||
if ( http_ctxt != NULL ) {
|
||||
#ifdef DEBUG_HTTP
|
||||
/* If testing/debugging - dump reply with request content */
|
||||
|
||||
FILE * tst_file = NULL;
|
||||
char buffer[ 4096 ];
|
||||
char * dump_name = NULL;
|
||||
int avail;
|
||||
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"xmlNanoHTTPCloseWrite: HTTP %s to\n%s returned %d.\n",
|
||||
http_mthd, ctxt->uri,
|
||||
xmlNanoHTTPReturnCode( http_ctxt ) );
|
||||
|
||||
/*
|
||||
** Since either content or reply may be gzipped,
|
||||
** dump them to separate files instead of the
|
||||
** standard error context.
|
||||
*/
|
||||
|
||||
dump_name = tempnam( NULL, "lxml" );
|
||||
if ( dump_name != NULL ) {
|
||||
(void)snprintf( buffer, sizeof(buffer), "%s.content", dump_name );
|
||||
|
||||
tst_file = fopen( buffer, "wb" );
|
||||
if ( tst_file != NULL ) {
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"Transmitted content saved in file: %s\n", buffer );
|
||||
|
||||
fwrite( http_content, 1, content_lgth, tst_file );
|
||||
fclose( tst_file );
|
||||
}
|
||||
|
||||
(void)snprintf( buffer, sizeof(buffer), "%s.reply", dump_name );
|
||||
tst_file = fopen( buffer, "wb" );
|
||||
if ( tst_file != NULL ) {
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"Reply content saved in file: %s\n", buffer );
|
||||
|
||||
|
||||
while ( (avail = xmlNanoHTTPRead( http_ctxt,
|
||||
buffer, sizeof( buffer ) )) > 0 ) {
|
||||
|
||||
fwrite( buffer, 1, avail, tst_file );
|
||||
}
|
||||
|
||||
fclose( tst_file );
|
||||
}
|
||||
|
||||
free( dump_name );
|
||||
}
|
||||
#endif /* DEBUG_HTTP */
|
||||
|
||||
http_rtn = xmlNanoHTTPReturnCode( http_ctxt );
|
||||
if ( ( http_rtn >= 200 ) && ( http_rtn < 300 ) )
|
||||
|
@ -2325,7 +2248,6 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
|
|||
|
||||
ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
|
||||
if (ret == NULL) {
|
||||
xmlIOErrMemory("creating input buffer");
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlParserInputBuffer));
|
||||
|
@ -2364,7 +2286,6 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
|||
|
||||
ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||
if (ret == NULL) {
|
||||
xmlIOErrMemory("creating output buffer");
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlOutputBuffer));
|
||||
|
@ -2412,7 +2333,6 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
|
|||
|
||||
ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||
if (ret == NULL) {
|
||||
xmlIOErrMemory("creating output buffer");
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlOutputBuffer));
|
||||
|
@ -2910,38 +2830,78 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) {
|
|||
return(ret);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char *mem;
|
||||
const char *cur;
|
||||
size_t size;
|
||||
} xmlMemIOCtxt;
|
||||
|
||||
static int
|
||||
xmlMemRead(void *vctxt, char *buf, int size) {
|
||||
xmlMemIOCtxt *ctxt = vctxt;
|
||||
|
||||
if ((size_t) size > ctxt->size)
|
||||
size = ctxt->size;
|
||||
|
||||
memcpy(buf, ctxt->cur, size);
|
||||
ctxt->cur += size;
|
||||
ctxt->size -= size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
xmlMemClose(void *vctxt) {
|
||||
xmlMemIOCtxt *ctxt = vctxt;
|
||||
|
||||
if (ctxt->mem != 0)
|
||||
xmlFree(ctxt->mem);
|
||||
xmlFree(ctxt);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateMem:
|
||||
* @mem: the memory input
|
||||
* @size: the length of the memory block
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* Create a buffered parser input for the progressive parsing for the input
|
||||
* from a memory area.
|
||||
* Create a parser input buffer for parsing from a memory area.
|
||||
*
|
||||
* Returns the new parser input or NULL
|
||||
* This function makes a copy of the whole input buffer. If you are sure
|
||||
* that the contents of the buffer will remain valid until the document
|
||||
* was parsed, you can avoid the copy by using
|
||||
* xmlParserInputBufferCreateStatic.
|
||||
*
|
||||
* The encoding argument is deprecated and should be set to
|
||||
* XML_CHAR_ENCODING_NONE. The encoding can be changed with
|
||||
* xmlSwitchEncoding or xmlSwitchEncodingName later on.
|
||||
*
|
||||
* Returns the new parser input or NULL in case of error.
|
||||
*/
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
|
||||
xmlParserInputBufferPtr ret;
|
||||
int errcode;
|
||||
xmlParserInputBufferPtr buf;
|
||||
xmlMemIOCtxt *ctxt;
|
||||
char *copy;
|
||||
|
||||
if (size < 0) return(NULL);
|
||||
if (mem == NULL) return(NULL);
|
||||
if ((size < 0) || (mem == NULL))
|
||||
return(NULL);
|
||||
|
||||
ret = xmlAllocParserInputBuffer(enc);
|
||||
if (ret != NULL) {
|
||||
ret->context = (void *) mem;
|
||||
ret->readcallback = NULL;
|
||||
ret->closecallback = NULL;
|
||||
errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size);
|
||||
if (errcode != 0) {
|
||||
xmlFreeParserInputBuffer(ret);
|
||||
return(NULL);
|
||||
}
|
||||
copy = (char *) xmlStrndup((const xmlChar *) mem, size);
|
||||
if (copy == NULL)
|
||||
return(NULL);
|
||||
|
||||
buf = xmlParserInputBufferCreateStatic(copy, size, enc);
|
||||
if (buf == NULL) {
|
||||
xmlFree(copy);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
ctxt = buf->context;
|
||||
ctxt->mem = copy;
|
||||
|
||||
return(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2950,14 +2910,104 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
|
|||
* @size: the length of the memory block
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* DEPRECATED: Use xmlParserInputBufferCreateMem.
|
||||
* Create a parser input buffer for parsing from a memory area.
|
||||
*
|
||||
* Returns the new parser input or NULL
|
||||
* This functions assumes that the contents of the input buffer remain
|
||||
* valid until the document was parsed. Use xmlParserInputBufferCreateMem
|
||||
* otherwise.
|
||||
*
|
||||
* The encoding argument is deprecated and should be set to
|
||||
* XML_CHAR_ENCODING_NONE. The encoding can be changed with
|
||||
* xmlSwitchEncoding or xmlSwitchEncodingName later on.
|
||||
*
|
||||
* Returns the new parser input or NULL in case of error.
|
||||
*/
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateStatic(const char *mem, int size,
|
||||
xmlCharEncoding enc) {
|
||||
return(xmlParserInputBufferCreateMem(mem, size, enc));
|
||||
xmlParserInputBufferPtr ret;
|
||||
xmlMemIOCtxt *ctxt;
|
||||
|
||||
if ((size < 0) || (mem == NULL))
|
||||
return(NULL);
|
||||
|
||||
ret = xmlAllocParserInputBuffer(enc);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
|
||||
ctxt = xmlMalloc(sizeof(*ctxt));
|
||||
if (ctxt == NULL) {
|
||||
xmlFreeParserInputBuffer(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->mem = NULL;
|
||||
ctxt->cur = mem;
|
||||
ctxt->size = size;
|
||||
|
||||
ret->context = ctxt;
|
||||
ret->readcallback = xmlMemRead;
|
||||
ret->closecallback = xmlMemClose;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const xmlChar *str;
|
||||
} xmlStringIOCtxt;
|
||||
|
||||
static int
|
||||
xmlStringRead(void *vctxt, char *buf, int size) {
|
||||
xmlStringIOCtxt *ctxt = vctxt;
|
||||
const xmlChar *zero;
|
||||
size_t len;
|
||||
|
||||
zero = memchr(ctxt->str, 0, size);
|
||||
len = zero ? zero - ctxt->str : size;
|
||||
|
||||
memcpy(buf, ctxt->str, len);
|
||||
ctxt->str += len;
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
static int
|
||||
xmlStringClose(void *vctxt) {
|
||||
xmlFree(vctxt);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateString:
|
||||
* @str: a null-terminated string
|
||||
*
|
||||
* Create a buffered parser input for the progressive parsing for the input
|
||||
* from a null-terminated C string.
|
||||
*
|
||||
* Returns the new parser input or NULL
|
||||
*/
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateString(const xmlChar *str) {
|
||||
xmlParserInputBufferPtr ret;
|
||||
xmlStringIOCtxt *ctxt;
|
||||
|
||||
if (str == NULL) return(NULL);
|
||||
|
||||
ret = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
|
||||
ctxt = xmlMalloc(sizeof(*ctxt));
|
||||
if (ctxt == NULL) {
|
||||
xmlFreeParserInputBuffer(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->str = str;
|
||||
|
||||
ret->context = ctxt;
|
||||
ret->readcallback = xmlStringRead;
|
||||
ret->closecallback = xmlStringClose;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
|
@ -3112,45 +3162,36 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
|
|||
if (len < 0) return(0);
|
||||
if ((in == NULL) || (in->error)) return(-1);
|
||||
if (in->encoder != NULL) {
|
||||
size_t use, consumed;
|
||||
|
||||
/*
|
||||
* Store the data in the incoming raw buffer
|
||||
*/
|
||||
if (in->raw == NULL) {
|
||||
in->raw = xmlBufCreate();
|
||||
if (in->raw == NULL) {
|
||||
in->error = XML_ERR_NO_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
in->error = XML_ERR_NO_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* convert as much as possible to the parser reading buffer.
|
||||
*/
|
||||
use = xmlBufUse(in->raw);
|
||||
nbchars = xmlCharEncInput(in, 1);
|
||||
if (nbchars < 0) {
|
||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||
in->error = XML_IO_ENCODER;
|
||||
nbchars = xmlCharEncInput(in);
|
||||
if (nbchars < 0)
|
||||
return(-1);
|
||||
}
|
||||
consumed = use - xmlBufUse(in->raw);
|
||||
if ((consumed > ULONG_MAX) ||
|
||||
(in->rawconsumed > ULONG_MAX - (unsigned long)consumed))
|
||||
in->rawconsumed = ULONG_MAX;
|
||||
else
|
||||
in->rawconsumed += consumed;
|
||||
} else {
|
||||
nbchars = len;
|
||||
ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
in->error = XML_ERR_NO_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: pushed %d chars, buffer %d/%d\n",
|
||||
nbchars, xmlBufUse(in->buffer), xmlBufLength(in->buffer));
|
||||
#endif
|
||||
return(nbchars);
|
||||
}
|
||||
|
||||
|
@ -3207,7 +3248,6 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||
*/
|
||||
if (in->readcallback != NULL) {
|
||||
if (xmlBufGrow(buf, len + 1) < 0) {
|
||||
xmlIOErrMemory("growing input buffer");
|
||||
in->error = XML_ERR_NO_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
|
@ -3215,11 +3255,15 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||
res = in->readcallback(in->context, (char *)xmlBufEnd(buf), len);
|
||||
if (res <= 0)
|
||||
in->readcallback = endOfInput;
|
||||
if (res < 0)
|
||||
if (res < 0) {
|
||||
in->error = XML_IO_UNKNOWN;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (xmlBufAddLen(buf, res) < 0)
|
||||
if (xmlBufAddLen(buf, res) < 0) {
|
||||
in->error = XML_ERR_NO_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3233,30 +3277,10 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||
}
|
||||
|
||||
if (in->encoder != NULL) {
|
||||
size_t use, consumed;
|
||||
|
||||
/*
|
||||
* convert as much as possible to the parser reading buffer.
|
||||
*/
|
||||
use = xmlBufUse(buf);
|
||||
res = xmlCharEncInput(in, 1);
|
||||
if (res < 0) {
|
||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||
in->error = XML_IO_ENCODER;
|
||||
res = xmlCharEncInput(in);
|
||||
if (res < 0)
|
||||
return(-1);
|
||||
}
|
||||
consumed = use - xmlBufUse(buf);
|
||||
if ((consumed > ULONG_MAX) ||
|
||||
(in->rawconsumed > ULONG_MAX - (unsigned long)consumed))
|
||||
in->rawconsumed = ULONG_MAX;
|
||||
else
|
||||
in->rawconsumed += consumed;
|
||||
}
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: read %d chars, buffer %d\n",
|
||||
nbchars, xmlBufUse(in->buffer));
|
||||
#endif
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
@ -3382,10 +3406,6 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
|
|||
} while (len > 0);
|
||||
|
||||
done:
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: wrote %d chars\n", written);
|
||||
#endif
|
||||
return(written);
|
||||
}
|
||||
|
||||
|
@ -3582,10 +3602,6 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
|||
} while ((len > 0) && (oldwritten != written));
|
||||
|
||||
done:
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: wrote %d chars\n", written);
|
||||
#endif
|
||||
return(written);
|
||||
}
|
||||
|
||||
|
@ -3673,10 +3689,6 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
|
|||
else
|
||||
out->written += ret;
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: flushed %d chars\n", ret);
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
@ -3786,8 +3798,6 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
|
|||
"Unknown encoding %s",
|
||||
BAD_CAST encoding, NULL);
|
||||
}
|
||||
if (ret->encoding == NULL)
|
||||
ret->encoding = xmlStrdup(BAD_CAST encoding);
|
||||
}
|
||||
#if 0
|
||||
} else if (xmlStrstr(BAD_CAST mime, BAD_CAST "html")) {
|
||||
|
@ -3929,10 +3939,6 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
|
|||
xmlParserInputPtr ret = NULL;
|
||||
xmlChar *resource = NULL;
|
||||
|
||||
#ifdef DEBUG_EXTERNAL_ENTITIES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
|
||||
#endif
|
||||
if ((ctxt != NULL) && (ctxt->options & XML_PARSE_NONET)) {
|
||||
int options = ctxt->options;
|
||||
|
||||
|
@ -4006,7 +4012,7 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
|
|||
|
||||
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
|
||||
if (canonicFilename == NULL) {
|
||||
xmlIOErrMemory("building canonical path\n");
|
||||
xmlErrMemory(ctxt, "building canonical path\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -4061,4 +4067,3 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
|
|||
xmlFree(resource);
|
||||
return(input);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
/* #define DEBUG_MEMORY */
|
||||
|
||||
/**
|
||||
* MEM_LIST:
|
||||
*
|
||||
|
@ -26,9 +24,9 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <libxml/globals.h> /* must come before xmlmemory.h */
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/threads.h>
|
||||
|
||||
#include "private/memory.h"
|
||||
|
@ -150,17 +148,12 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
|||
void *ret;
|
||||
|
||||
xmlInitParser();
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d)\n",size);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMallocLoc : Unsigned overflow\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -169,7 +162,6 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
|||
if (!p) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMallocLoc : Out of free space\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
p->mh_tag = MEMTAG;
|
||||
|
@ -187,11 +179,6 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
|||
#endif
|
||||
xmlMutexUnlock(&xmlMemMutex);
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d) Ok\n",size);
|
||||
#endif
|
||||
|
||||
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
||||
|
||||
ret = HDR_2_CLIENT(p);
|
||||
|
@ -226,17 +213,12 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
|||
void *ret;
|
||||
|
||||
xmlInitParser();
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d)\n",size);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMallocAtomicLoc : Unsigned overflow\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -245,7 +227,6 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
|||
if (!p) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMallocAtomicLoc : Out of free space\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
p->mh_tag = MEMTAG;
|
||||
|
@ -263,11 +244,6 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
|||
#endif
|
||||
xmlMutexUnlock(&xmlMemMutex);
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d) Ok\n",size);
|
||||
#endif
|
||||
|
||||
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
||||
|
||||
ret = HDR_2_CLIENT(p);
|
||||
|
@ -315,9 +291,6 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||
{
|
||||
MEMHDR *p, *tmp;
|
||||
unsigned long number;
|
||||
#ifdef DEBUG_MEMORY
|
||||
size_t oldsize;
|
||||
#endif
|
||||
|
||||
if (ptr == NULL)
|
||||
return(xmlMallocLoc(size, file, line));
|
||||
|
@ -336,9 +309,6 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||
xmlMutexLock(&xmlMemMutex);
|
||||
debugMemSize -= p->mh_size;
|
||||
debugMemBlocks--;
|
||||
#ifdef DEBUG_MEMORY
|
||||
oldsize = p->mh_size;
|
||||
#endif
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_delete(p);
|
||||
#endif
|
||||
|
@ -347,7 +317,6 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||
if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlReallocLoc : Unsigned overflow\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -381,10 +350,6 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||
|
||||
TEST_POINT
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Realloced(%d to %d) Ok\n", oldsize, size);
|
||||
#endif
|
||||
return(HDR_2_CLIENT(p));
|
||||
|
||||
error:
|
||||
|
@ -417,9 +382,6 @@ xmlMemFree(void *ptr)
|
|||
{
|
||||
MEMHDR *p;
|
||||
char *target;
|
||||
#ifdef DEBUG_MEMORY
|
||||
size_t size;
|
||||
#endif
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
@ -451,9 +413,6 @@ xmlMemFree(void *ptr)
|
|||
xmlMutexLock(&xmlMemMutex);
|
||||
debugMemSize -= p->mh_size;
|
||||
debugMemBlocks--;
|
||||
#ifdef DEBUG_MEMORY
|
||||
size = p->mh_size;
|
||||
#endif
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_delete(p);
|
||||
#endif
|
||||
|
@ -463,11 +422,6 @@ xmlMemFree(void *ptr)
|
|||
|
||||
TEST_POINT
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Freed(%d) Ok\n", size);
|
||||
#endif
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
|
@ -501,7 +455,6 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
|
|||
if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMemStrdupLoc : Unsigned overflow\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -759,10 +712,6 @@ static void debugmem_list_add(MEMHDR *p)
|
|||
p->mh_prev = NULL;
|
||||
if (memlist) memlist->mh_prev = p;
|
||||
memlist = p;
|
||||
#ifdef MEM_LIST_DEBUG
|
||||
if (stderr)
|
||||
Mem_Display(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void debugmem_list_delete(MEMHDR *p)
|
||||
|
@ -772,10 +721,6 @@ static void debugmem_list_delete(MEMHDR *p)
|
|||
if (p->mh_prev)
|
||||
p->mh_prev->mh_next = p->mh_next;
|
||||
else memlist = p->mh_next;
|
||||
#ifdef MEM_LIST_DEBUG
|
||||
if (stderr)
|
||||
Mem_Display(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -900,10 +845,6 @@ xmlInitMemory(void) {
|
|||
void
|
||||
xmlInitMemoryInternal(void) {
|
||||
char *breakpoint;
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlInitMemory()\n");
|
||||
#endif
|
||||
xmlInitMutex(&xmlMemMutex);
|
||||
|
||||
breakpoint = getenv("XML_MEM_BREAKPOINT");
|
||||
|
@ -915,10 +856,6 @@ xmlInitMemoryInternal(void) {
|
|||
sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlInitMemory() Ok\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -941,15 +878,15 @@ xmlCleanupMemory(void) {
|
|||
*/
|
||||
void
|
||||
xmlCleanupMemoryInternal(void) {
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlCleanupMemory()\n");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Don't clean up mutex on Windows. Global state destructors can call
|
||||
* malloc functions after xmlCleanupParser was called. If memory
|
||||
* debugging is enabled, xmlMemMutex can be used after cleanup.
|
||||
*
|
||||
* See python/tests/thread2.py
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED) || !defined(_WIN32)
|
||||
xmlCleanupMutex(&xmlMemMutex);
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlCleanupMemory() Ok\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -971,10 +908,6 @@ xmlCleanupMemoryInternal(void) {
|
|||
int
|
||||
xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
||||
xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) {
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMemSetup()\n");
|
||||
#endif
|
||||
if (freeFunc == NULL)
|
||||
return(-1);
|
||||
if (mallocFunc == NULL)
|
||||
|
@ -988,10 +921,6 @@ xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
|||
xmlMallocAtomic = mallocFunc;
|
||||
xmlRealloc = reallocFunc;
|
||||
xmlMemStrdup = strdupFunc;
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMemSetup() Ok\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1038,10 +967,6 @@ int
|
|||
xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
||||
xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc,
|
||||
xmlStrdupFunc strdupFunc) {
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGcMemSetup()\n");
|
||||
#endif
|
||||
if (freeFunc == NULL)
|
||||
return(-1);
|
||||
if (mallocFunc == NULL)
|
||||
|
@ -1057,10 +982,6 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
|||
xmlMallocAtomic = mallocAtomicFunc;
|
||||
xmlRealloc = reallocFunc;
|
||||
xmlMemStrdup = strdupFunc;
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGcMemSetup() Ok\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1089,4 +1010,3 @@ xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
|
|||
if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#endif
|
||||
|
||||
#include "private/buf.h"
|
||||
#include "private/parser.h"
|
||||
#include "private/tree.h"
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include "private/xinclude.h"
|
||||
|
@ -77,9 +78,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_CALLBACKS */
|
||||
/* #define DEBUG_READER */
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
*
|
||||
|
@ -90,12 +88,6 @@
|
|||
"Unimplemented block at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
#ifdef DEBUG_READER
|
||||
#define DUMP_READER xmlTextReaderDebug(reader);
|
||||
#else
|
||||
#define DUMP_READER
|
||||
#endif
|
||||
|
||||
#define CHUNK_SIZE 512
|
||||
/************************************************************************
|
||||
* *
|
||||
|
@ -505,33 +497,6 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
|
|||
* The reader core parser *
|
||||
* *
|
||||
************************************************************************/
|
||||
#ifdef DEBUG_READER
|
||||
static void
|
||||
xmlTextReaderDebug(xmlTextReaderPtr reader) {
|
||||
if ((reader == NULL) || (reader->ctxt == NULL)) {
|
||||
fprintf(stderr, "xmlTextReader NULL\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "xmlTextReader: state %d depth %d ",
|
||||
reader->state, reader->depth);
|
||||
if (reader->node == NULL) {
|
||||
fprintf(stderr, "node = NULL\n");
|
||||
} else {
|
||||
fprintf(stderr, "node %s\n", reader->node->name);
|
||||
}
|
||||
fprintf(stderr, " input: base %d, cur %d, depth %d: ",
|
||||
reader->base, reader->cur, reader->ctxt->nodeNr);
|
||||
if (reader->input->buffer == NULL) {
|
||||
fprintf(stderr, "buffer is NULL\n");
|
||||
} else {
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
xmlDebugDumpString(stderr,
|
||||
&reader->input->buffer->content[reader->cur]);
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlTextReaderEntPush:
|
||||
|
@ -602,9 +567,6 @@ xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderStartElement(%s)\n", fullname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->startElement != NULL)) {
|
||||
reader->startElement(ctx, fullname, atts);
|
||||
if ((ctxt->node != NULL) && (ctxt->input != NULL) &&
|
||||
|
@ -628,9 +590,6 @@ xmlTextReaderEndElement(void *ctx, const xmlChar *fullname) {
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderEndElement(%s)\n", fullname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->endElement != NULL)) {
|
||||
reader->endElement(ctx, fullname);
|
||||
}
|
||||
|
@ -665,9 +624,6 @@ xmlTextReaderStartElementNs(void *ctx,
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderStartElementNs(%s)\n", localname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->startElementNs != NULL)) {
|
||||
reader->startElementNs(ctx, localname, prefix, URI, nb_namespaces,
|
||||
namespaces, nb_attributes, nb_defaulted,
|
||||
|
@ -699,9 +655,6 @@ xmlTextReaderEndElementNs(void *ctx,
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderEndElementNs(%s)\n", localname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->endElementNs != NULL)) {
|
||||
reader->endElementNs(ctx, localname, prefix, URI);
|
||||
}
|
||||
|
@ -722,9 +675,6 @@ xmlTextReaderCharacters(void *ctx, const xmlChar *ch, int len)
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderCharacters()\n");
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->characters != NULL)) {
|
||||
reader->characters(ctx, ch, len);
|
||||
}
|
||||
|
@ -744,9 +694,6 @@ xmlTextReaderCDataBlock(void *ctx, const xmlChar *ch, int len)
|
|||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderCDataBlock()\n");
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->cdataBlock != NULL)) {
|
||||
reader->cdataBlock(ctx, ch, len);
|
||||
}
|
||||
|
@ -781,22 +728,17 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
|||
*/
|
||||
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
|
||||
val = xmlParserInputBufferRead(reader->input, 4096);
|
||||
if ((val == 0) &&
|
||||
(reader->input->readcallback == NULL)) {
|
||||
if (val == 0) {
|
||||
if (xmlBufUse(inbuf) == reader->cur) {
|
||||
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||
reader->state = oldstate;
|
||||
break;
|
||||
}
|
||||
} else if (val < 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlParserInputBufferRead failed\n");
|
||||
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||
reader->state = oldstate;
|
||||
if ((oldstate != XML_TEXTREADER_START) ||
|
||||
(reader->ctxt->myDoc != NULL))
|
||||
return(val);
|
||||
} else if (val == 0) {
|
||||
/* mark the end of the stream and process the remains */
|
||||
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||
break;
|
||||
return(val);
|
||||
}
|
||||
|
||||
} else
|
||||
|
@ -826,6 +768,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
reader->state = oldstate;
|
||||
|
||||
/*
|
||||
* Discard the consumed input when needed and possible
|
||||
|
@ -862,7 +805,6 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
|||
}
|
||||
}
|
||||
}
|
||||
reader->state = oldstate;
|
||||
if (reader->ctxt->wellFormed == 0) {
|
||||
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||
return(-1);
|
||||
|
@ -1230,10 +1172,6 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
|
|||
if (reader->ctxt == NULL)
|
||||
return(-1);
|
||||
|
||||
#ifdef DEBUG_READER
|
||||
fprintf(stderr, "\nREAD ");
|
||||
DUMP_READER
|
||||
#endif
|
||||
if (reader->mode == XML_TEXTREADER_MODE_INITIAL) {
|
||||
reader->mode = XML_TEXTREADER_MODE_INTERACTIVE;
|
||||
/*
|
||||
|
@ -1425,8 +1363,6 @@ get_next_node:
|
|||
reader->state = XML_TEXTREADER_BACKTRACK;
|
||||
|
||||
node_found:
|
||||
DUMP_READER
|
||||
|
||||
/*
|
||||
* If we are in the middle of a piece of CDATA make sure it's finished
|
||||
*/
|
||||
|
@ -2860,20 +2796,17 @@ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader) {
|
|||
*/
|
||||
const xmlChar *
|
||||
xmlTextReaderConstEncoding(xmlTextReaderPtr reader) {
|
||||
xmlDocPtr doc = NULL;
|
||||
if (reader == NULL)
|
||||
return(NULL);
|
||||
if (reader->doc != NULL)
|
||||
doc = reader->doc;
|
||||
else if (reader->ctxt != NULL)
|
||||
doc = reader->ctxt->myDoc;
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
const xmlChar *encoding = NULL;
|
||||
|
||||
if (doc->encoding == NULL)
|
||||
return(NULL);
|
||||
else
|
||||
return(CONSTSTR(doc->encoding));
|
||||
if (reader == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (reader->ctxt != NULL)
|
||||
encoding = xmlGetActualEncoding(reader->ctxt);
|
||||
else if (reader->doc != NULL)
|
||||
encoding = reader->doc->encoding;
|
||||
|
||||
return(CONSTSTR(encoding));
|
||||
}
|
||||
|
||||
|
||||
|
@ -4039,10 +3972,10 @@ xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
|
|||
}
|
||||
|
||||
static void
|
||||
xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
|
||||
xmlTextReaderStructuredError(void *ctxt, const xmlError *error);
|
||||
|
||||
static void
|
||||
xmlTextReaderValidityStructuredRelay(void *userData, xmlErrorPtr error)
|
||||
xmlTextReaderValidityStructuredRelay(void *userData, const xmlError *error)
|
||||
{
|
||||
xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
|
||||
|
||||
|
@ -4773,7 +4706,7 @@ xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity,
|
|||
}
|
||||
|
||||
static void
|
||||
xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
|
||||
xmlTextReaderStructuredError(void *ctxt, const xmlError *error)
|
||||
{
|
||||
xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
|
||||
|
||||
|
@ -5236,6 +5169,19 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
|||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderSetMaxAmplification:
|
||||
* @reader: an XML reader
|
||||
* @maxAmpl: maximum amplification factor
|
||||
*
|
||||
* Set the maximum amplification factor. See xmlCtxtSetMaxAmplification.
|
||||
*/
|
||||
void
|
||||
xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, unsigned maxAmpl)
|
||||
{
|
||||
xmlCtxtSetMaxAmplification(reader->ctxt, maxAmpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderByteConsumed:
|
||||
* @reader: an XML reader
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1391,13 +1391,14 @@ xhtmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
|
|||
static void
|
||||
xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
||||
int format = ctxt->format, addmeta;
|
||||
xmlNodePtr tmp, root, unformattedNode = NULL;
|
||||
xmlNodePtr tmp, root, unformattedNode = NULL, parent;
|
||||
xmlChar *start, *end;
|
||||
xmlOutputBufferPtr buf = ctxt->buf;
|
||||
|
||||
if (cur == NULL) return;
|
||||
|
||||
root = cur;
|
||||
parent = cur->parent;
|
||||
while (1) {
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
|
@ -1414,7 +1415,9 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
break;
|
||||
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
if (cur->children) {
|
||||
/* Always validate cur->parent when descending. */
|
||||
if ((cur->parent == parent) && (cur->children != NULL)) {
|
||||
parent = cur;
|
||||
cur = cur->children;
|
||||
continue;
|
||||
}
|
||||
|
@ -1441,6 +1444,16 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
ctxt->indent_nr : ctxt->level),
|
||||
ctxt->indent);
|
||||
|
||||
/*
|
||||
* Some users like lxml are known to pass nodes with a corrupted
|
||||
* tree structure. Fall back to a recursive call to handle this
|
||||
* case.
|
||||
*/
|
||||
if ((cur->parent != parent) && (cur->children != NULL)) {
|
||||
xhtmlNodeDumpOutput(ctxt, cur);
|
||||
break;
|
||||
}
|
||||
|
||||
xmlOutputBufferWrite(buf, 1, "<");
|
||||
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
|
||||
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
|
||||
|
@ -1461,10 +1474,10 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
if (cur->properties != NULL)
|
||||
xhtmlAttrListDumpOutput(ctxt, cur->properties);
|
||||
|
||||
if ((cur->parent != NULL) &&
|
||||
(cur->parent->parent == (xmlNodePtr) cur->doc) &&
|
||||
if ((parent != NULL) &&
|
||||
(parent->parent == (xmlNodePtr) cur->doc) &&
|
||||
xmlStrEqual(cur->name, BAD_CAST"head") &&
|
||||
xmlStrEqual(cur->parent->name, BAD_CAST"html")) {
|
||||
xmlStrEqual(parent->name, BAD_CAST"html")) {
|
||||
|
||||
tmp = cur->children;
|
||||
while (tmp != NULL) {
|
||||
|
@ -1570,6 +1583,7 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
|
||||
if (ctxt->format == 1) xmlOutputBufferWrite(buf, 1, "\n");
|
||||
if (ctxt->level >= 0) ctxt->level++;
|
||||
parent = cur;
|
||||
cur = cur->children;
|
||||
continue;
|
||||
}
|
||||
|
@ -1664,13 +1678,9 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* The parent should never be NULL here but we want to handle
|
||||
* corrupted documents gracefully.
|
||||
*/
|
||||
if (cur->parent == NULL)
|
||||
return;
|
||||
cur = cur->parent;
|
||||
cur = parent;
|
||||
/* cur->parent was validated when descending. */
|
||||
parent = cur->parent;
|
||||
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
if (ctxt->level > 0) ctxt->level--;
|
||||
|
@ -1847,7 +1857,7 @@ xmlSaveDoc(xmlSaveCtxtPtr ctxt, xmlDocPtr doc)
|
|||
/**
|
||||
* xmlSaveTree:
|
||||
* @ctxt: a document saving context
|
||||
* @node: the top node of the subtree to save
|
||||
* @cur: the top node of the subtree to save
|
||||
*
|
||||
* Save a subtree starting at the node parameter to a saving context
|
||||
* TODO: The function is not fully implemented yet as it does not return the
|
||||
|
@ -2166,17 +2176,9 @@ xmlBufNodeDump(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
|||
xmlInitParser();
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeDump : node == NULL\n");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeDump : buf == NULL\n");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||
|
@ -2218,18 +2220,8 @@ xmlElemDump(FILE * f, xmlDocPtr doc, xmlNodePtr cur)
|
|||
xmlInitParser();
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlElemDump : cur == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_TREE
|
||||
if (doc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlElemDump : doc == NULL\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
outbuf = xmlOutputBufferCreateFile(f, NULL);
|
||||
if (outbuf == NULL)
|
||||
|
@ -2274,6 +2266,8 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
|||
int is_xhtml = 0;
|
||||
#endif
|
||||
|
||||
(void) doc;
|
||||
|
||||
xmlInitParser();
|
||||
|
||||
if ((buf == NULL) || (cur == NULL)) return;
|
||||
|
@ -2467,10 +2461,6 @@ xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) {
|
|||
int ret;
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlDocDump : document == NULL\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
encoding = (const char *) cur->encoding;
|
||||
|
@ -2692,4 +2682,3 @@ xmlSaveFile(const char *filename, xmlDocPtr cur) {
|
|||
}
|
||||
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
|
|
|
@ -79,28 +79,8 @@
|
|||
#include "private/error.h"
|
||||
#include "private/string.h"
|
||||
|
||||
/* #define DEBUG 1 */
|
||||
|
||||
/* #define DEBUG_CONTENT 1 */
|
||||
|
||||
/* #define DEBUG_TYPE 1 */
|
||||
|
||||
/* #define DEBUG_CONTENT_REGEXP 1 */
|
||||
|
||||
/* #define DEBUG_AUTOMATA 1 */
|
||||
|
||||
/* #define DEBUG_IDC */
|
||||
|
||||
/* #define DEBUG_IDC_NODE_TABLE */
|
||||
|
||||
/* #define WXS_ELEM_DECL_CONS_ENABLED */
|
||||
|
||||
#ifdef DEBUG_IDC
|
||||
#ifndef DEBUG_IDC_NODE_TABLE
|
||||
#define DEBUG_IDC_NODE_TABLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define ENABLE_PARTICLE_RESTRICTION 1 */
|
||||
|
||||
#define ENABLE_REDEFINE
|
||||
|
@ -2143,8 +2123,14 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
|
|||
(vctxt->parserCtxt != NULL) &&
|
||||
(vctxt->parserCtxt->input != NULL)) {
|
||||
file = vctxt->parserCtxt->input->filename;
|
||||
line = vctxt->parserCtxt->input->line;
|
||||
col = vctxt->parserCtxt->input->col;
|
||||
if (vctxt->inode != NULL) {
|
||||
line = vctxt->inode->nodeLine;
|
||||
col = 0;
|
||||
} else {
|
||||
/* This is inaccurate. */
|
||||
line = vctxt->parserCtxt->input->line;
|
||||
col = vctxt->parserCtxt->input->col;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
@ -3803,6 +3789,8 @@ xmlSchemaFreeNotation(xmlSchemaNotationPtr nota)
|
|||
{
|
||||
if (nota == NULL)
|
||||
return;
|
||||
if (nota->annot != NULL)
|
||||
xmlSchemaFreeAnnot(nota->annot);
|
||||
xmlFree(nota);
|
||||
}
|
||||
|
||||
|
@ -4612,83 +4600,6 @@ xmlSchemaDump(FILE * output, xmlSchemaPtr schema)
|
|||
xmlHashScanFull(schema->elemDecl, xmlSchemaElementDump, output);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_IDC_NODE_TABLE
|
||||
/**
|
||||
* xmlSchemaDebugDumpIDCTable:
|
||||
* @vctxt: the WXS validation context
|
||||
*
|
||||
* Displays the current IDC table for debug purposes.
|
||||
*/
|
||||
static void
|
||||
xmlSchemaDebugDumpIDCTable(FILE * output,
|
||||
const xmlChar *namespaceName,
|
||||
const xmlChar *localName,
|
||||
xmlSchemaPSVIIDCBindingPtr bind)
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
const xmlChar *value;
|
||||
xmlSchemaPSVIIDCNodePtr tab;
|
||||
xmlSchemaPSVIIDCKeyPtr key;
|
||||
int i, j, res;
|
||||
|
||||
fprintf(output, "IDC: TABLES on '%s'\n",
|
||||
xmlSchemaFormatQName(&str, namespaceName, localName));
|
||||
FREE_AND_NULL(str)
|
||||
|
||||
if (bind == NULL)
|
||||
return;
|
||||
do {
|
||||
fprintf(output, "IDC: BINDING '%s' (%d)\n",
|
||||
xmlSchemaGetComponentQName(&str,
|
||||
bind->definition), bind->nbNodes);
|
||||
FREE_AND_NULL(str)
|
||||
for (i = 0; i < bind->nbNodes; i++) {
|
||||
tab = bind->nodeTable[i];
|
||||
fprintf(output, " ( ");
|
||||
for (j = 0; j < bind->definition->nbFields; j++) {
|
||||
key = tab->keys[j];
|
||||
if ((key != NULL) && (key->val != NULL)) {
|
||||
res = xmlSchemaGetCanonValue(key->val, &value);
|
||||
if (res >= 0)
|
||||
fprintf(output, "'%s' ", value);
|
||||
else
|
||||
fprintf(output, "CANON-VALUE-FAILED ");
|
||||
if (res == 0)
|
||||
FREE_AND_NULL(value)
|
||||
} else if (key != NULL)
|
||||
fprintf(output, "(no val), ");
|
||||
else
|
||||
fprintf(output, "(key missing), ");
|
||||
}
|
||||
fprintf(output, ")\n");
|
||||
}
|
||||
if (bind->dupls && bind->dupls->nbItems) {
|
||||
fprintf(output, "IDC: dupls (%d):\n", bind->dupls->nbItems);
|
||||
for (i = 0; i < bind->dupls->nbItems; i++) {
|
||||
tab = bind->dupls->items[i];
|
||||
fprintf(output, " ( ");
|
||||
for (j = 0; j < bind->definition->nbFields; j++) {
|
||||
key = tab->keys[j];
|
||||
if ((key != NULL) && (key->val != NULL)) {
|
||||
res = xmlSchemaGetCanonValue(key->val, &value);
|
||||
if (res >= 0)
|
||||
fprintf(output, "'%s' ", value);
|
||||
else
|
||||
fprintf(output, "CANON-VALUE-FAILED ");
|
||||
if (res == 0)
|
||||
FREE_AND_NULL(value)
|
||||
} else if (key != NULL)
|
||||
fprintf(output, "(no val), ");
|
||||
else
|
||||
fprintf(output, "(key missing), ");
|
||||
}
|
||||
fprintf(output, ")\n");
|
||||
}
|
||||
}
|
||||
bind = bind->next;
|
||||
} while (bind != NULL);
|
||||
}
|
||||
#endif /* DEBUG_IDC */
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/************************************************************************
|
||||
|
@ -4844,15 +4755,6 @@ xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name,
|
|||
WXS_FIND_GLOBAL_ITEM(elemDecl)
|
||||
}
|
||||
exit:
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (nsName == NULL)
|
||||
fprintf(stderr, "Unable to lookup element decl. %s", name);
|
||||
else
|
||||
fprintf(stderr, "Unable to lookup element decl. %s:%s", name,
|
||||
nsName);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -4891,15 +4793,6 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name,
|
|||
}
|
||||
exit:
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (nsName == NULL)
|
||||
fprintf(stderr, "Unable to lookup type %s", name);
|
||||
else
|
||||
fprintf(stderr, "Unable to lookup type %s:%s", name,
|
||||
nsName);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -4925,15 +4818,6 @@ xmlSchemaGetAttributeDecl(xmlSchemaPtr schema, const xmlChar * name,
|
|||
WXS_FIND_GLOBAL_ITEM(attrDecl)
|
||||
}
|
||||
exit:
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (nsName == NULL)
|
||||
fprintf(stderr, "Unable to lookup attribute %s", name);
|
||||
else
|
||||
fprintf(stderr, "Unable to lookup attribute %s:%s", name,
|
||||
nsName);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -4965,15 +4849,6 @@ exit:
|
|||
ret = ret->redef;
|
||||
}
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (nsName == NULL)
|
||||
fprintf(stderr, "Unable to lookup attribute group %s", name);
|
||||
else
|
||||
fprintf(stderr, "Unable to lookup attribute group %s:%s", name,
|
||||
nsName);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -5000,15 +4875,6 @@ xmlSchemaGetGroup(xmlSchemaPtr schema, const xmlChar * name,
|
|||
}
|
||||
exit:
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (nsName == NULL)
|
||||
fprintf(stderr, "Unable to lookup group %s", name);
|
||||
else
|
||||
fprintf(stderr, "Unable to lookup group %s:%s", name,
|
||||
nsName);
|
||||
}
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
@ -5598,9 +5464,6 @@ xmlSchemaAddParticle(xmlSchemaParserCtxtPtr ctxt,
|
|||
if (ctxt == NULL)
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Adding particle component\n");
|
||||
#endif
|
||||
ret = (xmlSchemaParticlePtr)
|
||||
xmlMalloc(sizeof(xmlSchemaParticle));
|
||||
if (ret == NULL) {
|
||||
|
@ -10682,7 +10545,7 @@ doc_load:
|
|||
* TODO: (2.2) is not supported.
|
||||
*/
|
||||
if (doc == NULL) {
|
||||
xmlErrorPtr lerr;
|
||||
const xmlError *lerr;
|
||||
lerr = xmlGetLastError();
|
||||
/*
|
||||
* Check if this a parser error, or if the document could
|
||||
|
@ -13251,10 +13114,6 @@ xmlSchemaBuildContentModel(xmlSchemaTypePtr type,
|
|||
(type->contentType != XML_SCHEMA_CONTENT_MIXED)))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_CONTENT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Building content model for %s\n", name);
|
||||
#endif
|
||||
ctxt->am = NULL;
|
||||
ctxt->am = xmlNewAutomata();
|
||||
if (ctxt->am == NULL) {
|
||||
|
@ -13281,11 +13140,6 @@ xmlSchemaBuildContentModel(xmlSchemaTypePtr type,
|
|||
WXS_BASIC_CAST type, type->node,
|
||||
"The content model is not determinist", NULL);
|
||||
} else {
|
||||
#ifdef DEBUG_CONTENT_REGEXP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Content model of %s:\n", type->name);
|
||||
xmlRegexpPrint(stderr, type->contModel);
|
||||
#endif
|
||||
}
|
||||
ctxt->state = NULL;
|
||||
xmlFreeAutomata(ctxt->am);
|
||||
|
@ -18149,59 +18003,6 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt,
|
|||
return(0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_TYPE
|
||||
static void
|
||||
xmlSchemaDebugFixedType(xmlSchemaParserCtxtPtr pctxt,
|
||||
xmlSchemaTypePtr type)
|
||||
{
|
||||
if (type->node != NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Type of %s : %s:%d :", name,
|
||||
type->node->doc->URL,
|
||||
xmlGetLineNo(type->node));
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext, "Type of %s :", name);
|
||||
}
|
||||
if ((WXS_IS_SIMPLE(type)) || (WXS_IS_COMPLEX(type))) {
|
||||
switch (type->contentType) {
|
||||
case XML_SCHEMA_CONTENT_SIMPLE:
|
||||
xmlGenericError(xmlGenericErrorContext, "simple\n");
|
||||
break;
|
||||
case XML_SCHEMA_CONTENT_ELEMENTS:
|
||||
xmlGenericError(xmlGenericErrorContext, "elements\n");
|
||||
break;
|
||||
case XML_SCHEMA_CONTENT_UNKNOWN:
|
||||
xmlGenericError(xmlGenericErrorContext, "unknown !!!\n");
|
||||
break;
|
||||
case XML_SCHEMA_CONTENT_EMPTY:
|
||||
xmlGenericError(xmlGenericErrorContext, "empty\n");
|
||||
break;
|
||||
case XML_SCHEMA_CONTENT_MIXED:
|
||||
if (xmlSchemaIsParticleEmptiable((xmlSchemaParticlePtr)
|
||||
type->subtypes))
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"mixed as emptiable particle\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, "mixed\n");
|
||||
break;
|
||||
/* Removed, since not used. */
|
||||
/*
|
||||
case XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS:
|
||||
xmlGenericError(xmlGenericErrorContext, "mixed or elems\n");
|
||||
break;
|
||||
*/
|
||||
case XML_SCHEMA_CONTENT_BASIC:
|
||||
xmlGenericError(xmlGenericErrorContext, "basic\n");
|
||||
break;
|
||||
default:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"not registered !!!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 3.14.6 Constraints on Simple Type Definition Schema Components
|
||||
*/
|
||||
|
@ -18284,17 +18085,11 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
|
|||
xmlSchemaTypeFixupOptimFacets(type);
|
||||
|
||||
exit_error:
|
||||
#ifdef DEBUG_TYPE
|
||||
xmlSchemaDebugFixedType(pctxt, type);
|
||||
#endif
|
||||
if (olderrs != pctxt->nberrors)
|
||||
return(pctxt->err);
|
||||
return(0);
|
||||
|
||||
exit_failure:
|
||||
#ifdef DEBUG_TYPE
|
||||
xmlSchemaDebugFixedType(pctxt, type);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -18716,9 +18511,6 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
|
|||
res = xmlSchemaCheckCTComponent(pctxt, type);
|
||||
HFAILURE HERROR
|
||||
|
||||
#ifdef DEBUG_TYPE
|
||||
xmlSchemaDebugFixedType(pctxt, type);
|
||||
#endif
|
||||
if (olderrs != pctxt->nberrors)
|
||||
return(pctxt->err);
|
||||
else
|
||||
|
@ -18726,16 +18518,10 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
|
|||
|
||||
exit_error:
|
||||
type->flags |= XML_SCHEMAS_TYPE_INTERNAL_INVALID;
|
||||
#ifdef DEBUG_TYPE
|
||||
xmlSchemaDebugFixedType(pctxt, type);
|
||||
#endif
|
||||
return(pctxt->err);
|
||||
|
||||
exit_failure:
|
||||
type->flags |= XML_SCHEMAS_TYPE_INTERNAL_INVALID;
|
||||
#ifdef DEBUG_TYPE
|
||||
xmlSchemaDebugFixedType(pctxt, type);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -22614,10 +22400,6 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt,
|
|||
sto->sel = sel;
|
||||
sto->nbHistory = 0;
|
||||
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: STO push '%s'\n",
|
||||
sto->sel->xpath);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -22643,30 +22425,12 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
|
|||
|
||||
if (nodeType == XML_ATTRIBUTE_NODE)
|
||||
depth++;
|
||||
#ifdef DEBUG_IDC
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"IDC: EVAL on %s, depth %d, type %d\n",
|
||||
xmlSchemaFormatQName(&str, vctxt->inode->nsName,
|
||||
vctxt->inode->localName), depth, nodeType);
|
||||
FREE_AND_NULL(str)
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Process all active XPath state objects.
|
||||
*/
|
||||
first = vctxt->xpathStates;
|
||||
sto = first;
|
||||
while (sto != head) {
|
||||
#ifdef DEBUG_IDC
|
||||
if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR)
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s'\n",
|
||||
sto->matcher->aidc->def->name, sto->sel->xpath);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n",
|
||||
sto->matcher->aidc->def->name, sto->sel->xpath);
|
||||
#endif
|
||||
if (nodeType == XML_ELEMENT_NODE)
|
||||
res = xmlStreamPush((xmlStreamCtxtPtr) sto->xpathCtxt,
|
||||
vctxt->inode->localName, vctxt->inode->nsName);
|
||||
|
@ -22684,10 +22448,6 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
|
|||
/*
|
||||
* Full match.
|
||||
*/
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: "
|
||||
"MATCH\n");
|
||||
#endif
|
||||
/*
|
||||
* Register a match in the state object history.
|
||||
*/
|
||||
|
@ -22711,21 +22471,12 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
|
|||
}
|
||||
sto->history[sto->nbHistory++] = depth;
|
||||
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: push match '%d'\n",
|
||||
vctxt->depth);
|
||||
#endif
|
||||
|
||||
if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
|
||||
xmlSchemaIDCSelectPtr sel;
|
||||
/*
|
||||
* Activate state objects for the IDC fields of
|
||||
* the IDC selector.
|
||||
*/
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: "
|
||||
"activating field states\n");
|
||||
#endif
|
||||
sel = sto->matcher->aidc->def->fields;
|
||||
while (sel != NULL) {
|
||||
if (xmlSchemaIDCAddStateObject(vctxt, sto->matcher,
|
||||
|
@ -22737,10 +22488,6 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
|
|||
/*
|
||||
* An IDC key node was found by the IDC field.
|
||||
*/
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"IDC: key found\n");
|
||||
#endif
|
||||
/*
|
||||
* Notify that the character value of this node is
|
||||
* needed.
|
||||
|
@ -22873,16 +22620,6 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
|
|||
return (0);
|
||||
sto = vctxt->xpathStates;
|
||||
|
||||
#ifdef DEBUG_IDC
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"IDC: BACK on %s, depth %d\n",
|
||||
xmlSchemaFormatQName(&str, vctxt->inode->nsName,
|
||||
vctxt->inode->localName), vctxt->depth);
|
||||
FREE_AND_NULL(str)
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Evaluate the state objects.
|
||||
*/
|
||||
|
@ -22893,10 +22630,6 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
|
|||
"calling xmlStreamPop()");
|
||||
return (-1);
|
||||
}
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: stream pop '%s'\n",
|
||||
sto->sel->xpath);
|
||||
#endif
|
||||
if (sto->nbHistory == 0)
|
||||
goto deregister_check;
|
||||
|
||||
|
@ -23355,10 +23088,6 @@ deregister_check:
|
|||
* Deregister state objects if they reach the depth of creation.
|
||||
*/
|
||||
if ((sto->nbHistory == 0) && (sto->depth == depth)) {
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: STO pop '%s'\n",
|
||||
sto->sel->xpath);
|
||||
#endif
|
||||
if (vctxt->xpathStates != sto) {
|
||||
VERROR_INT("xmlSchemaXPathProcessHistory",
|
||||
"The state object to be removed is not the first "
|
||||
|
@ -23403,16 +23132,6 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
|
|||
if (idc == NULL)
|
||||
return (0);
|
||||
|
||||
#ifdef DEBUG_IDC
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"IDC: REGISTER on %s, depth %d\n",
|
||||
(char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName,
|
||||
vctxt->inode->localName), vctxt->depth);
|
||||
FREE_AND_NULL(str)
|
||||
}
|
||||
#endif
|
||||
if (vctxt->inode->idcMatchers != NULL) {
|
||||
VERROR_INT("xmlSchemaIDCRegisterMatchers",
|
||||
"The chain of IDC matchers is expected to be empty");
|
||||
|
@ -23497,9 +23216,6 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
|
|||
matcher->depth = vctxt->depth;
|
||||
matcher->aidc = aidc;
|
||||
matcher->idcType = aidc->def->type;
|
||||
#ifdef DEBUG_IDC
|
||||
xmlGenericError(xmlGenericErrorContext, "IDC: register matcher\n");
|
||||
#endif
|
||||
/*
|
||||
* Init the automaton state object.
|
||||
*/
|
||||
|
@ -26210,25 +25926,6 @@ xmlSchemaVContentModelCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
|
|||
xmlSchemaElementPtr item = (xmlSchemaElementPtr) transdata;
|
||||
xmlSchemaNodeInfoPtr inode = (xmlSchemaNodeInfoPtr) inputdata;
|
||||
inode->decl = item;
|
||||
#ifdef DEBUG_CONTENT
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
|
||||
if (item->type == XML_SCHEMA_TYPE_ELEMENT) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON callback for '%s' [declaration]\n",
|
||||
xmlSchemaFormatQName(&str,
|
||||
inode->localName, inode->nsName));
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON callback for '%s' [wildcard]\n",
|
||||
xmlSchemaFormatQName(&str,
|
||||
inode->localName, inode->nsName));
|
||||
|
||||
}
|
||||
FREE_AND_NULL(str)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -26319,10 +26016,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
|
|||
"failed to create a regex context");
|
||||
goto internal_error;
|
||||
}
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON create on '%s'\n", inode->localName);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -26330,11 +26023,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
|
|||
*/
|
||||
if (INODE_NILLED(inode)) {
|
||||
ret = 0;
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON succeeded on nilled '%s'\n",
|
||||
inode->localName);
|
||||
#endif
|
||||
goto skip_nilled;
|
||||
}
|
||||
|
||||
|
@ -26356,21 +26044,11 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
|
|||
XML_SCHEMAV_ELEMENT_CONTENT, NULL, NULL,
|
||||
"Missing child element(s)",
|
||||
nbval, nbneg, values);
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON missing ERROR on '%s'\n",
|
||||
inode->localName);
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* Content model is satisfied.
|
||||
*/
|
||||
ret = 0;
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON succeeded on '%s'\n",
|
||||
inode->localName);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26673,12 +26351,6 @@ end_elem:
|
|||
* Merge/free the IDC table.
|
||||
*/
|
||||
if (inode->idcTable != NULL) {
|
||||
#ifdef DEBUG_IDC_NODE_TABLE
|
||||
xmlSchemaDebugDumpIDCTable(stdout,
|
||||
inode->nsName,
|
||||
inode->localName,
|
||||
inode->idcTable);
|
||||
#endif
|
||||
if ((vctxt->depth > 0) &&
|
||||
(vctxt->hasKeyrefs || vctxt->createIDCNodeTables))
|
||||
{
|
||||
|
@ -26870,10 +26542,6 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
|
|||
return (-1);
|
||||
}
|
||||
pielem->regexCtxt = regexCtxt;
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext, "AUTOMATA create on '%s'\n",
|
||||
pielem->localName);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -26888,16 +26556,6 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
|
|||
vctxt->inode->localName,
|
||||
vctxt->inode->nsName,
|
||||
vctxt->inode);
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
if (ret < 0)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON push ERROR for '%s' on '%s'\n",
|
||||
vctxt->inode->localName, pielem->localName);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"AUTOMATON push OK for '%s' on '%s'\n",
|
||||
vctxt->inode->localName, pielem->localName);
|
||||
#endif
|
||||
if (vctxt->err == XML_SCHEMAV_INTERNAL) {
|
||||
VERROR_INT("xmlSchemaValidateChildElem",
|
||||
"calling xmlRegExecPushString2()");
|
||||
|
@ -29067,6 +28725,55 @@ xmlSchemaValidateStreamLocator(void *ctx, const char **file,
|
|||
return(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSchemaValidateStreamInternal:
|
||||
* @ctxt: a schema validation context
|
||||
* @pctxt: a parser context
|
||||
*
|
||||
* Returns 0 if the document is schemas valid, a positive error code
|
||||
* number otherwise and -1 in case of internal or API error.
|
||||
*/
|
||||
static int
|
||||
xmlSchemaValidateStreamInternal(xmlSchemaValidCtxtPtr ctxt,
|
||||
xmlParserCtxtPtr pctxt) {
|
||||
xmlSchemaSAXPlugPtr plug = NULL;
|
||||
int ret;
|
||||
|
||||
pctxt->linenumbers = 1;
|
||||
xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
|
||||
|
||||
ctxt->parserCtxt = pctxt;
|
||||
ctxt->input = pctxt->input->buf;
|
||||
|
||||
/*
|
||||
* Plug the validation and launch the parsing
|
||||
*/
|
||||
plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData));
|
||||
if (plug == NULL) {
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
ctxt->input = pctxt->input->buf;
|
||||
ctxt->sax = pctxt->sax;
|
||||
ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
|
||||
ret = xmlSchemaVStart(ctxt);
|
||||
|
||||
if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
|
||||
ret = ctxt->parserCtxt->errNo;
|
||||
if (ret == 0)
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
done:
|
||||
ctxt->parserCtxt = NULL;
|
||||
ctxt->sax = NULL;
|
||||
ctxt->input = NULL;
|
||||
if (plug != NULL) {
|
||||
xmlSchemaSAXUnplug(plug);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSchemaValidateStream:
|
||||
* @ctxt: a schema validation context
|
||||
|
@ -29087,7 +28794,6 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
|
|||
xmlParserInputBufferPtr input, xmlCharEncoding enc,
|
||||
xmlSAXHandlerPtr sax, void *user_data)
|
||||
{
|
||||
xmlSchemaSAXPlugPtr plug = NULL;
|
||||
xmlParserCtxtPtr pctxt = NULL;
|
||||
xmlParserInputPtr inputStream = NULL;
|
||||
int ret;
|
||||
|
@ -29114,8 +28820,6 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
|
|||
if (options)
|
||||
xmlCtxtUseOptions(pctxt, options);
|
||||
#endif
|
||||
pctxt->linenumbers = 1;
|
||||
xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
|
||||
|
||||
inputStream = xmlNewIOInputStream(pctxt, input, enc);
|
||||
if (inputStream == NULL) {
|
||||
|
@ -29123,36 +28827,12 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
|
|||
goto done;
|
||||
}
|
||||
inputPush(pctxt, inputStream);
|
||||
ctxt->parserCtxt = pctxt;
|
||||
ctxt->input = input;
|
||||
|
||||
/*
|
||||
* Plug the validation and launch the parsing
|
||||
*/
|
||||
plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData));
|
||||
if (plug == NULL) {
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
ctxt->input = input;
|
||||
ctxt->enc = enc;
|
||||
ctxt->sax = pctxt->sax;
|
||||
ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
|
||||
ret = xmlSchemaVStart(ctxt);
|
||||
|
||||
if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
|
||||
ret = ctxt->parserCtxt->errNo;
|
||||
if (ret == 0)
|
||||
ret = 1;
|
||||
}
|
||||
ret = xmlSchemaValidateStreamInternal(ctxt, pctxt);
|
||||
|
||||
done:
|
||||
ctxt->parserCtxt = NULL;
|
||||
ctxt->sax = NULL;
|
||||
ctxt->input = NULL;
|
||||
if (plug != NULL) {
|
||||
xmlSchemaSAXUnplug(plug);
|
||||
}
|
||||
/* cleanup */
|
||||
if (pctxt != NULL) {
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
|
@ -29178,17 +28858,19 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
|
|||
int options ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int ret;
|
||||
xmlParserInputBufferPtr input;
|
||||
xmlParserCtxtPtr pctxt = NULL;
|
||||
|
||||
if ((ctxt == NULL) || (filename == NULL))
|
||||
return (-1);
|
||||
|
||||
input = xmlParserInputBufferCreateFilename(filename,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
if (input == NULL)
|
||||
pctxt = xmlCreateURLParserCtxt(filename, 0);
|
||||
if (pctxt == NULL)
|
||||
return (-1);
|
||||
ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
|
||||
NULL, NULL);
|
||||
/* We really want pctxt->sax to be NULL here. */
|
||||
xmlFree(pctxt->sax);
|
||||
pctxt->sax = NULL;
|
||||
ret = xmlSchemaValidateStreamInternal(ctxt, pctxt);
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
@ -25,7 +26,6 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/uri.h>
|
||||
|
||||
|
@ -35,8 +35,6 @@
|
|||
|
||||
#include "private/error.h"
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#ifndef LIBXML_XPATH_ENABLED
|
||||
extern double xmlXPathNAN;
|
||||
extern double xmlXPathPINF;
|
||||
|
@ -1299,25 +1297,6 @@ static const long dayInLeapYearByMonth[12] =
|
|||
dayInLeapYearByMonth[month - 1] : \
|
||||
dayInYearByMonth[month - 1]) + day)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_DATE(dt) \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"type=%o %04ld-%02u-%02uT%02u:%02u:%03f", \
|
||||
dt->type,dt->value.date.year,dt->value.date.mon, \
|
||||
dt->value.date.day,dt->value.date.hour,dt->value.date.min, \
|
||||
dt->value.date.sec); \
|
||||
if (dt->value.date.tz_flag) \
|
||||
if (dt->value.date.tzo != 0) \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"%+05d\n",dt->value.date.tzo); \
|
||||
else \
|
||||
xmlGenericError(xmlGenericErrorContext, "Z\n"); \
|
||||
else \
|
||||
xmlGenericError(xmlGenericErrorContext,"\n")
|
||||
#else
|
||||
#define DEBUG_DATE(dt)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* _xmlSchemaParseGYear:
|
||||
* @dt: pointer to a date structure
|
||||
|
|
|
@ -712,47 +712,47 @@ xmlGetUTF8Char(const unsigned char *utf, int *len) {
|
|||
goto error;
|
||||
if (len == NULL)
|
||||
goto error;
|
||||
if (*len < 1)
|
||||
goto error;
|
||||
|
||||
c = utf[0];
|
||||
if (c & 0x80) {
|
||||
if (*len < 2)
|
||||
if (c < 0x80) {
|
||||
if (*len < 1)
|
||||
goto error;
|
||||
if ((utf[1] & 0xc0) != 0x80)
|
||||
/* 1-byte code */
|
||||
*len = 1;
|
||||
} else {
|
||||
if ((*len < 2) || ((utf[1] & 0xc0) != 0x80))
|
||||
goto error;
|
||||
if ((c & 0xe0) == 0xe0) {
|
||||
if (*len < 3)
|
||||
if (c < 0xe0) {
|
||||
if (c < 0xc2)
|
||||
goto error;
|
||||
if ((utf[2] & 0xc0) != 0x80)
|
||||
/* 2-byte code */
|
||||
*len = 2;
|
||||
c = (c & 0x1f) << 6;
|
||||
c |= utf[1] & 0x3f;
|
||||
} else {
|
||||
if ((*len < 3) || ((utf[2] & 0xc0) != 0x80))
|
||||
goto error;
|
||||
if ((c & 0xf0) == 0xf0) {
|
||||
if (*len < 4)
|
||||
if (c < 0xf0) {
|
||||
/* 3-byte code */
|
||||
*len = 3;
|
||||
c = (c & 0xf) << 12;
|
||||
c |= (utf[1] & 0x3f) << 6;
|
||||
c |= utf[2] & 0x3f;
|
||||
if ((c < 0x800) || ((c >= 0xd800) && (c < 0xe000)))
|
||||
goto error;
|
||||
if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
|
||||
} else {
|
||||
if ((*len < 4) || ((utf[3] & 0xc0) != 0x80))
|
||||
goto error;
|
||||
*len = 4;
|
||||
/* 4-byte code */
|
||||
c = (utf[0] & 0x7) << 18;
|
||||
c = (c & 0x7) << 18;
|
||||
c |= (utf[1] & 0x3f) << 12;
|
||||
c |= (utf[2] & 0x3f) << 6;
|
||||
c |= utf[3] & 0x3f;
|
||||
} else {
|
||||
/* 3-byte code */
|
||||
*len = 3;
|
||||
c = (utf[0] & 0xf) << 12;
|
||||
c |= (utf[1] & 0x3f) << 6;
|
||||
c |= utf[2] & 0x3f;
|
||||
if ((c < 0x10000) || (c >= 0x110000))
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
/* 2-byte code */
|
||||
*len = 2;
|
||||
c = (utf[0] & 0x1f) << 6;
|
||||
c |= utf[1] & 0x3f;
|
||||
}
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
*len = 1;
|
||||
}
|
||||
return(c);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,20 +38,12 @@
|
|||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#ifdef LIBXML_XPTR_ENABLED
|
||||
|
||||
/* Add support of the xmlns() xpointer scheme to initialize the namespaces */
|
||||
#define XPTR_XMLNS_SCHEME
|
||||
|
||||
/* #define DEBUG_RANGES */
|
||||
#ifdef DEBUG_RANGES
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
#include <libxml/debugXML.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "private/error.h"
|
||||
|
||||
#define TODO \
|
||||
|
@ -705,10 +697,6 @@ xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
|
|||
if (cur->locTab[i] == val) break;
|
||||
|
||||
if (i >= cur->locNr) {
|
||||
#ifdef DEBUG
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlXPtrLocationSetDel: Range wasn't found in RangeList\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
cur->locNr--;
|
||||
|
@ -1248,7 +1236,6 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
|
|||
ctxt->valueNr = 0;
|
||||
ctxt->valueMax = 10;
|
||||
ctxt->value = NULL;
|
||||
ctxt->valueFrame = 0;
|
||||
}
|
||||
SKIP_BLANKS;
|
||||
if (CUR == '/') {
|
||||
|
@ -2425,13 +2412,6 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
|||
if (len >= pos + stringlen) {
|
||||
match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
|
||||
if (match) {
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"found range %d bytes at index %d of ->",
|
||||
stringlen, pos + 1);
|
||||
xmlDebugDumpString(stdout, cur->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
*end = cur;
|
||||
*endindex = pos + stringlen;
|
||||
return(1);
|
||||
|
@ -2442,13 +2422,6 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
|||
int sub = len - pos;
|
||||
match = (!xmlStrncmp(&cur->content[pos], string, sub));
|
||||
if (match) {
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"found subrange %d bytes at index %d of ->",
|
||||
sub, pos + 1);
|
||||
xmlDebugDumpString(stdout, cur->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
string = &string[sub];
|
||||
stringlen -= sub;
|
||||
} else {
|
||||
|
@ -2508,13 +2481,6 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
|||
str = xmlStrchr(&cur->content[pos], first);
|
||||
if (str != NULL) {
|
||||
pos = (str - (xmlChar *)(cur->content));
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"found '%c' at index %d of ->",
|
||||
first, pos + 1);
|
||||
xmlDebugDumpString(stdout, cur->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
if (xmlXPtrMatchString(string, cur, pos + 1,
|
||||
end, endindex)) {
|
||||
*start = cur;
|
||||
|
@ -2531,13 +2497,6 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
|||
* character of the string-value and after the final
|
||||
* character.
|
||||
*/
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"found '' at index %d of ->",
|
||||
pos + 1);
|
||||
xmlDebugDumpString(stdout, cur->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
*start = cur;
|
||||
*startindex = pos + 1;
|
||||
*end = cur;
|
||||
|
@ -2787,25 +2746,12 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||
* the list of location set corresponding to that search
|
||||
*/
|
||||
for (i = 0;i < oldset->locNr;i++) {
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlXPathDebugDumpObject(stdout, oldset->locTab[i], 0);
|
||||
#endif
|
||||
|
||||
xmlXPtrGetStartPoint(oldset->locTab[i], &start, &startindex);
|
||||
xmlXPtrGetEndPoint(oldset->locTab[i], &end, &endindex);
|
||||
xmlXPtrAdvanceChar(&start, &startindex, 0);
|
||||
xmlXPtrGetLastChar(&end, &endindex);
|
||||
|
||||
#ifdef DEBUG_RANGES
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"from index %d of ->", startindex);
|
||||
xmlDebugDumpString(stdout, start->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"to index %d of ->", endindex);
|
||||
xmlDebugDumpString(stdout, end->content);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
#endif
|
||||
do {
|
||||
fend = end;
|
||||
fendindex = endindex;
|
||||
|
@ -2971,4 +2917,3 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
|
|||
#endif /* LIBXML_XPTR_LOCS_ENABLED */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue