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

Function xmlXPathEqualNodeSetString

ThirdParty/libxml2/vtklibxml2/xpath.c:5708–5749  ·  view source on GitHub ↗

* xmlXPathEqualNodeSetString: * @arg: the nodeset object argument * @str: the string to compare to. * @neq: flag to show whether for '=' (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 string, * then the comparison will be true if and only if there is a node in * the node-set such

Source from the content-addressed store, hash-verified

5706 * Returns 0 or 1 depending on the results of the test.
5707 */
5708static int
5709xmlXPathEqualNodeSetString(xmlXPathParserContextPtr ctxt,
5710 xmlXPathObjectPtr arg, const xmlChar * str, int neq)
5711{
5712 int i;
5713 xmlNodeSetPtr ns;
5714 xmlChar *str2;
5715 unsigned int hash;
5716
5717 if ((str == NULL) || (arg == NULL) ||
5718 ((arg->type != XPATH_NODESET) && (arg->type != XPATH_XSLT_TREE)))
5719 return (0);
5720 ns = arg->nodesetval;
5721 /*
5722 * A NULL nodeset compared with a string is always false
5723 * (since there is no node equal, and no node not equal)
5724 */
5725 if ((ns == NULL) || (ns->nodeNr <= 0) )
5726 return (0);
5727 hash = xmlXPathStringHash(str);
5728 for (i = 0; i < ns->nodeNr; i++) {
5729 if (xmlXPathNodeValHash(ns->nodeTab[i]) == hash) {
5730 str2 = xmlNodeGetContent(ns->nodeTab[i]);
5731 if (str2 == NULL) {
5732 xmlXPathPErrMemory(ctxt);
5733 return(0);
5734 }
5735 if (xmlStrEqual(str, str2)) {
5736 xmlFree(str2);
5737 if (neq)
5738 continue;
5739 return (1);
5740 } else if (neq) {
5741 xmlFree(str2);
5742 return (1);
5743 }
5744 xmlFree(str2);
5745 } else if (neq)
5746 return (1);
5747 }
5748 return (0);
5749}
5750
5751/**
5752 * xmlXPathEqualNodeSetFloat:

Callers 2

xmlXPathEqualValuesFunction · 0.85
xmlXPathNotEqualValuesFunction · 0.85

Calls 5

xmlXPathStringHashFunction · 0.85
xmlXPathNodeValHashFunction · 0.85
xmlNodeGetContentFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected