Enhanced xmlXPathRunStreamEval, fixed handling of depth/level for cases

* 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.
diff --git a/doc/APIchunk11.html b/doc/APIchunk11.html
index 510648f..89d4ef1 100644
--- a/doc/APIchunk11.html
+++ b/doc/APIchunk11.html
@@ -362,6 +362,7 @@
 <a href="html/libxml-dict.html#xmlDictCreateSub">xmlDictCreateSub</a><br />
 <a href="html/libxml-dict.html#xmlDictReference">xmlDictReference</a><br />
 <a href="html/libxml-hash.html#xmlHashCreateDict">xmlHashCreateDict</a><br />
+<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 </dd><dt>dictionnary</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
@@ -375,9 +376,6 @@
 <a href="html/libxml-dict.html#xmlDictQLookup">xmlDictQLookup</a><br />
 <a href="html/libxml-dict.html#xmlDictReference">xmlDictReference</a><br />
 <a href="html/libxml-dict.html#xmlDictSize">xmlDictSize</a><br />
-<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
-<a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
-<a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 </dd><dt>did</dt><dd><a href="html/libxml-schemasInternals.html#XML_SCHEMAS_TYPE_BLOCK_DEFAULT">XML_SCHEMAS_TYPE_BLOCK_DEFAULT</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderGetRemainder">xmlTextReaderGetRemainder</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderStandalone">xmlTextReaderStandalone</a><br />
diff --git a/doc/APIchunk13.html b/doc/APIchunk13.html
index d29634a..83e51b3 100644
--- a/doc/APIchunk13.html
+++ b/doc/APIchunk13.html
@@ -268,6 +268,7 @@
 <a href="html/libxml-HTMLparser.html#htmlSAXParseFile">htmlSAXParseFile</a><br />
 <a href="html/libxml-tree.html#xmlNodeListGetRawString">xmlNodeListGetRawString</a><br />
 <a href="html/libxml-tree.html#xmlNodeListGetString">xmlNodeListGetString</a><br />
+<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathStringFunction">xmlXPathStringFunction</a><br />
 </dd><dt>formatted</dt><dd><a href="html/libxml-xmlwriter.html#xmlTextWriterWriteFormatAttribute">xmlTextWriterWriteFormatAttribute</a><br />
 <a href="html/libxml-xmlwriter.html#xmlTextWriterWriteFormatAttributeNS">xmlTextWriterWriteFormatAttributeNS</a><br />
diff --git a/doc/APIchunk20.html b/doc/APIchunk20.html
index a4e20b0..82ab282 100644
--- a/doc/APIchunk20.html
+++ b/doc/APIchunk20.html
@@ -492,8 +492,6 @@
 <a href="html/libxml-parser.html#xmlCtxtResetPush">xmlCtxtResetPush</a><br />
 <a href="html/libxml-xmlIO.html#xmlParserInputBufferPush">xmlParserInputBufferPush</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPop">xmlStreamPop</a><br />
-<a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
-<a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathEvalExpr">xmlXPathEvalExpr</a><br />
 </dd><dt>pushed</dt><dd><a href="html/libxml-xmlregexp.html#xmlRegExecErrInfo">xmlRegExecErrInfo</a><br />
 <a href="html/libxml-xpath.html#xmlXPathFunction">xmlXPathFunction</a><br />
diff --git a/doc/APIchunk25.html b/doc/APIchunk25.html
index 045ce69..2c7f531 100644
--- a/doc/APIchunk25.html
+++ b/doc/APIchunk25.html
@@ -117,7 +117,6 @@
 <a href="html/libxml-xinclude.html#xmlXIncludeProcessTree">xmlXIncludeProcessTree</a><br />
 <a href="html/libxml-xinclude.html#xmlXIncludeProcessTreeFlags">xmlXIncludeProcessTreeFlags</a><br />
 </dd><dt>wether</dt><dd><a href="html/libxml-xpath.html#_xmlNodeSet">_xmlNodeSet</a><br />
-<a href="html/libxml-pattern.html#xmlPatternMatch">xmlPatternMatch</a><br />
 </dd><dt>what</dt><dd><a href="html/libxml-catalog.html#xmlCatalogGetDefaults">xmlCatalogGetDefaults</a><br />
 <a href="html/libxml-catalog.html#xmlCatalogSetDefaults">xmlCatalogSetDefaults</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseNamespace">xmlParseNamespace</a><br />
diff --git a/doc/APIchunk5.html b/doc/APIchunk5.html
index 7a82a2c..f91da3d 100644
--- a/doc/APIchunk5.html
+++ b/doc/APIchunk5.html
@@ -229,6 +229,8 @@
 <a href="html/libxml-xmlregexp.html#xmlRegExecPushString">xmlRegExecPushString</a><br />
 <a href="html/libxml-xmlregexp.html#xmlRegExecPushString2">xmlRegExecPushString2</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidatePushElement">xmlRelaxNGValidatePushElement</a><br />
