mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-21 22:50:08 +03:00
Make xmlXPathEvalExpression call xmlXPathEval
Both functions are supposed to do exactly the same.
This commit is contained in:
parent
d6b3645f9b
commit
640a368c80
39
xpath.c
39
xpath.c
@ -15190,46 +15190,11 @@ xmlXPathNodeEval(xmlNodePtr node, const xmlChar *str, xmlXPathContextPtr ctx) {
|
||||
* @str: the XPath expression
|
||||
* @ctxt: the XPath context
|
||||
*
|
||||
* Evaluate the XPath expression in the given context.
|
||||
*
|
||||
* Returns the xmlXPathObjectPtr resulting from the evaluation or NULL.
|
||||
* the caller has to free the object.
|
||||
* Alias for xmlXPathEval.
|
||||
*/
|
||||
xmlXPathObjectPtr
|
||||
xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
|
||||
xmlXPathParserContextPtr pctxt;
|
||||
xmlXPathObjectPtr res, tmp;
|
||||
int stack = 0;
|
||||
|
||||
CHECK_CTXT(ctxt)
|
||||
|
||||
xmlXPathInit();
|
||||
|
||||
pctxt = xmlXPathNewParserContext(str, ctxt);
|
||||
if (pctxt == NULL)
|
||||
return NULL;
|
||||
xmlXPathEvalExpr(pctxt);
|
||||
|
||||
if ((*pctxt->cur != 0) || (pctxt->error != XPATH_EXPRESSION_OK)) {
|
||||
xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
|
||||
res = NULL;
|
||||
} else {
|
||||
res = valuePop(pctxt);
|
||||
}
|
||||
do {
|
||||
tmp = valuePop(pctxt);
|
||||
if (tmp != NULL) {
|
||||
xmlXPathReleaseObject(ctxt, tmp);
|
||||
stack++;
|
||||
}
|
||||
} while (tmp != NULL);
|
||||
if ((stack != 0) && (res != NULL)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlXPathEvalExpression: %d object left on the stack\n",
|
||||
stack);
|
||||
}
|
||||
xmlXPathFreeParserContext(pctxt);
|
||||
return(res);
|
||||
return(xmlXPathEval(str, ctxt));
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user