* xmlXPtrStringRangeFunction: * @ctxt: the XPointer Parser context * @nargs: the number of args * * Function implementing the string-range() function * range as described in 5.4.2 * * ------------------------------ * [Definition: For each location in the location-set argument, * string-range returns a set of string ranges, a set of substrings in a * string. Specifically, the string-val
| 2673 | * ------------------------------ |
| 2674 | */ |
| 2675 | static void |
| 2676 | xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 2677 | int i, startindex, endindex = 0, fendindex; |
| 2678 | xmlNodePtr start, end = 0, fend; |
| 2679 | xmlXPathObjectPtr set = NULL; |
| 2680 | xmlLocationSetPtr oldset; |
| 2681 | xmlLocationSetPtr newset = NULL; |
| 2682 | xmlXPathObjectPtr string = NULL; |
| 2683 | xmlXPathObjectPtr position = NULL; |
| 2684 | xmlXPathObjectPtr number = NULL; |
| 2685 | int found, pos = 0, num = 0; |
| 2686 | |
| 2687 | /* |
| 2688 | * Grab the arguments |
| 2689 | */ |
| 2690 | if ((nargs < 2) || (nargs > 4)) |
| 2691 | XP_ERROR(XPATH_INVALID_ARITY); |
| 2692 | |
| 2693 | if (nargs >= 4) { |
| 2694 | if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) { |
| 2695 | xmlXPathErr(ctxt, XPATH_INVALID_TYPE); |
| 2696 | goto error; |
| 2697 | } |
| 2698 | number = valuePop(ctxt); |
| 2699 | if (number != NULL) |
| 2700 | num = (int) number->floatval; |
| 2701 | } |
| 2702 | if (nargs >= 3) { |
| 2703 | if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) { |
| 2704 | xmlXPathErr(ctxt, XPATH_INVALID_TYPE); |
| 2705 | goto error; |
| 2706 | } |
| 2707 | position = valuePop(ctxt); |
| 2708 | if (position != NULL) |
| 2709 | pos = (int) position->floatval; |
| 2710 | } |
| 2711 | if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { |
| 2712 | xmlXPathErr(ctxt, XPATH_INVALID_TYPE); |
| 2713 | goto error; |
| 2714 | } |
| 2715 | string = valuePop(ctxt); |
| 2716 | if ((ctxt->value == NULL) || |
| 2717 | ((ctxt->value->type != XPATH_LOCATIONSET) && |
| 2718 | (ctxt->value->type != XPATH_NODESET))) { |
| 2719 | xmlXPathErr(ctxt, XPATH_INVALID_TYPE); |
| 2720 | goto error; |
| 2721 | } |
| 2722 | set = valuePop(ctxt); |
| 2723 | newset = xmlXPtrLocationSetCreate(NULL); |
| 2724 | if (newset == NULL) { |
| 2725 | xmlXPathErr(ctxt, XPATH_MEMORY_ERROR); |
| 2726 | goto error; |
| 2727 | } |
| 2728 | if (set->nodesetval == NULL) { |
| 2729 | goto error; |
| 2730 | } |
| 2731 | if (set->type == XPATH_NODESET) { |
| 2732 | xmlXPathObjectPtr tmp; |
nothing calls this directly
no test coverage detected