+<a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
+<a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
 <a href="html/libxml-valid.html#xmlValidatePushElement">xmlValidatePushElement</a><br />
 </dd><dt>Pushes</dt><dd><a href="html/libxml-parserInternals.html#inputPush">inputPush</a><br />
 <a href="html/libxml-parserInternals.html#namePush">namePush</a><br />
diff --git a/doc/apibuild.py b/doc/apibuild.py
index 518c93c..5686238 100755
--- a/doc/apibuild.py
+++ b/doc/apibuild.py
@@ -1201,7 +1201,9 @@
 	    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 f06fcd4..e9b5a69 100644
--- a/doc/html/libxml-pattern.html
+++ b/doc/html/libxml-pattern.html
@@ -44,17 +44,17 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if true, 0 if false and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlPatternGetStreamCtxt" id="xmlPatternGetStreamCtxt"></a>Function: xmlPatternGetStreamCtxt</h3><pre class="programlisting"><a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a>	xmlPatternGetStreamCtxt	(<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)<br />
 </pre><p>Get a streaming context for that pattern Use <a href="libxml-pattern.html#xmlFreeStreamCtxt">xmlFreeStreamCtxt</a> to free the context.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the context or NULL in case of failure</td></tr></tbody></table></div><h3><a name="xmlPatternMatch" id="xmlPatternMatch"></a>Function: xmlPatternMatch</h3><pre class="programlisting">int	xmlPatternMatch			(<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br />
-</pre><p>Test wether the node matches the pattern</p>
+</pre><p>Test whether the node matches the pattern</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>node</tt></i>:</span></td><td>a node</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if it matches, 0 if it doesn't and -1 in case of failure</td></tr></tbody></table></div><h3><a name="xmlPatternMaxDepth" id="xmlPatternMaxDepth"></a>Function: xmlPatternMaxDepth</h3><pre class="programlisting">int	xmlPatternMaxDepth		(<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)<br />
 </pre><p>Check the maximum depth reachable by a pattern</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>-2 if no limit (using //), otherwise the depth, and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlPatternStreamable" id="xmlPatternStreamable"></a>Function: xmlPatternStreamable</h3><pre class="programlisting">int	xmlPatternStreamable		(<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)<br />
 </pre><p>Check if the pattern is streamable i.e. xmlPatternGetStreamCtxt() should work.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if streamable, 0 if not and -1 in case of error.</td></tr></tbody></table></div><h3><a name="xmlPatterncompile" id="xmlPatterncompile"></a>Function: xmlPatterncompile</h3><pre class="programlisting"><a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a>	xmlPatterncompile	(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br />					 <a href="libxml-dict.html#xmlDict">xmlDict</a> * dict, <br />					 int flags, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)<br />
 </pre><p>Compile a pattern.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>the pattern to compile</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>an optional dictionnary for interned strings</td></tr><tr><td><span class="term"><i><tt>flags</tt></i>:</span></td><td>compilation flags, undefined yet</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the compiled for of the pattern or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlStreamPop" id="xmlStreamPop"></a>Function: xmlStreamPop</h3><pre class="programlisting">int	xmlStreamPop			(<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>the pattern to compile</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>an optional dictionary for interned strings</td></tr><tr><td><span class="term"><i><tt>flags</tt></i>:</span></td><td>compilation flags, undefined yet</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the compiled form of the pattern or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlStreamPop" id="xmlStreamPop"></a>Function: xmlStreamPop</h3><pre class="programlisting">int	xmlStreamPop			(<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream)<br />
 </pre><p>push one level from the stream.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>stream</tt></i>:</span></td><td>the stream context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>-1 in case of error, 0 otherwise.</td></tr></tbody></table></div><h3><a name="xmlStreamPush" id="xmlStreamPush"></a>Function: xmlStreamPush</h3><pre class="programlisting">int	xmlStreamPush			(<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * ns)<br />
-</pre><p>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.</p>
+</pre><p>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.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>stream</tt></i>:</span></td><td>the stream context</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the current name</td></tr><tr><td><span class="term"><i><tt>ns</tt></i>:</span></td><td>the namespace name</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.</td></tr></tbody></table></div><h3><a name="xmlStreamPushAttr" id="xmlStreamPushAttr"></a>Function: xmlStreamPushAttr</h3><pre class="programlisting">int	xmlStreamPushAttr		(<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * ns)<br />
-</pre><p>push new <a href="libxml-SAX.html#attribute">attribute</a> 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.</p>
+</pre><p>Push new <a href="libxml-SAX.html#attribute">attribute</a> 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.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>stream</tt></i>:</span></td><td>the stream context</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the current name</td></tr><tr><td><span class="term"><i><tt>ns</tt></i>:</span></td><td>the namespace name</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 1cf7068..16f7437 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -11618,7 +11618,7 @@
     </function>
     <function name='xmlPatternMatch' file='pattern' module='pattern'>
       <cond>defined(LIBXML_PATTERN_ENABLED)</cond>
-      <info>Test wether the node matches the pattern</info>
+      <info>Test whether the node matches the pattern</info>
       <return type='int' info='1 if it matches, 0 if it doesn&apos;t and -1 in case of failure'/>
       <arg name='comp' type='xmlPatternPtr' info='the precompiled pattern'/>
       <arg name='node' type='xmlNodePtr' info='a node'/>
@@ -11638,9 +11638,9 @@
     <function name='xmlPatterncompile' file='pattern' module='pattern'>
       <cond>defined(LIBXML_PATTERN_ENABLED)</cond>
       <info>Compile a pattern.</info>
-      <return type='xmlPatternPtr' info='the compiled for of the pattern or NULL in case of error'/>
+      <return type='xmlPatternPtr' info='the compiled form of the pattern or NULL in case of error'/>
       <arg name='pattern' type='const xmlChar *' info='the pattern to compile'/>
-      <arg name='dict' type='xmlDict *' info='an optional dictionnary for interned strings'/>
+      <arg name='dict' type='xmlDict *' info='an optional dictionary for interned strings'/>
       <arg name='flags' type='int' info='compilation flags, undefined yet'/>
       <arg name='namespaces' type='const xmlChar **' info='the prefix definitions, array of [URI, prefix] or NULL'/>
     </function>
@@ -13388,7 +13388,7 @@
     </function>
     <function name='xmlStreamPush' file='pattern' module='pattern'>
       <cond>defined(LIBXML_PATTERN_ENABLED)</cond>
-      <info>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.</info>
+      <info>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.</info>
       <return type='int' info='-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.'/>
       <arg name='stream' type='xmlStreamCtxtPtr' info='the stream context'/>
       <arg name='name' type='const xmlChar *' info='the current name'/>
@@ -13396,7 +13396,7 @@
     </function>
     <function name='xmlStreamPushAttr' file='pattern' module='pattern'>
       <cond>defined(LIBXML_PATTERN_ENABLED)</cond>
-      <info>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.</info>
+      <info>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.</info>
       <return type='int' info='-1 in case of error, 1 if the current state in the stream is a match and 0 otherwise.'/>
       <arg name='stream' type='xmlStreamCtxtPtr' info='the stream context'/>
       <arg name='name' type='const xmlChar *' info='the current name'/>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index e8ce474..93b1328 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -16062,6 +16062,8 @@
           <ref name='xmlRegExecPushString'/>
           <ref name='xmlRegExecPushString2'/>
           <ref name='xmlRelaxNGValidatePushElement'/>
+          <ref name='xmlStreamPush'/>
+          <ref name='xmlStreamPushAttr'/>
           <ref name='xmlValidatePushElement'/>
         </word>
         <word name='Pushes'>
@@ -20160,6 +20162,7 @@
           <ref name='xmlDictCreateSub'/>
           <ref name='xmlDictReference'/>
           <ref name='xmlHashCreateDict'/>
+          <ref name='xmlPatterncompile'/>
           <ref name='xmlStreamPush'/>
           <ref name='xmlStreamPushAttr'/>
         </word>
@@ -20175,9 +20178,6 @@
           <ref name='xmlDictQLookup'/>
           <ref name='xmlDictReference'/>
           <ref name='xmlDictSize'/>
-          <ref name='xmlPatterncompile'/>
-          <ref name='xmlStreamPush'/>
-          <ref name='xmlStreamPushAttr'/>
         </word>
         <word name='did'>
           <ref name='XML_SCHEMAS_TYPE_BLOCK_DEFAULT'/>
@@ -21412,6 +21412,7 @@
           <ref name='htmlSAXParseFile'/>
           <ref name='xmlNodeListGetRawString'/>
           <ref name='xmlNodeListGetString'/>
+          <ref name='xmlPatterncompile'/>
           <ref name='xmlXPathStringFunction'/>
         </word>
         <word name='formatted'>
@@ -25194,8 +25195,6 @@
           <ref name='xmlCtxtResetPush'/>
           <ref name='xmlParserInputBufferPush'/>
           <ref name='xmlStreamPop'/>
-          <ref name='xmlStreamPush'/>
-          <ref name='xmlStreamPushAttr'/>
           <ref name='xmlXPathEvalExpr'/>
         </word>
         <word name='pushed'>
@@ -28257,7 +28256,6 @@
         </word>
         <word name='wether'>
           <ref name='_xmlNodeSet'/>
-          <ref name='xmlPatternMatch'/>
         </word>
         <word name='what'>
           <ref name='xmlCatalogGetDefaults'/>