19#pragma convert("ISO8859-1")
43#ifdef LIBXML_XPTR_ENABLED
46#define XPTR_XMLNS_SCHEME
50#ifdef LIBXML_DEBUG_ENABLED
56 xmlGenericError(xmlGenericErrorContext, \
57 "Unimplemented block at %s:%d\n", \
61 xmlGenericError(xmlGenericErrorContext, \
62 "Internal error at %s:%d\n", \
78xmlXPtrErrMemory(
const char *
extra)
83 "Memory allocation failed : %s\n",
extra);
94xmlXPtrErr(xmlXPathParserContextPtr ctxt,
int error,
99 if ((ctxt ==
NULL) || (ctxt->context ==
NULL)) {
112 ctxt->context->lastError.code =
error;
114 ctxt->context->lastError.str1 = (
char *)
xmlStrdup(ctxt->base);
115 ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
116 ctxt->context->lastError.node = ctxt->context->debugNode;
117 if (ctxt->context->error !=
NULL) {
118 ctxt->context->error(ctxt->context->userData,
119 &ctxt->context->lastError);
124 (
const char *)
extra, (
const char *) ctxt->base,
NULL,
125 ctxt->cur - ctxt->base, 0,
135#ifdef LIBXML_XPTR_LOCS_ENABLED
210#ifdef LIBXML_XPTR_LOCS_ENABLED
231 if ((node1 ==
NULL) || (node2 ==
NULL))
236 if (node1 == node2) {
243 return(xmlXPathCmpNodes(node1, node2));
255static xmlXPathObjectPtr
257 xmlXPathObjectPtr
ret;
264 ret = (xmlXPathObjectPtr)
xmlMalloc(
sizeof(xmlXPathObject));
266 xmlXPtrErrMemory(
"allocating point");
269 memset(
ret, 0 , (
size_t)
sizeof(xmlXPathObject));
270 ret->type = XPATH_POINT;
283xmlXPtrRangeCheckOrder(xmlXPathObjectPtr
range) {
288 if (
range->type != XPATH_RANGE)
292 tmp = xmlXPtrCmpPoints(
range->user,
range->index,
314xmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) {
315 if (range1 == range2)
317 if ((range1 ==
NULL) || (range2 ==
NULL))
319 if (range1->type != range2->type)
321 if (range1->type != XPATH_RANGE)
323 if (range1->user != range2->user)
325 if (range1->index != range2->index)
327 if (range1->user2 != range2->user2)
329 if (range1->index2 != range2->index2)
345static xmlXPathObjectPtr
348 xmlXPathObjectPtr
ret;
359 ret = (xmlXPathObjectPtr)
xmlMalloc(
sizeof(xmlXPathObject));
361 xmlXPtrErrMemory(
"allocating range");
365 ret->type = XPATH_RANGE;
367 ret->index = startindex;
369 ret->index2 = endindex;
387 xmlXPathObjectPtr
ret;
398 ret = xmlXPtrNewRangeInternal(
start, startindex,
end, endindex);
399 xmlXPtrRangeCheckOrder(
ret);
413xmlXPtrNewRangePoints(xmlXPathObjectPtr
start, xmlXPathObjectPtr
end) {
414 xmlXPathObjectPtr
ret;
420 if (
start->type != XPATH_POINT)
422 if (
end->type != XPATH_POINT)
427 xmlXPtrRangeCheckOrder(
ret);
442 xmlXPathObjectPtr
ret;
448 if (
start->type != XPATH_POINT)
452 xmlXPtrRangeCheckOrder(
ret);
467 xmlXPathObjectPtr
ret;
473 if (
end->type != XPATH_POINT)
477 xmlXPtrRangeCheckOrder(
ret);
492 xmlXPathObjectPtr
ret;
500 xmlXPtrRangeCheckOrder(
ret);
514 xmlXPathObjectPtr
ret;
536 xmlXPathObjectPtr
ret;
545 endIndex =
end->index;
548 endNode =
end->user2;
549 endIndex =
end->index2;
555 if ((
end->nodesetval ==
NULL) || (
end->nodesetval->nodeNr <= 0))
557 endNode =
end->nodesetval->nodeTab[
end->nodesetval->nodeNr - 1];
565 ret = xmlXPtrNewRangeInternal(
start, -1, endNode, endIndex);
566 xmlXPtrRangeCheckOrder(
ret);
570#define XML_RANGESET_DEFAULT 10
581xmlXPtrLocationSetCreate(xmlXPathObjectPtr
val) {
582 xmlLocationSetPtr
ret;
584 ret = (xmlLocationSetPtr)
xmlMalloc(
sizeof(xmlLocationSet));
586 xmlXPtrErrMemory(
"allocating locationset");
589 memset(
ret, 0 , (
size_t)
sizeof(xmlLocationSet));
591 ret->locTab = (xmlXPathObjectPtr *)
xmlMalloc(XML_RANGESET_DEFAULT *
592 sizeof(xmlXPathObjectPtr));
594 xmlXPtrErrMemory(
"allocating locationset");
599 XML_RANGESET_DEFAULT * (
size_t)
sizeof(xmlXPathObjectPtr));
600 ret->locMax = XML_RANGESET_DEFAULT;
615xmlXPtrLocationSetAdd(xmlLocationSetPtr
cur, xmlXPathObjectPtr
val) {
623 for (
i = 0;
i <
cur->locNr;
i++) {
624 if (xmlXPtrRangesEqual(
cur->locTab[
i],
val)) {
625 xmlXPathFreeObject(
val);
633 if (
cur->locMax == 0) {
634 cur->locTab = (xmlXPathObjectPtr *)
xmlMalloc(XML_RANGESET_DEFAULT *
635 sizeof(xmlXPathObjectPtr));
637 xmlXPtrErrMemory(
"adding location to set");
641 XML_RANGESET_DEFAULT * (
size_t)
sizeof(xmlXPathObjectPtr));
642 cur->locMax = XML_RANGESET_DEFAULT;
643 }
else if (
cur->locNr ==
cur->locMax) {
644 xmlXPathObjectPtr *
temp;
648 sizeof(xmlXPathObjectPtr));
650 xmlXPtrErrMemory(
"adding location to set");
668xmlXPtrLocationSetMerge(xmlLocationSetPtr val1, xmlLocationSetPtr val2) {
672 if (val2 ==
NULL)
return(val1);
679 for (
i = 0;
i < val2->locNr;
i++)
680 xmlXPtrLocationSetAdd(val1, val2->locTab[
i]);
693xmlXPtrLocationSetDel(xmlLocationSetPtr
cur, xmlXPathObjectPtr
val) {
702 for (
i = 0;
i <
cur->locNr;
i++)
703 if (
cur->locTab[
i] ==
val)
break;
705 if (
i >=
cur->locNr) {
708 "xmlXPtrLocationSetDel: Range wasn't found in RangeList\n");
713 for (;
i <
cur->locNr;
i++)
714 cur->locTab[
i] =
cur->locTab[
i + 1];
726xmlXPtrLocationSetRemove(xmlLocationSetPtr
cur,
int val) {
728 if (
val >=
cur->locNr)
return;
742xmlXPtrFreeLocationSet(xmlLocationSetPtr
obj) {
747 for (
i = 0;
i <
obj->locNr;
i++) {
748 xmlXPathFreeObject(
obj->locTab[
i]);
767 xmlXPathObjectPtr
ret;
769 ret = (xmlXPathObjectPtr)
xmlMalloc(
sizeof(xmlXPathObject));
771 xmlXPtrErrMemory(
"allocating locationset");
774 memset(
ret, 0 , (
size_t)
sizeof(xmlXPathObject));
775 ret->type = XPATH_LOCATIONSET;
777 ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewCollapsedRange(
start));
779 ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewRangeNodes(
start,
end));
793xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr
set) {
794 xmlXPathObjectPtr
ret;
796 ret = (xmlXPathObjectPtr)
xmlMalloc(
sizeof(xmlXPathObject));
798 xmlXPtrErrMemory(
"allocating locationset");
801 memset(
ret, 0 , (
size_t)
sizeof(xmlXPathObject));
802 ret->type = XPATH_LOCATIONSET;
805 xmlLocationSetPtr newset;
807 newset = xmlXPtrLocationSetCreate(
NULL);
811 for (
i = 0;
i <
set->nodeNr;
i++)
812 xmlXPtrLocationSetAdd(newset,
813 xmlXPtrNewCollapsedRange(
set->nodeTab[
i]));
815 ret->user = (
void *) newset;
829xmlXPtrWrapLocationSet(xmlLocationSetPtr
val) {
830 xmlXPathObjectPtr
ret;
832 ret = (xmlXPathObjectPtr)
xmlMalloc(
sizeof(xmlXPathObject));
834 xmlXPtrErrMemory(
"allocating locationset");
837 memset(
ret, 0 , (
size_t)
sizeof(xmlXPathObject));
838 ret->type = XPATH_LOCATIONSET;
850static void xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt,
xmlChar *
name);
874#define CUR (*ctxt->cur)
875#define SKIP(val) ctxt->cur += (val)
876#define NXT(val) ctxt->cur[(val)]
879 while (IS_BLANK_CH(*(ctxt->cur))) NEXT
881#define CURRENT (*ctxt->cur)
882#define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
893xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt,
int indx) {
895 xmlXPathObjectPtr
obj;
896 xmlNodeSetPtr oldset;
898 CHECK_TYPE(XPATH_NODESET);
899 obj = valuePop(ctxt);
900 oldset =
obj->nodesetval;
901 if ((indx <= 0) || (oldset ==
NULL) || (oldset->nodeNr != 1)) {
902 xmlXPathFreeObject(
obj);
903 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
906 cur = xmlXPtrGetNthChild(oldset->nodeTab[0], indx);
908 xmlXPathFreeObject(
obj);
909 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
912 oldset->nodeTab[0] =
cur;
913 valuePush(ctxt,
obj);
951xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt,
xmlChar *
name) {
957 name = xmlXPathParseName(ctxt);
959 XP_ERROR(XPATH_EXPR_ERROR);
963 XP_ERROR(XPATH_EXPR_ERROR);
972 xmlXPtrErrMemory(
"allocating buffer");
985 }
else if (
CUR ==
'(') {
987 }
else if (
CUR ==
'^') {
988 if ((
NXT(1) ==
')') || (
NXT(1) ==
'(') || (
NXT(1) ==
'^')) {
1000 XP_ERROR(XPTR_SYNTAX_ERROR);
1005 const xmlChar *oldBase = ctxt->base;
1006 const xmlChar *oldCur = ctxt->cur;
1008 ctxt->cur = ctxt->base =
buffer;
1015 ctxt->context->node = (
xmlNodePtr)ctxt->context->doc;
1016 ctxt->context->proximityPosition = 1;
1017 ctxt->context->contextSize = 1;
1018#ifdef LIBXML_XPTR_LOCS_ENABLED
1021 xmlXPathEvalExpr(ctxt);
1022 ctxt->base = oldBase;
1025 const xmlChar *oldBase = ctxt->base;
1026 const xmlChar *oldCur = ctxt->cur;
1029 ctxt->cur = ctxt->base =
buffer;
1032 xmlXPtrEvalChildSeq(ctxt,
NULL);
1034 name2 = xmlXPathParseName(ctxt);
1036 ctxt->base = oldBase;
1040 XP_ERROR(XPATH_EXPR_ERROR);
1042 xmlXPtrEvalChildSeq(ctxt,
name2);
1044 ctxt->base = oldBase;
1046#ifdef XPTR_XMLNS_SCHEME
1048 const xmlChar *oldBase = ctxt->base;
1049 const xmlChar *oldCur = ctxt->cur;
1052 ctxt->cur = ctxt->base =
buffer;
1053 prefix = xmlXPathParseNCName(ctxt);
1054 if (prefix ==
NULL) {
1055 ctxt->base = oldBase;
1059 XP_ERROR(XPTR_SYNTAX_ERROR);
1063 ctxt->base = oldBase;
1068 XP_ERROR(XPTR_SYNTAX_ERROR);
1073 xmlXPathRegisterNs(ctxt->context, prefix, ctxt->cur);
1074 ctxt->base = oldBase;
1080 "unsupported scheme '%s'\n",
name);
1114xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt,
xmlChar *
name) {
1116 name = xmlXPathParseName(ctxt);
1118 XP_ERROR(XPATH_EXPR_ERROR);
1120 ctxt->error = XPATH_EXPRESSION_OK;
1121 xmlXPtrEvalXPtrPart(ctxt,
name);
1124 if ((ctxt->error != XPATH_EXPRESSION_OK) &&
1132 if (ctxt->value !=
NULL) {
1133 xmlXPathObjectPtr
obj = ctxt->value;
1135 switch (
obj->type) {
1136#ifdef LIBXML_XPTR_LOCS_ENABLED
1137 case XPATH_LOCATIONSET: {
1138 xmlLocationSetPtr loc = ctxt->value->user;
1139 if ((loc !=
NULL) && (loc->locNr > 0))
1144 case XPATH_NODESET: {
1145 xmlNodeSetPtr loc = ctxt->value->nodesetval;
1146 if ((loc !=
NULL) && (loc->nodeNr > 0))
1159 obj = valuePop(ctxt);
1161 xmlXPathFreeObject(
obj);
1170 name = xmlXPathParseName(ctxt);
1186xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt,
xmlChar *
name) {
1193 "warning: ChildSeq not starting by /1\n",
NULL);
1197 valuePush(ctxt, xmlXPathNewString(
name));
1199 xmlXPathIdFunction(ctxt, 1);
1203 while (
CUR ==
'/') {
1204 int child = 0, overflow = 0;
1207 while ((
CUR >=
'0') && (
CUR <=
'9')) {
1221 xmlXPtrGetChildNo(ctxt,
child);
1237xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
1238 if (ctxt->valueTab ==
NULL) {
1240 ctxt->valueTab = (xmlXPathObjectPtr *)
1241 xmlMalloc(10 *
sizeof(xmlXPathObjectPtr));
1242 if (ctxt->valueTab ==
NULL) {
1243 xmlXPtrErrMemory(
"allocating evaluation context");
1247 ctxt->valueMax = 10;
1249 ctxt->valueFrame = 0;
1254 xmlXPtrEvalChildSeq(ctxt,
NULL);
1258 name = xmlXPathParseName(ctxt);
1260 XP_ERROR(XPATH_EXPR_ERROR);
1262 xmlXPtrEvalFullXPtr(ctxt,
name);
1267 xmlXPtrEvalChildSeq(ctxt,
name);
1272 XP_ERROR(XPATH_EXPR_ERROR);
1282#ifdef LIBXML_XPTR_LOCS_ENABLED
1284void xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1286void xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1288void xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1290void xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1292void xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1294void xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1296void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt,
int nargs);
1312 xmlXPathContextPtr
ret;
1316 ret = xmlXPathNewContext(doc);
1319#ifdef LIBXML_XPTR_LOCS_ENABLED
1324 xmlXPathRegisterFunc(
ret, (
xmlChar *)
"range",
1325 xmlXPtrRangeFunction);
1326 xmlXPathRegisterFunc(
ret, (
xmlChar *)
"range-inside",
1327 xmlXPtrRangeInsideFunction);
1328 xmlXPathRegisterFunc(
ret, (
xmlChar *)
"string-range",
1329 xmlXPtrStringRangeFunction);
1330 xmlXPathRegisterFunc(
ret, (
xmlChar *)
"start-point",
1331 xmlXPtrStartPointFunction);
1332 xmlXPathRegisterFunc(
ret, (
xmlChar *)
"end-point",
1333 xmlXPtrEndPointFunction);
1335 xmlXPtrHereFunction);
1336 xmlXPathRegisterFunc(
ret, (
xmlChar *)
" origin",
1337 xmlXPtrOriginFunction);
1355 xmlXPathParserContextPtr ctxt;
1356 xmlXPathObjectPtr
res =
NULL, tmp;
1365 ctxt = xmlXPathNewParserContext(
str,
ctx);
1368 xmlXPtrEvalXPointer(ctxt);
1370 if ((ctxt->value !=
NULL) &&
1371#ifdef LIBXML_XPTR_LOCS_ENABLED
1372 (ctxt->value->type != XPATH_LOCATIONSET) &&
1374 (ctxt->value->type != XPATH_NODESET)) {
1376 "xmlXPtrEval: evaluation failed to return a node set\n",
1379 res = valuePop(ctxt);
1383 tmp = valuePop(ctxt);
1386 if (tmp->type == XPATH_NODESET) {
1391 set = tmp->nodesetval;
1398 xmlXPathFreeObject(tmp);
1400 }
while (tmp !=
NULL);
1403 "xmlXPtrEval: object(s) left on the eval stack\n",
1406 if (ctxt->error != XPATH_EXPRESSION_OK) {
1407 xmlXPathFreeObject(
res);
1411 xmlXPathFreeParserContext(ctxt);
1415#ifdef LIBXML_XPTR_LOCS_ENABLED
1426xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr
range) {
1435 if (
range->type != XPATH_RANGE)
1448 index1 =
range->index;
1449 index2 =
range->index2;
1460 if ((
cur ==
start) && (index1 > 1)) {
1462 len -= (index1 - 1);
1492 end = xmlXPtrGetNthChild(
cur, index2 - 1);
1495 if ((
cur ==
start) && (index1 > 1)) {
1496 cur = xmlXPtrGetNthChild(
cur, index1 - 1);
1522 if ((
cur ==
start) && (index1 > 1)) {
1527 cur = xmlXPtrGetNthChild(
cur, index1 - 1);
1541 switch (
cur->type) {
1598xmlXPtrBuildNodeList(xmlXPathObjectPtr
obj) {
1604 switch (
obj->type) {
1605 case XPATH_NODESET: {
1606 xmlNodeSetPtr
set =
obj->nodesetval;
1609 for (
i = 0;
i <
set->nodeNr;
i++) {
1612 switch (
set->nodeTab[
i]->type) {
1646 case XPATH_LOCATIONSET: {
1647 xmlLocationSetPtr
set = (xmlLocationSetPtr)
obj->user;
1650 for (
i = 0;
i <
set->locNr;
i++) {
1655 xmlXPtrBuildNodeList(
set->locTab[
i]));
1664 return(xmlXPtrBuildRangeNodeList(
obj));
1693 switch (
node->type) {
1729xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
1732 if (ctxt->context->here ==
NULL)
1733 XP_ERROR(XPTR_SYNTAX_ERROR);
1735 valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->here,
NULL));
1747xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
1750 if (ctxt->context->origin ==
NULL)
1751 XP_ERROR(XPTR_SYNTAX_ERROR);
1753 valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->origin,
NULL));
1780xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
1782 xmlLocationSetPtr newset =
NULL;
1783 xmlLocationSetPtr oldset =
NULL;
1786 if ((ctxt->value ==
NULL) ||
1787 ((ctxt->value->type != XPATH_LOCATIONSET) &&
1788 (ctxt->value->type != XPATH_NODESET)))
1789 XP_ERROR(XPATH_INVALID_TYPE)
1791 obj = valuePop(ctxt);
1792 if (
obj->type == XPATH_NODESET) {
1796 tmp = xmlXPtrNewLocationSetNodeSet(
obj->nodesetval);
1797 xmlXPathFreeObject(
obj);
1799 XP_ERROR(XPATH_MEMORY_ERROR)
1803 newset = xmlXPtrLocationSetCreate(
NULL);
1804 if (newset ==
NULL) {
1805 xmlXPathFreeObject(
obj);
1806 XP_ERROR(XPATH_MEMORY_ERROR);
1808 oldset = (xmlLocationSetPtr)
obj->user;
1812 for (
i = 0;
i < oldset->locNr;
i++) {
1813 tmp = oldset->locTab[
i];
1817 switch (tmp->type) {
1819 point = xmlXPtrNewPoint(tmp->user, tmp->index);
1826 xmlXPathFreeObject(
obj);
1827 xmlXPtrFreeLocationSet(newset);
1828 XP_ERROR(XPTR_SYNTAX_ERROR);
1830 point = xmlXPtrNewPoint(
node, tmp->index);
1843 xmlXPtrLocationSetAdd(newset,
point);
1846 xmlXPathFreeObject(
obj);
1847 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
1876xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
1878 xmlLocationSetPtr newset =
NULL;
1879 xmlLocationSetPtr oldset =
NULL;
1882 if ((ctxt->value ==
NULL) ||
1883 ((ctxt->value->type != XPATH_LOCATIONSET) &&
1884 (ctxt->value->type != XPATH_NODESET)))
1885 XP_ERROR(XPATH_INVALID_TYPE)
1887 obj = valuePop(ctxt);
1888 if (
obj->type == XPATH_NODESET) {
1892 tmp = xmlXPtrNewLocationSetNodeSet(
obj->nodesetval);
1893 xmlXPathFreeObject(
obj);
1895 XP_ERROR(XPATH_MEMORY_ERROR)
1899 newset = xmlXPtrLocationSetCreate(
NULL);
1900 if (newset ==
NULL) {
1901 xmlXPathFreeObject(
obj);
1902 XP_ERROR(XPATH_MEMORY_ERROR);
1904 oldset = (xmlLocationSetPtr)
obj->user;
1908 for (
i = 0;
i < oldset->locNr;
i++) {
1909 tmp = oldset->locTab[
i];
1913 switch (tmp->type) {
1915 point = xmlXPtrNewPoint(tmp->user, tmp->index);
1922 xmlXPathFreeObject(
obj);
1923 xmlXPtrFreeLocationSet(newset);
1924 XP_ERROR(XPTR_SYNTAX_ERROR);
1926 point = xmlXPtrNewPoint(
node, tmp->index2);
1927 }
else if (tmp->user ==
NULL) {
1929 xmlXPtrNbLocChildren(
node));
1942 xmlXPtrLocationSetAdd(newset,
point);
1945 xmlXPathFreeObject(
obj);
1946 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
1961static xmlXPathObjectPtr
1962xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
1965 if ((ctxt ==
NULL) || (ctxt->context ==
NULL) ||
1966 (ctxt->context->doc ==
NULL))
1968 switch (loc->type) {
1970 return(xmlXPtrNewRange(loc->user, loc->index,
1971 loc->user, loc->index));
1973 if (loc->user2 !=
NULL) {
1974 return(xmlXPtrNewRange(loc->user, loc->index,
1975 loc->user2, loc->index2));
1979 return(xmlXPtrNewRange(
node, 0,
node,
1980 xmlXPtrGetArity(
node)));
1982 switch (
node->type) {
1985 return(xmlXPtrNewRange(
node, 0,
node,
1986 xmlXPtrGetArity(
node)));
1996 int indx = xmlXPtrGetIndex(
node);
1999 return(xmlXPtrNewRange(
node, indx - 1,
2027xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
2029 xmlXPathObjectPtr
set;
2030 xmlLocationSetPtr oldset;
2031 xmlLocationSetPtr newset;
2034 if ((ctxt->value ==
NULL) ||
2035 ((ctxt->value->type != XPATH_LOCATIONSET) &&
2036 (ctxt->value->type != XPATH_NODESET)))
2037 XP_ERROR(XPATH_INVALID_TYPE)
2039 set = valuePop(ctxt);
2040 if (
set->type == XPATH_NODESET) {
2041 xmlXPathObjectPtr tmp;
2046 tmp = xmlXPtrNewLocationSetNodeSet(
set->nodesetval);
2047 xmlXPathFreeObject(
set);
2049 XP_ERROR(XPATH_MEMORY_ERROR)
2052 oldset = (xmlLocationSetPtr)
set->user;
2057 newset = xmlXPtrLocationSetCreate(
NULL);
2058 if (newset ==
NULL) {
2059 xmlXPathFreeObject(
set);
2060 XP_ERROR(XPATH_MEMORY_ERROR);
2062 if (oldset !=
NULL) {
2063 for (
i = 0;
i < oldset->locNr;
i++) {
2064 xmlXPtrLocationSetAdd(newset,
2065 xmlXPtrCoveringRange(ctxt, oldset->locTab[
i]));
2072 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
2073 xmlXPathFreeObject(
set);
2085static xmlXPathObjectPtr
2086xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
2089 if ((ctxt ==
NULL) || (ctxt->context ==
NULL) ||
2090 (ctxt->context->doc ==
NULL))
2092 switch (loc->type) {
2101 return(xmlXPtrNewRange(
node, 0,
node, 0));
2103 return(xmlXPtrNewRange(
node, 0,
node,
2113 return(xmlXPtrNewRange(
node, 0,
node,
2114 xmlXPtrGetArity(
node)));
2123 if (loc->user2 !=
NULL) {
2124 return(xmlXPtrNewRange(
node, loc->index,
2125 loc->user2, loc->index2));
2127 switch (
node->type) {
2133 return(xmlXPtrNewRange(
node, 0,
node, 0));
2135 return(xmlXPtrNewRange(
node, 0,
node,
2145 return(xmlXPtrNewRange(
node, 0,
node,
2146 xmlXPtrGetArity(
node)));
2181xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
2183 xmlXPathObjectPtr
set;
2184 xmlLocationSetPtr oldset;
2185 xmlLocationSetPtr newset;
2188 if ((ctxt->value ==
NULL) ||
2189 ((ctxt->value->type != XPATH_LOCATIONSET) &&
2190 (ctxt->value->type != XPATH_NODESET)))
2191 XP_ERROR(XPATH_INVALID_TYPE)
2193 set = valuePop(ctxt);
2194 if (
set->type == XPATH_NODESET) {
2195 xmlXPathObjectPtr tmp;
2200 tmp = xmlXPtrNewLocationSetNodeSet(
set->nodesetval);
2201 xmlXPathFreeObject(
set);
2203 XP_ERROR(XPATH_MEMORY_ERROR)
2210 newset = xmlXPtrLocationSetCreate(
NULL);
2211 if (newset ==
NULL) {
2212 xmlXPathFreeObject(
set);
2213 XP_ERROR(XPATH_MEMORY_ERROR);
2215 oldset = (xmlLocationSetPtr)
set->user;
2217 for (
i = 0;
i < oldset->locNr;
i++) {
2218 xmlXPtrLocationSetAdd(newset,
2219 xmlXPtrInsideRange(ctxt, oldset->locTab[
i]));
2226 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
2227 xmlXPathFreeObject(
set);
2241xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt,
2243 XP_ERROR(XPATH_EXPR_ERROR);
2321 while (
bytes >= 0) {
2414 pos = startindex - 1;
2428 "found range %d bytes at index %d of ->",
2430 xmlDebugDumpString(
stdout,
cur->content);
2445 "found subrange %d bytes at index %d of ->",
2447 xmlDebugDumpString(
stdout,
cur->content);
2450 string = &
string[sub];
2498 pos = *startindex - 1;
2511 "found '%c' at index %d of ->",
2513 xmlDebugDumpString(
stdout,
cur->content);
2516 if (xmlXPtrMatchString(
string,
cur,
pos + 1,
2519 *startindex =
pos + 1;
2534 "found '' at index %d of ->",
2536 xmlDebugDumpString(
stdout,
cur->content);
2540 *startindex =
pos + 1;
2542 *endindex =
pos + 1;
2547 if ((
cur == *
end) && (
pos >= *endindex))
2617 switch (
obj->type) {
2620 if (
obj->index <= 0)
2627 if (
obj->index <= 0)
2653 switch (
obj->type) {
2656 if (
obj->index <= 0)
2663 if (
obj->index <= 0)
2711xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt,
int nargs) {
2712 int i, startindex, endindex = 0, fendindex;
2715 xmlLocationSetPtr oldset;
2716 xmlLocationSetPtr newset =
NULL;
2717 xmlXPathObjectPtr
string =
NULL;
2718 xmlXPathObjectPtr position =
NULL;
2720 int found,
pos = 0,
num = 0;
2725 if ((nargs < 2) || (nargs > 4))
2726 XP_ERROR(XPATH_INVALID_ARITY);
2729 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_NUMBER)) {
2730 xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
2738 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_NUMBER)) {
2739 xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
2742 position = valuePop(ctxt);
2743 if (position !=
NULL)
2744 pos = (
int) position->floatval;
2746 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
2747 xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
2750 string = valuePop(ctxt);
2751 if ((ctxt->value ==
NULL) ||
2752 ((ctxt->value->type != XPATH_LOCATIONSET) &&
2753 (ctxt->value->type != XPATH_NODESET))) {
2754 xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
2757 set = valuePop(ctxt);
2758 newset = xmlXPtrLocationSetCreate(
NULL);
2759 if (newset ==
NULL) {
2760 xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
2763 if (
set->nodesetval ==
NULL) {
2766 if (
set->type == XPATH_NODESET) {
2767 xmlXPathObjectPtr tmp;
2772 tmp = xmlXPtrNewLocationSetNodeSet(
set->nodesetval);
2773 xmlXPathFreeObject(
set);
2776 xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
2781 oldset = (xmlLocationSetPtr)
set->user;
2787 for (
i = 0;
i < oldset->locNr;
i++) {
2789 xmlXPathDebugDumpObject(
stdout, oldset->locTab[
i], 0);
2792 xmlXPtrGetStartPoint(oldset->locTab[
i], &
start, &startindex);
2793 xmlXPtrGetEndPoint(oldset->locTab[
i], &
end, &endindex);
2794 xmlXPtrAdvanceChar(&
start, &startindex, 0);
2795 xmlXPtrGetLastChar(&
end, &endindex);
2799 "from index %d of ->", startindex);
2803 "to index %d of ->", endindex);
2804 xmlDebugDumpString(
stdout,
end->content);
2809 fendindex = endindex;
2810 found = xmlXPtrSearchString(
string->stringval, &
start, &startindex,
2813 if (position ==
NULL) {
2814 xmlXPtrLocationSetAdd(newset,
2815 xmlXPtrNewRange(
start, startindex, fend, fendindex));
2816 }
else if (xmlXPtrAdvanceChar(&
start, &startindex,
2822 rindx = startindex - 1;
2823 if (xmlXPtrAdvanceChar(&rend, &rindx,
2825 xmlXPtrLocationSetAdd(newset,
2826 xmlXPtrNewRange(
start, startindex,
2830 xmlXPtrLocationSetAdd(newset,
2831 xmlXPtrNewRange(
start, startindex,
2832 start, startindex));
2834 xmlXPtrLocationSetAdd(newset,
2835 xmlXPtrNewRange(
start, startindex,
2840 startindex = fendindex;
2841 if (
string->stringval[0] == 0)
2844 }
while (found == 1);
2852 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
2853 xmlXPathFreeObject(
set);
2854 xmlXPathFreeObject(
string);
2855 if (position) xmlXPathFreeObject(position);
2870xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
2872 xmlXPathObjectPtr
res;
2873 xmlXPathObjectPtr
obj, tmp;
2874 xmlLocationSetPtr newset =
NULL;
2875 xmlLocationSetPtr oldset;
2878 if (ctxt ==
NULL)
return;
2882 XP_ERROR(XPATH_INVALID_PREDICATE_ERROR);
2892 CHECK_TYPE(XPATH_LOCATIONSET);
2893 obj = valuePop(ctxt);
2895 ctxt->context->node =
NULL;
2897 if ((oldset ==
NULL) || (oldset->locNr == 0)) {
2898 ctxt->context->contextSize = 0;
2899 ctxt->context->proximityPosition = 0;
2900 xmlXPathEvalExpr(ctxt);
2901 res = valuePop(ctxt);
2903 xmlXPathFreeObject(
res);
2904 valuePush(ctxt,
obj);
2912 newset = xmlXPtrLocationSetCreate(
NULL);
2914 for (
i = 0;
i < oldset->locNr;
i++) {
2921 ctxt->context->node = oldset->locTab[
i]->user;
2922 tmp = xmlXPathNewNodeSet(ctxt->context->node);
2923 valuePush(ctxt, tmp);
2924 ctxt->context->contextSize = oldset->locNr;
2925 ctxt->context->proximityPosition =
i + 1;
2927 xmlXPathEvalExpr(ctxt);
2934 res = valuePop(ctxt);
2935 if (xmlXPathEvaluatePredicateResult(ctxt,
res)) {
2936 xmlXPtrLocationSetAdd(newset,
2937 xmlXPathObjectCopy(oldset->locTab[
i]));
2944 xmlXPathFreeObject(
res);
2945 if (ctxt->value == tmp) {
2946 res = valuePop(ctxt);
2947 xmlXPathFreeObject(
res);
2950 ctxt->context->node =
NULL;
2956 xmlXPathFreeObject(
obj);
2957 ctxt->context->node =
NULL;
2958 ctxt->context->contextSize = -1;
2959 ctxt->context->proximityPosition = -1;
2960 valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
2963 XP_ERROR(XPATH_INVALID_PREDICATE_ERROR);
static unsigned char bytes[4]
static WCHAR no[MAX_STRING_RESOURCE_LEN]
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLint const GLchar GLint stringlen
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static unsigned int number
static unsigned __int64 next
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR void * xmlGenericErrorContext
XMLPUBVAR xmlReallocFunc xmlRealloc
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
XMLPUBFUN void XMLCALL xmlInitParser(void)
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBFUN xmlNodePtr XMLCALL xmlCopyNode(xmlNodePtr node, int recursive)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewTextLen(const xmlChar *content, int len)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewText(const xmlChar *content)
XMLPUBFUN xmlNodePtr XMLCALL xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem)
XMLPUBFUN void XMLCALL xmlResetError(xmlErrorPtr err)
@ XML_XPTR_UNKNOWN_SCHEME
@ XML_XPTR_CHILDSEQ_START
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
XMLPUBFUN int XMLCALL xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len)
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
#define LIBXML_ATTR_FORMAT(fmt, args)