Commit 2b2e02d6 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixed implementation for | added a specific regression test Daniel

* pattern.c xmllint.c: fixed implementation for |
* test/pattern/conj.* result/pattern/conj: added a specific regression
  test
Daniel
parent f1f08cf8
Sun Feb 6 00:17:57 CET 2005 Daniel Veillard <daniel@veillard.com>
* pattern.c xmllint.c: fixed implementation for |
* test/pattern/conj.* result/pattern/conj: added a specific regression
test
Sat Feb 5 18:36:56 CET 2005 Daniel Veillard <daniel@veillard.com>
 
* pattern.c: first implementation for | support
......
......@@ -19,8 +19,6 @@
* currently push(NULL, NULL) means a reset of the streaming context
* and indicating we are on / (the document node), probably need
* something similar for .
* - handling of disjunction "pattern1 | pattern2" mean needed to build
* and check a list internally
* - get rid of the "compile" starting with lowercase
* - get rid of the Strdup/Strndup in case of dictionary
*/
......@@ -1303,10 +1301,14 @@ xmlNewStreamCtxt(xmlStreamCompPtr stream) {
*/
void
xmlFreeStreamCtxt(xmlStreamCtxtPtr stream) {
if (stream != NULL) {
xmlStreamCtxtPtr next;
while (stream != NULL) {
next = stream->next;
if (stream->states != NULL)
xmlFree(stream->states);
xmlFree(stream);
stream = next;
}
}
......@@ -1367,6 +1369,9 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
const xmlChar *name, const xmlChar *ns) {
int ret = 0, err = 0, tmp, i, m, match, step, desc, final;
xmlStreamCompPtr comp;
#ifdef DEBUG_STREAMING
xmlStreamCtxtPtr orig = stream;
#endif
if ((stream == NULL) || (stream->nbState < 0))
return(-1);
......@@ -1382,8 +1387,10 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
err++;
if (comp->steps[tmp].flags & XML_STREAM_STEP_FINAL)
ret = 1;
stream = stream->next;
continue; /* while */
}
stream = stream->next;
continue; /* while */
}
/*
......@@ -1486,11 +1493,11 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
stream = stream->next;
} /* while stream != NULL */
#ifdef DEBUG_STREAMING
xmlDebugStreamCtxt(stream, ret);
#endif
if (err > 0)
ret = -1;
#ifdef DEBUG_STREAMING
xmlDebugStreamCtxt(orig, ret);
#endif
return(ret);
}
......@@ -1560,8 +1567,8 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict,
return(NULL);
start = pattern;
or = start;
while (*or != 0) {
or = start;
tmp = NULL;
while ((*or != 0) && (*or != '|')) or++;
if (*or == 0)
......@@ -1591,11 +1598,11 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict,
xmlStreamCompile(cur);
if (xmlReversePattern(cur) < 0)
goto error;
start = or;
if (tmp != NULL) {
xmlFree(tmp);
tmp = NULL;
}
start = or;
}
return(ret);
error:
......
Node /a matches pattern a|b
Node /a/b matches pattern a|b
Node /a/b/c[1]/b matches pattern a|b
Node /a/b/c[2]/b matches pattern a|b
Node /a/b/c[2]/c/b matches pattern a|b
Node /a/c/b matches pattern a|b
Node /a matches pattern a|c
Node /a/b/c[1] matches pattern a|c
Node /a/b/c[2] matches pattern a|c
Node /a/b/c[2]/c matches pattern a|c
Node /a/c matches pattern a|c
Node /a/b matches pattern b|c
Node /a/b/c[1] matches pattern b|c
Node /a/b/c[1]/b matches pattern b|c
Node /a/b/c[2] matches pattern b|c
Node /a/b/c[2]/b matches pattern b|c
Node /a/b/c[2]/c matches pattern b|c
Node /a/b/c[2]/c/b matches pattern b|c
Node /a/c matches pattern b|c
Node /a/c/b matches pattern b|c
Node /a matches pattern a|b|c
Node /a/b matches pattern a|b|c
Node /a/b/c[1] matches pattern a|b|c
Node /a/b/c[1]/b matches pattern a|b|c
Node /a/b/c[2] matches pattern a|b|c
Node /a/b/c[2]/b matches pattern a|b|c
Node /a/b/c[2]/c matches pattern a|b|c
Node /a/b/c[2]/c/b matches pattern a|b|c
Node /a/c matches pattern a|b|c
Node /a/c/b matches pattern a|b|c
Node /a matches pattern /a|b
Node /a/b matches pattern /a|b
Node /a/b/c[1]/b matches pattern /a|b
Node /a/b/c[2]/b matches pattern /a|b
Node /a/b/c[2]/c/b matches pattern /a|b
Node /a/c/b matches pattern /a|b
Node /a matches pattern b|/a
Node /a/b matches pattern b|/a
Node /a/b/c[1]/b matches pattern b|/a
Node /a/b/c[2]/b matches pattern b|/a
Node /a/b/c[2]/c/b matches pattern b|/a
Node /a/c/b matches pattern b|/a
Node /a/b/c[1] matches pattern a//c|b//c
Node /a/b/c[2] matches pattern a//c|b//c
Node /a/b/c[2]/c matches pattern a//c|b//c
Node /a/c matches pattern a//c|b//c
Node /a matches pattern d|e|f|g|h|a
a|b
a|c
b|c
a|b|c
/a|b
b|/a
a//c|b//c
d|e|f|g|h|a
<a>
<b>
<c><b/></c>
<c>
<b/>
<c><b/></c>
</c>
</b>
<c>
<b>
</b>
</c>
</a>
......@@ -1062,6 +1062,17 @@ static void walkDoc(xmlDocPtr doc) {
pattern = NULL;
}
}
if (patternc != NULL) {
patstream = xmlPatternGetStreamCtxt(patternc);
if (patstream != NULL) {
ret = xmlStreamPush(patstream, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "xmlStreamPush() failure\n");
xmlFreeStreamCtxt(patstream);
patstream = NULL;
}
}
}
#endif /* LIBXML_PATTERN_ENABLED */
reader = xmlReaderWalker(doc);
if (reader != NULL) {
......@@ -1090,6 +1101,12 @@ static void walkDoc(xmlDocPtr doc) {
fprintf(stderr, "Failed to crate a reader from the document\n");
progresult = XMLLINT_ERR_UNCLASS;
}
#ifdef LIBXML_PATTERN_ENABLED
if (patstream != NULL) {
xmlFreeStreamCtxt(patstream);
patstream = NULL;
}
#endif
}
#endif /* LIBXML_READER_ENABLED */
......
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