fix bug raised by zamez on IRC regenerated, seems to pop-up leaks in new

* parserInternals.c: fix bug raised by zamez on IRC
* testapi.c: regenerated, seems to pop-up leaks in new tree functions
* tree.c: added comments missing.
* doc/*: regenerated
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6012d15..53cc190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jul  3 18:17:58 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+	* parserInternals.c: fix bug raised by zamez on IRC
+	* testapi.c: regenerated, seems to pop-up leaks in new tree functions
+	* tree.c: added comments missing.
+	* doc/*: regenerated
+
 Sun Jul  3 18:06:55 CEST 2005 Daniel Veillard <daniel@veillard.com>
 
 	* testapi.c runsuite.c runtest.c: fixing #307823 and a couple of
diff --git a/doc/APIchunk18.html b/doc/APIchunk18.html
index 952a0d8..90372af 100644
--- a/doc/APIchunk18.html
+++ b/doc/APIchunk18.html
@@ -265,6 +265,8 @@
 <a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
 <a href="html/libxml-xmlIO.html#xmlOutputMatchCallback">xmlOutputMatchCallback</a><br />
 <a href="html/libxml-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a><br />
+</dd><dt>moment</dt><dd><a href="html/libxml-tree.html#xmlDOMWrapReconcileNamespaces">xmlDOMWrapReconcileNamespaces</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 </dd><dt>month</dt><dd><a href="html/libxml-nanoftp.html#ftpListCallback">ftpListCallback</a><br />
 </dd><dt>more</dt><dd><a href="html/libxml-parserInternals.html#XML_MAX_NAMELEN">XML_MAX_NAMELEN</a><br />
 <a href="html/libxml-parser.html#xmlLoadExternalEntity">xmlLoadExternalEntity</a><br />
diff --git a/doc/APIchunk2.html b/doc/APIchunk2.html
index e05bdbe..427ca16 100644
--- a/doc/APIchunk2.html
+++ b/doc/APIchunk2.html
@@ -73,6 +73,8 @@
 <a href="html/libxml-parser.html#ignorableWhitespaceSAXFunc">ignorableWhitespaceSAXFunc</a><br />
 <a href="html/libxml-SAX.html#resolveEntity">resolveEntity</a><br />
 <a href="html/libxml-parser.html#resolveEntitySAXFunc">resolveEntitySAXFunc</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapReconcileNamespaces">xmlDOMWrapReconcileNamespaces</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 <a href="html/libxml-tree.html#xmlDocDumpFormatMemoryEnc">xmlDocDumpFormatMemoryEnc</a><br />
 <a href="html/libxml-tree.html#xmlDocDumpMemoryEnc">xmlDocDumpMemoryEnc</a><br />
 <a href="html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault</a><br />
diff --git a/doc/APIchunk20.html b/doc/APIchunk20.html
index 8e57e46..ea27f23 100644
--- a/doc/APIchunk20.html
+++ b/doc/APIchunk20.html
@@ -243,6 +243,7 @@
 <a href="html/libxml-uri.html#xmlURIUnescapeString">xmlURIUnescapeString</a><br />
 </dd><dt>options</dt><dd><a href="html/libxml-HTMLparser.html#htmlCtxtUseOptions">htmlCtxtUseOptions</a><br />
 <a href="html/libxml-parser.html#xmlCtxtUseOptions">xmlCtxtUseOptions</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveToFd">xmlSaveToFd</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveToFilename">xmlSaveToFilename</a><br />
diff --git a/doc/APIchunk25.html b/doc/APIchunk25.html
index ca21a86..e902b29 100644
--- a/doc/APIchunk25.html
+++ b/doc/APIchunk25.html
@@ -138,6 +138,8 @@
 <a href="html/libxml-parser.html#_xmlSAXHandlerV1">_xmlSAXHandlerV1</a><br />
 <a href="html/libxml-schemasInternals.html#_xmlSchema">_xmlSchema</a><br />
 <a href="html/libxml-xpath.html#_xmlXPathContext">_xmlXPathContext</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapReconcileNamespaces">xmlDOMWrapReconcileNamespaces</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidateFile">xmlSchemaValidateFile</a><br />
 <a href="html/libxml-debugXML.html#xmlShellBase">xmlShellBase</a><br />
 <a href="html/libxml-debugXML.html#xmlShellCat">xmlShellCat</a><br />
diff --git a/doc/APIchunk26.html b/doc/APIchunk26.html
index eb5efae..48ab979 100644
--- a/doc/APIchunk26.html
+++ b/doc/APIchunk26.html
@@ -251,6 +251,8 @@
 </dd><dt>would</dt><dd><a href="html/libxml-xmlerror.html#_xmlError">_xmlError</a><br />
 <a href="html/libxml-HTMLparser.html#htmlAutoCloseTag">htmlAutoCloseTag</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderGetRemainder">xmlTextReaderGetRemainder</a><br />
+</dd><dt>wrapper</dt><dd><a href="html/libxml-tree.html#xmlDOMWrapReconcileNamespaces">xmlDOMWrapReconcileNamespaces</a><br />
+<a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 </dd><dt>wraps</dt><dd><a href="html/libxml-xmlreader.html#xmlTextReaderByteConsumed">xmlTextReaderByteConsumed</a><br />
 </dd><dt>write</dt><dd><a href="html/libxml-xmlIO.html#xmlFileRead">xmlFileRead</a><br />
 <a href="html/libxml-encoding.html#xmlFindCharEncodingHandler">xmlFindCharEncodingHandler</a><br />
diff --git a/doc/html/libxml-tree.html b/doc/html/libxml-tree.html
index 7c13d80..b7f9055 100644
--- a/doc/html/libxml-tree.html
+++ b/doc/html/libxml-tree.html
@@ -681,9 +681,9 @@
 </pre><p>Allocates and initializes a new DOM-wrapper context.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> or NULL in case of an internal errror.</td></tr></tbody></table></div><h3><a name="xmlDOMWrapReconcileNamespaces" id="xmlDOMWrapReconcileNamespaces"></a>Function: xmlDOMWrapReconcileNamespaces</h3><pre class="programlisting">int	xmlDOMWrapReconcileNamespaces	(<a href="libxml-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> elem, <br />					 int options)<br />
 </pre><p>Ensures that ns-references point to ns-decls hold on element-nodes. Ensures that the tree is namespace wellformed by creating additional ns-decls where needed. Note that, since prefixes of already existent ns-decls can be shadowed by this process, it could break QNames in <a href="libxml-SAX.html#attribute">attribute</a> values or element content. WARNING: This function is in a experimental state.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td></td></tr><tr><td><span class="term"><i><tt>elem</tt></i>:</span></td><td>the element-node</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>option flags</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 if succeeded, -1 otherwise and on API/internal errors.</td></tr></tbody></table></div><h3><a name="xmlDOMWrapRemoveNode" id="xmlDOMWrapRemoveNode"></a>Function: xmlDOMWrapRemoveNode</h3><pre class="programlisting">int	xmlDOMWrapRemoveNode		(<a href="libxml-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br />					 int options)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>DOM wrapper context, unused at the moment</td></tr><tr><td><span class="term"><i><tt>elem</tt></i>:</span></td><td>the element-node</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>option flags</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 if succeeded, -1 otherwise and on API/internal errors.</td></tr></tbody></table></div><h3><a name="xmlDOMWrapRemoveNode" id="xmlDOMWrapRemoveNode"></a>Function: xmlDOMWrapRemoveNode</h3><pre class="programlisting">int	xmlDOMWrapRemoveNode		(<a href="libxml-tree.html#xmlDOMWrapCtxtPtr">xmlDOMWrapCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br />					 int options)<br />
 </pre><p>Unlinks the given node from its owner. This will substitute ns-references to node-&gt;nsDef for ns-references to doc-&gt;oldNs, thus ensuring the removed branch to be autark wrt ns-references. WARNING: This function is in a experimental state.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td></td></tr><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>the doc</td></tr><tr><td><span class="term"><i><tt>node</tt></i>:</span></td><td>the node to be removed.</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td></td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success, 1 if the node is not supported, -1 on API and internal errors.</td></tr></tbody></table></div><h3><a name="xmlDocCopyNode" id="xmlDocCopyNode"></a>Function: xmlDocCopyNode</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlDocCopyNode		(const <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 int extended)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a DOM wrapper context</td></tr><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>the doc</td></tr><tr><td><span class="term"><i><tt>node</tt></i>:</span></td><td>the node to be removed.</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>set of options, unused at the moment</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success, 1 if the node is not supported, -1 on API and internal errors.</td></tr></tbody></table></div><h3><a name="xmlDocCopyNode" id="xmlDocCopyNode"></a>Function: xmlDocCopyNode</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlDocCopyNode		(const <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 int extended)<br />
 </pre><p>Do a copy of the node to a given document.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>node</tt></i>:</span></td><td>the node</td></tr><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>the document</td></tr><tr><td><span class="term"><i><tt>extended</tt></i>:</span></td><td>if 1 do a recursive copy (properties, namespaces and children when applicable) if 2 copy properties and namespaces (when applicable)</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a new #xmlNodePtr, or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlDocCopyNodeList" id="xmlDocCopyNodeList"></a>Function: xmlDocCopyNodeList</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlDocCopyNodeList	(<a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 const <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node)<br />
 </pre><p>Do a recursive copy of the node list.</p>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index ccd3050..2314b94 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -8742,17 +8742,17 @@
     <function name='xmlDOMWrapReconcileNamespaces' file='tree' module='tree'>
       <info>Ensures that ns-references point to ns-decls hold on element-nodes. Ensures that the tree is namespace wellformed by creating additional ns-decls where needed. Note that, since prefixes of already existent ns-decls can be shadowed by this process, it could break QNames in attribute values or element content. WARNING: This function is in a experimental state.</info>
       <return type='int' info='0 if succeeded, -1 otherwise and on API/internal errors.'/>
-      <arg name='ctxt' type='xmlDOMWrapCtxtPtr' info=''/>
+      <arg name='ctxt' type='xmlDOMWrapCtxtPtr' info='DOM wrapper context, unused at the moment'/>
       <arg name='elem' type='xmlNodePtr' info='the element-node'/>
       <arg name='options' type='int' info='option flags'/>
     </function>
     <function name='xmlDOMWrapRemoveNode' file='tree' module='tree'>
       <info>Unlinks the given node from its owner. This will substitute ns-references to node-&gt;nsDef for ns-references to doc-&gt;oldNs, thus ensuring the removed branch to be autark wrt ns-references. WARNING: This function is in a experimental state.</info>
       <return type='int' info='0 on success, 1 if the node is not supported, -1 on API and internal errors.'/>
-      <arg name='ctxt' type='xmlDOMWrapCtxtPtr' info=''/>
+      <arg name='ctxt' type='xmlDOMWrapCtxtPtr' info='a DOM wrapper context'/>
       <arg name='doc' type='xmlDocPtr' info='the doc'/>
       <arg name='node' type='xmlNodePtr' info='the node to be removed.'/>
-      <arg name='options' type='int' info=''/>
+      <arg name='options' type='int' info='set of options, unused at the moment'/>
     </function>
     <function name='xmlDebugCheckDocument' file='debugXML' module='debugXML'>
       <cond>defined(LIBXML_DEBUG_ENABLED)</cond>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index 4b4d4f2..2bb941a 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -14327,6 +14327,8 @@
           <ref name='ignorableWhitespaceSAXFunc'/>
           <ref name='resolveEntity'/>
           <ref name='resolveEntitySAXFunc'/>
+          <ref name='xmlDOMWrapReconcileNamespaces'/>
+          <ref name='xmlDOMWrapRemoveNode'/>
           <ref name='xmlDocDumpFormatMemoryEnc'/>
           <ref name='xmlDocDumpMemoryEnc'/>
           <ref name='xmlKeepBlanksDefault'/>
@@ -23829,6 +23831,10 @@
           <ref name='xmlOutputMatchCallback'/>
           <ref name='xmlStructuredErrorFunc'/>
         </word>
+        <word name='moment'>
+          <ref name='xmlDOMWrapReconcileNamespaces'/>
+          <ref name='xmlDOMWrapRemoveNode'/>
+        </word>
         <word name='month'>
           <ref name='ftpListCallback'/>
         </word>
@@ -24597,6 +24603,7 @@
         <word name='options'>
           <ref name='htmlCtxtUseOptions'/>
           <ref name='xmlCtxtUseOptions'/>
+          <ref name='xmlDOMWrapRemoveNode'/>
           <ref name='xmlModuleOpen'/>
           <ref name='xmlSaveToFd'/>
           <ref name='xmlSaveToFilename'/>
@@ -28212,6 +28219,8 @@
           <ref name='_xmlSAXHandlerV1'/>
           <ref name='_xmlSchema'/>
           <ref name='_xmlXPathContext'/>
+          <ref name='xmlDOMWrapReconcileNamespaces'/>
+          <ref name='xmlDOMWrapRemoveNode'/>
           <ref name='xmlSchemaValidateFile'/>
           <ref name='xmlShellBase'/>
           <ref name='xmlShellCat'/>
@@ -28695,6 +28704,10 @@
           <ref name='htmlAutoCloseTag'/>
           <ref name='xmlTextReaderGetRemainder'/>
         </word>
+        <word name='wrapper'>
+          <ref name='xmlDOMWrapReconcileNamespaces'/>
+          <ref name='xmlDOMWrapRemoveNode'/>
+        </word>
         <word name='wraps'>
           <ref name='xmlTextReaderByteConsumed'/>
         </word>
diff --git a/parserInternals.c b/parserInternals.c
index 0e01deb..b5e302e 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1267,9 +1267,11 @@
 int
 xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) 
 {
+    int ret = 0;
+
     if (handler != NULL) {
         if (ctxt->input != NULL) {
-	    xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
+	    ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
 	} else {
 	    xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
 	                   NULL);
@@ -1281,7 +1283,7 @@
 	ctxt->charset = XML_CHAR_ENCODING_UTF8;
     } else 
 	return(-1);
-    return(0);
+    return(ret);
 }
 
 /************************************************************************
diff --git a/testapi.c b/testapi.c
index 90a20f0..adc80bb 100644
--- a/testapi.c
+++ b/testapi.c
@@ -18977,7 +18977,7 @@
 
     int mem_base;
     int ret_val;
-    xmlDOMWrapCtxtPtr ctxt; /*  */
+    xmlDOMWrapCtxtPtr ctxt; /* DOM wrapper context, unused at the moment */
     int n_ctxt;
     xmlNodePtr elem; /* the element-node */
     int n_elem;
