mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
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
This commit is contained in:
parent
f1f08cf8dc
commit
2b2e02d6bb
@ -1,3 +1,9 @@
|
||||
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
|
||||
|
23
pattern.c
23
pattern.c
@ -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:
|
||||
|
47
result/pattern/conj
Normal file
47
result/pattern/conj
Normal file
@ -0,0 +1,47 @@
|
||||
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
|
8
test/pattern/conj.pat
Normal file
8
test/pattern/conj.pat
Normal file
@ -0,0 +1,8 @@
|
||||
a|b
|
||||
a|c
|
||||
b|c
|
||||
a|b|c
|
||||
/a|b
|
||||
b|/a
|
||||
a//c|b//c
|
||||
d|e|f|g|h|a
|
13
test/pattern/conj.xml
Normal file
13
test/pattern/conj.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<a>
|
||||
<b>
|
||||
<c><b/></c>
|
||||
<c>
|
||||
<b/>
|
||||
<c><b/></c>
|
||||
</c>
|
||||
</b>
|
||||
<c>
|
||||
<b>
|
||||
</b>
|
||||
</c>
|
||||
</a>
|
17
xmllint.c
17
xmllint.c
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user