diff --git a/ChangeLog b/ChangeLog index 34e62713..a5c154d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Jun 6 06:43:33 PDT 2005 William Brack + + * xpath.c, pattern.c: Enhanced xmlXPathRunStreamEval, fixed + handling of depth/level for cases like union operator + (bug #306348 reported by Bob Stayton). Also enhanced + several comments throughout pattern.c. + * doc/apibuild.py: fixed problem in handling of + 'signed' declaration. Rebuilt the docs. + Tue May 31 20:35:27 PDT 2005 William Brack * xinclude.c: Enhanced handling of xml:base for included diff --git a/doc/APIchunk11.html b/doc/APIchunk11.html index 510648fe..89d4ef12 100644 --- a/doc/APIchunk11.html +++ b/doc/APIchunk11.html @@ -362,6 +362,7 @@ A:link, A:visited, A:active { text-decoration: underline } xmlDictCreateSub
xmlDictReference
xmlHashCreateDict
+xmlPatterncompile
xmlStreamPush
xmlStreamPushAttr
dictionnary
_xmlParserCtxt
@@ -375,9 +376,6 @@ A:link, A:visited, A:active { text-decoration: underline } xmlDictQLookup
xmlDictReference
xmlDictSize
-xmlPatterncompile
-xmlStreamPush
-xmlStreamPushAttr
did
XML_SCHEMAS_TYPE_BLOCK_DEFAULT
xmlTextReaderGetRemainder
xmlTextReaderStandalone
diff --git a/doc/APIchunk13.html b/doc/APIchunk13.html index d29634a0..83e51b3f 100644 --- a/doc/APIchunk13.html +++ b/doc/APIchunk13.html @@ -268,6 +268,7 @@ A:link, A:visited, A:active { text-decoration: underline } htmlSAXParseFile
xmlNodeListGetRawString
xmlNodeListGetString
+xmlPatterncompile
xmlXPathStringFunction
formatted
xmlTextWriterWriteFormatAttribute
xmlTextWriterWriteFormatAttributeNS
diff --git a/doc/APIchunk20.html b/doc/APIchunk20.html index a4e20b03..82ab2820 100644 --- a/doc/APIchunk20.html +++ b/doc/APIchunk20.html @@ -492,8 +492,6 @@ A:link, A:visited, A:active { text-decoration: underline } xmlCtxtResetPush
xmlParserInputBufferPush
xmlStreamPop
-xmlStreamPush
-xmlStreamPushAttr
xmlXPathEvalExpr
pushed
xmlRegExecErrInfo
xmlXPathFunction
diff --git a/doc/APIchunk25.html b/doc/APIchunk25.html index 045ce695..2c7f5318 100644 --- a/doc/APIchunk25.html +++ b/doc/APIchunk25.html @@ -117,7 +117,6 @@ A:link, A:visited, A:active { text-decoration: underline } xmlXIncludeProcessTree
xmlXIncludeProcessTreeFlags
wether
_xmlNodeSet
-xmlPatternMatch
what
xmlCatalogGetDefaults
xmlCatalogSetDefaults
xmlParseNamespace
diff --git a/doc/APIchunk5.html b/doc/APIchunk5.html index 7a82a2c9..f91da3d8 100644 --- a/doc/APIchunk5.html +++ b/doc/APIchunk5.html @@ -229,6 +229,8 @@ A:link, A:visited, A:active { text-decoration: underline } xmlRegExecPushString
xmlRegExecPushString2
xmlRelaxNGValidatePushElement
+xmlStreamPush
+xmlStreamPushAttr
xmlValidatePushElement
Pushes
inputPush
namePush
diff --git a/doc/apibuild.py b/doc/apibuild.py index 518c93ca..56862389 100755 --- a/doc/apibuild.py +++ b/doc/apibuild.py @@ -1201,7 +1201,9 @@ class CParser: return token while token[0] == "name" and ( - token[1] == "const" or token[1] == "unsigned"): + token[1] == "const" or \ + token[1] == "unsigned" or \ + token[1] == "signed"): if self.type == "": self.type = token[1] else: diff --git a/doc/html/libxml-pattern.html b/doc/html/libxml-pattern.html index f06fcd41..e9b5a69e 100644 --- a/doc/html/libxml-pattern.html +++ b/doc/html/libxml-pattern.html @@ -44,17 +44,17 @@ The content of this structure is not made public by the API.
comp:the precompiled pattern
Returns:1 if true, 0 if false and -1 in case of error

