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

Function xmlXPtrStartPointFunction

ThirdParty/libxml2/vtklibxml2/xpointer.c:1772–1841  ·  view source on GitHub ↗

* xmlXPtrStartPointFunction: * @ctxt: the XPointer Parser context * @nargs: the number of args * * Function implementing start-point() operation * as described in 5.4.3 * ---------------- * location-set start-point(location-set) * * For each location x in the argument location-set, start-point adds a * location of type point to the result location-set. That point represents * the star

Source from the content-addressed store, hash-verified

1770 *
1771 */
1772static void
1773xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
1774 xmlXPathObjectPtr tmp, obj, point;
1775 xmlLocationSetPtr newset = NULL;
1776 xmlLocationSetPtr oldset = NULL;
1777
1778 CHECK_ARITY(1);
1779 if ((ctxt->value == NULL) ||
1780 ((ctxt->value->type != XPATH_LOCATIONSET) &&
1781 (ctxt->value->type != XPATH_NODESET)))
1782 XP_ERROR(XPATH_INVALID_TYPE)
1783
1784 obj = valuePop(ctxt);
1785 if (obj->type == XPATH_NODESET) {
1786 /*
1787 * First convert to a location set
1788 */
1789 tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
1790 xmlXPathFreeObject(obj);
1791 if (tmp == NULL)
1792 XP_ERROR(XPATH_MEMORY_ERROR)
1793 obj = tmp;
1794 }
1795
1796 newset = xmlXPtrLocationSetCreate(NULL);
1797 if (newset == NULL) {
1798 xmlXPathFreeObject(obj);
1799 XP_ERROR(XPATH_MEMORY_ERROR);
1800 }
1801 oldset = (xmlLocationSetPtr) obj->user;
1802 if (oldset != NULL) {
1803 int i;
1804
1805 for (i = 0; i < oldset->locNr; i++) {
1806 tmp = oldset->locTab[i];
1807 if (tmp == NULL)
1808 continue;
1809 point = NULL;
1810 switch (tmp->type) {
1811 case XPATH_POINT:
1812 point = xmlXPtrNewPoint(tmp->user, tmp->index);
1813 break;
1814 case XPATH_RANGE: {
1815 xmlNodePtr node = tmp->user;
1816 if (node != NULL) {
1817 if ((node->type == XML_ATTRIBUTE_NODE) ||
1818 (node->type == XML_NAMESPACE_DECL)) {
1819 xmlXPathFreeObject(obj);
1820 xmlXPtrFreeLocationSet(newset);
1821 XP_ERROR(XPTR_SYNTAX_ERROR);
1822 }
1823 point = xmlXPtrNewPoint(node, tmp->index);
1824 }
1825 break;
1826 }
1827 default:
1828 /*** Should we raise an error ?
1829 xmlXPathFreeObject(obj);

Callers

nothing calls this directly

Calls 9

valuePopFunction · 0.85
xmlXPathFreeObjectFunction · 0.85
xmlXPtrNewPointFunction · 0.85
valuePushFunction · 0.85
xmlXPtrLocationSetCreateFunction · 0.70
xmlXPtrFreeLocationSetFunction · 0.70
xmlXPtrLocationSetAddFunction · 0.70
xmlXPtrWrapLocationSetFunction · 0.70

Tested by

no test coverage detected