chregu Mon Jan 6 04:59:54 2003 EDT
Modified files:
/php4/ext/domxml php_domxml.c php_domxml.h
Log:
- get_path forgotten in .h file
- fix crash in domxml_node_insert_before() (by Lukas Schr�der)
Index: php4/ext/domxml/php_domxml.c
diff -u php4/ext/domxml/php_domxml.c:1.229 php4/ext/domxml/php_domxml.c:1.230
--- php4/ext/domxml/php_domxml.c:1.229 Mon Jan 6 03:47:35 2003
+++ php4/ext/domxml/php_domxml.c Mon Jan 6 04:59:53 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_domxml.c,v 1.229 2003/01/06 08:47:35 chregu Exp $ */
+/* $Id: php_domxml.c,v 1.230 2003/01/06 09:59:53 chregu Exp $ */
/* TODO
* - Support Notation Nodes
@@ -2426,9 +2426,40 @@
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
Index: php4/ext/domxml/php_domxml.h
diff -u php4/ext/domxml/php_domxml.h:1.74 php4/ext/domxml/php_domxml.h:1.75
--- php4/ext/domxml/php_domxml.h:1.74 Tue Dec 31 11:06:32 2002
+++ php4/ext/domxml/php_domxml.h Mon Jan 6 04:59:53 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_domxml.h,v 1.74 2002/12/31 16:06:32 sebastian Exp $ */
+/* $Id: php_domxml.h,v 1.75 2003/01/06 09:59:53 chregu Exp $ */
#ifndef PHP_DOMXML_H
#define PHP_DOMXML_H
@@ -153,6 +153,7 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php