--- xpath.c 2003-04-15 01:30:34.000000000 +0900 +++ xpath.c.1 2003-04-15 01:30:41.000000000 +0900 @@ -1,55 +1,44 @@ /** - * xmlXPathEval: + * xmlXPathEvalExpression: * @str: the XPath expression - * @ctx: the XPath context + * @ctxt: the XPath context * - * Evaluate the XPath Location Path in the given 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. */ xmlXPathObjectPtr -xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) { - xmlXPathParserContextPtr ctxt; - xmlXPathObjectPtr res, tmp, init = NULL; +xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) { + xmlXPathParserContextPtr pctxt; + xmlXPathObjectPtr res, tmp; int stack = 0; xmlXPathInit(); - CHECK_CONTEXT(ctx) + CHECK_CONTEXT(ctxt) - ctxt = xmlXPathNewParserContext(str, ctx); - xmlXPathEvalExpr(ctxt); + pctxt = xmlXPathNewParserContext(str, ctxt); + xmlXPathEvalExpr(pctxt); - if (ctxt->value == NULL) { - xmlGenericError(xmlGenericErrorContext, - "xmlXPathEval: evaluation failed\n"); - res = NULL; - } else if (*ctxt->cur != 0) { - xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); + if (*pctxt->cur != 0) { + xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); res = NULL; } else { - res = valuePop(ctxt); + res = valuePop(pctxt); } - do { - tmp = valuePop(ctxt); + tmp = valuePop(pctxt); if (tmp != NULL) { - if (tmp != init) - stack++; xmlXPathFreeObject(tmp); - } + stack++; + } } while (tmp != NULL); if ((stack != 0) && (res != NULL)) { xmlGenericError(xmlGenericErrorContext, - "xmlXPathEval: %d object left on the stack\n", + "xmlXPathEvalExpression: %d object left on the stack\n", stack); } - if (ctxt->error != XPATH_EXPRESSION_OK) { - xmlXPathFreeObject(res); - res = NULL; - } - - xmlXPathFreeParserContext(ctxt); + xmlXPathFreeParserContext(pctxt); return(res); }