@@ -19023,13 +19023,13 @@
 
     int mem_base;
     int ret_val;
-    xmlDOMWrapCtxtPtr ctxt; /*  */
+    xmlDOMWrapCtxtPtr ctxt; /* a DOM wrapper context */
     int n_ctxt;
     xmlDocPtr doc; /* the doc */
     int n_doc;
     xmlNodePtr node; /* the node to be removed. */
     int n_node;
-    int options; /*  */
+    int options; /* set of options, unused at the moment */
     int n_options;
 
     for (n_ctxt = 0;n_ctxt < gen_nb_xmlDOMWrapCtxtPtr;n_ctxt++) {
diff --git a/tree.c b/tree.c
index 2ea8e7b..a5869a1 100644
--- a/tree.c
+++ b/tree.c
@@ -7499,9 +7499,10 @@
 
 /*
 * xmlDOMWrapRemoveNode:
-*
+* @ctxt: a DOM wrapper context
 * @doc: the doc
 * @node: the node to be removed.
+* @options: set of options, unused at the moment
 *
 * Unlinks the given node from its owner.
 * This will substitute ns-references to node->nsDef for
@@ -7953,6 +7954,7 @@
 
 /*
 * xmlDOMWrapReconcileNamespaces:
+* @ctxt: DOM wrapper context, unused at the moment
 * @elem: the element-node
 * @options: option flags
 *