* xmlXPtrRangeInsideFunction: * @ctxt: the XPointer Parser context * @nargs: the number of args * * Function implementing the range-inside() function 5.4.3 * location-set range-inside(location-set ) * * The range-inside function returns ranges covering the contents of * the locations in the argument location-set. For each location x in * the argument location-set, a range location i
| 2173 | * |
| 2174 | */ |
| 2175 | static void |
| 2176 | xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 2177 | int i; |
| 2178 | xmlXPathObjectPtr set; |
| 2179 | xmlLocationSetPtr oldset; |
| 2180 | xmlLocationSetPtr newset; |
| 2181 | |
| 2182 | CHECK_ARITY(1); |
| 2183 | if ((ctxt->value == NULL) || |
| 2184 | ((ctxt->value->type != XPATH_LOCATIONSET) && |
| 2185 | (ctxt->value->type != XPATH_NODESET))) |
| 2186 | XP_ERROR(XPATH_INVALID_TYPE) |
| 2187 | |
| 2188 | set = valuePop(ctxt); |
| 2189 | if (set->type == XPATH_NODESET) { |
| 2190 | xmlXPathObjectPtr tmp; |
| 2191 | |
| 2192 | /* |
| 2193 | * First convert to a location set |
| 2194 | */ |
| 2195 | tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval); |
| 2196 | xmlXPathFreeObject(set); |
| 2197 | if (tmp == NULL) |
| 2198 | XP_ERROR(XPATH_MEMORY_ERROR) |
| 2199 | set = tmp; |
| 2200 | } |
| 2201 | |
| 2202 | /* |
| 2203 | * The loop is to compute the covering range for each item and add it |
| 2204 | */ |
| 2205 | newset = xmlXPtrLocationSetCreate(NULL); |
| 2206 | if (newset == NULL) { |
| 2207 | xmlXPathFreeObject(set); |
| 2208 | XP_ERROR(XPATH_MEMORY_ERROR); |
| 2209 | } |
| 2210 | oldset = (xmlLocationSetPtr) set->user; |
| 2211 | if (oldset != NULL) { |
| 2212 | for (i = 0;i < oldset->locNr;i++) { |
| 2213 | xmlXPtrLocationSetAdd(newset, |
| 2214 | xmlXPtrInsideRange(ctxt, oldset->locTab[i])); |
| 2215 | } |
| 2216 | } |
| 2217 | |
| 2218 | /* |
| 2219 | * Save the new value and cleanup |
| 2220 | */ |
| 2221 | valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); |
| 2222 | xmlXPathFreeObject(set); |
| 2223 | } |
| 2224 | |
| 2225 | /** |
| 2226 | * xmlXPtrRangeToFunction: |
nothing calls this directly
no test coverage detected