Jumbo patch, resync of W3C/Gnome CVS trees:
- uri.c tree.c SAX.c parser.c entities.c debugXML.c: finished
  the cleanup of the computation of URI references when seeking
  external entities. The URI reference string and the resulting
  URI are both stored now.
- parser.c HTMLparser.c valid.c nanoftp.c nanohttp.c xpath.c:
  large s(n)printf checks and cleanup from Denis Barbier
  <barbier@imacs.polytechnique.fr>
- xmlversion.h.in tree.h: couple of SGML declarations for a
  possible docbook module.
- result/VC/ : a couple of test output changed due to the change
  of the entities URI
Daniel
diff --git a/uri.c b/uri.c
index 30a9047..efba43f 100644
--- a/uri.c
+++ b/uri.c
@@ -1637,8 +1637,8 @@
 	/*
 	 * Ensure the path includes a '/'
 	 */
-	if (res->path[0] != '/' && ref->path[0] != 0 &&
-	    ref->path[index] != '/') {
+	if ((out >0) && (res->path[out -1] != '/') &&
+	    (ref->path[0] != 0) && (ref->path[index] != '/')) {
 	    res->path[out++] = '/';
 	}
 	while (ref->path[index] != 0) {
@@ -1664,7 +1664,7 @@
 done:
     if (ref != NULL)
 	xmlFreeURI(ref);
-    if (base != NULL)
+    if (bas != NULL)
 	xmlFreeURI(bas);
     if (res != NULL)
 	xmlFreeURI(res);