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

Function xmlXPathNodeLeadingSorted

ThirdParty/libxml2/vtklibxml2/xpath.c:3687–3714  ·  view source on GitHub ↗

* xmlXPathNodeLeadingSorted: * @nodes: a node-set, sorted by document order * @node: a node * * Implements the EXSLT - Sets leading() function: * node-set set:leading (node-set, node-set) * * Returns the nodes in @nodes that precede @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */

Source from the content-addressed store, hash-verified

3685 * doesn't contain @node
3686 */
3687xmlNodeSetPtr
3688xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
3689 int i, l;
3690 xmlNodePtr cur;
3691 xmlNodeSetPtr ret;
3692
3693 if (node == NULL)
3694 return(nodes);
3695
3696 ret = xmlXPathNodeSetCreate(NULL);
3697 if (ret == NULL)
3698 return(ret);
3699 if (xmlXPathNodeSetIsEmpty(nodes) ||
3700 (!xmlXPathNodeSetContains(nodes, node)))
3701 return(ret);
3702
3703 l = xmlXPathNodeSetGetLength(nodes);
3704 for (i = 0; i < l; i++) {
3705 cur = xmlXPathNodeSetItem(nodes, i);
3706 if (cur == node)
3707 break;
3708 if (xmlXPathNodeSetAddUnique(ret, cur) < 0) {
3709 xmlXPathFreeNodeSet(ret);
3710 return(NULL);
3711 }
3712 }
3713 return(ret);
3714}
3715
3716/**
3717 * xmlXPathNodeLeading:

Callers 3

xmlXPathNodeLeadingFunction · 0.85
xmlXPathLeadingSortedFunction · 0.85
xmlXPathLeadingFunction · 0.85

Calls 4

xmlXPathNodeSetCreateFunction · 0.85
xmlXPathNodeSetContainsFunction · 0.85
xmlXPathNodeSetAddUniqueFunction · 0.85
xmlXPathFreeNodeSetFunction · 0.85

Tested by

no test coverage detected