preparing release 1.5.8 changed some preprocessor block applied patch from

* configure.in doc/*: preparing release 1.5.8
* nanohttp.c: changed some preprocessor block
* xmlschemastypes.c: applied patch from Charles Bozeman adding
  hexBinary schema datatype and adding support for totalDigits and
  fractionDigits facets.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6729580..bef38b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Jul  6 23:09:13 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+	* configure.in doc/*: preparing release 1.5.8
+	* nanohttp.c: changed some preprocessor block
+	* xmlschemastypes.c: applied patch from Charles Bozeman adding
+	  hexBinary schema datatype and adding support for totalDigits and
+	  fractionDigits facets.
+
 Sun Jul  6 19:56:18 CEST 2003 Daniel Veillard <daniel@veillard.com>
 
 	* debugXML.c xpath.c: fixed 2 bugs pointed in #116448
diff --git a/config.h.in b/config.h.in
index 3464eee..51edc7c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -11,10 +11,10 @@
 #undef HAVE_LIBPTHREAD
 #undef HAVE_PTHREAD_H
 
-/* Define if IPv6 support is there. */
+/* Define if IPV6 support is there */
 #undef SUPPORT_IP6
 
-/* Define if you have the getaddrinfo function. */
+/* Define if getaddrinfo is there */
 #undef HAVE_GETADDRINFO
 
 /* Define to 1 if you have the <ansidecl.h> header file. */
diff --git a/configure.in b/configure.in
index ae9b177..5ced7d7 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@
 
 LIBXML_MAJOR_VERSION=2
 LIBXML_MINOR_VERSION=5
-LIBXML_MICRO_VERSION=7
+LIBXML_MICRO_VERSION=8
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
 
diff --git a/doc/xml.html b/doc/xml.html
index 5c3cc22..de39f96 100644
--- a/doc/xml.html
+++ b/doc/xml.html
@@ -18,12 +18,12 @@
 <p></p>
 
 <p>Libxml2 is the XML C parser and toolkit developed for the Gnome project
