mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
applied patch from Aswin to fix tree skipping fixed a comment and added a
* xmlreader.c: applied patch from Aswin to fix tree skipping * include/libxml/entities.h entities.c: fixed a comment and added a new xmlNewEntity() entry point * runtest.c: be less verbose * tree.c: space and tabs cleanups daniel svn path=/trunk/; revision=3774
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
Mon Aug 25 16:52:53 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlreader.c: applied patch from Aswin to fix tree skipping
|
||||||
|
* include/libxml/entities.h entities.c: fixed a comment and
|
||||||
|
added a new xmlNewEntity() entry point
|
||||||
|
* runtest.c: be less verbose
|
||||||
|
* tree.c: space and tabs cleanups
|
||||||
|
|
||||||
Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
|
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
|
||||||
|
|||||||
122
entities.c
122
entities.c
@@ -139,45 +139,19 @@ xmlFreeEntity(xmlEntityPtr entity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xmlAddEntity : register a new entity for an entities table.
|
* xmlCreateEntity:
|
||||||
|
*
|
||||||
|
* internal routine doing the entity node strutures allocations
|
||||||
*/
|
*/
|
||||||
static xmlEntityPtr
|
static xmlEntityPtr
|
||||||
xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
|
||||||
const xmlChar *ExternalID, const xmlChar *SystemID,
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
const xmlChar *content) {
|
const xmlChar *content) {
|
||||||
xmlDictPtr dict = NULL;
|
|
||||||
xmlEntitiesTablePtr table = NULL;
|
|
||||||
xmlEntityPtr ret;
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
return(NULL);
|
|
||||||
if (dtd == NULL)
|
|
||||||
return(NULL);
|
|
||||||
if (dtd->doc != NULL)
|
|
||||||
dict = dtd->doc->dict;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case XML_INTERNAL_GENERAL_ENTITY:
|
|
||||||
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
|
|
||||||
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
|
||||||
if (dtd->entities == NULL)
|
|
||||||
dtd->entities = xmlHashCreateDict(0, dict);
|
|
||||||
table = dtd->entities;
|
|
||||||
break;
|
|
||||||
case XML_INTERNAL_PARAMETER_ENTITY:
|
|
||||||
case XML_EXTERNAL_PARAMETER_ENTITY:
|
|
||||||
if (dtd->pentities == NULL)
|
|
||||||
dtd->pentities = xmlHashCreateDict(0, dict);
|
|
||||||
table = dtd->pentities;
|
|
||||||
break;
|
|
||||||
case XML_INTERNAL_PREDEFINED_ENTITY:
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
if (table == NULL)
|
|
||||||
return(NULL);
|
|
||||||
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlEntitiesErrMemory("xmlAddEntity:: malloc failed");
|
xmlEntitiesErrMemory("xmlCreateEntity: malloc failed");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlEntity));
|
memset(ret, 0, sizeof(xmlEntity));
|
||||||
@@ -216,6 +190,50 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
|||||||
the defining entity */
|
the defining entity */
|
||||||
ret->orig = NULL;
|
ret->orig = NULL;
|
||||||
ret->owner = 0;
|
ret->owner = 0;
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xmlAddEntity : register a new entity for an entities table.
|
||||||
|
*/
|
||||||
|
static xmlEntityPtr
|
||||||
|
xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
||||||
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
|
const xmlChar *content) {
|
||||||
|
xmlDictPtr dict = NULL;
|
||||||
|
xmlEntitiesTablePtr table = NULL;
|
||||||
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (dtd == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (dtd->doc != NULL)
|
||||||
|
dict = dtd->doc->dict;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case XML_INTERNAL_GENERAL_ENTITY:
|
||||||
|
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
|
||||||
|
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
||||||
|
if (dtd->entities == NULL)
|
||||||
|
dtd->entities = xmlHashCreateDict(0, dict);
|
||||||
|
table = dtd->entities;
|
||||||
|
break;
|
||||||
|
case XML_INTERNAL_PARAMETER_ENTITY:
|
||||||
|
case XML_EXTERNAL_PARAMETER_ENTITY:
|
||||||
|
if (dtd->pentities == NULL)
|
||||||
|
dtd->pentities = xmlHashCreateDict(0, dict);
|
||||||
|
table = dtd->pentities;
|
||||||
|
break;
|
||||||
|
case XML_INTERNAL_PREDEFINED_ENTITY:
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (table == NULL)
|
||||||
|
return(NULL);
|
||||||
|
ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
|
||||||
|
if (ret == NULL)
|
||||||
|
return(NULL);
|
||||||
ret->doc = dtd->doc;
|
ret->doc = dtd->doc;
|
||||||
|
|
||||||
if (xmlHashAddEntry(table, name, ret)) {
|
if (xmlHashAddEntry(table, name, ret)) {
|
||||||
@@ -362,6 +380,44 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlNewEntity:
|
||||||
|
* @doc: the document
|
||||||
|
* @name: the entity name
|
||||||
|
* @type: the entity type XML_xxx_yyy_ENTITY
|
||||||
|
* @ExternalID: the entity external ID if available
|
||||||
|
* @SystemID: the entity system ID if available
|
||||||
|
* @content: the entity content
|
||||||
|
*
|
||||||
|
* Create a new entity, this differs from xmlAddDocEntity() that if
|
||||||
|
* the document is NULL or has no internal subset defined, then an
|
||||||
|
* unlinked entity structure will be returned, it is then the responsability
|
||||||
|
* of the caller to link it to the document later or free it when not needed
|
||||||
|
* anymore.
|
||||||
|
*
|
||||||
|
* Returns a pointer to the entity or NULL in case of error
|
||||||
|
*/
|
||||||
|
xmlEntityPtr
|
||||||
|
xmlNewEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
||||||
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
|
const xmlChar *content) {
|
||||||
|
xmlEntityPtr ret;
|
||||||
|
xmlDictPtr dict;
|
||||||
|
|
||||||
|
if ((doc != NULL) && (doc->intSubset != NULL)) {
|
||||||
|
return(xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content));
|
||||||
|
}
|
||||||
|
if (doc != NULL)
|
||||||
|
dict = doc->dict;
|
||||||
|
else
|
||||||
|
dict = NULL;
|
||||||
|
ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
|
||||||
|
if (ret == NULL)
|
||||||
|
return(NULL);
|
||||||
|
ret->doc = doc;
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlGetEntityFromTable:
|
* xmlGetEntityFromTable:
|
||||||
* @table: an entity table
|
* @table: an entity table
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ struct _xmlEntity {
|
|||||||
const xmlChar *URI; /* the full URI as computed */
|
const xmlChar *URI; /* the full URI as computed */
|
||||||
int owner; /* does the entity own the childrens */
|
int owner; /* does the entity own the childrens */
|
||||||
int checked; /* was the entity content checked */
|
int checked; /* was the entity content checked */
|
||||||
|
/* this is also used to count entites
|
||||||
|
* references done from that entity */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -75,6 +77,14 @@ typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
|||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlInitializePredefinedEntities (void);
|
xmlInitializePredefinedEntities (void);
|
||||||
#endif /* LIBXML_LEGACY_ENABLED */
|
#endif /* LIBXML_LEGACY_ENABLED */
|
||||||
|
|
||||||
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
|
xmlNewEntity (xmlDocPtr doc,
|
||||||
|
const xmlChar *name,
|
||||||
|
int type,
|
||||||
|
const xmlChar *ExternalID,
|
||||||
|
const xmlChar *SystemID,
|
||||||
|
const xmlChar *content);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlAddDocEntity (xmlDocPtr doc,
|
xmlAddDocEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name,
|
const xmlChar *name,
|
||||||
|
|||||||
11
runtest.c
11
runtest.c
@@ -314,7 +314,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
|||||||
n = 0;
|
n = 0;
|
||||||
/* search backwards for beginning-of-line (to max buff size) */
|
/* search backwards for beginning-of-line (to max buff size) */
|
||||||
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
||||||
(*(cur) != '\n') && (*(cur) != '\r'))
|
(*(cur) != '\n') && (*(cur) != '\r'))
|
||||||
cur--;
|
cur--;
|
||||||
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
|
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
|
||||||
/* calculate the error position in terms of the current position */
|
/* calculate the error position in terms of the current position */
|
||||||
@@ -324,7 +324,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
|||||||
ctnt = content;
|
ctnt = content;
|
||||||
/* copy selected text to our buffer */
|
/* copy selected text to our buffer */
|
||||||
while ((*cur != 0) && (*(cur) != '\n') &&
|
while ((*cur != 0) && (*(cur) != '\n') &&
|
||||||
(*(cur) != '\r') && (n < sizeof(content)-1)) {
|
(*(cur) != '\r') && (n < sizeof(content)-1)) {
|
||||||
*ctnt++ = *cur++;
|
*ctnt++ = *cur++;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@@ -3586,7 +3586,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
while(ns != NULL) {
|
while(ns != NULL) {
|
||||||
if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
|
if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
|
||||||
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
|
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -3600,7 +3600,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
xpath = xmlXPathEvalExpression(expr, ctx);
|
xpath = xmlXPathEvalExpression(expr, ctx);
|
||||||
if(xpath == NULL) {
|
if(xpath == NULL) {
|
||||||
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -3620,7 +3620,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
#define xxx_growBufferReentrant() { \
|
#define xxx_growBufferReentrant() { \
|
||||||
buffer_size *= 2; \
|
buffer_size *= 2; \
|
||||||
buffer = (xmlChar **) \
|
buffer = (xmlChar **) \
|
||||||
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
||||||
if (buffer == NULL) { \
|
if (buffer == NULL) { \
|
||||||
perror("realloc failed"); \
|
perror("realloc failed"); \
|
||||||
return(NULL); \
|
return(NULL); \
|
||||||
@@ -4392,7 +4392,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
|
|||||||
|
|
||||||
initializeLibxml2();
|
initializeLibxml2();
|
||||||
|
|
||||||
|
|
||||||
for (a = 1; a < argc;a++) {
|
for (a = 1; a < argc;a++) {
|
||||||
if (!strcmp(argv[a], "-v"))
|
if (!strcmp(argv[a], "-v"))
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
|||||||
26
runxmlconf.c
26
runxmlconf.c
@@ -446,22 +446,27 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur) {
|
xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
||||||
xmlChar *profile;
|
xmlChar *profile;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int tests = 0;
|
int tests = 0;
|
||||||
|
int output = 0;
|
||||||
|
|
||||||
profile = xmlGetProp(cur, BAD_CAST "PROFILE");
|
if (level == 1) {
|
||||||
if (profile != NULL) {
|
profile = xmlGetProp(cur, BAD_CAST "PROFILE");
|
||||||
printf("Test cases: %s\n", (char *) profile);
|
if (profile != NULL) {
|
||||||
xmlFree(profile);
|
output = 1;
|
||||||
|
level++;
|
||||||
|
printf("Test cases: %s\n", (char *) profile);
|
||||||
|
xmlFree(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
/* look only at elements we ignore everything else */
|
/* look only at elements we ignore everything else */
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
||||||
ret += xmlconfTestCases(doc, cur);
|
ret += xmlconfTestCases(doc, cur, level);
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
|
||||||
if (xmlconfTestItem(doc, cur) >= 0)
|
if (xmlconfTestItem(doc, cur) >= 0)
|
||||||
ret++;
|
ret++;
|
||||||
@@ -472,8 +477,10 @@ xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
if (tests > 0)
|
if (output == 1) {
|
||||||
printf("Test cases: %d tests\n", tests);
|
if (tests > 0)
|
||||||
|
printf("Test cases: %d tests\n", tests);
|
||||||
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +500,7 @@ xmlconfTestSuite(xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
/* look only at elements we ignore everything else */
|
/* look only at elements we ignore everything else */
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
||||||
ret += xmlconfTestCases(doc, cur);
|
ret += xmlconfTestCases(doc, cur, 1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
|
fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
|
||||||
}
|
}
|
||||||
@@ -584,6 +591,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
printf("Total %d tests, %d errors, %d leaks\n",
|
printf("Total %d tests, %d errors, %d leaks\n",
|
||||||
nb_tests, nb_errors, nb_leaks);
|
nb_tests, nb_errors, nb_leaks);
|
||||||
|
printf("See %s for detailed output\n", LOGFILE);
|
||||||
}
|
}
|
||||||
xmlXPathFreeContext(ctxtXPath);
|
xmlXPathFreeContext(ctxtXPath);
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
|
|||||||
34
tree.c
34
tree.c
@@ -45,7 +45,7 @@ int __xmlRegisterCallbacks = 0;
|
|||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Forward declarations *
|
* Forward declarations *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ static xmlChar* xmlGetPropNodeValueInternal(xmlAttrPtr prop);
|
|||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Tree memory error handler *
|
* Tree memory error handler *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +103,7 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra)
|
|||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* A few static variables and macros *
|
* A few static variables and macros *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
/* #undef xmlStringText */
|
/* #undef xmlStringText */
|
||||||
@@ -123,7 +123,7 @@ static int xmlCheckDTD = 1;
|
|||||||
(n)->last = NULL; \
|
(n)->last = NULL; \
|
||||||
} else { \
|
} else { \
|
||||||
while (ulccur->next != NULL) { \
|
while (ulccur->next != NULL) { \
|
||||||
ulccur->parent = (n); \
|
ulccur->parent = (n); \
|
||||||
ulccur = ulccur->next; \
|
ulccur = ulccur->next; \
|
||||||
} \
|
} \
|
||||||
ulccur->parent = (n); \
|
ulccur->parent = (n); \
|
||||||
@@ -138,7 +138,7 @@ static int xmlCheckDTD = 1;
|
|||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Functions to move to entities.c once the *
|
* Functions to move to entities.c once the *
|
||||||
* API freeze is smoothen and they can be made public. *
|
* API freeze is smoothen and they can be made public. *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
@@ -162,7 +162,7 @@ xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
|
|||||||
if((dtd != NULL) && (dtd->entities != NULL)) {
|
if((dtd != NULL) && (dtd->entities != NULL)) {
|
||||||
table = (xmlEntitiesTablePtr) dtd->entities;
|
table = (xmlEntitiesTablePtr) dtd->entities;
|
||||||
return((xmlEntityPtr) xmlHashLookup(table, name));
|
return((xmlEntityPtr) xmlHashLookup(table, name));
|
||||||
/* return(xmlGetEntityFromTable(table, name)); */
|
/* return(xmlGetEntityFromTable(table, name)); */
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@@ -1022,7 +1022,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
|
|||||||
* current scope
|
* current scope
|
||||||
*/
|
*/
|
||||||
#define DICT_FREE(str) \
|
#define DICT_FREE(str) \
|
||||||
if ((str) && ((!dict) || \
|
if ((str) && ((!dict) || \
|
||||||
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
|
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
|
||||||
xmlFree((char *)(str));
|
xmlFree((char *)(str));
|
||||||
|
|
||||||
@@ -3190,7 +3190,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
if ((cur->type == XML_TEXT_NODE) &&
|
if ((cur->type == XML_TEXT_NODE) &&
|
||||||
(parent->last->type == XML_TEXT_NODE) &&
|
(parent->last->type == XML_TEXT_NODE) &&
|
||||||
(cur->name == parent->last->name)) {
|
(cur->name == parent->last->name)) {
|
||||||
xmlNodeAddContent(parent->last, cur->content);
|
xmlNodeAddContent(parent->last, cur->content);
|
||||||
/*
|
/*
|
||||||
* if it's the only child, nothing more to be done.
|
* if it's the only child, nothing more to be done.
|
||||||
*/
|
*/
|
||||||
@@ -4140,7 +4140,7 @@ xmlCopyDtd(xmlDtdPtr dtd) {
|
|||||||
break;
|
break;
|
||||||
case XML_INTERNAL_PARAMETER_ENTITY:
|
case XML_INTERNAL_PARAMETER_ENTITY:
|
||||||
case XML_EXTERNAL_PARAMETER_ENTITY:
|
case XML_EXTERNAL_PARAMETER_ENTITY:
|
||||||
q = (xmlNodePtr)
|
q = (xmlNodePtr)
|
||||||
xmlGetParameterEntityFromDtd(ret, tmp->name);
|
xmlGetParameterEntityFromDtd(ret, tmp->name);
|
||||||
break;
|
break;
|
||||||
case XML_INTERNAL_PREDEFINED_ENTITY:
|
case XML_INTERNAL_PREDEFINED_ENTITY:
|
||||||
@@ -4166,13 +4166,13 @@ xmlCopyDtd(xmlDtdPtr dtd) {
|
|||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
ret->children = q;
|
ret->children = q;
|
||||||
else
|
else
|
||||||
p->next = q;
|
p->next = q;
|
||||||
|
|
||||||
q->prev = p;
|
q->prev = p;
|
||||||
q->parent = (xmlNodePtr) ret;
|
q->parent = (xmlNodePtr) ret;
|
||||||
q->next = NULL;
|
q->next = NULL;
|
||||||
ret->last = q;
|
ret->last = q;
|
||||||
p = q;
|
p = q;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4334,7 +4334,7 @@ xmlGetNodePath(xmlNodePtr node)
|
|||||||
if (cur->ns) {
|
if (cur->ns) {
|
||||||
if (cur->ns->prefix != NULL) {
|
if (cur->ns->prefix != NULL) {
|
||||||
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
|
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
|
||||||
(char *)cur->ns->prefix, (char *)cur->name);
|
(char *)cur->ns->prefix, (char *)cur->name);
|
||||||
nametemp[sizeof(nametemp) - 1] = 0;
|
nametemp[sizeof(nametemp) - 1] = 0;
|
||||||
name = nametemp;
|
name = nametemp;
|
||||||
} else {
|
} else {
|
||||||
@@ -4475,10 +4475,10 @@ xmlGetNodePath(xmlNodePtr node)
|
|||||||
if (cur->ns) {
|
if (cur->ns) {
|
||||||
if (cur->ns->prefix != NULL)
|
if (cur->ns->prefix != NULL)
|
||||||
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
|
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
|
||||||
(char *)cur->ns->prefix, (char *)cur->name);
|
(char *)cur->ns->prefix, (char *)cur->name);
|
||||||
else
|
else
|
||||||
snprintf(nametemp, sizeof(nametemp) - 1, "%s",
|
snprintf(nametemp, sizeof(nametemp) - 1, "%s",
|
||||||
(char *)cur->name);
|
(char *)cur->name);
|
||||||
nametemp[sizeof(nametemp) - 1] = 0;
|
nametemp[sizeof(nametemp) - 1] = 0;
|
||||||
name = nametemp;
|
name = nametemp;
|
||||||
}
|
}
|
||||||
@@ -5860,7 +5860,7 @@ xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
|
|||||||
snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);
|
snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);
|
||||||
else
|
else
|
||||||
snprintf((char *) prefix, sizeof(prefix), "%.20s%d",
|
snprintf((char *) prefix, sizeof(prefix), "%.20s%d",
|
||||||
(char *)ns->prefix, counter++);
|
(char *)ns->prefix, counter++);
|
||||||
def = xmlSearchNs(doc, tree, prefix);
|
def = xmlSearchNs(doc, tree, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
xmlreader.c
16
xmlreader.c
@@ -1847,17 +1847,22 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reader->state != XML_TEXTREADER_BACKTRACK) {
|
if (reader->state != XML_TEXTREADER_BACKTRACK) {
|
||||||
if (reader->node->children != 0) {
|
/* Here removed traversal to child, because we want to skip the subtree,
|
||||||
reader->node = reader->node->children;
|
replace with traversal to sibling to skip subtree */
|
||||||
reader->depth++;
|
if (reader->node->next != 0) {
|
||||||
|
reader->node = reader->node->next;// Move to sibling if present,skipping sub-tree
|
||||||
|
//reader->depth++;
|
||||||
reader->state = XML_TEXTREADER_START;
|
reader->state = XML_TEXTREADER_START;
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if reader->node->next is NULL mean no subtree for current node,
|
||||||
|
so need to move to sibling of parent node if present */
|
||||||
if ((reader->node->type == XML_ELEMENT_NODE) ||
|
if ((reader->node->type == XML_ELEMENT_NODE) ||
|
||||||
(reader->node->type == XML_ATTRIBUTE_NODE)) {
|
(reader->node->type == XML_ATTRIBUTE_NODE)) {
|
||||||
reader->state = XML_TEXTREADER_BACKTRACK;
|
reader->state = XML_TEXTREADER_BACKTRACK;
|
||||||
return(1);
|
xmlTextReaderRead(reader);// This will move to parent if present
|
||||||
|
//return(xmlTextReaderReadTree(reader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1876,7 +1881,8 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
|
|||||||
reader->node = reader->node->parent;
|
reader->node = reader->node->parent;
|
||||||
reader->depth--;
|
reader->depth--;
|
||||||
reader->state = XML_TEXTREADER_BACKTRACK;
|
reader->state = XML_TEXTREADER_BACKTRACK;
|
||||||
return(1);
|
xmlTextReaderNextTree(reader); //Repeat process to move to sibling of parent node if present
|
||||||
|
//return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader->state = XML_TEXTREADER_END;
|
reader->state = XML_TEXTREADER_END;
|
||||||
|
|||||||
Reference in New Issue
Block a user