summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2003-01-06 09:59:53 +0000
committerChristian Stocker <chregu@php.net>2003-01-06 09:59:53 +0000
commit413053aa75a757f5f5fee9a9f605cadd388f83e6 (patch)
treeb005051a8abb55c26c6869ffa3460aad96d08602
parent159f0bcdd882befd8624d13f2d3b3e5ecfb95e9a (diff)
downloadphp-git-413053aa75a757f5f5fee9a9f605cadd388f83e6.tar.gz
- get_path forgotten in .h file
- fix crash in domxml_node_insert_before() (by Lukas Schröder)
-rw-r--r--ext/domxml/php_domxml.c33
-rw-r--r--ext/domxml/php_domxml.h1
2 files changed, 33 insertions, 1 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
index 67290d79c7..3aef2a068d 100644
--- a/ext/domxml/php_domxml.c
+++ b/ext/domxml/php_domxml.c
@@ -2426,9 +2426,40 @@ PHP_FUNCTION(domxml_node_insert_before)
DOMXML_GET_OBJ(child, node, le_domxmlnodep);
+ new_child = NULL;
+
if (ref != NULL) {
DOMXML_GET_OBJ(refp, ref, le_domxmlnodep);
- new_child = xmlAddPrevSibling(refp, child);
+
+ /*
+ * The following code is from libxml2/tree.c
+ * libxml does free textnodes, if there are adjacent TEXT nodes
+ * This is bad behaviour for domxml, since then we have have reference
+ * to undefined nodes. The idea here is, that we do this text comparison
+ * by ourself and not free the nodes. and only if libxml2 won't do any harm
+ * call the function from libxml2.
+ * The code is exactly the same as in libxml2, only xmlFreeNode was taken away.
+ */
+
+ if (child->type == XML_TEXT_NODE) {
+ if (refp->type == XML_TEXT_NODE) {
+ xmlChar *tmp;
+
+ tmp = xmlStrdup(child->content);
+ tmp = xmlStrcat(tmp, refp->content);
+ xmlNodeSetContent(refp, tmp);
+ xmlFree(tmp);
+ new_child = refp;
+ }
+ if ((refp->prev != NULL) && (refp->prev->type == XML_TEXT_NODE)
+ && (refp->name == refp->prev->name)) {
+ xmlNodeAddContent(refp->prev, child->content);
+ new_child = refp->prev;
+ }
+ }
+
+ if (new_child == NULL)
+ new_child = xmlAddPrevSibling(refp, child);
} else {
/* first unlink node, if child is already a child of parent
for some strange reason, this is needed
diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h
index f3495172c7..557b2d0f05 100644
--- a/ext/domxml/php_domxml.h
+++ b/ext/domxml/php_domxml.h
@@ -153,6 +153,7 @@ PHP_FUNCTION(domxml_node_set_content);
PHP_FUNCTION(domxml_node_get_content);
PHP_FUNCTION(domxml_node_text_concat);
PHP_FUNCTION(domxml_node_set_name);
+PHP_FUNCTION(domxml_node_get_path);
PHP_FUNCTION(domxml_node_name);
PHP_FUNCTION(domxml_node_type);
PHP_FUNCTION(domxml_node_value);