Index: node.c =================================================================== RCS file: /repository/php-src/ext/dom/node.c,v retrieving revision 1.28 diff -r1.28 node.c 876a877,881 > > if (dom_node_children_valid(parentp) == FAILURE) { > RETURN_FALSE; > } > 898a904,908 > if (child->type == XML_DOCUMENT_FRAG_NODE && child->children == NULL) { > php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document Fragment is empty"); > RETURN_FALSE; > } > 915,932c925,941 < 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); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, refp, &ret, intern); < return; < } < if ((refp->prev != NULL) && (refp->prev->type == XML_TEXT_NODE) < && (refp->name == refp->prev->name)) { < xmlNodeAddContent(refp->prev, child->content); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, refp->prev, &ret, intern); < return; --- > if (child->type == XML_TEXT_NODE && (refp->type == XML_TEXT_NODE || > (refp->prev != NULL && refp->prev->type == XML_TEXT_NODE))) { > if (child->doc == NULL) { > xmlSetTreeDoc(child, parentp->doc); > } > new_child = child; > new_child->parent = refp->parent; > new_child->next = refp; > new_child->prev = refp->prev; > refp->prev = new_child; > if (new_child->prev != NULL) { > new_child->prev->next = new_child; > } > if (new_child->parent != NULL) { > if (new_child->parent->children == refp) { > new_child->parent->children = new_child; > } 933a943 > 949a960,961 > } else if (child->type == XML_DOCUMENT_FRAG_NODE) { > xmlNodePtr fragment; 950a963,990 > fragment = child; > new_child = child->children; > child = new_child; > while (child->next != NULL) { > child->parent = parentp; > if (child->doc != parentp->doc) { > xmlSetTreeDoc(child, parentp->doc); > } > child = child->next; > } > child->parent = parentp; > if (child->doc != parentp->doc) { > xmlSetTreeDoc(child, parentp->doc); > } > > if (refp->prev != NULL) { > refp->prev->next = new_child; > } else { > parentp->children = new_child; > } > new_child->prev = refp->prev; > refp->prev = child; > child->next = refp; > fragment->children = NULL; > } > > if (new_child == NULL) { > new_child = xmlAddPrevSibling(refp, child); 952d991 < new_child = xmlAddPrevSibling(refp, child); 957,972c996,1009 < if (child->type == XML_TEXT_NODE) { < if ((parentp->type == XML_TEXT_NODE) && < (parentp->content != NULL) && < (parentp != child)) { < xmlNodeAddContent(parentp, child->content); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, parentp, &ret, intern); < return; < } < if ((parentp->last != NULL) && (parentp->last->type == XML_TEXT_NODE) && < (parentp->last->name == child->name) && < (parentp->last != child)) { < xmlNodeAddContent(parentp->last, child->content); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, parentp->last, &ret, intern); < return; --- > if (child->type == XML_TEXT_NODE && parentp->last != NULL && parentp->last->type == XML_TEXT_NODE) { > child->parent = parentp; > if (child->doc == NULL) { > xmlSetTreeDoc(child, parentp->doc); > } > new_child = child; > if (parentp->children == NULL) { > parentp->children = child; > parentp->last = child; > } else { > child = parentp->last; > child->next = new_child; > new_child->prev = child; > parentp->last = new_child; 990,993c1027,1046 < } else if (child->type == XML_DOCUMENT_FRAG_NODE) { < new_child = xmlAddChildList(parentp, child->children); < if (new_child != NULL) { < child->children = NULL; --- > } else if (child->type == XML_DOCUMENT_FRAG_NODE) { > xmlNodePtr fragment; > > fragment = child; > > new_child = child->children; > if (parentp->children == NULL) { > parentp->children = new_child; > } else { > child = parentp->last; > child->next = new_child; > new_child->prev = child; > } > child = new_child; > while (child->next != NULL) { > child->parent = parentp; > if (child->doc != parentp->doc) { > xmlSetTreeDoc(child, parentp->doc); > } > child = child->next; 995,996c1048,1056 < DOM_RET_OBJ(rv, new_child, &ret, intern); < return; --- > child->parent = parentp; > if (child->doc != parentp->doc) { > xmlSetTreeDoc(child, parentp->doc); > } > parentp->last = child; > fragment->children = NULL; > } > if (new_child == NULL) { > new_child = xmlAddChild(parentp, child); 998d1057 < new_child = xmlAddChild(parentp, child); 1188a1248,1252 > if (child->type == XML_DOCUMENT_FRAG_NODE && child->children == NULL) { > php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document Fragment is empty"); > RETURN_FALSE; > } > 1198,1211c1262,1275 < if (child->type == XML_TEXT_NODE) { < if ((nodep->type == XML_TEXT_NODE) && < (nodep->content != NULL)) { < xmlNodeAddContent(nodep, child->content); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, nodep, &ret, intern); < return; < } < if ((nodep->last != NULL) && (nodep->last->type == XML_TEXT_NODE) && < (nodep->last->name == child->name)) { < xmlNodeAddContent(nodep->last, child->content); < php_libxml_node_free_resource(child TSRMLS_CC); < DOM_RET_OBJ(rv, nodep->last, &ret, intern); < return; --- > if (child->type == XML_TEXT_NODE && nodep->last != NULL && nodep->last->type == XML_TEXT_NODE) { > child->parent = nodep; > if (child->doc == NULL) { > xmlSetTreeDoc(child, nodep->doc); > } > new_child = child; > if (nodep->children == NULL) { > nodep->children = child; > nodep->last = child; > } else { > child = nodep->last; > child->next = new_child; > new_child->prev = child; > nodep->last = new_child; 1226,1229c1290,1312 < } else if (child->type == XML_DOCUMENT_FRAG_NODE) { < new_child = xmlAddChildList(nodep, child->children); < if (new_child != NULL) { < child->children = NULL; --- > } else if (child->type == XML_DOCUMENT_FRAG_NODE) { > xmlNodePtr fragment; > > fragment = child; > new_child = child->children; > if (nodep->children == NULL) { > nodep->children = new_child; > } else { > child = nodep->last; > child->next = new_child; > new_child->prev = child; > } > child = new_child; > while (child->next != NULL) { > child->parent = nodep; > if (child->doc != nodep->doc) { > xmlSetTreeDoc(child, nodep->doc); > } > child = child->next; > } > child->parent = nodep; > if (child->doc != nodep->doc) { > xmlSetTreeDoc(child, nodep->doc); 1231,1232c1314,1315 < DOM_RET_OBJ(rv, new_child, &ret, intern); < return; --- > nodep->last = child; > fragment->children = NULL; 1235,1236d1317 < new_child = xmlAddChild(nodep, child); < 1238,1239c1319,1323 < php_error(E_WARNING, "Couldn't append node"); < RETURN_FALSE; --- > new_child = xmlAddChild(nodep, child); > if (new_child == NULL) { > php_error(E_WARNING, "Couldn't append node"); > RETURN_FALSE; > }