summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c706
1 files changed, 407 insertions, 299 deletions
diff --git a/tree.c b/tree.c
index 763381b..f26748e 100644
--- a/tree.c
+++ b/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 */
@@ -123,7 +123,7 @@ static int xmlCheckDTD = 1;
(n)->last = NULL; \
} else { \
while (ulccur->next != NULL) { \
- ulccur->parent = (n); \
+ ulccur->parent = (n); \
ulccur = ulccur->next; \
} \
ulccur->parent = (n); \
@@ -138,12 +138,12 @@ 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. *
* *
************************************************************************/
#include <libxml/hash.h>
-
+
#ifdef LIBXML_TREE_ENABLED
/**
* xmlGetEntityFromDtd:
@@ -152,17 +152,17 @@ static int xmlCheckDTD = 1;
*
* Do an entity lookup in the DTD entity hash table and
* return the corresponding entity, if found.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
static xmlEntityPtr
xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
xmlEntitiesTablePtr table;
-
+
if((dtd != NULL) && (dtd->entities != NULL)) {
table = (xmlEntitiesTablePtr) dtd->entities;
return((xmlEntityPtr) xmlHashLookup(table, name));
- /* return(xmlGetEntityFromTable(table, name)); */
+ /* return(xmlGetEntityFromTable(table, name)); */
}
return(NULL);
}
@@ -170,7 +170,7 @@ xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
* xmlGetParameterEntityFromDtd:
* @dtd: A pointer to the DTD to search
* @name: The entity name
- *
+ *
* Do an entity lookup in the DTD pararmeter entity hash table and
* return the corresponding entity, if found.
*
@@ -179,7 +179,7 @@ xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
static xmlEntityPtr
xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
xmlEntitiesTablePtr table;
-
+
if ((dtd != NULL) && (dtd->pentities != NULL)) {
table = (xmlEntitiesTablePtr) dtd->pentities;
return((xmlEntityPtr) xmlHashLookup(table, name));
@@ -240,7 +240,7 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
/**
* xmlSplitQName2:
* @name: the full QName
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* parse an XML qualified name string
*
@@ -278,9 +278,9 @@ xmlSplitQName2(const xmlChar *name, xmlChar **prefix) {
* we are not trying to validate but just to cut, and yes it will
* work even if this is as set of UTF-8 encoded chars
*/
- while ((name[len] != 0) && (name[len] != ':'))
+ while ((name[len] != 0) && (name[len] != ':'))
len++;
-
+
if (name[len] == 0)
return(NULL);
@@ -329,9 +329,9 @@ xmlSplitQName3(const xmlChar *name, int *len) {
* we are not trying to validate but just to cut, and yes it will
* work even if this is as set of UTF-8 encoded chars
*/
- while ((name[l] != 0) && (name[l] != ':'))
+ while ((name[l] != 0) && (name[l] != ':'))
l++;
-
+
if (name[l] == 0)
return(NULL);
@@ -345,7 +345,7 @@ xmlSplitQName3(const xmlChar *name, int *len) {
* Check Name, NCName and QName strings *
* *
************************************************************************/
-
+
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
@@ -668,14 +668,14 @@ try_complex:
* Allocation and deallocation of basic structures *
* *
************************************************************************/
-
+
/**
* xmlSetBufferAllocationScheme:
* @scheme: allocation method to use
- *
+ *
* Set the buffer allocation method. Types are
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
* improves performance
*/
void
@@ -688,9 +688,9 @@ xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
*
* Types are
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
* improves performance
- *
+ *
* Returns the current allocation scheme
*/
xmlBufferAllocationScheme
@@ -733,9 +733,9 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
cur->type = XML_LOCAL_NAMESPACE;
if (href != NULL)
- cur->href = xmlStrdup(href);
+ cur->href = xmlStrdup(href);
if (prefix != NULL)
- cur->prefix = xmlStrdup(prefix);
+ cur->prefix = xmlStrdup(prefix);
/*
* Add it at the end to preserve parsing order ...
@@ -751,14 +751,14 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
(xmlStrEqual(prev->prefix, cur->prefix))) {
xmlFreeNs(cur);
return(NULL);
- }
+ }
while (prev->next != NULL) {
prev = prev->next;
if (((prev->prefix == NULL) && (cur->prefix == NULL)) ||
(xmlStrEqual(prev->prefix, cur->prefix))) {
xmlFreeNs(cur);
return(NULL);
- }
+ }
}
prev->next = cur;
}
@@ -867,11 +867,11 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
cur->type = XML_DTD_NODE;
if (name != NULL)
- cur->name = xmlStrdup(name);
+ cur->name = xmlStrdup(name);
if (ExternalID != NULL)
- cur->ExternalID = xmlStrdup(ExternalID);
+ cur->ExternalID = xmlStrdup(ExternalID);
if (SystemID != NULL)
- cur->SystemID = xmlStrdup(SystemID);
+ cur->SystemID = xmlStrdup(SystemID);
if (doc != NULL)
doc->extSubset = cur;
cur->doc = doc;
@@ -949,7 +949,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
}
}
if (ExternalID != NULL) {
- cur->ExternalID = xmlStrdup(ExternalID);
+ cur->ExternalID = xmlStrdup(ExternalID);
if (cur->ExternalID == NULL) {
xmlTreeErrMemory("building internal subset");
if (cur->name != NULL)
@@ -959,7 +959,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
}
}
if (SystemID != NULL) {
- cur->SystemID = xmlStrdup(SystemID);
+ cur->SystemID = xmlStrdup(SystemID);
if (cur->SystemID == NULL) {
xmlTreeErrMemory("building internal subset");
if (cur->name != NULL)
@@ -1022,7 +1022,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -1105,7 +1105,7 @@ xmlFreeDtd(xmlDtdPtr cur) {
/* TODO !!! */
if (cur->notations != NULL)
xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
-
+
if (cur->elements != NULL)
xmlFreeElementTable((xmlElementTablePtr) cur->elements);
if (cur->attributes != NULL)
@@ -1144,15 +1144,17 @@ xmlNewDoc(const xmlChar *version) {
memset(cur, 0, sizeof(xmlDoc));
cur->type = XML_DOCUMENT_NODE;
- cur->version = xmlStrdup(version);
+ cur->version = xmlStrdup(version);
if (cur->version == NULL) {
xmlTreeErrMemory("building doc");
xmlFree(cur);
- return(NULL);
+ return(NULL);
}
cur->standalone = -1;
cur->compression = -1; /* not initialized */
cur->doc = cur;
+ cur->parseFlags = 0;
+ cur->properties = XML_DOC_USERBUILT;
/*
* The in memory encoding is always UTF8
* This field will never change and would
@@ -1280,7 +1282,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
else
tmp = 0;
while (tmp != ';') { /* Non input consuming loop */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f'))
charval = charval * 16 + (tmp - 'a') + 10;
@@ -1308,7 +1310,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
else
tmp = 0;
while (tmp != ';') { /* Non input consuming loops */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0');
else {
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1353,7 +1355,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
last = xmlAddNextSibling(last, node);
} else
xmlNodeAddContent(last, ent->content);
-
+
} else {
/*
* Create a new REFERENCE_REF node
@@ -1474,7 +1476,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
cur += 3;
tmp = *cur;
while (tmp != ';') { /* Non input consuming loop */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f'))
charval = charval * 16 + (tmp - 'a') + 10;
@@ -1496,7 +1498,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
cur += 2;
tmp = *cur;
while (tmp != ';') { /* Non input consuming loops */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0');
else {
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1538,7 +1540,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
last = xmlAddNextSibling(last, node);
} else
xmlNodeAddContent(last, ent->content);
-
+
} else {
/*
* Create a new REFERENCE_REF node
@@ -1976,7 +1978,7 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
cur->name = xmlDictLookup(doc->dict, name, -1);
else
cur->name = xmlStrdup(name);
- cur->doc = doc;
+ cur->doc = doc;
if (value != NULL) {
xmlNodePtr tmp;
@@ -2183,7 +2185,7 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
}
memset(cur, 0, sizeof(xmlNode));
cur->type = XML_ELEMENT_NODE;
-
+
cur->name = xmlStrdup(name);
cur->ns = ns;
@@ -2226,7 +2228,7 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
}
memset(cur, 0, sizeof(xmlNode));
cur->type = XML_ELEMENT_NODE;
-
+
cur->name = name;
cur->ns = ns;
@@ -2414,9 +2416,9 @@ xmlNewText(const xmlChar *content) {
* a child TEXT node will be created containing the string @content.
* NOTE: Use xmlNewChild() if @content will contain entities that need to be
* preserved. Use this function, xmlNewTextChild(), if you need to ensure that
- * reserved XML chars that might appear in @content, such as the ampersand,
- * greater-than or less-than signs, are automatically replaced by their XML
- * escaped entity representations.
+ * reserved XML chars that might appear in @content, such as the ampersand,
+ * greater-than or less-than signs, are automatically replaced by their XML
+ * escaped entity representations.
*
* Returns a pointer to the new node object.
*/
@@ -2864,14 +2866,14 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
/**
* xmlAddPropSibling:
- * @prev: the attribute to which @prop is added after
+ * @prev: the attribute to which @prop is added after
* @cur: the base attribute passed to calling function
* @prop: the new attribute
*
* Add a new attribute after @prev using @cur as base attribute.
* When inserting before @cur, @prev is passed as @cur->prev.
* When inserting after @cur, @prev is passed as @cur.
- * If an existing attribute is found it is detroyed prior to adding @prop.
+ * If an existing attribute is found it is detroyed prior to adding @prop.
*
* Returns the attribute being inserted or NULL in case of error.
*/
@@ -2921,7 +2923,7 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
* first unlinked from its existing context.
* As a result of text merging @elem may be freed.
* If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the new node or NULL in case of error.
*/
@@ -2999,7 +3001,7 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
* If the new node was already inserted in a document it is
* first unlinked from its existing context.
* If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the new node or NULL in case of error.
*/
@@ -3103,7 +3105,7 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
* Constant time is we can rely on the ->parent->last to find
* the last sibling.
*/
- if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
+ if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
(cur->parent->children != NULL) &&
(cur->parent->last != NULL) &&
(cur->parent->last->next == NULL)) {
@@ -3185,10 +3187,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
/*
* If cur and parent->last both are TEXT nodes, then merge them.
*/
- if ((cur->type == XML_TEXT_NODE) &&
+ if ((cur->type == XML_TEXT_NODE) &&
(parent->last->type == XML_TEXT_NODE) &&
(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.
*/
@@ -3226,7 +3228,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
* Add a new node to @parent, at the end of the child (or property) list
* merging adjacent TEXT nodes (in which case @cur is freed)
* If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the child or NULL in case of error.
*/
@@ -3465,6 +3467,11 @@ xmlFreeNode(xmlNodePtr cur) {
if (cur->doc != NULL) dict = cur->doc->dict;
+ if (cur->type == XML_ENTITY_DECL) {
+ xmlEntityPtr ent = (xmlEntityPtr) cur;
+ DICT_FREE(ent->SystemID);
+ DICT_FREE(ent->ExternalID);
+ }
if ((cur->children != NULL) &&
(cur->type != XML_ENTITY_REF_NODE))
xmlFreeNodeList(cur->children);
@@ -3525,6 +3532,28 @@ xmlUnlinkNode(xmlNodePtr cur) {
doc->extSubset = NULL;
}
}
+ if (cur->type == XML_ENTITY_DECL) {
+ xmlDocPtr doc;
+ doc = cur->doc;
+ if (doc != NULL) {
+ if (doc->intSubset != NULL) {
+ if (xmlHashLookup(doc->intSubset->entities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->intSubset->entities, cur->name,
+ NULL);
+ if (xmlHashLookup(doc->intSubset->pentities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->intSubset->pentities, cur->name,
+ NULL);
+ }
+ if (doc->extSubset != NULL) {
+ if (xmlHashLookup(doc->extSubset->entities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->extSubset->entities, cur->name,
+ NULL);
+ if (xmlHashLookup(doc->extSubset->pentities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->extSubset->pentities, cur->name,
+ NULL);
+ }
+ }
+ }
if (cur->parent != NULL) {
xmlNodePtr parent;
parent = cur->parent;
@@ -3620,7 +3649,7 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
* Copy operations *
* *
************************************************************************/
-
+
/**
* xmlCopyNamespace:
* @cur: the namespace
@@ -3737,7 +3766,7 @@ xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
}
}
-
+
} else
ret->ns = NULL;
@@ -3858,7 +3887,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node));
case XML_NAMESPACE_DECL:
return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node));
-
+
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
@@ -3888,7 +3917,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
ret->type = node->type;
ret->doc = doc;
- ret->parent = parent;
+ ret->parent = parent;
if (node->name == xmlStringText)
ret->name = xmlStringText;
else if (node->name == xmlStringTextNoenc)
@@ -3927,7 +3956,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
if (tmp != ret)
return(tmp);
}
-
+
if (!extended)
goto out;
if ((node->type == XML_ELEMENT_NODE) && (node->nsDef != NULL))
@@ -4123,7 +4152,7 @@ xmlCopyDtd(xmlDtdPtr dtd) {
if (dtd->pentities != NULL)
ret->pentities = (void *) xmlCopyEntitiesTable(
(xmlEntitiesTablePtr) dtd->pentities);
-
+
cur = dtd->children;
while (cur != NULL) {
q = NULL;
@@ -4138,7 +4167,7 @@ xmlCopyDtd(xmlDtdPtr dtd) {
break;
case XML_INTERNAL_PARAMETER_ENTITY:
case XML_EXTERNAL_PARAMETER_ENTITY:
- q = (xmlNodePtr)
+ q = (xmlNodePtr)
xmlGetParameterEntityFromDtd(ret, tmp->name);
break;
case XML_INTERNAL_PREDEFINED_ENTITY:
@@ -4150,27 +4179,27 @@ xmlCopyDtd(xmlDtdPtr dtd) {
xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix);
} else if (cur->type == XML_ATTRIBUTE_DECL) {
xmlAttributePtr tmp = (xmlAttributePtr) cur;
- q = (xmlNodePtr)
+ q = (xmlNodePtr)
xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix);
} else if (cur->type == XML_COMMENT_NODE) {
q = xmlCopyNode(cur, 0);
}
-
+
if (q == NULL) {
cur = cur->next;
continue;
}
-
+
if (p == NULL)
ret->children = q;
else
- p->next = q;
-
- q->prev = p;
- q->parent = (xmlNodePtr) ret;
+ p->next = q;
+
+ q->prev = p;
+ q->parent = (xmlNodePtr) ret;
q->next = NULL;
ret->last = q;
- p = q;
+ p = q;
cur = cur->next;
}
@@ -4220,7 +4249,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
ret->oldNs = xmlCopyNamespaceList(doc->oldNs);
if (doc->children != NULL) {
xmlNodePtr tmp;
-
+
ret->children = xmlStaticCopyNodeList(doc->children, ret,
(xmlNodePtr)ret);
ret->last = NULL;
@@ -4240,7 +4269,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
* Content access functions *
* *
************************************************************************/
-
+
/**
* xmlGetLineNo:
* @node: valid node
@@ -4332,7 +4361,7 @@ xmlGetNodePath(xmlNodePtr node)
if (cur->ns) {
if (cur->ns->prefix != NULL) {
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;
name = nametemp;
} else {
@@ -4342,7 +4371,7 @@ xmlGetNodePath(xmlNodePtr node)
*/
generic = 1;
name = "*";
- }
+ }
}
next = cur->parent;
@@ -4430,7 +4459,7 @@ xmlGetNodePath(xmlNodePtr node)
{
occur = 1;
break;
- }
+ }
tmp = tmp->next;
}
} else
@@ -4473,10 +4502,10 @@ xmlGetNodePath(xmlNodePtr node)
if (cur->ns) {
if (cur->ns->prefix != NULL)
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
- (char *)cur->ns->prefix, (char *)cur->name);
+ (char *)cur->ns->prefix, (char *)cur->name);
else
snprintf(nametemp, sizeof(nametemp) - 1, "%s",
- (char *)cur->name);
+ (char *)cur->name);
nametemp[sizeof(nametemp) - 1] = 0;
name = nametemp;
}
@@ -4544,7 +4573,7 @@ xmlDocGetRootElement(xmlDocPtr doc) {
}
return(ret);
}
-
+
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
/**
* xmlDocSetRootElement:
@@ -4586,7 +4615,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
return(old);
}
#endif
-
+
#if defined(LIBXML_TREE_ENABLED)
/**
* xmlNodeSetLang:
@@ -4634,7 +4663,7 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
}
#endif /* LIBXML_TREE_ENABLED */
-
+
/**
* xmlNodeGetLang:
* @cur: the node being checked
@@ -4657,7 +4686,7 @@ xmlNodeGetLang(xmlNodePtr cur) {
}
return(NULL);
}
-
+
#ifdef LIBXML_TREE_ENABLED
/**
@@ -4745,7 +4774,7 @@ xmlNodeGetSpacePreserve(xmlNodePtr cur) {
}
return(-1);
}
-
+
#ifdef LIBXML_TREE_ENABLED
/**
* xmlNodeSetName:
@@ -4803,7 +4832,7 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
}
}
#endif
-
+
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
/**
* xmlNodeSetBase:
@@ -4856,7 +4885,7 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
return;
}
}
-
+
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
if (ns == NULL)
return;
@@ -4892,9 +4921,9 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *oldbase = NULL;
xmlChar *base, *newbase;
- if ((cur == NULL) && (doc == NULL))
+ if ((cur == NULL) && (doc == NULL))
return(NULL);
- if (doc == NULL) doc = cur->doc;
+ if (doc == NULL) doc = cur->doc;
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
cur = doc->children;
while ((cur != NULL) && (cur->name != NULL)) {
@@ -4956,7 +4985,7 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
}
return(oldbase);
}
-
+
/**
* xmlNodeBufGetContent:
* @buffer: a buffer
@@ -4967,7 +4996,7 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
* of the values carried by this node child's (TEXT and ENTITY_REF).
* Entity references are substituted.
* Fills up the buffer @buffer with this value
- *
+ *
* Returns 0 in case of success and -1 in case of error.
*/
int
@@ -5246,12 +5275,12 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
(xmlDictOwns(cur->doc->dict, cur->content))))
xmlFree(cur->content);
- }
+ }
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->last = cur->children = NULL;
if (content != NULL) {
cur->content = xmlStrdup(content);
- } else
+ } else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
@@ -5324,12 +5353,12 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
(xmlDictOwns(cur->doc->dict, cur->content))))
xmlFree(cur->content);
- }
+ }
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->children = cur->last = NULL;
if (content != NULL) {
cur->content = xmlStrndup(content, len);
- } else
+ } else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
@@ -5363,7 +5392,7 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
* @cur: the node being modified
* @content: extra content
* @len: the size of @content
- *
+ *
* Append the extra substring to the node content.
* NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be
* raw text, so unescaped XML special chars are allowed, entity
@@ -5438,7 +5467,7 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
* xmlNodeAddContent:
* @cur: the node being modified
* @content: extra content
- *
+ *
* Append the extra substring to the node content.
* NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be
* raw text, so unescaped XML special chars are allowed, entity
@@ -5464,7 +5493,7 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
* xmlTextMerge:
* @first: the first text node
* @second: the second text node being merged
- *
+ *
* Merge two text nodes into one
* Returns the first text node augmented
*/
@@ -5549,9 +5578,9 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
/*
* xmlTreeEnsureXMLDecl:
* @doc: the doc
-*
+*
* Ensures that there is an XML namespace declaration on the doc.
-*
+*
* Returns the XML ns-struct or NULL on API and internal errors.
*/
static xmlNsPtr
@@ -5571,7 +5600,7 @@ xmlTreeEnsureXMLDecl(xmlDocPtr doc)
}
memset(ns, 0, sizeof(xmlNs));
ns->type = XML_LOCAL_NAMESPACE;
- ns->href = xmlStrdup(XML_XML_NAMESPACE);
+ ns->href = xmlStrdup(XML_XML_NAMESPACE);
ns->prefix = xmlStrdup((const xmlChar *)"xml");
doc->oldNs = ns;
return (ns);
@@ -5596,7 +5625,7 @@ xmlTreeEnsureXMLDecl(xmlDocPtr doc)
*/
xmlNsPtr
xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
-
+
xmlNsPtr cur;
xmlNodePtr orig = node;
@@ -5616,8 +5645,8 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
}
memset(cur, 0, sizeof(xmlNs));
cur->type = XML_LOCAL_NAMESPACE;
- cur->href = xmlStrdup(XML_XML_NAMESPACE);
- cur->prefix = xmlStrdup((const xmlChar *)"xml");
+ cur->href = xmlStrdup(XML_XML_NAMESPACE);
+ cur->prefix = xmlStrdup((const xmlChar *)"xml");
cur->next = node->nsDef;
node->nsDef = cur;
return(cur);
@@ -5652,7 +5681,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
return(cur);
cur = cur->next;
}
- if (orig != node) {
+ if (orig != node) {
cur = node->ns;
if (cur != NULL) {
if ((cur->prefix == NULL) && (nameSpace == NULL) &&
@@ -5663,7 +5692,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
(xmlStrEqual(cur->prefix, nameSpace)))
return(cur);
}
- }
+ }
}
node = node->parent;
}
@@ -5679,7 +5708,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
*
* Verify that the given namespace held on @ancestor is still in scope
* on node.
- *
+ *
* Returns 1 if true, 0 if false and -1 in case of error.
*/
static int
@@ -5712,7 +5741,7 @@ xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node,
return (-1);
return (1);
}
-
+
/**
* xmlSearchNsByHref:
* @doc: the document
@@ -5766,7 +5795,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
if (doc->oldNs == NULL)
return(xmlTreeEnsureXMLDecl(doc));
else
- return(doc->oldNs);
+ return(doc->oldNs);
}
is_attr = (node->type == XML_ATTRIBUTE_NODE);
while (node != NULL) {
@@ -5795,7 +5824,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
return (cur);
}
}
- }
+ }
}
node = node->parent;
}
@@ -5858,7 +5887,7 @@ xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);
else
snprintf((char *) prefix, sizeof(prefix), "%.20s%d",
- (char *)ns->prefix, counter++);
+ (char *)ns->prefix, counter++);
def = xmlSearchNs(doc, tree, prefix);
}
@@ -6053,7 +6082,7 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
}
}
/* exit condition */
- if (node == tree)
+ if (node == tree)
node = NULL;
} else
break;
@@ -6109,14 +6138,14 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
/*
* Check if there is a default/fixed attribute declaration in
* the internal or external subset.
- */
+ */
if ((node->doc != NULL) && (node->doc->intSubset != NULL)) {
xmlDocPtr doc = node->doc;
xmlAttributePtr attrDecl = NULL;
xmlChar *elemQName, *tmpstr = NULL;
/*
- * We need the QName of the element for the DTD-lookup.
+ * We need the QName of the element for the DTD-lookup.
*/
if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
tmpstr = xmlStrdup(node->ns->prefix);
@@ -6167,7 +6196,7 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
cur++;
}
xmlFree(nsList);
- }
+ }
if (tmpstr != NULL)
xmlFree(tmpstr);
/*
@@ -6211,7 +6240,7 @@ xmlGetPropNodeValueInternal(xmlAttrPtr prop)
} else if (prop->type == XML_ATTRIBUTE_DECL) {
return(xmlStrdup(((xmlAttributePtr)prop)->defaultValue));
}
- return(NULL);
+ return(NULL);
}
/**
@@ -6223,7 +6252,7 @@ xmlGetPropNodeValueInternal(xmlAttrPtr prop)
* This function also looks in DTD attribute declaration for #FIXED or
* default declaration values unless DTD use has been turned off.
*
- * Returns the attribute or the attribute declaration or NULL if
+ * Returns the attribute or the attribute declaration or NULL if
* neither was found.
*/
xmlAttrPtr
@@ -6305,12 +6334,12 @@ xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
*/
xmlChar *
xmlGetProp(xmlNodePtr node, const xmlChar *name) {
- xmlAttrPtr prop;
+ xmlAttrPtr prop;
prop = xmlHasProp(node, name);
if (prop == NULL)
return(NULL);
- return(xmlGetPropNodeValueInternal(prop));
+ return(xmlGetPropNodeValueInternal(prop));
}
/**
@@ -6331,7 +6360,7 @@ xmlGetProp(xmlNodePtr node, const xmlChar *name) {
xmlChar *
xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
xmlAttrPtr prop;
-
+
prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD);
if (prop == NULL)
return(NULL);
@@ -6397,7 +6426,7 @@ xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
int
xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
xmlAttrPtr prop;
-
+
prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
if (prop == NULL)
return(-1);
@@ -6420,7 +6449,7 @@ xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
* error it there's no such ns-binding for the prefix in
* scope.
* Returns the attribute pointer.
- *
+ *
*/
xmlAttrPtr
xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
@@ -6463,7 +6492,7 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
const xmlChar *value)
{
xmlAttrPtr prop;
-
+
if (ns && (ns->href == NULL))
return(NULL);
prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
@@ -6475,14 +6504,14 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
xmlRemoveID(node->doc, prop);
prop->atype = XML_ATTRIBUTE_ID;
}
- if (prop->children != NULL)
+ if (prop->children != NULL)
xmlFreeNodeList(prop->children);
prop->children = NULL;
prop->last = NULL;
prop->ns = ns;
if (value != NULL) {
xmlNodePtr tmp;
-
+
if(!xmlCheckUTF8(value)) {
xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
NULL);
@@ -6514,7 +6543,7 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
/**
* xmlNodeIsText:
* @node: the node
- *
+ *
* Is this node a Text node ?
* Returns 1 yes, 0 no
*/
@@ -6529,7 +6558,7 @@ xmlNodeIsText(xmlNodePtr node) {
/**
* xmlIsBlankNode:
* @node: the node
- *
+ *
* Checks whether this node is an empty or whitespace only
* (and possibly ignorable) text-node.
*
@@ -6558,7 +6587,7 @@ xmlIsBlankNode(xmlNodePtr node) {
* @node: the node
* @content: the content
* @len: @content length
- *
+ *
* Concat the given string at the end of the existing node content
*
* Returns -1 in case of error, 0 otherwise
@@ -6623,6 +6652,7 @@ xmlBufferCreate(void) {
return(NULL);
}
ret->content[0] = 0;
+ ret->contentIO = NULL;
return(ret);
}
@@ -6655,6 +6685,7 @@ xmlBufferCreateSize(size_t size) {
ret->content[0] = 0;
} else
ret->content = NULL;
+ ret->contentIO = NULL;
return(ret);
}
@@ -6696,7 +6727,7 @@ xmlBufferCreateStatic(void *mem, size_t size) {
* Sets the allocation scheme for this buffer
*/
void
-xmlBufferSetAllocationScheme(xmlBufferPtr buf,
+xmlBufferSetAllocationScheme(xmlBufferPtr buf,
xmlBufferAllocationScheme scheme) {
if (buf == NULL) {
#ifdef DEBUG_BUFFER
@@ -6727,7 +6758,10 @@ xmlBufferFree(xmlBufferPtr buf) {
return;
}
- if ((buf->content != NULL) &&
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ xmlFree(buf->contentIO);
+ } else if ((buf->content != NULL) &&
(buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
xmlFree(buf->content);
}
@@ -6747,8 +6781,15 @@ xmlBufferEmpty(xmlBufferPtr buf) {
buf->use = 0;
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
buf->content = BAD_CAST "";
+ } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ buf->size += start_buf;
+ buf->content = buf->contentIO;
+ buf->content[0] = 0;
} else {
- memset(buf->content, 0, buf->size);
+ buf->content[0] = 0;
}
}
@@ -6768,10 +6809,30 @@ xmlBufferShrink(xmlBufferPtr buf, unsigned int len) {
if (len > buf->use) return(-1);
buf->use -= len;
- if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
+ /*
+ * we just move the content pointer, but also make sure
+ * the perceived buffer size has shrinked accordingly
+ */
buf->content += len;
+ buf->size -= len;
+
+ /*
+ * sometimes though it maybe be better to really shrink
+ * on IO buffers
+ */
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+ if (start_buf >= buf->size) {
+ memmove(buf->contentIO, &buf->content[0], buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ }
+ }
} else {
- memmove(buf->content, &buf->content[len], buf->use * sizeof(xmlChar));
+ memmove(buf->content, &buf->content[len], buf->use);
buf->content[buf->use] = 0;
}
return(len);
@@ -6809,12 +6870,24 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
size = buf->use + len + 100;
#endif
- newbuf = (xmlChar *) xmlRealloc(buf->content, size);
- if (newbuf == NULL) {
- xmlTreeErrMemory("growing buffer");
- return(-1);
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ newbuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + size);
+ if (newbuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return(-1);
+ }
+ buf->contentIO = newbuf;
+ buf->content = newbuf + start_buf;
+ } else {
+ newbuf = (xmlChar *) xmlRealloc(buf->content, size);
+ if (newbuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return(-1);
+ }
+ buf->content = newbuf;
}
- buf->content = newbuf;
buf->size = size;
return(buf->size - buf->use);
}
@@ -6871,7 +6944,7 @@ xmlBufferContent(const xmlBufferPtr buf)
/**
* xmlBufferLength:
- * @buf: the buffer
+ * @buf: the buffer
*
* Function to get the length of a buffer
*
@@ -6901,6 +6974,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
{
unsigned int newSize;
xmlChar* rebuf = NULL;
+ size_t start_buf;
if (buf == NULL)
return(0);
@@ -6913,42 +6987,62 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
/* figure out new size */
switch (buf->alloc){
- case XML_BUFFER_ALLOC_DOUBLEIT:
- /*take care of empty case*/
- newSize = (buf->size ? buf->size*2 : size + 10);
- while (size > newSize) newSize *= 2;
- break;
- case XML_BUFFER_ALLOC_EXACT:
- newSize = size+10;
- break;
- default:
- newSize = size+10;
- break;
- }
-
- if (buf->content == NULL)
- rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
- else if (buf->size - buf->use < 100) {
- rebuf = (xmlChar *) xmlRealloc(buf->content,
- newSize * sizeof(xmlChar));
- } else {
- /*
- * if we are reallocating a buffer far from being full, it's
- * better to make a new allocation and copy only the used range
- * and free the old one.
- */
- rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
- if (rebuf != NULL) {
- memcpy(rebuf, buf->content, buf->use);
- xmlFree(buf->content);
- rebuf[buf->use] = 0;
- }
+ case XML_BUFFER_ALLOC_IO:
+ case XML_BUFFER_ALLOC_DOUBLEIT:
+ /*take care of empty case*/
+ newSize = (buf->size ? buf->size*2 : size + 10);
+ while (size > newSize) newSize *= 2;
+ break;
+ case XML_BUFFER_ALLOC_EXACT:
+ newSize = size+10;
+ break;
+ default:
+ newSize = size+10;
+ break;
}
- if (rebuf == NULL) {
- xmlTreeErrMemory("growing buffer");
- return 0;
+
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > newSize) {
+ /* move data back to start */
+ memmove(buf->contentIO, buf->content, buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ } else {
+ rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize);
+ if (rebuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ buf->contentIO = rebuf;
+ buf->content = rebuf + start_buf;
+ }
+ } else {
+ if (buf->content == NULL) {
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ } else if (buf->size - buf->use < 100) {
+ rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
+ } else {
+ /*
+ * if we are reallocating a buffer far from being full, it's
+ * better to make a new allocation and copy only the used range
+ * and free the old one.
+ */
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ if (rebuf != NULL) {
+ memcpy(rebuf, buf->content, buf->use);
+ xmlFree(buf->content);
+ rebuf[buf->use] = 0;
+ }
+ }
+ if (rebuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ buf->content = rebuf;
}
- buf->content = rebuf;
buf->size = newSize;
return 1;
@@ -7043,6 +7137,20 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
if (len <= 0) return -1;
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > (unsigned int) len) {
+ /*
+ * We can add it in the space previously shrinked
+ */
+ buf->content -= len;
+ memmove(&buf->content[0], str, len);
+ buf->use += len;
+ buf->size += len;
+ return(0);
+ }
+ }
needSize = buf->use + len + 2;
if (needSize > buf->size){
if (!xmlBufferResize(buf, needSize)){
@@ -7051,8 +7159,8 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
}
}
- memmove(&buf->content[len], &buf->content[0], buf->use * sizeof(xmlChar));
- memmove(&buf->content[0], str, len * sizeof(xmlChar));
+ memmove(&buf->content[len], &buf->content[0], buf->use);
+ memmove(&buf->content[0], str, len);
buf->use += len;
buf->content[buf->use] = 0;
return 0;
@@ -7299,7 +7407,7 @@ struct xmlNsMap {
/*
* xmlDOMWrapNsMapFree:
* @map: the ns-map
-*
+*
* Frees the ns-map
*/
static void
@@ -7330,7 +7438,7 @@ xmlDOMWrapNsMapFree(xmlNsMapPtr nsmap)
* @oldNs: the old ns-struct
* @newNs: the new ns-struct
* @depth: depth and ns-kind information
-*
+*
* Adds an ns-mapping item.
*/
static xmlNsMapItemPtr
@@ -7358,7 +7466,7 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
memset(map, 0, sizeof(struct xmlNsMap));
*nsmap = map;
}
-
+
if (map->pool != NULL) {
/*
* Reuse an item from the pool.
@@ -7377,11 +7485,11 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
}
memset(ret, 0, sizeof(struct xmlNsMapItem));
}
-
+
if (map->first == NULL) {
/*
* First ever.
- */
+ */
map->first = ret;
map->last = ret;
} else if (position == -1) {
@@ -7390,14 +7498,14 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
*/
ret->prev = map->last;
map->last->next = ret;
- map->last = ret;
+ map->last = ret;
} else if (position == 0) {
/*
* Set on first position.
*/
map->first->prev = ret;
- ret->next = map->first;
- map->first = ret;
+ ret->next = map->first;
+ map->first = ret;
} else
return(NULL);
@@ -7413,10 +7521,10 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
* @doc: the doc
* @nsName: the namespace name
* @prefix: the prefix
-*
+*
* Creates or reuses an xmlNs struct on doc->oldNs with
* the given prefix and namespace name.
-*
+*
* Returns the aquired ns struct or NULL in case of an API
* or internal error.
*/
@@ -7456,7 +7564,7 @@ xmlDOMWrapStoreNs(xmlDocPtr doc,
*
* Allocates and initializes a new DOM-wrapper context.
*
-* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror.
+* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror.
*/
xmlDOMWrapCtxtPtr
xmlDOMWrapNewCtxt(void)
@@ -7495,9 +7603,9 @@ xmlDOMWrapFreeCtxt(xmlDOMWrapCtxtPtr ctxt)
* xmlTreeLookupNsListByPrefix:
* @nsList: a list of ns-structs
* @prefix: the searched prefix
-*
+*
* Searches for a ns-decl with the given prefix in @nsList.
-*
+*
* Returns the ns-decl if found, NULL if not found and on
* API errors.
*/
@@ -7525,9 +7633,9 @@ xmlTreeNSListLookupByPrefix(xmlNsPtr nsList, const xmlChar *prefix)
* xmlDOMWrapNSNormGatherInScopeNs:
* @map: the namespace map
* @node: the node to start with
-*
+*
* Puts in-scope namespaces into the ns-map.
-*
+*
* Returns 0 on success, -1 on API or internal errors.
*/
static int
@@ -7619,7 +7727,7 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map,
*
* For internal use. Adds a ns-decl mapping.
*
-* Returns 0 on success, -1 on internal errors.
+* Returns 0 on success, -1 on internal errors.
*/
static int
xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
@@ -7663,7 +7771,7 @@ xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
* NOTE: This function was not intensively tested.
*
* Returns 0 on success, 1 if the node is not supported,
-* -1 on API and internal errors.
+* -1 on API and internal errors.
*/
int
xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
@@ -7680,7 +7788,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
if (node->parent == NULL)
return (0);
- switch (node->type) {
+ switch (node->type) {
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
@@ -7688,7 +7796,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
case XML_COMMENT_NODE:
xmlUnlinkNode(node);
return (0);
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
break;
default:
@@ -7712,7 +7820,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
}
/* No break on purpose. */
case XML_ATTRIBUTE_NODE:
- if (node->ns != NULL) {
+ if (node->ns != NULL) {
/*
* Find a mapping.
*/
@@ -7756,14 +7864,14 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
break;
default:
goto next_sibling;
- }
-next_node:
+ }
+next_node:
if ((node->type == XML_ELEMENT_NODE) &&
(node->children != NULL)) {
node = node->children;
continue;
}
-next_sibling:
+next_sibling:
if (node == NULL)
break;
if (node->next != NULL)
@@ -7856,7 +7964,7 @@ xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node,
*/
if (out) {
int ret;
-
+
ret = xmlNsInScope(doc, node, prev, ns->prefix);
if (ret < 0)
return (-1);
@@ -7924,7 +8032,7 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
if (cur->type == XML_ELEMENT_NODE) {
if (cur->nsDef != NULL) {
ns = cur->nsDef;
- do {
+ do {
if ((prefix == ns->prefix) ||
xmlStrEqual(prefix, ns->prefix))
{
@@ -7938,7 +8046,7 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
return (1);
}
ns = ns->next;
- } while (ns != NULL);
+ } while (ns != NULL);
}
} else if ((cur->type == XML_ENTITY_NODE) ||
(cur->type == XML_ENTITY_DECL))
@@ -8045,12 +8153,12 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
xmlNsPtr ns,
xmlNsPtr *retNs,
xmlNsMapPtr *nsMap,
-
+
int depth,
int ancestorsOnly,
int prefixed)
{
- xmlNsMapItemPtr mi;
+ xmlNsMapItemPtr mi;
if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
(nsMap == NULL))
@@ -8075,13 +8183,13 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
*/
if ((XML_NSMAP_NOTEMPTY(*nsMap)) &&
(! (ancestorsOnly && (elem == NULL))))
- {
+ {
/*
* Try to find an equal ns-name in in-scope ns-decls.
*/
XML_NSMAP_FOREACH(*nsMap, mi) {
- if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
- /*
+ if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
+ /*
* ancestorsOnly: This should be turned on to gain speed,
* if one knows that the branch itself was already
* ns-wellformed and no stale references existed.
@@ -8089,10 +8197,10 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
*/
((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) &&
/* Skip shadowed prefixes. */
- (mi->shadowDepth == -1) &&
+ (mi->shadowDepth == -1) &&
/* Skip xmlns="" or xmlns:foo="". */
((mi->newNs->href != NULL) &&
- (mi->newNs->href[0] != 0)) &&
+ (mi->newNs->href[0] != 0)) &&
/* Ensure a prefix if wanted. */
((! prefixed) || (mi->newNs->prefix != NULL)) &&
/* Equal ns name */
@@ -8119,7 +8227,7 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
return (-1);
/*
* Insert mapping.
- */
+ */
if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns,
tmpns, XML_TREE_NSMAP_DOC) == NULL) {
xmlFreeNs(tmpns);
@@ -8161,7 +8269,7 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
}
typedef enum {
- XML_DOM_RECONNS_REMOVEREDUND = 1<<0
+ XML_DOM_RECONNS_REMOVEREDUND = 1<<0
} xmlDOMReconcileNSOptions;
/*
@@ -8179,7 +8287,7 @@ typedef enum {
* NOTE: This function was not intensively tested.
*
* Returns 0 if succeeded, -1 otherwise and on API/internal errors.
-*/
+*/
int
xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
@@ -8194,7 +8302,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlNsMapItemPtr /* topmi = NULL, */ mi;
/* @ancestorsOnly should be set by an option flag. */
int ancestorsOnly = 0;
- int optRemoveRedundantNS =
+ int optRemoveRedundantNS =
((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0;
xmlNsPtr *listRedund = NULL;
int sizeRedund = 0, nbRedund = 0, ret, i, j;
@@ -8230,7 +8338,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
}
parnsdone = 1;
}
-
+
/*
* Lookup the ns ancestor-axis for equal ns-decls in scope.
*/
@@ -8242,7 +8350,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
((ns->href == mi->newNs->href) ||
xmlStrEqual(ns->href, mi->newNs->href)))
- {
+ {
/*
* A redundant ns-decl was found.
* Add it to the list of redundant ns-decls.
@@ -8252,11 +8360,11 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
goto internal_error;
/*
* Remove the ns-decl from the element-node.
- */
+ */
if (prevns)
prevns->next = ns->next;
else
- cur->nsDef = ns->next;
+ cur->nsDef = ns->next;
goto next_ns_decl;
}
}
@@ -8267,7 +8375,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
* ns-decl is declared on the same element.
*/
if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
- adoptns = 0;
+ adoptns = 0;
/*
* Does it shadow any ns-decl?
*/
@@ -8277,7 +8385,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
-
+
mi->shadowDepth = depth;
}
}
@@ -8287,11 +8395,11 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
*/
if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
depth) == NULL)
- goto internal_error;
+ goto internal_error;
prevns = ns;
next_ns_decl:
- ns = ns->next;
+ ns = ns->next;
}
}
if (! adoptns)
@@ -8301,7 +8409,7 @@ next_ns_decl:
/* No ns, no fun. */
if (cur->ns == NULL)
goto ns_end;
-
+
if (! parnsdone) {
if ((elem->parent) &&
((xmlNodePtr) elem->parent->doc != elem->parent)) {
@@ -8320,7 +8428,7 @@ next_ns_decl:
cur->ns = listRedund[++j];
break;
}
- }
+ }
}
/*
* Adopt ns-references.
@@ -8358,7 +8466,7 @@ ns_end:
cur = (xmlNodePtr) cur->properties;
continue;
}
- break;
+ break;
default:
goto next_sibling;
}
@@ -8371,18 +8479,18 @@ into_content:
cur = cur->children;
continue;
}
-next_sibling:
+next_sibling:
if (cur == elem)
break;
if (cur->type == XML_ELEMENT_NODE) {
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
+ XML_NSMAP_POP(nsMap, mi)
}
/*
* Unshadow.
@@ -8391,7 +8499,7 @@ next_sibling:
if (mi->shadowDepth >= depth)
mi->shadowDepth = -1;
}
- }
+ }
depth--;
}
if (cur->next != NULL)
@@ -8405,13 +8513,13 @@ next_sibling:
goto next_sibling;
}
} while (cur != NULL);
-
+
ret = 0;
goto exit;
internal_error:
ret = -1;
exit:
- if (listRedund) {
+ if (listRedund) {
for (i = 0, j = 0; i < nbRedund; i++, j += 2) {
xmlFreeNs(listRedund[j]);
}
@@ -8462,7 +8570,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
int parnsdone;
/* @ancestorsOnly should be set per option. */
int ancestorsOnly = 0;
-
+
/*
* Optimize string adoption for equal or none dicts.
*/
@@ -8516,17 +8624,17 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
}
cur->doc = destDoc;
switch (cur->type) {
- case XML_XINCLUDE_START:
+ case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
/*
* TODO
*/
return (-1);
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
curElem = cur;
depth++;
/*
- * Namespace declarations.
+ * Namespace declarations.
* - ns->href and ns->prefix are never in the dict, so
* we need not move the values over to the destination dict.
* - Note that for custom handling of ns-references,
@@ -8550,10 +8658,10 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
* NOTE: ns->prefix and ns->href are never in the dict.
* XML_TREE_ADOPT_STR(ns->prefix)
* XML_TREE_ADOPT_STR(ns->href)
- */
+ */
/*
* Does it shadow any ns-decl?
- */
+ */
if (XML_NSMAP_NOTEMPTY(nsMap)) {
XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
@@ -8561,7 +8669,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix,
mi->newNs->prefix))) {
-
+
mi->shadowDepth = depth;
}
}
@@ -8624,7 +8732,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
* Aquire a normalized ns-decl and add it to the map.
*/
if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
- /* ns-decls on curElem or on destDoc->oldNs */
+ /* ns-decls on curElem or on destDoc->oldNs */
destParent ? curElem : NULL,
cur->ns, &ns,
&nsMap, depth,
@@ -8660,7 +8768,7 @@ ns_end:
*/
if ((sourceDoc != NULL) &&
(((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID))
- {
+ {
xmlRemoveID(sourceDoc, (xmlAttrPtr) cur);
}
((xmlAttrPtr) cur)->atype = 0;
@@ -8668,13 +8776,13 @@ ns_end:
}
break;
case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
+ case XML_CDATA_SECTION_NODE:
/*
* This puts the content in the dest dict, only if
* it was previously in the source dict.
*/
- XML_TREE_ADOPT_STR_2(cur->content)
- goto leave_node;
+ XML_TREE_ADOPT_STR_2(cur->content)
+ goto leave_node;
case XML_ENTITY_REF_NODE:
/*
* Remove reference to the entitity-node.
@@ -8699,7 +8807,7 @@ ns_end:
XML_TREE_ADOPT_STR(cur->name)
XML_TREE_ADOPT_STR_2(cur->content)
break;
- case XML_COMMENT_NODE:
+ case XML_COMMENT_NODE:
break;
default:
goto internal_error;
@@ -8722,15 +8830,15 @@ leave_node:
/*
* TODO: Do we expect nsDefs on XML_XINCLUDE_START?
*/
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
- }
+ XML_NSMAP_POP(nsMap, mi)
+ }
/*
* Unshadow.
*/
@@ -8752,10 +8860,10 @@ leave_node:
goto leave_node;
}
}
-
+
goto exit;
-internal_error:
+internal_error:
ret = -1;
exit:
@@ -8773,7 +8881,7 @@ exit:
nsMap->pool = nsMap->first;
nsMap->first = NULL;
}
- } else
+ } else
xmlDOMWrapNsMapFree(nsMap);
}
return(ret);
@@ -8795,7 +8903,7 @@ exit:
* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used.
* This is the case when you don't know already where the cloned branch
* will be added to.
-*
+*
* If @destParent is given, it ensures that the tree is namespace
* wellformed by creating additional ns-decls where needed.
* Note that, since prefixes of already existent ns-decls can be
@@ -8829,7 +8937,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/* gather @parent's ns-decls. */
int parnsdone = 0;
/*
- * @ancestorsOnly:
+ * @ancestorsOnly:
* TODO: @ancestorsOnly should be set per option.
*
*/
@@ -8856,7 +8964,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
return (-1);
}
if (sourceDoc == NULL)
- sourceDoc = node->doc;
+ sourceDoc = node->doc;
if (sourceDoc == NULL)
return (-1);
@@ -8868,7 +8976,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
nsMap = (xmlNsMapPtr) ctxt->namespaceMap;
*resNode = NULL;
-
+
cur = node;
while (cur != NULL) {
if (cur->doc != sourceDoc) {
@@ -8877,7 +8985,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* TODO: Do we need to reconciliate XIncluded nodes?
* TODO: This here returns -1 in this case.
*/
- goto internal_error;
+ goto internal_error;
}
/*
* Create a new node.
@@ -8892,9 +9000,9 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
break;
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
+ case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
- case XML_PI_NODE:
+ case XML_PI_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
@@ -8906,20 +9014,20 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating a node");
goto internal_error;
}
- memset(clone, 0, sizeof(xmlNode));
+ memset(clone, 0, sizeof(xmlNode));
/*
* Set hierachical links.
*/
- if (resultClone != NULL) {
+ if (resultClone != NULL) {
clone->parent = parentClone;
if (prevClone) {
prevClone->next = clone;
clone->prev = prevClone;
- } else
+ } else
parentClone->children = clone;
} else
resultClone = clone;
-
+
break;
case XML_ATTRIBUTE_NODE:
/*
@@ -8930,7 +9038,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node");
goto internal_error;
}
- memset(clone, 0, sizeof(xmlAttr));
+ memset(clone, 0, sizeof(xmlAttr));
/*
* Set hierachical links.
* TODO: Change this to add to the end of attributes.
@@ -8940,7 +9048,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
if (prevClone) {
prevClone->next = clone;
clone->prev = prevClone;
- } else
+ } else
parentClone->properties = (xmlAttrPtr) clone;
} else
resultClone = clone;
@@ -8953,8 +9061,8 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
clone->type = cur->type;
- clone->doc = destDoc;
-
+ clone->doc = destDoc;
+
/*
* Clone the name of the node if any.
*/
@@ -8964,14 +9072,14 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* NOTE: Although xmlStringTextNoenc is never assigned to a node
* in tree.c, it might be set in Libxslt via
- * "xsl:disable-output-escaping".
+ * "xsl:disable-output-escaping".
*/
clone->name = xmlStringTextNoenc;
else if (cur->name == xmlStringComment)
clone->name = xmlStringComment;
else if (cur->name != NULL) {
DICT_CONST_COPY(cur->name, clone->name);
- }
+ }
switch (cur->type) {
case XML_XINCLUDE_START:
@@ -8994,7 +9102,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
*/
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,
destParent) == -1)
- goto internal_error;
+ goto internal_error;
}
parnsdone = 1;
}
@@ -9014,7 +9122,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
memset(cloneNs, 0, sizeof(xmlNs));
cloneNs->type = XML_LOCAL_NAMESPACE;
-
+
if (ns->href != NULL)
cloneNs->href = xmlStrdup(ns->href);
if (ns->prefix != NULL)
@@ -9035,7 +9143,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* Does it shadow any ns-decl?
*/
if (XML_NSMAP_NOTEMPTY(nsMap)) {
- XML_NSMAP_FOREACH(nsMap, mi) {
+ XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
@@ -9060,7 +9168,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
/* cur->ns will be processed further down. */
break;
- case XML_ATTRIBUTE_NODE:
+ case XML_ATTRIBUTE_NODE:
/* IDs will be processed further down. */
/* cur->ns will be processed further down. */
break;
@@ -9069,12 +9177,12 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* Note that this will also cover the values of attributes.
*/
- DICT_COPY(cur->content, clone->content);
+ DICT_COPY(cur->content, clone->content);
goto leave_node;
case XML_ENTITY_NODE:
/* TODO: What to do here? */
goto leave_node;
- case XML_ENTITY_REF_NODE:
+ case XML_ENTITY_REF_NODE:
if (sourceDoc != destDoc) {
if ((destDoc->intSubset) || (destDoc->extSubset)) {
xmlEntityPtr ent;
@@ -9114,13 +9222,13 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/* handle_ns_reference: */
/*
** The following will take care of references to ns-decls ********
- ** and is intended only for element- and attribute-nodes.
+ ** and is intended only for element- and attribute-nodes.
**
*/
if (! parnsdone) {
if (destParent && (ctxt == NULL)) {
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1)
- goto internal_error;
+ goto internal_error;
}
parnsdone = 1;
}
@@ -9131,7 +9239,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* Search for a mapping.
*/
- XML_NSMAP_FOREACH(nsMap, mi) {
+ XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->shadowDepth == -1) &&
(cur->ns == mi->oldNs)) {
/*
@@ -9163,7 +9271,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* Aquire a normalized ns-decl and add it to the map.
*/
if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
- /* ns-decls on curElem or on destDoc->oldNs */
+ /* ns-decls on curElem or on destDoc->oldNs */
destParent ? curElem : NULL,
cur->ns, &ns,
&nsMap, depth,
@@ -9186,9 +9294,9 @@ end_ns_reference:
(clone->parent != NULL))
{
if (xmlIsID(destDoc, clone->parent, (xmlAttrPtr) clone)) {
-
+
xmlChar *idVal;
-
+
idVal = xmlNodeListGetString(cur->doc, cur->children, 1);
if (idVal != NULL) {
if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) {
@@ -9204,12 +9312,12 @@ end_ns_reference:
**
** The following will traverse the tree **************************
**
- *
+ *
* Walk the element's attributes before descending into child-nodes.
*/
if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) {
prevClone = NULL;
- parentClone = clone;
+ parentClone = clone;
cur = (xmlNodePtr) cur->properties;
continue;
}
@@ -9239,14 +9347,14 @@ leave_node:
/*
* TODO: Do we expect nsDefs on XML_XINCLUDE_START?
*/
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
+ XML_NSMAP_POP(nsMap, mi)
}
/*
* Unshadow.
@@ -9255,7 +9363,7 @@ leave_node:
if (mi->shadowDepth >= depth)
mi->shadowDepth = -1;
}
- }
+ }
depth--;
}
if (cur->next != NULL) {
@@ -9268,7 +9376,7 @@ leave_node:
if (clone->parent != NULL)
clone->parent->last = clone;
clone = clone->parent;
- parentClone = clone->parent;
+ parentClone = clone->parent;
/*
* Process parent --> next;
*/
@@ -9277,14 +9385,14 @@ leave_node:
} else {
/* This is for attributes only. */
clone = clone->parent;
- parentClone = clone->parent;
+ parentClone = clone->parent;
/*
* Process parent-element --> children.
*/
cur = cur->parent;
- goto into_content;
+ goto into_content;
}
- }
+ }
goto exit;
internal_error:
@@ -9305,7 +9413,7 @@ exit:
nsMap->pool = nsMap->first;
nsMap->first = NULL;
}
- } else
+ } else
xmlDOMWrapNsMapFree(nsMap);
}
/*
@@ -9345,7 +9453,7 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
if ((attr == NULL) || (destDoc == NULL))
return (-1);
-
+
attr->doc = destDoc;
if (attr->ns != NULL) {
xmlNsPtr ns = NULL;
@@ -9372,13 +9480,13 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent,
attr->ns->href, attr->ns->prefix, 1);
}
- }
+ }
if (ns == NULL)
goto internal_error;
attr->ns = ns;
- }
-
- XML_TREE_ADOPT_STR(attr->name);
+ }
+
+ XML_TREE_ADOPT_STR(attr->name);
attr->atype = 0;
attr->psvi = NULL;
/*
@@ -9393,7 +9501,7 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
XML_TREE_ADOPT_STR_2(cur->content)
- break;
+ break;
case XML_ENTITY_REF_NODE:
/*
* Remove reference to the entitity-node.
@@ -9411,7 +9519,7 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
cur->content = ent->content;
cur->children = (xmlNodePtr) ent;
cur->last = (xmlNodePtr) ent;
- }
+ }
}
break;
default:
@@ -9449,8 +9557,8 @@ internal_error:
* 1) If @destParent is given, then nsDef entries on element-nodes are used
* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used
* This is the case when you have an unliked node and just want to move it
-* to the context of
-*
+* to the context of
+*
* If @destParent is given, it ensures that the tree is namespace
* wellformed by creating additional ns-decls where needed.
* Note that, since prefixes of already existent ns-decls can be
@@ -9467,7 +9575,7 @@ int
xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr sourceDoc,
xmlNodePtr node,
- xmlDocPtr destDoc,
+ xmlDocPtr destDoc,
xmlNodePtr destParent,
int options)
{
@@ -9476,7 +9584,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
return(-1);
/*
* Check node->doc sanity.
- */
+ */
if ((node->doc != NULL) && (sourceDoc != NULL) &&
(node->doc != sourceDoc)) {
/*
@@ -9489,7 +9597,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
if (sourceDoc == destDoc)
return (-1);
switch (node->type) {
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
@@ -9515,7 +9623,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
} else if (node->type == XML_ATTRIBUTE_NODE) {
return (xmlDOMWrapAdoptAttr(ctxt, sourceDoc,
(xmlAttrPtr) node, destDoc, destParent, options));
- } else {
+ } else {
xmlNodePtr cur = node;
int adoptStr = 1;
@@ -9527,7 +9635,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
(sourceDoc->dict == destDoc->dict))
adoptStr = 0;
switch (node->type) {
- case XML_TEXT_NODE:
+ case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
XML_TREE_ADOPT_STR_2(node->content)
break;
@@ -9560,7 +9668,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
default:
break;
}
- }
+ }
return (0);
}