mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-21 22:50:08 +03:00
debug: Remove debugging code
This is barely useful these days and only clutters the code base.
This commit is contained in:
parent
c19771c1f1
commit
4e1c13ebfd
@ -40,8 +40,6 @@
|
||||
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
|
||||
#define HTML_PARSER_BUFFER_SIZE 100
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
static int htmlOmittedDefaultValue = 1;
|
||||
|
||||
xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
|
||||
|
142
SAX2.c
142
SAX2.c
@ -32,9 +32,6 @@
|
||||
#include "private/parser.h"
|
||||
#include "private/tree.h"
|
||||
|
||||
/* #define DEBUG_SAX2 */
|
||||
/* #define DEBUG_SAX2_TREE */
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
*
|
||||
@ -331,11 +328,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 +360,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))) {
|
||||
@ -512,11 +499,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)
|
||||
@ -540,10 +522,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);
|
||||
@ -590,10 +568,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);
|
||||
@ -619,11 +593,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);
|
||||
@ -696,11 +665,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)) {
|
||||
/*
|
||||
@ -766,11 +730,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);
|
||||
@ -815,11 +774,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",
|
||||
@ -864,11 +818,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,
|
||||
@ -927,11 +876,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
|
||||
}
|
||||
|
||||
/**
|
||||
@ -948,10 +892,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)
|
||||
@ -1007,10 +947,6 @@ xmlSAX2EndDocument(void *ctx)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlDocPtr doc;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2EndDocument()\n");
|
||||
#endif
|
||||
if (ctx == NULL) return;
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if (ctxt->validate && ctxt->wellFormed &&
|
||||
@ -1599,10 +1535,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
int i;
|
||||
|
||||
if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2StartElement(%s)\n", fullname);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* First check on validity:
|
||||
@ -1658,9 +1590,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
/*
|
||||
* 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);
|
||||
@ -1672,10 +1601,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
/*
|
||||
* Link the child element
|
||||
*/
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"adding child %s to %s\n", name, parent->name);
|
||||
#endif
|
||||
xmlAddChild(parent, ret);
|
||||
|
||||
if (!ctxt->html) {
|
||||
@ -1795,12 +1720,6 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||
|
||||
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;
|
||||
|
||||
@ -1815,9 +1734,6 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||
/*
|
||||
* 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 */
|
||||
@ -2454,15 +2370,7 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
|
||||
xmlNodePtr ret;
|
||||
|
||||
if (ctx == NULL) return;
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2Reference(%s)\n", name);
|
||||
#endif
|
||||
ret = xmlNewReference(ctxt->myDoc, name);
|
||||
#ifdef DEBUG_SAX_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
|
||||
#endif
|
||||
if (xmlAddChild(ctxt->node, ret) == NULL) {
|
||||
xmlFreeNode(ret);
|
||||
}
|
||||
@ -2484,10 +2392,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,
|
||||
@ -2495,17 +2399,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
|
||||
@ -2645,11 +2541,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
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2670,10 +2561,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;
|
||||
@ -2694,25 +2581,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);
|
||||
}
|
||||
}
|
||||
@ -2733,9 +2607,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) {
|
||||
@ -2755,25 +2626,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);
|
||||
}
|
||||
}
|
||||
|
28
buf.c
28
buf.c
@ -225,10 +225,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 +243,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 +277,6 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
|
||||
void
|
||||
xmlBufFree(xmlBufPtr buf) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufFree: buf == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -479,17 +467,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 +765,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 +858,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){
|
||||
|
13
globals.c
13
globals.c
@ -26,8 +26,6 @@
|
||||
#include "private/threads.h"
|
||||
#include "private/tree.h"
|
||||
|
||||
/* #define DEBUG_GLOBALS */
|
||||
|
||||
/*
|
||||
* Helpful Macro
|
||||
*/
|
||||
@ -126,7 +124,7 @@ static CRITICAL_SECTION cleanup_helpers_cs;
|
||||
#undef xmlMemStrdup
|
||||
#undef xmlRealloc
|
||||
|
||||
#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
|
||||
#if defined(DEBUG_MEMORY_LOCATION)
|
||||
xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
|
||||
xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
|
||||
xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
|
||||
@ -191,7 +189,7 @@ xmlPosixStrdup(const char *cur) {
|
||||
* Returns the copy of the string or NULL in case of error
|
||||
*/
|
||||
xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
|
||||
#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
|
||||
#endif /* DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
@ -655,11 +653,6 @@ void xmlCleanupGlobalsInternal(void) {
|
||||
void
|
||||
xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
||||
{
|
||||
#ifdef DEBUG_GLOBALS
|
||||
fprintf(stderr, "Initializing globals at %p for thread %d\n",
|
||||
(void *) gs, xmlGetThreadId());
|
||||
#endif
|
||||
|
||||
xmlMutexLock(&xmlThrDefMutex);
|
||||
|
||||
#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
||||
@ -678,7 +671,7 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
||||
gs->gsDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
|
||||
gs->gsDoValidityCheckingDefaultValue =
|
||||
xmlDoValidityCheckingDefaultValueThrDef;
|
||||
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
|
||||
#if defined(DEBUG_MEMORY_LOCATION)
|
||||
gs->gsFree = (xmlFreeFunc) xmlMemFree;
|
||||
gs->gsMalloc = (xmlMallocFunc) xmlMemMalloc;
|
||||
gs->gsMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
|
||||
|
@ -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
|
||||
|
115
nanoftp.c
115
nanoftp.c
@ -61,14 +61,6 @@
|
||||
#include "private/error.h"
|
||||
#include "private/io.h"
|
||||
|
||||
/* #define DEBUG_FTP 1 */
|
||||
#ifdef STANDALONE
|
||||
#ifndef DEBUG_FTP
|
||||
#define DEBUG_FTP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <wsockcompat.h>
|
||||
#endif
|
||||
@ -408,14 +400,6 @@ xmlNanoFTPScanProxy(const char *URL) {
|
||||
}
|
||||
proxyPort = 0;
|
||||
|
||||
#ifdef DEBUG_FTP
|
||||
if (URL == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Removing FTP proxy info\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Using FTP proxy %s\n", URL);
|
||||
#endif
|
||||
if (URL == NULL) return;
|
||||
|
||||
uri = xmlParseURIRaw(URL, 1);
|
||||
@ -548,28 +532,13 @@ xmlNanoFTPGetMore(void *ctx) {
|
||||
if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
|
||||
|
||||
if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) {
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPGetMore : controlBufIndex = %d\n",
|
||||
ctxt->controlBufIndex);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) {
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPGetMore : controlBufUsed = %d\n",
|
||||
ctxt->controlBufUsed);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
if (ctxt->controlBufIndex > ctxt->controlBufUsed) {
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n",
|
||||
ctxt->controlBufIndex, ctxt->controlBufUsed);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -584,10 +553,6 @@ xmlNanoFTPGetMore(void *ctx) {
|
||||
}
|
||||
size = FTP_BUF_SIZE - ctxt->controlBufUsed;
|
||||
if (size == 0) {
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed);
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -601,11 +566,6 @@ xmlNanoFTPGetMore(void *ctx) {
|
||||
ctxt->controlFd = INVALID_SOCKET;
|
||||
return(-1);
|
||||
}
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPGetMore : read %d [%d - %d]\n", len,
|
||||
ctxt->controlBufUsed, ctxt->controlBufUsed + len);
|
||||
#endif
|
||||
ctxt->controlBufUsed += len;
|
||||
ctxt->controlBuf[ctxt->controlBufUsed] = 0;
|
||||
|
||||
@ -643,10 +603,6 @@ get_more:
|
||||
ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
|
||||
end = &ctxt->controlBuf[ctxt->controlBufUsed];
|
||||
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"\n<<<\n%s\n--\n", ptr);
|
||||
#endif
|
||||
while (ptr < end) {
|
||||
cur = xmlNanoFTPParseResponse(ptr, end - ptr);
|
||||
if (cur > 0) {
|
||||
@ -673,14 +629,7 @@ get_more:
|
||||
|
||||
if (res < 0) goto get_more;
|
||||
ctxt->controlBufIndex = ptr - ctxt->controlBuf;
|
||||
#ifdef DEBUG_FTP
|
||||
ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
|
||||
xmlGenericError(xmlGenericErrorContext, "\n---\n%s\n--\n", ptr);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "Got %d\n", res);
|
||||
#endif
|
||||
return(res / 100);
|
||||
}
|
||||
|
||||
@ -749,9 +698,6 @@ xmlNanoFTPSendUser(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -777,9 +723,6 @@ xmlNanoFTPSendPasswd(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -808,9 +751,6 @@ xmlNanoFTPQuit(void *ctx) {
|
||||
|
||||
snprintf(buf, sizeof(buf), "QUIT\r\n");
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1004,9 +944,6 @@ xmlNanoFTPConnect(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1027,9 +964,6 @@ xmlNanoFTPConnect(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "PASS anonymous@\r\n");
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1068,9 +1002,6 @@ xmlNanoFTPConnect(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1100,9 +1031,6 @@ xmlNanoFTPConnect(void *ctx) {
|
||||
ctxt->user, ctxt->hostname);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1122,9 +1050,6 @@ xmlNanoFTPConnect(void *ctx) {
|
||||
snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1273,9 +1198,6 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
|
||||
snprintf(buf, sizeof(buf), "CWD %s\r\n", directory);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1324,9 +1246,6 @@ xmlNanoFTPDele(void *ctx, const char *file) {
|
||||
snprintf(buf, sizeof(buf), "DELE %s\r\n", file);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1396,9 +1315,6 @@ xmlNanoFTPGetConnection(void *ctx) {
|
||||
#endif
|
||||
snprintf (buf, sizeof(buf), "PASV\r\n");
|
||||
len = strlen (buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1496,9 +1412,6 @@ xmlNanoFTPGetConnection(void *ctx) {
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
@ -1543,17 +1456,10 @@ xmlNanoFTPCloseConnection(void *ctx) {
|
||||
FD_SET(ctxt->controlFd, &efd);
|
||||
res = select(ctxt->controlFd + 1, &rfd, NULL, &efd, &tv);
|
||||
if (res < 0) {
|
||||
#ifdef DEBUG_FTP
|
||||
perror("select");
|
||||
#endif
|
||||
closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
|
||||
return(-1);
|
||||
}
|
||||
if (res == 0) {
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoFTPCloseConnection: timeout\n");
|
||||
#endif
|
||||
closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
|
||||
} else {
|
||||
res = xmlNanoFTPGetResponse(ctxt);
|
||||
@ -1734,9 +1640,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
||||
}
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1758,9 +1661,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
||||
FD_SET(ctxt->dataFd, &efd);
|
||||
res = select(ctxt->dataFd + 1, &rfd, NULL, &efd, &tv);
|
||||
if (res < 0) {
|
||||
#ifdef DEBUG_FTP
|
||||
perror("select");
|
||||
#endif
|
||||
closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
|
||||
return(-1);
|
||||
}
|
||||
@ -1785,9 +1685,6 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
||||
ctxt->dataFd = INVALID_SOCKET;
|
||||
return(-1);
|
||||
}
|
||||
#ifdef DEBUG_FTP
|
||||
write(1, &buf[indx], len);
|
||||
#endif
|
||||
indx += len;
|
||||
buf[indx] = 0;
|
||||
base = 0;
|
||||
@ -1829,9 +1726,6 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
||||
|
||||
snprintf(buf, sizeof(buf), "TYPE I\r\n");
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1849,9 +1743,6 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
||||
snprintf(buf, sizeof(buf), "RETR %s\r\n", filename);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||
#endif
|
||||
res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
|
||||
if (res < 0) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
|
||||
@ -1903,9 +1794,6 @@ xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
|
||||
FD_SET(ctxt->dataFd, &rfd);
|
||||
res = select(ctxt->dataFd + 1, &rfd, NULL, NULL, &tv);
|
||||
if (res < 0) {
|
||||
#ifdef DEBUG_FTP
|
||||
perror("select");
|
||||
#endif
|
||||
closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
|
||||
return(-1);
|
||||
}
|
||||
@ -1962,9 +1850,6 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) {
|
||||
__xmlIOErr(XML_FROM_FTP, 0, "recv failed");
|
||||
xmlNanoFTPCloseConnection(ctxt);
|
||||
}
|
||||
#ifdef DEBUG_FTP
|
||||
xmlGenericError(xmlGenericErrorContext, "Recvd %d bytes\n", len);
|
||||
#endif
|
||||
return(len);
|
||||
}
|
||||
|
||||
|
73
nanohttp.c
73
nanohttp.c
@ -92,7 +92,6 @@
|
||||
#define SEND_ARG2_CAST (char *)
|
||||
|
||||
#ifdef STANDALONE
|
||||
#define DEBUG_HTTP
|
||||
#define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n)
|
||||
#define xmlStrcasecmpi(a, b) strcasecmp((char *)a, (char *)b)
|
||||
#endif
|
||||
@ -328,14 +327,6 @@ xmlNanoHTTPScanProxy(const char *URL) {
|
||||
}
|
||||
proxyPort = 0;
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
if (URL == NULL)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Removing HTTP proxy info\n");
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Using HTTP proxy %s\n", URL);
|
||||
#endif
|
||||
if (URL == NULL) return;
|
||||
|
||||
uri = xmlParseURIRaw(URL, 1);
|
||||
@ -854,9 +845,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
}
|
||||
if (s == INVALID_SOCKET) {
|
||||
#ifdef DEBUG_HTTP
|
||||
perror("socket");
|
||||
#endif
|
||||
__xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n");
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
@ -885,9 +873,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
|
||||
status = fcntl(s, F_SETFL, status);
|
||||
}
|
||||
if (status < 0) {
|
||||
#ifdef DEBUG_HTTP
|
||||
perror("nonblocking");
|
||||
#endif
|
||||
__xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n");
|
||||
closesocket(s);
|
||||
return INVALID_SOCKET;
|
||||
@ -1137,11 +1122,6 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoHTTPConnectHost: unable to connect to '%s'.\n",
|
||||
host);
|
||||
#endif
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
@ -1392,9 +1372,6 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
|
||||
int nbRedirects = 0;
|
||||
int use_proxy;
|
||||
char *redirURL = NULL;
|
||||
#ifdef DEBUG_HTTP
|
||||
int xmt_bytes;
|
||||
#endif
|
||||
|
||||
if (URL == NULL) return(NULL);
|
||||
if (method == NULL) method = "GET";
|
||||
@ -1514,41 +1491,13 @@ retry:
|
||||
else
|
||||
snprintf(p, blen - (p - bp), "\r\n");
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"-> %s%s", use_proxy ? "(Proxy) " : "", bp);
|
||||
if ((blen -= strlen(bp)+1) < 0)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"ERROR: overflowed buffer by %d bytes\n", -blen);
|
||||
#endif
|
||||
ctxt->outptr = ctxt->out = bp;
|
||||
ctxt->state = XML_NANO_HTTP_WRITE;
|
||||
blen = strlen( ctxt->out );
|
||||
#ifdef DEBUG_HTTP
|
||||
xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen );
|
||||
if ( xmt_bytes != blen )
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
|
||||
xmt_bytes, blen,
|
||||
"bytes of HTTP headers sent to host",
|
||||
ctxt->hostname );
|
||||
#else
|
||||
xmlNanoHTTPSend(ctxt, ctxt->out, blen );
|
||||
#endif
|
||||
|
||||
if ( input != NULL ) {
|
||||
#ifdef DEBUG_HTTP
|
||||
xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen );
|
||||
|
||||
if ( xmt_bytes != ilen )
|
||||
xmlGenericError( xmlGenericErrorContext,
|
||||
"xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
|
||||
xmt_bytes, ilen,
|
||||
"bytes of HTTP content sent to host",
|
||||
ctxt->hostname );
|
||||
#else
|
||||
xmlNanoHTTPSend( ctxt, input, ilen );
|
||||
#endif
|
||||
}
|
||||
|
||||
ctxt->state = XML_NANO_HTTP_READ;
|
||||
@ -1561,18 +1510,11 @@ retry:
|
||||
}
|
||||
xmlNanoHTTPScanAnswer(ctxt, p);
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
xmlGenericError(xmlGenericErrorContext, "<- %s\n", p);
|
||||
#endif
|
||||
xmlFree(p);
|
||||
}
|
||||
|
||||
if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) &&
|
||||
(ctxt->returnValue < 400)) {
|
||||
#ifdef DEBUG_HTTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"\nRedirect to: %s\n", ctxt->location);
|
||||
#endif
|
||||
while ( xmlNanoHTTPRecv(ctxt) > 0 )
|
||||
;
|
||||
if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
|
||||
@ -1585,10 +1527,6 @@ retry:
|
||||
}
|
||||
xmlNanoHTTPFreeCtxt(ctxt);
|
||||
if (redirURL != NULL) xmlFree(redirURL);
|
||||
#ifdef DEBUG_HTTP
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNanoHTTPMethodRedir: Too many redirects, aborting ...\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -1608,17 +1546,6 @@ retry:
|
||||
*redir = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
if (ctxt->contentType != NULL)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"\nCode %d, content-type '%s'\n\n",
|
||||
ctxt->returnValue, ctxt->contentType);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"\nCode %d, no content-type\n\n",
|
||||
ctxt->returnValue);
|
||||
#endif
|
||||
|
||||
return((void *) ctxt);
|
||||
}
|
||||
|
||||
|
32
parser.c
32
parser.c
@ -2897,14 +2897,6 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
|
||||
* Routines to parse Name, NCName and NmToken *
|
||||
* *
|
||||
************************************************************************/
|
||||
#ifdef DEBUG
|
||||
static unsigned long nbParseName = 0;
|
||||
static unsigned long nbParseNmToken = 0;
|
||||
static unsigned long nbParseNCName = 0;
|
||||
static unsigned long nbParseNCNameComplex = 0;
|
||||
static unsigned long nbParseNameComplex = 0;
|
||||
static unsigned long nbParseStringName = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The two following functions are related to the change of accepted
|
||||
@ -2997,10 +2989,6 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
|
||||
XML_MAX_TEXT_LENGTH :
|
||||
XML_MAX_NAME_LENGTH;
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseNameComplex++;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handler for more complex cases
|
||||
*/
|
||||
@ -3131,10 +3119,6 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
return(NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseName++;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Accelerator for simple ASCII names
|
||||
*/
|
||||
@ -3176,10 +3160,6 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
|
||||
XML_MAX_NAME_LENGTH;
|
||||
size_t startPosition = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseNCNameComplex++;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handler for more complex cases
|
||||
*/
|
||||
@ -3230,10 +3210,6 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
|
||||
XML_MAX_TEXT_LENGTH :
|
||||
XML_MAX_NAME_LENGTH;
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseNCName++;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Accelerator for simple ASCII names
|
||||
*/
|
||||
@ -3339,10 +3315,6 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
|
||||
XML_MAX_TEXT_LENGTH :
|
||||
XML_MAX_NAME_LENGTH;
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseStringName++;
|
||||
#endif
|
||||
|
||||
c = CUR_SCHAR(cur, l);
|
||||
if (!xmlIsNameStartChar(ctxt, c)) {
|
||||
return(NULL);
|
||||
@ -3428,10 +3400,6 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
|
||||
XML_MAX_TEXT_LENGTH :
|
||||
XML_MAX_NAME_LENGTH;
|
||||
|
||||
#ifdef DEBUG
|
||||
nbParseNmToken++;
|
||||
#endif
|
||||
|
||||
c = CUR_CHAR(l);
|
||||
|
||||
while (xmlIsNameChar(ctxt, c)) {
|
||||
|
@ -451,40 +451,9 @@ xmlIsLetter(int c) {
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/* #define DEBUG_INPUT */
|
||||
/* #define DEBUG_STACK */
|
||||
|
||||
|
||||
/* we need to keep enough input to show errors in context */
|
||||
#define LINE_LEN 80
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
#define CHECK_BUFFER(in) check_buffer(in)
|
||||
|
||||
static
|
||||
void check_buffer(xmlParserInputPtr in) {
|
||||
if (in->base != xmlBufContent(in->buf->buffer)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlParserInput: base mismatch problem\n");
|
||||
}
|
||||
if (in->cur < in->base) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlParserInput: cur < base problem\n");
|
||||
}
|
||||
if (in->cur > in->base + xmlBufUse(in->buf->buffer)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlParserInput: cur > base + use problem\n");
|
||||
}
|
||||
xmlGenericError(xmlGenericErrorContext,"buffer %p : content %x, cur %d, use %d\n",
|
||||
(void *) in, (int) xmlBufContent(in->buf->buffer),
|
||||
in->cur - in->base, xmlBufUse(in->buf->buffer));
|
||||
}
|
||||
|
||||
#else
|
||||
#define CHECK_BUFFER(in)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* xmlHaltParser:
|
||||
* @ctxt: an XML parser context
|
||||
@ -597,21 +566,13 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
size_t indx;
|
||||
|
||||
if ((in == NULL) || (len < 0)) return(-1);
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
||||
#endif
|
||||
if (in->buf == NULL) return(-1);
|
||||
if (in->base == NULL) return(-1);
|
||||
if (in->cur == NULL) return(-1);
|
||||
if (in->buf->buffer == NULL) return(-1);
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
indx = in->cur - in->base;
|
||||
if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
return(0);
|
||||
}
|
||||
ret = xmlParserInputBufferGrow(in->buf, len);
|
||||
@ -626,8 +587,6 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
in->cur = in->base + indx;
|
||||
in->end = xmlBufEnd(in->buf->buffer);
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -681,17 +640,12 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
||||
size_t used;
|
||||
size_t ret;
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
|
||||
#endif
|
||||
if (in == NULL) return;
|
||||
if (in->buf == NULL) return;
|
||||
if (in->base == NULL) return;
|
||||
if (in->cur == NULL) return;
|
||||
if (in->buf->buffer == NULL) return;
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
used = in->cur - in->base;
|
||||
/*
|
||||
* Do not shrink on large buffers whose only a tiny fraction
|
||||
@ -723,8 +677,6 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
||||
}
|
||||
in->cur = in->base + used;
|
||||
in->end = xmlBufEnd(in->buf->buffer);
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
67
pattern.c
67
pattern.c
@ -37,8 +37,6 @@
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
|
||||
/* #define DEBUG_STREAMING */
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
@ -1416,62 +1414,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
|
||||
@ -1730,9 +1672,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:
|
||||
@ -1853,9 +1792,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);
|
||||
@ -2173,9 +2109,6 @@ stream_next:
|
||||
|
||||
if (err > 0)
|
||||
ret = -1;
|
||||
#ifdef DEBUG_STREAMING
|
||||
xmlDebugStreamCtxt(orig, ret);
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
211
python/libxml.c
211
python/libxml.c
@ -34,14 +34,6 @@
|
||||
#define vsnprintf trio_vsnprintf
|
||||
#endif
|
||||
|
||||
/* #define DEBUG */
|
||||
/* #define DEBUG_SAX */
|
||||
/* #define DEBUG_XPATH */
|
||||
/* #define DEBUG_ERROR */
|
||||
/* #define DEBUG_MEMORY */
|
||||
/* #define DEBUG_FILES */
|
||||
/* #define DEBUG_LOADER */
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject *PyInit_libxml2mod(void);
|
||||
|
||||
@ -128,10 +120,6 @@ libxml_xmlDebugMemory(PyObject * self ATTRIBUTE_UNUSED, PyObject * args)
|
||||
if (!PyArg_ParseTuple(args, (char *) "i:xmlDebugMemory", &activate))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
printf("libxml_xmlDebugMemory(%d) called\n", activate);
|
||||
#endif
|
||||
|
||||
if (activate != 0) {
|
||||
if (libxmlMemoryDebug == 0) {
|
||||
/*
|
||||
@ -231,9 +219,6 @@ static int
|
||||
xmlPythonFileCloseRaw (void * context) {
|
||||
PyObject *file, *ret;
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
printf("xmlPythonFileCloseUnref\n");
|
||||
#endif
|
||||
file = (PyObject *) context;
|
||||
if (file == NULL) return(-1);
|
||||
ret = PyObject_CallMethod(file, (char *) "close", (char *) "()");
|
||||
@ -261,9 +246,6 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
|
||||
int lenread = -1;
|
||||
char *data;
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
printf("xmlPythonFileReadRaw: %d\n", len);
|
||||
#endif
|
||||
file = (PyObject *) context;
|
||||
if (file == NULL) return(-1);
|
||||
ret = PyObject_CallMethod(file, (char *) "read", (char *) "(i)", len);
|
||||
@ -326,9 +308,6 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
|
||||
int lenread = -1;
|
||||
char *data;
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
printf("xmlPythonFileRead: %d\n", len);
|
||||
#endif
|
||||
file = (PyObject *) context;
|
||||
if (file == NULL) return(-1);
|
||||
ret = PyObject_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
|
||||
@ -391,9 +370,6 @@ xmlPythonFileWrite (void * context, const char * buffer, int len) {
|
||||
PyObject *ret = NULL;
|
||||
int written = -1;
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
printf("xmlPythonFileWrite: %d\n", len);
|
||||
#endif
|
||||
file = (PyObject *) context;
|
||||
if (file == NULL) return(-1);
|
||||
string = PY_IMPORT_STRING_SIZE(buffer, len);
|
||||
@ -432,9 +408,6 @@ static int
|
||||
xmlPythonFileClose (void * context) {
|
||||
PyObject *file, *ret = NULL;
|
||||
|
||||
#ifdef DEBUG_FILES
|
||||
printf("xmlPythonFileClose\n");
|
||||
#endif
|
||||
file = (PyObject *) context;
|
||||
if (file == NULL) return(-1);
|
||||
if (PyObject_HasAttrString(file, (char *) "io_close")) {
|
||||
@ -694,18 +667,10 @@ pythonExternalEntityLoader(const char *URL, const char *ID,
|
||||
PyObject *ctxtobj;
|
||||
|
||||
ctxtobj = libxml_xmlParserCtxtPtrWrap(ctxt);
|
||||
#ifdef DEBUG_LOADER
|
||||
printf("pythonExternalEntityLoader: ready to call\n");
|
||||
#endif
|
||||
|
||||
ret = PyObject_CallFunction(pythonExternalEntityLoaderObjext,
|
||||
(char *) "(ssO)", URL, ID, ctxtobj);
|
||||
Py_XDECREF(ctxtobj);
|
||||
#ifdef DEBUG_LOADER
|
||||
printf("pythonExternalEntityLoader: result ");
|
||||
PyObject_Print(ret, stdout, 0);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
if (ret != NULL) {
|
||||
if (PyObject_HasAttrString(ret, (char *) "read")) {
|
||||
@ -754,9 +719,6 @@ libxml_xmlSetEntityLoader(ATTRIBUTE_UNUSED PyObject *self, PyObject *args) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOADER
|
||||
printf("libxml_xmlSetEntityLoader\n");
|
||||
#endif
|
||||
if (defaultExternalEntityLoader == NULL)
|
||||
defaultExternalEntityLoader = xmlGetExternalEntityLoader();
|
||||
|
||||
@ -876,9 +838,6 @@ pythonStartElement(void *user_data, const xmlChar * name,
|
||||
PyObject *result = NULL;
|
||||
int type = 0;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonStartElement(%s) called\n", name);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "startElement"))
|
||||
type = 1;
|
||||
@ -930,9 +889,6 @@ pythonStartDocument(void *user_data)
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonStartDocument() called\n");
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "startDocument")) {
|
||||
result =
|
||||
@ -949,9 +905,6 @@ pythonEndDocument(void *user_data)
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonEndDocument() called\n");
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "endDocument")) {
|
||||
result =
|
||||
@ -972,9 +925,6 @@ pythonEndElement(void *user_data, const xmlChar * name)
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonEndElement(%s) called\n", name);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "endElement")) {
|
||||
result = PyObject_CallMethod(handler, (char *) "endElement",
|
||||
@ -997,9 +947,6 @@ pythonReference(void *user_data, const xmlChar * name)
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonReference(%s) called\n", name);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "reference")) {
|
||||
result = PyObject_CallMethod(handler, (char *) "reference",
|
||||
@ -1017,9 +964,6 @@ pythonCharacters(void *user_data, const xmlChar * ch, int len)
|
||||
PyObject *result = NULL;
|
||||
int type = 0;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonCharacters(%s, %d) called\n", ch, len);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "characters"))
|
||||
type = 1;
|
||||
@ -1045,9 +989,6 @@ pythonIgnorableWhitespace(void *user_data, const xmlChar * ch, int len)
|
||||
PyObject *result = NULL;
|
||||
int type = 0;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonIgnorableWhitespace(%s, %d) called\n", ch, len);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "ignorableWhitespace"))
|
||||
type = 1;
|
||||
@ -1074,9 +1015,6 @@ pythonProcessingInstruction(void *user_data,
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonProcessingInstruction(%s, %s) called\n", target, data);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "processingInstruction")) {
|
||||
result = PyObject_CallMethod(handler, (char *)
|
||||
@ -1092,9 +1030,6 @@ pythonComment(void *user_data, const xmlChar * value)
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonComment(%s) called\n", value);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "comment")) {
|
||||
result =
|
||||
@ -1114,9 +1049,6 @@ pythonWarning(void *user_data, const char *msg, ...)
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonWarning(%s) called\n", msg);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "warning")) {
|
||||
va_start(args, msg);
|
||||
@ -1140,9 +1072,6 @@ pythonError(void *user_data, const char *msg, ...)
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonError(%s) called\n", msg);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "error")) {
|
||||
va_start(args, msg);
|
||||
@ -1166,9 +1095,6 @@ pythonFatalError(void *user_data, const char *msg, ...)
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonFatalError(%s) called\n", msg);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "fatalError")) {
|
||||
va_start(args, msg);
|
||||
@ -1191,9 +1117,6 @@ pythonCdataBlock(void *user_data, const xmlChar * ch, int len)
|
||||
PyObject *result = NULL;
|
||||
int type = 0;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonCdataBlock(%s, %d) called\n", ch, len);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "cdataBlock"))
|
||||
type = 1;
|
||||
@ -1222,10 +1145,6 @@ pythonExternalSubset(void *user_data,
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonExternalSubset(%s, %s, %s) called\n",
|
||||
name, externalID, systemID);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "externalSubset")) {
|
||||
result =
|
||||
@ -1371,10 +1290,6 @@ pythonInternalSubset(void *user_data, const xmlChar * name,
|
||||
PyObject *handler;
|
||||
PyObject *result;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
printf("pythonInternalSubset(%s, %s, %s) called\n",
|
||||
name, ExternalID, SystemID);
|
||||
#endif
|
||||
handler = (PyObject *) user_data;
|
||||
if (PyObject_HasAttrString(handler, (char *) "internalSubset")) {
|
||||
result = PyObject_CallMethod(handler, (char *) "internalSubset",
|
||||
@ -1444,10 +1359,6 @@ libxml_xmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self,
|
||||
&size, &URI))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlCreatePushParser(%p, %s, %d, %s) called\n",
|
||||
pyobj_SAX, chunk, size, URI);
|
||||
#endif
|
||||
if (pyobj_SAX != Py_None) {
|
||||
SAX = &pythonSaxHandler;
|
||||
Py_INCREF(pyobj_SAX);
|
||||
@ -1476,10 +1387,6 @@ libxml_htmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self,
|
||||
&size, &URI))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_htmlCreatePushParser(%p, %s, %d, %s) called\n",
|
||||
pyobj_SAX, chunk, size, URI);
|
||||
#endif
|
||||
if (pyobj_SAX != Py_None) {
|
||||
SAX = &pythonSaxHandler;
|
||||
Py_INCREF(pyobj_SAX);
|
||||
@ -1509,10 +1416,6 @@ libxml_xmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
&URI, &recover))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlSAXParseFile(%p, %s, %d) called\n",
|
||||
pyobj_SAX, URI, recover);
|
||||
#endif
|
||||
if (pyobj_SAX == Py_None) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1543,10 +1446,6 @@ libxml_htmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
&encoding))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_htmlSAXParseFile(%p, %s, %s) called\n",
|
||||
pyobj_SAX, URI, encoding);
|
||||
#endif
|
||||
if (pyobj_SAX == Py_None) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1607,11 +1506,6 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
|
||||
PyObject *result;
|
||||
char str[1000];
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
|
||||
#endif
|
||||
|
||||
|
||||
if (libxml_xmlPythonErrorFuncHandler == NULL) {
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, msg, ap);
|
||||
@ -1636,9 +1530,6 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
|
||||
static void
|
||||
libxml_xmlErrorInitialize(void)
|
||||
{
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlErrorInitialize() called\n");
|
||||
#endif
|
||||
xmlSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
|
||||
xmlThrDefSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
|
||||
}
|
||||
@ -1656,11 +1547,6 @@ libxml_xmlRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
|
||||
&pyobj_ctx))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlRegisterErrorHandler(%p, %p) called\n", pyobj_ctx,
|
||||
pyobj_f);
|
||||
#endif
|
||||
|
||||
if (libxml_xmlPythonErrorFuncHandler != NULL) {
|
||||
Py_XDECREF(libxml_xmlPythonErrorFuncHandler);
|
||||
}
|
||||
@ -1701,10 +1587,6 @@ libxml_xmlParserCtxtGenericErrorFuncHandler(void *ctx, int severity, char *str)
|
||||
xmlParserCtxtPtr ctxt;
|
||||
xmlParserCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlParserCtxtGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
|
||||
#endif
|
||||
|
||||
ctxt = (xmlParserCtxtPtr)ctx;
|
||||
pyCtxt = (xmlParserCtxtPyCtxtPtr)ctxt->_private;
|
||||
|
||||
@ -1891,10 +1773,6 @@ libxml_xmlValidCtxtGenericErrorFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sever
|
||||
PyObject *result;
|
||||
xmlValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlValidCtxtGenericErrorFuncHandler(%p, %d, %s, ...) called\n", ctx, severity, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlValidCtxtPyCtxtPtr)ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -1918,10 +1796,6 @@ libxml_xmlValidCtxtGenericWarningFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sev
|
||||
PyObject *result;
|
||||
xmlValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlValidCtxtGenericWarningFuncHandler(%p, %d, %s, ...) called\n", ctx, severity, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlValidCtxtPyCtxtPtr)ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -1973,10 +1847,6 @@ libxml_xmlSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
(args, (char *) "OOO|O:xmlSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
|
||||
#endif
|
||||
|
||||
ctxt = PyValidCtxt_Get(pyobj_ctx);
|
||||
pyCtxt = xmlMalloc(sizeof(xmlValidCtxtPyCtxt));
|
||||
if (pyCtxt == NULL) {
|
||||
@ -2229,10 +2099,6 @@ libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
return;
|
||||
name = rctxt->function;
|
||||
ns_uri = rctxt->functionURI;
|
||||
#ifdef DEBUG_XPATH
|
||||
printf("libxml_xmlXPathFuncCallback called name %s URI %s\n", name,
|
||||
ns_uri);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find the function, it should be there it was there at lookup
|
||||
@ -2271,10 +2137,6 @@ libxml_xmlXPathFuncLookupFunc(void *ctxt, const xmlChar * name,
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef DEBUG_XPATH
|
||||
printf("libxml_xmlXPathFuncLookupFunc(%p, %s, %s) called\n",
|
||||
ctxt, name, ns_uri);
|
||||
#endif
|
||||
/*
|
||||
* This is called once only. The address is then stored in the
|
||||
* XPath expression evaluation, the proper object to call can
|
||||
@ -2299,9 +2161,6 @@ libxml_xpathCallbacksInitialize(void)
|
||||
if (libxml_xpathCallbacksInitialized != 0)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_XPATH
|
||||
printf("libxml_xpathCallbacksInitialized called\n");
|
||||
#endif
|
||||
libxml_xpathCallbacks = (libxml_xpathCallbackArray*)xmlMalloc(
|
||||
libxml_xpathCallbacksAllocd*sizeof(libxml_xpathCallback));
|
||||
|
||||
@ -2341,10 +2200,6 @@ libxml_xmlRegisterXPathFunction(ATTRIBUTE_UNUSED PyObject * self,
|
||||
py_retval = libxml_intWrap(-1);
|
||||
return (py_retval);
|
||||
}
|
||||
#ifdef DEBUG_XPATH
|
||||
printf("libxml_registerXPathFunction(%p, %s, %s) called\n",
|
||||
ctx, name, ns_uri);
|
||||
#endif
|
||||
for (i = 0; i < libxml_xpathCallbacksNb; i++) {
|
||||
if ((ctx == (*libxml_xpathCallbacks)[i].ctx) &&
|
||||
(xmlStrEqual(name, (*libxml_xpathCallbacks)[i].name)) &&
|
||||
@ -2417,10 +2272,6 @@ libxml_name(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_name: cur = %p type %d\n", cur, cur->type);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:{
|
||||
@ -2461,10 +2312,6 @@ libxml_doc(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_doc: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
@ -2516,10 +2363,6 @@ libxml_next(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_next: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
@ -2557,10 +2400,6 @@ libxml_prev(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_prev: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
@ -2594,10 +2433,6 @@ libxml_children(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_children: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_ENTITY_REF_NODE:
|
||||
@ -2634,10 +2469,6 @@ libxml_last(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_last: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_ENTITY_REF_NODE:
|
||||
@ -2674,10 +2505,6 @@ libxml_parent(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return NULL;
|
||||
cur = PyxmlNode_Get(obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_parent: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
@ -2718,10 +2545,6 @@ libxml_type(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_type: cur = %p\n", cur);
|
||||
#endif
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
res = (const xmlChar *) "element";
|
||||
@ -2784,9 +2607,6 @@ libxml_type(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
res = (const xmlChar *) "xinclude_end";
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("libxml_type: cur = %p: %s\n", cur, res);
|
||||
#endif
|
||||
|
||||
resultobj = libxml_constxmlCharPtrWrap(res);
|
||||
return resultobj;
|
||||
@ -3060,9 +2880,6 @@ libxml_xmlNewNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
if (!PyArg_ParseTuple(args, (char *) "s:xmlNewNode", &name))
|
||||
return (NULL);
|
||||
node = (xmlNodePtr) xmlNewNode(NULL, name);
|
||||
#ifdef DEBUG
|
||||
printf("NewNode: %s : %p\n", name, (void *) node);
|
||||
#endif
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
@ -3094,10 +2911,6 @@ libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
ctxt->catalogs = xmlCatalogAddLocal(ctxt->catalogs, URL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("LocalCatalog: %s\n", URL);
|
||||
#endif
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
}
|
||||
@ -3125,10 +2938,6 @@ libxml_xmlRelaxNGValidityGenericErrorFuncHandler(void *ctx, char *str)
|
||||
PyObject *result;
|
||||
xmlRelaxNGValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlRelaxNGValidityGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlRelaxNGValidCtxtPyCtxtPtr)ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -3152,10 +2961,6 @@ libxml_xmlRelaxNGValidityGenericWarningFuncHandler(void *ctx, char *str)
|
||||
PyObject *result;
|
||||
xmlRelaxNGValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlRelaxNGValidityGenericWarningFuncHandler(%p, %s, ...) called\n", ctx, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlRelaxNGValidCtxtPyCtxtPtr)ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -3207,10 +3012,6 @@ libxml_xmlRelaxNGSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * arg
|
||||
(args, (char *) "OOO|O:xmlRelaxNGSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlRelaxNGSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
|
||||
#endif
|
||||
|
||||
ctxt = PyrelaxNgValidCtxt_Get(pyobj_ctx);
|
||||
if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == -1)
|
||||
{
|
||||
@ -3289,10 +3090,6 @@ libxml_xmlSchemaValidityGenericErrorFuncHandler(void *ctx, char *str)
|
||||
PyObject *result;
|
||||
xmlSchemaValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlSchemaValidityGenericErrorFuncHandler(%p, %s, ...) called\n", ctx, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlSchemaValidCtxtPyCtxtPtr) ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -3316,10 +3113,6 @@ libxml_xmlSchemaValidityGenericWarningFuncHandler(void *ctx, char *str)
|
||||
PyObject *result;
|
||||
xmlSchemaValidCtxtPyCtxtPtr pyCtxt;
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlSchemaValidityGenericWarningFuncHandler(%p, %s, ...) called\n", ctx, str);
|
||||
#endif
|
||||
|
||||
pyCtxt = (xmlSchemaValidCtxtPyCtxtPtr) ctx;
|
||||
|
||||
list = PyTuple_New(2);
|
||||
@ -3371,10 +3164,6 @@ libxml_xmlSchemaSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * args
|
||||
(args, (char *) "OOO|O:xmlSchemaSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
|
||||
return (NULL);
|
||||
|
||||
#ifdef DEBUG_ERROR
|
||||
printf("libxml_xmlSchemaSetValidErrors(%p, %p, %p) called\n", pyobj_ctx, pyobj_error, pyobj_warn);
|
||||
#endif
|
||||
|
||||
ctxt = PySchemaValidCtxt_Get(pyobj_ctx);
|
||||
if (xmlSchemaGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == -1)
|
||||
{
|
||||
|
120
python/types.c
120
python/types.c
@ -229,9 +229,6 @@ libxml_intWrap(int val)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_intWrap: val = %d\n", val);
|
||||
#endif
|
||||
ret = PY_IMPORT_INT((long) val);
|
||||
return (ret);
|
||||
}
|
||||
@ -241,9 +238,6 @@ libxml_longWrap(long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_longWrap: val = %ld\n", val);
|
||||
#endif
|
||||
ret = PyLong_FromLong(val);
|
||||
return (ret);
|
||||
}
|
||||
@ -253,9 +247,6 @@ libxml_doubleWrap(double val)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_doubleWrap: val = %f\n", val);
|
||||
#endif
|
||||
ret = PyFloat_FromDouble((double) val);
|
||||
return (ret);
|
||||
}
|
||||
@ -265,9 +256,6 @@ libxml_charPtrWrap(char *str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -282,9 +270,6 @@ libxml_charPtrConstWrap(const char *str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -298,9 +283,6 @@ libxml_xmlCharPtrWrap(xmlChar * str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -315,9 +297,6 @@ libxml_xmlCharPtrConstWrap(const xmlChar * str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -331,9 +310,6 @@ libxml_constcharPtrWrap(const char *str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -347,9 +323,6 @@ libxml_constxmlCharPtrWrap(const xmlChar * str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -363,9 +336,6 @@ libxml_xmlDocPtrWrap(xmlDocPtr doc)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlDocPtrWrap: doc = %p\n", doc);
|
||||
#endif
|
||||
if (doc == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -380,9 +350,6 @@ libxml_xmlNodePtrWrap(xmlNodePtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlNodePtrWrap: node = %p\n", node);
|
||||
#endif
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -396,9 +363,6 @@ libxml_xmlURIPtrWrap(xmlURIPtr uri)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlURIPtrWrap: uri = %p\n", uri);
|
||||
#endif
|
||||
if (uri == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -412,9 +376,6 @@ libxml_xmlNsPtrWrap(xmlNsPtr ns)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlNsPtrWrap: node = %p\n", ns);
|
||||
#endif
|
||||
if (ns == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -428,9 +389,6 @@ libxml_xmlAttrPtrWrap(xmlAttrPtr attr)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlAttrNodePtrWrap: attr = %p\n", attr);
|
||||
#endif
|
||||
if (attr == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -444,9 +402,6 @@ libxml_xmlAttributePtrWrap(xmlAttributePtr attr)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlAttributePtrWrap: attr = %p\n", attr);
|
||||
#endif
|
||||
if (attr == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -460,9 +415,6 @@ libxml_xmlElementPtrWrap(xmlElementPtr elem)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlElementNodePtrWrap: elem = %p\n", elem);
|
||||
#endif
|
||||
if (elem == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -476,9 +428,6 @@ libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlXPathContextPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -492,9 +441,6 @@ libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlXPathParserContextPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -508,9 +454,6 @@ libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -537,9 +480,6 @@ static void
|
||||
libxml_xmlXPathDestructNsNode(PyObject *cap)
|
||||
#endif
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cap);
|
||||
#endif
|
||||
#if PY_VERSION_HEX < 0x02070000
|
||||
xmlXPathNodeSetFreeNs((xmlNsPtr) cap);
|
||||
#else
|
||||
@ -552,9 +492,6 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlXPathObjectPtrWrap: ctxt = %p\n", obj);
|
||||
#endif
|
||||
if (obj == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -723,9 +660,6 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
|
||||
}
|
||||
#endif /* LIBXML_XPTR_LOCS_ENABLED */
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
printf("Unable to convert XPath object type %d\n", obj->type);
|
||||
#endif
|
||||
Py_INCREF(Py_None);
|
||||
ret = Py_None;
|
||||
}
|
||||
@ -738,9 +672,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
|
||||
{
|
||||
xmlXPathObjectPtr ret = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
|
||||
#endif
|
||||
if (obj == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
@ -807,9 +738,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
|
||||
|
||||
cur = NULL;
|
||||
if (PyCapsule_CheckExact(node)) {
|
||||
#ifdef DEBUG
|
||||
printf("Got a Capsule\n");
|
||||
#endif
|
||||
cur = PyxmlNode_Get(node);
|
||||
} else if ((PyObject_HasAttrString(node, (char *) "_o")) &&
|
||||
(PyObject_HasAttrString(node, (char *) "get_doc"))) {
|
||||
@ -819,9 +747,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
|
||||
if (wrapper != NULL)
|
||||
cur = PyxmlNode_Get(wrapper);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printf("Unknown object in Python return list\n");
|
||||
#endif
|
||||
}
|
||||
if (cur != NULL) {
|
||||
xmlXPathNodeSetAdd(set, cur);
|
||||
@ -829,9 +754,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
|
||||
}
|
||||
ret = xmlXPathWrapNodeSet(set);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printf("Unable to convert Python Object to XPath");
|
||||
#endif
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
@ -841,9 +763,6 @@ libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlValidCtxtPtrWrap: valid = %p\n", valid);
|
||||
#endif
|
||||
if (valid == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -861,9 +780,6 @@ libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlNodePtrWrap: catal = %p\n", catal);
|
||||
#endif
|
||||
if (catal == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -879,9 +795,6 @@ libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlOutputBufferPtrWrap: buffer = %p\n", buffer);
|
||||
#endif
|
||||
if (buffer == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -897,9 +810,6 @@ libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlParserInputBufferPtrWrap: buffer = %p\n", buffer);
|
||||
#endif
|
||||
if (buffer == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -916,9 +826,6 @@ libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlRegexpPtrWrap: regexp = %p\n", regexp);
|
||||
#endif
|
||||
if (regexp == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -936,9 +843,6 @@ libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlTextReaderPtrWrap: reader = %p\n", reader);
|
||||
#endif
|
||||
if (reader == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -954,9 +858,6 @@ libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlTextReaderLocatorPtrWrap: locator = %p\n", locator);
|
||||
#endif
|
||||
if (locator == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -974,9 +875,6 @@ libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlRelaxNGPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -992,9 +890,6 @@ libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlRelaxNGParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1009,9 +904,6 @@ libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlRelaxNGValidCtxtPtrWrap: valid = %p\n", valid);
|
||||
#endif
|
||||
if (valid == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1027,9 +919,6 @@ libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlSchemaPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1045,9 +934,6 @@ libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlSchemaParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
||||
#endif
|
||||
if (ctxt == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1064,9 +950,6 @@ libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlSchemaValidCtxtPtrWrap: valid = %p\n", valid);
|
||||
#endif
|
||||
if (valid == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
@ -1085,9 +968,6 @@ libxml_xmlErrorPtrWrap(xmlErrorPtr error)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlErrorPtrWrap: error = %p\n", error);
|
||||
#endif
|
||||
if (error == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return (Py_None);
|
||||
|
292
relaxng.c
292
relaxng.c
@ -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;
|
||||
|
11
threads.c
11
threads.c
@ -23,8 +23,6 @@
|
||||
#include "private/dict.h"
|
||||
#include "private/threads.h"
|
||||
|
||||
/* #define DEBUG_THREADS */
|
||||
|
||||
#if defined(HAVE_POSIX_THREADS) && \
|
||||
defined(__GLIBC__) && \
|
||||
__GLIBC__ * 100 + __GLIBC_MINOR__ >= 234
|
||||
@ -502,9 +500,6 @@ xmlIsMainThread(void)
|
||||
{
|
||||
xmlInitParser();
|
||||
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
|
||||
#endif
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
if (XML_IS_THREADED() == 0)
|
||||
return (1);
|
||||
@ -525,9 +520,6 @@ xmlIsMainThread(void)
|
||||
void
|
||||
xmlLockLibrary(void)
|
||||
{
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n");
|
||||
#endif
|
||||
xmlRMutexLock(xmlLibraryLock);
|
||||
}
|
||||
|
||||
@ -540,9 +532,6 @@ xmlLockLibrary(void)
|
||||
void
|
||||
xmlUnlockLibrary(void)
|
||||
{
|
||||
#ifdef DEBUG_THREADS
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n");
|
||||
#endif
|
||||
xmlRMutexUnlock(xmlLibraryLock);
|
||||
}
|
||||
|
||||
|
231
tree.c
231
tree.c
@ -142,9 +142,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 *
|
||||
@ -803,10 +800,6 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
|
||||
void
|
||||
xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
||||
if (node == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSetNs: node == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if ((node->type == XML_ELEMENT_NODE) ||
|
||||
@ -823,10 +816,6 @@ xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
||||
void
|
||||
xmlFreeNs(xmlNsPtr cur) {
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeNs : ns == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (cur->href != NULL) xmlFree((char *) cur->href);
|
||||
@ -844,10 +833,6 @@ void
|
||||
xmlFreeNsList(xmlNsPtr cur) {
|
||||
xmlNsPtr next;
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeNsList : ns == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
while (cur != NULL) {
|
||||
@ -875,12 +860,6 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
|
||||
xmlDtdPtr cur;
|
||||
|
||||
if ((doc != NULL) && (doc->extSubset != NULL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewDtd(%s): document %s already have a DTD %s\n",
|
||||
/* !!! */ (char *) name, doc->name,
|
||||
/* !!! */ (char *)doc->extSubset->name);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -949,12 +928,6 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
|
||||
xmlDtdPtr cur;
|
||||
|
||||
if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
|
||||
"xmlCreateIntSubset(): document %s already have an internal subset\n",
|
||||
doc->name);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -1208,10 +1181,6 @@ xmlFreeDoc(xmlDocPtr cur) {
|
||||
xmlDictPtr dict = NULL;
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFreeDoc : document == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1963,10 +1932,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);
|
||||
}
|
||||
|
||||
@ -1989,10 +1954,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);
|
||||
}
|
||||
|
||||
@ -2014,10 +1975,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);
|
||||
}
|
||||
|
||||
@ -2043,10 +2000,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);
|
||||
}
|
||||
|
||||
@ -2141,17 +2094,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;
|
||||
@ -2172,10 +2117,6 @@ xmlRemoveProp(xmlAttrPtr cur) {
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRemoveProp : attribute not owned by its node\n");
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -2193,10 +2134,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);
|
||||
}
|
||||
|
||||
@ -2258,10 +2195,6 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
|
||||
xmlNodePtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNode : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -2302,10 +2235,6 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
|
||||
xmlNodePtr cur;
|
||||
|
||||
if (name == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNewNode : name == NULL\n");
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -2524,18 +2453,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);
|
||||
}
|
||||
|
||||
@ -2959,18 +2880,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);
|
||||
}
|
||||
|
||||
@ -3087,25 +3000,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);
|
||||
}
|
||||
|
||||
@ -3167,25 +3068,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);
|
||||
}
|
||||
|
||||
@ -3247,26 +3136,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);
|
||||
}
|
||||
|
||||
@ -3325,27 +3202,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
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3417,26 +3282,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);
|
||||
}
|
||||
/*
|
||||
@ -3539,10 +3392,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);
|
||||
@ -3907,10 +3756,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)
|
||||
@ -3987,10 +3832,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)) {
|
||||
@ -4001,17 +3842,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);
|
||||
@ -4064,10 +3897,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);
|
||||
@ -5770,10 +5599,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) {
|
||||
@ -5843,10 +5668,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) {
|
||||
@ -5913,10 +5734,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;
|
||||
@ -5987,10 +5804,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;
|
||||
@ -6356,17 +6169,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);
|
||||
}
|
||||
/*
|
||||
@ -7113,10 +6918,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 */
|
||||
@ -7255,10 +7056,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;
|
||||
@ -7278,10 +7075,6 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||
void
|
||||
xmlBufferFree(xmlBufferPtr buf) {
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlBufferFree: buf == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7425,17 +7218,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)
|
||||
@ -7617,10 +7402,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;
|
||||
@ -7669,17 +7450,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;
|
||||
@ -7804,10 +7577,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){
|
||||
|
195
valid.c
195
valid.c
@ -29,8 +29,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 +463,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 +681,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 +4742,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 +4757,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 +4768,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 +4789,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 +4810,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 +4825,6 @@ cont:
|
||||
(NODE->type != XML_TEXT_NODE) &&
|
||||
(NODE->type != XML_CDATA_SECTION_NODE)));
|
||||
} else {
|
||||
DEBUG_VALID_MSG("element failed");
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
@ -5017,7 +4857,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 +4898,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 +4912,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 +4921,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 +4981,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 +5010,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 +5021,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 +5260,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) {
|
||||
|
39
xinclude.c
39
xinclude.c
@ -34,13 +34,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 +215,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 +237,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");
|
||||
@ -298,9 +285,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));
|
||||
@ -328,9 +312,6 @@ void
|
||||
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
|
||||
int i;
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Freeing context\n");
|
||||
#endif
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
if (ctxt->urlTab != NULL) {
|
||||
@ -457,9 +438,6 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
|
||||
if (cur == NULL)
|
||||
return(NULL);
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "Add node\n");
|
||||
#endif
|
||||
/*
|
||||
* read the attributes
|
||||
*/
|
||||
@ -1265,9 +1243,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
|
||||
*/
|
||||
@ -1308,9 +1283,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);
|
||||
@ -1326,9 +1298,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
|
||||
@ -1987,11 +1956,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)
|
||||
@ -2017,9 +1981,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) &&
|
||||
|
104
xmlIO.c
104
xmlIO.c
@ -70,14 +70,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
|
||||
@ -1449,23 +1443,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;
|
||||
@ -1563,15 +1545,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;
|
||||
@ -1992,57 +1965,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 ) )
|
||||
@ -3229,11 +3151,6 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -3323,11 +3240,6 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
||||
if (res < 0)
|
||||
return(-1);
|
||||
}
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"I/O: read %d chars, buffer %d\n",
|
||||
nbchars, xmlBufUse(in->buffer));
|
||||
#endif
|
||||
return(res);
|
||||
}
|
||||
|
||||
@ -3453,10 +3365,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);
|
||||
}
|
||||
|
||||
@ -3653,10 +3561,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);
|
||||
}
|
||||
|
||||
@ -3744,10 +3648,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 */
|
||||
@ -3998,10 +3898,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;
|
||||
|
||||
|
82
xmlmemory.c
82
xmlmemory.c
@ -12,8 +12,6 @@
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
/* #define DEBUG_MEMORY */
|
||||
|
||||
/**
|
||||
* MEM_LIST:
|
||||
*
|
||||
@ -150,10 +148,6 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
||||
void *ret;
|
||||
|
||||
xmlInitParser();
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d)\n",size);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
@ -185,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);
|
||||
@ -224,10 +213,6 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
||||
void *ret;
|
||||
|
||||
xmlInitParser();
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d)\n",size);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
@ -259,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);
|
||||
@ -311,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));
|
||||
@ -332,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
|
||||
@ -376,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:
|
||||
@ -412,9 +382,6 @@ xmlMemFree(void *ptr)
|
||||
{
|
||||
MEMHDR *p;
|
||||
char *target;
|
||||
#ifdef DEBUG_MEMORY
|
||||
size_t size;
|
||||
#endif
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
@ -446,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
|
||||
@ -458,11 +422,6 @@ xmlMemFree(void *ptr)
|
||||
|
||||
TEST_POINT
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Freed(%d) Ok\n", size);
|
||||
#endif
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
@ -753,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)
|
||||
@ -766,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
|
||||
@ -894,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");
|
||||
@ -909,10 +856,6 @@ xmlInitMemoryInternal(void) {
|
||||
sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlInitMemory() Ok\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -935,16 +878,7 @@ xmlCleanupMemory(void) {
|
||||
*/
|
||||
void
|
||||
xmlCleanupMemoryInternal(void) {
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlCleanupMemory()\n");
|
||||
#endif
|
||||
|
||||
xmlCleanupMutex(&xmlMemMutex);
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlCleanupMemory() Ok\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -965,10 +899,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)
|
||||
@ -982,10 +912,6 @@ xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
||||
xmlMallocAtomic = mallocFunc;
|
||||
xmlRealloc = reallocFunc;
|
||||
xmlMemStrdup = strdupFunc;
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMemSetup() Ok\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -1032,10 +958,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)
|
||||
@ -1051,10 +973,6 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
||||
xmlMallocAtomic = mallocAtomicFunc;
|
||||
xmlRealloc = reallocFunc;
|
||||
xmlMemStrdup = strdupFunc;
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlGcMemSetup() Ok\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
60
xmlreader.c
60
xmlreader.c
@ -77,9 +77,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_CALLBACKS */
|
||||
/* #define DEBUG_READER */
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
*
|
||||
@ -90,12 +87,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 +496,6 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
|
||||
* The reader core parser *
|
||||
* *
|
||||
************************************************************************/
|
||||
#ifdef DEBUG_READER
|
||||
static void
|
||||
xmlTextReaderDebug(xmlTextReaderPtr reader) {
|
||||
if ((reader == NULL) || (reader->ctxt == NULL)) {
|
||||
fprintf(stderr, "xmlTextReader NULL\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "xmlTextReader: state %d depth %d ",
|
||||
reader->state, reader->depth);
|
||||
if (reader->node == NULL) {
|
||||
fprintf(stderr, "node = NULL\n");
|
||||
} else {
|
||||
fprintf(stderr, "node %s\n", reader->node->name);
|
||||
}
|
||||
fprintf(stderr, " input: base %d, cur %d, depth %d: ",
|
||||
reader->base, reader->cur, reader->ctxt->nodeNr);
|
||||
if (reader->input->buffer == NULL) {
|
||||
fprintf(stderr, "buffer is NULL\n");
|
||||
} else {
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
xmlDebugDumpString(stderr,
|
||||
&reader->input->buffer->content[reader->cur]);
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlTextReaderEntPush:
|
||||
@ -602,9 +566,6 @@ xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderStartElement(%s)\n", fullname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->startElement != NULL)) {
|
||||
reader->startElement(ctx, fullname, atts);
|
||||
if ((ctxt->node != NULL) && (ctxt->input != NULL) &&
|
||||
@ -628,9 +589,6 @@ xmlTextReaderEndElement(void *ctx, const xmlChar *fullname) {
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderEndElement(%s)\n", fullname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->endElement != NULL)) {
|
||||
reader->endElement(ctx, fullname);
|
||||
}
|
||||
@ -665,9 +623,6 @@ xmlTextReaderStartElementNs(void *ctx,
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderStartElementNs(%s)\n", localname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->startElementNs != NULL)) {
|
||||
reader->startElementNs(ctx, localname, prefix, URI, nb_namespaces,
|
||||
namespaces, nb_attributes, nb_defaulted,
|
||||
@ -699,9 +654,6 @@ xmlTextReaderEndElementNs(void *ctx,
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderEndElementNs(%s)\n", localname);
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->endElementNs != NULL)) {
|
||||
reader->endElementNs(ctx, localname, prefix, URI);
|
||||
}
|
||||
@ -722,9 +674,6 @@ xmlTextReaderCharacters(void *ctx, const xmlChar *ch, int len)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderCharacters()\n");
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->characters != NULL)) {
|
||||
reader->characters(ctx, ch, len);
|
||||
}
|
||||
@ -744,9 +693,6 @@ xmlTextReaderCDataBlock(void *ctx, const xmlChar *ch, int len)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlTextReaderPtr reader = ctxt->_private;
|
||||
|
||||
#ifdef DEBUG_CALLBACKS
|
||||
printf("xmlTextReaderCDataBlock()\n");
|
||||
#endif
|
||||
if ((reader != NULL) && (reader->cdataBlock != NULL)) {
|
||||
reader->cdataBlock(ctx, ch, len);
|
||||
}
|
||||
@ -1230,10 +1176,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 +1367,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
|
||||
*/
|
||||
|
440
xmlregexp.c
440
xmlregexp.c
@ -19,8 +19,6 @@
|
||||
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
|
||||
/* #define DEBUG_ERR */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
@ -38,11 +36,6 @@
|
||||
#define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_REGEXP_GRAPH */
|
||||
/* #define DEBUG_REGEXP_EXEC */
|
||||
/* #define DEBUG_PUSH */
|
||||
/* #define DEBUG_COMPACTION */
|
||||
|
||||
#define MAX_PUSH 10000000
|
||||
|
||||
#ifdef ERROR
|
||||
@ -513,9 +506,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
|
||||
stateRemap[i] = -1;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_COMPACTION
|
||||
printf("Final: %d states\n", nbstates);
|
||||
#endif
|
||||
stringMap = xmlMalloc(ret->nbAtoms * sizeof(char *));
|
||||
if (stringMap == NULL) {
|
||||
xmlRegexpErrMemory(ctxt, "compiling regexp");
|
||||
@ -565,9 +555,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_COMPACTION
|
||||
printf("Final: %d atoms\n", nbatoms);
|
||||
#endif
|
||||
transitions = (int *) xmlRegCalloc2(nbstates + 1, nbatoms + 1,
|
||||
sizeof(int));
|
||||
if (transitions == NULL) {
|
||||
@ -621,11 +608,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
|
||||
if (prev != 0) {
|
||||
if (prev != targetno + 1) {
|
||||
ret->determinist = 0;
|
||||
#ifdef DEBUG_COMPACTION
|
||||
printf("Indet: state %d trans %d, atom %d to %d : %d to %d\n",
|
||||
i, j, trans->atom->no, trans->to, atomno, targetno);
|
||||
printf(" previous to is %d\n", prev);
|
||||
#endif
|
||||
if (transdata != NULL)
|
||||
xmlFree(transdata);
|
||||
xmlFree(transitions);
|
||||
@ -650,18 +632,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
|
||||
}
|
||||
}
|
||||
ret->determinist = 1;
|
||||
#ifdef DEBUG_COMPACTION
|
||||
/*
|
||||
* Debug
|
||||
*/
|
||||
for (i = 0;i < nbstates;i++) {
|
||||
for (j = 0;j < nbatoms + 1;j++) {
|
||||
printf("%02d ", transitions[i * (nbatoms + 1) + j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
/*
|
||||
* Cleanup of the old data
|
||||
*/
|
||||
@ -1191,48 +1161,6 @@ xmlRegPrintState(FILE *output, xmlRegStatePtr state) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
static void
|
||||
xmlRegPrintCtxt(FILE *output, xmlRegParserCtxtPtr ctxt) {
|
||||
int i;
|
||||
|
||||
fprintf(output, " ctxt: ");
|
||||
if (ctxt == NULL) {
|
||||
fprintf(output, "NULL\n");
|
||||
return;
|
||||
}
|
||||
fprintf(output, "'%s' ", ctxt->string);
|
||||
if (ctxt->error)
|
||||
fprintf(output, "error ");
|
||||
if (ctxt->neg)
|
||||
fprintf(output, "neg ");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "%d atoms:\n", ctxt->nbAtoms);
|
||||
for (i = 0;i < ctxt->nbAtoms; i++) {
|
||||
fprintf(output, " %02d ", i);
|
||||
xmlRegPrintAtom(output, ctxt->atoms[i]);
|
||||
}
|
||||
if (ctxt->atom != NULL) {
|
||||
fprintf(output, "current atom:\n");
|
||||
xmlRegPrintAtom(output, ctxt->atom);
|
||||
}
|
||||
fprintf(output, "%d states:", ctxt->nbStates);
|
||||
if (ctxt->start != NULL)
|
||||
fprintf(output, " start: %d", ctxt->start->no);
|
||||
if (ctxt->end != NULL)
|
||||
fprintf(output, " end: %d", ctxt->end->no);
|
||||
fprintf(output, "\n");
|
||||
for (i = 0;i < ctxt->nbStates; i++) {
|
||||
xmlRegPrintState(output, ctxt->states[i]);
|
||||
}
|
||||
fprintf(output, "%d counters:\n", ctxt->nbCounters);
|
||||
for (i = 0;i < ctxt->nbCounters; i++) {
|
||||
fprintf(output, " %d: min %d max %d\n", i, ctxt->counters[i].min,
|
||||
ctxt->counters[i].max);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Finite Automata structures manipulations *
|
||||
@ -1389,10 +1317,6 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||
(trans->to == target->no) &&
|
||||
(trans->counter == counter) &&
|
||||
(trans->count == count)) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Ignoring duplicate transition from %d to %d\n",
|
||||
state->no, target->no);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1418,19 +1342,6 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||
}
|
||||
state->trans = tmp;
|
||||
}
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Add trans from %d to %d ", state->no, target->no);
|
||||
if (count == REGEXP_ALL_COUNTER)
|
||||
printf("all transition\n");
|
||||
else if (count >= 0)
|
||||
printf("count based %d\n", count);
|
||||
else if (counter >= 0)
|
||||
printf("counted %d\n", counter);
|
||||
else if (atom == NULL)
|
||||
printf("epsilon transition\n");
|
||||
else if (atom != NULL)
|
||||
xmlRegPrintAtom(stdout, atom);
|
||||
#endif
|
||||
|
||||
state->trans[state->nbTrans].atom = atom;
|
||||
state->trans[state->nbTrans].to = target->no;
|
||||
@ -1800,9 +1711,6 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
|
||||
xmlRegStatePtr from;
|
||||
xmlRegStatePtr to;
|
||||
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("xmlFAReduceEpsilonTransitions(%d, %d)\n", fromnr, tonr);
|
||||
#endif
|
||||
from = ctxt->states[fromnr];
|
||||
if (from == NULL)
|
||||
return;
|
||||
@ -1815,9 +1723,6 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
|
||||
|
||||
to->mark = XML_REGEXP_MARK_VISITED;
|
||||
if (to->type == XML_REGEXP_FINAL_STATE) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("State %d is final, so %d becomes final\n", tonr, fromnr);
|
||||
#endif
|
||||
from->type = XML_REGEXP_FINAL_STATE;
|
||||
}
|
||||
for (transnr = 0;transnr < to->nbTrans;transnr++) {
|
||||
@ -1842,10 +1747,6 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
|
||||
xmlRegStateAddTrans(ctxt, from, NULL, ctxt->states[t1->to],
|
||||
-1, t1->count);
|
||||
} else {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Found epsilon trans %d from %d to %d\n",
|
||||
transnr, tonr, t1->to);
|
||||
#endif
|
||||
xmlFAReduceEpsilonTransitions(ctxt, fromnr, t1->to,
|
||||
tcounter);
|
||||
}
|
||||
@ -1929,23 +1830,11 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
||||
newto = state->trans[0].to;
|
||||
|
||||
if (state->type == XML_REGEXP_START_STATE) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Found simple epsilon trans from start %d to %d\n",
|
||||
statenr, newto);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Found simple epsilon trans from %d to %d\n",
|
||||
statenr, newto);
|
||||
#endif
|
||||
for (i = 0;i < state->nbTransTo;i++) {
|
||||
tmp = ctxt->states[state->transTo[i]];
|
||||
for (j = 0;j < tmp->nbTrans;j++) {
|
||||
if (tmp->trans[j].to == statenr) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Changed transition %d on %d to go to %d\n",
|
||||
j, tmp->no, newto);
|
||||
#endif
|
||||
tmp->trans[j].to = -1;
|
||||
xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom,
|
||||
ctxt->states[newto],
|
||||
@ -1987,9 +1876,6 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
||||
for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
|
||||
state = ctxt->states[statenr];
|
||||
if ((state != NULL) && (state->type == XML_REGEXP_UNREACH_STATE)) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Removed unreachable state %d\n", statenr);
|
||||
#endif
|
||||
xmlRegFreeState(state);
|
||||
ctxt->states[statenr] = NULL;
|
||||
}
|
||||
@ -2018,17 +1904,9 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
||||
(state->trans[transnr].to >= 0)) {
|
||||
if (state->trans[transnr].to == statenr) {
|
||||
state->trans[transnr].to = -1;
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Removed loopback epsilon trans %d on %d\n",
|
||||
transnr, statenr);
|
||||
#endif
|
||||
} else if (state->trans[transnr].count < 0) {
|
||||
int newto = state->trans[transnr].to;
|
||||
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Found epsilon trans %d from %d to %d\n",
|
||||
transnr, statenr, newto);
|
||||
#endif
|
||||
has_epsilon = 1;
|
||||
state->trans[transnr].to = -2;
|
||||
state->mark = XML_REGEXP_MARK_START;
|
||||
@ -2036,11 +1914,6 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
||||
newto, state->trans[transnr].counter);
|
||||
xmlFAFinishReduceEpsilonTransitions(ctxt, newto);
|
||||
state->mark = XML_REGEXP_MARK_NORMAL;
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
} else {
|
||||
printf("Found counted transition %d on %d\n",
|
||||
transnr, statenr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2114,9 +1987,6 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
|
||||
for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
|
||||
state = ctxt->states[statenr];
|
||||
if ((state != NULL) && (state->reached == XML_REGEXP_MARK_NORMAL)) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("Removed unreachable state %d\n", statenr);
|
||||
#endif
|
||||
xmlRegFreeState(state);
|
||||
ctxt->states[statenr] = NULL;
|
||||
}
|
||||
@ -2732,10 +2602,6 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
|
||||
int ret = 1;
|
||||
int deep = 1;
|
||||
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("xmlFAComputesDeterminism\n");
|
||||
xmlRegPrintCtxt(stdout, ctxt);
|
||||
#endif
|
||||
if (ctxt->determinist != -1)
|
||||
return(ctxt->determinist);
|
||||
|
||||
@ -3166,31 +3032,8 @@ xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) {
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
static void
|
||||
xmlFARegDebugExec(xmlRegExecCtxtPtr exec) {
|
||||
printf("state: %d:%d:idx %d", exec->state->no, exec->transno, exec->index);
|
||||
if (exec->inputStack != NULL) {
|
||||
int i;
|
||||
printf(": ");
|
||||
for (i = 0;(i < 3) && (i < exec->inputStackNr);i++)
|
||||
printf("%s ", (const char *)
|
||||
exec->inputStack[exec->inputStackNr - (i + 1)].value);
|
||||
} else {
|
||||
printf(": %s", &(exec->inputString[exec->index]));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("saving ");
|
||||
exec->transno++;
|
||||
xmlFARegDebugExec(exec);
|
||||
exec->transno--;
|
||||
#endif
|
||||
#ifdef MAX_PUSH
|
||||
if (exec->nbPush > MAX_PUSH) {
|
||||
return;
|
||||
@ -3248,9 +3091,6 @@ static void
|
||||
xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
|
||||
if (exec->nbRollbacks <= 0) {
|
||||
exec->status = -1;
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("rollback failed on empty stack\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
exec->nbRollbacks--;
|
||||
@ -3268,11 +3108,6 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
|
||||
exec->comp->nbCounters * sizeof(int));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("restored ");
|
||||
xmlFARegDebugExec(exec);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -3363,10 +3198,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
|
||||
count = exec->counts[trans->count];
|
||||
counter = &exec->comp->counters[trans->count];
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("testing count %d: val %d, min %d, max %d\n",
|
||||
trans->count, count, counter->min, counter->max);
|
||||
#endif
|
||||
ret = ((count >= counter->min) && (count <= counter->max));
|
||||
if ((ret) && (counter->min != counter->max))
|
||||
deter = 0;
|
||||
@ -3404,9 +3235,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
xmlFARegExecSave(exec);
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("Increasing count %d\n", trans->counter);
|
||||
#endif
|
||||
exec->counts[trans->counter]++;
|
||||
}
|
||||
exec->transcount = 1;
|
||||
@ -3460,9 +3288,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
exec->status = -1;
|
||||
goto error;
|
||||
}
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("Decreasing count %d\n", trans->counter);
|
||||
#endif
|
||||
exec->counts[trans->counter]--;
|
||||
}
|
||||
} else if ((ret == 0) && (atom->min == 0) && (atom->max > 0)) {
|
||||
@ -3485,14 +3310,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
if ((trans->nd == 1) ||
|
||||
((trans->count >= 0) && (deter == 0) &&
|
||||
(exec->state->nbTrans > exec->transno + 1))) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
if (trans->nd == 1)
|
||||
printf("Saving on nd transition atom %d for %c at %d\n",
|
||||
trans->atom->no, codepoint, exec->index);
|
||||
else
|
||||
printf("Saving on counted transition count %d for %c at %d\n",
|
||||
trans->count, codepoint, exec->index);
|
||||
#endif
|
||||
xmlFARegExecSave(exec);
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
@ -3508,9 +3325,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
counter = &exec->comp->counters[trans->counter];
|
||||
if (exec->counts[trans->counter] >= counter->max)
|
||||
continue; /* for loop on transitions */
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("Increasing count %d\n", trans->counter);
|
||||
#endif
|
||||
exec->counts[trans->counter]++;
|
||||
}
|
||||
if ((trans->count >= 0) &&
|
||||
@ -3519,15 +3333,8 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
exec->status = -1;
|
||||
goto error;
|
||||
}
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("resetting count %d on transition\n",
|
||||
trans->count);
|
||||
#endif
|
||||
exec->counts[trans->count] = 0;
|
||||
}
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("entering state %d\n", trans->to);
|
||||
#endif
|
||||
exec->state = comp->states[trans->to];
|
||||
exec->transno = 0;
|
||||
if (trans->atom != NULL) {
|
||||
@ -3545,10 +3352,6 @@ rollback:
|
||||
* Failed to find a way out
|
||||
*/
|
||||
exec->determinist = 0;
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("rollback from state %d on %d:%c\n", exec->state->no,
|
||||
codepoint,codepoint);
|
||||
#endif
|
||||
xmlFARegExecRollBack(exec);
|
||||
}
|
||||
progress:
|
||||
@ -3584,9 +3387,6 @@ error:
|
||||
* Progressive interface to the verifier one atom at a time *
|
||||
* *
|
||||
************************************************************************/
|
||||
#ifdef DEBUG_ERR
|
||||
static void testerr(xmlRegExecCtxtPtr exec);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlRegNewExecCtxt:
|
||||
@ -3694,9 +3494,6 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
|
||||
static void
|
||||
xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
void *data) {
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("saving value: %d:%s\n", exec->inputStackNr, value);
|
||||
#endif
|
||||
if (exec->inputStackMax == 0) {
|
||||
exec->inputStackMax = 4;
|
||||
exec->inputStack = (xmlRegInputTokenPtr)
|
||||
@ -3809,10 +3606,6 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value pushed: %s\n", value);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Examine all outside transitions from current state
|
||||
*/
|
||||
@ -3826,9 +3619,6 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
|
||||
exec->callback(exec->data, value,
|
||||
comp->transdata[state * comp->nbstrings + i], data);
|
||||
}
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("entering state %d\n", target);
|
||||
#endif
|
||||
if (comp->compact[target * (comp->nbstrings + 1)] ==
|
||||
XML_REGEXP_SINK_STATE)
|
||||
goto error;
|
||||
@ -3844,18 +3634,12 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
|
||||
* Failed to find an exit transition out from current state for the
|
||||
* current token
|
||||
*/
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("failed to find a transition for %s on state %d\n", value, state);
|
||||
#endif
|
||||
error:
|
||||
if (exec->errString != NULL)
|
||||
xmlFree(exec->errString);
|
||||
exec->errString = xmlStrdup(value);
|
||||
exec->errStateNo = state;
|
||||
exec->status = -1;
|
||||
#ifdef DEBUG_ERR
|
||||
testerr(exec);
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -3896,9 +3680,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
final = 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value pushed: %s\n", value);
|
||||
#endif
|
||||
/*
|
||||
* If we have an active rollback stack push the new value there
|
||||
* and get back to where we were left
|
||||
@ -3907,9 +3688,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
xmlFARegExecSaveInputString(exec, value, data);
|
||||
value = exec->inputStack[exec->index].value;
|
||||
data = exec->inputStack[exec->index].data;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value loaded: %s\n", value);
|
||||
#endif
|
||||
}
|
||||
|
||||
while ((exec->status == 0) &&
|
||||
@ -3940,9 +3718,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
|
||||
ret = 0;
|
||||
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("testing all lax %d\n", trans->count);
|
||||
#endif
|
||||
/*
|
||||
* Check all counted transitions from the current state
|
||||
*/
|
||||
@ -3978,9 +3753,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
|
||||
ret = 1;
|
||||
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("testing all %d\n", trans->count);
|
||||
#endif
|
||||
/*
|
||||
* Check all counted transitions from the current state
|
||||
*/
|
||||
@ -4005,10 +3777,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
|
||||
count = exec->counts[trans->count];
|
||||
counter = &exec->comp->counters[trans->count];
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("testing count %d: val %d, min %d, max %d\n",
|
||||
trans->count, count, counter->min, counter->max);
|
||||
#endif
|
||||
ret = ((count >= counter->min) && (count <= counter->max));
|
||||
} else if (atom == NULL) {
|
||||
fprintf(stderr, "epsilon transition left at runtime\n");
|
||||
@ -4054,9 +3822,6 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
exec->index++;
|
||||
value = exec->inputStack[exec->index].value;
|
||||
data = exec->inputStack[exec->index].data;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value loaded: %s\n", value);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* End of input: stop here
|
||||
@ -4111,22 +3876,12 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
xmlFARegExecSave(exec);
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("Increasing count %d\n", trans->counter);
|
||||
#endif
|
||||
exec->counts[trans->counter]++;
|
||||
}
|
||||
if ((trans->count >= 0) &&
|
||||
(trans->count < REGEXP_ALL_COUNTER)) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("resetting count %d on transition\n",
|
||||
trans->count);
|
||||
#endif
|
||||
exec->counts[trans->count] = 0;
|
||||
}
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("entering state %d\n", trans->to);
|
||||
#endif
|
||||
if ((exec->comp->states[trans->to] != NULL) &&
|
||||
(exec->comp->states[trans->to]->type ==
|
||||
XML_REGEXP_SINK_STATE)) {
|
||||
@ -4149,22 +3904,13 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
if (exec->index < exec->inputStackNr) {
|
||||
value = exec->inputStack[exec->index].value;
|
||||
data = exec->inputStack[exec->index].data;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value loaded: %s\n", value);
|
||||
#endif
|
||||
} else {
|
||||
value = NULL;
|
||||
data = NULL;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("end of input\n");
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
value = NULL;
|
||||
data = NULL;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("end of input\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
goto progress;
|
||||
@ -4199,9 +3945,6 @@ rollback:
|
||||
if ((exec->inputStack != NULL ) && (exec->status == 0)) {
|
||||
value = exec->inputStack[exec->index].value;
|
||||
data = exec->inputStack[exec->index].data;
|
||||
#ifdef DEBUG_PUSH
|
||||
printf("value loaded: %s\n", value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@ -4212,11 +3955,6 @@ progress:
|
||||
if (exec->status == 0) {
|
||||
return(exec->state->type == XML_REGEXP_FINAL_STATE);
|
||||
}
|
||||
#ifdef DEBUG_ERR
|
||||
if (exec->status < 0) {
|
||||
testerr(exec);
|
||||
}
|
||||
#endif
|
||||
return(exec->status);
|
||||
}
|
||||
|
||||
@ -4509,17 +4247,6 @@ xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string,
|
||||
return(xmlRegExecGetValues(exec, 1, nbval, nbneg, values, terminal));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ERR
|
||||
static void testerr(xmlRegExecCtxtPtr exec) {
|
||||
const xmlChar *string;
|
||||
xmlChar *values[5];
|
||||
int nb = 5;
|
||||
int nbneg;
|
||||
int terminal;
|
||||
xmlRegExecErrInfo(exec, &string, &nb, &nbneg, &values[0], &terminal);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int
|
||||
xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
|
||||
@ -4562,10 +4289,6 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
|
||||
|
||||
count = exec->counts[trans->count];
|
||||
counter = &exec->comp->counters[trans->count];
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("testing count %d: val %d, min %d, max %d\n",
|
||||
trans->count, count, counter->min, counter->max);
|
||||
#endif
|
||||
ret = ((count >= counter->min) && (count <= counter->max));
|
||||
} else if (atom == NULL) {
|
||||
fprintf(stderr, "epsilon transition left at runtime\n");
|
||||
@ -4639,20 +4362,11 @@ xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
|
||||
* restart count for expressions like this ((abc){2})*
|
||||
*/
|
||||
if (trans->count >= 0) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("Reset count %d\n", trans->count);
|
||||
#endif
|
||||
exec->counts[trans->count] = 0;
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("Increasing count %d\n", trans->counter);
|
||||
#endif
|
||||
exec->counts[trans->counter]++;
|
||||
}
|
||||
#ifdef DEBUG_REGEXP_EXEC
|
||||
printf("entering state %d\n", trans->to);
|
||||
#endif
|
||||
exec->state = exec->comp->states[trans->to];
|
||||
exec->transno = 0;
|
||||
if (trans->atom != NULL) {
|
||||
@ -5574,9 +5288,6 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
|
||||
ctxt->end = NULL;
|
||||
xmlFAParseBranch(ctxt, NULL);
|
||||
if (top) {
|
||||
#ifdef DEBUG_REGEXP_GRAPH
|
||||
printf("State %d is final\n", ctxt->state->no);
|
||||
#endif
|
||||
ctxt->state->type = XML_REGEXP_FINAL_STATE;
|
||||
}
|
||||
if (CUR != '|') {
|
||||
@ -6638,8 +6349,6 @@ xmlExpFreeCtxt(xmlExpCtxtPtr ctxt) {
|
||||
************************************************************************/
|
||||
#define MAX_NODES 10000
|
||||
|
||||
/* #define DEBUG_DERIV */
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - Wildcards
|
||||
@ -7314,14 +7023,8 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
|
||||
return(forbiddenExp);
|
||||
case XML_EXP_ATOM:
|
||||
if (exp->exp_str == str) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv atom: equal => Empty\n");
|
||||
#endif
|
||||
ret = emptyExp;
|
||||
} else {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv atom: mismatch => forbid\n");
|
||||
#endif
|
||||
/* TODO wildcards here */
|
||||
ret = forbiddenExp;
|
||||
}
|
||||
@ -7329,9 +7032,6 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
|
||||
case XML_EXP_OR: {
|
||||
xmlExpNodePtr tmp;
|
||||
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv or: => or(derivs)\n");
|
||||
#endif
|
||||
tmp = xmlExpStringDeriveInt(ctxt, exp->exp_left, str);
|
||||
if (tmp == NULL) {
|
||||
return(NULL);
|
||||
@ -7346,23 +7046,14 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
|
||||
return(ret);
|
||||
}
|
||||
case XML_EXP_SEQ:
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv seq: starting with left\n");
|
||||
#endif
|
||||
ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str);
|
||||
if (ret == NULL) {
|
||||
return(NULL);
|
||||
} else if (ret == forbiddenExp) {
|
||||
if (IS_NILLABLE(exp->exp_left)) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv seq: left failed but nillable\n");
|
||||
#endif
|
||||
ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str);
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv seq: left match => sequence\n");
|
||||
#endif
|
||||
exp->exp_right->ref++;
|
||||
ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right,
|
||||
NULL, 0, 0);
|
||||
@ -7378,9 +7069,6 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
if (ret == forbiddenExp) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv count: pattern mismatch => forbid\n");
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
if (exp->exp_max == 1)
|
||||
@ -7397,14 +7085,8 @@ xmlExpStringDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, const xmlChar *str)
|
||||
tmp = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL,
|
||||
NULL, min, max);
|
||||
if (ret == emptyExp) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv count: match to empty => new count\n");
|
||||
#endif
|
||||
return(tmp);
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("deriv count: match => sequence with new count\n");
|
||||
#endif
|
||||
return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, tmp,
|
||||
NULL, 0, 0));
|
||||
}
|
||||
@ -7513,17 +7195,11 @@ xmlExpDivide(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub,
|
||||
*mult = tmp;
|
||||
else
|
||||
xmlExpFree(ctxt, tmp);
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Divide succeeded %d\n", i);
|
||||
#endif
|
||||
return(i);
|
||||
}
|
||||
xmlExpFree(ctxt, tmp);
|
||||
xmlExpFree(ctxt, tmp2);
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Divide failed\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -7549,25 +7225,16 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
* amount, then the derivation is empty
|
||||
*/
|
||||
if ((exp == sub) && (exp->c_max >= 0)) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Equal(exp, sub) and finite -> Empty\n");
|
||||
#endif
|
||||
return(emptyExp);
|
||||
}
|
||||
/*
|
||||
* decompose sub sequence first
|
||||
*/
|
||||
if (sub->type == XML_EXP_EMPTY) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Empty(sub) -> Empty\n");
|
||||
#endif
|
||||
exp->ref++;
|
||||
return(exp);
|
||||
}
|
||||
if (sub->type == XML_EXP_SEQ) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Seq(sub) -> decompose\n");
|
||||
#endif
|
||||
tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left);
|
||||
if (tmp == NULL)
|
||||
return(NULL);
|
||||
@ -7578,9 +7245,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
return(ret);
|
||||
}
|
||||
if (sub->type == XML_EXP_OR) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Or(sub) -> decompose\n");
|
||||
#endif
|
||||
tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left);
|
||||
if (tmp == forbiddenExp)
|
||||
return(tmp);
|
||||
@ -7594,36 +7258,21 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
return(xmlExpHashGetEntry(ctxt, XML_EXP_OR, tmp, ret, NULL, 0, 0));
|
||||
}
|
||||
if (!xmlExpCheckCard(exp, sub)) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("CheckCard(exp, sub) failed -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
switch (exp->type) {
|
||||
case XML_EXP_EMPTY:
|
||||
if (sub == emptyExp)
|
||||
return(emptyExp);
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Empty(exp) -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
case XML_EXP_FORBID:
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Forbid(exp) -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
case XML_EXP_ATOM:
|
||||
if (sub->type == XML_EXP_ATOM) {
|
||||
/* TODO: handle wildcards */
|
||||
if (exp->exp_str == sub->exp_str) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Atom match -> Empty\n");
|
||||
#endif
|
||||
return(emptyExp);
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Atom mismatch -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
if ((sub->type == XML_EXP_COUNT) &&
|
||||
@ -7631,32 +7280,17 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
(sub->exp_left->type == XML_EXP_ATOM)) {
|
||||
/* TODO: handle wildcards */
|
||||
if (exp->exp_str == sub->exp_left->exp_str) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Atom match -> Empty\n");
|
||||
#endif
|
||||
return(emptyExp);
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Atom mismatch -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Complex exp vs Atom -> Forbid\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
case XML_EXP_SEQ:
|
||||
/* try to get the sequence consumed only if possible */
|
||||
if (xmlExpCheckCard(exp->exp_left, sub)) {
|
||||
/* See if the sequence can be consumed directly */
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Seq trying left only\n");
|
||||
#endif
|
||||
ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub);
|
||||
if ((ret != forbiddenExp) && (ret != NULL)) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Seq trying left only worked\n");
|
||||
#endif
|
||||
/*
|
||||
* TODO: assumption here that we are determinist
|
||||
* i.e. we won't get to a nillable exp left
|
||||
@ -7668,25 +7302,15 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
return(xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret,
|
||||
exp->exp_right, NULL, 0, 0));
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
} else {
|
||||
printf("Seq: left too short\n");
|
||||
#endif
|
||||
}
|
||||
/* Try instead to decompose */
|
||||
if (sub->type == XML_EXP_COUNT) {
|
||||
int min, max;
|
||||
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Seq: sub is a count\n");
|
||||
#endif
|
||||
ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
if (ret != forbiddenExp) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Seq , Count match on left\n");
|
||||
#endif
|
||||
if (sub->exp_max < 0)
|
||||
max = -1;
|
||||
else
|
||||
@ -7717,9 +7341,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
/* we made no progress on structured operations */
|
||||
break;
|
||||
case XML_EXP_OR:
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Or , trying both side\n");
|
||||
#endif
|
||||
ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
@ -7742,15 +7363,9 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
if (tmp == forbiddenExp) {
|
||||
int mult;
|
||||
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Count, Count inner don't subsume\n");
|
||||
#endif
|
||||
mult = xmlExpDivide(ctxt, sub->exp_left, exp->exp_left,
|
||||
NULL, &tmp);
|
||||
if (mult <= 0) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Count, Count not multiple => forbidden\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
if (sub->exp_max == -1) {
|
||||
@ -7761,17 +7376,11 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
else
|
||||
min = exp->exp_min - sub->exp_min * mult;
|
||||
} else {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Count, Count finite can't subsume infinite\n");
|
||||
#endif
|
||||
xmlExpFree(ctxt, tmp);
|
||||
return(forbiddenExp);
|
||||
}
|
||||
} else {
|
||||
if (exp->exp_max == -1) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Infinite loop consume mult finite loop\n");
|
||||
#endif
|
||||
if (exp->exp_min > sub->exp_min * mult) {
|
||||
max = -1;
|
||||
min = exp->exp_min - sub->exp_min * mult;
|
||||
@ -7781,9 +7390,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
}
|
||||
} else {
|
||||
if (exp->exp_max < sub->exp_max * mult) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loops max mult mismatch => forbidden\n");
|
||||
#endif
|
||||
xmlExpFree(ctxt, tmp);
|
||||
return(forbiddenExp);
|
||||
}
|
||||
@ -7799,30 +7405,18 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
* TODO: loop here to try to grow if working on finite
|
||||
* blocks.
|
||||
*/
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Count, Count remain not nillable => forbidden\n");
|
||||
#endif
|
||||
xmlExpFree(ctxt, tmp);
|
||||
return(forbiddenExp);
|
||||
} else if (sub->exp_max == -1) {
|
||||
if (exp->exp_max == -1) {
|
||||
if (exp->exp_min <= sub->exp_min) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Infinite loops Okay => COUNT(0,Inf)\n");
|
||||
#endif
|
||||
max = -1;
|
||||
min = 0;
|
||||
} else {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Infinite loops min => Count(X,Inf)\n");
|
||||
#endif
|
||||
max = -1;
|
||||
min = exp->exp_min - sub->exp_min;
|
||||
}
|
||||
} else if (exp->exp_min > sub->exp_min) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loops min mismatch 1 => forbidden ???\n");
|
||||
#endif
|
||||
xmlExpFree(ctxt, tmp);
|
||||
return(forbiddenExp);
|
||||
} else {
|
||||
@ -7831,9 +7425,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
}
|
||||
} else {
|
||||
if (exp->exp_max == -1) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Infinite loop consume finite loop\n");
|
||||
#endif
|
||||
if (exp->exp_min > sub->exp_min) {
|
||||
max = -1;
|
||||
min = exp->exp_min - sub->exp_min;
|
||||
@ -7843,9 +7434,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
}
|
||||
} else {
|
||||
if (exp->exp_max < sub->exp_max) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loops max mismatch => forbidden\n");
|
||||
#endif
|
||||
xmlExpFree(ctxt, tmp);
|
||||
return(forbiddenExp);
|
||||
}
|
||||
@ -7856,9 +7444,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
max = exp->exp_max - sub->exp_max;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loops match => SEQ(COUNT())\n");
|
||||
#endif
|
||||
exp->exp_left->ref++;
|
||||
tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left,
|
||||
NULL, NULL, min, max);
|
||||
@ -7873,9 +7458,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
if (tmp == NULL)
|
||||
return(NULL);
|
||||
if (tmp == forbiddenExp) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loop mismatch => forbidden\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
if (exp->exp_min > 0)
|
||||
@ -7887,9 +7469,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
else
|
||||
max = exp->exp_max - 1;
|
||||
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("loop match => SEQ(COUNT())\n");
|
||||
#endif
|
||||
exp->exp_left->ref++;
|
||||
tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left,
|
||||
NULL, NULL, min, max);
|
||||
@ -7901,9 +7480,6 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Fallback to derivative\n");
|
||||
#endif
|
||||
if (IS_NILLABLE(sub)) {
|
||||
if (!(IS_NILLABLE(exp)))
|
||||
return(forbiddenExp);
|
||||
@ -8001,15 +7577,9 @@ xmlExpExpDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
* O(1) speedups
|
||||
*/
|
||||
if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Sub nillable and not exp : can't subsume\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
if (xmlExpCheckCard(exp, sub) == 0) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("sub generate longer sequences than exp : can't subsume\n");
|
||||
#endif
|
||||
return(forbiddenExp);
|
||||
}
|
||||
return(xmlExpExpDeriveInt(ctxt, exp, sub));
|
||||
@ -8041,22 +7611,12 @@ xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
|
||||
* O(1) speedups
|
||||
*/
|
||||
if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Sub nillable and not exp : can't subsume\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
if (xmlExpCheckCard(exp, sub) == 0) {
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("sub generate longer sequences than exp : can't subsume\n");
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
tmp = xmlExpExpDeriveInt(ctxt, exp, sub);
|
||||
#ifdef DEBUG_DERIV
|
||||
printf("Result derivation :\n");
|
||||
PRINT_EXP(tmp);
|
||||
#endif
|
||||
if (tmp == NULL)
|
||||
return(-1);
|
||||
if (tmp == forbiddenExp)
|
||||
|
22
xmlsave.c
22
xmlsave.c
@ -2166,17 +2166,9 @@ xmlBufNodeDump(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
||||
xmlInitParser();
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeDump : node == NULL\n");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
if (buf == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlNodeDump : buf == NULL\n");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||
@ -2218,18 +2210,8 @@ xmlElemDump(FILE * f, xmlDocPtr doc, xmlNodePtr cur)
|
||||
xmlInitParser();
|
||||
|
||||
if (cur == NULL) {
|
||||
#ifdef DEBUG_TREE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlElemDump : cur == NULL\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_TREE
|
||||
if (doc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlElemDump : doc == NULL\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
outbuf = xmlOutputBufferCreateFile(f, NULL);
|
||||
if (outbuf == NULL)
|
||||
@ -2467,10 +2449,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;
|
||||
|
350
xmlschemas.c
350
xmlschemas.c
@ -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
|
||||
@ -4620,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 */
|
||||
|
||||
/************************************************************************
|
||||
@ -4852,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);
|
||||
}
|
||||
|
||||
@ -4899,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);
|
||||
}
|
||||
|
||||
@ -4933,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);
|
||||
}
|
||||
|
||||
@ -4973,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);
|
||||
}
|
||||
|
||||
@ -5008,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);
|
||||
}
|
||||
|
||||
@ -5606,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) {
|
||||
@ -13259,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) {
|
||||
@ -13289,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);
|
||||
@ -18157,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
|
||||
*/
|
||||
@ -18292,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);
|
||||
}
|
||||
|
||||
@ -18724,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
|
||||
@ -18734,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);
|
||||
}
|
||||
|
||||
@ -22622,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);
|
||||
}
|
||||
|
||||
@ -22651,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);
|
||||
@ -22692,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.
|
||||
*/
|
||||
@ -22719,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,
|
||||
@ -22745,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.
|
||||
@ -22881,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.
|
||||
*/
|
||||
@ -22901,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;
|
||||
|
||||
@ -23363,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 "
|
||||
@ -23411,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");
|
||||
@ -23505,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.
|
||||
*/
|
||||
@ -26218,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
|
||||
@ -26327,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
|
||||
}
|
||||
|
||||
/*
|
||||
@ -26338,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;
|
||||
}
|
||||
|
||||
@ -26364,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
|
||||
}
|
||||
|
||||
}
|
||||
@ -26681,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))
|
||||
{
|
||||
@ -26878,10 +26542,6 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
|
||||
return (-1);
|
||||
}
|
||||
pielem->regexCtxt = regexCtxt;
|
||||
#ifdef DEBUG_AUTOMATA
|
||||
xmlGenericError(xmlGenericErrorContext, "AUTOMATA create on '%s'\n",
|
||||
pielem->localName);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -26896,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()");
|
||||
|
@ -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
|
||||
|
52
xpointer.c
52
xpointer.c
@ -45,13 +45,6 @@
|
||||
/* 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 +698,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--;
|
||||
@ -2424,13 +2413,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);
|
||||
@ -2441,13 +2423,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 {
|
||||
@ -2507,13 +2482,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;
|
||||
@ -2530,13 +2498,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;
|
||||
@ -2786,25 +2747,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user