[LIBXML2]
authorAmine Khaldi <amine.khaldi@reactos.org>
Fri, 17 Oct 2014 10:58:01 +0000 (10:58 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Fri, 17 Oct 2014 10:58:01 +0000 (10:58 +0000)
* Update to v2.9.2.
CORE-8642

svn path=/trunk/; revision=64779

58 files changed:
reactos/include/reactos/libs/libxml/SAX2.h
reactos/include/reactos/libs/libxml/entities.h
reactos/include/reactos/libs/libxml/globals.h
reactos/include/reactos/libs/libxml/relaxng.h
reactos/include/reactos/libs/libxml/tree.h
reactos/include/reactos/libs/libxml/xmlIO.h
reactos/include/reactos/libs/libxml/xmlerror.h
reactos/include/reactos/libs/libxml/xmlversion.h
reactos/lib/3rdparty/libxml2/COPYING
reactos/lib/3rdparty/libxml2/ChangeLog
reactos/lib/3rdparty/libxml2/HTMLparser.c
reactos/lib/3rdparty/libxml2/HTMLtree.c
reactos/lib/3rdparty/libxml2/NEWS
reactos/lib/3rdparty/libxml2/SAX2.c
reactos/lib/3rdparty/libxml2/buf.c
reactos/lib/3rdparty/libxml2/buf.h
reactos/lib/3rdparty/libxml2/c14n.c
reactos/lib/3rdparty/libxml2/catalog.c
reactos/lib/3rdparty/libxml2/config.h
reactos/lib/3rdparty/libxml2/debugXML.c
reactos/lib/3rdparty/libxml2/elfgcchack.h
reactos/lib/3rdparty/libxml2/encoding.c
reactos/lib/3rdparty/libxml2/entities.c
reactos/lib/3rdparty/libxml2/hash.c
reactos/lib/3rdparty/libxml2/include/win32config.h
reactos/lib/3rdparty/libxml2/legacy.c
reactos/lib/3rdparty/libxml2/nanoftp.c
reactos/lib/3rdparty/libxml2/nanohttp.c
reactos/lib/3rdparty/libxml2/parser.c
reactos/lib/3rdparty/libxml2/parserInternals.c
reactos/lib/3rdparty/libxml2/relaxng.c
reactos/lib/3rdparty/libxml2/schematron.c
reactos/lib/3rdparty/libxml2/threads.c
reactos/lib/3rdparty/libxml2/timsort.h
reactos/lib/3rdparty/libxml2/tree.c
reactos/lib/3rdparty/libxml2/trio.c
reactos/lib/3rdparty/libxml2/trio.h
reactos/lib/3rdparty/libxml2/triodef.h
reactos/lib/3rdparty/libxml2/triostr.c
reactos/lib/3rdparty/libxml2/uri.c
reactos/lib/3rdparty/libxml2/valid.c
reactos/lib/3rdparty/libxml2/xinclude.c
reactos/lib/3rdparty/libxml2/xlink.c
reactos/lib/3rdparty/libxml2/xmlIO.c
reactos/lib/3rdparty/libxml2/xmlcatalog.c
reactos/lib/3rdparty/libxml2/xmllint.c
reactos/lib/3rdparty/libxml2/xmlmemory.c
reactos/lib/3rdparty/libxml2/xmlmodule.c
reactos/lib/3rdparty/libxml2/xmlreader.c
reactos/lib/3rdparty/libxml2/xmlregexp.c
reactos/lib/3rdparty/libxml2/xmlschemas.c
reactos/lib/3rdparty/libxml2/xmlschemastypes.c
reactos/lib/3rdparty/libxml2/xmlwriter.c
reactos/lib/3rdparty/libxml2/xpath.c
reactos/lib/3rdparty/libxml2/xpointer.c
reactos/lib/3rdparty/libxml2/xzlib.c
reactos/lib/3rdparty/libxml2/xzlib.h
reactos/media/doc/3rd Party Files.txt

index daafd17..a55212e 100644 (file)
@@ -98,7 +98,9 @@ XMLPUBFUN void XMLCALL
                xmlSAX2StartDocument            (void *ctx);
 XMLPUBFUN void XMLCALL
                xmlSAX2EndDocument              (void *ctx);
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
+    defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \
+    defined(LIBXML_LEGACY_ENABLED)
 XMLPUBFUN void XMLCALL
                xmlSAX2StartElement             (void *ctx,
                                                 const xmlChar *fullname,
@@ -106,7 +108,7 @@ XMLPUBFUN void XMLCALL
 XMLPUBFUN void XMLCALL
                xmlSAX2EndElement               (void *ctx,
                                                 const xmlChar *name);
-#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED */
+#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */
 XMLPUBFUN void XMLCALL
                xmlSAX2StartElementNs           (void *ctx,
                                                 const xmlChar *localname,
index 1e91189..47b4573 100644 (file)
@@ -57,7 +57,7 @@ struct _xmlEntity {
     const xmlChar           *URI;      /* the full URI as computed */
     int                    owner;      /* does the entity own the childrens */
     int                         checked;       /* was the entity content checked */
-                                       /* this is also used to count entites
+                                       /* this is also used to count entities
                                         * references done from that entity
                                         * and if it contains '<' */
 };
@@ -103,7 +103,7 @@ XMLPUBFUN xmlEntityPtr XMLCALL
 XMLPUBFUN xmlEntityPtr XMLCALL
                        xmlGetPredefinedEntity  (const xmlChar *name);
 XMLPUBFUN xmlEntityPtr XMLCALL
-                       xmlGetDocEntity         (xmlDocPtr doc,
+                       xmlGetDocEntity         (const xmlDoc *doc,
                                                 const xmlChar *name);
 XMLPUBFUN xmlEntityPtr XMLCALL
                        xmlGetDtdEntity         (xmlDocPtr doc,
@@ -120,7 +120,7 @@ XMLPUBFUN xmlChar * XMLCALL
                        xmlEncodeEntitiesReentrant(xmlDocPtr doc,
                                                 const xmlChar *input);
 XMLPUBFUN xmlChar * XMLCALL
-                       xmlEncodeSpecialChars   (xmlDocPtr doc,
+                       xmlEncodeSpecialChars   (const xmlDoc *doc,
                                                 const xmlChar *input);
 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
                        xmlCreateEntitiesTable  (void);
index 9d688e0..a9305aa 100644 (file)
@@ -39,7 +39,9 @@ XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
  * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
  *         method was found.
  */
-typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc);
+typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
+                                                                          xmlCharEncoding enc);
+
 
 /**
  * xmlOutputBufferCreateFilenameFunc:
@@ -52,7 +54,9 @@ typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const
  * Returns the new xmlOutputBufferPtr in case of success or NULL if no
  *         method was found.
  */
-typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression);
+typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
+                                                                xmlCharEncodingHandlerPtr encoder,
+                                                                int compression);
 
 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
 XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
@@ -185,7 +189,8 @@ XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregi
 XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
        xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
-       xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
+       xmlThrDefParserInputBufferCreateFilenameDefault(
+                               xmlParserInputBufferCreateFilenameFunc func);
 
 /** DOC_DISABLE */
 /*
@@ -297,7 +302,8 @@ XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
 #else
 XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
 #endif
-XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
+XMLPUBFUN xmlBufferAllocationScheme XMLCALL
+       xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
 
 XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
 #ifdef LIBXML_THREAD_ENABLED
@@ -479,7 +485,8 @@ XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
 XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
 #endif
 
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void);
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \
+                               __xmlParserInputBufferCreateFilenameValue(void);
 #ifdef LIBXML_THREAD_ENABLED
 #define xmlParserInputBufferCreateFilenameValue \
 (*(__xmlParserInputBufferCreateFilenameValue()))
index bdb0a7d..f269c9e 100644 (file)
@@ -32,7 +32,9 @@ typedef xmlRelaxNG *xmlRelaxNGPtr;
  *
  * Signature of an error callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx,
+                                                     const char *msg,
+                                                     ...) LIBXML_ATTR_FORMAT(2,3);
 
 /**
  * xmlRelaxNGValidityWarningFunc:
@@ -42,7 +44,9 @@ typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg
  *
  * Signature of a warning callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx,
+                                                       const char *msg,
+                                                       ...) LIBXML_ATTR_FORMAT(2,3);
 
 /**
  * A schemas validation context
index 7e06686..2f90717 100644 (file)
@@ -116,8 +116,8 @@ typedef xmlBuf *xmlBufPtr;
  * A few public routines for xmlBuf. As those are expected to be used
  * mostly internally the bulk of the routines are internal in buf.h
  */
-XMLPUBFUN xmlChar* XMLCALL       xmlBufContent (const xmlBufPtr buf);
-XMLPUBFUN xmlChar* XMLCALL       xmlBufEnd      (const xmlBufPtr buf);
+XMLPUBFUN xmlChar* XMLCALL       xmlBufContent (const xmlBuf* buf);
+XMLPUBFUN xmlChar* XMLCALL       xmlBufEnd      (xmlBufPtr buf);
 XMLPUBFUN size_t XMLCALL         xmlBufUse      (const xmlBufPtr buf);
 XMLPUBFUN size_t XMLCALL         xmlBufShrink  (xmlBufPtr buf, size_t len);
 
@@ -654,7 +654,11 @@ struct _xmlDOMWrapCtxt {
 /*
  * Some helper functions
  */
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
+    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \
+    defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \
+    defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \
+    defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 XMLPUBFUN int XMLCALL
                xmlValidateNCName       (const xmlChar *value,
                                         int space);
@@ -731,14 +735,14 @@ XMLPUBFUN int XMLCALL
 XMLPUBFUN void XMLCALL
                xmlBufferEmpty          (xmlBufferPtr buf);
 XMLPUBFUN const xmlChar* XMLCALL
-               xmlBufferContent        (const xmlBufferPtr buf);
+               xmlBufferContent        (const xmlBuffer *buf);
 XMLPUBFUN xmlChar* XMLCALL
                xmlBufferDetach         (xmlBufferPtr buf);
 XMLPUBFUN void XMLCALL
                xmlBufferSetAllocationScheme(xmlBufferPtr buf,
                                         xmlBufferAllocationScheme scheme);
 XMLPUBFUN int XMLCALL
-               xmlBufferLength         (const xmlBufferPtr buf);
+               xmlBufferLength         (const xmlBuffer *buf);
 
 /*
  * Creating/freeing new structures.
@@ -754,7 +758,7 @@ XMLPUBFUN xmlDtdPtr XMLCALL
                                         const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
 XMLPUBFUN xmlDtdPtr XMLCALL
-               xmlGetIntSubset         (xmlDocPtr doc);
+               xmlGetIntSubset         (const xmlDoc *doc);
 XMLPUBFUN void XMLCALL
                xmlFreeDtd              (xmlDtdPtr cur);
 #ifdef LIBXML_LEGACY_ENABLED
@@ -842,7 +846,7 @@ XMLPUBFUN xmlNodePtr XMLCALL
                                         const xmlChar *content);
 #endif
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlNewDocText           (xmlDocPtr doc,
+               xmlNewDocText           (const xmlDoc *doc,
                                         const xmlChar *content);
 XMLPUBFUN xmlNodePtr XMLCALL
                xmlNewText              (const xmlChar *content);
@@ -873,20 +877,20 @@ XMLPUBFUN xmlNodePtr XMLCALL
                xmlNewCharRef           (xmlDocPtr doc,
                                         const xmlChar *name);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlNewReference         (xmlDocPtr doc,
+               xmlNewReference         (const xmlDoc *doc,
                                         const xmlChar *name);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlCopyNode             (const xmlNodePtr node,
+               xmlCopyNode             (xmlNodePtr node,
                                         int recursive);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlDocCopyNode          (const xmlNodePtr node,
+               xmlDocCopyNode          (xmlNodePtr node,
                                         xmlDocPtr doc,
                                         int recursive);
 XMLPUBFUN xmlNodePtr XMLCALL
                xmlDocCopyNodeList      (xmlDocPtr doc,
-                                        const xmlNodePtr node);
+                                        xmlNodePtr node);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlCopyNodeList         (const xmlNodePtr node);
+               xmlCopyNodeList         (xmlNodePtr node);
 #ifdef LIBXML_TREE_ENABLED
 XMLPUBFUN xmlNodePtr XMLCALL
                xmlNewTextChild         (xmlNodePtr parent,
@@ -906,19 +910,19 @@ XMLPUBFUN xmlNodePtr XMLCALL
  * Navigating.
  */
 XMLPUBFUN long XMLCALL
-               xmlGetLineNo            (xmlNodePtr node);
+               xmlGetLineNo            (const xmlNode *node);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
 XMLPUBFUN xmlChar * XMLCALL
-               xmlGetNodePath          (xmlNodePtr node);
+               xmlGetNodePath          (const xmlNode *node);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlDocGetRootElement    (xmlDocPtr doc);
+               xmlDocGetRootElement    (const xmlDoc *doc);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlGetLastChild         (xmlNodePtr parent);
+               xmlGetLastChild         (const xmlNode *parent);
 XMLPUBFUN int XMLCALL
-               xmlNodeIsText           (xmlNodePtr node);
+               xmlNodeIsText           (const xmlNode *node);
 XMLPUBFUN int XMLCALL
-               xmlIsBlankNode          (xmlNodePtr node);
+               xmlIsBlankNode          (const xmlNode *node);
 
 /*
  * Changing the structure.
@@ -945,7 +949,7 @@ XMLPUBFUN xmlNodePtr XMLCALL
                                         xmlNodePtr cur);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
-    defined(LIBXML_SCHEMAS_ENABLED)
+    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
 XMLPUBFUN xmlNodePtr XMLCALL
                xmlAddPrevSibling       (xmlNodePtr cur,
                                         xmlNodePtr elem);
@@ -986,10 +990,11 @@ XMLPUBFUN xmlNsPtr XMLCALL
                xmlSearchNsByHref       (xmlDocPtr doc,
                                         xmlNodePtr node,
                                         const xmlChar *href);
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
+    defined(LIBXML_SCHEMAS_ENABLED)
 XMLPUBFUN xmlNsPtr * XMLCALL
-               xmlGetNsList            (xmlDocPtr doc,
-                                        xmlNodePtr node);
+               xmlGetNsList            (const xmlDoc *doc,
+                                        const xmlNode *node);
 #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */
 
 XMLPUBFUN void XMLCALL
@@ -1003,7 +1008,8 @@ XMLPUBFUN xmlNsPtr XMLCALL
 /*
  * Changing the content.
  */
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
+    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
 XMLPUBFUN xmlAttrPtr XMLCALL
                xmlSetProp              (xmlNodePtr node,
                                         const xmlChar *name,
@@ -1013,39 +1019,40 @@ XMLPUBFUN xmlAttrPtr XMLCALL
                                         xmlNsPtr ns,
                                         const xmlChar *name,
                                         const xmlChar *value);
-#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
+         defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
 XMLPUBFUN xmlChar * XMLCALL
-               xmlGetNoNsProp          (xmlNodePtr node,
+               xmlGetNoNsProp          (const xmlNode *node,
                                         const xmlChar *name);
 XMLPUBFUN xmlChar * XMLCALL
-               xmlGetProp              (xmlNodePtr node,
+               xmlGetProp              (const xmlNode *node,
                                         const xmlChar *name);
 XMLPUBFUN xmlAttrPtr XMLCALL
-               xmlHasProp              (xmlNodePtr node,
+               xmlHasProp              (const xmlNode *node,
                                         const xmlChar *name);
 XMLPUBFUN xmlAttrPtr XMLCALL
-               xmlHasNsProp            (xmlNodePtr node,
+               xmlHasNsProp            (const xmlNode *node,
                                         const xmlChar *name,
                                         const xmlChar *nameSpace);
 XMLPUBFUN xmlChar * XMLCALL
-               xmlGetNsProp            (xmlNodePtr node,
+               xmlGetNsProp            (const xmlNode *node,
                                         const xmlChar *name,
                                         const xmlChar *nameSpace);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlStringGetNodeList    (xmlDocPtr doc,
+               xmlStringGetNodeList    (const xmlDoc *doc,
                                         const xmlChar *value);
 XMLPUBFUN xmlNodePtr XMLCALL
-               xmlStringLenGetNodeList (xmlDocPtr doc,
+               xmlStringLenGetNodeList (const xmlDoc *doc,
                                         const xmlChar *value,
                                         int len);
 XMLPUBFUN xmlChar * XMLCALL
                xmlNodeListGetString    (xmlDocPtr doc,
-                                        xmlNodePtr list,
+                                        const xmlNode *list,
                                         int inLine);
 #ifdef LIBXML_TREE_ENABLED
 XMLPUBFUN xmlChar * XMLCALL
-               xmlNodeListGetRawString (xmlDocPtr doc,
-                                        xmlNodePtr list,
+               xmlNodeListGetRawString (const xmlDoc *doc,
+                                        const xmlNode *list,
                                         int inLine);
 #endif /* LIBXML_TREE_ENABLED */
 XMLPUBFUN void XMLCALL
@@ -1065,19 +1072,19 @@ XMLPUBFUN void XMLCALL
                                         const xmlChar *content,
                                         int len);
 XMLPUBFUN xmlChar * XMLCALL
-               xmlNodeGetContent       (xmlNodePtr cur);
+               xmlNodeGetContent       (const xmlNode *cur);
 
 XMLPUBFUN int XMLCALL
                xmlNodeBufGetContent    (xmlBufferPtr buffer,
-                                        xmlNodePtr cur);
+                                        const xmlNode *cur);
 XMLPUBFUN int XMLCALL
                xmlBufGetNodeContent    (xmlBufPtr buf,
-                                        xmlNodePtr cur);
+                                        const xmlNode *cur);
 
 XMLPUBFUN xmlChar * XMLCALL
-               xmlNodeGetLang          (xmlNodePtr cur);
+               xmlNodeGetLang          (const xmlNode *cur);
 XMLPUBFUN int XMLCALL
-               xmlNodeGetSpacePreserve (xmlNodePtr cur);
+               xmlNodeGetSpacePreserve (const xmlNode *cur);
 #ifdef LIBXML_TREE_ENABLED
 XMLPUBFUN void XMLCALL
                xmlNodeSetLang          (xmlNodePtr cur,
@@ -1087,8 +1094,8 @@ XMLPUBFUN void XMLCALL
                                         int val);
 #endif /* LIBXML_TREE_ENABLED */
 XMLPUBFUN xmlChar * XMLCALL
-               xmlNodeGetBase          (xmlDocPtr doc,
-                                        xmlNodePtr cur);
+               xmlNodeGetBase          (const xmlDoc *doc,
+                                        const xmlNode *cur);
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
 XMLPUBFUN void XMLCALL
                xmlNodeSetBase          (xmlNodePtr cur,
@@ -1234,7 +1241,7 @@ XMLPUBFUN int XMLCALL
  * Compression.
  */
 XMLPUBFUN int XMLCALL
-               xmlGetDocCompressMode   (xmlDocPtr doc);
+               xmlGetDocCompressMode   (const xmlDoc *doc);
 XMLPUBFUN void XMLCALL
                xmlSetDocCompressMode   (xmlDocPtr doc,
                                         int mode);
index 6c241a8..3e41744 100644 (file)
@@ -209,7 +209,7 @@ XMLPUBFUN int XMLCALL
 
 xmlParserInputBufferPtr
        __xmlParserInputBufferCreateFilename(const char *URI,
-                                                                               xmlCharEncoding enc);
+                                               xmlCharEncoding enc);
 
 #ifdef LIBXML_OUTPUT_ENABLED
 /*
index 537a396..43e68ca 100644 (file)
@@ -86,7 +86,7 @@ struct _xmlError {
     char       *str2;  /* extra string information */
     char       *str3;  /* extra string information */
     int                int1;   /* extra number information */
-    int                int2;   /* column number of the error or 0 if N/A (todo: rename this field when we would break ABI) */
+    int                int2;   /* error column # or 0 if N/A (todo: rename field when we would brk ABI) */
     void       *ctxt;   /* the parser context if available */
     void       *node;   /* the node in the tree */
 };
index 2651741..92f1352 100644 (file)
@@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
  *
  * the version string like "1.2.3"
  */
-#define LIBXML_DOTTED_VERSION "2.9.1"
+#define LIBXML_DOTTED_VERSION "2.9.2"
 
 /**
  * LIBXML_VERSION:
  *
  * the version number: 1.2.3 value is 10203
  */
-#define LIBXML_VERSION 20901
+#define LIBXML_VERSION 20902
 
 /**
  * LIBXML_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "10203"
  */
-#define LIBXML_VERSION_STRING "20901"
+#define LIBXML_VERSION_STRING "20902"
 
 /**
  * LIBXML_VERSION_EXTRA:
@@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
  * Macro to check that the libxml version in use is compatible with
  * the version the software has been compiled against
  */
-#define LIBXML_TEST_VERSION xmlCheckVersion(20901);
+#define LIBXML_TEST_VERSION xmlCheckVersion(20902);
 
 #ifndef VMS
 #if 0
index 417e955..d613185 100644 (file)
@@ -2,7 +2,7 @@ Except where otherwise noted in the source code (e.g. the files hash.c,
 list.c and the trio files, which are covered by a similar licence but
 with different Copyright notices) all the files are:
 
- Copyright (C) 1998-2003 Daniel Veillard.  All Rights Reserved.
+ Copyright (C) 1998-2012 Daniel Veillard.  All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -17,11 +17,7 @@ all copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
 NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
-NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Daniel Veillard shall not
-be used in advertising or otherwise to promote the sale, use or other deal-
-ings in this Software without prior written authorization from him.
-
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
index 36045e6..08725dd 100644 (file)
@@ -8139,7 +8139,7 @@ Wed Dec 10 11:16:29 CET 2003 Daniel Veillard <daniel@veillard.com>
 
 Tue Dec  9 23:50:23 CET 2003 Daniel Veillard <daniel@veillard.com>
 
-       * entities.c: fixed an XML entites content serialization 
+       * entities.c: fixed an XML entities content serialization
          potentially triggered by XInclude, see #126817
 
 Tue Dec  9 16:12:50 CET 2003 Daniel Veillard <daniel@veillard.com>
index dd0c1ea..d329d3b 100644 (file)
@@ -1177,7 +1177,7 @@ static const char *const htmlScriptAttributes[] = {
     "onfocus",
     "onblur",
     "onsubmit",
-    "onrest",
+    "onreset",
     "onchange",
     "onselect"
 };
@@ -3671,13 +3671,13 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
     int i;
     int discardtag = 0;
 
-    if (ctxt->instate == XML_PARSER_EOF)
-        return(-1);
     if ((ctxt == NULL) || (ctxt->input == NULL)) {
        htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
                     "htmlParseStartTag: context error\n", NULL, NULL);
        return -1;
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(-1);
     if (CUR != '<') return -1;
     NEXT;
 
@@ -4366,7 +4366,7 @@ static void
 htmlParseElementInternal(htmlParserCtxtPtr ctxt) {
     const xmlChar *name;
     const htmlElemDesc * info;
-    htmlParserNodeInfo node_info;
+    htmlParserNodeInfo node_info = { 0, };
     int failed;
 
     if ((ctxt == NULL) || (ctxt->input == NULL)) {
@@ -5991,7 +5991,7 @@ done:
                ctxt->sax->endDocument(ctxt->userData);
        }
     }
-    if ((ctxt->myDoc != NULL) &&
+    if ((!(ctxt->options & HTML_PARSE_NODEFDTD)) && (ctxt->myDoc != NULL) &&
        ((terminate) || (ctxt->instate == XML_PARSER_EOF) ||
         (ctxt->instate == XML_PARSER_EPILOG))) {
        xmlDtdPtr dtd;
@@ -6288,12 +6288,16 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
 
     /* set encoding */
     if (encoding) {
-        content = xmlMallocAtomic (xmlStrlen(content_line) + strlen(encoding) + 1);
-       if (content) {
-           strcpy ((char *)content, (char *)content_line);
-            strcat ((char *)content, (char *)encoding);
-            htmlCheckEncoding (ctxt, content);
-           xmlFree (content);
+        size_t l = strlen(encoding);
+
+       if (l < 1000) {
+           content = xmlMallocAtomic (xmlStrlen(content_line) + l + 1);
+           if (content) {
+               strcpy ((char *)content, (char *)content_line);
+               strcat ((char *)content, (char *)encoding);
+               htmlCheckEncoding (ctxt, content);
+               xmlFree (content);
+           }
        }
     }
 
@@ -6808,6 +6812,7 @@ htmlReadFd(int fd, const char *URL, const char *encoding, int options)
 
     if (fd < 0)
         return (NULL);
+    xmlInitParser();
 
     xmlInitParser();
     input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
@@ -6898,6 +6903,7 @@ htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     htmlCtxtReset(ctxt);
 
@@ -6931,6 +6937,7 @@ htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     htmlCtxtReset(ctxt);
 
@@ -6967,6 +6974,7 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
         return (NULL);
     if (buffer == NULL)
         return (NULL);
+    xmlInitParser();
 
     htmlCtxtReset(ctxt);
 
@@ -7009,6 +7017,7 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     htmlCtxtReset(ctxt);
 
@@ -7053,6 +7062,7 @@ htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     htmlCtxtReset(ctxt);
 
index 4d8e354..5c57fc5 100644 (file)
@@ -716,22 +716,49 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
                 (!xmlStrcasecmp(cur->name, BAD_CAST "src")) ||
                 ((!xmlStrcasecmp(cur->name, BAD_CAST "name")) &&
                  (!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) {
-               xmlChar *escaped;
                xmlChar *tmp = value;
+               /* xmlURIEscapeStr() escapes '"' so it can be safely used. */
+               xmlBufCCat(buf->buffer, "\"");
 
                while (IS_BLANK_CH(*tmp)) tmp++;
 
-               /*
-                * the < and > have already been escaped at the entity level
-                * And doing so here breaks server side includes
-                */
-               escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+<>");
-               if (escaped != NULL) {
-                   xmlBufWriteQuotedString(buf->buffer, escaped);
-                   xmlFree(escaped);
-               } else {
-                   xmlBufWriteQuotedString(buf->buffer, value);
+               /* URI Escape everything, except server side includes. */
+               for ( ; ; ) {
+                   xmlChar *escaped;
+                   xmlChar endChar;
+                   xmlChar *end = NULL;
+                   xmlChar *start = (xmlChar *)xmlStrstr(tmp, BAD_CAST "<!--");
+                   if (start != NULL) {
+                       end = (xmlChar *)xmlStrstr(tmp, BAD_CAST "-->");
+                       if (end != NULL) {
+                           *start = '\0';
+                       }
+                   }
+
+                   /* Escape the whole string, or until start (set to '\0'). */
+                   escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
+                   if (escaped != NULL) {
+                       xmlBufCat(buf->buffer, escaped);
+                       xmlFree(escaped);
+                   } else {
+                       xmlBufCat(buf->buffer, tmp);
+                   }
+
+                   if (end == NULL) { /* Everything has been written. */
+                       break;
+                   }
+
+                   /* Do not escape anything within server side includes. */
+                   *start = '<'; /* Restore the first character of "<!--". */
+                   end += 3; /* strlen("-->") */
+                   endChar = *end;
+                   *end = '\0';
+                   xmlBufCat(buf->buffer, start);
+                   *end = endChar;
+                   tmp = end;
                }
+
+               xmlBufCCat(buf->buffer, "\"");
            } else {
                xmlBufWriteQuotedString(buf->buffer, value);
            }
index cdfdda6..8027d55 100644 (file)
   Note that this is automatically generated from the news webpage at:
        http://xmlsoft.org/news.html
 
-Items not finished and worked on, get in touch with the list if you want
-to help those   - More testing on RelaxNG
-   - Finishing up XML
-  Schemas
-
 The change log at 
 ChangeLog.html
  describes the recents commits
-to the SVN at 
-http://svn.gnome.org/viewvc/libxml2/trunk/
+to the GIT at 
+http://git.gnome.org/browse/libxml2/
  code base.Here is the list of public releases:
+2.9.2: Oct 16 2014:
+   - Security:
+  Fix for CVE-2014-3660 billion laugh variant (Daniel Veillard),
+  CVE-2014-0191 Do not fetch external parameter entities (Daniel Veillard)
+  
+   - Bug Fixes:
+  fix memory leak xml header encoding field with XML_PARSE_IGNORE_ENC (Bart De Schuymer),
+  xmlmemory: handle realloc properly (Yegor Yefremov),
+  Python generator bug raised by the const change (Daniel Veillard),
+  Windows Critical sections not released correctly (Daniel Veillard),
+  Parser error on repeated recursive entity expansion containing &lt; (Daniel Veillard),
+  xpointer : fixing Null Pointers (Gaurav Gupta),
+  Remove Unnecessary Null check in xpointer.c (Gaurav Gupta),
+  parser bug on misformed namespace attributes (Dennis Filder),
+  Pointer dereferenced before null check (Daniel Veillard),
+  Leak of struct addrinfo in xmlNanoFTPConnect() (Gaurav Gupta),
+  Possible overflow in HTMLParser.c (Daniel Veillard),
+  python/tests/sync.py assumes Python dictionaries are ordered (John Beck),
+  Fix Enum check and missing break (Gaurav Gupta),
+  xmlIO: Handle error returns from dup() (Philip Withnall),
+  Fix a problem properly saving URIs (Daniel Veillard),
+  wrong error column in structured error when parsing attribute values (Juergen Keil),
+  wrong error column in structured error when skipping whitespace in xml decl (Juergen Keil),
+  no error column in structured error handler for xml schema validation errors (Juergen Keil),
+  Couple of Missing Null checks (Gaurav Gupta),
+  Add couple of missing Null checks (Daniel Veillard),
+  xmlschemastypes: Fix potential array overflow (Philip Withnall),
+  runtest: Fix a memory leak on parse failure (Philip Withnall),
+  xmlIO: Fix an FD leak on gzdopen() failure (Philip Withnall),
+  xmlcatalog: Fix a memory leak on quit (Philip Withnall),
+  HTMLparser: Correctly initialise a stack allocated structure (Philip Withnall),
+  Check for tmon in _xmlSchemaDateAdd() is incorrect (David Kilzer),
+  Avoid Possible Null Pointer in trio.c (Gaurav Gupta),
+  Fix processing in SAX2 in case of an allocation failure (Daniel Veillard),
+  XML Shell command "cd" does not handle "/" at end of path (Daniel Veillard),
+  Fix various Missing Null checks (Gaurav Gupta),
+  Fix a potential NULL dereference (Daniel Veillard),
+  Add a couple of misisng check in xmlRelaxNGCleanupTree (Gaurav Gupta),
+  Add a missing argument check (Gaurav Gupta),
+  Adding a check in case of allocation error (Gaurav Gupta),
+  xmlSaveUri() incorrectly recomposes URIs with rootless paths (Dennis Filder),
+  Adding some missing NULL checks (Gaurav),
+  Fixes for xmlInitParserCtxt (Daniel Veillard),
+  Fix regressions introduced by CVE-2014-0191 patch (Daniel Veillard),
+  erroneously ignores a validation error if no error callback set (Daniel Veillard),
+  xmllint was not parsing the --c14n11 flag (Sérgio Batista),
+  Avoid Possible null pointer dereference in memory debug mode (Gaurav),
+  Avoid Double Null Check (Gaurav),
+  Restore context size and position after XPATH_OP_ARG (Nick Wellnhofer),
+  Fix xmlParseInNodeContext() if node is not element (Daniel Veillard),
+  Avoid a possible NULL pointer dereference (Gaurav),
+  Fix xmlTextWriterWriteElement when a null content is given (Daniel Veillard),
+  Fix an typo 'onrest' in htmlScriptAttributes (Daniel Veillard),
+  fixing a ptotential uninitialized access (Daniel Veillard),
+  Fix an fd leak in an error case (Daniel Veillard),
+  Missing initialization for the catalog module (Daniel Veillard),
+  Handling of XPath function arguments in error case (Nick Wellnhofer),
+  Fix a couple of missing NULL checks (Gaurav),
+  Avoid a possibility of dangling encoding handler (Gaurav),
+  Fix HTML push parser to accept HTML_PARSE_NODEFDTD (Arnold Hendriks),
+  Fix a bug loading some compressed files (Mike Alexander),
+  Fix XPath node comparison bug (Gaurav),
+  Type mismatch in xmlschemas.c (Gaurav),
+  Type mismatch in xmlschemastypes.c (Gaurav),
+  Avoid a deadcode in catalog.c (Daniel Veillard),
+  run close socket on Solaris, same as we do on other platforms (Denis Pauk),
+  Fix pointer dereferenced before null check (Gaurav),
+  Fix a potential NULL dereference in tree code (Daniel Veillard),
+  Fix potential NULL pointer dereferences in regexp code (Gaurav),
+  xmllint --pretty crashed without following numeric argument (Tim Galeckas),
+  Fix XPath expressions of the form '@ns:*' (Nick Wellnhofer),
+  Fix XPath '//' optimization with predicates (Nick Wellnhofer),
+  Clear up a potential NULL dereference (Daniel Veillard),
+  Fix a possible NULL dereference (Gaurav),
+  Avoid crash if allocation fails (Daniel Veillard),
+  Remove occasional leading space in XPath number formatting (Daniel Veillard),
+  Fix handling of mmap errors (Daniel Veillard),
+  Catch malloc error and exit accordingly (Daniel Veillard),
+  missing else in xlink.c (Ami Fischman),
+  Fix a parsing bug on non-ascii element and CR/LF usage (Daniel Veillard),
+  Fix a regression in xmlGetDocCompressMode() (Daniel Veillard),
+  properly quote the namespace uris written out during c14n (Aleksey Sanin),
+  Remove premature XInclude check on URI being relative (Alexey Neyman),
+  Fix missing break on last() function for attributes (dcb),
+  Do not URI escape in server side includes (Romain Bondue),
+  Fix an error in xmlCleanupParser (Alexander Pastukhov)
+  
+   - Documentation:
+  typo in error messages "colon are forbidden from..." (Daniel Veillard),
+  Fix a link to James SAX documentation old page (Daniel Veillard),
+  Fix typos in relaxng.c (Jan Pokorný),
+  Fix a doc typo (Daniel Veillard),
+  Fix typos in {tree,xpath}.c (errror) (Jan Pokorný),
+  Add limitations about encoding conversion (Daniel Veillard),
+  Fix typos in xmlschemas{,types}.c (Jan Pokorný),
+  Fix incorrect spelling entites->entities (Jan Pokorný),
+  Forgot to document 2.9.1 release, regenerate docs (Daniel Veillard)
+  
+   - Portability:
+  AC_CONFIG_FILES and executable bit (Roumen Petrov),
+  remove HAVE_CONFIG_H dependency in testlimits.c (Roumen Petrov),
+  fix some tabs mixing incompatible with python3 (Roumen Petrov),
+  Visual Studio 14 CTP defines snprintf() (Francis Dupont),
+  OS400: do not try to copy unexisting doc files (Patrick Monnerat),
+  OS400: use either configure.ac or configure.in. (Patrick Monnerat),
+  os400: make-src.sh: create physical file with target CCSID (Patrick Monnerat),
+  OS400: Add some more C macros equivalent procedures. (Patrick Monnerat),
+  OS400: use C macros to implement equivalent RPG support procedures. (Patrick Monnerat),
+  OS400: implement XPath macros as procedures for ILE/RPG support. (Patrick Monnerat),
+  OS400: include in distribution tarball. (Patrick Monnerat),
+  OS400: Add README: compilation directives and OS/400 specific stuff. (Patrick Monnerat),
+  OS400: Add compilation scripts. (Patrick Monnerat),
+  OS400: ILE RPG language header files. (Patrick Monnerat),
+  OS400: implement some macros as functions for ILE/RPG language support (that as no macros). (Patrick Monnerat),
+  OS400: UTF8<-->EBCDIC wrappers for system and external library calls (Patrick Monnerat),
+  OS400: Easy character transcoding support (Patrick Monnerat),
+  OS400: iconv functions compatibility wrappers and table builder. (Patrick Monnerat),
+  OS400: create architecture directory. Implement dlfcn emulation. (Patrick Monnerat),
+  Fix building when configuring without xpath and xptr (Daniel Veillard),
+  configure: Add --with-python-install-dir (Jonas Eriksson),
+  Fix compilation with minimum and xinclude. (Nicolas Le Cam),
+  Compile out use of xmlValidateNCName() when not available. (Nicolas Le Cam),
+  Fix compilation with minimum and schematron. (Nicolas Le Cam),
+  Legacy needs xmlSAX2StartElement() and xmlSAX2EndElement(). (Nicolas Le Cam),
+  Don't use xmlValidateName() when not available. (Nicolas Le Cam),
+  Fix a portability issue on Windows (Longstreth Jon),
+  Various portability patches for OpenVMS (Jacob (Jouk) Jansen),
+  Use specific macros for portability to OS/400 (Patrick Monnerat),
+  Add macros needed for OS/400 portability (Patrick Monnerat),
+  Portability patch for fopen on OS/400 (Patrick Monnerat),
+  Portability fixes for OS/400 (Patrick Monnerat),
+  Improve va_list portability (Patrick Monnerat),
+  Portability fix (Patrick Monnerat),
+  Portability fix (Patrick Monnerat),
+  Generic portability fix (Patrick Monnerat),
+  Shortening lines in headers (Patrick Monnerat),
+  build: Use pkg-config to find liblzma in preference to AC_CHECK_LIB (Philip Withnall),
+  build: Add @LZMA_LIBS@ to libxml’s pkg-config files (Philip Withnall),
+  fix some tabs mixing incompatible with python3 (Daniel Veillard),
+  add additional defines checks for support "./configure --with-minimum" (Denis Pauk),
+  Another round of fixes for older versions of Python (Arfrever Frehtes Taifersar Arahesis),
+  python: fix drv_libxml2.py for python3 compatibility (Alexandre Rostovtsev),
+  python: Fix compiler warnings when building python3 bindings (Armin K),
+  Fix for compilation with python 2.6.8 (Petr Sumbera)
+  
+   - Improvements:
+  win32/libxml2.def.src after rebuild in doc (Roumen Petrov),
+  elfgcchack.h: more legacy needs xmlSAX2StartElement() and xmlSAX2EndElement() (Roumen Petrov),
+  elfgcchack.h: add xmlXPathNodeEval and xmlXPathSetContextNode (Roumen Petrov),
+  Provide cmake module (Samuel Martin),
+  Fix a couple of issues raised by make dist (Daniel Veillard),
+  Fix and add const qualifiers (Kurt Roeckx),
+  Preparing for upcoming release of 2.9.2 (Daniel Veillard),
+  Fix zlib and lzma libraries check via command line (Dmitriy),
+  wrong error column in structured error when parsing end tag (Juergen Keil),
+  doc/news.html: small update to avoid line join while generating NEWS. (Patrick Monnerat),
+  Add methods for python3 iterator (Ron Angeles),
+  Support element node traversal in document fragments. (Kyle VanderBeek),
+  xmlNodeSetName: Allow setting the name to a substring of the currently set name (Tristan Van Berkom),
+  Added macros for argument casts (Eric Zurcher),
+  adding init calls to xml and html Read parsing entry points (Daniel Veillard),
+  Get rid of 'REPLACEMENT CHARACTER' Unicode chars in xmlschemas.c (Jan Pokorný),
+  Implement choice for name classes on attributes (Shaun McCance),
+  Two small namespace tweaks (Daniel Veillard),
+  xmllint --memory should fail on empty files (Daniel Veillard),
+  Cast encoding name to char pointer to match arg type (Nikolay Sivov)
+  
+   - Cleanups:
+  Removal of old configure.in (Daniel Veillard),
+  Unreachable code in tree.c (Gaurav Gupta),
+  Remove a couple of dead conditions (Gaurav Gupta),
+  Avoid some dead code and cleanup in relaxng.c (Gaurav),
+  Drop not needed checks (Denis Pauk),
+  Fix a wrong test (Daniel Veillard)
+  
+
+
+2.9.1: Apr 19 2013:
+   -  Features:
+    Support for Python3 (Daniel Veillard),
+    Add xmlXPathSetContextNode and xmlXPathNodeEval (Alex Bligh)
+  
+   -  Documentation:
+    Add documentation for xmllint --xpath (Daniel Veillard),
+    Fix the URL of the SAX documentation from James (Daniel Veillard),
+    Fix spelling of "length". (Michael Wood)
+  
+   -  Portability:
+    Fix python bindings with versions older than 2.7 (Daniel Veillard),
+    rebuild docs:Makefile.am (Roumen Petrov),
+    elfgcchack.h after rebuild in doc (Roumen Petrov),
+    elfgcchack for buf module (Roumen Petrov),
+    Fix a uneeded and wrong extra link parameter (Daniel Veillard),
+    Few cleanup patches for Windows (Denis Pauk),
+    Fix rpmbuild --nocheck (Mark Salter),
+    Fix for win32/configure.js and WITH_THREAD_ALLOC (Daniel Richard),
+    Fix Broken multi-arch support in xml2-config (Daniel Veillard),
+    Fix a portability issue for GCC < 3.4.0 (Daniel Veillard),
+    Windows build fixes (Daniel Richard),
+    Fix a thread portability problem (Friedrich Haubensak),
+    Downgrade autoconf requirement to 2.63 (Daniel Veillard)
+  
+   -  Bug Fixes:
+    Fix a linking error for python bindings (Daniel Veillard),
+    Fix a couple of return without value (Jüri Aedla),
+    Improve the hashing functions (Daniel Franke),
+    Improve handling of xmlStopParser() (Daniel Veillard),
+    Remove risk of lockup in dictionary initialization (Daniel Veillard),
+    Activate detection of encoding in external subset (Daniel Veillard),
+    Fix an output buffer flushing conversion bug (Mikhail Titov),
+    Fix an old bug in xmlSchemaValidateOneElement (Csaba László),
+    Fix configure cannot remove messages (Gilles Espinasse),
+    fix schema validation in combination with xsi:nil (Daniel Veillard),
+    xmlCtxtReadFile doesn't work with literal IPv6 URLs (Steve Wolf),
+    Fix a few problems with setEntityLoader (Alexey Neyman),
+    Detect excessive entities expansion upon replacement (Daniel Veillard),
+    Fix the flushing out of raw buffers on encoding conversions (Daniel,
+Veillard),
+    Fix some buffer conversion issues (Daniel Veillard),
+    When calling xmlNodeDump make sure we grow the buffer quickly (Daniel,
+Veillard),
+    Fix an error in the progressive DTD parsing code (Dan Winship),
+    xmllint should not load DTD by default when using the reader (Daniel,
+Veillard),
+    Try IBM-037 when looking for EBCDIC handlers (Petr Sumbera),
+    Fix potential out of bound access (Daniel Veillard),
+    Fix large parse of file from memory (Daniel Veillard),
+    Fix a bug in the nsclean option of the parser (Daniel Veillard),
+    Fix a regression in 2.9.0 breaking validation while streaming (Daniel,
+Veillard),
+    Remove potential calls to exit() (Daniel Veillard)
+  
+   -  Improvements:
+    Regenerated API, and testapi, rebuild documentation (Daniel Veillard),
+    Fix tree iterators broken by 2to3 script (Daniel Veillard),
+    update all tests for Python3 and Python2 (Daniel Veillard),
+    A few more fixes for python 3 affecting libxml2.py (Daniel Veillard),
+    Fix compilation on Python3 (Daniel Veillard),
+    Converting apibuild.py to python3 (Daniel Veillard),
+    First pass at starting porting to python3 (Daniel Veillard),
+    updated configure.in for python3 (Daniel Veillard),
+    Add support for xpathRegisterVariable in Python (Shaun McCance),
+    Added a regression tests from bug 694228 data (Daniel Veillard),
+    Cache presence of '<' in entities content (Daniel Veillard),
+    Avoid extra processing on entities (Daniel Veillard),
+    Python binding for xmlRegisterInputCallback (Alexey Neyman),
+    Python bindings: DOM casts everything to xmlNode (Alexey Neyman),
+    Define LIBXML_THREAD_ALLOC_ENABLED via xmlversion.h (Tim Starling),
+    Adding streaming validation to runtest checks (Daniel Veillard),
+    Add a --pushsmall option to xmllint (Daniel Veillard)
+  
+   -  Cleanups:
+    Switched comment in file to UTF-8 encoding (Daniel Veillard),
+    Extend gitignore (Daniel Veillard),
+    Silent the new python test on input (Alexey Neyman),
+    Cleanup of a duplicate test (Daniel Veillard),
+    Cleanup on duplicate test expressions (Daniel Veillard),
+    Fix compiler warning after 153cf15905cf4ec080612ada6703757d10caba1e (Patrick,
+Gansterer),
+    Spec cleanups and a fix for multiarch support (Daniel Veillard),
+    Silence a clang warning (Daniel Veillard),
+    Cleanup the Copyright to be pure MIT Licence wording (Daniel Veillard),
+    rand_seed should be static in dict.c (Wouter Van Rooy),
+    Fix typos in parser comments (Jan Pokorný)
+  
+
+
+2.9.0: Sep 11 2012:
+   -  Features:
+    A few new API entry points,
+    More resilient push parser mode,
+    A lot of portability improvement,
+    Faster XPath evaluation
+  
+   -  Documentation:
+    xml2-config.1 markup error (Christian Weisgerber),
+    libxml(3) manpage typo fix (John Bradshaw),
+    More cleanups to the documentation part of libxml2 (Daniel Richard G)
+  
+   -  Portability:
+    Bug 676544 - fails to build with --without-sax1 (Akira TAGOH),
+    fix builds not having stdint.h (Rob Richards),
+    GetProcAddressA is available only on WinCE (Daniel Veillard),
+    More updates and cleanups on autotools and Makefiles (Daniel Richard G),
+    More changes for Win32 compilation (Eric Zurcher),
+    Basic changes for Win32 builds of release 2.9.0: compile buf.c (Eric Zurcher),
+    Bundles all generated files for python into the distribution (Daniel Richard G),
+    Fix compiler warnings of wincecompat.c (Patrick Gansterer),
+    Fix non __GNUC__ build (Patrick Gansterer),
+    Fix windows unicode build (Patrick Gansterer),
+    clean redefinition of {v}snprintf in C-source (Roumen Petrov),
+    use xmlBuf... if DEBUG_INPUT is defined (Roumen Petrov),
+    fix runtests to use pthreads support for various Unix platforms (Daniel Richard G),
+    Various "make distcheck" and portability fixups 2nd part (Daniel Richard G),
+    Various "make distcheck" and portability fixups (Daniel Richard G),
+    Fix compilation on older Visual Studio (Daniel Veillard)
+  
+   -  Bug Fixes:
+    Change the XPath code to percolate allocation errors (Daniel Veillard),
+    Fix reuse of xmlInitParser (Daniel Veillard),
+    Fix potential crash on entities errors (Daniel Veillard),
+    initialize var (Rob Richards),
+    Fix the XPath arity check to also check the XPath stack limits (Daniel Veillard),
+    Fix problem with specific and generic error handlers (Pietro Cerutti),
+    Avoid a potential infinite recursion (Daniel Veillard),
+    Fix an XSD error when generating internal automata (Daniel Veillard),
+    Patch for xinclude of text using multibyte characters (Vitaly Ostanin),
+    Fix a segfault on XSD validation on pattern error (Daniel Veillard),
+    Fix missing xmlsave.h module which was ignored in recent builds (Daniel Veillard),
+    Add a missing element check (Daniel Veillard),
+    Adding various checks on node type though the API (Daniel Veillard),
+    Namespace nodes can't be unlinked with xmlUnlinkNode (Daniel Veillard),
+    Fix make dist to include new private header files (Daniel Veillard),
+    More fixups on the push parser behaviour (Daniel Veillard),
+    Strengthen behaviour of the push parser in problematic situations (Daniel Veillard),
+    Enforce XML_PARSER_EOF state handling through the parser (Daniel Veillard),
+    Fixup limits parser (Daniel Veillard),
+    Do not fetch external parsed entities (Daniel Veillard),
+    Fix an error in previous commit (Aron Xu),
+    Fix entities local buffers size problems (Daniel Veillard),
+    Fix parser local buffers size problems (Daniel Veillard),
+    Fix a failure to report xmlreader parsing failures (Daniel Veillard)
+  
+   -  Improvements:
+    Keep libxml2.syms when running "make distclean" (Daniel Veillard),
+    Allow to set the quoting character of an xmlWriter (Csaba Raduly),
+    Keep non-significant blanks node in HTML parser (Daniel Veillard),
+    Add a forbidden variable error number and message to XPath (Daniel Veillard),
+    Support long path names on WNT (Michael Stahl),
+    Improve HTML escaping of attribute on output (Daniel Veillard),
+    Handle ICU_LIBS as LIBADD, not LDFLAGS to prevent linking errors (Arfrever Frehtes Taifersar Arahesis),
+    Switching XPath node sorting to Timsort (Vojtech Fried),
+    Optimizing '//' in XPath expressions (Nick Wellnhofer),
+    Expose xmlBufShrink in the public tree API (Daniel Veillard),
+    Visible HTML elements close the head tag (Conrad Irwin),
+    Fix file and line report for XSD SAX and reader streaming validation (Daniel Veillard),
+    Fix const qualifyer to definition of xmlBufferDetach (Daniel Veillard),
+    minimize use of HAVE_CONFIG_H (Roumen Petrov),
+    fixup regression in Various "make distcheck" and portability fixups (Roumen Petrov),
+    Add support for big line numbers in error reporting (Daniel Veillard),
+    Avoid using xmlBuffer for serialization (Daniel Veillard),
+    Improve compatibility between xmlBuf and xmlBuffer (Daniel Veillard),
+    Provide new accessors for xmlOutputBuffer (Daniel Veillard),
+    Improvements for old buffer compatibility (Daniel Veillard),
+    Expand the limit test program (Daniel Veillard),
+    Improve error reporting on parser errors (Daniel Veillard),
+    Implement some default limits in the XPath module (Daniel Veillard),
+    Introduce some default parser limits (Daniel Veillard),
+    Cleanups and new limit APIs for dictionaries (Daniel Veillard),
+    Fixup for buf.c (Daniel Veillard),
+    Cleanup URI module memory allocation code (Daniel Veillard),
+    Extend testlimits (Daniel Veillard),
+    More avoid quadratic behaviour (Daniel Veillard),
+    Impose a reasonable limit on PI size (Daniel Veillard),
+    first version of testlimits new test (Daniel Veillard),
+    Avoid quadratic behaviour in some push parsing cases (Daniel Veillard),
+    Impose a reasonable limit on comment size (Daniel Veillard),
+    Impose a reasonable limit on attribute size (Daniel Veillard),
+    Harden the buffer code and make it more compatible (Daniel Veillard),
+    More cleanups for input/buffers code (Daniel Veillard),
+    Cleanup function xmlBufResetInput(), to set input from Buffer (Daniel Veillard)
+    Swicth the test program for characters to new input buffers (Daniel Veillard),
+    Convert the HTML tree module to the new buffers (Daniel Veillard),
+    Convert of the HTML parser to new input buffers (Daniel Veillard),
+    Convert the writer to new output buffer and save APIs (Daniel Veillard),
+    Convert XMLReader to the new input buffers (Daniel Veillard),
+    New saving functions using xmlBuf and conversion (Daniel Veillard),
+    Provide new xmlBuf based saving functions (Daniel Veillard),
+    Convert XInclude to the new input buffers (Daniel Veillard),
+    Convert catalog code to the new input buffers (Daniel Veillard),
+    Convert C14N to the new Input buffer (Daniel Veillard),
+    Convert xmlIO.c to the new input and output buffers (Daniel Veillard),
+    Convert XML parser to the new input buffers (Daniel Veillard),
+    Incompatible change to the Input and Output buffers (Daniel Veillard),
+    Adding new encoding function to deal with the new structures (Daniel Veillard),
+    Convert XPath to xmlBuf (Daniel Veillard),
+    Adding a new buf module for buffers (Daniel Veillard),
+    Memory error within SAX2 reuse common framework (Daniel Veillard),
+    Fix xmllint --xpath node initialization (Daniel Veillard)
+  
+   -  Cleanups:
+    Various cleanups to avoid compiler warnings (Daniel Veillard),
+    Big space and tab cleanup (Daniel Veillard),
+    Followup to LibXML2 docs/examples cleanup patch (Daniel Veillard),
+    Second round of cleanups for LibXML2 docs/examples (Daniel Richard),
+    Remove all .cvsignore as they are not used anymore (Daniel Veillard),
+    Fix a Timsort function helper comment (Daniel Veillard),
+    Small cleanup for valgrind target (Daniel Veillard),
+    Patch for portability of latin characters in C files (Daniel Veillard),
+    Cleanup some of the parser code (Daniel Veillard),
+    Fix a variable name in comment (Daniel Veillard),
+    Regenerated testapi.c (Daniel Veillard),
+    Regenerating docs and API files (Daniel Veillard),
+    Small cleanup of unused variables in test (Daniel Veillard),
+    Expand .gitignore with more files (Daniel Veillard)
+  
+
+
+2.8.0: May 23 2012:
+   - Features:
+  add lzma compression support (Anders F Bjorklund)
+  
+   - Documentation:
+    xmlcatalog: Add uri and delegateURI to possible add types in man page. (Ville Skyttä),
+    Update README.tests (Daniel Veillard),
+    URI handling code is not OOM resilient (Daniel Veillard),
+    Fix an error in comment (Daniel Veillard),
+    Fixed bug #617016 (Daniel Mustieles),
+    Fixed two typos in the README document (Daniel Neel),
+    add generated html files (Anders F Bjorklund),
+    Clarify the need to use xmlFreeNode after xmlUnlinkNode (Daniel Veillard),
+    Improve documentation a bit (Daniel Veillard),
+    Updated URL for lxml python bindings (Daniel Veillard)
+  
+   - Portability:
+    Restore code for Windows compilation (Daniel Veillard),
+    Remove git error message during configure (Christian Dywan),
+    xmllint: Build fix for endTimer if !defined(HAVE_GETTIMEOFDAY) (Patrick R. Gansterer),
+    remove a bashism in confgure.in (John Hein),
+    undef ERROR if already defined (Patrick R. Gansterer),
+    Fix library problems with mingw-w64 (Michael Cronenworth),
+    fix windows build. ifdef addition from bug 666491 makes no sense (Rob Richards),
+    prefer native threads on win32 (Sam Thursfield),
+    Allow to compile with Visual Studio 2010 (Thomas Lemm),
+    Fix mingw's snprintf configure check (Andoni Morales),
+    fixed a 64bit big endian issue (Marcus Meissner),
+    Fix portability failure if netdb.h lacks NO_ADDRESS (Daniel Veillard),
+    Fix windows build from lzma addition (Rob Richards),
+    autogen: Only check for libtoolize (Colin Walters),
+    Fix the Windows build files (Patrick von Reth),
+    634846 Remove a linking option breaking Windows VC10 (Daniel Veillard),
+    599241 fix an initialization problem on Win64 (Andrew W. Nosenko),
+    fix win build (Rob Richards)
+  
+   - Bug fixes:
+    Part for rand_r checking missing (Daniel Veillard),
+    Cleanup on randomization (Daniel Veillard),
+    Fix undefined reference in python module (Pacho Ramos),
+    Fix a race in xmlNewInputStream (Daniel Veillard),
+    Fix weird streaming RelaxNG errors (Noam),
+    Fix various bugs in new code raised by the API checking (Daniel Veillard),
+    Fix various problems with "make dist" (Daniel Veillard),
+    Fix a memory leak in the xzlib code (Daniel Veillard),
+    HTML parser error with <noscript> in the <head> (Denis Pauk),
+    XSD: optional element in complex type extension (Remi Gacogne),
+    Fix html serialization error and htmlSetMetaEncoding() (Daniel Veillard),
+    Fix a wrong return value in previous patch (Daniel Veillard),
+    Fix an uninitialized variable use (Daniel Veillard),
+    Fix a compilation problem with --minimum (Brandon Slack),
+    Remove redundant and ungarded include of resolv.h (Daniel Veillard),
+    xinclude with parse="text" does not use the entity loader (Shaun McCance),
+    Allow to parse 1 byte HTML files (Denis Pauk),
+    Patch that fixes the skipping of the HTML_PARSE_NOIMPLIED flag (Martin Schröder),
+    Avoid memory leak if xmlParserInputBufferCreateIO fails (Lin Yi-Li),
+    Prevent an infinite loop when dumping a node with encoding problems (Timothy Elliott),
+    xmlParseNodeInContext problems with an empty document (Tim Elliott),
+    HTML element position is not detected propperly (Pavel Andrejs),
+    Fix an off by one pointer access (Jüri Aedla),
+    Try to fix a problem with entities in SAX mode (Daniel Veillard),
+    Fix a crash with xmllint --path on empty results (Daniel Veillard),
+    Fixed bug #667946 (Daniel Mustieles),
+    Fix a logic error in Schemas Component Constraints (Ryan Sleevi),
+    Fix a wrong enum type use in Schemas Types (Nico Weber),
+    Fix SAX2 builder in case of undefined attributes namespace (Daniel Veillard),
+    Fix SAX2 builder in case of undefined element namespaces (Daniel Veillard),
+    fix reference to STDOUT_FILENO on MSVC (Tay Ray Chuan),
+    fix a pair of possible out of array char references (Daniel Veillard),
+    Fix an allocation error when copying entities (Daniel Veillard),
+    Make sure the parser returns when getting a Stop order (Chris Evans),
+    Fix some potential problems on reallocation failures(parser.c) (Xia Xinfeng),
+    Fix a schema type duration comparison overflow (Daniel Veillard),
+    Fix an unimplemented part in RNG value validation (Daniel Veillard),
+    Fix missing error status in XPath evaluation (Daniel Veillard),
+    Hardening of XPath evaluation (Daniel Veillard),
+    Fix an off by one error in encoding (Daniel Veillard),
+    Fix RELAX NG include bug #655288 (Shaun McCance),
+    Fix XSD validation bug #630130 (Toyoda Eizi),
+    Fix some potential problems on reallocation failures (Chris Evans),
+    __xmlRaiseError: fix use of the structured callback channel (Dmitry V. Levin),
+    __xmlRaiseError: fix the structured callback channel's data initialization (Dmitry V. Levin),
+    Fix memory corruption when xmlParseBalancedChunkMemoryInternal is called from xmlParseBalancedChunk (Rob Richards),
+    Small fix for previous commit (Daniel Veillard),
+    Fix a potential freeing error in XPath (Daniel Veillard),
+    Fix a potential memory access error (Daniel Veillard),
+    Reactivate the shared library versionning script (Daniel Veillard)
+  
+   - Improvements:
+    use mingw C99 compatible functions {v}snprintf instead those from MSVC runtime (Roumen Petrov),
+    New symbols added for the next release (Daniel Veillard),
+    xmlTextReader bails too quickly on error (Andy Lutomirski),
+    Use a hybrid allocation scheme in xmlNodeSetContent (Conrad Irwin),
+    Use buffers when constructing string node lists. (Conrad Irwin),
+    Add HTML parser support for HTML5 meta charset encoding declaration (Denis Pauk),
+    wrong message for double hyphen in comment XML error (Bryan Henderson),
+    Fix "make tst" to grab lzma lib too (Daniel Veillard),
+    Add "whereis" command to xmllint shell (Ryan),
+    Improve xmllint shell (Ryan),
+    add function xmlTextReaderRelaxNGValidateCtxt() (Noam Postavsky),
+    Add --system support to autogen.sh (Daniel Veillard),
+    Add hash randomization to hash and dict structures (Daniel Veillard),
+    included xzlib in dist (Anders F Bjorklund),
+    move xz/lzma helpers to separate included files (Anders F Bjorklund),
+    add generated devhelp files (Anders F Bjorklund),
+    add XML_WITH_LZMA to api (Anders F Bjorklund),
+    autogen.sh: Honor NOCONFIGURE environment variable (Colin Walters),
+    Improve the error report on undefined REFs (Daniel Veillard),
+    Add exception for new W3C PI xml-model (Daniel Veillard),
+    Add options to ignore the internal encoding (Daniel Veillard),
+    testapi: use the right type for the check (Stefan Kost),
+    various: handle return values of write calls (Stefan Kost),
+    testWriter: xmlTextWriterWriteFormatElement wants an int instead of a long int (Stefan Kost),
+    runxmlconf: update to latest testsuite version (Stefan Kost),
+    configure: add -Wno-long-long to CFLAGS (Stefan Kost),
+    configure: support silent automake rules if possible (Stefan Kost),
+    xmlmemory: add a cast as size_t has no portable printf modifier (Stefan Kost),
+    __xmlRaiseError: remove redundant schannel initialization (Dmitry V. Levin),
+    __xmlRaiseError: do cheap code check early (Dmitry V. Levin)
+  
+   - Cleanups:
+    Cleanups before 2.8.0-rc2 (Daniel Veillard),
+    Avoid an extra operation (Daniel Veillard),
+    Remove vestigial de-ANSI-fication support. (Javier Jardón),
+    autogen.sh: Fix typo (Javier Jardón),
+    Do not use unsigned but unsigned int (Daniel Veillard),
+    Remove two references to u_short (Daniel Veillard),
+    Fix -Wempty-body warning from clang (Nico Weber),
+    Cleanups of lzma support (Daniel Veillard),
+    Augment the list of ignored files (Daniel Veillard),
+    python: remove unused variable (Stefan Kost),
+    python: flag two unused args (Stefan Kost),
+    configure: acconfig.h is deprecated since autoconf-2.50 (Stefan Kost),
+    xpath: remove unused variable (Stefan Kost)
+  
+
+
+2.7.8: Nov 4 2010:
+   -  Features:
+    480323 add code to plug in ICU converters by default (Giuseppe Iuculano),
+    Add xmlSaveOption XML_SAVE_WSNONSIG (Adam Spragg)
+  
+   -  Documentation:
+    Fix devhelp documentation installation (Mike Hommey),
+    Fix web site encoding problems (Daniel Veillard),
+    Fix a couple of typo in HTML parser error messages (Michael Day),
+    Forgot to update the news page for 0.7.7 (Daniel Veillard)
+  
+   -  Portability:
+    607273 Fix python detection on MSys/Windows (LRN),
+    614087 Fix Socket API usage to allow Windows64 compilation (Ozkan Sezer),
+    Fix compilation with Clang (Koop Mast),
+    Fix Win32 build (Rob Richards)
+  
+   -  Bug Fixes:
+    595789 fix a remaining potential Solaris problem (Daniel Veillard),
+    617468 fix progressive HTML parsing with style using "'" (Denis Pauk),
+    616478 Fix xmllint shell write command (Gwenn Kahz),
+    614005 Possible erroneous HTML parsing on unterminated script (Pierre Belzile),
+    627987 Fix XSD IDC errors in imported schemas (Jim Panetta),
+    629325 XPath rounding errors first cleanup (Phil Shafer),
+    630140 fix iso995x encoding error (Daniel Veillard),
+    make sure htmlCtxtReset do reset the disableSAX field (Daniel Veillard),
+    Fix a change of semantic on XPath preceding and following axis (Daniel Veillard),
+    Fix a potential segfault due to weak symbols on pthreads (Mike Hommey),
+    Fix a leak in XPath compilation (Daniel Veillard),
+    Fix the semantic of XPath axis for namespace/attribute context nodes (Daniel Veillard),
+    Avoid a descriptor leak in catalog loading code (Carlo Bramini),
+    Fix a small bug in XPath evaluation code (Marius Wachtler),
+    Fix handling of XML-1.0 XML namespace declaration (Daniel Veillard),
+    Fix errors in XSD double validation check (Csaba Raduly),
+    Fix handling of apos in URIs (Daniel Veillard),
+    xmlTextReaderReadOuterXml should handle DTD (Rob Richards),
+    Autogen.sh needs to create m4 directory (Rob Richards)
+  
+   -  Improvements:
+    606592 update language ID parser to RFC 5646 (Daniel Veillard),
+    Sort python generated stubs (Mike Hommey),
+    Add an HTML parser option to avoid a default doctype (Daniel Veillard)
+  
+   -  Cleanups:
+    618831 don't ship generated files in git (Adrian Bunk),
+    Switch from the obsolete mkinstalldirs to AC_PROG_MKDIR_P (Adrian Bunk),
+    Various cleanups on encoding handling (Daniel Veillard),
+    Fix xmllint to use format=1 for default formatting (Adam Spragg),
+    Force _xmlSaveCtxt.format to be 0 or 1 (Adam Spragg),
+    Cleanup encoding pointer comparison (Nikolay Sivov),
+    Small code cleanup on previous patch (Daniel Veillard)
+  
+
+
+2.7.7: Mar 15 2010:
+   -  Improvements:
+    Adding a --xpath option to xmllint (Daniel Veillard),
+    Make HTML parser non-recursive (Eugene Pimenov)
+  
+   -  Portability:
+    relaxng.c: cast to allow compilation with sun studio 11 (Ben Walton),
+    Fix build failure on Sparc solaris (Roumen Petrov),
+    use autoreconf in autogen.sh (Daniel Veillard),
+    Fix build with mingw (Roumen Petrov),
+    Upgrade some of the configure and autogen (Daniel Veillard),
+    Fix relaxNG tests in runtest for Windows runtest.c: initialize ret (Rob Richards),
+    Fix a const warning in xmlNodeSetBase (Martin Trappel),
+    Fix python generator to not use deprecated xmllib (Daniel Veillard),
+    Update some automake files (Daniel Veillard),
+    598785 Fix nanohttp on Windows (spadix)
+  
+   -  Bug Fixes:
+    libxml violates the zlib interface and crashes (Mark Adler),
+    Fix broken escape behaviour in regexp ranges (Daniel Veillard),
+    Fix  missing win32 libraries in libxml-2.0.pc (Volker Grabsch),
+    Fix detection of python linker flags (Daniel Macks),
+    fix build error in libxml2/python (Paul Smith),
+    ChunkParser: Incorrect decoding of small xml files (Raul Hudea),
+    htmlCheckEncoding doesn't update input-end after shrink (Eugene Pimenov),
+    Fix a missing #ifdef (Daniel Veillard),
+    Fix encoding selection for xmlParseInNodeContext (Daniel Veillard),
+    xmlPreviousElementSibling mistake (François Delyon),
+    608773 add a missing check in xmlGROW (Daniel Veillard),
+    Fix xmlParseInNodeContext for HTML content (Daniel Veillard),
+    Fix lost namespace when copying node * tree.c: reconcile namespace if not found (Rob Richards),
+    Fix some missing commas in HTML element lists (Eugene Pimenov),
+    Correct variable type to unsigned (Nikolay Sivov),
+    Recognize ID attribute in HTML without DOCTYPE (Daniel Veillard),
+    Fix memory leak in xmlXPathEvalExpression() (Martin),
+    Fix an init bug in global.c (Kai Henning),
+    Fix xmlNodeSetBase() comment (Daniel Veillard),
+    Fix broken escape behaviour in regexp ranges (Daniel Veillard),
+    Don't give default HTML boolean attribute values in parser (Daniel Veillard),
+    xmlCtxtResetLastError should reset ctxt-errNo (Daniel Veillard)
+  
+   -  Cleanups:
+    Cleanup a couple of weirdness in HTML parser (Eugene Pimenov)
+  
+
+
 2.7.6: Oct  6 2009:
    -  Bug Fixes:
      Restore thread support in default configuration (Andrew W. Nosenko),
@@ -1325,7 +1955,8 @@ http://www.w3.org/TR/xmlschema-2/
  code, beware, all
 interfaces are likely to change, there is huge holes, it is clearly a work in
 progress and don't even think of putting this code in a production system,
-it's actually not compiled in by default. The real fixes are:   - a couple of bugs or limitations introduced in 2.4.20
+it's actually not compiled in by default. The real fixes are:
+   - a couple of bugs or limitations introduced in 2.4.20
    - patches for Borland C++ and MSC by Igor
    - some fixes on XPath strings and conformance patches by Richard
   Jinks
@@ -1567,7 +2198,8 @@ it's actually not compiled in by default. The real fixes are:   - a couple of bu
 
 
 2.3.9: May 19 2001:
-Lots of bugfixes, and added a basic SGML catalog support:   - HTML push bugfix #54891 and another patch from Jonas Borgström
+Lots of bugfixes, and added a basic SGML catalog support:
+   - HTML push bugfix #54891 and another patch from Jonas Borgstrom
    - some serious speed optimization again
    - some documentation cleanups
    - trying to get better linking on Solaris (-R)
@@ -1809,7 +2441,8 @@ Lots of bugfixes, and added a basic SGML catalog support:   - HTML push bugfix #
     about &#38; charref parsing
    - 2.1.0 also ease the upgrade from libxml v1 to the recent version. it
     also contains numerous fixes and enhancements:
-    added xmlStopParser() to stop parsing
+    
+      added xmlStopParser() to stop parsing
       improved a lot parsing speed when there is large CDATA blocs
       includes XPath patches provided by Picdar Technology
       tried to fix as much as possible DTD validation and namespace
@@ -1817,6 +2450,7 @@ Lots of bugfixes, and added a basic SGML catalog support:   - HTML push bugfix #
       output to a given encoding has been added/tested
       lot of various fixes
     
+  
    - added xmlStopParser() to stop parsing
    - improved a lot parsing speed when there is large CDATA blocs
    - includes XPath patches provided by Picdar Technology
@@ -1865,7 +2499,8 @@ Lots of bugfixes, and added a basic SGML catalog support:   - HTML push bugfix #
     upgrade page
    - Some interfaces may changes (especially a bit about encoding).
    - the updates includes:
-    fix I18N support. ISO-Latin-x/UTF-8/UTF-16 (nearly) seems correctly
+    
+      fix I18N support. ISO-Latin-x/UTF-8/UTF-16 (nearly) seems correctly
         handled now
       Better handling of entities, especially well-formedness checking
         and proper PEref extensions in external subsets
@@ -1874,6 +2509,7 @@ Lots of bugfixes, and added a basic SGML catalog support:   - HTML push bugfix #
       change
         structures to accommodate DOM
     
+  
    - fix I18N support. ISO-Latin-x/UTF-8/UTF-16 (nearly) seems correctly
         handled now
    - Better handling of entities, especially well-formedness checking
index 4adf202..ffef3e1 100644 (file)
@@ -994,12 +994,12 @@ xmlSAX2StartDocument(void *ctx)
 #ifdef LIBXML_HTML_ENABLED
        if (ctxt->myDoc == NULL)
            ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
-       ctxt->myDoc->properties = XML_DOC_HTML;
-       ctxt->myDoc->parseFlags = ctxt->options;
        if (ctxt->myDoc == NULL) {
            xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
            return;
        }
+       ctxt->myDoc->properties = XML_DOC_HTML;
+       ctxt->myDoc->parseFlags = ctxt->options;
 #else
         xmlGenericError(xmlGenericErrorContext,
                "libxml2 built without HTML support\n");
@@ -1078,7 +1078,7 @@ xmlSAX2EndDocument(void *ctx)
     }
 }
 
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 /**
  * xmlSAX2AttributeInternal:
  * @ctx: the user data (XML parser context)
@@ -1177,6 +1177,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
            val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
                                          0,0,0);
            ctxt->depth--;
+           if (val == NULL) {
+               xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
+               if (name != NULL)
+                   xmlFree(name);
+               return;
+           }
        } else {
            val = (xmlChar *) value;
        }
@@ -1822,7 +1828,7 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
 #endif
     nodePop(ctxt);
 }
-#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */
+#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLED || LIBXML_LEGACY_ENABLED */
 
 /*
  * xmlSAX2TextNode:
@@ -2145,12 +2151,14 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
             */
            if (dup == NULL)
                dup = xmlStrndup(value, valueend - value);
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef LIBXML_VALID_ENABLED
            if (xmlValidateNCName(dup, 1) != 0) {
                xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
                      "xml:id : attribute value %s is not an NCName\n",
                            (const char *) dup, NULL);
            }
+#endif
 #endif
            xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
        } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
@@ -2570,6 +2578,10 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
                       (xmlDictOwns(ctxt->dict, lastChild->content))) {
                lastChild->content = xmlStrdup(lastChild->content);
            }
+           if (lastChild->content == NULL) {
+               xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
+               return;
+           }
             if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
                 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
                 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
index d1756c4..6efc7b6 100644 (file)
@@ -565,7 +565,7 @@ xmlBufDump(FILE *file, xmlBufPtr buf) {
  */
 
 xmlChar *
-xmlBufContent(const xmlBufPtr buf)
+xmlBufContent(const xmlBuf *buf)
 {
     if ((!buf) || (buf->error))
         return NULL;
@@ -583,7 +583,7 @@ xmlBufContent(const xmlBufPtr buf)
  */
 
 xmlChar *
-xmlBufEnd(const xmlBufPtr buf)
+xmlBufEnd(xmlBufPtr buf)
 {
     if ((!buf) || (buf->error))
         return NULL;
index e8c7715..ebdc978 100644 (file)
@@ -50,8 +50,8 @@ int xmlBufIsEmpty(const xmlBufPtr buf);
 int xmlBufAddLen(xmlBufPtr buf, size_t len);
 int xmlBufErase(xmlBufPtr buf, size_t len);
 
-/* const xmlChar * xmlBufContent(const xmlBufPtr buf); */
-/* const xmlChar * xmlBufEnd(const xmlBufPtr buf); */
+/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
+/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
 
 xmlChar * xmlBufDetach(xmlBufPtr buf);
 
index afd95b3..ca77f92 100644 (file)
@@ -547,14 +547,15 @@ xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx)
     if (ns->prefix != NULL) {
         xmlOutputBufferWriteString(ctx->buf, " xmlns:");
         xmlOutputBufferWriteString(ctx->buf, (const char *) ns->prefix);
-        xmlOutputBufferWriteString(ctx->buf, "=\"");
+        xmlOutputBufferWriteString(ctx->buf, "=");
     } else {
-        xmlOutputBufferWriteString(ctx->buf, " xmlns=\"");
+        xmlOutputBufferWriteString(ctx->buf, " xmlns=");
     }
     if(ns->href != NULL) {
-       xmlOutputBufferWriteString(ctx->buf, (const char *) ns->href);
+       xmlBufWriteQuotedString(ctx->buf->buffer, ns->href);
+    } else {
+       xmlOutputBufferWriteString(ctx->buf, "\"\"");
     }
-    xmlOutputBufferWriteString(ctx->buf, "\"");
     return (1);
 }
 
index 8e34cd2..5773db3 100644 (file)
@@ -994,6 +994,11 @@ xmlLoadFileContent(const char *filename)
     content = (xmlChar*)xmlMallocAtomic(size + 10);
     if (content == NULL) {
         xmlCatalogErrMemory("allocating catalog data");
+#ifdef HAVE_STAT
+       close(fd);
+#else
+       fclose(fd);
+#endif
         return (NULL);
     }
 #ifdef HAVE_STAT
@@ -3550,8 +3555,8 @@ xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer) {
                xmlGenericError(xmlGenericErrorContext,
                        "Setting catalog preference to SYSTEM\n");
                break;
-           case XML_CATA_PREFER_NONE:
-               break;
+           default:
+               return(ret);
        }
     }
     xmlCatalogDefaultPrefer = prefer;
index b96114a..37ed5d6 100644 (file)
 #define HAVE_VSPRINTF 1
 
 /* Define to 1 if you have the <zlib.h> header file. */
-#define HAVE_ZLIB_H
+#define HAVE_ZLIB_H 1
 
 /* Define to 1 if you have the `_stat' function. */
 #define HAVE__STAT 1
 
 /* Whether __va_copy() is available */
-/* #undef HAVE___VA_COPY */
+#define HAVE___VA_COPY 1
 
 /* Define as const if the declaration of iconv() needs const. */
 /* #undef ICONV_CONST */
 /* #undef SUPPORT_IP6 */
 
 /* Version number of package */
-#define VERSION "2.9.0"
+#define VERSION "2.9.2"
 
 /* Determine what socket length (socklen_t) data type is */
 #define XML_SOCKLEN_T int
 #if defined(_MSC_VER)
 #undef GetModuleHandleA
 #endif
+
+#define SEND_ARG2_CAST
+#define GETHOSTBYNAME_ARG_CAST
index c8efe6a..b05fdff 100644 (file)
@@ -254,10 +254,12 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
            xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL");
            return;
        }
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
         if (xmlValidateName(name, 0)) {
            xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME,
                         "Name is not an NCName '%s'", (const char *) name);
        }
+#endif
        if ((ctxt->dict != NULL) &&
            (!xmlDictOwns(ctxt->dict, name)) &&
             ((ctxt->doc == NULL) ||
@@ -2946,7 +2948,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
         } else if (!strcmp(command, "save")) {
             xmlShellSave(ctxt, arg, NULL, NULL);
         } else if (!strcmp(command, "write")) {
-           if ((arg == NULL) || (arg[0] == 0))
+           if (arg[0] == 0)
                xmlGenericError(xmlGenericErrorContext,
                         "Write command requires a filename argument\n");
            else
@@ -3241,7 +3243,12 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
                 ctxt->node = (xmlNodePtr) ctxt->doc;
             } else {
 #ifdef LIBXML_XPATH_ENABLED
+                int l;
+
                 ctxt->pctxt->node = ctxt->node;
+               l = strlen(arg);
+               if ((l >= 2) && (arg[l - 1] == '/'))
+                   arg[l - 1] = 0;
                 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
 #else
                 list = NULL;
index 85c49d6..8c52884 100644 (file)
@@ -1061,7 +1061,7 @@ extern __typeof (xmlAddNotationDecl) xmlAddNotationDecl__internal_alias __attrib
 #endif
 #endif
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
 #ifdef bottom_tree
 #undef xmlAddPrevSibling
 extern __typeof (xmlAddPrevSibling) xmlAddPrevSibling __attribute((alias("xmlAddPrevSibling__internal_alias")));
@@ -8885,7 +8885,7 @@ extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument__internal_alias __attrib
 #endif
 #endif
 
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef bottom_SAX2
 #undef xmlSAX2EndElement
 extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement __attribute((alias("xmlSAX2EndElement__internal_alias")));
@@ -9131,7 +9131,7 @@ extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument__internal_alias __at
 #endif
 #endif
 
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef bottom_SAX2
 #undef xmlSAX2StartElement
 extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement __attribute((alias("xmlSAX2StartElement__internal_alias")));
@@ -15363,7 +15363,7 @@ extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl__internal_alias
 #endif
 #endif
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 #ifdef bottom_tree
 #undef xmlValidateNCName
 extern __typeof (xmlValidateNCName) xmlValidateNCName __attribute((alias("xmlValidateNCName__internal_alias")));
@@ -16767,6 +16767,18 @@ extern __typeof (xmlXPathNextSelf) xmlXPathNextSelf__internal_alias __attribute(
 #endif
 #endif
 
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeEval
+extern __typeof (xmlXPathNodeEval) xmlXPathNodeEval __attribute((alias("xmlXPathNodeEval__internal_alias")));
+#else
+#ifndef xmlXPathNodeEval
+extern __typeof (xmlXPathNodeEval) xmlXPathNodeEval__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeEval xmlXPathNodeEval__internal_alias
+#endif
+#endif
+#endif
+
 #if defined(LIBXML_XPATH_ENABLED)
 #ifdef bottom_xpath
 #undef xmlXPathNodeLeading
@@ -17271,6 +17283,18 @@ extern __typeof (xmlXPathRoundFunction) xmlXPathRoundFunction__internal_alias __
 #endif
 #endif
 
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSetContextNode
+extern __typeof (xmlXPathSetContextNode) xmlXPathSetContextNode __attribute((alias("xmlXPathSetContextNode__internal_alias")));
+#else
+#ifndef xmlXPathSetContextNode
+extern __typeof (xmlXPathSetContextNode) xmlXPathSetContextNode__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSetContextNode xmlXPathSetContextNode__internal_alias
+#endif
+#endif
+#endif
+
 #if defined(LIBXML_XPATH_ENABLED)
 #ifdef bottom_xpath
 #undef xmlXPathStartsWithFunction
index 7330e90..574e1ae 100644 (file)
@@ -2384,6 +2384,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
     return (written? written : ret);
 }
 
+#ifdef LIBXML_OUTPUT_ENABLED
 /**
  * xmlCharEncOutput:
  * @output: a parser output buffer
@@ -2612,6 +2613,7 @@ retry:
     }
     return(ret);
 }
+#endif
 
 /**
  * xmlCharEncOutFunc:
@@ -2851,14 +2853,25 @@ int
 xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
     int ret = 0;
     int tofree = 0;
+    int i, handler_in_list = 0;
+
     if (handler == NULL) return(-1);
     if (handler->name == NULL) return(-1);
+    if (handlers != NULL) {
+        for (i = 0;i < nbCharEncodingHandler; i++) {
+            if (handler == handlers[i]) {
+               handler_in_list = 1;
+               break;
+           }
+       }
+    }
 #ifdef LIBXML_ICONV_ENABLED
     /*
      * Iconv handlers can be used only once, free the whole block.
      * and the associated icon resources.
      */
-    if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
+    if ((handler_in_list == 0) &&
+        ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
         tofree = 1;
        if (handler->iconv_out != NULL) {
            if (iconv_close(handler->iconv_out))
@@ -2873,7 +2886,8 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
     }
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
-    if ((handler->uconv_out != NULL) || (handler->uconv_in != NULL)) {
+    if ((handler_in_list == 0) &&
+        ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
         tofree = 1;
        if (handler->uconv_out != NULL) {
            closeIcuConverter(handler->uconv_out);
index 5e786a1..c594237 100644 (file)
@@ -502,7 +502,7 @@ xmlGetDtdEntity(xmlDocPtr doc, const xmlChar *name) {
  * Returns A pointer to the entity structure or NULL if not found.
  */
 xmlEntityPtr
-xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
+xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name) {
     xmlEntityPtr cur;
     xmlEntitiesTablePtr table;
 
@@ -783,7 +783,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
  * Returns A newly allocated string with the substitution done.
  */
 xmlChar *
-xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
+xmlEncodeSpecialChars(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlChar *input) {
     const xmlChar *cur = input;
     xmlChar *buffer = NULL;
     xmlChar *out = NULL;
index 0145109..f9a2017 100644 (file)
@@ -984,6 +984,9 @@ xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
        return(NULL);
 
     ret = xmlHashCreate(table->size);
+    if (ret == NULL)
+        return(NULL);
+
     if (table->table) {
        for(i = 0; i < table->size; i++) {
            if (table->table[i].valid == 0)
index 3fc9be5..40cf7df 100644 (file)
@@ -5,6 +5,8 @@
 #define HAVE_STDARG_H
 #define HAVE_MALLOC_H
 #define HAVE_ERRNO_H
+#define SEND_ARG2_CAST
+#define GETHOSTBYNAME_ARG_CAST
 
 #if defined(_WIN32_WCE)
 #undef HAVE_ERRNO_H
@@ -95,7 +97,9 @@ static int isnan (double d) {
 
 #if defined(_MSC_VER)
 #define mkdir(p,m) _mkdir(p)
+#if _MSC_VER < 1900
 #define snprintf _snprintf
+#endif
 #if _MSC_VER < 1500
 #define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
 #endif
index e941cb0..86362bf 100644 (file)
@@ -1151,7 +1151,7 @@ void
 endElement(void *ctx, const xmlChar * name ATTRIBUTE_UNUSED)
 {
     DEPRECATED("endElement")
-        xmlSAX2EndElement(ctx, name);
+    xmlSAX2EndElement(ctx, name);
 }
 
 /**
index 077bfe2..2135ab9 100644 (file)
@@ -775,7 +775,7 @@ xmlNanoFTPSendUser(void *ctx) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        return(res);
@@ -803,7 +803,7 @@ xmlNanoFTPSendPasswd(void *ctx) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        return(res);
@@ -834,7 +834,7 @@ xmlNanoFTPQuit(void *ctx) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        return(res);
@@ -908,6 +908,8 @@ xmlNanoFTPConnect(void *ctx) {
            return (-1);
        }
        if (tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) {
+           if (result)
+               freeaddrinfo (result);
            __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch");
            return (-1);
        }
@@ -928,9 +930,9 @@ xmlNanoFTPConnect(void *ctx) {
 #endif
     {
        if (proxy)
-           hp = gethostbyname (proxy);
+           hp = gethostbyname (GETHOSTBYNAME_ARG_CAST proxy);
        else
-           hp = gethostbyname (ctxt->hostname);
+           hp = gethostbyname (GETHOSTBYNAME_ARG_CAST ctxt->hostname);
        if (hp == NULL) {
            __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname failed");
            return (-1);
@@ -1028,7 +1030,7 @@ xmlNanoFTPConnect(void *ctx) {
 #ifdef DEBUG_FTP
            xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-           res = send(ctxt->controlFd, buf, len, 0);
+           res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
            if (res < 0) {
                __xmlIOErr(XML_FROM_FTP, 0, "send failed");
                closesocket(ctxt->controlFd);
@@ -1050,7 +1052,7 @@ xmlNanoFTPConnect(void *ctx) {
 #ifdef DEBUG_FTP
                    xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-                   res = send(ctxt->controlFd, buf, len, 0);
+                   res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                    if (res < 0) {
                        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
                        closesocket(ctxt->controlFd);
@@ -1091,7 +1093,7 @@ xmlNanoFTPConnect(void *ctx) {
 #ifdef DEBUG_FTP
                xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-               res = send(ctxt->controlFd, buf, len, 0);
+               res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
                    closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
@@ -1122,7 +1124,7 @@ xmlNanoFTPConnect(void *ctx) {
 #ifdef DEBUG_FTP
                xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-               res = send(ctxt->controlFd, buf, len, 0);
+               res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
                    closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
@@ -1144,7 +1146,7 @@ xmlNanoFTPConnect(void *ctx) {
 #ifdef DEBUG_FTP
                xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-               res = send(ctxt->controlFd, buf, len, 0);
+               res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
                if (res < 0) {
                    __xmlIOErr(XML_FROM_FTP, 0, "send failed");
                    closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
@@ -1244,7 +1246,13 @@ xmlNanoFTPConnectTo(const char *server, int port) {
     if (port <= 0)
        return(NULL);
     ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(NULL);
+    if (ctxt == NULL)
+        return(NULL);
     ctxt->hostname = xmlMemStrdup(server);
+    if (ctxt->hostname == NULL) {
+       xmlNanoFTPFreeCtxt(ctxt);
+       return(NULL);
+    }
     if (port != 0)
        ctxt->port = port;
     res = xmlNanoFTPConnect(ctxt);
@@ -1288,7 +1296,7 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        return(res);
@@ -1321,8 +1329,8 @@ xmlNanoFTPDele(void *ctx, const char *file) {
     int len;
     int res;
 
-    if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) || (file == NULL)) return(-1);
-    if (file == NULL) return (0);
+    if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) ||
+        (file == NULL)) return(-1);
 
     /*
      * Expected response code for DELE:
@@ -1339,7 +1347,7 @@ xmlNanoFTPDele(void *ctx, const char *file) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        return(res);
@@ -1411,7 +1419,7 @@ xmlNanoFTPGetConnection(void *ctx) {
 #ifdef DEBUG_FTP
        xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-       res = send(ctxt->controlFd, buf, len, 0);
+       res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
        if (res < 0) {
            __xmlIOErr(XML_FROM_FTP, 0, "send failed");
            closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
@@ -1512,7 +1520,7 @@ xmlNanoFTPGetConnection(void *ctx) {
        xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
 
-       res = send(ctxt->controlFd, buf, len, 0);
+       res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
        if (res < 0) {
            __xmlIOErr(XML_FROM_FTP, 0, "send failed");
            closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
@@ -1749,7 +1757,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
@@ -1844,7 +1852,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
@@ -1864,7 +1872,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
 #ifdef DEBUG_FTP
     xmlGenericError(xmlGenericErrorContext, "%s", buf);
 #endif
-    res = send(ctxt->controlFd, buf, len, 0);
+    res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
     if (res < 0) {
        __xmlIOErr(XML_FROM_FTP, 0, "send failed");
        closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
index 04733b7..4593eb3 100644 (file)
@@ -461,7 +461,7 @@ xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char *xmt_ptr, int outlen)
 
     if ((ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL)) {
         while (total_sent < outlen) {
-            int nsent = send(ctxt->fd, xmt_ptr + total_sent,
+            int nsent = send(ctxt->fd, SEND_ARG2_CAST (xmt_ptr + total_sent),
                              outlen - total_sent, 0);
 
             if (nsent > 0)
@@ -1003,6 +1003,7 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
             0) {
             /* Solaris error code */
             __xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n");
+            closesocket(s);
             return INVALID_SOCKET;
         }
 #endif
@@ -1121,7 +1122,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
 #endif
 #if !defined(HAVE_GETADDRINFO) || !defined(_WIN32)
     {
-       h = gethostbyname (host);
+       h = gethostbyname (GETHOSTBYNAME_ARG_CAST host);
        if (h == NULL) {
 
 /*
@@ -1362,17 +1363,17 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
     xmlNanoHTTPInit();
 
 retry:
-    if (redirURL == NULL)
+    if (redirURL == NULL) {
        ctxt = xmlNanoHTTPNewCtxt(URL);
-    else {
+       if (ctxt == NULL)
+           return(NULL);
+    } else {
        ctxt = xmlNanoHTTPNewCtxt(redirURL);
+       if (ctxt == NULL)
+           return(NULL);
        ctxt->location = xmlMemStrdup(redirURL);
     }
 
-    if ( ctxt == NULL ) {
-       return ( NULL );
-    }
-
     if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
        __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI");
         xmlNanoHTTPFreeCtxt(ctxt);
index ee429f3..1d93967 100644 (file)
@@ -130,6 +130,29 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
         return (0);
     if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
         return (1);
+
+    /*
+     * This may look absurd but is needed to detect
+     * entities problems
+     */
+    if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
+       (ent->content != NULL) && (ent->checked == 0)) {
+       unsigned long oldnbent = ctxt->nbentities;
+       xmlChar *rep;
+
+       ent->checked = 1;
+
+       rep = xmlStringDecodeEntities(ctxt, ent->content,
+                                 XML_SUBSTITUTE_REF, 0, 0, 0);
+
+       ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
+       if (rep != NULL) {
+           if (xmlStrchr(rep, '<'))
+               ent->checked |= 1;
+           xmlFree(rep);
+           rep = NULL;
+       }
+    }
     if (replacement != 0) {
        if (replacement < XML_MAX_TEXT_LENGTH)
            return(0);
@@ -189,9 +212,12 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
             return (0);
     } else {
         /*
-         * strange we got no data for checking just return
+         * strange we got no data for checking
          */
-        return (0);
+       if (((ctxt->lastError.code != XML_ERR_UNDECLARED_ENTITY) &&
+            (ctxt->lastError.code != XML_WAR_UNDECLARED_ENTITY)) ||
+           (ctxt->nbentities <= 10000))
+           return (0);
     }
     xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
     return (1);
@@ -2039,8 +2065,11 @@ static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
        xmlGROW (ctxt);
 
 static void xmlGROW (xmlParserCtxtPtr ctxt) {
-    if ((((ctxt->input->end - ctxt->input->cur) > XML_MAX_LOOKUP_LIMIT) ||
-         ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
+    unsigned long curEnd = ctxt->input->end - ctxt->input->cur;
+    unsigned long curBase = ctxt->input->cur - ctxt->input->base;
+
+    if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) ||
+         (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) &&
          ((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) &&
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
@@ -2106,6 +2135,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
        while (IS_BLANK_CH(*cur)) {
            if (*cur == '\n') {
                ctxt->input->line++; ctxt->input->col = 1;
+           } else {
+               ctxt->input->col++;
            }
            cur++;
            res++;
@@ -2584,6 +2615,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
                                      name, NULL);
                    ctxt->valid = 0;
                }
+               xmlParserEntityCheck(ctxt, 0, NULL, 0);
            } else if (ctxt->input->free != deallocblankswrapper) {
                    input = xmlNewBlanksWrapperInputStream(ctxt, entity);
                    if (xmlPushInput(ctxt, input) < 0)
@@ -2594,6 +2626,23 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
                    xmlChar start[4];
                    xmlCharEncoding enc;
 
+                   /*
+                    * Note: external parameter entities will not be loaded, it
+                    * is not required for a non-validating parser, unless the
+                    * option of validating, or substituting entities were
+                    * given. Doing so is far more secure as the parser will
+                    * only process data coming from the document entity by
+                    * default.
+                    */
+                    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+                       ((ctxt->options & XML_PARSE_NOENT) == 0) &&
+                       ((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
+                       ((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
+                       ((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
+                       (ctxt->replaceEntities == 0) &&
+                       (ctxt->validate == 0))
+                       return;
+
                    /*
                     * handle the extra spaces added before and after
                     * c.f. http://www.w3.org/TR/REC-xml#as-PE
@@ -2737,6 +2786,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
            if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
                (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
                goto int_error;
+           xmlParserEntityCheck(ctxt, 0, ent, 0);
            if (ent != NULL)
                ctxt->nbentities += ent->checked / 2;
            if ((ent != NULL) &&
@@ -2788,6 +2838,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
            ent = xmlParseStringPEReference(ctxt, &str);
            if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
                goto int_error;
+           xmlParserEntityCheck(ctxt, 0, ent, 0);
            if (ent != NULL)
                ctxt->nbentities += ent->checked / 2;
            if (ent != NULL) {
@@ -3404,6 +3455,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
     int len = 0, l;
     int c;
     int count = 0;
+    const xmlChar *end; /* needed because CUR_CHAR() can move cur on \r\n */
 
 #ifdef DEBUG
     nbParseNCNameComplex++;
@@ -3413,6 +3465,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
      * Handler for more complex cases
      */
     GROW;
+    end = ctxt->input->cur;
     c = CUR_CHAR(l);
     if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
        (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {
@@ -3434,12 +3487,14 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
        }
        len += l;
        NEXTL(l);
+       end = ctxt->input->cur;
        c = CUR_CHAR(l);
        if (c == 0) {
            count = 0;
            GROW;
             if (ctxt->instate == XML_PARSER_EOF)
                 return(NULL);
+           end = ctxt->input->cur;
            c = CUR_CHAR(l);
        }
     }
@@ -3448,7 +3503,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
         xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
         return(NULL);
     }
-    return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
+    return(xmlDictLookup(ctxt->dict, end - len, len));
 }
 
 /**
@@ -5075,7 +5130,7 @@ xmlParsePITarget(xmlParserCtxtPtr ctxt) {
     }
     if ((name != NULL) && (xmlStrchr(name, ':') != NULL)) {
        xmlNsErr(ctxt, XML_NS_ERR_COLON,
-                "colon are forbidden from PI names '%s'\n", name, NULL, NULL);
+                "colons are forbidden from PI names '%s'\n", name, NULL, NULL);
     }
     return(name);
 }
@@ -5344,7 +5399,7 @@ xmlParseNotationDecl(xmlParserCtxtPtr ctxt) {
        }
        if (xmlStrchr(name, ':') != NULL) {
            xmlNsErr(ctxt, XML_NS_ERR_COLON,
-                    "colon are forbidden from notation names '%s'\n",
+                    "colons are forbidden from notation names '%s'\n",
                     name, NULL, NULL);
        }
        SKIP_BLANKS;
@@ -5433,7 +5488,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
        }
        if (xmlStrchr(name, ':') != NULL) {
            xmlNsErr(ctxt, XML_NS_ERR_COLON,
-                    "colon are forbidden from entities names '%s'\n",
+                    "colons are forbidden from entities names '%s'\n",
                     name, NULL, NULL);
        }
         skipped = SKIP_BLANKS;
@@ -7286,6 +7341,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                   (ret != XML_WAR_UNDECLARED_ENTITY)) {
            xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
                     "Entity '%s' failed to parse\n", ent->name);
+           xmlParserEntityCheck(ctxt, 0, ent, 0);
        } else if (list != NULL) {
            xmlFreeNodeList(list);
            list = NULL;
@@ -7392,7 +7448,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                /*
                 * We are copying here, make sure there is no abuse
                 */
-               ctxt->sizeentcopy += ent->length;
+               ctxt->sizeentcopy += ent->length + 5;
                if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
                    return;
 
@@ -7440,7 +7496,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
                /*
                 * We are copying here, make sure there is no abuse
                 */
-               ctxt->sizeentcopy += ent->length;
+               ctxt->sizeentcopy += ent->length + 5;
                if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
                    return;
 
@@ -7626,6 +7682,7 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
                ctxt->sax->reference(ctxt->userData, name);
            }
        }
+       xmlParserEntityCheck(ctxt, 0, ent, 0);
        ctxt->valid = 0;
     }
 
@@ -7658,8 +7715,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
     else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
             (ent != NULL) && 
             (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
-       if ((ent->checked & 1) || ((ent->checked == 0) &&
-            (ent->content != NULL) &&(xmlStrchr(ent->content, '<')))) {
+       if (((ent->checked & 1) || (ent->checked == 0)) &&
+            (ent->content != NULL) && (xmlStrchr(ent->content, '<'))) {
            xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
        "'<' in entity '%s' is not allowed in attributes values\n", name);
         }
@@ -7753,7 +7810,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
 
 
     /*
-     * Predefined entites override any extra definition
+     * Predefined entities override any extra definition
      */
     if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
         ent = xmlGetPredefinedEntity(name);
@@ -7819,6 +7876,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
                          "Entity '%s' not defined\n",
                          name);
        }
+       xmlParserEntityCheck(ctxt, 0, ent, 0);
        /* TODO ? check regressions ctxt->valid = 0; */
     }
 
@@ -7978,6 +8036,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
                          name, NULL);
            ctxt->valid = 0;
        }
+       xmlParserEntityCheck(ctxt, 0, NULL, 0);
     } else {
        /*
         * Internal checking in case the entity quest barfed
@@ -8217,6 +8276,7 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
                          name, NULL);
            ctxt->valid = 0;
        }
+       xmlParserEntityCheck(ctxt, 0, NULL, 0);
     } else {
        /*
         * Internal checking in case the entity quest barfed
@@ -8906,9 +8966,12 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
     xmlChar limit = 0;
     const xmlChar *in = NULL, *start, *end, *last;
     xmlChar *ret = NULL;
+    int line, col;
 
     GROW;
     in = (xmlChar *) CUR_PTR;
+    line = ctxt->input->line;
+    col = ctxt->input->col;
     if (*in != '"' && *in != '\'') {
         xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
         return (NULL);
@@ -8921,6 +8984,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
      * pure ASCII.
      */
     limit = *in++;
+    col++;
     end = ctxt->input->end;
     start = in;
     if (in >= end) {
@@ -8940,6 +9004,11 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
        while ((in < end) && (*in != limit) &&
               ((*in == 0x20) || (*in == 0x9) ||
                (*in == 0xA) || (*in == 0xD))) {
+           if (*in == 0xA) {
+               line++; col = 1;
+           } else {
+               col++;
+           }
            in++;
            start = in;
            if (in >= end) {
@@ -8963,6 +9032,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
        }
        while ((in < end) && (*in != limit) && (*in >= 0x20) &&
               (*in <= 0x7f) && (*in != '&') && (*in != '<')) {
+           col++;
            if ((*in++ == 0x20) && (*in == 0x20)) break;
            if (in >= end) {
                const xmlChar *oldbase = ctxt->input->base;
@@ -8991,6 +9061,11 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
        while ((in < end) && (*in != limit) &&
               ((*in == 0x20) || (*in == 0x9) ||
                (*in == 0xA) || (*in == 0xD))) {
+           if (*in == 0xA) {
+               line++, col = 1;
+           } else {
+               col++;
+           }
            in++;
            if (in >= end) {
                const xmlChar *oldbase = ctxt->input->base;
@@ -9023,6 +9098,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
        while ((in < end) && (*in != limit) && (*in >= 0x20) &&
               (*in <= 0x7f) && (*in != '&') && (*in != '<')) {
            in++;
+           col++;
            if (in >= end) {
                const xmlChar *oldbase = ctxt->input->base;
                GROW;
@@ -9052,6 +9128,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
        if (*in != limit) goto need_complex;
     }
     in++;
+    col++;
     if (len != NULL) {
         *len = last - start;
         ret = (xmlChar *) start;
@@ -9060,6 +9137,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
         ret = xmlStrndup(start, last - start);
     }
     CUR_PTR = in;
+    ctxt->input->line = line;
+    ctxt->input->col = col;
     if (alloc) *alloc = 0;
     return ret;
 need_complex:
@@ -9292,6 +9371,12 @@ reparse:
                const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
                xmlURIPtr uri;
 
+                if (URL == NULL) {
+                   xmlErrMemory(ctxt, "dictionary allocation failure");
+                   if ((attvalue != NULL) && (alloc != 0))
+                       xmlFree(attvalue);
+                   return(NULL);
+               }
                 if (*URL != 0) {
                    uri = xmlParseURI((const char *) URL);
                    if (uri == NULL) {
@@ -9335,6 +9420,13 @@ reparse:
                    if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
 skip_default_ns:
                if (alloc != 0) xmlFree(attvalue);
+               if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
+                   break;
+               if (!IS_BLANK_CH(RAW)) {
+                   xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
+                                  "attributes construct error\n");
+                   break;
+               }
                SKIP_BLANKS;
                continue;
            }
@@ -9408,6 +9500,13 @@ skip_default_ns:
                    if (nsPush(ctxt, attname, URL) > 0) nbNs++;
 skip_ns:
                if (alloc != 0) xmlFree(attvalue);
+               if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
+                   break;
+               if (!IS_BLANK_CH(RAW)) {
+                   xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
+                                  "attributes construct error\n");
+                   break;
+               }
                SKIP_BLANKS;
                if (ctxt->input->base != base) goto base_changed;
                continue;
@@ -9668,9 +9767,11 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
     if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
         if (ctxt->input->cur[tlen] == '>') {
            ctxt->input->cur += tlen + 1;
+           ctxt->input->col += tlen + 1;
            goto done;
        }
        ctxt->input->cur += tlen;
+       ctxt->input->col += tlen;
        name = (xmlChar*)1;
     } else {
        if (prefix == NULL)
@@ -10311,8 +10412,10 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
         /*
          * Non standard parsing, allowing the user to ignore encoding
          */
-        if (ctxt->options & XML_PARSE_IGNORE_ENC)
-            return(encoding);
+        if (ctxt->options & XML_PARSE_IGNORE_ENC) {
+           xmlFree((xmlChar *) encoding);
+            return(NULL);
+       }
 
        /*
         * UTF-16 encoding stwich has already taken place at this stage,
@@ -10681,6 +10784,10 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
         ctxt->sax->startDocument(ctxt->userData);
     if (ctxt->instate == XML_PARSER_EOF)
        return(-1);
+    if ((ctxt->myDoc != NULL) && (ctxt->input != NULL) &&
+        (ctxt->input->buf != NULL) && (ctxt->input->buf->compressed >= 0)) {
+       ctxt->myDoc->compression = ctxt->input->buf->compressed;
+    }
 
     /*
      * The Misc part of the Prolog
@@ -12591,6 +12698,9 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
        return(NULL);
     }
 
+    /* We are loading a DTD */
+    ctxt->options |= XML_PARSE_DTDLOAD;
+
     /*
      * Set-up the SAX context
      */
@@ -12718,6 +12828,9 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
        return(NULL);
     }
 
+    /* We are loading a DTD */
+    ctxt->options |= XML_PARSE_DTDLOAD;
+
     /*
      * Set-up the SAX context
      */
@@ -13607,7 +13720,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
            xmlFree((xmlChar *) ctxt->encoding);
         ctxt->encoding = xmlStrdup((const xmlChar *) doc->encoding);
 
-        hdlr = xmlFindCharEncodingHandler(doc->encoding);
+        hdlr = xmlFindCharEncodingHandler((const char *) doc->encoding);
         if (hdlr != NULL) {
             xmlSwitchToEncoding(ctxt, hdlr);
        } else {
@@ -13618,6 +13731,8 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
     xmlCtxtUseOptionsInternal(ctxt, options, NULL);
     xmlDetectSAX2(ctxt);
     ctxt->myDoc = doc;
+    /* parsing in context, i.e. as within existing content */
+    ctxt->instate = XML_PARSER_CONTENT;
 
     fake = xmlNewComment(NULL);
     if (fake == NULL) {
@@ -13653,7 +13768,6 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
            }
            cur = cur->parent;
        }
-       ctxt->instate = XML_PARSER_CONTENT;
     }
 
     if ((ctxt->validate) || (ctxt->replaceEntities != 0)) {
@@ -14715,6 +14829,9 @@ xmlInitParser(void) {
 #endif
 #ifdef LIBXML_XPATH_ENABLED
        xmlXPathInit();
+#endif
+#ifdef LIBXML_CATALOG_ENABLED
+        xmlInitializeCatalog();
 #endif
        xmlParserInitialized = 1;
 #ifdef LIBXML_THREAD_ENABLED
@@ -14763,8 +14880,8 @@ xmlCleanupParser(void) {
     xmlSchemaCleanupTypes();
     xmlRelaxNGCleanupTypes();
 #endif
-    xmlCleanupGlobals();
     xmlResetLastError();
+    xmlCleanupGlobals();
     xmlCleanupThreads(); /* must be last if called not from the main thread */
     xmlCleanupMemory();
     xmlParserInitialized = 0;
@@ -15213,6 +15330,7 @@ xmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int optio
 
     if (cur == NULL)
         return (NULL);
+    xmlInitParser();
 
     ctxt = xmlCreateDocParserCtxt(cur);
     if (ctxt == NULL)
@@ -15235,6 +15353,7 @@ xmlReadFile(const char *filename, const char *encoding, int options)
 {
     xmlParserCtxtPtr ctxt;
 
+    xmlInitParser();
     ctxt = xmlCreateURLParserCtxt(filename, options);
     if (ctxt == NULL)
         return (NULL);
@@ -15258,6 +15377,7 @@ xmlReadMemory(const char *buffer, int size, const char *URL, const char *encodin
 {
     xmlParserCtxtPtr ctxt;
 
+    xmlInitParser();
     ctxt = xmlCreateMemoryParserCtxt(buffer, size);
     if (ctxt == NULL)
         return (NULL);
@@ -15286,6 +15406,7 @@ xmlReadFd(int fd, const char *URL, const char *encoding, int options)
 
     if (fd < 0)
         return (NULL);
+    xmlInitParser();
 
     input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
     if (input == NULL)
@@ -15329,6 +15450,7 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
 
     if (ioread == NULL)
         return (NULL);
+    xmlInitParser();
 
     input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
                                          XML_CHAR_ENCODING_NONE);
@@ -15375,6 +15497,7 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     xmlCtxtReset(ctxt);
 
@@ -15408,6 +15531,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     xmlCtxtReset(ctxt);
 
@@ -15444,6 +15568,7 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
         return (NULL);
     if (buffer == NULL)
         return (NULL);
+    xmlInitParser();
 
     xmlCtxtReset(ctxt);
 
@@ -15488,6 +15613,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     xmlCtxtReset(ctxt);
 
@@ -15533,6 +15659,7 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
         return (NULL);
     if (ctxt == NULL)
         return (NULL);
+    xmlInitParser();
 
     xmlCtxtReset(ctxt);
 
index f8a7041..df204fd 100644 (file)
@@ -1691,12 +1691,20 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
     ctxt->nsWellFormed = 1;
     ctxt->valid = 1;
     ctxt->loadsubset = xmlLoadExtDtdDefaultValue;
+    if (ctxt->loadsubset) {
+        ctxt->options |= XML_PARSE_DTDLOAD;
+    }
     ctxt->validate = xmlDoValidityCheckingDefaultValue;
     ctxt->pedantic = xmlPedanticParserDefaultValue;
+    if (ctxt->pedantic) {
+        ctxt->options |= XML_PARSE_PEDANTIC;
+    }
     ctxt->linenumbers = xmlLineNumbersDefaultValue;
     ctxt->keepBlanks = xmlKeepBlanksDefaultValue;
-    if (ctxt->keepBlanks == 0)
+    if (ctxt->keepBlanks == 0) {
        ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
+       ctxt->options |= XML_PARSE_NOBLANKS;
+    }
 
     ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
     ctxt->vctxt.userData = ctxt;
@@ -1708,8 +1716,12 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
        else
            ctxt->vctxt.warning = xmlParserValidityWarning;
        ctxt->vctxt.nodeMax = 0;
+        ctxt->options |= XML_PARSE_DTDVALID;
     }
     ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
+    if (ctxt->replaceEntities) {
+        ctxt->options |= XML_PARSE_NOENT;
+    }
     ctxt->record_info = 0;
     ctxt->nbChars = 0;
     ctxt->checkIndex = 0;
@@ -1990,7 +2002,8 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
 
     /* Otherwise, we need to add new node to buffer */
     else {
-        if (ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) {
+        if ((ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) ||
+           (ctxt->node_seq.buffer == NULL)) {
             xmlParserNodeInfo *tmp_buffer;
             unsigned int byte_size;
 
index 370e314..8d88e95 100644 (file)
@@ -1095,7 +1095,7 @@ xmlRelaxNGAddStates(xmlRelaxNGValidCtxtPtr ctxt,
 {
     int i;
 
-    if (state == NULL) {
+    if (state == NULL || states == NULL) {
         return (-1);
     }
     if (states->nbState >= states->maxState) {
@@ -2595,13 +2595,10 @@ xmlRelaxNGSchemaTypeCompare(void *data ATTRIBUTE_UNUSED,
     }
     ret = xmlSchemaValPredefTypeNode(typ, value2, &res2, ctxt2);
     if (ret != 0) {
-       if ((comp1 == NULL) && (res1 != NULL))
+       if (res1 != (xmlSchemaValPtr) comp1)
            xmlSchemaFreeValue(res1);
         return (-1);
     }
-    if (res1 == NULL) {
-        return (-1);
-    }
     ret = xmlSchemaCompareValues(res1, res2);
     if (res1 != (xmlSchemaValPtr) comp1)
         xmlSchemaFreeValue(res1);
@@ -6603,7 +6600,7 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
     }
 
     /*
-     * Apply 4.17 mergingd rules to defines and starts
+     * Apply 4.17 merging rules to defines and starts
      */
     xmlRelaxNGCombineStart(ctxt, ret);
     if (ret->defs != NULL) {
@@ -6655,12 +6652,17 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
     ctxt->define = NULL;
     if (IS_RELAXNG(node, "grammar")) {
         schema->topgrammar = xmlRelaxNGParseGrammar(ctxt, node->children);
+        if (schema->topgrammar == NULL) {
+            xmlRelaxNGFree(schema);
+            return (NULL);
+        }
     } else {
         xmlRelaxNGGrammarPtr tmp, ret;
 
         schema->topgrammar = ret = xmlRelaxNGNewGrammar(ctxt);
         if (schema->topgrammar == NULL) {
-            return (schema);
+            xmlRelaxNGFree(schema);
+            return (NULL);
         }
         /*
          * Link the new grammar in the tree
@@ -7317,7 +7319,7 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
                     }
                 }
                 /*
-                 * Thisd is not an else since "include" is transformed
+                 * This is not an else since "include" is transformed
                  * into a div
                  */
                 if (xmlStrEqual(cur->name, BAD_CAST "div")) {
@@ -7346,13 +7348,13 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
                     if (ns != NULL)
                         xmlFree(ns);
                    /*
-                    * Since we are about to delete cur, if it's nsDef is non-NULL we
+                    * Since we are about to delete cur, if its nsDef is non-NULL we
                     * need to preserve it (it contains the ns definitions for the
                     * children we just moved).  We'll just stick it on to the end
                     * of cur->parent's list, since it's never going to be re-serialized
                     * (bug 143738).
                     */
-                   if (cur->nsDef != NULL) {
+                   if ((cur->nsDef != NULL) && (cur->parent != NULL)) {
                        xmlNsPtr parDef = (xmlNsPtr)&cur->parent->nsDef;
                        while (parDef->next != NULL)
                            parDef = parDef->next;
@@ -7370,7 +7372,8 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
         else if ((cur->type == XML_TEXT_NODE) ||
                  (cur->type == XML_CDATA_SECTION_NODE)) {
             if (IS_BLANK_NODE(cur)) {
-                if (cur->parent->type == XML_ELEMENT_NODE) {
+                if ((cur->parent != NULL) &&
+                   (cur->parent->type == XML_ELEMENT_NODE)) {
                     if ((!xmlStrEqual(cur->parent->name, BAD_CAST "value"))
                         &&
                         (!xmlStrEqual
@@ -9050,6 +9053,19 @@ xmlRelaxNGAttributeMatch(xmlRelaxNGValidCtxtPtr ctxt,
                 return (ret);
             list = list->next;
         }
+    } else if (define->type == XML_RELAXNG_CHOICE) {
+        xmlRelaxNGDefinePtr list;
+
+        list = define->nameClass;
+        while (list != NULL) {
+            ret = xmlRelaxNGAttributeMatch(ctxt, list, prop);
+            if (ret == 1)
+                return (1);
+            if (ret < 0)
+                return (ret);
+            list = list->next;
+        }
+        return (0);
     } else {
     TODO}
     return (1);
@@ -9409,6 +9425,10 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
     oldstate = ctxt->state;
     for (i = 0; i < nbgroups; i++) {
         ctxt->state = xmlRelaxNGCopyValidState(ctxt, oldstate);
+       if (ctxt->state == NULL) {
+           ret = -1;
+           break;
+       }
         group = partitions->groups[i];
         if (lasts[i] != NULL) {
             last = lasts[i]->next;
index 537b868..eb4befe 100644 (file)
@@ -165,8 +165,10 @@ struct _xmlSchematronValidCtxt {
 
     FILE *outputFile;          /* if using XML_SCHEMATRON_OUT_FILE */
     xmlBufferPtr outputBuffer; /* if using XML_SCHEMATRON_OUT_BUFFER */
+#ifdef LIBXML_OUTPUT_ENABLED
     xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */
     xmlOutputCloseCallback  ioclose;
+#endif
     void *ioctx;
 
     /* error reporting data */
index 0d7fe52..c0188f2 100644 (file)
@@ -378,7 +378,7 @@ xmlRMutexLock(xmlRMutexPtr tok)
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-    ++tok->count;
+    tok->count++;
 #elif defined HAVE_BEOS_THREADS
     if (tok->lock->tid == find_thread(NULL)) {
         tok->count++;
@@ -414,8 +414,10 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
     }
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
-    if (!--tok->count)
+    if (tok->count > 0) {
         LeaveCriticalSection(&tok->cs);
+       tok->count--;
+    }
 #elif defined HAVE_BEOS_THREADS
     if (tok->lock->tid == find_thread(NULL)) {
         tok->count--;
index 99697a0..efa3aab 100644 (file)
@@ -61,12 +61,12 @@ int clzll(uint64_t x) /* {{{ */
 
   if (x == 0) return(64);
   n = 0;
-  if (x <= 0x00000000FFFFFFFFL) {n = n + 32; x = x << 32;}
-  if (x <= 0x0000FFFFFFFFFFFFL) {n = n + 16; x = x << 16;}
-  if (x <= 0x00FFFFFFFFFFFFFFL) {n = n + 8; x = x << 8;}
-  if (x <= 0x0FFFFFFFFFFFFFFFL) {n = n + 4; x = x << 4;}
-  if (x <= 0x3FFFFFFFFFFFFFFFL) {n = n + 2; x = x << 2;}
-  if (x <= 0x7FFFFFFFFFFFFFFFL) {n = n + 1;}
+  if (x <= MK_UINT64(0x00000000FFFFFFFF)) {n = n + 32; x = x << 32;}
+  if (x <= MK_UINT64(0x0000FFFFFFFFFFFF)) {n = n + 16; x = x << 16;}
+  if (x <= MK_UINT64(0x00FFFFFFFFFFFFFF)) {n = n + 8; x = x << 8;}
+  if (x <= MK_UINT64(0x0FFFFFFFFFFFFFFF)) {n = n + 4; x = x << 4;}
+  if (x <= MK_UINT64(0x3FFFFFFFFFFFFFFF)) {n = n + 2; x = x << 2;}
+  if (x <= MK_UINT64(0x7FFFFFFFFFFFFFFF)) {n = n + 1;}
   return n;
 }
 /* }}} */
index 7e5af26..307782c 100644 (file)
@@ -55,7 +55,7 @@ int __xmlRegisterCallbacks = 0;
 static xmlNsPtr
 xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
 
-static xmlChar* xmlGetPropNodeValueInternal(xmlAttrPtr prop);
+static xmlChar* xmlGetPropNodeValueInternal(const xmlAttr *prop);
 
 /************************************************************************
  *                                                                     *
@@ -160,7 +160,7 @@ static int xmlCheckDTD = 1;
  * Returns A pointer to the entity structure or NULL if not found.
  */
 static xmlEntityPtr
-xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
+xmlGetEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
     xmlEntitiesTablePtr table;
 
     if((dtd != NULL) && (dtd->entities != NULL)) {
@@ -181,7 +181,7 @@ xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
  * Returns A pointer to the entity structure or NULL if not found.
  */
 static xmlEntityPtr
-xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
+xmlGetParameterEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
     xmlEntitiesTablePtr table;
 
     if ((dtd != NULL) && (dtd->pentities != NULL)) {
@@ -352,7 +352,7 @@ xmlSplitQName3(const xmlChar *name, int *len) {
 
 #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
 /**
  * xmlValidateNCName:
  * @value: the value to check
@@ -717,8 +717,11 @@ xmlGetBufferAllocationScheme(void) {
  * Creation of a new Namespace. This function will refuse to create
  * a namespace with a similar prefix than an existing one present on this
  * node.
+ * Note that for a default namespace, @prefix should be NULL.
+ *
  * We use href==NULL in the case of an element creation where the namespace
  * was not defined.
+ *
  * Returns a new namespace pointer or NULL
  */
 xmlNsPtr
@@ -803,7 +806,9 @@ xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
 #endif
        return;
     }
-    node->ns = ns;
+    if ((node->type == XML_ELEMENT_NODE) ||
+        (node->type == XML_ATTRIBUTE_NODE))
+       node->ns = ns;
 }
 
 /**
@@ -911,7 +916,7 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
  */
 
 xmlDtdPtr
-xmlGetIntSubset(xmlDocPtr doc) {
+xmlGetIntSubset(const xmlDoc *doc) {
     xmlNodePtr cur;
 
     if (doc == NULL)
@@ -1261,7 +1266,7 @@ xmlFreeDoc(xmlDocPtr cur) {
  * Returns a pointer to the first child
  */
 xmlNodePtr
-xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
+xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
     xmlNodePtr ret = NULL, last = NULL;
     xmlNodePtr node;
     xmlChar *val;
@@ -1469,7 +1474,7 @@ out:
  * Returns a pointer to the first child
  */
 xmlNodePtr
-xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
+xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
     xmlNodePtr ret = NULL, last = NULL;
     xmlNodePtr node;
     xmlChar *val;
@@ -1657,9 +1662,9 @@ out:
  * Returns a pointer to the string copy, the caller must free it with xmlFree().
  */
 xmlChar *
-xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
+xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
 {
-    xmlNodePtr node = list;
+    const xmlNode *node = list;
     xmlChar *ret = NULL;
     xmlEntityPtr ent;
     int attr;
@@ -1747,9 +1752,9 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
  * Returns a pointer to the string copy, the caller must free it with xmlFree().
  */
 xmlChar *
-xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine)
+xmlNodeListGetRawString(const xmlDoc *doc, const xmlNode *list, int inLine)
 {
-    xmlNodePtr node = list;
+    const xmlNode *node = list;
     xmlChar *ret = NULL;
     xmlEntityPtr ent;
 
@@ -2578,7 +2583,7 @@ xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) {
  * Returns a pointer to the new node object.
  */
 xmlNodePtr
-xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
+xmlNewReference(const xmlDoc *doc, const xmlChar *name) {
     xmlNodePtr cur;
     xmlEntityPtr ent;
 
@@ -2596,7 +2601,7 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
     memset(cur, 0, sizeof(xmlNode));
     cur->type = XML_ENTITY_REF_NODE;
 
-    cur->doc = doc;
+    cur->doc = (xmlDoc *)doc;
     if (name[0] == '&') {
         int len;
         name++;
@@ -2634,11 +2639,11 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
  * Returns a pointer to the new node object.
  */
 xmlNodePtr
-xmlNewDocText(xmlDocPtr doc, const xmlChar *content) {
+xmlNewDocText(const xmlDoc *doc, const xmlChar *content) {
     xmlNodePtr cur;
 
     cur = xmlNewText(content);
-    if (cur != NULL) cur->doc = doc;
+    if (cur != NULL) cur->doc = (xmlDoc *)doc;
     return(cur);
 }
 
@@ -3034,7 +3039,7 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
 }
 
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
-    defined(LIBXML_SCHEMAS_ENABLED)
+    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
 /**
  * xmlAddPrevSibling:
  * @cur:  the child node
@@ -3412,7 +3417,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
  * Returns the last child or NULL if none.
  */
 xmlNodePtr
-xmlGetLastChild(xmlNodePtr parent) {
+xmlGetLastChild(const xmlNode *parent) {
     if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
 #ifdef DEBUG_TREE
         xmlGenericError(xmlGenericErrorContext,
@@ -3451,6 +3456,7 @@ xmlChildElementCount(xmlNodePtr parent) {
         case XML_ELEMENT_NODE:
         case XML_ENTITY_NODE:
         case XML_DOCUMENT_NODE:
+        case XML_DOCUMENT_FRAG_NODE:
         case XML_HTML_DOCUMENT_NODE:
             cur = parent->children;
             break;
@@ -3486,6 +3492,7 @@ xmlFirstElementChild(xmlNodePtr parent) {
         case XML_ELEMENT_NODE:
         case XML_ENTITY_NODE:
         case XML_DOCUMENT_NODE:
+        case XML_DOCUMENT_FRAG_NODE:
         case XML_HTML_DOCUMENT_NODE:
             cur = parent->children;
             break;
@@ -3521,6 +3528,7 @@ xmlLastElementChild(xmlNodePtr parent) {
         case XML_ELEMENT_NODE:
         case XML_ENTITY_NODE:
         case XML_DOCUMENT_NODE:
+        case XML_DOCUMENT_FRAG_NODE:
         case XML_HTML_DOCUMENT_NODE:
             cur = parent->last;
             break;
@@ -4128,7 +4136,7 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
  */
 
 static xmlNodePtr
-xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
+xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
                   int extended) {
     xmlNodePtr ret;
 
@@ -4294,6 +4302,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
            }
            if (doc->intSubset == NULL) {
                q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
+               if (q == NULL) return(NULL);
                q->doc = doc;
                q->parent = parent;
                doc->intSubset = (xmlDtdPtr) q;
@@ -4305,6 +4314,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
        } else
 #endif /* LIBXML_TREE_ENABLED */
            q = xmlStaticCopyNode(node, doc, parent, 1);
+       if (q == NULL) return(NULL);
        if (ret == NULL) {
            q->prev = NULL;
            ret = p = q;
@@ -4331,7 +4341,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
  * Returns: a new #xmlNodePtr, or NULL in case of error.
  */
 xmlNodePtr
-xmlCopyNode(const xmlNodePtr node, int extended) {
+xmlCopyNode(xmlNodePtr node, int extended) {
     xmlNodePtr ret;
 
     ret = xmlStaticCopyNode(node, NULL, NULL, extended);
@@ -4351,7 +4361,7 @@ xmlCopyNode(const xmlNodePtr node, int extended) {
  * Returns: a new #xmlNodePtr, or NULL in case of error.
  */
 xmlNodePtr
-xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended) {
+xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int extended) {
     xmlNodePtr ret;
 
     ret = xmlStaticCopyNode(node, doc, NULL, extended);
@@ -4367,7 +4377,7 @@ xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended) {
  *
  * Returns: a new #xmlNodePtr, or NULL in case of error.
  */
-xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, const xmlNodePtr node) {
+xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, xmlNodePtr node) {
     xmlNodePtr ret = xmlStaticCopyNodeList(node, doc, NULL);
     return(ret);
 }
@@ -4381,7 +4391,7 @@ xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, const xmlNodePtr node) {
  *
  * Returns: a new #xmlNodePtr, or NULL in case of error.
  */
-xmlNodePtr xmlCopyNodeList(const xmlNodePtr node) {
+xmlNodePtr xmlCopyNodeList(xmlNodePtr node) {
     xmlNodePtr ret = xmlStaticCopyNodeList(node, NULL, NULL);
     return(ret);
 }
@@ -4507,6 +4517,10 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
 #ifdef LIBXML_TREE_ENABLED
     if (doc->intSubset != NULL) {
         ret->intSubset = xmlCopyDtd(doc->intSubset);
+       if (ret->intSubset == NULL) {
+           xmlFreeDoc(ret);
+           return(NULL);
+       }
        xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret);
        ret->intSubset->parent = ret;
     }
@@ -4547,7 +4561,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
  * Returns the line number if successful, -1 otherwise
  */
 static long
-xmlGetLineNoInternal(xmlNodePtr node, int depth)
+xmlGetLineNoInternal(const xmlNode *node, int depth)
 {
     long result = -1;
 
@@ -4597,7 +4611,7 @@ xmlGetLineNoInternal(xmlNodePtr node, int depth)
  * Returns the line number if successful, -1 otherwise
  */
 long
-xmlGetLineNo(xmlNodePtr node)
+xmlGetLineNo(const xmlNode *node)
 {
     return(xmlGetLineNoInternal(node, 0));
 }
@@ -4613,9 +4627,9 @@ xmlGetLineNo(xmlNodePtr node)
  *     the returned string
  */
 xmlChar *
-xmlGetNodePath(xmlNodePtr node)
+xmlGetNodePath(const xmlNode *node)
 {
-    xmlNodePtr cur, tmp, next;
+    const xmlNode *cur, *tmp, *next;
     xmlChar *buffer = NULL, *temp;
     size_t buf_len;
     xmlChar *buf;
@@ -4859,7 +4873,7 @@ xmlGetNodePath(xmlNodePtr node)
  * Returns the #xmlNodePtr for the root or NULL
  */
 xmlNodePtr
-xmlDocGetRootElement(xmlDocPtr doc) {
+xmlDocGetRootElement(const xmlDoc *doc) {
     xmlNodePtr ret;
 
     if (doc == NULL) return(NULL);
@@ -4973,7 +4987,7 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlNodeGetLang(xmlNodePtr cur) {
+xmlNodeGetLang(const xmlNode *cur) {
     xmlChar *lang;
 
     if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
@@ -5054,7 +5068,7 @@ xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
  * Returns -1 if xml:space is not inherited, 0 if "default", 1 if "preserve"
  */
 int
-xmlNodeGetSpacePreserve(xmlNodePtr cur) {
+xmlNodeGetSpacePreserve(const xmlNode *cur) {
     xmlChar *space;
 
     if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE))
@@ -5089,6 +5103,7 @@ void
 xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
     xmlDocPtr doc;
     xmlDictPtr dict;
+    const xmlChar *freeme = NULL;
 
     if (cur == NULL) return;
     if (name == NULL) return;
@@ -5126,12 +5141,16 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
         dict = NULL;
     if (dict != NULL) {
         if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
-           xmlFree((xmlChar *) cur->name);
+           freeme = cur->name;
        cur->name = xmlDictLookup(dict, name, -1);
     } else {
-       if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
+       if (cur->name != NULL)
+           freeme = cur->name;
        cur->name = xmlStrdup(name);
     }
+
+    if (freeme)
+        xmlFree((xmlChar *) freeme);
 }
 #endif
 
@@ -5219,7 +5238,7 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
+xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur) {
     xmlChar *oldbase = NULL;
     xmlChar *base, *newbase;
 
@@ -5304,7 +5323,7 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
  * Returns 0 in case of success and -1 in case of error.
  */
 int
-xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
+xmlNodeBufGetContent(xmlBufferPtr buffer, const xmlNode *cur)
 {
     xmlBufPtr buf;
     int ret;
@@ -5327,12 +5346,12 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
  * directly by this node if it's a TEXT node or the aggregate string
  * of the values carried by this node child's (TEXT and ENTITY_REF).
  * Entity references are substituted.
- * Fills up the buffer @buffer with this value
+ * Fills up the buffer @buf with this value
  *
  * Returns 0 in case of success and -1 in case of error.
  */
 int
-xmlBufGetNodeContent(xmlBufPtr buf, xmlNodePtr cur)
+xmlBufGetNodeContent(xmlBufPtr buf, const xmlNode *cur)
 {
     if ((cur == NULL) || (buf == NULL)) return(-1);
     switch (cur->type) {
@@ -5342,7 +5361,7 @@ xmlBufGetNodeContent(xmlBufPtr buf, xmlNodePtr cur)
             break;
         case XML_DOCUMENT_FRAG_NODE:
         case XML_ELEMENT_NODE:{
-                xmlNodePtr tmp = cur;
+                const xmlNode *tmp = cur;
 
                 while (tmp != NULL) {
                     switch (tmp->type) {
@@ -5473,7 +5492,7 @@ xmlBufGetNodeContent(xmlBufPtr buf, xmlNodePtr cur)
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlNodeGetContent(xmlNodePtr cur)
+xmlNodeGetContent(const xmlNode *cur)
 {
     if (cur == NULL)
         return (NULL);
@@ -5853,7 +5872,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
  *         namespace if defined
  */
 xmlNsPtr *
-xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
+xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node)
 {
     xmlNsPtr cur;
     xmlNsPtr *ret = NULL;
@@ -5960,7 +5979,7 @@ xmlNsPtr
 xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
 
     xmlNsPtr cur;
-    xmlNodePtr orig = node;
+    const xmlNode *orig = node;
 
     if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) return(NULL);
     if ((nameSpace != NULL) &&
@@ -6429,7 +6448,7 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
 #endif /* LIBXML_TREE_ENABLED */
 
 static xmlAttrPtr
-xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
+xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name,
                       const xmlChar *nsName, int useDTD)
 {
     xmlAttrPtr prop;
@@ -6543,7 +6562,7 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
 }
 
 static xmlChar*
-xmlGetPropNodeValueInternal(xmlAttrPtr prop)
+xmlGetPropNodeValueInternal(const xmlAttr *prop)
 {
     if (prop == NULL)
        return(NULL);
@@ -6589,7 +6608,7 @@ xmlGetPropNodeValueInternal(xmlAttrPtr prop)
  *         neither was found.
  */
 xmlAttrPtr
-xmlHasProp(xmlNodePtr node, const xmlChar *name) {
+xmlHasProp(const xmlNode *node, const xmlChar *name) {
     xmlAttrPtr prop;
     xmlDocPtr doc;
 
@@ -6644,7 +6663,7 @@ xmlHasProp(xmlNodePtr node, const xmlChar *name) {
  *     if neither was found.
  */
 xmlAttrPtr
-xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
+xmlHasNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) {
 
     return(xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD));
 }
@@ -6666,7 +6685,7 @@ xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlGetProp(xmlNodePtr node, const xmlChar *name) {
+xmlGetProp(const xmlNode *node, const xmlChar *name) {
     xmlAttrPtr prop;
 
     prop = xmlHasProp(node, name);
@@ -6691,7 +6710,7 @@ xmlGetProp(xmlNodePtr node, const xmlChar *name) {
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
+xmlGetNoNsProp(const xmlNode *node, const xmlChar *name) {
     xmlAttrPtr prop;
 
     prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD);
@@ -6716,7 +6735,7 @@ xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
  *     It's up to the caller to free the memory with xmlFree().
  */
 xmlChar *
-xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
+xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) {
     xmlAttrPtr prop;
 
     prop = xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD);
@@ -6881,7 +6900,7 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
  * Returns 1 yes, 0 no
  */
 int
-xmlNodeIsText(xmlNodePtr node) {
+xmlNodeIsText(const xmlNode *node) {
     if (node == NULL) return(0);
 
     if (node->type == XML_TEXT_NODE) return(1);
@@ -6898,7 +6917,7 @@ xmlNodeIsText(xmlNodePtr node) {
  * Returns 1 yes, 0 no
  */
 int
-xmlIsBlankNode(xmlNodePtr node) {
+xmlIsBlankNode(const xmlNode *node) {
     const xmlChar *cur;
     if (node == NULL) return(0);
 
@@ -7301,7 +7320,7 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
  */
 
 const xmlChar *
-xmlBufferContent(const xmlBufferPtr buf)
+xmlBufferContent(const xmlBuffer *buf)
 {
     if(!buf)
         return NULL;
@@ -7319,7 +7338,7 @@ xmlBufferContent(const xmlBufferPtr buf)
  */
 
 int
-xmlBufferLength(const xmlBufferPtr buf)
+xmlBufferLength(const xmlBuffer *buf)
 {
     if(!buf)
         return 0;
@@ -7703,7 +7722,7 @@ xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
  * Returns 0 (uncompressed) to 9 (max compression)
  */
 int
-xmlGetDocCompressMode (xmlDocPtr doc) {
+xmlGetDocCompressMode (const xmlDoc *doc) {
     if (doc == NULL) return(-1);
     return(doc->compression);
 }
@@ -7894,8 +7913,7 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
        map->first->prev = ret;
        ret->next = map->first;
        map->first = ret;
-    } else
-       return(NULL);
+    }
 
     ret->oldNs = oldNs;
     ret->newNs = newNs;
@@ -7955,7 +7973,7 @@ xmlDOMWrapStoreNs(xmlDocPtr doc,
 *
 * Allocates and initializes a new DOM-wrapper context.
 *
-* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror.
+* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal error.
 */
 xmlDOMWrapCtxtPtr
 xmlDOMWrapNewCtxt(void)
@@ -9780,7 +9798,8 @@ leave_node:
            if (clone->parent != NULL)
                clone->parent->last = clone;
            clone = clone->parent;
-           parentClone = clone->parent;
+           if (clone != NULL)
+               parentClone = clone->parent;
            /*
            * Process parent --> next;
            */
@@ -9962,7 +9981,7 @@ internal_error:
 * References of out-of scope ns-decls are remapped to point to @destDoc:
 * 1) If @destParent is given, then nsDef entries on element-nodes are used
 * 2) If *no* @destParent is given, then @destDoc->oldNs entries are used
-*    This is the case when you have an unliked node and just want to move it
+*    This is the case when you have an unlinked node and just want to move it
 *    to the context of
 *
 * If @destParent is given, it ensures that the tree is namespace
index d885db9..c8b9c84 100644 (file)
@@ -99,7 +99,7 @@
 #endif
 #include <stddef.h>
 
-#ifdef HAVE_ERRNO_H
+#if defined( HAVE_ERRNO_H ) || defined( __VMS )
 #include <errno.h>
 #endif
 
 # define TRIO_ERROR_RETURN(x,y) (-1)
 #endif
 
+#ifndef VA_LIST_IS_ARRAY
+#define TRIO_VA_LIST_PTR       va_list *
+#define TRIO_VA_LIST_ADDR(l)   (&(l))
+#define TRIO_VA_LIST_DEREF(l)  (*(l))
+#else
+#define TRIO_VA_LIST_PTR       va_list
+#define TRIO_VA_LIST_ADDR(l)   (l)
+#define TRIO_VA_LIST_DEREF(l)  (l)
+#endif
+
 typedef unsigned long trio_flags_t;
 
 
 /*************************************************************************
  * Platform specific definitions
  */
-#if defined(TRIO_PLATFORM_UNIX)
+#if defined(TRIO_PLATFORM_UNIX) || defined(TRIO_PLATFORM_OS400)
 # include <unistd.h>
 # include <signal.h>
 # include <locale.h>
@@ -208,7 +218,7 @@ typedef unsigned long int trio_ulonglong_t;
 #endif
 
 /* Maximal and fixed integer types */
-#if defined(TRIO_COMPILER_SUPPORTS_C99)
+#if defined(TRIO_COMPILER_SUPPORTS_C99) && !defined( __VMS )
 # include <stdint.h>
 typedef intmax_t trio_intmax_t;
 typedef uintmax_t trio_uintmax_t;
@@ -216,8 +226,12 @@ typedef int8_t trio_int8_t;
 typedef int16_t trio_int16_t;
 typedef int32_t trio_int32_t;
 typedef int64_t trio_int64_t;
-#elif defined(TRIO_COMPILER_SUPPORTS_UNIX98)
+#elif defined(TRIO_COMPILER_SUPPORTS_UNIX98) || defined( __VMS )
 # include <inttypes.h>
+#ifdef __VMS
+typedef long long int          intmax_t;
+typedef unsigned long long int uintmax_t;
+#endif
 typedef intmax_t trio_intmax_t;
 typedef uintmax_t trio_uintmax_t;
 typedef int8_t trio_int8_t;
@@ -308,7 +322,9 @@ typedef trio_longlong_t trio_int64_t;
 #define NAN_UPPER "NAN"
 
 #if !defined(HAVE_ISASCII) && !defined(isascii)
-#  define isascii(x) ((unsigned int)(x) < 128)
+#ifndef __VMS
+# define isascii(x) ((unsigned int)(x) < 128)
+#endif
 #endif
 
 /* Various constants */
@@ -1167,7 +1183,7 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
           int type,
           TRIO_CONST char *format,
           trio_parameter_t *parameters,
-          va_list *arglist,
+          TRIO_VA_LIST_PTR arglist,
           trio_pointer_t *argarray)
 {
   /* Count the number of times a parameter is referenced */
@@ -1945,14 +1961,14 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
          if (flags & FLAGS_WIDECHAR)
            {
              parameters[i].data.wstring = (argarray == NULL)
-               ? va_arg(*arglist, trio_wchar_t *)
+               ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_wchar_t *)
                : (trio_wchar_t *)(argarray[num]);
            }
          else
 #endif
            {
              parameters[i].data.string = (argarray == NULL)
-               ? va_arg(*arglist, char *)
+               ? va_arg(TRIO_VA_LIST_DEREF(arglist), char *)
                : (char *)(argarray[num]);
            }
          break;
@@ -1964,7 +1980,7 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
        case FORMAT_COUNT:
        case FORMAT_UNKNOWN:
          parameters[i].data.pointer = (argarray == NULL)
-           ? va_arg(*arglist, trio_pointer_t )
+           ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t )
            : argarray[num];
          break;
 
@@ -1974,7 +1990,7 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
            {
               if (argarray == NULL)
                 parameters[i].data.pointer =
-                  (trio_pointer_t)va_arg(*arglist, trio_pointer_t);
+                  (trio_pointer_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t);
               else
                 {
                   if (parameters[i].type == FORMAT_CHAR)
@@ -2032,36 +2048,36 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
 #if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER)
              if (parameters[i].flags & FLAGS_SIZE_T)
                parameters[i].data.number.as_unsigned = (argarray == NULL)
-                 ? (trio_uintmax_t)va_arg(*arglist, size_t)
+                 ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), size_t)
                  : (trio_uintmax_t)(*((size_t *)argarray[num]));
              else
 #endif
 #if defined(QUALIFIER_PTRDIFF_T)
              if (parameters[i].flags & FLAGS_PTRDIFF_T)
                parameters[i].data.number.as_unsigned = (argarray == NULL)
-                 ? (trio_uintmax_t)va_arg(*arglist, ptrdiff_t)
+                 ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), ptrdiff_t)
                  : (trio_uintmax_t)(*((ptrdiff_t *)argarray[num]));
              else
 #endif
 #if defined(QUALIFIER_INTMAX_T)
              if (parameters[i].flags & FLAGS_INTMAX_T)
                parameters[i].data.number.as_unsigned = (argarray == NULL)
-                 ? (trio_uintmax_t)va_arg(*arglist, trio_intmax_t)
+                 ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_intmax_t)
                  : (trio_uintmax_t)(*((trio_intmax_t *)argarray[num]));
              else
 #endif
              if (parameters[i].flags & FLAGS_QUAD)
                parameters[i].data.number.as_unsigned = (argarray == NULL)
-                 ? (trio_uintmax_t)va_arg(*arglist, trio_ulonglong_t)
+                 ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_ulonglong_t)
                  : (trio_uintmax_t)(*((trio_ulonglong_t *)argarray[num]));
              else if (parameters[i].flags & FLAGS_LONG)
                parameters[i].data.number.as_unsigned = (argarray == NULL)
-                 ? (trio_uintmax_t)va_arg(*arglist, long)
+                 ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), long)
                  : (trio_uintmax_t)(*((long *)argarray[num]));
              else
                {
                  if (argarray == NULL)
-                   parameters[i].data.number.as_unsigned = (trio_uintmax_t)va_arg(*arglist, int);
+                   parameters[i].data.number.as_unsigned = (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), int);
                  else
                    {
                      if (parameters[i].type == FORMAT_CHAR)
@@ -2082,11 +2098,11 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
           */
          if (parameters[i].flags & FLAGS_USER_DEFINED)
            parameters[i].data.pointer = (argarray == NULL)
-             ? va_arg(*arglist, trio_pointer_t )
+             ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t )
              : argarray[num];
          else
            parameters[i].data.number.as_unsigned = (argarray == NULL)
-             ? (trio_uintmax_t)va_arg(*arglist, int)
+             ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), int)
              : (trio_uintmax_t)(*((int *)argarray[num]));
          break;
 
@@ -2095,17 +2111,17 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
            {
              if (parameters[i].flags & FLAGS_LONGDOUBLE)
                parameters[i].data.longdoublePointer = (argarray == NULL)
-                 ? va_arg(*arglist, trio_long_double_t *)
+                 ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_long_double_t *)
                  : (trio_long_double_t *)argarray[num];
              else
                 {
                  if (parameters[i].flags & FLAGS_LONG)
                    parameters[i].data.doublePointer = (argarray == NULL)
-                     ? va_arg(*arglist, double *)
+                     ? va_arg(TRIO_VA_LIST_DEREF(arglist), double *)
                      : (double *)argarray[num];
                  else
                    parameters[i].data.doublePointer = (argarray == NULL)
-                     ? (double *)va_arg(*arglist, float *)
+                     ? (double *)va_arg(TRIO_VA_LIST_DEREF(arglist), float *)
                      : (double *)((float *)argarray[num]);
                 }
            }
@@ -2113,13 +2129,13 @@ TRIO_ARGS5((type, format, parameters, arglist, argarray),
            {
              if (parameters[i].flags & FLAGS_LONGDOUBLE)
                parameters[i].data.longdoubleNumber = (argarray == NULL)
-                 ? va_arg(*arglist, trio_long_double_t)
+                 ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_long_double_t)
                  : (trio_long_double_t)(*((trio_long_double_t *)argarray[num]));
              else
                {
                  if (argarray == NULL)
                    parameters[i].data.longdoubleNumber =
-                     (trio_long_double_t)va_arg(*arglist, double);
+                     (trio_long_double_t)va_arg(TRIO_VA_LIST_DEREF(arglist), double);
                  else
                    {
                      if (parameters[i].flags & FLAGS_SHORT)
@@ -3384,7 +3400,7 @@ TrioFormatRef
 TRIO_ARGS4((reference, format, arglist, argarray),
           trio_reference_t *reference,
           TRIO_CONST char *format,
-          va_list *arglist,
+          TRIO_VA_LIST_PTR arglist,
           trio_pointer_t *argarray)
 {
   int status;
@@ -3412,7 +3428,7 @@ TRIO_ARGS6((destination, destinationSize, OutStream, format, arglist, argarray),
           size_t destinationSize,
           void (*OutStream) TRIO_PROTO((trio_class_t *, int)),
           TRIO_CONST char *format,
-          va_list *arglist,
+          TRIO_VA_LIST_PTR arglist,
           trio_pointer_t *argarray)
 {
   int status;
@@ -3638,7 +3654,7 @@ TRIO_VARGS2((format, va_alist),
   assert(VALID(format));
 
   TRIO_VA_START(args, format);
-  status = TrioFormat(stdout, 0, TrioOutStreamFile, format, &args, NULL);
+  status = TrioFormat(stdout, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -3658,7 +3674,7 @@ TRIO_ARGS2((format, args),
 {
   assert(VALID(format));
 
-  return TrioFormat(stdout, 0, TrioOutStreamFile, format, &args, NULL);
+  return TrioFormat(stdout, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 /**
@@ -3705,7 +3721,7 @@ TRIO_VARGS3((file, format, va_alist),
   assert(VALID(format));
 
   TRIO_VA_START(args, format);
-  status = TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL);
+  status = TrioFormat(file, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -3728,7 +3744,7 @@ TRIO_ARGS3((file, format, args),
   assert(VALID(file));
   assert(VALID(format));
 
-  return TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL);
+  return TrioFormat(file, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 /**
@@ -3777,7 +3793,7 @@ TRIO_VARGS3((fd, format, va_alist),
   assert(VALID(format));
 
   TRIO_VA_START(args, format);
-  status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL);
+  status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -3799,7 +3815,7 @@ TRIO_ARGS3((fd, format, args),
 {
   assert(VALID(format));
 
-  return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL);
+  return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 /**
@@ -3843,7 +3859,7 @@ TRIO_VARGS4((stream, closure, format, va_alist),
   TRIO_VA_START(args, format);
   data.stream.out = stream;
   data.closure = closure;
-  status = TrioFormat(&data, 0, TrioOutStreamCustom, format, &args, NULL);
+  status = TrioFormat(&data, 0, TrioOutStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -3863,7 +3879,7 @@ TRIO_ARGS4((stream, closure, format, args),
 
   data.stream.out = stream;
   data.closure = closure;
-  return TrioFormat(&data, 0, TrioOutStreamCustom, format, &args, NULL);
+  return TrioFormat(&data, 0, TrioOutStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
@@ -3910,7 +3926,7 @@ TRIO_VARGS3((buffer, format, va_alist),
   assert(VALID(format));
 
   TRIO_VA_START(args, format);
-  status = TrioFormat(&buffer, 0, TrioOutStreamString, format, &args, NULL);
+  status = TrioFormat(&buffer, 0, TrioOutStreamString, format, TRIO_VA_LIST_ADDR(args), NULL);
   *buffer = NIL; /* Terminate with NIL character */
   TRIO_VA_END(args);
   return status;
@@ -3936,7 +3952,7 @@ TRIO_ARGS3((buffer, format, args),
   assert(VALID(buffer));
   assert(VALID(format));
 
-  status = TrioFormat(&buffer, 0, TrioOutStreamString, format, &args, NULL);
+  status = TrioFormat(&buffer, 0, TrioOutStreamString, format, TRIO_VA_LIST_ADDR(args), NULL);
   *buffer = NIL;
   return status;
 }
@@ -3995,7 +4011,7 @@ TRIO_VARGS4((buffer, max, format, va_alist),
 
   TRIO_VA_START(args, format);
   status = TrioFormat(&buffer, max > 0 ? max - 1 : 0,
-                     TrioOutStreamStringMax, format, &args, NULL);
+                     TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL);
   if (max > 0)
     *buffer = NIL;
   TRIO_VA_END(args);
@@ -4025,7 +4041,7 @@ TRIO_ARGS4((buffer, max, format, args),
   assert(VALID(format));
 
   status = TrioFormat(&buffer, max > 0 ? max - 1 : 0,
-                     TrioOutStreamStringMax, format, &args, NULL);
+                     TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL);
   if (max > 0)
     *buffer = NIL;
   return status;
@@ -4086,7 +4102,7 @@ TRIO_VARGS4((buffer, max, format, va_alist),
   buffer = &buffer[buf_len];
 
   status = TrioFormat(&buffer, max - 1 - buf_len,
-                     TrioOutStreamStringMax, format, &args, NULL);
+                     TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   *buffer = NIL;
   return status;
@@ -4109,7 +4125,7 @@ TRIO_ARGS4((buffer, max, format, args),
   buf_len = trio_length(buffer);
   buffer = &buffer[buf_len];
   status = TrioFormat(&buffer, max - 1 - buf_len,
-                     TrioOutStreamStringMax, format, &args, NULL);
+                     TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL);
   *buffer = NIL;
   return status;
 }
@@ -4136,7 +4152,7 @@ TRIO_VARGS2((format, va_alist),
     {
       TRIO_VA_START(args, format);
       (void)TrioFormat(info, 0, TrioOutStreamStringDynamic,
-                      format, &args, NULL);
+                      format, TRIO_VA_LIST_ADDR(args), NULL);
       TRIO_VA_END(args);
 
       trio_string_terminate(info);
@@ -4162,7 +4178,7 @@ TRIO_ARGS2((format, args),
   if (info)
     {
       (void)TrioFormat(info, 0, TrioOutStreamStringDynamic,
-                      format, &args, NULL);
+                      format, TRIO_VA_LIST_ADDR(args), NULL);
       trio_string_terminate(info);
       result = trio_string_extract(info);
       trio_string_destroy(info);
@@ -4194,7 +4210,7 @@ TRIO_VARGS3((result, format, va_alist),
     {
       TRIO_VA_START(args, format);
       status = TrioFormat(info, 0, TrioOutStreamStringDynamic,
-                         format, &args, NULL);
+                         format, TRIO_VA_LIST_ADDR(args), NULL);
       TRIO_VA_END(args);
       if (status >= 0)
        {
@@ -4228,7 +4244,7 @@ TRIO_ARGS3((result, format, args),
   else
     {
       status = TrioFormat(info, 0, TrioOutStreamStringDynamic,
-                         format, &args, NULL);
+                         format, TRIO_VA_LIST_ADDR(args), NULL);
       if (status >= 0)
        {
          trio_string_terminate(info);
@@ -4930,7 +4946,7 @@ TRIO_VARGS3((ref, format, va_alist),
   assert(VALID(format));
 
   TRIO_VA_START(arglist, format);
-  status = TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL);
+  status = TrioFormatRef((trio_reference_t *)ref, format, TRIO_VA_LIST_ADDR(arglist), NULL);
   TRIO_VA_END(arglist);
   return status;
 }
@@ -4947,7 +4963,7 @@ TRIO_ARGS3((ref, format, arglist),
 {
   assert(VALID(format));
 
-  return TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL);
+  return TrioFormatRef((trio_reference_t *)ref, format, TRIO_VA_LIST_ADDR(arglist), NULL);
 }
 
 /*************************************************************************
@@ -6374,7 +6390,7 @@ TRIO_ARGS6((source, sourceSize, InStream, format, arglist, argarray),
           size_t sourceSize,
           void (*InStream) TRIO_PROTO((trio_class_t *, int *)),
           TRIO_CONST char *format,
-          va_list *arglist,
+          TRIO_VA_LIST_PTR arglist,
           trio_pointer_t *argarray)
 {
   int status;
@@ -6418,11 +6434,14 @@ TRIO_ARGS2((self, intPointer),
           trio_class_t *self,
           int *intPointer)
 {
-  FILE *file = (FILE *)self->location;
+  FILE *file;
 
   assert(VALID(self));
+  assert(VALID(self->location));
   assert(VALID(file));
 
+  file = (FILE *)self->location;
+
   self->current = fgetc(file);
   if (self->current == EOF)
     {
@@ -6451,11 +6470,14 @@ TRIO_ARGS2((self, intPointer),
           trio_class_t *self,
           int *intPointer)
 {
-  int fd = *((int *)self->location);
+  int fd;
   int size;
   unsigned char input;
 
   assert(VALID(self));
+  assert(VALID(self->location));
+
+  fd = *((int *)self->location);
 
   size = read(fd, &input, sizeof(char));
   if (size == -1)
@@ -6586,7 +6608,7 @@ TRIO_VARGS2((format, va_alist),
   TRIO_VA_START(args, format);
   status = TrioScan((trio_pointer_t)stdin, 0,
                    TrioInStreamFile,
-                   format, &args, NULL);
+                   format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -6601,7 +6623,7 @@ TRIO_ARGS2((format, args),
 
   return TrioScan((trio_pointer_t)stdin, 0,
                  TrioInStreamFile,
-                 format, &args, NULL);
+                 format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
@@ -6636,7 +6658,7 @@ TRIO_VARGS3((file, format, va_alist),
   TRIO_VA_START(args, format);
   status = TrioScan((trio_pointer_t)file, 0,
                    TrioInStreamFile,
-                   format, &args, NULL);
+                   format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -6653,7 +6675,7 @@ TRIO_ARGS3((file, format, args),
 
   return TrioScan((trio_pointer_t)file, 0,
                  TrioInStreamFile,
-                 format, &args, NULL);
+                 format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
@@ -6689,7 +6711,7 @@ TRIO_VARGS3((fd, format, va_alist),
   TRIO_VA_START(args, format);
   status = TrioScan((trio_pointer_t)&fd, 0,
                    TrioInStreamFileDescriptor,
-                   format, &args, NULL);
+                   format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -6705,7 +6727,7 @@ TRIO_ARGS3((fd, format, args),
 
   return TrioScan((trio_pointer_t)&fd, 0,
                  TrioInStreamFileDescriptor,
-                 format, &args, NULL);
+                 format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
@@ -6743,7 +6765,7 @@ TRIO_VARGS4((stream, closure, format, va_alist),
   TRIO_VA_START(args, format);
   data.stream.in = stream;
   data.closure = closure;
-  status = TrioScan(&data, 0, TrioInStreamCustom, format, &args, NULL);
+  status = TrioScan(&data, 0, TrioInStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -6763,7 +6785,7 @@ TRIO_ARGS4((stream, closure, format, args),
 
   data.stream.in = stream;
   data.closure = closure;
-  return TrioScan(&data, 0, TrioInStreamCustom, format, &args, NULL);
+  return TrioScan(&data, 0, TrioInStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
@@ -6803,7 +6825,7 @@ TRIO_VARGS3((buffer, format, va_alist),
   TRIO_VA_START(args, format);
   status = TrioScan((trio_pointer_t)&buffer, 0,
                    TrioInStreamString,
-                   format, &args, NULL);
+                   format, TRIO_VA_LIST_ADDR(args), NULL);
   TRIO_VA_END(args);
   return status;
 }
@@ -6820,7 +6842,7 @@ TRIO_ARGS3((buffer, format, args),
 
   return TrioScan((trio_pointer_t)&buffer, 0,
                  TrioInStreamString,
-                 format, &args, NULL);
+                 format, TRIO_VA_LIST_ADDR(args), NULL);
 }
 
 TRIO_PUBLIC int
index 108a709..99d2127 100644 (file)
@@ -155,45 +155,59 @@ void trio_locale_set_grouping TRIO_PROTO((char *grouping));
 #ifdef TRIO_REPLACE_STDIO
 /* Replace the <stdio.h> functions */
 #ifndef HAVE_PRINTF
+# undef printf
 # define printf trio_printf
 #endif
 #ifndef HAVE_VPRINTF
+# undef vprintf
 # define vprintf trio_vprintf
 #endif
 #ifndef HAVE_FPRINTF
+# undef fprintf
 # define fprintf trio_fprintf
 #endif
 #ifndef HAVE_VFPRINTF
+# undef vfprintf
 # define vfprintf trio_vfprintf
 #endif
 #ifndef HAVE_SPRINTF
+# undef sprintf
 # define sprintf trio_sprintf
 #endif
 #ifndef HAVE_VSPRINTF
+# undef vsprintf
 # define vsprintf trio_vsprintf
 #endif
 #ifndef HAVE_SNPRINTF
+# undef snprintf
 # define snprintf trio_snprintf
 #endif
 #ifndef HAVE_VSNPRINTF
+# undef vsnprintf
 # define vsnprintf trio_vsnprintf
 #endif
 #ifndef HAVE_SCANF
+# undef scanf
 # define scanf trio_scanf
 #endif
 #ifndef HAVE_VSCANF
+# undef vscanf
 # define vscanf trio_vscanf
 #endif
 #ifndef HAVE_FSCANF
+# undef fscanf
 # define fscanf trio_fscanf
 #endif
 #ifndef HAVE_VFSCANF
+# undef vfscanf
 # define vfscanf trio_vfscanf
 #endif
 #ifndef HAVE_SSCANF
+# undef sscanf
 # define sscanf trio_sscanf
 #endif
 #ifndef HAVE_VSSCANF
+# undef vsscanf
 # define vsscanf trio_vsscanf
 #endif
 /* These aren't stdio functions, but we make them look similar */
index fa89416..46772ee 100644 (file)
@@ -48,6 +48,8 @@
  * based on the DECC compiler later on.
  */
 # define TRIO_PLATFORM_VMS
+#elif defined(__OS400__)
+# define TRIO_PLATFORM_OS400
 #elif defined(unix) || defined(__unix) || defined(__unix__)
 # define TRIO_PLATFORM_UNIX
 #elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
 #   define TRIO_COMPILER_SUPPORTS_C94
 #  endif
 # endif
+#elif defined(TRIO_COMPILER_XLC) && defined(__EXTENDED__)
+# define TRIO_COMPILER_SUPPORTS_C89
+# define TRIO_COMPILER_SUPPORTS_C90
+# define TRIO_COMPILER_SUPPORTS_C94
 #endif
 
 #if defined(_XOPEN_SOURCE)
index e507645..123bbeb 100644 (file)
@@ -52,7 +52,9 @@
 # define BOOLEAN_T int
 #endif
 
-#if defined(TRIO_COMPILER_SUPPORTS_C99)
+#ifdef __VMS
+# define USE_STRTOD
+#elif defined(TRIO_COMPILER_SUPPORTS_C99)
 # define USE_STRTOD
 # define USE_STRTOF
 #elif defined(TRIO_COMPILER_MSVC)
 # else
 #  define strcasecmp(x,y) strcmpi(x,y)
 # endif
+#elif defined(TRIO_PLATFORM_OS400)
+# define USE_STRCASECMP
+# define USE_STRNCASECMP
+# include <strings.h>
 #endif
 
 #if !(defined(TRIO_PLATFORM_SUNOS))
index 4ab0ce2..ff47abb 100644 (file)
@@ -759,6 +759,8 @@ xmlParse3986HierPart(xmlURIPtr uri, const char **str)
         cur += 2;
        ret = xmlParse3986Authority(uri, &cur);
        if (ret != 0) return(ret);
+       if (uri->server == NULL)
+           uri->port = -1;
        ret = xmlParse3986PathAbEmpty(uri, &cur);
        if (ret != 0) return(ret);
        *str = cur;
@@ -1106,7 +1108,7 @@ xmlSaveUri(xmlURIPtr uri) {
            }
        }
     } else {
-       if (uri->server != NULL) {
+       if ((uri->server != NULL) || (uri->port == -1)) {
            if (len + 3 >= max) {
                 temp = xmlSaveUriRealloc(ret, &max);
                 if (temp == NULL) goto mem_error;
@@ -1143,22 +1145,24 @@ xmlSaveUri(xmlURIPtr uri) {
                }
                ret[len++] = '@';
            }
-           p = uri->server;
-           while (*p != 0) {
-               if (len >= max) {
-                    temp = xmlSaveUriRealloc(ret, &max);
-                    if (temp == NULL) goto mem_error;
-                    ret = temp;
+           if (uri->server != NULL) {
+               p = uri->server;
+               while (*p != 0) {
+                   if (len >= max) {
+                       temp = xmlSaveUriRealloc(ret, &max);
+                       if (temp == NULL) goto mem_error;
+                       ret = temp;
+                   }
+                   ret[len++] = *p++;
                }
-               ret[len++] = *p++;
-           }
-           if (uri->port > 0) {
-               if (len + 10 >= max) {
-                    temp = xmlSaveUriRealloc(ret, &max);
-                    if (temp == NULL) goto mem_error;
-                    ret = temp;
+               if (uri->port > 0) {
+                   if (len + 10 >= max) {
+                       temp = xmlSaveUriRealloc(ret, &max);
+                       if (temp == NULL) goto mem_error;
+                       ret = temp;
+                   }
+                   len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
                }
-               len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
            }
        } else if (uri->authority != NULL) {
            if (len + 3 >= max) {
@@ -1194,8 +1198,6 @@ xmlSaveUri(xmlURIPtr uri) {
                 if (temp == NULL) goto mem_error;
                 ret = temp;
            }
-           ret[len++] = '/';
-           ret[len++] = '/';
        }
        if (uri->path != NULL) {
            p = uri->path;
index 6e53a76..409aa81 100644 (file)
@@ -1798,6 +1798,7 @@ xmlCopyEnumeration(xmlEnumerationPtr cur) {
 
     if (cur == NULL) return(NULL);
     ret = xmlCreateEnumeration((xmlChar *) cur->name);
+    if (ret == NULL) return(NULL);
 
     if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next);
     else ret->next = NULL;
@@ -2633,11 +2634,8 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
        /*
         * The id is already defined in this DTD.
         */
-       if ((ctxt != NULL) && (ctxt->error != NULL)) {
-           xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
-                           "ID %s already defined\n",
-                           value, NULL, NULL);
-       }
+       xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
+                       "ID %s already defined\n", value, NULL, NULL);
 #endif /* LIBXML_VALID_ENABLED */
        xmlFreeID(ret);
        return(NULL);
@@ -2740,23 +2738,24 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
 
     if (doc == NULL) return(-1);
     if (attr == NULL) return(-1);
+
     table = (xmlIDTablePtr) doc->ids;
     if (table == NULL)
         return(-1);
 
-    if (attr == NULL)
-       return(-1);
     ID = xmlNodeListGetString(doc, attr->children, 1);
     if (ID == NULL)
-       return(-1);
+        return(-1);
+
     id = xmlHashLookup(table, ID);
     if (id == NULL || id->attr != attr) {
-       xmlFree(ID);
-       return(-1);
+        xmlFree(ID);
+        return(-1);
     }
+
     xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
     xmlFree(ID);
-       attr->atype = 0;
+    attr->atype = 0;
     return(0);
 }
 
@@ -3059,21 +3058,21 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
 
     if (doc == NULL) return(-1);
     if (attr == NULL) return(-1);
+
     table = (xmlRefTablePtr) doc->refs;
     if (table == NULL)
         return(-1);
 
-    if (attr == NULL)
-        return(-1);
     ID = xmlNodeListGetString(doc, attr->children, 1);
     if (ID == NULL)
         return(-1);
-    ref_list = xmlHashLookup(table, ID);
 
+    ref_list = xmlHashLookup(table, ID);
     if(ref_list == NULL) {
         xmlFree(ID);
         return (-1);
     }
+
     /* At this point, ref_list refers to a list of references which
      * have the same key as the supplied attr. Our list of references
      * is ordered by reference address and we don't have that information
@@ -5236,7 +5235,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
     xmlElementContentPtr cont;
     const xmlChar *name;
 
-    if ((elemDecl == NULL) || (parent == NULL))
+    if ((elemDecl == NULL) || (parent == NULL) || (ctxt == NULL))
        return(-1);
     cont = elemDecl->content;
     name = elemDecl->name;
@@ -6948,7 +6947,7 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
                          int max) {
     xmlValidCtxt vctxt;
     int nb_valid_elements = 0;
-    const xmlChar *elements[256];
+    const xmlChar *elements[256]={0};
     int nb_elements = 0, i;
     const xmlChar *name;
 
@@ -6998,6 +6997,9 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
      * Creates a dummy node and insert it into the tree
      */
     test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "<!dummy?>", NULL);
+    if (test_node == NULL)
+        return(-1);
+
     test_node->parent = parent;
     test_node->prev = prev;
     test_node->next = next;
index ace005b..ff3dafb 100644 (file)
@@ -17,6 +17,7 @@
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/uri.h>
+#include <libxml/xpath.h>
 #include <libxml/xpointer.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlerror.h>
@@ -1207,6 +1208,7 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
            }
            break;
        }
+#ifdef LIBXML_XPTR_ENABLED
        case XPATH_LOCATIONSET: {
            xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
            if (set == NULL)
@@ -1226,7 +1228,6 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
            }
            break;
        }
-#ifdef LIBXML_XPTR_ENABLED
        case XPATH_RANGE:
            return(xmlXIncludeCopyRange(ctxt, target, source, obj));
 #endif
@@ -1687,7 +1688,7 @@ loaded:
     /*
      * Do the xml:base fixup if needed
      */
-    if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/')) &&
+    if ((doc != NULL) && (URL != NULL) &&
         (!(ctxt->parseFlags & XML_PARSE_NOBASEFIX)) &&
        (!(doc->parseFlags & XML_PARSE_NOBASEFIX))) {
        xmlNodePtr node;
index 3566e06..c0e4ff3 100644 (file)
@@ -150,7 +150,7 @@ xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
     if (type != NULL) {
        if (xmlStrEqual(type, BAD_CAST "simple")) {
             ret = XLINK_TYPE_SIMPLE;
-       } if (xmlStrEqual(type, BAD_CAST "extended")) {
+       } else if (xmlStrEqual(type, BAD_CAST "extended")) {
            role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);
            if (role != NULL) {
                xmlNsPtr xlink;
index 16a7b3d..2a2dd3b 100644 (file)
@@ -801,6 +801,13 @@ xmlCheckFilename (const char *path)
     return 1;
 }
 
+/**
+ * xmlNop:
+ *
+ * No Operation function, does nothing, no input
+ *
+ * Returns zero
+ */
 int
 xmlNop(void) {
     return(0);
@@ -888,7 +895,7 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
  */
 static void *
 xmlFileOpen_real (const char *filename) {
-    const char *path = NULL;
+    const char *path = filename;
     FILE *fd;
 
     if (filename == NULL)
@@ -918,11 +925,8 @@ xmlFileOpen_real (const char *filename) {
 #else
        path = &filename[5];
 #endif
-    } else
-       path = filename;
+    }
 
-    if (path == NULL)
-       return(NULL);
     if (!xmlCheckFilename(path))
         return(NULL);
 
@@ -1160,7 +1164,12 @@ xmlGzfileOpen_real (const char *filename) {
     gzFile fd;
 
     if (!strcmp(filename, "-")) {
-        fd = gzdopen(dup(0), "rb");
+        int duped_fd = dup(fileno(stdin));
+        fd = gzdopen(duped_fd, "rb");
+        if (fd == Z_NULL && duped_fd >= 0) {
+            close(duped_fd);  /* gzdOpen() does not close on failure */
+        }
+
        return((void *) fd);
     }
 
@@ -1234,7 +1243,12 @@ xmlGzfileOpenW (const char *filename, int compression) {
 
     snprintf(mode, sizeof(mode), "wb%d", compression);
     if (!strcmp(filename, "-")) {
-        fd = gzdopen(dup(1), mode);
+        int duped_fd = dup(fileno(stdout));
+        fd = gzdopen(duped_fd, "rb");
+        if (fd == Z_NULL && duped_fd >= 0) {
+            close(duped_fd);  /* gzdOpen() does not close on failure */
+        }
+
        return((void *) fd);
     }
 
@@ -1356,7 +1370,7 @@ xmlXzfileOpen_real (const char *filename) {
     xzFile fd;
 
     if (!strcmp(filename, "-")) {
-        fd = __libxml2_xzdopen(dup(0), "rb");
+        fd = __libxml2_xzdopen(dup(fileno(stdin)), "rb");
        return((void *) fd);
     }
 
@@ -2669,6 +2683,12 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
            }
 #endif
        }
+#endif
+#ifdef HAVE_LZMA_H
+       if ((xmlInputCallbackTable[i].opencallback == xmlXzfileOpen) &&
+               (strcmp(URI, "-") != 0)) {
+            ret->compressed = __libxml2_xzcompressed(context);
+       }
 #endif
     }
     else
@@ -3326,6 +3346,17 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
     if (res < 0) {
        return(-1);
     }
+
+    /*
+     * try to establish compressed status of input if not done already
+     */
+    if (in->compressed == -1) {
+#ifdef HAVE_LZMA_H
+       if (in->readcallback == xmlXzfileRead)
+            in->compressed = __libxml2_xzcompressed(in->context);
+#endif
+    }
+
     len = res;
     if (in->encoder != NULL) {
         unsigned int use;
index 43f455a..b9ed6a4 100644 (file)
@@ -181,12 +181,13 @@ static void usershell(void) {
        /*
         * start interpreting the command
         */
-        if (!strcmp(command, "exit"))
-           break;
-        if (!strcmp(command, "quit"))
-           break;
-        if (!strcmp(command, "bye"))
+       if (!strcmp(command, "exit") ||
+           !strcmp(command, "quit") ||
+           !strcmp(command, "bye")) {
+           free(cmdline);
            break;
+       }
+
        if (!strcmp(command, "public")) {
            if (nbargs != 1) {
                printf("public requires 1 arguments\n");
index 26d8db1..b297ded 100644 (file)
@@ -1837,8 +1837,12 @@ static void streamFile(char *filename) {
        if ((fd = open(filename, O_RDONLY)) < 0)
            return;
        base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
-       if (base == (void *) MAP_FAILED)
+       if (base == (void *) MAP_FAILED) {
+           close(fd);
+           fprintf(stderr, "mmap failure for file %s\n", filename);
+           progresult = XMLLINT_ERR_RDFILE;
            return;
+       }
 
        reader = xmlReaderForMemory(base, info.st_size, filename,
                                    NULL, options);
@@ -2190,6 +2194,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
        f = fopen(filename, "rb");
+#elif defined(__OS400__)
+       f = fopen(filename, "rb");
 #else
        f = fopen(filename, "r");
 #endif
@@ -2202,6 +2208,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
             if (res > 0) {
                 ctxt = htmlCreatePushParserCtxt(NULL, NULL,
                             chars, res, filename, XML_CHAR_ENCODING_NONE);
+                xmlCtxtUseOptions(ctxt, options);
                 while ((res = fread(chars, 1, pushsize, f)) > 0) {
                     htmlParseChunk(ctxt, chars, res, 0);
                 }
@@ -2223,8 +2230,12 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
        if ((fd = open(filename, O_RDONLY)) < 0)
            return;
        base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
-       if (base == (void *) MAP_FAILED)
+       if (base == (void *) MAP_FAILED) {
+           close(fd);
+           fprintf(stderr, "mmap failure for file %s\n", filename);
+           progresult = XMLLINT_ERR_RDFILE;
            return;
+       }
 
        doc = htmlReadMemory((char *) base, info.st_size, filename,
                             NULL, options);
@@ -2251,6 +2262,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
            } else {
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
                f = fopen(filename, "rb");
+#elif defined(__OS400__)
+               f = fopen(filename, "rb");
 #else
                f = fopen(filename, "r");
 #endif
@@ -2292,6 +2305,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
                f = fopen(filename, "rb");
+#elif defined(__OS400__)
+               f = fopen(filename, "rb");
 #else
                f = fopen(filename, "r");
 #endif
@@ -2338,8 +2353,12 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
            if ((fd = open(filename, O_RDONLY)) < 0)
                return;
            base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
-           if (base == (void *) MAP_FAILED)
+           if (base == (void *) MAP_FAILED) {
+               close(fd);
+               fprintf(stderr, "mmap failure for file %s\n", filename);
+               progresult = XMLLINT_ERR_RDFILE;
                return;
+           }
 
            if (rectxt == NULL)
                doc = xmlReadMemory((char *) base, info.st_size,
@@ -2561,7 +2580,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
                    fprintf(stderr, "Failed to canonicalize\n");
                    progresult = XMLLINT_ERR_OUT;
                }
-           } else if (canonical) {
+           } else if (canonical_11) {
                xmlChar *result = NULL;
                int size;
 
@@ -2990,7 +3009,7 @@ static void usage(const char *name) {
     printf("\t--noenc : ignore any encoding specified inside the document\n");
     printf("\t--noout : don't output the result tree\n");
     printf("\t--path 'paths': provide a set of paths for resources\n");
-    printf("\t--load-trace : print trace of all external entites loaded\n");
+    printf("\t--load-trace : print trace of all external entities loaded\n");
     printf("\t--nonet : refuse to fetch DTDs or entities over network\n");
     printf("\t--nocompact : do not generate compact text nodes\n");
     printf("\t--htmlout : output results as HTML\n");
@@ -3087,6 +3106,10 @@ static void usage(const char *name) {
 static void registerNode(xmlNodePtr node)
 {
     node->_private = malloc(sizeof(long));
+    if (node->_private == NULL) {
+        fprintf(stderr, "Out of memory in xmllint:registerNode()\n");
+       exit(XMLLINT_ERR_MEM);
+    }
     *(long*)node->_private = (long) 0x81726354;
     nbregister++;
 }
@@ -3372,11 +3395,13 @@ main(int argc, char **argv) {
                 (!strcmp(argv[i], "--pretty"))) {
             i++;
 #ifdef LIBXML_OUTPUT_ENABLED
-            format = atoi(argv[i]);
-            if (format == 1) {
-                noblanks++;
-                xmlKeepBlanksDefault(0);
-            }
+       if (argv[i] != NULL) {
+                format = atoi(argv[i]);
+                if (format == 1) {
+                    noblanks++;
+                    xmlKeepBlanksDefault(0);
+                }
+       }
 #endif /* LIBXML_OUTPUT_ENABLED */
        }
 #ifdef LIBXML_READER_ENABLED
index 25d9318..a3dc737 100644 (file)
@@ -313,7 +313,7 @@ xmlMemMalloc(size_t size)
 void *
 xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
 {
-    MEMHDR *p;
+    MEMHDR *p, *tmp;
     unsigned long number;
 #ifdef DEBUG_MEMORY
     size_t oldsize;
@@ -344,10 +344,12 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
 #endif
     xmlMutexUnlock(xmlMemMutex);
 
-    p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
-    if (!p) {
+    tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
+    if (!tmp) {
+        free(p);
         goto error;
     }
+    p = tmp;
     if (xmlMemTraceBlockAt == ptr) {
        xmlGenericError(xmlGenericErrorContext,
                        "%p : Realloced(%lu -> %lu) Ok\n",
@@ -512,10 +514,7 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
 
     if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
 
-    if (s != NULL)
-      strcpy(s,str);
-    else
-      goto error;
+    strcpy(s,str);
 
     TEST_POINT
 
@@ -583,13 +582,15 @@ xmlMemBlocks(void) {
 static void
 xmlMemContentShow(FILE *fp, MEMHDR *p)
 {
-    int i,j,k,len = p->mh_size;
-    const char *buf = (const char *) HDR_2_CLIENT(p);
+    int i,j,k,len;
+    const char *buf;
 
     if (p == NULL) {
        fprintf(fp, " NULL");
        return;
     }
+    len = p->mh_size;
+    buf = (const char *) HDR_2_CLIENT(p);
 
     for (i = 0;i < len;i++) {
         if (buf[i] == 0) break;
index 9232da3..1499f1d 100644 (file)
@@ -115,7 +115,7 @@ xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol)
 {
     int rc = -1;
 
-    if ((NULL == module) || (symbol == NULL)) {
+    if ((NULL == module) || (symbol == NULL) || (name == NULL)) {
         __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
                         XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
                         NULL, NULL, 0, 0, "null parameter\n");
index 00083d0..f19e123 100644 (file)
@@ -51,9 +51,8 @@
 /*
  * The following VA_COPY was coded following an example in
  * the Samba project.  It may not be sufficient for some
- * esoteric implementations of va_list (i.e. it may need
- * something involving a memcpy) but (hopefully) will be
- * sufficient for libxml2.
+ * esoteric implementations of va_list but (hopefully) will
+ * be sufficient for libxml2.
  */
 #ifndef VA_COPY
   #ifdef HAVE_VA_COPY
     #ifdef HAVE___VA_COPY
       #define VA_COPY(dest,src) __va_copy(dest, src)
     #else
-      #define VA_COPY(dest,src) (dest) = (src)
+      #ifndef VA_LIST_IS_ARRAY
+        #define VA_COPY(dest,src) (dest) = (src)
+      #else
+        #include <string.h>
+        #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
+      #endif
     #endif
   #endif
 #endif
@@ -282,7 +286,10 @@ static void
 xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
     xmlDictPtr dict;
 
-    dict = reader->ctxt->dict;
+    if ((reader != NULL) && (reader->ctxt != NULL))
+       dict = reader->ctxt->dict;
+    else
+        dict = NULL;
     if (cur == NULL) return;
 
     if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
@@ -319,7 +326,7 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
 static void
 xmlTextReaderFreePropList(xmlTextReaderPtr reader, xmlAttrPtr cur) {
     xmlAttrPtr next;
-    if (cur == NULL) return;
+
     while (cur != NULL) {
         next = cur->next;
         xmlTextReaderFreeProp(reader, cur);
@@ -340,7 +347,10 @@ xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
     xmlNodePtr next;
     xmlDictPtr dict;
 
-    dict = reader->ctxt->dict;
+    if ((reader != NULL) && (reader->ctxt != NULL))
+       dict = reader->ctxt->dict;
+    else
+        dict = NULL;
     if (cur == NULL) return;
     if (cur->type == XML_NAMESPACE_DECL) {
        xmlFreeNsList((xmlNsPtr) cur);
@@ -417,7 +427,10 @@ static void
 xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
     xmlDictPtr dict;
 
-    dict = reader->ctxt->dict;
+    if ((reader != NULL) && (reader->ctxt != NULL))
+       dict = reader->ctxt->dict;
+    else
+        dict = NULL;
     if (cur->type == XML_DTD_NODE) {
        xmlFreeDtd((xmlDtdPtr) cur);
        return;
@@ -1427,7 +1440,7 @@ get_next_node:
        goto node_found;
     }
 #ifdef LIBXML_REGEXP_ENABLED
-    if ((reader->validate) && (reader->node->type == XML_ELEMENT_NODE))
+    if ((reader->validate != XML_TEXTREADER_NOT_VALIDATE) && (reader->node->type == XML_ELEMENT_NODE))
        xmlTextReaderValidatePop(reader);
 #endif /* LIBXML_REGEXP_ENABLED */
     if ((reader->preserves > 0) &&
@@ -1560,7 +1573,7 @@ node_found:
         goto get_next_node;
     }
 #ifdef LIBXML_REGEXP_ENABLED
-    if ((reader->validate) && (reader->node != NULL)) {
+    if ((reader->validate != XML_TEXTREADER_NOT_VALIDATE) && (reader->node != NULL)) {
        xmlNodePtr node = reader->node;
 
        if ((node->type == XML_ELEMENT_NODE) &&
@@ -1790,6 +1803,7 @@ xmlTextReaderReadString(xmlTextReaderPtr reader)
        if (xmlTextReaderDoExpand(reader) != -1) {
            return xmlTextReaderCollectSiblings(node->children);
        }
+       break;
     case XML_ATTRIBUTE_NODE:
        TODO
        break;
index 1f9911c..3e912ab 100644 (file)
@@ -3162,8 +3162,10 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
            exec->status = -6;
            return;
        }
-       memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
+       if (exec->counts) {
+           memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
               exec->comp->nbCounters * sizeof(int));
+       }
     }
 
 #ifdef DEBUG_REGEXP_EXEC
@@ -4091,7 +4093,7 @@ rollback:
             */
            exec->determinist = 0;
            xmlFARegExecRollBack(exec);
-           if (exec->status == 0) {
+           if ((exec->inputStack != NULL ) && (exec->status == 0)) {
                value = exec->inputStack[exec->index].value;
                data = exec->inputStack[exec->index].data;
 #ifdef DEBUG_PUSH
@@ -4306,7 +4308,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
                    (*nbval)++;
                }
            } else {
-                if ((exec->comp->states[trans->to] != NULL) &&
+                if ((exec->comp != NULL) && (exec->comp->states[trans->to] != NULL) &&
                    (exec->comp->states[trans->to]->type !=
                     XML_REGEXP_SINK_STATE)) {
                    if (atom->neg)
@@ -5707,8 +5709,6 @@ xmlAutomataNewTransition(xmlAutomataPtr am, xmlAutomataStatePtr from,
     if (atom == NULL)
         return(NULL);
     atom->data = data;
-    if (atom == NULL)
-       return(NULL);
     atom->valuep = xmlStrdup(token);
 
     if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
index 121533f..0657b66 100644 (file)
@@ -1471,7 +1471,7 @@ xmlSchemaWildcardPCToString(int pc)
  * @retValue: the returned value
  * @ws: the whitespace type of the value
  *
- * Get a the cononical representation of the value.
+ * Get a the canonical representation of the value.
  * The caller has to free the returned retValue.
  *
  * Returns 0 if the value could be built and -1 in case of
@@ -2039,6 +2039,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
        if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
            xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt;
            const char *file = NULL;
+           int col = 0;
            if (errorLevel != XML_ERR_WARNING) {
                vctxt->nberrors++;
                vctxt->err = error;
@@ -2067,6 +2068,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
                    (vctxt->parserCtxt->input != NULL)) {
                    file = vctxt->parserCtxt->input->filename;
                    line = vctxt->parserCtxt->input->line;
+                   col = vctxt->parserCtxt->input->col;
                }
            } else {
                /*
@@ -2101,7 +2103,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
                node, XML_FROM_SCHEMASV,
                error, errorLevel, file, line,
                (const char *) str1, (const char *) str2,
-               (const char *) str3, 0, 0, msg, str1, str2, str3, str4);
+               (const char *) str3, 0, col, msg, str1, str2, str3, str4);
 
        } else if (ctxt->type == XML_SCHEMA_CTXT_PARSER) {
            xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt;
@@ -6139,7 +6141,7 @@ xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt,
     value = xmlNodeGetContent(node);
     /*
     * 3.2.2.1 Lexical representation
-    * An instance of a datatype that is defined as ï¿½boolean�
+    * An instance of a datatype that is defined as `boolean`
     * can have the following legal literals {true, false, 1, 0}.
     */
     if (xmlStrEqual(BAD_CAST value, BAD_CAST "true"))
@@ -6187,7 +6189,7 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt,
         return (def);
     /*
     * 3.2.2.1 Lexical representation
-    * An instance of a datatype that is defined as ï¿½boolean�
+    * An instance of a datatype that is defined as `boolean`
     * can have the following legal literals {true, false, 1, 0}.
     */
     if (xmlStrEqual(val, BAD_CAST "true"))
@@ -7717,8 +7719,8 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
        /*
        * SPEC src-redefine:
        * (7.1) "If it has an <attributeGroup> among its contents
-       * the ï¿½actual value� of whose ref [attribute] is the same
-       * as the ï¿½actual value� of its own name attribute plus
+       * the `actual value` of whose ref [attribute] is the same
+       * as the `actual value` of its own name attribute plus
        * target namespace, then it must have exactly one such group."
        */
        if (pctxt->redefCounter != 0) {
@@ -8867,7 +8869,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
     type->flags |= XML_SCHEMAS_TYPE_VARIETY_UNION;
     /*
     * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
-    * then the ï¿½simple ur-type definition�."
+    * then the `simple ur-type definition`."
     */
     type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
     /*
@@ -9035,7 +9037,7 @@ xmlSchemaParseList(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
     type->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
     /*
     * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
-    * then the ï¿½simple ur-type definition�."
+    * then the `simple ur-type definition`."
     */
     type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
     /*
@@ -9180,9 +9182,9 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
     }
     /*
     * TargetNamespace:
-    * SPEC "The ï¿½actual value� of the targetNamespace [attribute]
+    * SPEC "The `actual value` of the targetNamespace [attribute]
     * of the <schema> ancestor element information item if present,
-    * otherwise ï¿½absent�.
+    * otherwise `absent`.
     */
     if (topLevel == 0) {
 #ifdef ENABLE_NAMED_LOCALS
@@ -9317,8 +9319,8 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
     /*
     * REDEFINE: SPEC src-redefine (5)
     * "Within the [children], each <simpleType> must have a
-    * <restriction> among its [children] ... the ï¿½actual value� of whose
-    * base [attribute] must be the same as the ï¿½actual value� of its own
+    * <restriction> among its [children] ... the `actual value` of whose
+    * base [attribute] must be the same as the `actual value` of its own
     * name attribute plus target namespace;"
     */
     if (topLevel && ctxt->isRedefine && (! hasRestriction)) {
@@ -10402,7 +10404,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
        /*
        * Given that the schemaLocation [attribute] is only a hint, it is open
        * to applications to ignore all but the first <import> for a given
-       * namespace, regardless of the ï¿½actual value� of schemaLocation, but
+       * namespace, regardless of the `actual value` of schemaLocation, but
        * such a strategy risks missing useful information when new
        * schemaLocations are offered.
        *
@@ -10755,7 +10757,7 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
            XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
            NULL, node,
            xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYURI),
-           NULL, namespaceName, NULL, NULL, NULL);
+           NULL, schemaLocation, NULL, NULL, NULL);
        return (pctxt->err);
     }
     /*
@@ -10786,8 +10788,8 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
     thisTargetNamespace = WXS_BUCKET(pctxt)->origTargetNamespace;
     if (namespaceName != NULL) {
        /*
-       * 1.1 If the namespace [attribute] is present, then its ï¿½actual value�
-       * must not match the ï¿½actual value� of the enclosing <schema>'s
+       * 1.1 If the namespace [attribute] is present, then its `actual value`
+       * must not match the `actual value` of the enclosing <schema>'s
        * targetNamespace [attribute].
        */
        if (xmlStrEqual(thisTargetNamespace, namespaceName)) {
@@ -10988,7 +10990,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
            * for inclusions, since the that was the feedback from the
            * schema people. I.e. the following spec piece will *not* be
            * satisfied:
-           * SPEC src-include: "It is not an error for the ï¿½actual value� of the
+           * SPEC src-include: "It is not an error for the `actual value` of the
            * schemaLocation [attribute] to fail to resolve it all, in which
            * case no corresponding inclusion is performed.
            * So do we need a warning report here?"
@@ -11005,7 +11007,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
            *
            * SPEC src-redefine (1)
            * "If there are any element information items among the [children]
-           * other than <annotation> then the ï¿½actual value� of the
+           * other than <annotation> then the `actual value` of the
            * schemaLocation [attribute] must successfully resolve."
            * TODO: Ask the WG if a the location has always to resolve
            * here as well!
@@ -11025,9 +11027,9 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
        if (bucket->origTargetNamespace != NULL) {
            /*
            * SPEC src-include (2.1)
-           * "SII has a targetNamespace [attribute], and its ï¿½actual
-           * value� is identical to the ï¿½actual value� of the targetNamespace
-           * [attribute] of SII� (which must have such an [attribute])."
+           * "SII has a targetNamespace [attribute], and its `actual
+           * value` is identical to the `actual value` of the targetNamespace
+           * [attribute] of SII' (which must have such an [attribute])."
            */
            if (pctxt->targetNamespace == NULL) {
                xmlSchemaCustomErr(ACTXT_CAST pctxt,
@@ -11375,8 +11377,8 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
                        /*
                        * SPEC src-redefine:
                        * (6.1) "If it has a <group> among its contents at
-                       * some level the ï¿½actual value� of whose ref
-                       * [attribute] is the same as the ï¿½actual value� of
+                       * some level the `actual value` of whose ref
+                       * [attribute] is the same as the `actual value` of
                        * its own name attribute plus target namespace, then
                        * all of the following must be true:"
                        * (6.1.1) "It must have exactly one such group."
@@ -11401,9 +11403,9 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
                            xmlChar *str = NULL;
                            /*
                            * SPEC src-redefine:
-                           * (6.1.2) "The ï¿½actual value� of both that
+                           * (6.1.2) "The `actual value` of both that
                            * group's minOccurs and maxOccurs [attribute]
-                           * must be 1 (or ï¿½absent�).
+                           * must be 1 (or `absent`).
                            */
                            xmlSchemaCustomErr(ACTXT_CAST ctxt,
                                XML_SCHEMAP_SRC_REDEFINE, child, NULL,
@@ -11517,8 +11519,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
     *
     * SPEC (1.2) "...otherwise (<restriction> has no <simpleType> "
     * among its [children]), the simple type definition which is
-    * the {content type} of the type definition ï¿½resolved� to by
-    * the ï¿½actual value� of the base [attribute]"
+    * the {content type} of the type definition `resolved` to by
+    * the `actual value` of the base [attribute]"
     */
     if (xmlSchemaPValAttrQName(ctxt, schema, NULL, node, "base",
        &(type->baseNs), &(type->base)) == 0)
@@ -11541,8 +11543,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
                /*
                * REDEFINE: SPEC src-redefine (5)
                * "Within the [children], each <simpleType> must have a
-               * <restriction> among its [children] ... the ï¿½actual value� of
-               * whose base [attribute] must be the same as the ï¿½actual value�
+               * <restriction> among its [children] ... the `actual value` of
+               * whose base [attribute] must be the same as the `actual value`
                * of its own name attribute plus target namespace;"
                */
                xmlSchemaPCustomErrExt(ctxt, XML_SCHEMAP_SRC_REDEFINE,
@@ -12303,7 +12305,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
        * SPEC
        * "...the third alternative (neither <simpleContent> nor
        * <complexContent>) is chosen. This case is understood as shorthand
-       * for complex content restricting the ï¿½ur-type definition�, and the
+       * for complex content restricting the `ur-type definition`, and the
        * details of the mappings should be modified as necessary.
        */
        type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
@@ -13211,8 +13213,8 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl,
     if ((elemDecl->subtypes == NULL) && (elemDecl->namedType != NULL)) {
        xmlSchemaTypePtr type;
 
-       /* (type definition) ... otherwise the type definition ï¿½resolved�
-       * to by the ï¿½actual value� of the type [attribute] ...
+       /* (type definition) ... otherwise the type definition `resolved`
+       * to by the `actual value` of the type [attribute] ...
        */
        type = xmlSchemaGetType(ctxt->schema, elemDecl->namedType,
            elemDecl->namedTypeNs);
@@ -13250,7 +13252,7 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl,
            /*
            * The type definitions is set to:
            * SPEC "...the {type definition} of the element
-           * declaration ï¿½resolved� to by the ï¿½actual value�
+           * declaration `resolved` to by the `actual value`
            * of the substitutionGroup [attribute], if present"
            */
            if (elemDecl->subtypes == NULL)
@@ -13288,8 +13290,8 @@ xmlSchemaResolveUnionMemberTypes(xmlSchemaParserCtxtPtr ctxt,
 
     /*
     * SPEC (1) "If the <union> alternative is chosen, then [Definition:]
-    * define the explicit members as the type definitions ï¿½resolved�
-    * to by the items in the ï¿½actual value� of the memberTypes [attribute],
+    * define the explicit members as the type definitions `resolved`
+    * to by the items in the `actual value` of the memberTypes [attribute],
     * if any, followed by the type definitions corresponding to the
     * <simpleType>s among the [children] of <union>, if any."
     */
@@ -13584,7 +13586,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        return (0);
     }
     /*
-    * 3 If both O1 and O2 are sets of (namespace names or ï¿½absent�),
+    * 3 If both O1 and O2 are sets of (namespace names or `absent`),
     * then the union of those sets must be the value.
     */
     if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
@@ -13618,7 +13620,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
     }
     /*
     * 4 If the two are negations of different values (namespace names
-    * or ï¿½absent�), then a pair of not and ï¿½absent� must be the value.
+    * or `absent`), then a pair of not and `absent` must be the value.
     */
     if ((completeWild->negNsSet != NULL) &&
        (curWild->negNsSet != NULL) &&
@@ -13660,7 +13662,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        if (nsFound && absentFound) {
            /*
            * 5.1 If the set S includes both the negated namespace
-           * name and ï¿½absent�, then any must be the value.
+           * name and `absent`, then any must be the value.
            */
            completeWild->any = 1;
            if (completeWild->nsSet != NULL) {
@@ -13674,7 +13676,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        } else if (nsFound && (!absentFound)) {
            /*
            * 5.2 If the set S includes the negated namespace name
-           * but not ï¿½absent�, then a pair of not and ï¿½absent� must
+           * but not `absent`, then a pair of not and `absent` must
            * be the value.
            */
            if (completeWild->nsSet != NULL) {
@@ -13689,7 +13691,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
            completeWild->negNsSet->value = NULL;
        } else if ((!nsFound) && absentFound) {
            /*
-           * 5.3 If the set S includes ï¿½absent� but not the negated
+           * 5.3 If the set S includes `absent` but not the negated
            * namespace name, then the union is not expressible.
            */
            xmlSchemaPErr(ctxt, completeWild->node,
@@ -13700,7 +13702,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        } else if ((!nsFound) && (!absentFound)) {
            /*
            * 5.4 If the set S does not include either the negated namespace
-           * name or ï¿½absent�, then whichever of O1 or O2 is a pair of not
+           * name or `absent`, then whichever of O1 or O2 is a pair of not
            * and a namespace name must be the value.
            */
            if (completeWild->negNsSet == NULL) {
@@ -13734,7 +13736,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        while (cur != NULL) {
            if (cur->value == NULL) {
                /*
-               * 6.1 If the set S includes ï¿½absent�, then any must be the
+               * 6.1 If the set S includes `absent`, then any must be the
                * value.
                */
                completeWild->any = 1;
@@ -13752,8 +13754,8 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
        }
        if (completeWild->negNsSet == NULL) {
            /*
-           * 6.2 If the set S does not include ï¿½absent�, then a pair of not
-           * and ï¿½absent� must be the value.
+           * 6.2 If the set S does not include `absent`, then a pair of not
+           * and `absent` must be the value.
            */
            if (completeWild->nsSet != NULL) {
                xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
@@ -13836,9 +13838,9 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
     }
     /*
     * 3 If either O1 or O2 is a pair of not and a value (a namespace
-    * name or ï¿½absent�) and the other is a set of (namespace names or
-    * ï¿½absent�), then that set, minus the negated value if it was in
-    * the set, minus ï¿½absent� if it was in the set, must be the value.
+    * name or `absent`) and the other is a set of (namespace names or
+    * `absent`), then that set, minus the negated value if it was in
+    * the set, minus `absent` if it was in the set, must be the value.
     */
     if (((completeWild->negNsSet != NULL) && (curWild->nsSet != NULL)) ||
        ((curWild->negNsSet != NULL) && (completeWild->nsSet != NULL))) {
@@ -13887,7 +13889,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
        return(0);
     }
     /*
-    * 4 If both O1 and O2 are sets of (namespace names or ï¿½absent�),
+    * 4 If both O1 and O2 are sets of (namespace names or `absent`),
     * then the intersection of those sets must be the value.
     */
     if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
@@ -13937,7 +13939,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
     }
     /*
     * 6 If the one is a negation of a namespace name and the other
-    * is a negation of ï¿½absent�, then the one which is the negation
+    * is a negation of `absent`, then the one which is the negation
     * of a namespace name must be the value.
     */
     if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) &&
@@ -13969,7 +13971,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
     if (super->any)
        return (0);
     /*
-    * 2.1 sub must be a pair of not and a namespace name or ï¿½absent�.
+    * 2.1 sub must be a pair of not and a namespace name or `absent`.
     * 2.2 super must be a pair of not and the same value.
     */
     if ((sub->negNsSet != NULL) &&
@@ -13977,7 +13979,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
        (sub->negNsSet->value == super->negNsSet->value))
        return (0);
     /*
-    * 3.1 sub must be a set whose members are either namespace names or ï¿½absent�.
+    * 3.1 sub must be a set whose members are either namespace names or `absent`.
     */
     if (sub->nsSet != NULL) {
        /*
@@ -14008,7 +14010,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
            xmlSchemaWildcardNsPtr cur;
            /*
            * 3.2.2 super must be a pair of not and a namespace name or
-           * ï¿½absent� and that value must not be in sub's set.
+           * `absent` and that value must not be in sub's set.
            */
            cur = sub->nsSet;
            while (cur != NULL) {
@@ -14170,7 +14172,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
                        * SPEC (2.1.2) "R's {attribute declaration}'s
                        * {type definition} must be validly derived from
                        * B's {type definition} given the empty set as
-                       * defined in Type Derivation OK (Simple) (�3.14.6)."
+                       * defined in Type Derivation OK (Simple) ($3.14.6)."
                        */
                        xmlSchemaPAttrUseErr4(pctxt,
                            XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2,
@@ -14202,8 +14204,8 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
                        /*
                        * 2.1.3 ... one of the following must be true
                        *
-                       * 2.1.3.1 B's ï¿½effective value constraint� is
-                       * ï¿½absent� or default.
+                       * 2.1.3.1 B's `effective value constraint` is
+                       * `absent` or default.
                        */
                        if ((bEffValue != NULL) &&
                            (effFixed == 1)) {
@@ -14212,7 +14214,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
                            xmlSchemaGetEffectiveValueConstraint(bcur,
                                &effFixed, &rEffValue, NULL);
                            /*
-                           * 2.1.3.2 R's ï¿½effective value constraint� is
+                           * 2.1.3.2 R's `effective value constraint` is
                            * fixed with the same string as B's.
                            * MAYBE TODO: Compare the computed values.
                            *       Hmm, it says "same string" so
@@ -14246,9 +14248,9 @@ not_found:
                /*
                * (2.2) "otherwise the {base type definition} must have an
                * {attribute wildcard} and the {target namespace} of the
-               * R's {attribute declaration} must be ï¿½valid� with respect
+               * R's {attribute declaration} must be `valid` with respect
                * to that wildcard, as defined in Wildcard allows Namespace
-               * Name (�3.10.4)."
+               * Name ($3.10.4)."
                */
                if ((baseWild == NULL) ||
                    (xmlSchemaCheckCVCWildcardNamespace(baseWild,
@@ -14346,7 +14348,7 @@ not_found:
            * (4.2) "The complex type definition's {attribute wildcard}'s
            * {namespace constraint} must be a subset of the {base type
            * definition}'s {attribute wildcard}'s {namespace constraint},
-           * as defined by Wildcard Subset (�3.10.6)."
+           * as defined by Wildcard Subset ($3.10.6)."
            */
            xmlSchemaCustomErr4(ACTXT_CAST pctxt,
                XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2,
@@ -14360,8 +14362,8 @@ not_found:
            FREE_AND_NULL(str);
            return(pctxt->err);
        }
-       /* 4.3 Unless the {base type definition} is the ï¿½ur-type
-       * definition�, the complex type definition's {attribute
+       /* 4.3 Unless the {base type definition} is the `ur-type
+       * definition`, the complex type definition's {attribute
        * wildcard}'s {process contents} must be identical to or
        * stronger than the {base type definition}'s {attribute
        * wildcard}'s {process contents}, where strict is stronger
@@ -14547,7 +14549,7 @@ inherit_next: {}
     if (WXS_IS_EXTENSION(type)) {
        if (baseType->attributeWildcard != NULL) {
            /*
-           * (3.2.2.1) "If the ï¿½base wildcard� is non-�absent�, then
+           * (3.2.2.1) "If the `base wildcard` is non-`absent`, then
            * the appropriate case among the following:"
            */
            if (type->attributeWildcard != NULL) {
@@ -14555,26 +14557,26 @@ inherit_next: {}
                * Union the complete wildcard with the base wildcard.
                * SPEC {attribute wildcard}
                * (3.2.2.1.2) "otherwise a wildcard whose {process contents}
-               * and {annotation} are those of the ï¿½complete wildcard�,
+               * and {annotation} are those of the `complete wildcard`,
                * and whose {namespace constraint} is the intensional union
-               * of the {namespace constraint} of the ï¿½complete wildcard�
-               * and of the ï¿½base wildcard�, as defined in Attribute
-               * Wildcard Union (�3.10.6)."
+               * of the {namespace constraint} of the `complete wildcard`
+               * and of the `base wildcard`, as defined in Attribute
+               * Wildcard Union ($3.10.6)."
                */
                if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard,
                    baseType->attributeWildcard) == -1)
                    goto exit_failure;
            } else {
                /*
-               * (3.2.2.1.1) "If the ï¿½complete wildcard� is ï¿½absent�,
-               * then the ï¿½base wildcard�."
+               * (3.2.2.1.1) "If the `complete wildcard` is `absent`,
+               * then the `base wildcard`."
                */
                type->attributeWildcard = baseType->attributeWildcard;
            }
        } else {
            /*
-           * (3.2.2.2) "otherwise (the ï¿½base wildcard� is ï¿½absent�) the
-           * ï¿½complete wildcard"
+           * (3.2.2.2) "otherwise (the `base wildcard` is `absent`) the
+           * `complete wildcard`"
            * NOOP
            */
        }
@@ -14582,7 +14584,7 @@ inherit_next: {}
        /*
        * SPEC {attribute wildcard}
        * (3.1) "If the <restriction> alternative is chosen, then the
-       * ï¿½complete wildcard�;"
+       * `complete wildcard`;"
        * NOOP
        */
     }
@@ -14831,12 +14833,12 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
     /* 2.2 */
     if (type->baseType == baseType) {
        /*
-       * 2.2.1 D's ï¿½base type definition� is B.
+       * 2.2.1 D's `base type definition` is B.
        */
        return (0);
     }
     /*
-    * 2.2.2 D's ï¿½base type definition� is not the ï¿½ur-type definition�
+    * 2.2.2 D's `base type definition` is not the `ur-type definition`
     * and is validly derived from B given the subset, as defined by this
     * constraint.
     */
@@ -14846,8 +14848,8 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
        return (0);
     }
     /*
-    * 2.2.3 D's {variety} is list or union and B is the ï¿½simple ur-type
-    * definition�.
+    * 2.2.3 D's {variety} is list or union and B is the `simple ur-type
+    * definition`.
     */
     if (WXS_IS_ANY_SIMPLE_TYPE(baseType) &&
        (WXS_IS_LIST(type) || WXS_IS_UNION(type))) {
@@ -15159,14 +15161,14 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
     * NOTE: This is somehow redundant, since we actually built a simple type
     * to have all the needed information; this acts as an self test.
     */
-    /* Base type: If the datatype has been ï¿½derived� by ï¿½restriction�
-    * then the Simple Type Definition component from which it is ï¿½derived�,
-    * otherwise the Simple Type Definition for anySimpleType (�4.1.6).
+    /* Base type: If the datatype has been `derived` by `restriction`
+    * then the Simple Type Definition component from which it is `derived`,
+    * otherwise the Simple Type Definition for anySimpleType ($4.1.6).
     */
     if (baseType == NULL) {
        /*
        * TODO: Think about: "modulo the impact of Missing
-       * Sub-components (�5.3)."
+       * Sub-components ($5.3)."
        */
        xmlSchemaPCustomErr(ctxt,
            XML_SCHEMAP_ST_PROPS_CORRECT_1,
@@ -15226,10 +15228,10 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
     }
 
     /*
-    * 2 All simple type definitions must be derived ultimately from the ï¿½simple
-    * ur-type definition (so� circular definitions are disallowed). That is, it
-    * must be possible to reach a built-in primitive datatype or the ï¿½simple
-    * ur-type definition� by repeatedly following the {base type definition}.
+    * 2 All simple type definitions must be derived ultimately from the `simple
+    * ur-type definition` (so circular definitions are disallowed). That is, it
+    * must be possible to reach a built-in primitive datatype or the `simple
+    * ur-type definition` by repeatedly following the {base type definition}.
     *
     * NOTE: this is done in xmlSchemaCheckTypeDefCircular().
     */
@@ -15413,10 +15415,10 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
            }
            /*
            * MAYBE TODO: (Hmm, not really) Datatypes states:
-           * A ï¿½list� datatype can be ï¿½derived� from an ï¿½atomic� datatype
-           * whose ï¿½lexical space� allows space (such as string or anyURI)or
-           * a ï¿½union� datatype any of whose {member type definitions}'s
-           * ï¿½lexical space� allows space.
+           * A `list` datatype can be `derived` from an `atomic` datatype
+           * whose `lexical space` allows space (such as string or anyURI)or
+           * a `union` datatype any of whose {member type definitions}'s
+           * `lexical space` allows space.
            */
        } else {
            /*
@@ -15453,7 +15455,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
            /*
            * 2.3.2.3 The {item type definition} must be validly derived
            * from the {base type definition}'s {item type definition} given
-           * the empty set, as defined in Type Derivation OK (Simple) (�3.14.6).
+           * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6).
            */
            {
                xmlSchemaTypePtr baseItemType;
@@ -15500,7 +15502,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
                        case XML_SCHEMA_FACET_WHITESPACE:
                            /*
                            * TODO: 2.5.1.2 List datatypes
-                           * The value of ï¿½whiteSpace� is fixed to the value collapse.
+                           * The value of `whiteSpace` is fixed to the value collapse.
                            */
                        case XML_SCHEMA_FACET_PATTERN:
                        case XML_SCHEMA_FACET_ENUMERATION:
@@ -15553,8 +15555,8 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
            member = member->next;
        }
        /*
-       * 3.3.1 If the {base type definition} is the ï¿½simple ur-type
-       * definition�
+       * 3.3.1 If the {base type definition} is the `simple ur-type
+       * definition`
        */
        if (type->baseType->builtInType == XML_SCHEMAS_ANYSIMPLETYPE) {
            /*
@@ -15616,7 +15618,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
            * 3.3.2.3 The {member type definitions}, in order, must be validly
            * derived from the corresponding type definitions in the {base
            * type definition}'s {member type definitions} given the empty set,
-           * as defined in Type Derivation OK (Simple) (�3.14.6).
+           * as defined in Type Derivation OK (Simple) ($3.14.6).
            */
            {
                xmlSchemaTypeLinkPtr baseMember;
@@ -15723,7 +15725,7 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt,
     /*
     * src-simple-type.1 The corresponding simple type definition, if any,
     * must satisfy the conditions set out in Constraints on Simple Type
-    * Definition Schema Components (�3.14.6).
+    * Definition Schema Components ($3.14.6).
     */
     if (WXS_IS_RESTRICTION(type)) {
        /*
@@ -15821,8 +15823,8 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt,
        * SPEC (2.1) "its {content type} must be a simple type definition
        * or mixed."
        * SPEC (2.2.2) "If the {content type} is mixed, then the {content
-       * type}'s particle must be ï¿½emptiable� as defined by
-       * Particle Emptiable (�3.9.6)."
+       * type}'s particle must be `emptiable` as defined by
+       * Particle Emptiable ($3.9.6)."
        */
        if ((! WXS_HAS_SIMPLE_CONTENT(type)) &&
            ((! WXS_HAS_MIXED_CONTENT(type)) || (! WXS_EMPTIABLE(type)))) {
@@ -15838,14 +15840,14 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt,
     }
     /*
     * 1 If the type definition is a simple type definition, then the string
-    * must be ï¿½valid� with respect to that definition as defined by String
-    * Valid (�3.14.4).
+    * must be `valid` with respect to that definition as defined by String
+    * Valid ($3.14.4).
     *
     * AND
     *
     * 2.2.1 If the {content type} is a simple type definition, then the
-    * string must be ï¿½valid� with respect to that simple type definition
-    * as defined by String Valid (�3.14.4).
+    * string must be `valid` with respect to that simple type definition
+    * as defined by String Valid ($3.14.4).
     */
     if (WXS_IS_SIMPLE(type))
        ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node,
@@ -15886,8 +15888,8 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
     *
     * SPEC (1) "The values of the properties of a complex type definition must
     * be as described in the property tableau in The Complex Type Definition
-    * Schema Component (�3.4.1), modulo the impact of Missing
-    * Sub-components (�5.3)."
+    * Schema Component ($3.4.1), modulo the impact of Missing
+    * Sub-components ($5.3)."
     */
     if ((type->baseType != NULL) &&
        (WXS_IS_SIMPLE(type->baseType)) &&
@@ -15904,9 +15906,9 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
        return (XML_SCHEMAP_SRC_CT_1);
     }
     /*
-    * SPEC (3) "Circular definitions are disallowed, except for the ï¿½ur-type
-    * definition�. That is, it must be possible to reach the ï¿½ur-type
-    * definition by repeatedly following the {base type definition}."
+    * SPEC (3) "Circular definitions are disallowed, except for the `ur-type
+    * definition`. That is, it must be possible to reach the `ur-type
+    * definition` by repeatedly following the {base type definition}."
     *
     * NOTE (3) is done in xmlSchemaCheckTypeDefCircular().
     */
@@ -16058,8 +16060,8 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
     if (type->baseType == baseType)
        return (0);
     /*
-    * SPEC (2.3.1) "D's {base type definition} must not be the ï¿½ur-type
-    * definition�."
+    * SPEC (2.3.1) "D's {base type definition} must not be the `ur-type
+    * definition`."
     */
     if (WXS_IS_ANYTYPE(type->baseType))
        return (1);
@@ -16076,7 +16078,7 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
        /*
        * SPEC (2.3.2.2) "If D's {base type definition} is simple, then it
        * must be validly derived from B given the subset as defined in Type
-       * Derivation OK (Simple) (�3.14.6).
+       * Derivation OK (Simple) ($3.14.6).
        */
        return (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType,
            baseType, set));
@@ -16216,7 +16218,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
        * definition must also have one, and the base type definition's
        * {attribute  wildcard}'s {namespace constraint} must be a subset
        * of the complex  type definition's {attribute wildcard}'s {namespace
-       * constraint}, as defined by Wildcard Subset (�3.10.6)."
+       * constraint}, as defined by Wildcard Subset ($3.10.6)."
        */
 
        /*
@@ -16313,9 +16315,9 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
                }
                /*
                * URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the
-               * complex type definition must be a ï¿½valid extension�
+               * complex type definition must be a `valid extension`
                * of the {base type definition}'s particle, as defined
-               * in Particle Valid (Extension) (�3.9.6)."
+               * in Particle Valid (Extension) ($3.9.6)."
                *
                * NOTE that we won't check "Particle Valid (Extension)",
                * since it is ensured by the derivation process in
@@ -16432,7 +16434,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
     if (base->builtInType == XML_SCHEMAS_ANYTYPE) {
        /*
        * SPEC (5.1) "The {base type definition} must be the
-       * ï¿½ur-type definition�."
+       * `ur-type definition`."
        * PASS
        */
     } else if ((type->contentType == XML_SCHEMA_CONTENT_SIMPLE) ||
@@ -16451,7 +16453,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
            * SPEC (5.2.2.1) "The {content type} of the {base type
            * definition} must be a simple type definition from which
            * the {content type} is validly derived given the empty
-           * set as defined in Type Derivation OK (Simple) (�3.14.6)."
+           * set as defined in Type Derivation OK (Simple) ($3.14.6)."
            *
            * ATTENTION TODO: This seems not needed if the type implicitely
            * derived from the base type.
@@ -16482,8 +16484,8 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
                (xmlSchemaParticlePtr) base->subtypes))) {
            /*
            * SPEC (5.2.2.2) "The {base type definition} must be mixed
-           * and have a particle which is ï¿½emptiable� as defined in
-           * Particle Emptiable (�3.9.6)."
+           * and have a particle which is `emptiable` as defined in
+           * Particle Emptiable ($3.9.6)."
            * PASS
            */
        } else {
@@ -16512,7 +16514,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
            /*
            * SPEC (5.3.2.2) "The {content type} of the {base type
            * definition} must be elementOnly or mixed and have a particle
-           * which is ï¿½emptiable� as defined in Particle Emptiable (�3.9.6)."
+           * which is `emptiable` as defined in Particle Emptiable ($3.9.6)."
            * PASS
            */
        } else {
@@ -16545,9 +16547,9 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
        }
        /*
        * SPEC (5.4.2) "The particle of the complex type definition itself
-       * must be a ï¿½valid restriction� of the particle of the {content
+       * must be a `valid restriction` of the particle of the {content
        * type} of the {base type definition} as defined in Particle Valid
-       * (Restriction) (�3.9.6).
+       * (Restriction) ($3.9.6).
        *
        * URGENT TODO: (5.4.2)
        */
@@ -16616,7 +16618,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
     if (! WXS_HAS_SIMPLE_CONTENT(type)) {
        /*
        * 1 If the <complexContent> alternative is chosen, the type definition
-       * ï¿½resolved� to by the ï¿½actual value� of the base [attribute]
+       * `resolved` to by the `actual value` of the base [attribute]
        * must be a complex type definition;
        */
        if (! WXS_IS_COMPLEX(base)) {
@@ -16636,7 +16638,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
        * SPEC
        * 2 If the <simpleContent> alternative is chosen, all of the
        * following must be true:
-       * 2.1 The type definition ï¿½resolved� to by the ï¿½actual value� of the
+       * 2.1 The type definition `resolved` to by the `actual value` of the
        * base [attribute] must be one of the following:
        */
        if (WXS_IS_SIMPLE(base)) {
@@ -16742,14 +16744,14 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
     /*
     * SPEC (3) "The corresponding complex type definition component must
     * satisfy the conditions set out in Constraints on Complex Type
-    * Definition Schema Components (�3.4.6);"
+    * Definition Schema Components ($3.4.6);"
     * NOTE (3) will be done in xmlSchemaTypeFixup().
     */
     /*
     * SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specification
     * above for {attribute wildcard} is satisfied, the intensional
     * intersection must be expressible, as defined in Attribute Wildcard
-    * Intersection (�3.10.6).
+    * Intersection ($3.10.6).
     * NOTE (4) is done in xmlSchemaFixupTypeAttributeUses().
     */
     return (ret);
@@ -16820,7 +16822,7 @@ xmlSchemaCheckRCaseNameAndTypeOK(xmlSchemaParserCtxtPtr ctxt,
        return (1);
     /*
     * SPEC (2) "R's occurrence range is a valid restriction of B's
-    * occurrence range as defined by Occurrence Range OK (�3.9.6)."
+    * occurrence range as defined by Occurrence Range OK ($3.9.6)."
     */
     if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
            b->minOccurs, b->maxOccurs) != 0)
@@ -16912,19 +16914,19 @@ xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt,
 {
     /* TODO:Error codes (rcase-NSCompat). */
     /*
-    * SPEC "For an element declaration particle to be a ï¿½valid restriction�
+    * SPEC "For an element declaration particle to be a `valid restriction`
     * of a wildcard particle all of the following must be true:"
     *
-    * SPEC (1) "The element declaration's {target namespace} is ï¿½valid�
+    * SPEC (1) "The element declaration's {target namespace} is `valid`
     * with respect to the wildcard's {namespace constraint} as defined by
-    * Wildcard allows Namespace Name (�3.10.4)."
+    * Wildcard allows Namespace Name ($3.10.4)."
     */
     if (xmlSchemaCheckCVCWildcardNamespace((xmlSchemaWildcardPtr) b->children,
        ((xmlSchemaElementPtr) r->children)->targetNamespace) != 0)
        return (1);
     /*
     * SPEC (2) "R's occurrence range is a valid restriction of B's
-    * occurrence range as defined by Occurrence Range OK (�3.9.6)."
+    * occurrence range as defined by Occurrence Range OK ($3.9.6)."
     */
     if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
            b->minOccurs, b->maxOccurs) != 0)
@@ -16984,21 +16986,21 @@ xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt,
     /* TODO: Error codes (rcase-NSSubset). */
     /*
     * SPEC (1) "R's occurrence range is a valid restriction of B's
-    * occurrence range as defined by Occurrence Range OK (�3.9.6)."
+    * occurrence range as defined by Occurrence Range OK ($3.9.6)."
     */
     if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
            b->minOccurs, b->maxOccurs))
        return (1);
     /*
     * SPEC (2) "R's {namespace constraint} must be an intensional subset
-    * of B's {namespace constraint} as defined by Wildcard Subset (�3.10.6)."
+    * of B's {namespace constraint} as defined by Wildcard Subset ($3.10.6)."
     */
     if (xmlSchemaCheckCOSNSSubset((xmlSchemaWildcardPtr) r->children,
        (xmlSchemaWildcardPtr) b->children))
        return (1);
     /*
-    * SPEC (3) "Unless B is the content model wildcard of the ï¿½ur-type
-    * definition�, R's {process contents} must be identical to or stronger
+    * SPEC (3) "Unless B is the content model wildcard of the `ur-type
+    * definition`, R's {process contents} must be identical to or stronger
     * than B's {process contents}, where strict is stronger than lax is
     * stronger than skip."
     */
@@ -17076,12 +17078,12 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
     if ((r->children == NULL) || (r->children->children == NULL))
        return (-1);
     /*
-    * SPEC "For a group particle to be a ï¿½valid restriction� of a
+    * SPEC "For a group particle to be a `valid restriction` of a
     * wildcard particle..."
     *
-    * SPEC (1) "Every member of the {particles} of the group is a ï¿½valid
-    * restriction� of the wildcard as defined by
-    * Particle Valid (Restriction) (�3.9.6)."
+    * SPEC (1) "Every member of the {particles} of the group is a `valid
+    * restriction` of the wildcard as defined by
+    * Particle Valid (Restriction) ($3.9.6)."
     */
     part = (xmlSchemaParticlePtr) r->children->children;
     do {
@@ -17092,7 +17094,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
     /*
     * SPEC (2) "The effective total range of the group [...] is a
     * valid restriction of B's occurrence range as defined by
-    * Occurrence Range OK (�3.9.6)."
+    * Occurrence Range OK ($3.9.6)."
     */
     if (xmlSchemaCheckParticleRangeOK(
            xmlSchemaGetParticleTotalRangeMin(r),
@@ -17132,11 +17134,11 @@ xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt,
        (r->children->type != b->children->type))
        return (-1);
     /*
-    * SPEC "For an all or sequence group particle to be a ï¿½valid
-    * restriction� of another group particle with the same {compositor}..."
+    * SPEC "For an all or sequence group particle to be a `valid
+    * restriction` of another group particle with the same {compositor}..."
     *
     * SPEC (1) "R's occurrence range is a valid restriction of B's
-    * occurrence range as defined by Occurrence Range OK (�3.9.6)."
+    * occurrence range as defined by Occurrence Range OK ($3.9.6)."
     */
     if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
            b->minOccurs, b->maxOccurs))
@@ -17760,7 +17762,7 @@ xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt,
     xmlSchemaTypeLinkPtr link, lastLink, prevLink, subLink, newLink;
     /*
     * The actual value is then formed by replacing any union type
-    * definition in the ï¿½explicit members� with the members of their
+    * definition in the `explicit members` with the members of their
     * {member type definitions}, in order.
     *
     * TODO: There's a bug entry at
@@ -17894,8 +17896,8 @@ xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type)
        }
     }
     /*
-    * For all ï¿½atomic� datatypes other than string (and types ï¿½derived�
-    * by ï¿½restriction� from it) the value of whiteSpace is fixed to
+    * For all `atomic` datatypes other than string (and types `derived`
+    * by `restriction` from it) the value of whiteSpace is fixed to
     * collapse
     */
     {
@@ -18084,7 +18086,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
     * SPEC src-simple-type 1
     * "The corresponding simple type definition, if any, must satisfy
     * the conditions set out in Constraints on Simple Type Definition
-    * Schema Components (�3.14.6)."
+    * Schema Components ($3.14.6)."
     */
     /*
     * Schema Component Constraint: Simple Type Definition Properties Correct
@@ -18344,7 +18346,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
            ( ((xmlSchemaTreeItemPtr) particle->children)->children == NULL))) {
            if (type->flags & XML_SCHEMAS_TYPE_MIXED) {
                /*
-               * SPEC (2.1.4) "If the ï¿½effective mixed� is true, then
+               * SPEC (2.1.4) "If the `effective mixed` is true, then
                * a particle whose properties are as follows:..."
                *
                * Empty sequence model group with
@@ -18406,7 +18408,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
            if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) {
                /*
                * SPEC (3.2.1)
-               * "If the ï¿½effective content� is empty, then the
+               * "If the `effective content` is empty, then the
                *  {content type} of the [...] base ..."
                */
                type->contentType = baseType->contentType;
@@ -18513,7 +18515,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
                    particle->children =
                        ((xmlSchemaParticlePtr) baseType->subtypes)->children;
                    /*
-                   * SPEC "followed by the ï¿½effective content�."
+                   * SPEC "followed by the `effective content`."
                    */
                    particle->next = effectiveContent;
                    /*
@@ -18657,12 +18659,12 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
 
                /* 4.3.5.5 Constraints on enumeration Schema Components
                * Schema Component Constraint: enumeration valid restriction
-               * It is an ï¿½error� if any member of {value} is not in the
-               * ï¿½value space� of {base type definition}.
+               * It is an `error` if any member of {value} is not in the
+               * `value space` of {base type definition}.
                *
                * minInclusive, maxInclusive, minExclusive, maxExclusive:
-               * The value ï¿½must� be in the
-               * ï¿½value space� of the ï¿½base type�.
+               * The value `must` be in the
+               * `value space` of the `base type`.
                */
                /*
                * This function is intended to deliver a compiled value
@@ -19097,9 +19099,9 @@ xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr,
     * not be an <attributeGroup> with ref [attribute] which resolves
     * to the component corresponding to this <attributeGroup>. Indirect
     * circularity is also ruled out. That is, when QName resolution
-    * (Schema Document) (�3.15.3) is applied to a ï¿½QName� arising from
+    * (Schema Document) ($3.15.3) is applied to a `QName` arising from
     * any <attributeGroup>s with a ref [attribute] among the [children],
-    * it must not be the case that a ï¿½QName� is encountered at any depth
+    * it must not be the case that a `QName` is encountered at any depth
     * which resolves to the component corresponding to this <attributeGroup>.
     */
     if (attrGr->attrUses == NULL)
@@ -19356,8 +19358,8 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
     * SPEC ag-props-correct
     * (1) "The values of the properties of an attribute group definition
     * must be as described in the property tableau in The Attribute
-    * Group Definition Schema Component (�3.6.1), modulo the impact of
-    * Missing Sub-components (�5.3);"
+    * Group Definition Schema Component ($3.6.1), modulo the impact of
+    * Missing Sub-components ($5.3);"
     */
 
     if ((attrGr->attrUses != NULL) &&
@@ -19491,8 +19493,8 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
     * SPEC a-props-correct (1)
     * "The values of the properties of an attribute declaration must
     * be as described in the property tableau in The Attribute
-    * Declaration Schema Component (�3.2.1), modulo the impact of
-    * Missing Sub-components (�5.3)."
+    * Declaration Schema Component ($3.2.1), modulo the impact of
+    * Missing Sub-components ($5.3)."
     */
 
     if (WXS_ATTR_TYPEDEF(attr) == NULL)
@@ -19520,9 +19522,9 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
        /*
        * SPEC a-props-correct (2)
        * "if there is a {value constraint}, the canonical lexical
-       * representation of its value must be ï¿½valid� with respect
-       * to the {type definition} as defined in String Valid (�3.14.4)."
-       * TODO: Don't care about the *cononical* stuff here, this requirement
+       * representation of its value must be `valid` with respect
+       * to the {type definition} as defined in String Valid ($3.14.4)."
+       * TODO: Don't care about the *canonical* stuff here, this requirement
        * will be removed in WXS 1.1 anyway.
        */
        ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt,
@@ -19589,15 +19591,15 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
     /*
     * SPEC (1) "The values of the properties of an element declaration
     * must be as described in the property tableau in The Element
-    * Declaration Schema Component (�3.3.1), modulo the impact of Missing
-    * Sub-components (�5.3)."
+    * Declaration Schema Component ($3.3.1), modulo the impact of Missing
+    * Sub-components ($5.3)."
     */
     if (WXS_SUBST_HEAD(elemDecl) != NULL) {
        xmlSchemaElementPtr head = WXS_SUBST_HEAD(elemDecl), circ;
 
        xmlSchemaCheckElementDeclComponent(head, pctxt);
        /*
-       * SPEC (3) "If there is a non-�absent� {substitution group
+       * SPEC (3) "If there is a non-`absent` {substitution group
        * affiliation}, then {scope} must be global."
        */
        if ((elemDecl->flags & XML_SCHEMAS_ELEM_GLOBAL) == 0) {
@@ -19641,9 +19643,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
        * of the element declaration must be validly derived from the {type
        * definition} of the {substitution group affiliation}, given the value
        * of the {substitution group exclusions} of the {substitution group
-       * affiliation}, as defined in Type Derivation OK (Complex) (�3.4.6)
+       * affiliation}, as defined in Type Derivation OK (Complex) ($3.4.6)
        * (if the {type definition} is complex) or as defined in
-       * Type Derivation OK (Simple) (�3.14.6) (if the {type definition} is
+       * Type Derivation OK (Simple) ($3.14.6) (if the {type definition} is
        * simple)."
        *
        * NOTE: {substitution group exclusions} means the values of the
@@ -19707,9 +19709,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
 
        /*
        * SPEC (2) "If there is a {value constraint}, the canonical lexical
-       * representation of its value must be ï¿½valid� with respect to the
+       * representation of its value must be `valid` with respect to the
        * {type definition} as defined in Element Default Valid (Immediate)
-       * (�3.3.6)."
+       * ($3.3.6)."
        */
        if (typeDef == NULL) {
            xmlSchemaPErr(pctxt, elemDecl->node,
@@ -19777,7 +19779,7 @@ xmlSchemaCheckElemSubstGroup(xmlSchemaParserCtxtPtr ctxt,
        /*
        * SPEC (2) "It is validly substitutable for HEAD subject to HEAD's
        * {disallowed substitutions} as the blocking constraint, as defined in
-       * Substitution Group OK (Transitive) (�3.3.6)."
+       * Substitution Group OK (Transitive) ($3.3.6)."
        */
        for (head = WXS_SUBST_HEAD(elemDecl); head != NULL;
            head = WXS_SUBST_HEAD(head)) {
@@ -19910,7 +19912,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
                    * SPEC Element Declarations Consistent:
                    * "If the {particles} contains, either directly,
                    * indirectly (that is, within the {particles} of a
-                   * contained model group, recursively) or ï¿½implicitly�
+                   * contained model group, recursively) or `implicitly`
                    * two or more element declaration particles with
                    * the same {name} and {target namespace}, then
                    * all their type definitions must be the same
@@ -20108,12 +20110,12 @@ xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
        ptx = xmlSchemaGetPrimitiveType(tx);
        pty = xmlSchemaGetPrimitiveType(ty);
        /*
-       * (1) if a datatype T' is ï¿½derived� by ï¿½restriction� from an
-       * atomic datatype T then the ï¿½value space� of T' is a subset of
-       * the ï¿½value space� of T. */
+       * (1) if a datatype T' is `derived` by `restriction` from an
+       * atomic datatype T then the `value space` of T' is a subset of
+       * the `value space` of T. */
        /*
-       * (2) if datatypes T' and T'' are ï¿½derived� by ï¿½restriction�
-       * from a common atomic ancestor T then the ï¿½value space�s of T'
+       * (2) if datatypes T' and T'' are `derived` by `restriction`
+       * from a common atomic ancestor T then the `value space`s of T'
        * and T'' may overlap.
        */
        if (ptx != pty)
@@ -20214,8 +20216,8 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
     * SPEC au-props-correct (1)
     * "The values of the properties of an attribute use must be as
     * described in the property tableau in The Attribute Use Schema
-    * Component (�3.5.1), modulo the impact of Missing
-    * Sub-components (�5.3)."
+    * Component ($3.5.1), modulo the impact of Missing
+    * Sub-components ($5.3)."
     */
 
     if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) &&
@@ -20316,8 +20318,8 @@ xmlSchemaResolveAttrTypeReferences(xmlSchemaAttributePtr item,
     /*
     * The simple type definition corresponding to the <simpleType> element
     * information item in the [children], if present, otherwise the simple
-    * type definition ï¿½resolved� to by the ï¿½actual value� of the type
-    * [attribute], if present, otherwise the ï¿½simple ur-type definition�.
+    * type definition `resolved` to by the `actual value` of the type
+    * [attribute], if present, otherwise the `simple ur-type definition`.
     */
     if (item->flags & XML_SCHEMAS_ATTR_INTERNAL_RESOLVED)
        return(0);
@@ -20481,11 +20483,11 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
 
            /*
            * SPEC src-redefine:
-           * (6.2.1) "The ï¿½actual value� of its own name attribute plus
-           * target namespace must successfully ï¿½resolve� to a model
+           * (6.2.1) "The `actual value` of its own name attribute plus
+           * target namespace must successfully `resolve` to a model
            * group definition in I."
-           * (7.2.1) "The ï¿½actual value� of its own name attribute plus
-           * target namespace must successfully ï¿½resolve� to an attribute
+           * (7.2.1) "The `actual value` of its own name attribute plus
+           * target namespace must successfully `resolve` to an attribute
            * group definition in I."
 
            *
@@ -20658,10 +20660,10 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
                * SPEC src-redefine:
                * (6.2.2) "The {model group} of the model group definition
                * which corresponds to it per XML Representation of Model
-               * Group Definition Schema Components (�3.7.2) must be a
-               * ï¿½valid restriction� of the {model group} of that model
+               * Group Definition Schema Components ($3.7.2) must be a
+               * `valid restriction` of the {model group} of that model
                * group definition in I, as defined in Particle Valid
-               * (Restriction) (�3.9.6)."
+               * (Restriction) ($3.9.6)."
                */
                break;
            case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
@@ -20670,11 +20672,11 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
                * (7.2.2) "The {attribute uses} and {attribute wildcard} of
                * the attribute group definition which corresponds to it
                * per XML Representation of Attribute Group Definition Schema
-               * Components (�3.6.2) must be ï¿½valid restrictions� of the
+               * Components ($3.6.2) must be `valid restrictions` of the
                * {attribute uses} and {attribute wildcard} of that attribute
                * group definition in I, as defined in clause 2, clause 3 and
                * clause 4 of Derivation Valid (Restriction, Complex)
-               * (�3.4.6) (where references to the base type definition are
+               * ($3.4.6) (where references to the base type definition are
                * understood as references to the attribute group definition
                * in I)."
                */
@@ -20849,9 +20851,9 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
 
     * (6.2.2) The {model group} of the model group definition which
     * corresponds to it per XML Representation of Model Group
-    * Definition Schema Components (�3.7.2) must be a ï¿½valid
-    * restriction� of the {model group} of that model group definition
-    * in I, as defined in Particle Valid (Restriction) (�3.9.6)."
+    * Definition Schema Components ($3.7.2) must be a `valid
+    * restriction` of the {model group} of that model group definition
+    * in I, as defined in Particle Valid (Restriction) ($3.9.6)."
     */
     xmlSchemaCheckSRCRedefineFirst(pctxt);
 
@@ -21535,8 +21537,8 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type)
            return(XML_SCHEMA_WHITESPACE_REPLACE);
        else {
            /*
-           * For all ï¿½atomic� datatypes other than string (and types ï¿½derived�
-           * by ï¿½restriction� from it) the value of whiteSpace is fixed to
+           * For all `atomic` datatypes other than string (and types `derived`
+           * by `restriction` from it) the value of whiteSpace is fixed to
            * collapse
            * Note that this includes built-in list datatypes.
            */
@@ -22841,7 +22843,7 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
                    xmlChar *str = NULL;
                    /*
                    * cvc-identity-constraint:
-                   * 3 For each node in the ï¿½target node set� all
+                   * 3 For each node in the `target node set` all
                    * of the {fields}, with that node as the context
                    * node, evaluate to either an empty node-set or
                    * a node-set with exactly one member, which must
@@ -22971,8 +22973,8 @@ create_key:
 
            /*
            * 4.1 If the {identity-constraint category} is unique(/key),
-           * then no two members of the ï¿½qualified node set� have
-           * ï¿½key-sequences� whose members are pairwise equal, as
+           * then no two members of the `qualified node set` have
+           * `key-sequences` whose members are pairwise equal, as
            * defined by Equal in [XML Schemas: Datatypes].
            *
            * Get the IDC binding from the matcher and check for
@@ -23100,10 +23102,10 @@ selector_key_error:
            {
                xmlChar *str = NULL;
                /*
-               * 4.2.1 (KEY) The ï¿½target node set� and the
-               * ï¿½qualified node set� are equal, that is, every
-               * member of the ï¿½target node set� is also a member
-               * of the ï¿½qualified node set� and vice versa.
+               * 4.2.1 (KEY) The `target node set` and the
+               * `qualified node set` are equal, that is, every
+               * member of the `target node set` is also a member
+               * of the `qualified node set` and vice versa.
                */
                xmlSchemaCustomErr(ACTXT_CAST vctxt,
                    XML_SCHEMAV_CVC_IDC, NULL,
@@ -24499,14 +24501,14 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
     */
     /*
     * 2.1 If The definition is ENTITY or is validly derived from ENTITY given
-    * the empty set, as defined in Type Derivation OK (Simple) (�3.14.6), then
-    * the string must be a ï¿½declared entity name�.
+    * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6), then
+    * the string must be a `declared entity name`.
     */
     /*
     * 2.2 If The definition is ENTITIES or is validly derived from ENTITIES
-    * given the empty set, as defined in Type Derivation OK (Simple) (�3.14.6),
-    * then every whitespace-delimited substring of the string must be a ï¿½declared
-    * entity name�.
+    * given the empty set, as defined in Type Derivation OK (Simple) ($3.14.6),
+    * then every whitespace-delimited substring of the string must be a `declared
+    * entity name`.
     */
     /*
     * 2.3 otherwise no further condition applies.
@@ -24518,8 +24520,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
     if (WXS_IS_ANY_SIMPLE_TYPE(type) || WXS_IS_ATOMIC(type)) {
        xmlSchemaTypePtr biType; /* The built-in type. */
        /*
-       * SPEC (1.2.1) "if {variety} is ï¿½atomic� then the string must ï¿½match�
-       * a literal in the ï¿½lexical space� of {base type definition}"
+       * SPEC (1.2.1) "if {variety} is `atomic` then the string must `match`
+       * a literal in the `lexical space` of {base type definition}"
        */
        /*
        * Whitespace-normalize.
@@ -24630,9 +24632,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
        xmlChar *tmpValue = NULL;
        unsigned long len = 0;
        xmlSchemaValPtr prevVal = NULL, curVal = NULL;
-       /* 1.2.2 if {variety} is ï¿½list� then the string must be a sequence
-       * of white space separated tokens, each of which ï¿½match�es a literal
-       * in the ï¿½lexical space� of {item type definition}
+       /* 1.2.2 if {variety} is `list` then the string must be a sequence
+       * of white space separated tokens, each of which `match`es a literal
+       * in the `lexical space` of {item type definition}
        */
        /*
        * Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if
@@ -24713,10 +24715,10 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
     } else if (WXS_IS_UNION(type)) {
        xmlSchemaTypeLinkPtr memberLink;
        /*
-       * TODO: For all datatypes ï¿½derived� by ï¿½union�  whiteSpace does
-       * not apply directly; however, the normalization behavior of ï¿½union�
+       * TODO: For all datatypes `derived` by `union`  whiteSpace does
+       * not apply directly; however, the normalization behavior of `union`
        * types is controlled by the value of whiteSpace on that one of the
-       * ï¿½memberTypes� against which the ï¿½union� is successfully validated.
+       * `memberTypes` against which the `union` is successfully validated.
        *
        * This means that the value is normalized by the first validating
        * member type, then the facets of the union type are applied. This
@@ -24724,8 +24726,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
        */
 
        /*
-       * 1.2.3 if {variety} is ï¿½union� then the string must ï¿½match� a
-       * literal in the ï¿½lexical space� of at least one member of
+       * 1.2.3 if {variety} is `union` then the string must `match` a
+       * literal in the `lexical space` of at least one member of
        * {member type definitions}
        */
        memberLink = xmlSchemaGetUnionSimpleTypeMemberTypes(type);
@@ -24764,9 +24766,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
        */
        if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
            /*
-           * The normalization behavior of ï¿½union� types is controlled by
-           * the value of whiteSpace on that one of the ï¿½memberTypes�
-           * against which the ï¿½union� is successfully validated.
+           * The normalization behavior of `union` types is controlled by
+           * the value of whiteSpace on that one of the `memberTypes`
+           * against which the `union` is successfully validated.
            */
            NORMALIZE(memberLink->type);
            ret = xmlSchemaValidateFacets(actxt, node, type,
@@ -24926,14 +24928,14 @@ xmlSchemaProcessXSIType(xmlSchemaValidCtxtPtr vctxt,
 
            /*
            * SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK)
-           * "The ï¿½local type definition� must be validly
+           * "The `local type definition` must be validly
            * derived from the {type definition} given the union of
            * the {disallowed substitutions} and the {type definition}'s
            * {prohibited substitutions}, as defined in
-           * Type Derivation OK (Complex) (�3.4.6)
+           * Type Derivation OK (Complex) ($3.4.6)
            * (if it is a complex type definition),
            * or given {disallowed substitutions} as defined in Type
-           * Derivation OK (Simple) (�3.14.6) (if it is a simple type
+           * Derivation OK (Simple) ($3.14.6) (if it is a simple type
            * definition)."
            *
            * {disallowed substitutions}: the "block" on the element decl.
@@ -25204,8 +25206,8 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
 
     /*
     * SPEC (cvc-attribute)
-    * (1) "The declaration must not be ï¿½absent� (see Missing
-    * Sub-components (�5.3) for how this can fail to be
+    * (1) "The declaration must not be `absent` (see Missing
+    * Sub-components ($5.3) for how this can fail to be
     * the case)."
     * (2) "Its {type definition} must not be absent."
     *
@@ -25255,15 +25257,15 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
            * use with an {attribute declaration} whose {name} matches
            * the attribute information item's [local name] and whose
            * {target namespace} is identical to the attribute information
-           * item's [namespace name] (where an ï¿½absent� {target namespace}
+           * item's [namespace name] (where an `absent` {target namespace}
            * is taken to be identical to a [namespace name] with no value),
-           * then the attribute information must be ï¿½valid� with respect
+           * then the attribute information must be `valid` with respect
            * to that attribute use as per Attribute Locally Valid (Use)
-           * (�3.5.4). In this case the {attribute declaration} of that
-           * attribute use is the ï¿½context-determined declaration� for the
+           * ($3.5.4). In this case the {attribute declaration} of that
+           * attribute use is the `context-determined declaration` for the
            * attribute information item with respect to Schema-Validity
-           * Assessment (Attribute) (�3.2.4) and
-           * Assessment Outcome (Attribute) (�3.2.5).
+           * Assessment (Attribute) ($3.2.4) and
+           * Assessment Outcome (Attribute) ($3.2.5).
            */
            iattr->state = XML_SCHEMAS_ATTR_ASSESSED;
            iattr->use = attrUse;
@@ -25340,13 +25342,13 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
                continue;
            /*
            * SPEC (cvc-complex-type)
-           * (3.2.2) "The attribute information item must be ï¿½valid� with
-           * respect to it as defined in Item Valid (Wildcard) (�3.10.4)."
+           * (3.2.2) "The attribute information item must be `valid` with
+           * respect to it as defined in Item Valid (Wildcard) ($3.10.4)."
            *
            * SPEC Item Valid (Wildcard) (cvc-wildcard)
-           * "... its [namespace name] must be ï¿½valid� with respect to
+           * "... its [namespace name] must be `valid` with respect to
            * the wildcard constraint, as defined in Wildcard allows
-           * Namespace Name (�3.10.4)."
+           * Namespace Name ($3.10.4)."
            */
            if (xmlSchemaCheckCVCWildcardNamespace(type->attributeWildcard,
                    iattr->nsName) == 0) {
@@ -25382,11 +25384,11 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
                    * SPEC (cvc-complex-type)
                    * (5) "Let [Definition:]  the wild IDs be the set of
                    * all attribute information item to which clause 3.2
-                   * applied and whose ï¿½validation� resulted in a
-                   * ï¿½context-determined declaration� of mustFind or no
-                   * ï¿½context-determined declaration� at all, and whose
+                   * applied and whose `validation` resulted in a
+                   * `context-determined declaration` of mustFind or no
+                   * `context-determined declaration` at all, and whose
                    * [local name] and [namespace name] resolve (as
-                   * defined by QName resolution (Instance) (�3.15.4)) to
+                   * defined by QName resolution (Instance) ($3.15.4)) to
                    * an attribute declaration whose {type definition} is
                    * or is derived from ID. Then all of the following
                    * must be true:"
@@ -25396,7 +25398,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
                        iattr->typeDef, XML_SCHEMAS_ID)) {
                        /*
                        * SPEC (5.1) "There must be no more than one
-                       * item in ï¿½wild IDs�."
+                       * item in `wild IDs`."
                        */
                        if (wildIDs != 0) {
                            /* VAL TODO */
@@ -25407,7 +25409,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
                        wildIDs++;
                        /*
                        * SPEC (cvc-complex-type)
-                       * (5.2) "If ï¿½wild IDs� is non-empty, there must not
+                       * (5.2) "If `wild IDs` is non-empty, there must not
                        * be any attribute uses among the {attribute uses}
                        * whose {attribute declaration}'s {type definition}
                        * is or is derived from ID."
@@ -25617,9 +25619,9 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
            fixed = 0;
        /*
        * SPEC (cvc-attribute)
-       * (3) "The item's ï¿½normalized value� must be locally ï¿½valid�
+       * (3) "The item's `normalized value` must be locally `valid`
        * with respect to that {type definition} as per
-       * String Valid (�3.14.4)."
+       * String Valid ($3.14.4)."
        *
        * VAL TODO: Do we already have the
        * "normalized attribute value" here?
@@ -25657,9 +25659,9 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
        if (fixed) {
            /*
            * SPEC Attribute Locally Valid (Use) (cvc-au)
-           * "For an attribute information item to be�valid�
+           * "For an attribute information item to be `valid`
            * with respect to an attribute use its *normalized*
-           * value� must match the *canonical* lexical
+           * value must match the *canonical* lexical
            * representation of the attribute use's {value
            * constraint}value, if it is present and fixed."
            *
@@ -25668,7 +25670,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
            */
            /*
            * SPEC Attribute Locally Valid (cvc-attribute)
-           * (4) "The item's *actual* value� must match the *value* of
+           * (4) "The item's *actual* value must match the *value* of
            * the {value constraint}, if it is present and fixed."
            */
            if (iattr->val == NULL) {
@@ -25898,8 +25900,8 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
        * SPEC (2.1) "its {content type} must be a simple type definition
        * or mixed."
        * SPEC (2.2.2) "If the {content type} is mixed, then the {content
-       * type}'s particle must be ï¿½emptiable� as defined by
-       * Particle Emptiable (�3.9.6)."
+       * type}'s particle must be `emptiable` as defined by
+       * Particle Emptiable ($3.9.6)."
        */
        if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) &&
            ((! WXS_HAS_MIXED_CONTENT(inode->typeDef)) ||
@@ -25915,14 +25917,14 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
     }
     /*
     * 1 If the type definition is a simple type definition, then the string
-    * must be ï¿½valid� with respect to that definition as defined by String
-    * Valid (�3.14.4).
+    * must be `valid` with respect to that definition as defined by String
+    * Valid ($3.14.4).
     *
     * AND
     *
     * 2.2.1 If the {content type} is a simple type definition, then the
-    * string must be ï¿½valid� with respect to that simple type definition
-    * as defined by String Valid (�3.14.4).
+    * string must be `valid` with respect to that simple type definition
+    * as defined by String Valid ($3.14.4).
     */
     if (WXS_IS_SIMPLE(inode->typeDef)) {
 
@@ -26163,10 +26165,10 @@ character_content:
        (! INODE_NILLED(inode))) {
        /*
        * cvc-elt (3.3.4) : 5.1.1
-       * If the ï¿½actual type definition� is a ï¿½local type definition�
+       * If the `actual type definition` is a `local type definition`
        * then the canonical lexical representation of the {value constraint}
-       * value must be a valid default for the ï¿½actual type definition� as
-       * defined in Element Default Valid (Immediate) (�3.3.6).
+       * value must be a valid default for the `actual type definition` as
+       * defined in Element Default Valid (Immediate) ($3.3.6).
        */
        /*
        * NOTE: 'local' above means types acquired by xsi:type.
@@ -26196,9 +26198,9 @@ character_content:
        * cvc-elt (3.3.4) : 5.1.2
        * The element information item with the canonical lexical
        * representation of the {value constraint} value used as its
-       * ï¿½normalized value� must be ï¿½valid� with respect to the
-       * ï¿½actual type definition� as defined by Element Locally Valid (Type)
-       * (�3.3.4).
+       * `normalized value` must be `valid` with respect to the
+       * `actual type definition` as defined by Element Locally Valid (Type)
+       * ($3.3.4).
        */
        if (WXS_IS_SIMPLE(inode->typeDef)) {
            ret = xmlSchemaVCheckINodeDataType(vctxt,
@@ -26245,18 +26247,18 @@ default_psvi:
 
     } else if (! INODE_NILLED(inode)) {
        /*
-       * 5.2.1 The element information item must be ï¿½valid� with respect
-       * to the ï¿½actual type definition� as defined by Element Locally
-       * Valid (Type) (�3.3.4).
+       * 5.2.1 The element information item must be `valid` with respect
+       * to the `actual type definition` as defined by Element Locally
+       * Valid (Type) ($3.3.4).
        */
        if (WXS_IS_SIMPLE(inode->typeDef)) {
             /*
            * SPEC (cvc-type) (3.1)
            * "If the type definition is a simple type definition, ..."
            * (3.1.3) "If clause 3.2 of Element Locally Valid
-           * (Element) (�3.3.4) did not apply, then the ï¿½normalized value�
-           * must be ï¿½valid� with respect to the type definition as defined
-           * by String Valid (�3.14.4).
+           * (Element) ($3.3.4) did not apply, then the `normalized value`
+           * must be `valid` with respect to the type definition as defined
+           * by String Valid ($3.14.4).
            */
            ret = xmlSchemaVCheckINodeDataType(vctxt,
                    inode, inode->typeDef, inode->value);
@@ -26264,14 +26266,14 @@ default_psvi:
            /*
            * SPEC (cvc-type) (3.2) "If the type definition is a complex type
            * definition, then the element information item must be
-           * ï¿½valid� with respect to the type definition as per
-           * Element Locally Valid (Complex Type) (�3.4.4);"
+           * `valid` with respect to the type definition as per
+           * Element Locally Valid (Complex Type) ($3.4.4);"
            *
            * SPEC (cvc-complex-type) (2.2)
            * "If the {content type} is a simple type definition, ...
-           * the ï¿½normalized value� of the element information item is
-           * ï¿½valid� with respect to that simple type definition as
-           * defined by String Valid (�3.14.4)."
+           * the `normalized value` of the element information item is
+           * `valid` with respect to that simple type definition as
+           * defined by String Valid ($3.14.4)."
            */
            ret = xmlSchemaVCheckINodeDataType(vctxt,
                inode, inode->typeDef->contentTypeDef, inode->value);
@@ -26313,8 +26315,8 @@ default_psvi:
                */
                if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) {
                    /*
-                   * 5.2.2.2.1 If the {content type} of the ï¿½actual type
-                   * definition� is mixed, then the *initial value* of the
+                   * 5.2.2.2.1 If the {content type} of the `actual type
+                   * definition` is mixed, then the *initial value* of the
                    * item must match the canonical lexical representation
                    * of the {value constraint} value.
                    *
@@ -26338,8 +26340,8 @@ default_psvi:
                    }
                } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
                    /*
-                   * 5.2.2.2.2 If the {content type} of the ï¿½actual type
-                   * definition� is a simple type definition, then the
+                   * 5.2.2.2.2 If the {content type} of the `actual type
+                   * definition` is a simple type definition, then the
                    * *actual value* of the item must match the canonical
                    * lexical representation of the {value constraint} value.
                    */
@@ -26380,9 +26382,9 @@ end_elem:
        goto internal_error;
     /*
     * MAYBE TODO:
-    * SPEC (6) "The element information item must be ï¿½valid� with
+    * SPEC (6) "The element information item must be `valid` with
     * respect to each of the {identity-constraint definitions} as per
-    * Identity-constraint Satisfied (�3.11.4)."
+    * Identity-constraint Satisfied ($3.11.4)."
     */
     /*
     * PSVI TODO: If we expose IDC node-tables via PSVI then the tables
@@ -26460,8 +26462,8 @@ end_elem:
     vctxt->depth--;
     vctxt->inode = vctxt->elemInfos[vctxt->depth];
     /*
-    * VAL TODO: 7 If the element information item is the ï¿½validation root�, it must be
-    * ï¿½valid� per Validation Root Valid (ID/IDREF) (�3.3.4).
+    * VAL TODO: 7 If the element information item is the `validation root`, it must be
+    * `valid` per Validation Root Valid (ID/IDREF) ($3.3.4).
     */
     return (ret);
 
@@ -26542,11 +26544,11 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
                 * Fallback to "anyType".
                 *
                 * SPEC (cvc-assess-elt)
-                * "If the item cannot be ï¿½strictly assessed�, [...]
+                * "If the item cannot be `strictly assessed`, [...]
                 * an element information item's schema validity may be laxly
-                * assessed if its ï¿½context-determined declaration� is not
-                * skip by ï¿½validating� with respect to the ï¿½ur-type
-                * definition� as per Element Locally Valid (Type) (�3.3.4)."
+                * assessed if its `context-determined declaration` is not
+                * skip by `validating` with respect to the `ur-type
+                * definition` as per Element Locally Valid (Type) ($3.3.4)."
                */
                vctxt->inode->typeDef =
                    xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
@@ -26618,9 +26620,9 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
            * SPEC (2.4) "If the {content type} is element-only or mixed,
            * then the sequence of the element information item's
            * element information item [children], if any, taken in
-           * order, is ï¿½valid� with respect to the {content type}'s
+           * order, is `valid` with respect to the {content type}'s
            * particle, as defined in Element Sequence Locally Valid
-           * (Particle) (�3.9.4)."
+           * (Particle) ($3.9.4)."
            */
            ret = xmlRegExecPushString2(regexCtxt,
                vctxt->inode->localName,
index a9edc03..ff64f50 100644 (file)
@@ -242,6 +242,10 @@ xmlSchemaNewMinLengthFacet(int value)
     }
     ret->type = XML_SCHEMA_FACET_MINLENGTH;
     ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER);
+    if (ret->val == NULL) {
+        xmlFree(ret);
+       return(NULL);
+    }
     ret->val->value.decimal.lo = value;
     return (ret);
 }
@@ -3844,13 +3848,14 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
             * Coverity detected an overrun in daysInMonth
             * of size 12 at position 12 with index variable "((r)->mon - 1)"
             */
-           if (tmon < 0)
-               tmon = 0;
+           if (tmon < 1)
+               tmon = 1;
            if (tmon > 12)
                tmon = 12;
             tempdays += MAX_DAYINMONTH(tyr, tmon);
             carry = -1;
-        } else if (tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
+        } else if (VALID_YEAR(r->year) && VALID_MONTH(r->mon) &&
+                   tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
             tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon);
             carry = 1;
         } else
@@ -4929,7 +4934,7 @@ xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) {
 
     if (y->type == XML_SCHEMAS_STRING)
        yws = XML_SCHEMA_WHITESPACE_PRESERVE;
-    else if (x->type == XML_SCHEMAS_NORMSTRING)
+    else if (y->type == XML_SCHEMAS_NORMSTRING)
         yws = XML_SCHEMA_WHITESPACE_REPLACE;
     else
         yws = XML_SCHEMA_WHITESPACE_COLLAPSE;
@@ -5644,7 +5649,7 @@ xmlSchemaFormatFloat(double number, char buffer[], int buffersize)
  * @val: the precomputed value
  * @retValue: the returned value
  *
- * Get a the cononical lexical representation of the value.
+ * Get the canonical lexical representation of the value.
  * The caller has to FREE the returned retValue.
  *
  * WARNING: Some value types are not supported yet, resulting
@@ -6066,7 +6071,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
  * @retValue: the returned value
  * @ws: the whitespace type of the value
  *
- * Get a the cononical representation of the value.
+ * Get the canonical representation of the value.
  * The caller has to free the returned @retValue.
  *
  * Returns 0 if the value could be built, 1 if the value type is
index d3f29f8..fac20ac 100644 (file)
@@ -31,9 +31,8 @@
 /*
  * The following VA_COPY was coded following an example in
  * the Samba project.  It may not be sufficient for some
- * esoteric implementations of va_list (i.e. it may need
- * something involving a memcpy) but (hopefully) will be
- * sufficient for libxml2.
+ * esoteric implementations of va_list but (hopefully) will
+ * be sufficient for libxml2.
  */
 #ifndef VA_COPY
   #ifdef HAVE_VA_COPY
     #ifdef HAVE___VA_COPY
       #define VA_COPY(dest,src) __va_copy(dest, src)
     #else
-      #define VA_COPY(dest,src) (dest) = (src)
+      #ifndef VA_LIST_IS_ARRAY
+        #define VA_COPY(dest,src) (dest) = (src)
+      #else
+        #include <string.h>
+        #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
+      #endif
     #endif
   #endif
 #endif
@@ -2238,10 +2242,12 @@ xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name,
     if (count == -1)
         return -1;
     sum += count;
-    count = xmlTextWriterWriteString(writer, content);
-    if (count == -1)
-        return -1;
-    sum += count;
+    if (content != NULL) {
+       count = xmlTextWriterWriteString(writer, content);
+       if (count == -1)
+           return -1;
+       sum += count;
+    }
     count = xmlTextWriterEndElement(writer);
     if (count == -1)
         return -1;
index 97410e7..dc41ce6 100644 (file)
  * any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT)
  */
 
+#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
+/**
+ * xmlXPathCmpNodesExt:
+ * @node1:  the first node
+ * @node2:  the second node
+ *
+ * Compare two nodes w.r.t document order.
+ * This one is optimized for handling of non-element nodes.
+ *
+ * Returns -2 in case of error 1 if first point < second point, 0 if
+ *         it's the same node, -1 otherwise
+ */
+static int
+xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
+    int depth1, depth2;
+    int misc = 0, precedence1 = 0, precedence2 = 0;
+    xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
+    xmlNodePtr cur, root;
+    long l1, l2;
+
+    if ((node1 == NULL) || (node2 == NULL))
+       return(-2);
+
+    if (node1 == node2)
+       return(0);
+
+    /*
+     * a couple of optimizations which will avoid computations in most cases
+     */
+    switch (node1->type) {
+       case XML_ELEMENT_NODE:
+           if (node2->type == XML_ELEMENT_NODE) {
+               if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
+                   (0 > (long) node2->content) &&
+                   (node1->doc == node2->doc))
+               {
+                   l1 = -((long) node1->content);
+                   l2 = -((long) node2->content);
+                   if (l1 < l2)
+                       return(1);
+                   if (l1 > l2)
+                       return(-1);
+               } else
+                   goto turtle_comparison;
+           }
+           break;
+       case XML_ATTRIBUTE_NODE:
+           precedence1 = 1; /* element is owner */
+           miscNode1 = node1;
+           node1 = node1->parent;
+           misc = 1;
+           break;
+       case XML_TEXT_NODE:
+       case XML_CDATA_SECTION_NODE:
+       case XML_COMMENT_NODE:
+       case XML_PI_NODE: {
+           miscNode1 = node1;
+           /*
+           * Find nearest element node.
+           */
+           if (node1->prev != NULL) {
+               do {
+                   node1 = node1->prev;
+                   if (node1->type == XML_ELEMENT_NODE) {
+                       precedence1 = 3; /* element in prev-sibl axis */
+                       break;
+                   }
+                   if (node1->prev == NULL) {
+                       precedence1 = 2; /* element is parent */
+                       /*
+                       * URGENT TODO: Are there any cases, where the
+                       * parent of such a node is not an element node?
+                       */
+                       node1 = node1->parent;
+                       break;
+                   }
+               } while (1);
+           } else {
+               precedence1 = 2; /* element is parent */
+               node1 = node1->parent;
+           }
+           if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) ||
+               (0 <= (long) node1->content)) {
+               /*
+               * Fallback for whatever case.
+               */
+               node1 = miscNode1;
+               precedence1 = 0;
+           } else
+               misc = 1;
+       }
+           break;
+       case XML_NAMESPACE_DECL:
+           /*
+           * TODO: why do we return 1 for namespace nodes?
+           */
+           return(1);
+       default:
+           break;
+    }
+    switch (node2->type) {
+       case XML_ELEMENT_NODE:
+           break;
+       case XML_ATTRIBUTE_NODE:
+           precedence2 = 1; /* element is owner */
+           miscNode2 = node2;
+           node2 = node2->parent;
+           misc = 1;
+           break;
+       case XML_TEXT_NODE:
+       case XML_CDATA_SECTION_NODE:
+       case XML_COMMENT_NODE:
+       case XML_PI_NODE: {
+           miscNode2 = node2;
+           if (node2->prev != NULL) {
+               do {
+                   node2 = node2->prev;
+                   if (node2->type == XML_ELEMENT_NODE) {
+                       precedence2 = 3; /* element in prev-sibl axis */
+                       break;
+                   }
+                   if (node2->prev == NULL) {
+                       precedence2 = 2; /* element is parent */
+                       node2 = node2->parent;
+                       break;
+                   }
+               } while (1);
+           } else {
+               precedence2 = 2; /* element is parent */
+               node2 = node2->parent;
+           }
+           if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||
+               (0 <= (long) node2->content))
+           {
+               node2 = miscNode2;
+               precedence2 = 0;
+           } else
+               misc = 1;
+       }
+           break;
+       case XML_NAMESPACE_DECL:
+           return(1);
+       default:
+           break;
+    }
+    if (misc) {
+       if (node1 == node2) {
+           if (precedence1 == precedence2) {
+               /*
+               * The ugly case; but normally there aren't many
+               * adjacent non-element nodes around.
+               */
+               cur = miscNode2->prev;
+               while (cur != NULL) {
+                   if (cur == miscNode1)
+                       return(1);
+                   if (cur->type == XML_ELEMENT_NODE)
+                       return(-1);
+                   cur = cur->prev;
+               }
+               return (-1);
+           } else {
+               /*
+               * Evaluate based on higher precedence wrt to the element.
+               * TODO: This assumes attributes are sorted before content.
+               *   Is this 100% correct?
+               */
+               if (precedence1 < precedence2)
+                   return(1);
+               else
+                   return(-1);
+           }
+       }
+       /*
+       * Special case: One of the helper-elements is contained by the other.
+       * <foo>
+       *   <node2>
+       *     <node1>Text-1(precedence1 == 2)</node1>
+       *   </node2>
+       *   Text-6(precedence2 == 3)
+       * </foo>
+       */
+       if ((precedence2 == 3) && (precedence1 > 1)) {
+           cur = node1->parent;
+           while (cur) {
+               if (cur == node2)
+                   return(1);
+               cur = cur->parent;
+           }
+       }
+       if ((precedence1 == 3) && (precedence2 > 1)) {
+           cur = node2->parent;
+           while (cur) {
+               if (cur == node1)
+                   return(-1);
+               cur = cur->parent;
+           }
+       }
+    }
+
+    /*
+     * Speedup using document order if availble.
+     */
+    if ((node1->type == XML_ELEMENT_NODE) &&
+       (node2->type == XML_ELEMENT_NODE) &&
+       (0 > (long) node1->content) &&
+       (0 > (long) node2->content) &&
+       (node1->doc == node2->doc)) {
+
+       l1 = -((long) node1->content);
+       l2 = -((long) node2->content);
+       if (l1 < l2)
+           return(1);
+       if (l1 > l2)
+           return(-1);
+    }
+
+turtle_comparison:
+
+    if (node1 == node2->prev)
+       return(1);
+    if (node1 == node2->next)
+       return(-1);
+    /*
+     * compute depth to root
+     */
+    for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) {
+       if (cur == node1)
+           return(1);
+       depth2++;
+    }
+    root = cur;
+    for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) {
+       if (cur == node2)
+           return(-1);
+       depth1++;
+    }
+    /*
+     * Distinct document (or distinct entities :-( ) case.
+     */
+    if (root != cur) {
+       return(-2);
+    }
+    /*
+     * get the nearest common ancestor.
+     */
+    while (depth1 > depth2) {
+       depth1--;
+       node1 = node1->parent;
+    }
+    while (depth2 > depth1) {
+       depth2--;
+       node2 = node2->parent;
+    }
+    while (node1->parent != node2->parent) {
+       node1 = node1->parent;
+       node2 = node2->parent;
+       /* should not happen but just in case ... */
+       if ((node1 == NULL) || (node2 == NULL))
+           return(-2);
+    }
+    /*
+     * Find who's first.
+     */
+    if (node1 == node2->prev)
+       return(1);
+    if (node1 == node2->next)
+       return(-1);
+    /*
+     * Speedup using document order if availble.
+     */
+    if ((node1->type == XML_ELEMENT_NODE) &&
+       (node2->type == XML_ELEMENT_NODE) &&
+       (0 > (long) node1->content) &&
+       (0 > (long) node2->content) &&
+       (node1->doc == node2->doc)) {
+
+       l1 = -((long) node1->content);
+       l2 = -((long) node2->content);
+       if (l1 < l2)
+           return(1);
+       if (l1 > l2)
+           return(-1);
+    }
+
+    for (cur = node1->next;cur != NULL;cur = cur->next)
+       if (cur == node2)
+           return(1);
+    return(-1); /* assume there is no sibling list corruption */
+}
+#endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */
+
 /*
  * Wrapper for the Timsort argorithm from timsort.h
  */
 static
 int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
 #ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
-    static int xmlXPathCmpNodesExt(xmlNodePtr, xmlNodePtr);
     static int wrap_cmp( xmlNodePtr x, xmlNodePtr y )
     {
         int res = xmlXPathCmpNodesExt(x, y);
@@ -327,7 +618,7 @@ static const char *xmlXPathErrorMessages[] = {
     "Encoding error\n",
     "Char out of XML range\n",
     "Invalid or incomplete context\n",
-    "Stack usage errror\n",
+    "Stack usage error\n",
     "Forbidden variable\n",
     "?? Unknown error ??\n"    /* Must be last in the list! */
 };
@@ -2885,6 +3176,12 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
                                fraction_place, number);
            }
 
+           /* Remove leading spaces sometimes inserted by snprintf */
+           while (work[0] == ' ') {
+               for (ptr = &work[0];(ptr[0] = ptr[1]);ptr++);
+               size--;
+           }
+
            /* Remove fractional trailing zeroes */
            after_fraction = work + size;
            ptr = after_fraction;
@@ -2948,367 +3245,80 @@ xmlXPathOrderDocElems(xmlDocPtr doc) {
        }
        do {
            cur = cur->parent;
-           if (cur == NULL)
-               break;
-           if (cur == (xmlNodePtr) doc) {
-               cur = NULL;
-               break;
-           }
-           if (cur->next != NULL) {
-               cur = cur->next;
-               break;
-           }
-       } while (cur != NULL);
-    }
-    return(count);
-}
-
-/**
- * xmlXPathCmpNodes:
- * @node1:  the first node
- * @node2:  the second node
- *
- * Compare two nodes w.r.t document order
- *
- * Returns -2 in case of error 1 if first point < second point, 0 if
- *         it's the same node, -1 otherwise
- */
-int
-xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
-    int depth1, depth2;
-    int attr1 = 0, attr2 = 0;
-    xmlNodePtr attrNode1 = NULL, attrNode2 = NULL;
-    xmlNodePtr cur, root;
-
-    if ((node1 == NULL) || (node2 == NULL))
-       return(-2);
-    /*
-     * a couple of optimizations which will avoid computations in most cases
-     */
-    if (node1 == node2)                /* trivial case */
-       return(0);
-    if (node1->type == XML_ATTRIBUTE_NODE) {
-       attr1 = 1;
-       attrNode1 = node1;
-       node1 = node1->parent;
-    }
-    if (node2->type == XML_ATTRIBUTE_NODE) {
-       attr2 = 1;
-       attrNode2 = node2;
-       node2 = node2->parent;
-    }
-    if (node1 == node2) {
-       if (attr1 == attr2) {
-           /* not required, but we keep attributes in order */
-           if (attr1 != 0) {
-               cur = attrNode2->prev;
-               while (cur != NULL) {
-                   if (cur == attrNode1)
-                       return (1);
-                   cur = cur->prev;
-               }
-               return (-1);
-           }
-           return(0);
-       }
-       if (attr2 == 1)
-           return(1);
-       return(-1);
-    }
-    if ((node1->type == XML_NAMESPACE_DECL) ||
-        (node2->type == XML_NAMESPACE_DECL))
-       return(1);
-    if (node1 == node2->prev)
-       return(1);
-    if (node1 == node2->next)
-       return(-1);
-
-    /*
-     * Speedup using document order if availble.
-     */
-    if ((node1->type == XML_ELEMENT_NODE) &&
-       (node2->type == XML_ELEMENT_NODE) &&
-       (0 > (long) node1->content) &&
-       (0 > (long) node2->content) &&
-       (node1->doc == node2->doc)) {
-       long l1, l2;
-
-       l1 = -((long) node1->content);
-       l2 = -((long) node2->content);
-       if (l1 < l2)
-           return(1);
-       if (l1 > l2)
-           return(-1);
-    }
-
-    /*
-     * compute depth to root
-     */
-    for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) {
-       if (cur == node1)
-           return(1);
-       depth2++;
-    }
-    root = cur;
-    for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) {
-       if (cur == node2)
-           return(-1);
-       depth1++;
-    }
-    /*
-     * Distinct document (or distinct entities :-( ) case.
-     */
-    if (root != cur) {
-       return(-2);
-    }
-    /*
-     * get the nearest common ancestor.
-     */
-    while (depth1 > depth2) {
-       depth1--;
-       node1 = node1->parent;
-    }
-    while (depth2 > depth1) {
-       depth2--;
-       node2 = node2->parent;
-    }
-    while (node1->parent != node2->parent) {
-       node1 = node1->parent;
-       node2 = node2->parent;
-       /* should not happen but just in case ... */
-       if ((node1 == NULL) || (node2 == NULL))
-           return(-2);
-    }
-    /*
-     * Find who's first.
-     */
-    if (node1 == node2->prev)
-       return(1);
-    if (node1 == node2->next)
-       return(-1);
-    /*
-     * Speedup using document order if availble.
-     */
-    if ((node1->type == XML_ELEMENT_NODE) &&
-       (node2->type == XML_ELEMENT_NODE) &&
-       (0 > (long) node1->content) &&
-       (0 > (long) node2->content) &&
-       (node1->doc == node2->doc)) {
-       long l1, l2;
-
-       l1 = -((long) node1->content);
-       l2 = -((long) node2->content);
-       if (l1 < l2)
-           return(1);
-       if (l1 > l2)
-           return(-1);
+           if (cur == NULL)
+               break;
+           if (cur == (xmlNodePtr) doc) {
+               cur = NULL;
+               break;
+           }
+           if (cur->next != NULL) {
+               cur = cur->next;
+               break;
+           }
+       } while (cur != NULL);
     }
-
-    for (cur = node1->next;cur != NULL;cur = cur->next)
-       if (cur == node2)
-           return(1);
-    return(-1); /* assume there is no sibling list corruption */
+    return(count);
 }
 
-#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
 /**
- * xmlXPathCmpNodesExt:
+ * xmlXPathCmpNodes:
  * @node1:  the first node
  * @node2:  the second node
  *
- * Compare two nodes w.r.t document order.
- * This one is optimized for handling of non-element nodes.
+ * Compare two nodes w.r.t document order
  *
  * Returns -2 in case of error 1 if first point < second point, 0 if
  *         it's the same node, -1 otherwise
  */
-static int
-xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
+int
+xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
     int depth1, depth2;
-    int misc = 0, precedence1 = 0, precedence2 = 0;
-    xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
+    int attr1 = 0, attr2 = 0;
+    xmlNodePtr attrNode1 = NULL, attrNode2 = NULL;
     xmlNodePtr cur, root;
-    long l1, l2;
 
     if ((node1 == NULL) || (node2 == NULL))
        return(-2);
-
-    if (node1 == node2)
-       return(0);
-
     /*
      * a couple of optimizations which will avoid computations in most cases
      */
-    switch (node1->type) {
-       case XML_ELEMENT_NODE:
-           if (node2->type == XML_ELEMENT_NODE) {
-               if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
-                   (0 > (long) node2->content) &&
-                   (node1->doc == node2->doc))
-               {
-                   l1 = -((long) node1->content);
-                   l2 = -((long) node2->content);
-                   if (l1 < l2)
-                       return(1);
-                   if (l1 > l2)
-                       return(-1);
-               } else
-                   goto turtle_comparison;
-           }
-           break;
-       case XML_ATTRIBUTE_NODE:
-           precedence1 = 1; /* element is owner */
-           miscNode1 = node1;
-           node1 = node1->parent;
-           misc = 1;
-           break;
-       case XML_TEXT_NODE:
-       case XML_CDATA_SECTION_NODE:
-       case XML_COMMENT_NODE:
-       case XML_PI_NODE: {
-           miscNode1 = node1;
-           /*
-           * Find nearest element node.
-           */
-           if (node1->prev != NULL) {
-               do {
-                   node1 = node1->prev;
-                   if (node1->type == XML_ELEMENT_NODE) {
-                       precedence1 = 3; /* element in prev-sibl axis */
-                       break;
-                   }
-                   if (node1->prev == NULL) {
-                       precedence1 = 2; /* element is parent */
-                       /*
-                       * URGENT TODO: Are there any cases, where the
-                       * parent of such a node is not an element node?
-                       */
-                       node1 = node1->parent;
-                       break;
-                   }
-               } while (1);
-           } else {
-               precedence1 = 2; /* element is parent */
-               node1 = node1->parent;
-           }
-           if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) ||
-               (0 <= (long) node1->content)) {
-               /*
-               * Fallback for whatever case.
-               */
-               node1 = miscNode1;
-               precedence1 = 0;
-           } else
-               misc = 1;
-       }
-           break;
-       case XML_NAMESPACE_DECL:
-           /*
-           * TODO: why do we return 1 for namespace nodes?
-           */
-           return(1);
-       default:
-           break;
+    if (node1 == node2)                /* trivial case */
+       return(0);
+    if (node1->type == XML_ATTRIBUTE_NODE) {
+       attr1 = 1;
+       attrNode1 = node1;
+       node1 = node1->parent;
     }
-    switch (node2->type) {
-       case XML_ELEMENT_NODE:
-           break;
-       case XML_ATTRIBUTE_NODE:
-           precedence2 = 1; /* element is owner */
-           miscNode2 = node2;
-           node2 = node2->parent;
-           misc = 1;
-           break;
-       case XML_TEXT_NODE:
-       case XML_CDATA_SECTION_NODE:
-       case XML_COMMENT_NODE:
-       case XML_PI_NODE: {
-           miscNode2 = node2;
-           if (node2->prev != NULL) {
-               do {
-                   node2 = node2->prev;
-                   if (node2->type == XML_ELEMENT_NODE) {
-                       precedence2 = 3; /* element in prev-sibl axis */
-                       break;
-                   }
-                   if (node2->prev == NULL) {
-                       precedence2 = 2; /* element is parent */
-                       node2 = node2->parent;
-                       break;
-                   }
-               } while (1);
-           } else {
-               precedence2 = 2; /* element is parent */
-               node2 = node2->parent;
-           }
-           if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||
-               (0 <= (long) node1->content))
-           {
-               node2 = miscNode2;
-               precedence2 = 0;
-           } else
-               misc = 1;
-       }
-           break;
-       case XML_NAMESPACE_DECL:
-           return(1);
-       default:
-           break;
+    if (node2->type == XML_ATTRIBUTE_NODE) {
+       attr2 = 1;
+       attrNode2 = node2;
+       node2 = node2->parent;
     }
-    if (misc) {
-       if (node1 == node2) {
-           if (precedence1 == precedence2) {
-               /*
-               * The ugly case; but normally there aren't many
-               * adjacent non-element nodes around.
-               */
-               cur = miscNode2->prev;
+    if (node1 == node2) {
+       if (attr1 == attr2) {
+           /* not required, but we keep attributes in order */
+           if (attr1 != 0) {
+               cur = attrNode2->prev;
                while (cur != NULL) {
-                   if (cur == miscNode1)
-                       return(1);
-                   if (cur->type == XML_ELEMENT_NODE)
-                       return(-1);
+                   if (cur == attrNode1)
+                       return (1);
                    cur = cur->prev;
                }
                return (-1);
-           } else {
-               /*
-               * Evaluate based on higher precedence wrt to the element.
-               * TODO: This assumes attributes are sorted before content.
-               *   Is this 100% correct?
-               */
-               if (precedence1 < precedence2)
-                   return(1);
-               else
-                   return(-1);
-           }
-       }
-       /*
-       * Special case: One of the helper-elements is contained by the other.
-       * <foo>
-       *   <node2>
-       *     <node1>Text-1(precedence1 == 2)</node1>
-       *   </node2>
-       *   Text-6(precedence2 == 3)
-       * </foo>
-       */
-       if ((precedence2 == 3) && (precedence1 > 1)) {
-           cur = node1->parent;
-           while (cur) {
-               if (cur == node2)
-                   return(1);
-               cur = cur->parent;
-           }
-       }
-       if ((precedence1 == 3) && (precedence2 > 1)) {
-           cur = node2->parent;
-           while (cur) {
-               if (cur == node1)
-                   return(-1);
-               cur = cur->parent;
            }
+           return(0);
        }
+       if (attr2 == 1)
+           return(1);
+       return(-1);
     }
+    if ((node1->type == XML_NAMESPACE_DECL) ||
+        (node2->type == XML_NAMESPACE_DECL))
+       return(1);
+    if (node1 == node2->prev)
+       return(1);
+    if (node1 == node2->next)
+       return(-1);
 
     /*
      * Speedup using document order if availble.
@@ -3318,6 +3328,7 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
        (0 > (long) node1->content) &&
        (0 > (long) node2->content) &&
        (node1->doc == node2->doc)) {
+       long l1, l2;
 
        l1 = -((long) node1->content);
        l2 = -((long) node2->content);
@@ -3327,12 +3338,6 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
            return(-1);
     }
 
-turtle_comparison:
-
-    if (node1 == node2->prev)
-       return(1);
-    if (node1 == node2->next)
-       return(-1);
     /*
      * compute depth to root
      */
@@ -3386,6 +3391,7 @@ turtle_comparison:
        (0 > (long) node1->content) &&
        (0 > (long) node2->content) &&
        (node1->doc == node2->doc)) {
+       long l1, l2;
 
        l1 = -((long) node1->content);
        l2 = -((long) node2->content);
@@ -3400,7 +3406,6 @@ turtle_comparison:
            return(1);
     return(-1); /* assume there is no sibling list corruption */
 }
-#endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */
 
 /**
  * xmlXPathNodeSetSort:
@@ -12420,7 +12425,14 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
                     if (axis == AXIS_ATTRIBUTE) {
                         if (cur->type == XML_ATTRIBUTE_NODE)
                        {
-                           XP_TEST_HIT
+                            if (prefix == NULL)
+                           {
+                               XP_TEST_HIT
+                            } else if ((cur->ns != NULL) &&
+                               (xmlStrEqual(URI, cur->ns->href)))
+                           {
+                               XP_TEST_HIT
+                            }
                         }
                     } else if (axis == AXIS_NAMESPACE) {
                         if (cur->type == XML_NAMESPACE_DECL)
@@ -13512,10 +13524,15 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                 int frame;
 
                 frame = xmlXPathSetFrame(ctxt);
-                if (op->ch1 != -1)
+                if (op->ch1 != -1) {
                     total +=
                         xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
-               if (ctxt->valueNr < op->value) {
+                    if (ctxt->error != XPATH_EXPRESSION_OK) {
+                        xmlXPathPopFrame(ctxt, frame);
+                        return (total);
+                    }
+                }
+               if (ctxt->valueNr < ctxt->valueFrame + op->value) {
                    xmlGenericError(xmlGenericErrorContext,
                            "xmlXPathCompOpEval: parameter error\n");
                    ctxt->error = XPATH_INVALID_OPERAND;
@@ -13577,17 +13594,20 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
            bak = ctxt->context->node;
            pp = ctxt->context->proximityPosition;
            cs = ctxt->context->contextSize;
-            if (op->ch1 != -1)
+            if (op->ch1 != -1) {
                 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
-           ctxt->context->contextSize = cs;
-           ctxt->context->proximityPosition = pp;
-           ctxt->context->node = bak;
-           ctxt->context->doc = bakd;
-           CHECK_ERROR0;
+                ctxt->context->contextSize = cs;
+                ctxt->context->proximityPosition = pp;
+                ctxt->context->node = bak;
+                ctxt->context->doc = bakd;
+               CHECK_ERROR0;
+            }
             if (op->ch2 != -1) {
                 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
-               ctxt->context->doc = bakd;
-               ctxt->context->node = bak;
+                ctxt->context->contextSize = cs;
+                ctxt->context->proximityPosition = pp;
+                ctxt->context->node = bak;
+                ctxt->context->doc = bakd;
                CHECK_ERROR0;
            }
             return (total);
@@ -14719,8 +14739,9 @@ xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
     * internal representation.
     */
 
-    if ((op->ch1 != -1) &&
-        (op->op == XPATH_OP_COLLECT /* 11 */))
+    if ((op->op == XPATH_OP_COLLECT /* 11 */) &&
+        (op->ch1 != -1) &&
+        (op->ch2 == -1 /* no predicate */))
     {
         xmlXPathStepOpPtr prevop = &comp->steps[op->ch1];
 
index 46f11e8..4b4ac2e 100644 (file)
@@ -1375,6 +1375,8 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
        return(NULL);
 
     ctxt = xmlXPathNewParserContext(str, ctx);
+    if (ctxt == NULL)
+       return(NULL);
     ctxt->xptr = 1;
     xmlXPtrEvalXPointer(ctxt);
 
@@ -1807,6 +1809,8 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
         */
        tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
        xmlXPathFreeObject(obj);
+       if (tmp == NULL)
+            XP_ERROR(XPATH_MEMORY_ERROR)
        obj = tmp;
     }
 
@@ -1901,10 +1905,16 @@ xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
         */
        tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
        xmlXPathFreeObject(obj);
+       if (tmp == NULL)
+            XP_ERROR(XPATH_MEMORY_ERROR)
        obj = tmp;
     }
 
     newset = xmlXPtrLocationSetCreate(NULL);
+    if (newset == NULL) {
+       xmlXPathFreeObject(obj);
+        XP_ERROR(XPATH_MEMORY_ERROR);
+    }
     oldset = (xmlLocationSetPtr) obj->user;
     if (oldset != NULL) {
        int i;
@@ -2049,6 +2059,8 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
         */
        tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
        xmlXPathFreeObject(set);
+       if (tmp == NULL)
+            XP_ERROR(XPATH_MEMORY_ERROR)
        set = tmp;
     }
     oldset = (xmlLocationSetPtr) set->user;
@@ -2057,6 +2069,10 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
      * The loop is to compute the covering range for each item and add it
      */
     newset = xmlXPtrLocationSetCreate(NULL);
+    if (newset == NULL) {
+       xmlXPathFreeObject(set);
+        XP_ERROR(XPATH_MEMORY_ERROR);
+    }
     for (i = 0;i < oldset->locNr;i++) {
        xmlXPtrLocationSetAdd(newset,
                xmlXPtrCoveringRange(ctxt, oldset->locTab[i]));
@@ -2195,6 +2211,8 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
         */
        tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
        xmlXPathFreeObject(set);
+       if (tmp == NULL)
+            XP_ERROR(XPATH_MEMORY_ERROR)
        set = tmp;
     }
     oldset = (xmlLocationSetPtr) set->user;
@@ -2203,6 +2221,10 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
      * The loop is to compute the covering range for each item and add it
      */
     newset = xmlXPtrLocationSetCreate(NULL);
+    if (newset == NULL) {
+       xmlXPathFreeObject(set);
+        XP_ERROR(XPATH_MEMORY_ERROR);
+    }
     for (i = 0;i < oldset->locNr;i++) {
        xmlXPtrLocationSetAdd(newset,
                xmlXPtrInsideRange(ctxt, oldset->locTab[i]));
@@ -2461,8 +2483,6 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
         ((*end)->type == XML_NAMESPACE_DECL) || (endindex == NULL))
        return(-1);
     cur = start;
-    if (cur == NULL)
-       return(-1);
     pos = startindex - 1;
     stringlen = xmlStrlen(string);
 
@@ -2798,6 +2818,10 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
 
     set = valuePop(ctxt);
     newset = xmlXPtrLocationSetCreate(NULL);
+    if (newset == NULL) {
+       xmlXPathFreeObject(set);
+        XP_ERROR(XPATH_MEMORY_ERROR);
+    }
     if (set->nodesetval == NULL) {
         goto error;
     }
@@ -2809,6 +2833,8 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
         */
        tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
        xmlXPathFreeObject(set);
+       if (tmp == NULL)
+            XP_ERROR(XPATH_MEMORY_ERROR)
        set = tmp;
     }
     oldset = (xmlLocationSetPtr) set->user;
index 928bd17..0dcb9f4 100644 (file)
@@ -182,12 +182,37 @@ xz_open(const char *path, int fd, const char *mode ATTRIBUTE_UNUSED)
     return (xzFile) state;
 }
 
+static int
+xz_compressed(xzFile f) {
+    xz_statep state;
+
+    if (f == NULL)
+        return(-1);
+    state = (xz_statep) f;
+    if (state->init <= 0)
+        return(-1);
+
+    switch (state->how) {
+        case COPY:
+           return(0);
+       case GZIP:
+       case LZMA:
+           return(1);
+    }
+    return(-1);
+}
+
 xzFile
 __libxml2_xzopen(const char *path, const char *mode)
 {
     return xz_open(path, -1, mode);
 }
 
+int
+__libxml2_xzcompressed(xzFile f) {
+    return xz_compressed(f);
+}
+
 xzFile
 __libxml2_xzdopen(int fd, const char *mode)
 {
@@ -245,6 +270,20 @@ xz_avail(xz_statep state)
     return 0;
 }
 
+#ifdef HAVE_ZLIB_H
+static int
+xz_avail_zstrm(xz_statep state)
+{
+    int ret;
+    state->strm.avail_in = state->zstrm.avail_in;
+    state->strm.next_in = state->zstrm.next_in;
+    ret = xz_avail(state);
+    state->zstrm.avail_in = (uInt) state->strm.avail_in;
+    state->zstrm.next_in = (Bytef *) state->strm.next_in;
+    return ret;
+}
+#endif
+
 static int
 is_format_xz(xz_statep state)
 {
@@ -314,6 +353,10 @@ is_format_lzma(xz_statep state)
 #define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \
                 (strm->avail_in == 0 ? -1 : \
                  (strm->avail_in--, *(strm->next_in)++)))
+/* Same thing, but from zstrm */
+#define NEXTZ() ((strm->avail_in == 0 && xz_avail_zstrm(state) == -1) ? -1 : \
+                (strm->avail_in == 0 ? -1 : \
+                 (strm->avail_in--, *(strm->next_in)++)))
 
 /* Get a four-byte little-endian integer and return 0 on success and the value
    in *ret.  Otherwise -1 is returned and *ret is not modified. */
@@ -324,10 +367,10 @@ gz_next4(xz_statep state, unsigned long *ret)
     unsigned long val;
     z_streamp strm = &(state->zstrm);
 
-    val = NEXT();
-    val += (unsigned) NEXT() << 8;
-    val += (unsigned long) NEXT() << 16;
-    ch = NEXT();
+    val = NEXTZ();
+    val += (unsigned) NEXTZ() << 8;
+    val += (unsigned long) NEXTZ() << 16;
+    ch = NEXTZ();
     if (ch == -1)
         return -1;
     val += (unsigned long) ch << 24;
index 43c75e1..29ba55e 100644 (file)
@@ -15,4 +15,5 @@ xzFile __libxml2_xzopen(const char *path, const char *mode);
 xzFile __libxml2_xzdopen(int fd, const char *mode);
 int __libxml2_xzread(xzFile file, void *buf, unsigned len);
 int __libxml2_xzclose(xzFile file);
+int __libxml2_xzcompressed(xzFile f);
 #endif /* LIBXML2_XZLIB_H */
index 41dcea0..03fd513 100644 (file)
@@ -43,7 +43,7 @@ Used Version: 1.0.6
 Website: http://www.bzip.org
 
 Title: LibXML
-Used Version: 2.9.1
+Used Version: 2.9.2
 Website: http://xmlsoft.org | ftp://xmlsoft.org/libxml2/
 
 Title: ZLib