38#ifdef LIBXML_PATTERN_ENABLED
45#define ERROR(a, b, c, d)
46#define ERROR5(a, b, c, d, e)
48#define XML_STREAM_STEP_DESC 1
49#define XML_STREAM_STEP_FINAL 2
50#define XML_STREAM_STEP_ROOT 4
51#define XML_STREAM_STEP_ATTR 8
52#define XML_STREAM_STEP_NODE 16
53#define XML_STREAM_STEP_IN_SET 32
61#define XML_STREAM_FINAL_IS_ANY_NODE 1<<14
62#define XML_STREAM_FROM_ROOT 1<<15
63#define XML_STREAM_DESC 1<<16
69#define XML_STREAM_ANY_NODE 100
71#define XML_PATTERN_NOTPATTERN (XML_PATTERN_XPATH | \
75#define XML_STREAM_XS_IDC(c) ((c)->flags & \
76 (XML_PATTERN_XSSEL | XML_PATTERN_XSFIELD))
78#define XML_STREAM_XS_IDC_SEL(c) ((c)->flags & XML_PATTERN_XSSEL)
80#define XML_STREAM_XS_IDC_FIELD(c) ((c)->flags & XML_PATTERN_XSFIELD)
82#define XML_PAT_COPY_NSNAME(c, r, nsname) \
83 if ((c)->comp->dict) \
84 r = (xmlChar *) xmlDictLookup((c)->comp->dict, BAD_CAST nsname, -1); \
85 else r = xmlStrdup(BAD_CAST nsname);
87#define XML_PAT_FREE_STRING(c, r) if ((c)->comp->dict == NULL) xmlFree(r);
89typedef struct _xmlStreamStep xmlStreamStep;
90typedef xmlStreamStep *xmlStreamStepPtr;
91struct _xmlStreamStep {
98typedef struct _xmlStreamComp xmlStreamComp;
99typedef xmlStreamComp *xmlStreamCompPtr;
100struct _xmlStreamComp {
104 xmlStreamStepPtr
steps;
108struct _xmlStreamCtxt {
109 struct _xmlStreamCtxt *
next;
110 xmlStreamCompPtr comp;
119static void xmlFreeStreamComp(xmlStreamCompPtr comp);
138typedef struct _xmlStepState xmlStepState;
139typedef xmlStepState *xmlStepStatePtr;
140struct _xmlStepState {
145typedef struct _xmlStepStates xmlStepStates;
146typedef xmlStepStates *xmlStepStatesPtr;
147struct _xmlStepStates {
150 xmlStepStatePtr states;
153typedef struct _xmlStepOp xmlStepOp;
154typedef xmlStepOp *xmlStepOpPtr;
161#define PAT_FROM_ROOT (1<<8)
162#define PAT_FROM_CUR (1<<9)
167 struct _xmlPattern *
next;
176typedef struct _xmlPatParserContext xmlPatParserContext;
177typedef xmlPatParserContext *xmlPatParserContextPtr;
178struct _xmlPatParserContext {
209 "xmlNewPattern : malloc failed\n");
214 cur->steps = (xmlStepOpPtr)
xmlMalloc(
cur->maxStep *
sizeof(xmlStepOp));
218 "xmlNewPattern : malloc failed\n");
231xmlFreePattern(xmlPatternPtr comp) {
232 xmlFreePatternList(comp);
236xmlFreePatternInternal(xmlPatternPtr comp) {
242 if (comp->stream !=
NULL)
243 xmlFreeStreamComp(comp->stream);
244 if (comp->pattern !=
NULL)
246 if (comp->steps !=
NULL) {
247 if (comp->dict ==
NULL) {
248 for (
i = 0;
i < comp->nbStep;
i++) {
249 op = &comp->steps[
i];
258 if (comp->dict !=
NULL)
261 memset(comp, -1,
sizeof(xmlPattern));
272xmlFreePatternList(xmlPatternPtr comp) {
275 while (comp !=
NULL) {
279 xmlFreePatternInternal(
cur);
294static xmlPatParserContextPtr
297 xmlPatParserContextPtr
cur;
302 cur = (xmlPatParserContextPtr)
xmlMalloc(
sizeof(xmlPatParserContext));
305 "xmlNewPatParserContext : malloc failed\n");
308 memset(
cur, 0,
sizeof(xmlPatParserContext));
312 if (namespaces !=
NULL) {
314 for (
i = 0;namespaces[2 *
i] !=
NULL;
i++)
316 cur->nb_namespaces =
i;
318 cur->nb_namespaces = 0;
320 cur->namespaces = namespaces;
331xmlFreePatParserContext(xmlPatParserContextPtr ctxt) {
334 memset(ctxt, -1,
sizeof(xmlPatParserContext));
354 if (comp->nbStep >= comp->maxStep) {
360 "xmlPatternAdd: realloc failed\n");
366 comp->steps[comp->nbStep].op =
op;
367 comp->steps[comp->nbStep].value =
value;
368 comp->steps[comp->nbStep].value2 = value2;
381xsltSwapTopPattern(xmlPatternPtr comp) {
383 int j = comp->nbStep - 1;
387 register xmlPatOp
op;
389 tmp = comp->steps[
i].value;
390 comp->steps[
i].value = comp->steps[
j].value;
391 comp->steps[
j].value = tmp;
392 tmp = comp->steps[
i].value2;
393 comp->steps[
i].value2 = comp->steps[
j].value2;
394 comp->steps[
j].value2 = tmp;
395 op = comp->steps[
i].op;
396 comp->steps[
i].op = comp->steps[
j].op;
397 comp->steps[
j].op =
op;
411xmlReversePattern(xmlPatternPtr comp) {
417 if ((comp->nbStep > 0) && (comp->steps[0].op == XML_OP_ANCESTOR)) {
418 for (
i = 0,
j = 1;
j < comp->nbStep;
i++,
j++) {
419 comp->steps[
i].value = comp->steps[
j].value;
420 comp->steps[
i].value2 = comp->steps[
j].value2;
421 comp->steps[
i].op = comp->steps[
j].op;
425 if (comp->nbStep >= comp->maxStep) {
431 "xmlReversePattern: realloc failed\n");
438 j = comp->nbStep - 1;
441 register xmlPatOp
op;
442 tmp = comp->steps[
i].value;
443 comp->steps[
i].value = comp->steps[
j].value;
444 comp->steps[
j].value = tmp;
445 tmp = comp->steps[
i].value2;
446 comp->steps[
i].value2 = comp->steps[
j].value2;
447 comp->steps[
j].value2 = tmp;
448 op = comp->steps[
i].op;
449 comp->steps[
i].op = comp->steps[
j].op;
450 comp->steps[
j].op =
op;
454 comp->steps[comp->nbStep].value =
NULL;
455 comp->steps[comp->nbStep].value2 =
NULL;
456 comp->steps[comp->nbStep++].op = XML_OP_END;
467xmlPatPushState(xmlStepStates *states,
int step,
xmlNodePtr node) {
468 if ((states->states ==
NULL) || (states->maxstates <= 0)) {
469 states->maxstates = 4;
470 states->nbstates = 0;
471 states->states =
xmlMalloc(4 *
sizeof(xmlStepState));
473 else if (states->maxstates <= states->nbstates) {
476 tmp = (xmlStepStatePtr)
xmlRealloc(states->states,
477 2 * states->maxstates *
sizeof(xmlStepState));
480 states->states = tmp;
481 states->maxstates *= 2;
483 states->states[states->nbstates].step = step;
484 states->states[states->nbstates++].node =
node;
504 xmlStepStates states = {0, 0,
NULL};
509 for (;
i < comp->nbStep;
i++) {
510 step = &comp->steps[
i];
525 if (step->value ==
NULL)
527 if (step->value[0] !=
node->name[0])
534 if (step->value2 !=
NULL)
536 }
else if (
node->ns->href !=
NULL) {
537 if (step->value2 ==
NULL)
551 lst =
node->children;
553 if (step->value !=
NULL) {
554 while (lst !=
NULL) {
556 (step->value[0] == lst->
name[0]) &&
569 if (step->value !=
NULL) {
570 if (step->value[0] !=
node->name[0])
577 if (step->value2 !=
NULL)
579 }
else if (step->value2 !=
NULL) {
592 if (step->value ==
NULL)
594 if (step->value[0] !=
node->name[0])
600 if (step->value2 !=
NULL)
602 }
else if (
node->ns->href !=
NULL) {
603 if (step->value2 ==
NULL)
609 case XML_OP_ANCESTOR:
611 if (step->value ==
NULL) {
613 step = &comp->steps[
i];
614 if (step->op == XML_OP_ROOT)
616 if (step->op != XML_OP_ELEM)
618 if (step->value ==
NULL)
630 (step->value[0] ==
node->name[0]) &&
634 if (step->value2 ==
NULL)
636 }
else if (
node->ns->href !=
NULL) {
637 if ((step->value2 !=
NULL) &&
650 if (step->op == XML_OP_ANCESTOR)
651 xmlPatPushState(&states,
i,
node);
653 xmlPatPushState(&states,
i - 1,
node);
659 if (step->value !=
NULL)
661 }
else if (
node->ns->href !=
NULL) {
662 if (step->value ==
NULL)
675 if (states.states !=
NULL) {
682 if (states.states ==
NULL)
684 if (states.nbstates <= 0) {
689 i = states.states[states.nbstates].step;
690 node = states.states[states.nbstates].node;
704 xmlGenericError(xmlGenericErrorContext, \
705 "Unimplemented block at %s:%d\n", \
707#define CUR (*ctxt->cur)
708#define SKIP(val) ctxt->cur += (val)
709#define NXT(val) ctxt->cur[(val)]
710#define PEEKPREV(val) ctxt->cur[-(val)]
711#define CUR_PTR ctxt->cur
714 while (IS_BLANK_CH(CUR)) NEXT
716#define CURRENT (*ctxt->cur)
717#define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
720#define PUSH(op, val, val2) \
721 if (xmlPatternAdd(ctxt, ctxt->comp, (op), (val), (val2))) goto error;
723#define XSLT_ERROR(X) \
724 { xsltError(ctxt, __FILE__, __LINE__, X); \
725 ctxt->error = (X); return; }
727#define XSLT_ERROR0(X) \
728 { xsltError(ctxt, __FILE__, __LINE__, X); \
729 ctxt->error = (X); return(0); }
745xmlPatScanLiteral(xmlPatParserContextPtr ctxt) {
770 }
else if (
CUR ==
'\'') {
813xmlPatScanName(xmlPatParserContextPtr ctxt) {
826 (
val ==
'.') || (
val ==
'-') ||
851xmlPatScanNCName(xmlPatParserContextPtr ctxt) {
864 (
val ==
'.') || (
val ==
'-') ||
891xmlPatScanQName(xmlPatParserContextPtr ctxt,
xmlChar **prefix) {
895 ret = xmlPatScanNCName(ctxt);
899 ret = xmlPatScanNCName(ctxt);
912xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
918 name = xmlPatScanNCName(ctxt);
925 "xmlCompileAttributeTest : Name expected\n");
938 XML_PAT_FREE_STRING(ctxt, prefix);
945 token = xmlPatScanName(ctxt);
946 if ((prefix[0] ==
'x') &&
947 (prefix[1] ==
'm') &&
948 (prefix[2] ==
'l') &&
953 for (
i = 0;
i < ctxt->nb_namespaces;
i++) {
955 XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 *
i])
959 if (
i >= ctxt->nb_namespaces) {
961 "xmlCompileAttributeTest : no namespace bound to prefix %s\n",
963 XML_PAT_FREE_STRING(ctxt, prefix);
968 XML_PAT_FREE_STRING(ctxt, prefix);
975 "xmlCompileAttributeTest : Name expected\n");
988 XML_PAT_FREE_STRING(ctxt, URL)
990 XML_PAT_FREE_STRING(ctxt,
token);
1005xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
1024 if (XML_STREAM_XS_IDC_SEL(ctxt->comp)) {
1026 "Unexpected attribute axis in '%s'.\n", ctxt->base);
1031 xmlCompileAttributeTest(ctxt);
1032 if (ctxt->error != 0)
1036 name = xmlPatScanNCName(ctxt);
1044 "xmlCompileStepPattern : Name expected\n");
1067 token = xmlPatScanName(ctxt);
1068 if ((prefix[0] ==
'x') &&
1069 (prefix[1] ==
'm') &&
1070 (prefix[2] ==
'l') &&
1075 for (
i = 0;
i < ctxt->nb_namespaces;
i++) {
1076 if (
xmlStrEqual(ctxt->namespaces[2 *
i + 1], prefix)) {
1077 XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 *
i])
1081 if (
i >= ctxt->nb_namespaces) {
1083 "xmlCompileStepPattern : no namespace bound to prefix %s\n",
1089 XML_PAT_FREE_STRING(ctxt, prefix);
1097 "xmlCompileStepPattern : Name expected\n");
1107 XML_PAT_FREE_STRING(ctxt,
name);
1108 name = xmlPatScanName(ctxt);
1116 "xmlCompileStepPattern : QName expected\n");
1134 token = xmlPatScanName(ctxt);
1135 if ((prefix[0] ==
'x') &&
1136 (prefix[1] ==
'm') &&
1137 (prefix[2] ==
'l') &&
1142 for (
i = 0;
i < ctxt->nb_namespaces;
i++) {
1143 if (
xmlStrEqual(ctxt->namespaces[2 *
i + 1], prefix)) {
1144 XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 *
i])
1148 if (
i >= ctxt->nb_namespaces) {
1150 "xmlCompileStepPattern : no namespace bound "
1151 "to prefix %s\n", prefix);
1156 XML_PAT_FREE_STRING(ctxt, prefix);
1164 "xmlCompileStepPattern : Name expected\n");
1175 XML_PAT_FREE_STRING(ctxt,
name)
1177 if (XML_STREAM_XS_IDC_SEL(ctxt->comp)) {
1179 "Unexpected attribute axis in '%s'.\n", ctxt->base);
1183 xmlCompileAttributeTest(ctxt);
1184 if (ctxt->error != 0)
1189 "The 'element' or 'attribute' axis is expected.\n",
NULL);
1194 }
else if (
CUR ==
'*') {
1207 XML_PAT_FREE_STRING(ctxt, URL)
1209 XML_PAT_FREE_STRING(ctxt,
token)
1211 XML_PAT_FREE_STRING(ctxt,
name)
1224xmlCompilePathPattern(xmlPatParserContextPtr ctxt) {
1227 ctxt->comp->flags |= PAT_FROM_ROOT;
1228 }
else if ((
CUR ==
'.') || (ctxt->comp->flags & XML_PATTERN_NOTPATTERN)) {
1229 ctxt->comp->flags |= PAT_FROM_CUR;
1232 if ((
CUR ==
'/') && (
NXT(1) ==
'/')) {
1236 }
else if ((
CUR ==
'.') && (
NXT(1) ==
'/') && (
NXT(2) ==
'/')) {
1245 "Incomplete expression '%s'.\n", ctxt->base);
1252 xmlCompileAttributeTest(ctxt);
1256 xmlCompileStepPattern(ctxt);
1257 if (ctxt->error != 0)
1268 "Incomplete expression '%s'.\n", ctxt->base);
1273 xmlCompileStepPattern(ctxt);
1274 if (ctxt->error != 0)
1277 while (
CUR ==
'/') {
1278 if (
NXT(1) ==
'/') {
1283 xmlCompileStepPattern(ctxt);
1284 if (ctxt->error != 0)
1292 "Incomplete expression '%s'.\n", ctxt->base);
1296 xmlCompileStepPattern(ctxt);
1297 if (ctxt->error != 0)
1304 "Failed to compile pattern %s\n", ctxt->base);
1321xmlCompileIDCXPathPath(xmlPatParserContextPtr ctxt) {
1325 "Unexpected selection of the document root in '%s'.\n",
1329 ctxt->comp->flags |= PAT_FROM_CUR;
1345 "Unexpected token after '.' in '%s'.\n", ctxt->base);
1357 "Unexpected '/' token in '%s'.\n", ctxt->base);
1366 goto error_unfinished;
1372 xmlCompileStepPattern(ctxt);
1373 if (ctxt->error != 0)
1386 "Unexpected subsequent '//' in '%s'.\n",
1391 goto error_unfinished;
1397 "Failed to compile expression '%s'.\n", ctxt->base);
1408 "Unfinished expression '%s'.\n", ctxt->base);
1418#ifdef DEBUG_STREAMING
1420xmlDebugStreamComp(xmlStreamCompPtr
stream) {
1424 printf(
"Stream: NULL\n");
1437 if (
stream->steps[
i].flags & XML_STREAM_STEP_ROOT)
1439 if (
stream->steps[
i].flags & XML_STREAM_STEP_DESC)
1441 if (
stream->steps[
i].flags & XML_STREAM_STEP_FINAL)
1447xmlDebugStreamCtxt(xmlStreamCtxtPtr ctxt,
int match) {
1451 printf(
"Stream: NULL\n");
1454 printf(
"Stream: level %d, %d states: ", ctxt->level, ctxt->nbState);
1459 for (
i = 0;
i < ctxt->nbState;
i++) {
1460 if (ctxt->states[2 *
i] < 0)
1463 printf(
" %d: step %d, level %d",
i, ctxt->states[2 *
i],
1464 ctxt->states[(2 *
i) + 1]);
1465 if (ctxt->comp->steps[ctxt->states[2 *
i]].flags &
1466 XML_STREAM_STEP_DESC)
1482static xmlStreamCompPtr
1483xmlNewStreamComp(
int size) {
1484 xmlStreamCompPtr
cur;
1489 cur = (xmlStreamCompPtr)
xmlMalloc(
sizeof(xmlStreamComp));
1492 "xmlNewStreamComp: malloc failed\n");
1500 "xmlNewStreamComp: malloc failed\n");
1515xmlFreeStreamComp(xmlStreamCompPtr comp) {
1517 if (comp->steps !=
NULL)
1519 if (comp->dict !=
NULL)
1537xmlStreamCompAddStep(xmlStreamCompPtr comp,
const xmlChar *
name,
1539 xmlStreamStepPtr
cur;
1541 if (comp->nbStep >= comp->maxStep) {
1543 comp->maxStep * 2 *
sizeof(xmlStreamStep));
1546 "xmlNewStreamComp: malloc failed\n");
1552 cur = &comp->steps[comp->nbStep++];
1556 cur->nodeType = nodeType;
1557 return(comp->nbStep - 1);
1569xmlStreamCompile(xmlPatternPtr comp) {
1574 if ((comp ==
NULL) || (comp->steps ==
NULL))
1579 if ((comp->nbStep == 1) &&
1580 (comp->steps[0].op == XML_OP_ELEM) &&
1581 (comp->steps[0].value ==
NULL) &&
1582 (comp->steps[0].value2 ==
NULL)) {
1583 stream = xmlNewStreamComp(0);
1587 stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE;
1592 stream = xmlNewStreamComp((comp->nbStep / 2) + 1);
1595 if (comp->dict !=
NULL) {
1596 stream->dict = comp->dict;
1601 if (comp->flags & PAT_FROM_ROOT)
1602 stream->flags |= XML_STREAM_FROM_ROOT;
1604 for (;
i < comp->nbStep;
i++) {
1605 step = comp->steps[
i];
1623 flags |= XML_STREAM_STEP_ATTR;
1625 s = xmlStreamCompAddStep(
stream,
1632 if ((step.value ==
NULL) && (step.value2 ==
NULL)) {
1641 if ((comp->nbStep ==
i + 1) &&
1642 (
flags & XML_STREAM_STEP_DESC)) {
1647 if (comp->nbStep ==
i + 1) {
1648 stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE;
1650 flags |= XML_STREAM_STEP_NODE;
1652 XML_STREAM_ANY_NODE,
flags);
1663 stream->steps[prevs].flags |= XML_STREAM_STEP_IN_SET;
1674 s = xmlStreamCompAddStep(
stream, step.value, step.value2,
1683 s = xmlStreamCompAddStep(
stream, step.value, step.value2,
1700 case XML_OP_ANCESTOR:
1702 if (
flags & XML_STREAM_STEP_DESC)
1704 flags |= XML_STREAM_STEP_DESC;
1708 if ((
stream->flags & XML_STREAM_DESC) == 0)
1709 stream->flags |= XML_STREAM_DESC;
1713 if ((!
root) && (comp->flags & XML_PATTERN_NOTPATTERN) == 0) {
1719 if ((
stream->flags & XML_STREAM_DESC) == 0)
1720 stream->flags |= XML_STREAM_DESC;
1722 if (
stream->nbStep > 0) {
1723 if ((
stream->steps[0].flags & XML_STREAM_STEP_DESC) == 0)
1724 stream->steps[0].flags |= XML_STREAM_STEP_DESC;
1729 stream->steps[
s].flags |= XML_STREAM_STEP_FINAL;
1731 stream->steps[0].flags |= XML_STREAM_STEP_ROOT;
1732#ifdef DEBUG_STREAMING
1733 xmlDebugStreamComp(
stream);
1738 xmlFreeStreamComp(
stream);
1750static xmlStreamCtxtPtr
1751xmlNewStreamCtxt(xmlStreamCompPtr
stream) {
1752 xmlStreamCtxtPtr
cur;
1754 cur = (xmlStreamCtxtPtr)
xmlMalloc(
sizeof(xmlStreamCtxt));
1757 "xmlNewStreamCtxt: malloc failed\n");
1765 "xmlNewStreamCtxt: malloc failed\n");
1772 cur->blockLevel = -1;
1783xmlFreeStreamCtxt(xmlStreamCtxtPtr
stream) {
1784 xmlStreamCtxtPtr
next;
1805xmlStreamCtxtAddState(xmlStreamCtxtPtr comp,
int idx,
int level) {
1807 for (
i = 0;
i < comp->nbState;
i++) {
1808 if (comp->states[2 *
i] < 0) {
1809 comp->states[2 *
i] =
idx;
1810 comp->states[2 *
i + 1] =
level;
1814 if (comp->nbState >= comp->maxState) {
1818 comp->maxState * 4 *
sizeof(
int));
1821 "xmlNewStreamCtxt: malloc failed\n");
1825 comp->maxState *= 2;
1827 comp->states[2 * comp->nbState] =
idx;
1828 comp->states[2 * comp->nbState++ + 1] =
level;
1829 return(comp->nbState - 1);
1849xmlStreamPushInternal(xmlStreamCtxtPtr
stream,
1853 xmlStreamCompPtr comp;
1855#ifdef DEBUG_STREAMING
1856 xmlStreamCtxtPtr orig =
stream;
1871 if (comp->flags & XML_STREAM_FROM_ROOT) {
1872 if (comp->nbStep == 0) {
1876 if ((comp->nbStep == 1) &&
1877 (comp->steps[0].nodeType == XML_STREAM_ANY_NODE) &&
1878 (comp->steps[0].flags & XML_STREAM_STEP_DESC))
1885 }
else if (comp->steps[0].flags & XML_STREAM_STEP_ROOT) {
1887 tmp = xmlStreamCtxtAddState(
stream, 0, 0);
1900 if (comp->nbStep == 0) {
1905 if (
stream->flags & XML_PATTERN_XPATH) {
1915 (((
stream->flags & XML_PATTERN_NOTPATTERN) == 0) ||
1922 if (
stream->blockLevel != -1) {
1932 ((comp->flags & XML_STREAM_FINAL_IS_ANY_NODE) == 0)) {
1948 if ((comp->flags & XML_STREAM_DESC) == 0) {
1970 stepNr =
stream->states[2 *
i];
1976 tmp =
stream->states[(2 *
i) + 1];
1983 desc = comp->steps[stepNr].flags & XML_STREAM_STEP_DESC;
1990 step = comp->steps[stepNr];
1991 if (step.nodeType != nodeType) {
1996 if ((comp->flags & XML_STREAM_DESC) == 0)
1999 }
else if (step.nodeType != XML_STREAM_ANY_NODE)
2006 if (step.nodeType == XML_STREAM_ANY_NODE) {
2008 }
else if (step.name ==
NULL) {
2009 if (step.ns ==
NULL) {
2016 }
else if (((step.ns !=
NULL) == (
ns !=
NULL)) &&
2018 (step.name[0] ==
name[0]) &&
2030 }
else if (comp->dict) {
2031 if (step.name ==
NULL) {
2032 if (step.ns ==
NULL)
2041 final = step.flags & XML_STREAM_STEP_FINAL;
2047 xmlStreamCtxtAddState(
stream, stepNr + 1,
2054 xmlStreamCtxtAddState(
stream, stepNr + 1,
2058 if ((
ret != 1) && (step.flags & XML_STREAM_STEP_IN_SET)) {
2066 if (((comp->flags & XML_STREAM_DESC) == 0) &&
2067 ((!
match) ||
final)) {
2086 step = comp->steps[0];
2087 if (step.flags & XML_STREAM_STEP_ROOT)
2090 desc = step.flags & XML_STREAM_STEP_DESC;
2091 if (
stream->flags & XML_PATTERN_NOTPATTERN) {
2097 if (
stream->level == 1) {
2098 if (XML_STREAM_XS_IDC(
stream)) {
2128 if (step.nodeType != nodeType) {
2131 else if (step.nodeType != XML_STREAM_ANY_NODE)
2138 if (step.nodeType == XML_STREAM_ANY_NODE) {
2140 }
else if (step.name ==
NULL) {
2141 if (step.ns ==
NULL) {
2148 }
else if (((step.ns !=
NULL) == (
ns !=
NULL)) &&
2150 (step.name[0] ==
name[0]) &&
2156 final = step.flags & XML_STREAM_STEP_FINAL;
2162 if ((
ret != 1) && (step.flags & XML_STREAM_STEP_IN_SET)) {
2170 if (((comp->flags & XML_STREAM_DESC) == 0) &&
2171 ((!
match) ||
final)) {
2185#ifdef DEBUG_STREAMING
2186 xmlDebugStreamCtxt(orig,
ret);
2208xmlStreamPush(xmlStreamCtxtPtr
stream,
2233xmlStreamPushNode(xmlStreamCtxtPtr
stream,
2258xmlStreamPushAttr(xmlStreamCtxtPtr
stream,
2272xmlStreamPop(xmlStreamCtxtPtr
stream) {
2294 for (
i =
stream->nbState -1;
i >= 0;
i--) {
2296 lev =
stream->states[(2 *
i) + 1];
2299 if (lev <= stream->
level)
2320xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt)
2322 if (streamCtxt ==
NULL)
2324 while (streamCtxt !=
NULL) {
2325 if (streamCtxt->comp->flags & XML_STREAM_FINAL_IS_ANY_NODE)
2327 streamCtxt = streamCtxt->next;
2353 xmlPatParserContextPtr ctxt =
NULL;
2366 while ((*or != 0) && (*or !=
'|')) or++;
2368 ctxt = xmlNewPatParserContext(
start, dict, namespaces);
2372 ctxt = xmlNewPatParserContext(tmp, dict, namespaces);
2377 cur = xmlNewPattern();
2395 if (XML_STREAM_XS_IDC(
cur))
2396 xmlCompileIDCXPathPath(ctxt);
2398 xmlCompilePathPattern(ctxt);
2399 if (ctxt->error != 0)
2401 xmlFreePatParserContext(ctxt);
2407 type =
cur->flags & (PAT_FROM_ROOT | PAT_FROM_CUR);
2408 }
else if (
type == PAT_FROM_ROOT) {
2409 if (
cur->flags & PAT_FROM_CUR)
2411 }
else if (
type == PAT_FROM_CUR) {
2412 if (
cur->flags & PAT_FROM_ROOT)
2417 xmlStreamCompile(
cur);
2418 if (xmlReversePattern(
cur) < 0)
2426 if (streamable == 0) {
2430 xmlFreeStreamComp(
cur->stream);
2439 if (ctxt !=
NULL) xmlFreePatParserContext(ctxt);
2462 while (comp !=
NULL) {
2463 ret = xmlPatMatch(comp,
node);
2481xmlPatternGetStreamCtxt(xmlPatternPtr comp)
2485 if ((comp ==
NULL) || (comp->stream ==
NULL))
2488 while (comp !=
NULL) {
2489 if (comp->stream ==
NULL)
2491 cur = xmlNewStreamCtxt(comp->stream);
2500 cur->flags = comp->flags;
2505 xmlFreeStreamCtxt(
ret);
2519xmlPatternStreamable(xmlPatternPtr comp) {
2522 while (comp !=
NULL) {
2523 if (comp->stream ==
NULL)
2540xmlPatternMaxDepth(xmlPatternPtr comp) {
2544 while (comp !=
NULL) {
2545 if (comp->stream ==
NULL)
2547 for (
i = 0;
i < comp->stream->nbStep;
i++)
2548 if (comp->stream->steps[
i].flags & XML_STREAM_STEP_DESC)
2550 if (comp->stream->nbStep >
ret)
2551 ret = comp->stream->nbStep;
2568xmlPatternMinDepth(xmlPatternPtr comp) {
2572 while (comp !=
NULL) {
2573 if (comp->stream ==
NULL)
2575 if (comp->stream->nbStep <
ret)
2576 ret = comp->stream->nbStep;
2593xmlPatternFromRoot(xmlPatternPtr comp) {
2596 while (comp !=
NULL) {
2597 if (comp->stream ==
NULL)
2599 if (comp->flags & PAT_FROM_ROOT)
void restart(int argc, const char *argv[])
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
#define PUSH(op, val, val2, novar)
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble GLdouble q
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
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 token
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 GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static const WCHAR desc[]
static DWORD DWORD DWORD DWORD * steps
XMLPUBFUN int XMLCALL xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len)
static unsigned __int64 next
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR xmlReallocFunc xmlRealloc
#define XML_XML_NAMESPACE
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)