mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
apply an patch from Petr Kozelka for unlink and replace support of
* tree.c: apply an patch from Petr Kozelka for unlink and replace support of attribute nodes Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Tue Jan 22 22:38:42 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* tree.c: apply an patch from Petr Kozelka for unlink and replace
|
||||||
|
support of attribute nodes
|
||||||
|
|
||||||
Tue Jan 22 19:12:06 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Tue Jan 22 19:12:06 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* doc/libxml2-api.xml doc/parsedecl.py: Build a new version
|
* doc/libxml2-api.xml doc/parsedecl.py: Build a new version
|
||||||
|
46
tree.c
46
tree.c
@ -2506,16 +2506,25 @@ xmlUnlinkNode(xmlNodePtr cur) {
|
|||||||
if (doc->extSubset == (xmlDtdPtr) cur)
|
if (doc->extSubset == (xmlDtdPtr) cur)
|
||||||
doc->extSubset = NULL;
|
doc->extSubset = NULL;
|
||||||
}
|
}
|
||||||
if ((cur->parent != NULL) && (cur->parent->children == cur))
|
if (cur->parent != NULL) {
|
||||||
cur->parent->children = cur->next;
|
xmlNodePtr parent;
|
||||||
if ((cur->parent != NULL) && (cur->parent->last == cur))
|
parent = cur->parent;
|
||||||
cur->parent->last = cur->prev;
|
if (cur->type == XML_ATTRIBUTE_NODE) {
|
||||||
|
if (parent->properties == (xmlAttrPtr) cur)
|
||||||
|
parent->properties = ((xmlAttrPtr) cur)->next;
|
||||||
|
} else {
|
||||||
|
if (parent->children == cur)
|
||||||
|
parent->children = cur->next;
|
||||||
|
if (parent->last == cur)
|
||||||
|
parent->last = cur->prev;
|
||||||
|
}
|
||||||
|
cur->parent = NULL;
|
||||||
|
}
|
||||||
if (cur->next != NULL)
|
if (cur->next != NULL)
|
||||||
cur->next->prev = cur->prev;
|
cur->next->prev = cur->prev;
|
||||||
if (cur->prev != NULL)
|
if (cur->prev != NULL)
|
||||||
cur->prev->next = cur->next;
|
cur->prev->next = cur->next;
|
||||||
cur->next = cur->prev = NULL;
|
cur->next = cur->prev = NULL;
|
||||||
cur->parent = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2545,6 +2554,20 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
|||||||
if (cur == old) {
|
if (cur == old) {
|
||||||
return(old);
|
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);
|
xmlUnlinkNode(cur);
|
||||||
cur->doc = old->doc;
|
cur->doc = old->doc;
|
||||||
cur->parent = old->parent;
|
cur->parent = old->parent;
|
||||||
@ -2555,10 +2578,15 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
|||||||
if (cur->prev != NULL)
|
if (cur->prev != NULL)
|
||||||
cur->prev->next = cur;
|
cur->prev->next = cur;
|
||||||
if (cur->parent != NULL) {
|
if (cur->parent != NULL) {
|
||||||
if (cur->parent->children == old)
|
if (cur->type == XML_ATTRIBUTE_NODE) {
|
||||||
cur->parent->children = cur;
|
if (cur->parent->properties == (xmlAttrPtr)old)
|
||||||
if (cur->parent->last == old)
|
cur->parent->properties = ((xmlAttrPtr) cur);
|
||||||
cur->parent->last = cur;
|
} else {
|
||||||
|
if (cur->parent->children == old)
|
||||||
|
cur->parent->children = cur;
|
||||||
|
if (cur->parent->last == old)
|
||||||
|
cur->parent->last = cur;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
old->next = old->prev = NULL;
|
old->next = old->prev = NULL;
|
||||||
old->parent = NULL;
|
old->parent = NULL;
|
||||||
|
Reference in New Issue
Block a user