summaryrefslogtreecommitdiff
path: root/ext/domxml/php_domxml.c
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2003-01-06 08:47:35 +0000
committerChristian Stocker <chregu@php.net>2003-01-06 08:47:35 +0000
commitcafc0b2e59d49cd2d50405e06fe1da739a63ee0a (patch)
tree52552161c8d37a2b7266ece2c48fe1d75e2d0393 /ext/domxml/php_domxml.c
parent509b4d39b554718273c2d3d7e7329cc81d36f84a (diff)
downloadphp-git-cafc0b2e59d49cd2d50405e06fe1da739a63ee0a.tar.gz
@- Added domxml_node_get_path() (Lukas Schröder)
- Fixed segfault, when trying to add a node to itself.
Diffstat (limited to 'ext/domxml/php_domxml.c')
-rw-r--r--ext/domxml/php_domxml.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
index 690885fc0f..67290d79c7 100644
--- a/ext/domxml/php_domxml.c
+++ b/ext/domxml/php_domxml.c
@@ -420,6 +420,7 @@ static zend_function_entry php_domxmlnode_class_functions[] = {
PHP_FALIAS(get_content, domxml_node_get_content, NULL)
PHP_FALIAS(text_concat, domxml_node_text_concat, NULL)
PHP_FALIAS(set_name, domxml_node_set_name, NULL)
+ PHP_FALIAS(get_path, domxml_node_get_path, NULL)
PHP_FALIAS(is_blank_node, domxml_is_blank_node, NULL)
PHP_FALIAS(dump_node, domxml_dump_node, NULL)
{NULL, NULL, NULL}
@@ -2190,6 +2191,25 @@ PHP_FUNCTION(domxml_node_namespace_uri)
}
/* }}} */
+/* {{{ proto string domxml_node_get_path(void)
+ Returns the path of the node in the document */
+PHP_FUNCTION(domxml_node_get_path)
+{
+ zval *id;
+ xmlNodePtr nodep;
+ xmlChar *path;
+
+ DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
+
+ DOMXML_NO_ARGS();
+
+ path = xmlGetNodePath(nodep);
+ if (!path) {
+ RETURN_FALSE;
+ }
+ RETVAL_STRING((char *)path, 1);
+ xmlFree(path);
+}
/* {{{ proto object domxml_node_parent(void)
Returns parent of node */
@@ -2302,6 +2322,12 @@ PHP_FUNCTION(domxml_node_append_child)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append attribute node");
RETURN_FALSE;
}
+
+ /* XXX:ls */
+ if (child == parent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append node to itself");
+ RETURN_FALSE;
+ }
if (!(child->doc == NULL || child->doc == parent->doc)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append node, which is in a different document than the parent node");