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

Function xmlStreamCompile

ThirdParty/libxml2/vtklibxml2/pattern.c:1506–1675  ·  view source on GitHub ↗

* xmlStreamCompile: * @comp: the precompiled pattern * * Tries to stream compile a pattern * * Returns -1 in case of failure and 0 in case of success. */

Source from the content-addressed store, hash-verified

1504 * Returns -1 in case of failure and 0 in case of success.
1505 */
1506static int
1507xmlStreamCompile(xmlPatternPtr comp) {
1508 xmlStreamCompPtr stream;
1509 int i, s = 0, root = 0, flags = 0, prevs = -1;
1510 xmlStepOp step;
1511
1512 if ((comp == NULL) || (comp->steps == NULL))
1513 return(-1);
1514 /*
1515 * special case for .
1516 */
1517 if ((comp->nbStep == 1) &&
1518 (comp->steps[0].op == XML_OP_ELEM) &&
1519 (comp->steps[0].value == NULL) &&
1520 (comp->steps[0].value2 == NULL)) {
1521 stream = xmlNewStreamComp(0);
1522 if (stream == NULL)
1523 return(-1);
1524 /* Note that the stream will have no steps in this case. */
1525 stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE;
1526 comp->stream = stream;
1527 return(0);
1528 }
1529
1530 stream = xmlNewStreamComp((comp->nbStep / 2) + 1);
1531 if (stream == NULL)
1532 return(-1);
1533 if (comp->dict != NULL) {
1534 stream->dict = comp->dict;
1535 xmlDictReference(stream->dict);
1536 }
1537
1538 i = 0;
1539 if (comp->flags & PAT_FROM_ROOT)
1540 stream->flags |= XML_STREAM_FROM_ROOT;
1541
1542 for (;i < comp->nbStep;i++) {
1543 step = comp->steps[i];
1544 switch (step.op) {
1545 case XML_OP_END:
1546 break;
1547 case XML_OP_ROOT:
1548 if (i != 0)
1549 goto error;
1550 root = 1;
1551 break;
1552 case XML_OP_NS:
1553 s = xmlStreamCompAddStep(stream, NULL, step.value,
1554 XML_ELEMENT_NODE, flags);
1555 if (s < 0)
1556 goto error;
1557 prevs = s;
1558 flags = 0;
1559 break;
1560 case XML_OP_ATTR:
1561 flags |= XML_STREAM_STEP_ATTR;
1562 prevs = -1;
1563 s = xmlStreamCompAddStep(stream,

Callers 1

xmlPatternCompileSafeFunction · 0.85

Calls 4

xmlNewStreamCompFunction · 0.85
xmlDictReferenceFunction · 0.85
xmlStreamCompAddStepFunction · 0.85
xmlFreeStreamCompFunction · 0.85

Tested by

no test coverage detected