ext/dom/php_domxml.c patch

From: Date: Tue, 10 Jul 2001 23:00:36 +0000
Subject: ext/dom/php_domxml.c patch
Groups: php.dev 
Request: Send a blank email to php-dev+get-59635@lists.php.net to get a copy of this message
Attached is a patch to ext/dom/php_domxml.c that adds the ability to set the context node when running xpath_eval(). xpath_eval() (and xpath_eval_expression()) can now accept and optional second parameter that is the context node. If no argument is specified, it works as before. This patch is against the head of the CVS tree. I also have a patch for the 4.0.6 version of this file for those who need/want it. BTW, has a decision been made about what interface to domxml will be in the next release of PHP? -- Paul Marquis pmarquis@pobox.com

Index: php_domxml.c =================================================================== RCS file: /repository/php4/ext/domxml/php_domxml.c,v retrieving revision 1.40 diff -u -r1.40 php_domxml.c --- php_domxml.c 8 Jul 2001 00:54:25 -0000 1.40 +++ php_domxml.c 10 Jul 2001 21:34:10 -0000 @@ -2456,19 +2456,37 @@ static void php_xpathptr_eval(INTERNAL_FUNCTION_PARAMETERS, int mode, int expr) { - zval *id, *str, *rv; + zval *id, *str, *contextnode, *rv; 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; + switch (ZEND_NUM_ARGS()) { + case 1: + if (getParameters(ht, 1, &str) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 2: + if (getParameters(ht, 2, &str, &contextnode) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + default: + WRONG_PARAM_COUNT; + } id = getThis(); ctxp = php_xpath_get_context(id, le_xpathctxp, 0); 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) { xpathobjp = xmlXPtrEval(BAD_CAST str->value.str.val, ctxp); @@ -2481,7 +2499,7 @@ #if defined(LIBXML_XPTR_ENABLED) } #endif - + ctxp->node = NULL; if (!xpathobjp) { RETURN_FALSE; }
« previous php.dev (#59635) next »