Function: xmlPatternGetStreamCtxt

xmlStreamCtxtPtr	xmlPatternGetStreamCtxt	(xmlPatternPtr comp)

Get a streaming context for that pattern Use xmlFreeStreamCtxt to free the context.

comp:the precompiled pattern
Returns:a pointer to the context or NULL in case of failure

Function: xmlPatternMatch

int	xmlPatternMatch			(xmlPatternPtr comp, 
xmlNodePtr node)
-

Test wether the node matches the pattern

+

Test whether the node matches the pattern

comp:the precompiled pattern
node:a node
Returns:1 if it matches, 0 if it doesn't and -1 in case of failure

Function: xmlPatternMaxDepth

int	xmlPatternMaxDepth		(xmlPatternPtr comp)

Check the maximum depth reachable by a pattern

comp:the precompiled pattern
Returns:-2 if no limit (using //), otherwise the depth, and -1 in case of error

Function: xmlPatternStreamable

int	xmlPatternStreamable		(xmlPatternPtr comp)

Check if the pattern is streamable i.e. xmlPatternGetStreamCtxt() should work.

comp:the precompiled pattern
Returns:1 if streamable, 0 if not and -1 in case of error.

Function: xmlPatterncompile

xmlPatternPtr	xmlPatterncompile	(const xmlChar * pattern, 
xmlDict * dict,
int flags,
const xmlChar ** namespaces)

Compile a pattern.

-
pattern:the pattern to compile
dict:an optional dictionnary for interned strings
flags:compilation flags, undefined yet
namespaces:the prefix definitions, array of [URI, prefix] or NULL
Returns:the compiled for of the pattern or NULL in case of error

Function: xmlStreamPop

int	xmlStreamPop			(xmlStreamCtxtPtr stream)
+
pattern:the pattern to compile
dict:an optional dictionary for interned strings
flags:compilation flags, undefined yet
namespaces:the prefix definitions, array of [URI, prefix] or NULL
Returns:the compiled form of the pattern or NULL in case of error

Function: xmlStreamPop

int	xmlStreamPop			(xmlStreamCtxtPtr stream)

push one level from the stream.

stream:the stream context
Returns:-1 in case of error, 0 otherwise.

Function: xmlStreamPush

int	xmlStreamPush			(xmlStreamCtxtPtr stream, 
const xmlChar * name,
const xmlChar * ns)
-

push new data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionnary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset.

+

Push new data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset.

stream:the stream context
name:the current name
ns:the namespace name
Returns:-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.

Function: xmlStreamPushAttr

int	xmlStreamPushAttr		(xmlStreamCtxtPtr stream, 
const xmlChar * name,
const xmlChar * ns)
-

push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionnary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset.

+

Push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset.

stream:the stream context
name:the current name
ns:the namespace name
Returns:-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.

Daniel Veillard

diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 1cf70684..16f7437b 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -11618,7 +11618,7 @@ actually an xmlCharEncoding'/> defined(LIBXML_PATTERN_ENABLED) - Test wether the node matches the pattern + Test whether the node matches the pattern @@ -11638,9 +11638,9 @@ actually an xmlCharEncoding'/> defined(LIBXML_PATTERN_ENABLED) Compile a pattern. - + - + @@ -13388,7 +13388,7 @@ actually an xmlCharEncoding'/> defined(LIBXML_PATTERN_ENABLED) - push new data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionnary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset. + Push new data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset. @@ -13396,7 +13396,7 @@ actually an xmlCharEncoding'/> defined(LIBXML_PATTERN_ENABLED) - push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionnary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset. + Push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() indicated a dictionary, then strings for name and ns will be expected to come from the dictionary. Both @name and @ns being NULL means the / i.e. the root of the document. This can also act as a reset. diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml index e8ce4743..93b13288 100644 --- a/doc/libxml2-refs.xml +++ b/doc/libxml2-refs.xml @@ -16062,6 +16062,8 @@ + + @@ -20160,6 +20162,7 @@ + @@ -20175,9 +20178,6 @@ - - - @@ -21412,6 +21412,7 @@ + @@ -25194,8 +25195,6 @@ - - @@ -28257,7 +28256,6 @@ - diff --git a/pattern.c b/pattern.c index ca0580fc..fdd9f162 100644 --- a/pattern.c +++ b/pattern.c @@ -61,7 +61,7 @@ struct _xmlStreamStep { typedef struct _xmlStreamComp xmlStreamComp; typedef xmlStreamComp *xmlStreamCompPtr; struct _xmlStreamComp { - xmlDict *dict; /* the dictionnary if any */ + xmlDict *dict; /* the dictionary if any */ int nbStep; /* number of steps in the automata */ int maxStep; /* allocated number of steps */ xmlStreamStepPtr steps; /* the array of steps */ @@ -70,8 +70,8 @@ struct _xmlStreamComp { struct _xmlStreamCtxt { struct _xmlStreamCtxt *next;/* link to next sub pattern if | */ xmlStreamCompPtr comp; /* the compiled stream */ - int nbState; /* number of state in the automata */ - int maxState; /* allocated number of state */ + int nbState; /* number of states in the automata */ + int maxState; /* allocated number of states */ int level; /* how deep are we ? */ int *states; /* the array of step indexes */ int flags; /* validation options */ @@ -124,7 +124,7 @@ struct _xmlStepOp { struct _xmlPattern { void *data; /* the associated template */ - xmlDictPtr dict; /* the optional dictionnary */ + xmlDictPtr dict; /* the optional dictionary */ struct _xmlPattern *next; /* next pattern if | is used */ const xmlChar *pattern; /* the pattern */ @@ -141,7 +141,7 @@ struct _xmlPatParserContext { const xmlChar *cur; /* the current char being parsed */ const xmlChar *base; /* the full expression */ int error; /* error code */ - xmlDictPtr dict; /* the dictionnary if any */ + xmlDictPtr dict; /* the dictionary if any */ xmlPatternPtr comp; /* the result */ xmlNodePtr elem; /* the current node if any */ const xmlChar **namespaces; /* the namespaces definitions */ @@ -242,7 +242,7 @@ xmlFreePatternList(xmlPatternPtr comp) { /** * xmlNewPatParserContext: * @pattern: the pattern context - * @dict: the inherited dictionnary or NULL + * @dict: the inherited dictionary or NULL * @namespaces: the prefix definitions, array of [URI, prefix] terminated * with [NULL, NULL] or NULL if no namespace is used * @@ -300,7 +300,7 @@ xmlFreePatParserContext(xmlPatParserContextPtr ctxt) { * @value: the first value * @value2: the second value * - * Add an step to an XSLT Compiled Match + * Add a step to an XSLT Compiled Match * * Returns -1 in case of failure, 0 otherwise. */ @@ -451,7 +451,7 @@ xmlPatPushState(xmlStepStates *states, int step, xmlNodePtr node) { * @comp: the precompiled pattern * @node: a node * - * Test wether the node matches the pattern + * Test whether the node matches the pattern * * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure */ @@ -1139,7 +1139,7 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) { NEXT; xmlCompileAttributeTest(ctxt); SKIP_BLANKS; - if ((CUR != 0) || (CUR == '|')) { + if (CUR != 0) { xmlCompileStepPattern(ctxt); } } else { @@ -1150,7 +1150,7 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) { xmlCompileStepPattern(ctxt); SKIP_BLANKS; while (CUR == '/') { - if ((CUR == '/') && (NXT(1) == '/')) { + if (NXT(1) == '/') { PUSH(XML_OP_ANCESTOR, NULL, NULL); NEXT; NEXT; @@ -1160,7 +1160,7 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) { PUSH(XML_OP_PARENT, NULL, NULL); NEXT; SKIP_BLANKS; - if ((CUR != 0) || (CUR == '|')) { + if (CUR != 0) { xmlCompileStepPattern(ctxt); } } @@ -1538,8 +1538,8 @@ xmlStreamCtxtAddState(xmlStreamCtxtPtr comp, int idx, int level) { * @ns: the namespace name * @nodeType: the type of the node * - * push new data onto the stream. NOTE: if the call xmlPatterncompile() - * indicated a dictionnary, then strings for name and ns will be expected + * Push new data onto the stream. NOTE: if the call xmlPatterncompile() + * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. @@ -1571,8 +1571,6 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream, err++; if (comp->nbStep == 0) ret = 1; - stream = stream->next; - continue; /* while */ } stream = stream->next; continue; /* while */ @@ -1595,6 +1593,17 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream, stream->level++; goto stream_next; } + tmp = stream->level; + for (i = 0; i < comp->nbStep; i++) { + if (comp->steps[i].flags & XML_STREAM_STEP_DESC) { + tmp = -2; + break; + } + } + if (comp->nbStep < tmp) { + stream->level++; + goto stream_next; + } /* * Check evolution of existing states @@ -1773,8 +1782,8 @@ stream_next: * @name: the current name * @ns: the namespace name * - * push new data onto the stream. NOTE: if the call xmlPatterncompile() - * indicated a dictionnary, then strings for name and ns will be expected + * Push new data onto the stream. NOTE: if the call xmlPatterncompile() + * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. @@ -1794,8 +1803,8 @@ xmlStreamPush(xmlStreamCtxtPtr stream, * @name: the current name * @ns: the namespace name * -* push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() -* indicated a dictionnary, then strings for name and ns will be expected +* Push new attribute data onto the stream. NOTE: if the call xmlPatterncompile() +* indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document. * This can also act as a reset. @@ -1854,13 +1863,13 @@ xmlStreamPop(xmlStreamCtxtPtr stream) { /** * xmlPatterncompile: * @pattern: the pattern to compile - * @dict: an optional dictionnary for interned strings + * @dict: an optional dictionary for interned strings * @flags: compilation flags, undefined yet * @namespaces: the prefix definitions, array of [URI, prefix] or NULL * * Compile a pattern. * - * Returns the compiled for of the pattern or NULL in case of error + * Returns the compiled form of the pattern or NULL in case of error */ xmlPatternPtr xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, @@ -1906,6 +1915,7 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, if (ctxt->error != 0) goto error; xmlFreePatParserContext(ctxt); + ctxt = NULL; if (streamable) { @@ -1923,10 +1933,8 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, xmlStreamCompile(cur); if (xmlReversePattern(cur) < 0) goto error; - if (tmp != NULL) { + if (tmp != NULL) xmlFree(tmp); - tmp = NULL; - } start = or; } if (streamable == 0) { @@ -1953,7 +1961,7 @@ error: * @comp: the precompiled pattern * @node: a node * - * Test wether the node matches the pattern + * Test whether the node matches the pattern * * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure */ diff --git a/xpath.c b/xpath.c index 862ff535..8ee08052 100644 --- a/xpath.c +++ b/xpath.c @@ -11080,6 +11080,12 @@ next_node: } if ((cur->children == NULL) || (depth >= max_depth)) { ret = xmlStreamPop(patstream); + while (cur->next != NULL) { + cur = cur->next; + if ((cur->type != XML_ENTITY_DECL) && + (cur->type != XML_DTD_NODE)) + goto next_node; + } } } @@ -11110,11 +11116,12 @@ scan_children: } do { - ret = xmlStreamPop(patstream); cur = cur->parent; depth--; if ((cur == NULL) || (cur == limit)) goto done; + if (cur->type == XML_ELEMENT_NODE) + ret = xmlStreamPop(patstream); if (cur->next != NULL) { cur = cur->next; break;