MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathRunEval

Function xmlXPathRunEval

ThirdParty/libxml2/vtklibxml2/xpath.c:12693–12760  ·  view source on GitHub ↗

* xmlXPathRunEval: * @ctxt: the XPath parser context with the compiled expression * @toBool: evaluate to a boolean result * * Evaluate the Precompiled XPath expression in the given context. */

Source from the content-addressed store, hash-verified

12691 * Evaluate the Precompiled XPath expression in the given context.
12692 */
12693static int
12694xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
12695{
12696 xmlXPathCompExprPtr comp;
12697 int oldDepth;
12698
12699 if ((ctxt == NULL) || (ctxt->comp == NULL))
12700 return(-1);
12701
12702 if (ctxt->valueTab == NULL) {
12703 /* Allocate the value stack */
12704 ctxt->valueTab = (xmlXPathObjectPtr *)
12705 xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
12706 if (ctxt->valueTab == NULL) {
12707 xmlXPathPErrMemory(ctxt);
12708 return(-1);
12709 }
12710 ctxt->valueNr = 0;
12711 ctxt->valueMax = 10;
12712 ctxt->value = NULL;
12713 }
12714#ifdef XPATH_STREAMING
12715 if (ctxt->comp->stream) {
12716 int res;
12717
12718 if (toBool) {
12719 /*
12720 * Evaluation to boolean result.
12721 */
12722 res = xmlXPathRunStreamEval(ctxt, ctxt->comp->stream, NULL, 1);
12723 if (res != -1)
12724 return(res);
12725 } else {
12726 xmlXPathObjectPtr resObj = NULL;
12727
12728 /*
12729 * Evaluation to a sequence.
12730 */
12731 res = xmlXPathRunStreamEval(ctxt, ctxt->comp->stream, &resObj, 0);
12732
12733 if ((res != -1) && (resObj != NULL)) {
12734 valuePush(ctxt, resObj);
12735 return(0);
12736 }
12737 if (resObj != NULL)
12738 xmlXPathReleaseObject(ctxt->context, resObj);
12739 }
12740 /*
12741 * QUESTION TODO: This falls back to normal XPath evaluation
12742 * if res == -1. Is this intended?
12743 */
12744 }
12745#endif
12746 comp = ctxt->comp;
12747 if (comp->last < 0) {
12748 xmlXPathErr(ctxt, XPATH_STACK_ERROR);
12749 return(-1);
12750 }

Callers 2

xmlXPathEvalExprFunction · 0.85

Calls 7

xmlXPathPErrMemoryFunction · 0.85
xmlXPathRunStreamEvalFunction · 0.85
valuePushFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85
xmlXPathErrFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85

Tested by

no test coverage detected