[LIBXML2]

* Update to v2.9.2.
CORE-8642

svn path=/trunk/; revision=64779
This commit is contained in:
Amine Khaldi 2014-10-17 10:58:01 +00:00
parent e5a60cbf1b
commit 3331eff2ba
58 changed files with 2185 additions and 1002 deletions

View 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,

View 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);

View 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()))

View 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

View 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);

View file

@ -209,7 +209,7 @@ XMLPUBFUN int XMLCALL
xmlParserInputBufferPtr
__xmlParserInputBufferCreateFilename(const char *URI,
xmlCharEncoding enc);
xmlCharEncoding enc);
#ifdef LIBXML_OUTPUT_ENABLED
/*

View 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 */
};

View 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

View 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.

View 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>

View 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);

View 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);
}

View file

@ -4,17 +4,647 @@
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 libxmls 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

View 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");

View 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;

View 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);

View 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);
}

View 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;

View file

@ -261,13 +261,13 @@
#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 */
@ -304,7 +304,7 @@
/* #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
@ -340,3 +340,6 @@
#if defined(_MSC_VER)
#undef GetModuleHandleA
#endif
#define SEND_ARG2_CAST
#define GETHOSTBYNAME_ARG_CAST

View 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;

View 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

View 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);

View 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;

View 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)

View 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

View file

@ -1151,7 +1151,7 @@ void
endElement(void *ctx, const xmlChar * name ATTRIBUTE_UNUSED)
{
DEPRECATED("endElement")
xmlSAX2EndElement(ctx, name);
xmlSAX2EndElement(ctx, name);
}
/**

View 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;

View 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);

View 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);

View 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;

View 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;

View 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 */

View 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--;

View 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;
}
/* }}} */

View 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

View file

@ -99,7 +99,7 @@
#endif
#include <stddef.h>
#ifdef HAVE_ERRNO_H
#if defined( HAVE_ERRNO_H ) || defined( __VMS )
#include <errno.h>
#endif
@ -126,13 +126,23 @@
# 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

View 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 */

View 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)
@ -98,6 +100,10 @@
# 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)

View 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)
@ -78,6 +80,10 @@
# 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))

View 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;

View 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;

View 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;

View 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;

View 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;

View 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");

View 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

View 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;

View 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");

View 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
@ -62,7 +61,12 @@
#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;

View 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) {

File diff suppressed because it is too large Load diff

View 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

View 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
@ -42,7 +41,12 @@
#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;

View file

@ -135,6 +135,298 @@
* 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
*/
@ -154,7 +446,6 @@
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;
@ -3110,298 +3407,6 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
return(-1); /* assume there is no sibling list corruption */
}
#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) node1->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 */
/**
* xmlXPathNodeSetSort:
* @set: the node set
@ -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];

View 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;

View 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;

View 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 */

View 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