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

Function xmlXPathCompiledEvalInternal

ThirdParty/libxml2/vtklibxml2/xpath.c:13132–13181  ·  view source on GitHub ↗

* xmlXPathCompiledEvalInternal: * @comp: the compiled XPath expression * @ctxt: the XPath context * @resObj: the resulting XPath object or NULL * @toBool: 1 if only a boolean result is requested * * Evaluate the Precompiled XPath expression in the given context. * The caller has to free @resObj. * * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL. * the call

Source from the content-addressed store, hash-verified

13130 * the caller has to free the object.
13131 */
13132static int
13133xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
13134 xmlXPathContextPtr ctxt,
13135 xmlXPathObjectPtr *resObjPtr,
13136 int toBool)
13137{
13138 xmlXPathParserContextPtr pctxt;
13139 xmlXPathObjectPtr resObj = NULL;
13140#ifndef LIBXML_THREAD_ENABLED
13141 static int reentance = 0;
13142#endif
13143 int res;
13144
13145 if (comp == NULL)
13146 return(-1);
13147 xmlInitParser();
13148
13149 xmlResetError(&ctxt->lastError);
13150
13151#ifndef LIBXML_THREAD_ENABLED
13152 reentance++;
13153 if (reentance > 1)
13154 xmlXPathDisableOptimizer = 1;
13155#endif
13156
13157 pctxt = xmlXPathCompParserContext(comp, ctxt);
13158 if (pctxt == NULL)
13159 return(-1);
13160 res = xmlXPathRunEval(pctxt, toBool);
13161
13162 if (pctxt->error == XPATH_EXPRESSION_OK) {
13163 if (pctxt->valueNr != ((toBool) ? 0 : 1))
13164 xmlXPathErr(pctxt, XPATH_STACK_ERROR);
13165 else if (!toBool)
13166 resObj = valuePop(pctxt);
13167 }
13168
13169 if (resObjPtr)
13170 *resObjPtr = resObj;
13171 else
13172 xmlXPathReleaseObject(ctxt, resObj);
13173
13174 pctxt->comp = NULL;
13175 xmlXPathFreeParserContext(pctxt);
13176#ifndef LIBXML_THREAD_ENABLED
13177 reentance--;
13178#endif
13179
13180 return(res);
13181}
13182
13183/**
13184 * xmlXPathCompiledEval:

Callers 2

xmlXPathCompiledEvalFunction · 0.85

Calls 8

xmlInitParserFunction · 0.85
xmlResetErrorFunction · 0.85
xmlXPathRunEvalFunction · 0.85
xmlXPathErrFunction · 0.85
valuePopFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85

Tested by

no test coverage detected