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

Function xmlXPathNumberFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:8526–8557  ·  view source on GitHub ↗

* xmlXPathNumberFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the number() XPath function * number number(object?) */

Source from the content-addressed store, hash-verified

8524 * number number(object?)
8525 */
8526void
8527xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8528 xmlXPathObjectPtr cur;
8529 double res;
8530
8531 if (ctxt == NULL) return;
8532 if (nargs == 0) {
8533 if (ctxt->context->node == NULL) {
8534 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt, 0.0));
8535 } else {
8536 xmlChar* content = xmlNodeGetContent(ctxt->context->node);
8537 if (content == NULL)
8538 xmlXPathPErrMemory(ctxt);
8539
8540 res = xmlXPathStringEvalNumber(content);
8541 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt, res));
8542 xmlFree(content);
8543 }
8544 return;
8545 }
8546
8547 CHECK_ARITY(1);
8548 cur = valuePop(ctxt);
8549 if (cur->type != XPATH_NUMBER) {
8550 double floatval;
8551
8552 floatval = xmlXPathCastToNumberInternal(ctxt, cur);
8553 xmlXPathReleaseObject(ctxt->context, cur);
8554 cur = xmlXPathCacheNewFloat(ctxt, floatval);
8555 }
8556 valuePush(ctxt, cur);
8557}
8558
8559/**
8560 * xmlXPathSumFunction:

Callers 4

xmlXPathCompareValuesFunction · 0.85

Calls 8

valuePushFunction · 0.85
xmlXPathCacheNewFloatFunction · 0.85
xmlNodeGetContentFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
xmlXPathStringEvalNumberFunction · 0.85
valuePopFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85

Tested by

no test coverage detected