-(but usable outside of the Gnome platform).
-XML itself is a metalanguage to design markup languages, i.e. text language
-where semantic and structure are added to the content using extra "markup"
-information enclosed between angle brackets. HTML is the most well-known
-markup language. Though the library is written in C <a href="python.html">a
-variety of language bindings</a> make it available in other environments.</p>
+(but usable outside of the Gnome platform). XML itself is a metalanguage to
+design markup languages, i.e. text language where semantic and structure are
+added to the content using extra "markup" information enclosed between angle
+brackets. HTML is the most well-known markup language. Though the library is
+written in C <a href="python.html">a variety of language bindings</a> make it
+available in other environments.</p>
 
 <p>Libxml2 is known to be very portable, the library should build and work
 without serious troubles on a variety of systems (Linux, Unix, Windows,
@@ -67,9 +67,9 @@
     2001</a> except the base64Binary and hexBinary types</li>
 </ul>
 
-<p>In most cases libxml2 tries to implement the specifications in a relatively
-strictly compliant way. As of release 2.4.16, libxml2 passes all 1800+ tests
-from the <a
+<p>In most cases libxml2 tries to implement the specifications in a
+relatively strictly compliant way. As of release 2.4.16, libxml2 passes all
+1800+ tests from the <a
 href="http://www.oasis-open.org/committees/xml-conformance/">OASIS XML Tests
 Suite</a>.</p>
 
@@ -121,8 +121,8 @@
 <h2><a name="Introducti">Introduction</a></h2>
 
 <p>This document describes libxml, the <a
-href="http://www.w3.org/XML/">XML</a> C parser and toolkit developed for the <a
-href="http://www.gnome.org/">Gnome</a> project. <a
+href="http://www.w3.org/XML/">XML</a> C parser and toolkit developed for the
+<a href="http://www.gnome.org/">Gnome</a> project. <a
 href="http://www.w3.org/XML/">XML is a standard</a> for building tag-based
 structured documents/data.</p>
 
@@ -144,8 +144,9 @@
   <li>The design is modular, most of the extensions can be compiled out.</li>
   <li>The internal document representation is as close as possible to the <a
     href="http://www.w3.org/DOM/">DOM</a> interfaces.</li>
-  <li>Libxml2 also has a <a href="http://www.megginson.com/SAX/index.html">SAX
-    like interface</a>; the interface is designed to be compatible with <a
+  <li>Libxml2 also has a <a
+    href="http://www.megginson.com/SAX/index.html">SAX like interface</a>;
+    the interface is designed to be compatible with <a
     href="http://www.jclark.com/xml/expat.html">Expat</a>.</li>
   <li>This library is released under the <a
     href="http://www.opensource.org/licenses/mit-license.html">MIT
@@ -186,8 +187,8 @@
 
 <h3><a name="Installati">Installation</a></h3>
 <ol>
-  <li><strong><span style="background-color: #FF0000">Do
-    Not Use libxml1</span></strong>, use libxml2</li>
+  <li><strong><span style="background-color: #FF0000">Do Not Use
+    libxml1</span></strong>, use libxml2</li>
   <li><em>Where can I get libxml</em> ?
     <p>The original distribution comes from <a
     href="ftp://rpmfind.net/pub/libxml/">rpmfind.net</a> or <a
@@ -296,7 +297,7 @@
     <p>Usually the problem comes from the fact that the compiler doesn't get
     the right compilation or linking flags. There is a small shell script
     <code>xml2-config</code> which is installed as part of libxml2 usual
-    install process which provides those flags. Use </p>
+    install process which provides those flags. Use</p>
     <p><code>xml2-config --cflags</code></p>
     <p>to get the compilation flags and</p>
     <p><code>xml2-config --libs</code></p>
@@ -460,8 +461,8 @@
     internationalization support</a>.</li>
   <li>This page provides a global overview and <a href="example.html">some
     examples</a> on how to use libxml.</li>
-  <li>John Fleck's libxml2 tutorial: <a href="tutorial/index.html">html</a> or
-    <a href="tutorial/xmltutorial.pdf">pdf</a>.</li>
+  <li>John Fleck's libxml2 tutorial: <a href="tutorial/index.html">html</a>
+    or <a href="tutorial/xmltutorial.pdf">pdf</a>.</li>
   <li>If you need to parse large files, check the <a
     href="xmlreader.html">xmlReader</a> API tutorial</li>
   <li><a href="mailto:james@daa.com.au">James Henstridge</a> wrote <a
@@ -530,9 +531,9 @@
     others" and is not welcome. I will automatically Carbon-Copy the
     xml@gnome.org mailing list for any technical reply made about libxml2 or
     libxslt.</li>
-  <li>There is <span style="color: #E50000">no garantee of support</span>,
-    if your question remains unanswered after a week, repost it, making sure
-    you gave all the detail needed and the information requested.</li>
+  <li>There is <span style="color: #E50000">no garantee of support</span>, if
+    your question remains unanswered after a week, repost it, making sure you
+    gave all the detail needed and the information requested.</li>
   <li>Failing to provide information as requested or double checking first
     for prior feedback also carries the implicit message "the time of the
     library maintainers is less valuable than my time" and might not be
@@ -544,10 +545,11 @@
 
 <p>If you're looking for help, a quick look at <a
 href="http://mail.gnome.org/archives/xml/">the list archive</a> may actually
-provide the answer. I usually send source samples when answering libxml2 usage
-questions. The <a href="http://xmlsoft.org/html/book1.html">auto-generated
-documentation</a> is not as polished as I would like (i need to learn more
-about DocBook), but it's a good starting point.</p>
+provide the answer. I usually send source samples when answering libxml2
+usage questions. The <a
+href="http://xmlsoft.org/html/book1.html">auto-generated documentation</a> is
+not as polished as I would like (i need to learn more about DocBook), but
+it's a good starting point.</p>
 
 <h2><a name="help">How to help</a></h2>
 
@@ -650,6 +652,27 @@
   Schemas</a></li>
 </ul>
 
+<h3>2.5.8: Jul 6 2003</h3>
+<ul>
+  <li>bugfixes: XPath, XInclude, file/URI mapping, UTF-16 save (Mark
+    Itzcovitz), UTF-8 checking, URI saving, error printing (William Brack),
+    PI related memleak, compilation without schemas or without xpath (Joerg
+    Schmitz-Linneweber/Garry Pennington), xmlUnlinkNode problem with DTDs,
+    rpm problem on , i86_64, removed a few compilation problems from 2.5.7,
+    xmlIOParseDTD, and xmlSAXParseDTD (Malcolm Tredinnick)</li>
+  <li>portability: DJGPP (MsDos) , OpenVMS (Craig A. Berry)</li>
+  <li>William Brack fixed multithreading lock problems</li>
+  <li>IPv6 patch for FTP and HTTP accesses (Archana Shah/Wipro)</li>
+  <li>Windows fixes (Igor Zlatkovic,  Eric Zurcher), threading (Stéphane
+    Bidoul)</li>
+  <li>A few W3C Schemas Structure improvements</li>
+  <li>W3C Schemas Datatype improvements (Charlie Bozeman)</li>
+  <li>Python bindings for thread globals (Stéphane Bidoul), and method/class
+    generator </li>
+  <li>added --nonet option to xmllint </li>
+  <li>documentation improvements (John Fleck)</li>
+</ul>
+
 <h3>2.5.7: Apr 25 2003</h3>
 <ul>
   <li>Relax-NG: Compiling to regexp and streaming validation on top of the
@@ -1677,8 +1700,8 @@
 language for transforming XML documents into other XML documents (or
 HTML/textual output).</p>
 
-<p>A separate library called libxslt is available implementing XSLT-1.0
-for libxml2. This module "libxslt" too can be found in the Gnome CVS base.</p>
+<p>A separate library called libxslt is available implementing XSLT-1.0 for
+libxml2. This module "libxslt" too can be found in the Gnome CVS base.</p>
 
 <p>You can check the <a
 href="http://cvs.gnome.org/lxr/source/libxslt/FEATURES">features</a>
@@ -2019,8 +2042,8 @@
 
 <h2><a name="architecture">libxml2 architecture</a></h2>
 
-<p>Libxml2 is made of multiple components; some of them are optional, and most
-of the block interfaces are public. The main components are:</p>
+<p>Libxml2 is made of multiple components; some of them are optional, and
+most of the block interfaces are public. The main components are:</p>
 <ul>
   <li>an Input/Output layer</li>
   <li>FTP and HTTP client layers (optional)</li>
@@ -3230,8 +3253,8 @@
 
 <p>The API is voluntarily kept very simple. First it is not obvious that
 applications really need access to it since it is the default behaviour of
-libxml2 (Note: it is possible to completely override libxml2 default catalog by
-using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a> to
+libxml2 (Note: it is possible to completely override libxml2 default catalog
+by using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a> to
 plug an application specific resolver).</p>
 
 <p>Basically libxml2 support 2 catalog lists:</p>
@@ -3349,9 +3372,8 @@
 using the XML tollkit from the C language. It is not intended to be
 extensive. I hope the automatically generated documents will provide the
 completeness required, but as a separate set of documents. The interfaces of
-the XML parser are by principle low level,
-Those interested in a higher level API should <a href="#DOM">look at
-DOM</a>.</p>
+the XML parser are by principle low level, Those interested in a higher level
+API should <a href="#DOM">look at DOM</a>.</p>
 
 <p>The <a href="html/libxml-parser.html">parser interfaces for XML</a> are
 separated from the <a href="html/libxml-htmlparser.html">HTML parser
@@ -3380,8 +3402,9 @@
 <h3 id="Invoking1">Invoking the parser: the push method</h3>
 
 <p>In order for the application to keep the control when the document is
-being fetched (which is common for GUI based programs) libxml2 provides a push
-interface, too, as of version 1.8.3. Here are the interface functions:</p>
+being fetched (which is common for GUI based programs) libxml2 provides a
+push interface, too, as of version 1.8.3. Here are the interface
+functions:</p>
 <pre>xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
                                          void *user_data,
                                          const char *chunk,
diff --git a/nanohttp.c b/nanohttp.c
index d94f6d9..2879c14 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -968,13 +968,14 @@
 #ifdef SUPPORT_IP6
     memset (&sockin6, 0, sizeof(sockin6));
     if (have_ipv6 ())
-    {
 #if !defined(HAVE_GETADDRINFO) && defined(RES_USE_INET6)
+    {
 	if (!(_res.options & RES_INIT))
 	    res_init();
 	_res.options |= RES_USE_INET6;
     }
 #elif defined(HAVE_GETADDRINFO)
+    {
 	int status;
 	struct addrinfo hints, *res, *result;
 
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index 44ecab9..006dd90 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -82,7 +82,8 @@
     XML_SCHEMAS_SHORT,
     XML_SCHEMAS_USHORT,
     XML_SCHEMAS_BYTE,
-    XML_SCHEMAS_UBYTE
+    XML_SCHEMAS_UBYTE,
+    XML_SCHEMAS_HEXBINARY
 } xmlSchemaValType;
 
 static unsigned long powten[10] = {
@@ -169,6 +170,7 @@
 static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
 static xmlSchemaTypePtr xmlSchemaTypeBooleanDef = NULL;
 static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
+static xmlSchemaTypePtr xmlSchemaTypeHexBinaryDef = NULL;
 static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL;
 
 /*
@@ -278,6 +280,8 @@
                                                      XML_SCHEMAS_BOOLEAN);
     xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI",
                                                     XML_SCHEMAS_ANYURI);
+    xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType("hexBinary",
+                                                     XML_SCHEMAS_HEXBINARY);
 
     /*
      * derived datatypes
@@ -1914,6 +1918,67 @@
 	    xmlFreeURI(uri);
 	    goto return0;
 	}
+        case XML_SCHEMAS_HEXBINARY: {
+	    const xmlChar *tmp, *cur = value;
+            int total, i = 0;
+            unsigned long lo = 0, mi = 0, hi = 0;
+	    unsigned long *base;
+
+            tmp = cur;
+            while (((*tmp >= '0') && (*tmp <= '9')) ||
+                   ((*tmp >= 'A') && (*tmp <= 'F')) ||
+                   ((*tmp >= 'a') && (*tmp <= 'f'))) {
+	        i++;tmp++;
+            }
+
+	    if (*tmp != 0)
+		goto return1;
+            if (i > 24)
+		goto return1;
+            if ((i % 2) != 0)
+		goto return1;
+
+            total = i / 2;		/* number of octets */
+
+	    if (i >= 16)
+	        base = &hi;
+	    else if (i >= 8)
+	        base = &mi;
+	    else
+	        base = &lo;
+
+            while (i > 0) {
+                if ((*cur >= '0') && (*cur <= '9')) {
+                    *base = *base * 16 + (*cur - '0');
+                } else if ((*cur >= 'A') && (*cur <= 'F')) {
+                    *base = *base * 16 + (*cur - 'A') + 10;
+                } else if ((*cur >= 'a') && (*cur <= 'f')) {
+                    *base = *base * 16 + (*cur - 'a') + 10;
+                } else
+            	    break;
+
+                cur++;
+                i--;
+		if (i == 16)
+		    base = &mi;
+		else if (i == 8)
+		    base = &lo;
+            }
+
+	    if (val != NULL) {
+		v = xmlSchemaNewValue(XML_SCHEMAS_HEXBINARY);
+		if (v != NULL) {
+		    v->value.decimal.lo = lo;
+		    v->value.decimal.mi = mi;
+		    v->value.decimal.hi = hi;
+		    v->value.decimal.total = total;
+		    *val = v;
+		} else {
+		    goto error;
+		}
+	    }
+	    goto return0;
+        }
         case XML_SCHEMAS_INTEGER:
         case XML_SCHEMAS_PINTEGER:
         case XML_SCHEMAS_NPINTEGER:
@@ -3061,6 +3126,10 @@
 		return(1);
 	    }
 	    return (-2);
+        case XML_SCHEMAS_HEXBINARY:
+            if (y->type == XML_SCHEMAS_HEXBINARY)
+                return (xmlSchemaCompareDecimals(x, y));
+            return (-2);
         case XML_SCHEMAS_STRING:
         case XML_SCHEMAS_IDREFS:
         case XML_SCHEMAS_ENTITIES:
@@ -3205,22 +3274,26 @@
 		(facet->val->value.decimal.frac != 0)) {
 		return(-1);
 	    }
-	    switch (base->flags) {
-		case XML_SCHEMAS_IDREF:
-		case XML_SCHEMAS_NORMSTRING:
-		case XML_SCHEMAS_TOKEN:
-		case XML_SCHEMAS_LANGUAGE:
-		case XML_SCHEMAS_NMTOKEN:
-		case XML_SCHEMAS_NAME:
-		case XML_SCHEMAS_NCNAME:
-		case XML_SCHEMAS_ID:
-		    len = xmlSchemaNormLen(value);
-		    break;
-		case XML_SCHEMAS_STRING:
-		    len = xmlUTF8Strlen(value);
-		    break;
-		default:
-		    TODO
+	    if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY))
+	        len = val->value.decimal.total;
+	    else { 
+	        switch (base->flags) {
+	    	    case XML_SCHEMAS_IDREF:
+		    case XML_SCHEMAS_NORMSTRING:
+		    case XML_SCHEMAS_TOKEN:
+		    case XML_SCHEMAS_LANGUAGE:
+		    case XML_SCHEMAS_NMTOKEN:
+		    case XML_SCHEMAS_NAME:
+		    case XML_SCHEMAS_NCNAME:
+		    case XML_SCHEMAS_ID:
+		        len = xmlSchemaNormLen(value);
+		        break;
+		    case XML_SCHEMAS_STRING:
+		        len = xmlUTF8Strlen(value);
+		        break;
+		    default:
+		        TODO
+	        }
 	    }
 	    if (facet->type == XML_SCHEMA_FACET_LENGTH) {
 		if (len != facet->val->value.decimal.lo)
@@ -3234,6 +3307,41 @@
 	    }
 	    break;
 	}
