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

Function xmlXPathEqualNodeSetFloat

ThirdParty/libxml2/vtklibxml2/xpath.c:5766–5810  ·  view source on GitHub ↗

* xmlXPathEqualNodeSetFloat: * @arg: the nodeset object argument * @f: the float to compare to * @neq: flag to show whether to compare '=' (0) or '!=' (1) * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * If one object to be compared is a node-set and the other is a number, * then the comparison will be true if and only if there is a node in * the node-set suc

Source from the content-addressed store, hash-verified

5764 * Returns 0 or 1 depending on the results of the test.
5765 */
5766static int
5767xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt,
5768 xmlXPathObjectPtr arg, double f, int neq) {
5769 int i, ret=0;
5770 xmlNodeSetPtr ns;
5771 xmlChar *str2;
5772 xmlXPathObjectPtr val;
5773 double v;
5774
5775 if ((arg == NULL) ||
5776 ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE)))
5777 return(0);
5778
5779 ns = arg->nodesetval;
5780 if (ns != NULL) {
5781 for (i=0;i<ns->nodeNr;i++) {
5782 str2 = xmlXPathCastNodeToString(ns->nodeTab[i]);
5783 if (str2 != NULL) {
5784 valuePush(ctxt, xmlXPathCacheNewString(ctxt, str2));
5785 xmlFree(str2);
5786 xmlXPathNumberFunction(ctxt, 1);
5787 CHECK_ERROR0;
5788 val = valuePop(ctxt);
5789 v = val->floatval;
5790 xmlXPathReleaseObject(ctxt->context, val);
5791 if (!xmlXPathIsNaN(v)) {
5792 if ((!neq) && (v==f)) {
5793 ret = 1;
5794 break;
5795 } else if ((neq) && (v!=f)) {
5796 ret = 1;
5797 break;
5798 }
5799 } else { /* NaN is unequal to any value */
5800 if (neq)
5801 ret = 1;
5802 }
5803 } else {
5804 xmlXPathPErrMemory(ctxt);
5805 }
5806 }
5807 }
5808
5809 return(ret);
5810}
5811
5812
5813/**

Callers 2

xmlXPathEqualValuesFunction · 0.85
xmlXPathNotEqualValuesFunction · 0.85

Calls 8

xmlXPathCastNodeToStringFunction · 0.85
valuePushFunction · 0.85
xmlXPathCacheNewStringFunction · 0.85
xmlXPathNumberFunctionFunction · 0.85
valuePopFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85
xmlXPathIsNaNFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85

Tested by

no test coverage detected