cvs: php4 /ext/domxml php_domxml.c
| From: | Joey Smith | Date: | Thu, 09 Aug 2001 12:35:10 +0000 |
| Subject: | cvs: php4 /ext/domxml php_domxml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6674@lists.php.net to get a copy of this message | ||
joey Thu Aug 9 08:35:10 2001 EDT
Modified files:
/php4/ext/domxml php_domxml.c
Log:
Commit acutal code only, will do ws on another pass.
Index: php4/ext/domxml/php_domxml.c
diff -u php4/ext/domxml/php_domxml.c:1.50 php4/ext/domxml/php_domxml.c:1.51
--- php4/ext/domxml/php_domxml.c:1.50 Thu Aug 9 08:22:41 2001
+++ php4/ext/domxml/php_domxml.c Thu Aug 9 08:35:09 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_domxml.c,v 1.50 2001/08/09 12:22:41 joey Exp $ */
+/* $Id: php_domxml.c,v 1.51 2001/08/09 12:35:09 joey Exp $ */
#ifdef HAVE_CONFIG_H
@@ -102,13 +102,13 @@
PHP_FE(domxml_new_xmldoc, NULL)
PHP_FALIAS(new_xmldoc, domxml_new_xmldoc, NULL)
#if defined(LIBXML_XPATH_ENABLED)
-/* PHP_FE(xpath_new_context, NULL)
+ PHP_FE(xpath_new_context, NULL)
PHP_FE(xpath_eval, NULL)
- PHP_FE(xpath_eval_expression, NULL) */
+ PHP_FE(xpath_eval_expression, NULL)
#endif
#if defined(LIBXML_XPTR_ENABLED)
-/* PHP_FE(xptr_new_context, NULL)
- PHP_FE(xptr_eval, NULL) */
+ PHP_FE(xptr_new_context, NULL)
+ PHP_FE(xptr_eval, NULL)
#endif
{NULL, NULL, NULL}
};
@@ -2477,20 +2477,49 @@
}
/* }}} */
+/* {{{ */
static void php_xpathptr_eval(INTERNAL_FUNCTION_PARAMETERS, int mode, int expr)
{
- zval *id, *str, *rv;
+ zval *id, *str, *rv, *contextnode;
xmlXPathContextPtr ctxp;
xmlXPathObjectPtr xpathobjp;
+ xmlNode *contextnodep;
int ret;
- if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ contextnode = NULL;
+ contextnodep = NULL;
id = getThis();
+
+ if (! id) {
+ switch(ZEND_NUM_ARGS()) {
+ case 2:
+ if ((getParameters(ht, 2, &id, &str)) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+
+ case 3:
+ if ((getParameters(ht, 3, &id, &str, &contextnode)) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+
+ default:
+ WRONG_PARAM_COUNT;
+ }
+ }
+
+
ctxp = php_xpath_get_context(id, le_xpathctxp, 0 TSRMLS_CC);
convert_to_string(str);
+
+ if (contextnode) {
+ contextnodep = php_dom_get_object(contextnode, le_domxmlnodep, 0);
+ }
+ ctxp->node = contextnodep;
#if defined(LIBXML_XPTR_ENABLED)
if(mode == PHP_XPTR) {
@@ -2504,7 +2533,8 @@
#if defined(LIBXML_XPTR_ENABLED)
}
#endif
-
+
+ ctxp->node = NULL;
if (!xpathobjp) {
RETURN_FALSE;
}