+	case XML_SCHEMA_FACET_TOTALDIGITS:
+	case XML_SCHEMA_FACET_FRACTIONDIGITS:
+
+	    if ((facet->val == NULL) ||
+		((facet->val->type != XML_SCHEMAS_DECIMAL) &&
+		 (facet->val->type != XML_SCHEMAS_NNINTEGER)) ||
+		(facet->val->value.decimal.frac != 0)) {
+		return(-1);
+	    }
+	    if ((val == NULL) ||
+		((val->type != XML_SCHEMAS_DECIMAL) &&
+		 (val->type != XML_SCHEMAS_INTEGER) &&
+		 (val->type != XML_SCHEMAS_NPINTEGER) &&
+		 (val->type != XML_SCHEMAS_NINTEGER) &&
+		 (val->type != XML_SCHEMAS_NNINTEGER) &&
+		 (val->type != XML_SCHEMAS_PINTEGER) &&
+		 (val->type != XML_SCHEMAS_INT) &&
+		 (val->type != XML_SCHEMAS_UINT) &&
+		 (val->type != XML_SCHEMAS_LONG) &&
+		 (val->type != XML_SCHEMAS_ULONG) &&
+		 (val->type != XML_SCHEMAS_SHORT) &&
+		 (val->type != XML_SCHEMAS_USHORT) &&
+		 (val->type != XML_SCHEMAS_BYTE) &&
+		 (val->type != XML_SCHEMAS_UBYTE))) {
+		return(-1);
+	    }
+	    if (facet->type == XML_SCHEMA_FACET_TOTALDIGITS) {
+	        if (val->value.decimal.total > facet->val->value.decimal.lo)
+	            return(1);
+
+	    } else if (facet->type == XML_SCHEMA_FACET_FRACTIONDIGITS) {
+	        if (val->value.decimal.frac > facet->val->value.decimal.lo)
+		    return(1);
+	    }
+	    break;
 	default:
 	    TODO
     }