Commit 16ef800b authored by Daniel Veillard's avatar Daniel Veillard
Browse files

bugfixes around the streaming patterns Daniel

* pattern.c xmllint.c: bugfixes around the streaming patterns
Daniel
parent f9d16914
Mon Jan 31 01:27:22 CET 2005 Daniel Veillard <daniel@veillard.com>
* pattern.c xmllint.c: bugfixes around the streaming patterns
Sun Jan 30 23:35:19 CET 2005 Daniel Veillard <daniel@veillard.com>
 
* Makefile.am configure.in result/pattern/simple
......
......@@ -1289,7 +1289,7 @@ xmlStreamCtxtAddState(xmlStreamCtxtPtr comp, int idx, int level) {
int
xmlStreamPush(xmlStreamCtxtPtr stream,
const xmlChar *name, const xmlChar *ns) {
int ret = 0, tmp, i, m, match, step;
int ret = 0, tmp, i, m, match, step, desc, final;
xmlStreamCompPtr comp;
if ((stream == NULL) || (stream->nbState < 0))
......@@ -1318,6 +1318,9 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
if (step < 0) continue;
/* skip new states just added */
if (stream->states[(2 * i) + 1] > stream->level) continue;
/* skip continuations */
desc = comp->steps[step].flags & XML_STREAM_STEP_DESC;
if ((stream->states[(2 * i) + 1] < stream->level) && (!desc))continue;
/* discard old states */
/* something needed about old level discarded */
......@@ -1344,23 +1347,29 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
}
}
if (match) {
if (comp->steps[step].flags & XML_STREAM_STEP_DESC) {
if (comp->steps[step].flags & XML_STREAM_STEP_FINAL) {
final = comp->steps[step].flags & XML_STREAM_STEP_FINAL;
if (desc) {
if (final) {
ret = 1;
} else {
/* descending match create a new state */
xmlStreamCtxtAddState(stream, step + 1, stream->level + 1);
}
} else {
if (comp->steps[step].flags & XML_STREAM_STEP_FINAL) {
if (final) {
ret = 1;
#if 0
stream->states[2 * i] = -1;
#endif
} else {
#if 0
stream->states[2 * i] = step + 1;
stream->states[2 * i + 1] = stream->level + 1;
#endif
xmlStreamCtxtAddState(stream, step + 1, stream->level + 1);
}
}
} else if (!(comp->steps[step].flags & XML_STREAM_STEP_DESC)) {
} else if (!desc) {
/* didn't match, discard */
stream->states[2 * i] = -1;
}
......
......@@ -806,9 +806,10 @@ static void myClose(FILE *f) {
************************************************************************/
static void processNode(xmlTextReaderPtr reader) {
const xmlChar *name, *value;
int type;
int type, empty;
type = xmlTextReaderNodeType(reader);
empty = xmlTextReaderIsEmptyElement(reader);
if (debug) {
name = xmlTextReaderConstName(reader);
......@@ -822,7 +823,7 @@ static void processNode(xmlTextReaderPtr reader) {
xmlTextReaderDepth(reader),
type,
name,
xmlTextReaderIsEmptyElement(reader),
empty,
xmlTextReaderHasValue(reader));
if (value == NULL)
printf("\n");
......@@ -868,7 +869,9 @@ static void processNode(xmlTextReaderPtr reader) {
}
} else if (type == XML_READER_TYPE_END_ELEMENT) {
}
if ((type == XML_READER_TYPE_END_ELEMENT) ||
((type == XML_READER_TYPE_ELEMENT) && (empty))) {
ret = xmlStreamPop(patstream);
if (ret < 0) {
fprintf(stderr, "xmlStreamPop() failure\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment