* xmlXPtrEndPointFunction: * @ctxt: the XPointer Parser context * @nargs: the number of args * * Function implementing end-point() operation * as described in 5.4.3 * ---------------------------- * location-set end-point(location-set) * * For each location x in the argument location-set, end-point adds a * location of type point to the result location-set. That point represents * the
| 1866 | * ---------------------------- |
| 1867 | */ |
| 1868 | static void |
| 1869 | xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 1870 | xmlXPathObjectPtr tmp, obj, point; |
| 1871 | xmlLocationSetPtr newset = NULL; |
| 1872 | xmlLocationSetPtr oldset = NULL; |
| 1873 | |
| 1874 | CHECK_ARITY(1); |
| 1875 | if ((ctxt->value == NULL) || |
| 1876 | ((ctxt->value->type != XPATH_LOCATIONSET) && |
| 1877 | (ctxt->value->type != XPATH_NODESET))) |
| 1878 | XP_ERROR(XPATH_INVALID_TYPE) |
| 1879 | |
| 1880 | obj = valuePop(ctxt); |
| 1881 | if (obj->type == XPATH_NODESET) { |
| 1882 | /* |
| 1883 | * First convert to a location set |
| 1884 | */ |
| 1885 | tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval); |
| 1886 | xmlXPathFreeObject(obj); |
| 1887 | if (tmp == NULL) |
| 1888 | XP_ERROR(XPATH_MEMORY_ERROR) |
| 1889 | obj = tmp; |
| 1890 | } |
| 1891 | |
| 1892 | newset = xmlXPtrLocationSetCreate(NULL); |
| 1893 | if (newset == NULL) { |
| 1894 | xmlXPathFreeObject(obj); |
| 1895 | XP_ERROR(XPATH_MEMORY_ERROR); |
| 1896 | } |
| 1897 | oldset = (xmlLocationSetPtr) obj->user; |
| 1898 | if (oldset != NULL) { |
| 1899 | int i; |
| 1900 | |
| 1901 | for (i = 0; i < oldset->locNr; i++) { |
| 1902 | tmp = oldset->locTab[i]; |
| 1903 | if (tmp == NULL) |
| 1904 | continue; |
| 1905 | point = NULL; |
| 1906 | switch (tmp->type) { |
| 1907 | case XPATH_POINT: |
| 1908 | point = xmlXPtrNewPoint(tmp->user, tmp->index); |
| 1909 | break; |
| 1910 | case XPATH_RANGE: { |
| 1911 | xmlNodePtr node = tmp->user2; |
| 1912 | if (node != NULL) { |
| 1913 | if ((node->type == XML_ATTRIBUTE_NODE) || |
| 1914 | (node->type == XML_NAMESPACE_DECL)) { |
| 1915 | xmlXPathFreeObject(obj); |
| 1916 | xmlXPtrFreeLocationSet(newset); |
| 1917 | XP_ERROR(XPTR_SYNTAX_ERROR); |
| 1918 | } |
| 1919 | point = xmlXPtrNewPoint(node, tmp->index2); |
| 1920 | } else if (tmp->user == NULL) { |
| 1921 | point = xmlXPtrNewPoint(node, |
| 1922 | xmlXPtrNbLocChildren(node)); |
| 1923 | } |
| 1924 | break; |
| 1925 | } |
nothing calls this directly
no test coverage detected