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

Function xmlXPtrRangeFunction

ThirdParty/libxml2/vtklibxml2/xpointer.c:2020–2068  ·  view source on GitHub ↗

* xmlXPtrRangeFunction: * @ctxt: the XPointer Parser context * @nargs: the number of args * * Function implementing the range() function 5.4.3 * location-set range(location-set ) * * The range function returns ranges covering the locations in * the argument location-set. For each location x in the argument * location-set, a range location representing the covering range of * x is

Source from the content-addressed store, hash-verified

2018 * x is added to the result location-set.
2019 */
2020static void
2021xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
2022 int i;
2023 xmlXPathObjectPtr set;
2024 xmlLocationSetPtr oldset;
2025 xmlLocationSetPtr newset;
2026
2027 CHECK_ARITY(1);
2028 if ((ctxt->value == NULL) ||
2029 ((ctxt->value->type != XPATH_LOCATIONSET) &&
2030 (ctxt->value->type != XPATH_NODESET)))
2031 XP_ERROR(XPATH_INVALID_TYPE)
2032
2033 set = valuePop(ctxt);
2034 if (set->type == XPATH_NODESET) {
2035 xmlXPathObjectPtr tmp;
2036
2037 /*
2038 * First convert to a location set
2039 */
2040 tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
2041 xmlXPathFreeObject(set);
2042 if (tmp == NULL)
2043 XP_ERROR(XPATH_MEMORY_ERROR)
2044 set = tmp;
2045 }
2046 oldset = (xmlLocationSetPtr) set->user;
2047
2048 /*
2049 * The loop is to compute the covering range for each item and add it
2050 */
2051 newset = xmlXPtrLocationSetCreate(NULL);
2052 if (newset == NULL) {
2053 xmlXPathFreeObject(set);
2054 XP_ERROR(XPATH_MEMORY_ERROR);
2055 }
2056 if (oldset != NULL) {
2057 for (i = 0;i < oldset->locNr;i++) {
2058 xmlXPtrLocationSetAdd(newset,
2059 xmlXPtrCoveringRange(ctxt, oldset->locTab[i]));
2060 }
2061 }
2062
2063 /*
2064 * Save the new value and cleanup
2065 */
2066 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
2067 xmlXPathFreeObject(set);
2068}
2069
2070/**
2071 * xmlXPtrInsideRange:

Callers

nothing calls this directly

Calls 8

valuePopFunction · 0.85
xmlXPathFreeObjectFunction · 0.85
xmlXPtrCoveringRangeFunction · 0.85
valuePushFunction · 0.85
xmlXPtrLocationSetCreateFunction · 0.70
xmlXPtrLocationSetAddFunction · 0.70
xmlXPtrWrapLocationSetFunction · 0.70

Tested by

no test coverage detected