[LIBXML2] Update to version 2.10.0. CORE-17766

This commit is contained in:
Thomas Faber 2022-11-20 10:17:45 -05:00
parent 608bbe1136
commit 911153da10
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
80 changed files with 2351 additions and 20735 deletions

View file

@ -239,7 +239,7 @@ URL: https://github.com/win-iconv/win-iconv
Title: LibXML
Path: sdk/lib/3rdparty/libxml2
Used Version: 2.9.14
Used Version: 2.10.0
License: MIT (https://spdx.org/licenses/MIT.htmlf)
URL: http://xmlsoft.org, ftp://xmlsoft.org/libxml2/

View file

@ -16,54 +16,67 @@
#include <stdlib.h>
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/xlink.h>
#ifdef LIBXML_LEGACY_ENABLED
#ifdef __cplusplus
extern "C" {
#endif
XML_DEPRECATED
XMLPUBFUN const xmlChar * XMLCALL
getPublicId (void *ctx);
XML_DEPRECATED
XMLPUBFUN const xmlChar * XMLCALL
getSystemId (void *ctx);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
setDocumentLocator (void *ctx,
xmlSAXLocatorPtr loc);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
getLineNumber (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
getColumnNumber (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
isStandalone (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
hasInternalSubset (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
hasExternalSubset (void *ctx);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
internalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
externalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
XML_DEPRECATED
XMLPUBFUN xmlEntityPtr XMLCALL
getEntity (void *ctx,
const xmlChar *name);
XML_DEPRECATED
XMLPUBFUN xmlEntityPtr XMLCALL
getParameterEntity (void *ctx,
const xmlChar *name);
XML_DEPRECATED
XMLPUBFUN xmlParserInputPtr XMLCALL
resolveEntity (void *ctx,
const xmlChar *publicId,
const xmlChar *systemId);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
entityDecl (void *ctx,
const xmlChar *name,
@ -71,6 +84,7 @@ XMLPUBFUN void XMLCALL
const xmlChar *publicId,
const xmlChar *systemId,
xmlChar *content);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
attributeDecl (void *ctx,
const xmlChar *elem,
@ -79,16 +93,19 @@ XMLPUBFUN void XMLCALL
int def,
const xmlChar *defaultValue,
xmlEnumerationPtr tree);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
elementDecl (void *ctx,
const xmlChar *name,
int type,
xmlElementContentPtr content);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
notationDecl (void *ctx,
const xmlChar *name,
const xmlChar *publicId,
const xmlChar *systemId);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
unparsedEntityDecl (void *ctx,
const xmlChar *name,
@ -96,72 +113,86 @@ XMLPUBFUN void XMLCALL
const xmlChar *systemId,
const xmlChar *notationName);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
startDocument (void *ctx);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
endDocument (void *ctx);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
attribute (void *ctx,
const xmlChar *fullname,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
startElement (void *ctx,
const xmlChar *fullname,
const xmlChar **atts);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
endElement (void *ctx,
const xmlChar *name);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
reference (void *ctx,
const xmlChar *name);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
characters (void *ctx,
const xmlChar *ch,
int len);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
ignorableWhitespace (void *ctx,
const xmlChar *ch,
int len);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
processingInstruction (void *ctx,
const xmlChar *target,
const xmlChar *data);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
globalNamespace (void *ctx,
const xmlChar *href,
const xmlChar *prefix);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
setNamespace (void *ctx,
const xmlChar *name);
XML_DEPRECATED
XMLPUBFUN xmlNsPtr XMLCALL
getNamespace (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
checkNamespace (void *ctx,
xmlChar *nameSpace);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
namespaceDecl (void *ctx,
const xmlChar *href,
const xmlChar *prefix);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
comment (void *ctx,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
cdataBlock (void *ctx,
const xmlChar *value,
int len);
#ifdef LIBXML_SAX1_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
int warning);
#ifdef LIBXML_HTML_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif
#ifdef LIBXML_DOCB_ENABLED
XMLPUBFUN void XMLCALL
initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif
#endif /* LIBXML_SAX1_ENABLED */
#ifdef __cplusplus

View file

@ -16,7 +16,6 @@
#include <stdlib.h>
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/xlink.h>
#ifdef __cplusplus
extern "C" {
@ -99,8 +98,7 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN void XMLCALL
xmlSAX2EndDocument (void *ctx);
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \
defined(LIBXML_LEGACY_ENABLED)
defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
XMLPUBFUN void XMLCALL
xmlSAX2StartElement (void *ctx,
const xmlChar *fullname,
@ -161,15 +159,11 @@ XMLPUBFUN void XMLCALL
#ifdef LIBXML_HTML_ENABLED
XMLPUBFUN void XMLCALL
xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
htmlDefaultSAXHandlerInit (void);
#endif
#ifdef LIBXML_DOCB_ENABLED
XMLPUBFUN void XMLCALL
xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
XMLPUBFUN void XMLCALL
docbDefaultSAXHandlerInit (void);
#endif
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlDefaultSAXHandlerInit (void);
#ifdef __cplusplus

View file

@ -27,6 +27,7 @@ typedef xmlDict *xmlDictPtr;
/*
* Initializer
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL xmlInitializeDict(void);
/*
@ -70,6 +71,7 @@ XMLPUBFUN int XMLCALL
/*
* Cleanup function
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlDictCleanup (void);

View file

@ -27,9 +27,7 @@
#ifdef LIBXML_ICONV_ENABLED
#include <iconv.h>
#endif
#ifdef LIBXML_ICU_ENABLED
#include <unicode/ucnv.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -128,19 +126,6 @@ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
* Block defining the handlers for non UTF-8 encodings.
* If iconv is supported, there are two extra fields.
*/
#ifdef LIBXML_ICU_ENABLED
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
#define ICU_PIVOT_BUF_SIZE 1024
struct _uconv_t {
UConverter *uconv; /* for conversion between an encoding and UTF-16 */
UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
UChar *pivot_source;
UChar *pivot_target;
};
typedef struct _uconv_t uconv_t;
#endif
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
struct _xmlCharEncodingHandler {
@ -152,8 +137,8 @@ struct _xmlCharEncodingHandler {
iconv_t iconv_out;
#endif /* LIBXML_ICONV_ENABLED */
#ifdef LIBXML_ICU_ENABLED
uconv_t *uconv_in;
uconv_t *uconv_out;
struct _uconv_t *uconv_in;
struct _uconv_t *uconv_out;
#endif /* LIBXML_ICU_ENABLED */
};
@ -168,8 +153,10 @@ extern "C" {
/*
* Interfaces for encoding handlers.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlInitCharEncodingHandlers (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupCharEncodingHandlers (void);
XMLPUBFUN void XMLCALL

View file

@ -75,6 +75,7 @@ typedef xmlEntitiesTable *xmlEntitiesTablePtr;
*/
#ifdef LIBXML_LEGACY_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlInitializePredefinedEntities (void);
#endif /* LIBXML_LEGACY_ENABLED */
@ -112,6 +113,7 @@ XMLPUBFUN xmlEntityPtr XMLCALL
xmlGetParameterEntity (xmlDocPtr doc,
const xmlChar *name);
#ifdef LIBXML_LEGACY_ENABLED
XML_DEPRECATED
XMLPUBFUN const xmlChar * XMLCALL
xmlEncodeEntities (xmlDocPtr doc,
const xmlChar *input);

View file

@ -24,7 +24,9 @@
extern "C" {
#endif
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlInitGlobals(void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
/**
@ -67,7 +69,6 @@ XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc
* compatibility support.
*/
#undef docbDefaultSAXHandler
#undef htmlDefaultSAXHandler
#undef oldXMLWDcompatibility
#undef xmlBufferAllocScheme
@ -124,7 +125,7 @@ struct _xmlGlobalState
xmlSAXLocator xmlDefaultSAXLocator;
xmlSAXHandlerV1 xmlDefaultSAXHandler;
xmlSAXHandlerV1 docbDefaultSAXHandler;
xmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */
xmlSAXHandlerV1 htmlDefaultSAXHandler;
xmlFreeFunc xmlFree;
@ -251,16 +252,6 @@ XMLPUBVAR xmlFreeFunc xmlFree;
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
#endif /* LIBXML_THREAD_ALLOC_ENABLED */
#ifdef LIBXML_DOCB_ENABLED
XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
#ifdef LIBXML_THREAD_ENABLED
#define docbDefaultSAXHandler \
(*(__docbDefaultSAXHandler()))
#else
XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
#endif
#endif
#ifdef LIBXML_HTML_ENABLED
XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
#ifdef LIBXML_THREAD_ENABLED

View file

@ -1,7 +1,8 @@
/*
* Summary: minimal FTP implementation
* Description: minimal FTP implementation allowing to fetch resources
* like external subset.
* like external subset. This module is DEPRECATED, do not
* use any of its functions.
*
* Copy: See Copyright for the status of this software.
*
@ -16,7 +17,7 @@
#ifdef LIBXML_FTP_ENABLED
/* Needed for portability to Windows 64 bits */
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
#include <winsock2.h>
#else
/**
@ -78,40 +79,52 @@ typedef void (*ftpDataCallback) (void *userData,
/*
* Init
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlNanoFTPInit (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlNanoFTPCleanup (void);
/*
* Creating/freeing contexts.
*/
XML_DEPRECATED
XMLPUBFUN void * XMLCALL
xmlNanoFTPNewCtxt (const char *URL);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlNanoFTPFreeCtxt (void * ctx);
XML_DEPRECATED
XMLPUBFUN void * XMLCALL
xmlNanoFTPConnectTo (const char *server,
int port);
/*
* Opening/closing session connections.
*/
XML_DEPRECATED
XMLPUBFUN void * XMLCALL
xmlNanoFTPOpen (const char *URL);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPConnect (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPClose (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPQuit (void *ctx);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlNanoFTPScanProxy (const char *URL);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlNanoFTPProxy (const char *host,
int port,
const char *user,
const char *passwd,
int type);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPUpdateURL (void *ctx,
const char *URL);
@ -119,38 +132,48 @@ XMLPUBFUN int XMLCALL
/*
* Rather internal commands.
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPGetResponse (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPCheckResponse (void *ctx);
/*
* CD/DIR/GET handlers.
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPCwd (void *ctx,
const char *directory);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPDele (void *ctx,
const char *file);
XML_DEPRECATED
XMLPUBFUN SOCKET XMLCALL
xmlNanoFTPGetConnection (void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPCloseConnection(void *ctx);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPList (void *ctx,
ftpListCallback callback,
void *userData,
const char *filename);
XML_DEPRECATED
XMLPUBFUN SOCKET XMLCALL
xmlNanoFTPGetSocket (void *ctx,
const char *filename);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPGet (void *ctx,
ftpDataCallback callback,
void *userData,
const char *filename);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlNanoFTPRead (void *ctx,
void *dest,

View file

@ -10,8 +10,6 @@
#ifndef __XML_PARSER_H__
#define __XML_PARSER_H__
#include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
#include <libxml/dict.h>
@ -192,7 +190,7 @@ struct _xmlParserCtxt {
const xmlChar *version; /* the XML version string */
const xmlChar *encoding; /* the declared encoding, if any */
int standalone; /* standalone document */
int html; /* an HTML(1)/Docbook(2) document
int html; /* an HTML(1) document
* 3 is HTML after <head>
* 10 is HTML after <body>
*/
@ -996,13 +994,16 @@ XMLPUBFUN xmlParserCtxtPtr XMLCALL
/*
* Reading/setting optional parsing features.
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlGetFeaturesList (int *len,
const char **result);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlGetFeature (xmlParserCtxtPtr ctxt,
const char *name,
void *result);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlSetFeature (xmlParserCtxtPtr ctxt,
const char *name,

View file

@ -339,6 +339,7 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
xmlCharEncodingHandlerPtr handler);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
xmlParserInputPtr input,
@ -574,6 +575,7 @@ XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in);
/*
* Actually comes from the HTML parser but launched from the init stuff.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL htmlInitAutoClose (void);
XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename,
const char *encoding);
@ -597,25 +599,34 @@ typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
xmlNodePtr firstNode,
xmlNodePtr lastNode);
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlParseQuotedString (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlParseNamespace (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlScanName (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt);
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
xmlChar **prefix);
/**
* Entities
*/
XML_DEPRECATED
XMLPUBFUN xmlChar * XMLCALL
xmlDecodeEntities (xmlParserCtxtPtr ctxt,
int len,
@ -623,6 +634,7 @@ XMLPUBFUN xmlChar * XMLCALL
xmlChar end,
xmlChar end2,
xmlChar end3);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlHandleEntity (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity);

View file

@ -118,6 +118,7 @@ typedef enum {
XMLPUBFUN int XMLCALL
xmlRelaxNGInitTypes (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlRelaxNGCleanupTypes (void);

View file

@ -1,5 +1,5 @@
/*
* Summary: XML Schemastron implementation
* Summary: XML Schematron implementation
* Description: interface to the XML Schematron validity checking.
*
* Copy: See Copyright for the status of this software.

View file

@ -57,6 +57,7 @@ XMLPUBFUN void XMLCALL
/*
* Library wide APIs.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlInitThreads (void);
XMLPUBFUN void XMLCALL
@ -67,6 +68,7 @@ XMLPUBFUN int XMLCALL
xmlGetThreadId (void);
XMLPUBFUN int XMLCALL
xmlIsMainThread (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupThreads(void);
XMLPUBFUN xmlGlobalStatePtr XMLCALL

View file

@ -177,11 +177,11 @@ typedef enum {
XML_NAMESPACE_DECL= 18,
XML_XINCLUDE_START= 19,
XML_XINCLUDE_END= 20
#ifdef LIBXML_DOCB_ENABLED
,XML_DOCB_DOCUMENT_NODE= 21
#endif
/* XML_DOCB_DOCUMENT_NODE= 21 */ /* removed */
} xmlElementType;
/* For backward compatibility */
#define XML_DOCB_DOCUMENT_NODE 21
/**
* xmlNotation:
@ -659,7 +659,7 @@ struct _xmlDOMWrapCtxt {
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)
defined(LIBXML_LEGACY_ENABLED)
XMLPUBFUN int XMLCALL
xmlValidateNCName (const xmlChar *value,
int space);
@ -763,6 +763,7 @@ XMLPUBFUN xmlDtdPtr XMLCALL
XMLPUBFUN void XMLCALL
xmlFreeDtd (xmlDtdPtr cur);
#ifdef LIBXML_LEGACY_ENABLED
XML_DEPRECATED
XMLPUBFUN xmlNsPtr XMLCALL
xmlNewGlobalNs (xmlDocPtr doc,
const xmlChar *href,

View file

@ -60,17 +60,17 @@ typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
#ifdef IN_LIBXML
/**
* XML_CTXT_FINISH_DTD_0:
* XML_VCTXT_DTD_VALIDATED:
*
* Special value for finishDtd field when embedded in an xmlParserCtxt
* Set after xmlValidateDtdFinal was called.
*/
#define XML_CTXT_FINISH_DTD_0 0xabcd1234
#define XML_VCTXT_DTD_VALIDATED (1u << 0)
/**
* XML_CTXT_FINISH_DTD_1:
* XML_VCTXT_USE_PCTXT:
*
* Special value for finishDtd field when embedded in an xmlParserCtxt
* Set if the validation context is part of a parser context.
*/
#define XML_CTXT_FINISH_DTD_1 0xabcd1235
#define XML_VCTXT_USE_PCTXT (1u << 1)
#endif
/*
@ -90,7 +90,7 @@ struct _xmlValidCtxt {
int nodeMax; /* Max depth of the parsing stack */
xmlNodePtr *nodeTab; /* array of nodes */
unsigned int finishDtd; /* finished validating the Dtd ? */
unsigned int flags; /* internal flags */
xmlDocPtr doc; /* the document */
int valid; /* temporary validity check result */
@ -283,20 +283,25 @@ XMLPUBFUN int XMLCALL
xmlAttrPtr attr);
/* IDREFs */
XML_DEPRECATED
XMLPUBFUN xmlRefPtr XMLCALL
xmlAddRef (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlFreeRefTable (xmlRefTablePtr table);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlRemoveRef (xmlDocPtr doc,
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN xmlListPtr XMLCALL
xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID);

View file

@ -209,6 +209,7 @@ typedef enum {
XML_ERR_VERSION_MISMATCH, /* 109 */
XML_ERR_NAME_TOO_LONG, /* 110 */
XML_ERR_USER_STOP, /* 111 */
XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */
XML_NS_ERR_XML_NAMESPACE = 200,
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
XML_NS_ERR_QNAME, /* 202 */
@ -259,6 +260,7 @@ typedef enum {
XML_DTD_DUP_TOKEN, /* 541 */
XML_HTML_STRUCURE_ERROR = 800,
XML_HTML_UNKNOWN_TAG, /* 801 */
XML_HTML_INCORRECTLY_OPENED_COMMENT, /* 802 */
XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000,
XML_RNGP_ATTR_CONFLICT, /* 1001 */
XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */

View file

@ -126,12 +126,14 @@ XMLPUBFUN int XMLCALL
/*
* Initialization of the memory layer.
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlInitMemory (void);
/*
* Cleanup of the memory layer.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupMemory (void);
/*

View file

@ -32,6 +32,7 @@ typedef enum {
XMLPUBFUN void XMLCALL
xmlSchemaInitTypes (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlSchemaCleanupTypes (void);
XMLPUBFUN xmlSchemaTypePtr XMLCALL

View file

@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* the version string like "1.2.3"
*/
#define LIBXML_DOTTED_VERSION "2.9.14"
#define LIBXML_DOTTED_VERSION "2.10.0"
/**
* LIBXML_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
#define LIBXML_VERSION 20914
#define LIBXML_VERSION 21000
/**
* LIBXML_VERSION_STRING:
*
* the version number string, 1.2.3 value is "10203"
*/
#define LIBXML_VERSION_STRING "20914"
#define LIBXML_VERSION_STRING "21000"
/**
* LIBXML_VERSION_EXTRA:
*
* extra version information, used to show a git commit description
*/
#define LIBXML_VERSION_EXTRA "-GITv2.9.13-22-g7846b0a67"
#define LIBXML_VERSION_EXTRA "-GITv2.9.13-209-gae383bdb7"
/**
* LIBXML_TEST_VERSION:
@ -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(20914);
#define LIBXML_TEST_VERSION xmlCheckVersion(21000);
#ifndef VMS
#if 0
@ -171,7 +171,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* Whether the FTP support is configured in
*/
#if 1
#if 0
#define LIBXML_FTP_ENABLED
#endif
@ -207,7 +207,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* Whether the deprecated APIs are compiled in for compatibility
*/
#if 1
#if 0
#define LIBXML_LEGACY_ENABLED
#endif
@ -229,15 +229,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_CATALOG_ENABLED
#endif
/**
* LIBXML_DOCB_ENABLED:
*
* Whether the SGML Docbook support is configured in
*/
#if 1
#define LIBXML_DOCB_ENABLED
#endif
/**
* LIBXML_XPATH_ENABLED:
*
@ -256,6 +247,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_XPTR_ENABLED
#endif
/**
* LIBXML_XPTR_LOCS_ENABLED:
*
* Whether support for XPointer locations is configured in
*/
#if 0
#define LIBXML_XPTR_LOCS_ENABLED
#endif
/**
* LIBXML_XINCLUDE_ENABLED:
*
@ -456,6 +456,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
# define LIBXML_ATTR_FORMAT(fmt,args)
#endif
#ifndef XML_DEPRECATED
# ifdef IN_LIBXML
# define XML_DEPRECATED
# else
/* Available since at least GCC 3.1 */
# define XML_DEPRECATED __attribute__((deprecated))
# endif
#endif
#else /* ! __GNUC__ */
/**
* ATTRIBUTE_UNUSED:
@ -475,6 +484,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro used to indicate to GCC the parameter are printf like
*/
#define LIBXML_ATTR_FORMAT(fmt,args)
/**
* XML_DEPRECATED:
*
* Macro used to indicate that a function, variable, type or struct member
* is deprecated.
*/
#ifndef XML_DEPRECATED
#define XML_DEPRECATED
#endif
#endif /* __GNUC__ */
#ifdef __cplusplus

View file

@ -229,15 +229,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_CATALOG_ENABLED
#endif
/**
* LIBXML_DOCB_ENABLED:
*
* Whether the SGML Docbook support is configured in
*/
#if @WITH_DOCB@
#define LIBXML_DOCB_ENABLED
#endif
/**
* LIBXML_XPATH_ENABLED:
*
@ -256,6 +247,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_XPTR_ENABLED
#endif
/**
* LIBXML_XPTR_LOCS_ENABLED:
*
* Whether support for XPointer locations is configured in
*/
#if @WITH_XPTR_LOCS@
#define LIBXML_XPTR_LOCS_ENABLED
#endif
/**
* LIBXML_XINCLUDE_ENABLED:
*
@ -456,6 +456,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
# define LIBXML_ATTR_FORMAT(fmt,args)
#endif
#ifndef XML_DEPRECATED
# ifdef IN_LIBXML
# define XML_DEPRECATED
# else
/* Available since at least GCC 3.1 */
# define XML_DEPRECATED __attribute__((deprecated))
# endif
#endif
#else /* ! __GNUC__ */
/**
* ATTRIBUTE_UNUSED:
@ -475,6 +484,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro used to indicate to GCC the parameter are printf like
*/
#define LIBXML_ATTR_FORMAT(fmt,args)
/**
* XML_DEPRECATED:
*
* Macro used to indicate that a function, variable, type or struct member
* is deprecated.
*/
#ifndef XML_DEPRECATED
#define XML_DEPRECATED
#endif
#endif /* __GNUC__ */
#ifdef __cplusplus

View file

@ -104,13 +104,23 @@ typedef enum {
XPATH_BOOLEAN = 2,
XPATH_NUMBER = 3,
XPATH_STRING = 4,
#ifdef LIBXML_XPTR_LOCS_ENABLED
XPATH_POINT = 5,
XPATH_RANGE = 6,
XPATH_LOCATIONSET = 7,
#endif
XPATH_USERS = 8,
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
} xmlXPathObjectType;
#ifndef LIBXML_XPTR_LOCS_ENABLED
/** DOC_DISABLE */
#define XPATH_POINT 5
#define XPATH_RANGE 6
#define XPATH_LOCATIONSET 7
/** DOC_ENABLE */
#endif
typedef struct _xmlXPathObject xmlXPathObject;
typedef xmlXPathObject *xmlXPathObjectPtr;
struct _xmlXPathObject {
@ -549,6 +559,7 @@ XMLPUBFUN void XMLCALL
xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp);
#endif /* LIBXML_XPATH_ENABLED */
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPathInit (void);
XMLPUBFUN int XMLCALL

View file

@ -28,6 +28,7 @@
extern "C" {
#endif
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* A Location Set
*/
@ -43,51 +44,68 @@ struct _xmlLocationSet {
* Handling of location sets.
*/
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetCreate (xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodePoint (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePointNode (xmlXPathObjectPtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodeObject (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewCollapsedRange (xmlNodePtr start);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
int val);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/*
* Functions.
@ -99,13 +117,18 @@ XMLPUBFUN xmlXPathContextPtr XMLCALL
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrEval (const xmlChar *str,
xmlXPathContextPtr ctx);
#ifdef LIBXML_XPTR_LOCS_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
int nargs);
XML_DEPRECATED
XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#ifdef __cplusplus
}
#endif

View file

@ -23,7 +23,6 @@ list(APPEND SOURCE
chvalid.c
debugXML.c
dict.c
DOCBparser.c
encoding.c
entities.c
error.c

View file

@ -1,23 +0,0 @@
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-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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is fur-
nished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
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
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

@ -1,305 +0,0 @@
/*
* DOCBparser.c : an attempt to parse SGML Docbook documents
*
* This is deprecated !!!
* Code removed with release 2.6.0 it was broken.
* The doc are expect to be migrated to XML DocBook
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#define IN_LIBXML
#include "libxml.h"
#ifdef LIBXML_DOCB_ENABLED
#include <libxml/xmlerror.h>
#include <libxml/DOCBparser.h>
/**
* docbEncodeEntities:
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of UTF-8 chars
* @inlen: the length of @in
* @quoteChar: the quote character to escape (' or ") or zero.
*
* Take a block of UTF-8 chars in and try to convert it to an ASCII
* plus SGML entities block of chars out.
*
* Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
* The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed.
*/
int
docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
int *outlen ATTRIBUTE_UNUSED,
const unsigned char *in ATTRIBUTE_UNUSED,
int *inlen ATTRIBUTE_UNUSED,
int quoteChar ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbEncodeEntities() deprecated function reached\n");
deprecated = 1;
}
return(-1);
}
/**
* docbParseDocument:
* @ctxt: an SGML parser context
*
* parse an SGML document (and build a tree if using the standard SAX
* interface).
*
* Returns 0, -1 in case of error. the parser context is augmented
* as a result of the parsing.
*/
int
docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseDocument() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseDocument(ctxt));
}
/**
* docbFreeParserCtxt:
* @ctxt: an SGML parser context
*
* Free all the memory used by a parser context. However the parsed
* document in ctxt->myDoc is not freed.
*/
void
docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbFreeParserCtxt() deprecated function reached\n");
deprecated = 1;
}
xmlFreeParserCtxt(ctxt);
}
/**
* docbParseChunk:
* @ctxt: an XML parser context
* @chunk: an char array
* @size: the size in byte of the chunk
* @terminate: last chunk indicator
*
* Parse a Chunk of memory
*
* Returns zero if no error, the xmlParserErrors otherwise.
*/
int
docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
const char *chunk ATTRIBUTE_UNUSED,
int size ATTRIBUTE_UNUSED,
int terminate ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseChunk(ctxt, chunk, size, terminate));
}
/**
* docbCreatePushParserCtxt:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @chunk: a pointer to an array of chars
* @size: number of chars in the array
* @filename: an optional file name or URI
* @enc: an optional encoding
*
* Create a parser context for using the DocBook SGML parser in push mode
* To allow content encoding detection, @size should be >= 4
* The value of @filename is used for fetching external entities
* and error/warning reports.
*
* Returns the new parser context or NULL
*/
docbParserCtxtPtr
docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *user_data ATTRIBUTE_UNUSED,
const char *chunk ATTRIBUTE_UNUSED,
int size ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
xmlCharEncoding enc ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));
}
/**
* docbSAXParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
docbDocPtr
docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED,
docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *userData ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlSAXParseMemoryWithData(sax, (const char *)cur,
xmlStrlen((const xmlChar *) cur), 0, userData));
}
/**
* docbParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the SGML document encoding, or NULL
*
* parse an SGML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
docbDocPtr
docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseDoc(cur));
}
/**
* docbCreateFileParserCtxt:
* @filename: the filename
* @encoding: the SGML document encoding, or NULL
*
* Create a parser context for a file content.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
*
* Returns the new parser context or NULL
*/
docbParserCtxtPtr
docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbCreateFileParserCtxt() deprecated function reached\n");
deprecated = 1;
}
return (xmlCreateFileParserCtxt(filename));
}
/**
* docbSAXParseFile:
* @filename: the filename
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
docbDocPtr
docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED,
docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *userData ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbSAXParseFile() deprecated function reached\n");
deprecated = 1;
}
return (xmlSAXParseFileWithData(sax, filename, 0, userData));
}
/**
* docbParseFile:
* @filename: the filename
* @encoding: a free form C string describing document encoding, or NULL
*
* parse a Docbook SGML file and build a tree. Automatic support for
* ZLIB/Compress compressed document is provided by default if found
* at compile-time.
*
* Returns the resulting document tree
*/
docbDocPtr
docbParseFile(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseFile() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseFile(filename));
}
#define bottom_DOCBparser
#include "elfgcchack.h"
#endif /* LIBXML_DOCB_ENABLED */

View file

@ -11,24 +11,8 @@
#ifdef LIBXML_HTML_ENABLED
#include <string.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
@ -1411,6 +1395,9 @@ static const elementPriority htmlEndPriority[] = {
/**
* htmlInitAutoClose:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* This is a no-op now.
*/
void
@ -2558,6 +2545,21 @@ htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) {
static const xmlChar * htmlParseNameComplex(xmlParserCtxtPtr ctxt);
static void
htmlSkipBogusComment(htmlParserCtxtPtr ctxt) {
int c;
htmlParseErr(ctxt, XML_HTML_INCORRECTLY_OPENED_COMMENT,
"Incorrectly opened comment\n", NULL, NULL);
do {
c = CUR;
if (c == 0)
break;
NEXT;
} while (c != '>');
}
/**
* htmlParseHTMLName:
* @ctxt: an HTML parser context
@ -3488,10 +3490,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
q = CUR_CHAR(ql);
if (q == 0)
goto unfinished;
if (q == '>') {
htmlParseErr(ctxt, XML_ERR_COMMENT_ABRUPTLY_ENDED, "Comment abruptly ended", NULL, NULL);
cur = '>';
goto finished;
}
NEXTL(ql);
r = CUR_CHAR(rl);
if (r == 0)
goto unfinished;
if (q == '-' && r == '>') {
htmlParseErr(ctxt, XML_ERR_COMMENT_ABRUPTLY_ENDED, "Comment abruptly ended", NULL, NULL);
cur = '>';
goto finished;
}
NEXTL(rl);
cur = CUR_CHAR(l);
while ((cur != 0) &&
@ -3539,6 +3551,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
cur = next;
l = nl;
}
finished:
buf[len] = 0;
if (cur == '>') {
NEXT;
@ -4380,72 +4393,74 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
* Handle SCRIPT/STYLE separately
*/
htmlParseScript(ctxt);
} else {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((CUR == '<') && (NXT(1) == '!') &&
(UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
}
/*
* First case : a comment
*/
if ((CUR == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) {
htmlParseComment(ctxt);
}
/*
* Second case : a Processing Instruction.
*/
else if ((CUR == '<') && (NXT(1) == '?')) {
htmlParsePI(ctxt);
}
/*
* Third case : a sub-element.
*/
else if ((CUR == '<') && IS_ASCII_LETTER(NXT(1))) {
htmlParseElement(ctxt);
}
else if (CUR == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, BAD_CAST "<", 1);
NEXT;
}
/*
* Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (CUR == '&') {
htmlParseReference(ctxt);
}
/*
* Fifth case : end of the resource
*/
else if (CUR == 0) {
htmlAutoCloseOnEnd(ctxt);
break;
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
htmlParseCharData(ctxt);
}
}
else if ((CUR == '<') && (NXT(1) == '!')) {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
}
/*
* First case : a comment
*/
else if ((NXT(2) == '-') && (NXT(3) == '-')) {
htmlParseComment(ctxt);
}
else {
htmlSkipBogusComment(ctxt);
}
}
/*
* Second case : a Processing Instruction.
*/
else if ((CUR == '<') && (NXT(1) == '?')) {
htmlParsePI(ctxt);
}
/*
* Third case : a sub-element.
*/
else if ((CUR == '<') && IS_ASCII_LETTER(NXT(1))) {
htmlParseElement(ctxt);
}
else if (CUR == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, BAD_CAST "<", 1);
NEXT;
}
/*
* Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (CUR == '&') {
htmlParseReference(ctxt);
}
/*
* Fifth case : end of the resource
*/
else if (CUR == 0) {
htmlAutoCloseOnEnd(ctxt);
break;
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
htmlParseCharData(ctxt);
}
GROW;
}
if (currentNode != NULL) xmlFree(currentNode);
@ -4785,76 +4800,78 @@ htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
* Handle SCRIPT/STYLE separately
*/
htmlParseScript(ctxt);
} else {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((CUR == '<') && (NXT(1) == '!') &&
(UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
}
/*
* First case : a comment
*/
if ((CUR == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) {
htmlParseComment(ctxt);
}
/*
* Second case : a Processing Instruction.
*/
else if ((CUR == '<') && (NXT(1) == '?')) {
htmlParsePI(ctxt);
}
/*
* Third case : a sub-element.
*/
else if ((CUR == '<') && IS_ASCII_LETTER(NXT(1))) {
htmlParseElementInternal(ctxt);
if (currentNode != NULL) xmlFree(currentNode);
currentNode = xmlStrdup(ctxt->name);
depth = ctxt->nameNr;
}
else if (CUR == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, BAD_CAST "<", 1);
NEXT;
}
/*
* Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (CUR == '&') {
htmlParseReference(ctxt);
}
/*
* Fifth case : end of the resource
*/
else if (CUR == 0) {
htmlAutoCloseOnEnd(ctxt);
break;
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
htmlParseCharData(ctxt);
}
}
else if ((CUR == '<') && (NXT(1) == '!')) {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
}
/*
* First case : a comment
*/
else if ((NXT(2) == '-') && (NXT(3) == '-')) {
htmlParseComment(ctxt);
}
else {
htmlSkipBogusComment(ctxt);
}
}
/*
* Second case : a Processing Instruction.
*/
else if ((CUR == '<') && (NXT(1) == '?')) {
htmlParsePI(ctxt);
}
/*
* Third case : a sub-element.
*/
else if ((CUR == '<') && IS_ASCII_LETTER(NXT(1))) {
htmlParseElementInternal(ctxt);
if (currentNode != NULL) xmlFree(currentNode);
currentNode = xmlStrdup(ctxt->name);
depth = ctxt->nameNr;
}
else if (CUR == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, BAD_CAST "<", 1);
NEXT;
}
/*
* Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (CUR == '&') {
htmlParseReference(ctxt);
}
/*
* Fifth case : end of the resource
*/
else if (CUR == 0) {
htmlAutoCloseOnEnd(ctxt);
break;
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
htmlParseCharData(ctxt);
}
GROW;
}
if (currentNode != NULL) xmlFree(currentNode);
@ -5111,7 +5128,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->linenumbers = xmlLineNumbersDefaultValue;
ctxt->keepBlanks = xmlKeepBlanksDefaultValue;
ctxt->html = 1;
ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
ctxt->vctxt.flags = XML_VCTXT_USE_PCTXT;
ctxt->vctxt.userData = ctxt;
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.warning = xmlParserValidityWarning;
@ -5951,93 +5968,97 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
#endif
break;
}
} else {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((cur == '<') && (next == '!') &&
(UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0, 1) < 0))
goto done;
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
} else if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) && (htmlParseLookupCommentEnd(ctxt) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing Comment\n");
#endif
htmlParseComment(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing PI\n");
#endif
htmlParsePI(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
} else if ((cur == '<') && (next == '!') && (avail < 4)) {
goto done;
} else if ((cur == '<') && (next == '/')) {
ctxt->instate = XML_PARSER_END_TAG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: entering END_TAG\n");
#endif
break;
} else if ((cur == '<') && IS_ASCII_LETTER(next)) {
if ((!terminate) && (next == 0))
} else if ((cur == '<') && (next == '!')) {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0, 1) < 0))
goto done;
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
BAD_CAST "DOCTYPE" , NULL);
htmlParseDocTypeDecl(ctxt);
} else if ((in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) &&
(htmlParseLookupCommentEnd(ctxt) < 0))
goto done;
ctxt->instate = XML_PARSER_START_TAG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: entering START_TAG\n");
"HPP: Parsing Comment\n");
#endif
break;
} else if (cur == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData,
BAD_CAST "<", 1);
NEXT;
} else {
/*
* check that the text sequence is complete
* before handing out the data to the parser
* to avoid problems with erroneous end of
* data detection.
*/
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0))
goto done;
ctxt->checkIndex = 0;
htmlParseComment(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
} else {
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
goto done;
htmlSkipBogusComment(ctxt);
}
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing char data\n");
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing PI\n");
#endif
while ((ctxt->instate != XML_PARSER_EOF) &&
(cur != '<') && (in->cur < in->end)) {
if (cur == '&') {
htmlParseReference(ctxt);
} else {
htmlParseCharData(ctxt);
}
cur = in->cur[0];
htmlParsePI(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
} else if ((cur == '<') && (next == '!') && (avail < 4)) {
goto done;
} else if ((cur == '<') && (next == '/')) {
ctxt->instate = XML_PARSER_END_TAG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: entering END_TAG\n");
#endif
break;
} else if ((cur == '<') && IS_ASCII_LETTER(next)) {
if ((!terminate) && (next == 0))
goto done;
ctxt->instate = XML_PARSER_START_TAG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: entering START_TAG\n");
#endif
break;
} else if (cur == '<') {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData,
BAD_CAST "<", 1);
NEXT;
} else {
/*
* check that the text sequence is complete
* before handing out the data to the parser
* to avoid problems with erroneous end of
* data detection.
*/
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0))
goto done;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing char data\n");
#endif
while ((ctxt->instate != XML_PARSER_EOF) &&
(cur != '<') && (in->cur < in->end)) {
if (cur == '&') {
htmlParseReference(ctxt);
} else {
htmlParseCharData(ctxt);
}
}
cur = in->cur[0];
}
}
break;
@ -6745,6 +6766,8 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
ctxt->nameNr = 0;
ctxt->name = NULL;
ctxt->nsNr = 0;
DICT_FREE(ctxt->version);
ctxt->version = NULL;
DICT_FREE(ctxt->encoding);
@ -7278,6 +7301,4 @@ htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (htmlDoRead(ctxt, URL, encoding, options, 1));
}
#define bottom_HTMLparser
#include "elfgcchack.h"
#endif /* LIBXML_HTML_ENABLED */

View file

@ -12,13 +12,8 @@
#ifdef LIBXML_HTML_ENABLED
#include <string.h> /* for memset() only ! */
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/HTMLparser.h>
@ -304,7 +299,7 @@ create:
* output as <option selected>, as per XSLT 1.0 16.2 "HTML Output Method"
*
*/
static const char* htmlBooleanAttrs[] = {
static const char* const htmlBooleanAttrs[] = {
"checked", "compact", "declare", "defer", "disabled", "ismap",
"multiple", "nohref", "noresize", "noshade", "nowrap", "readonly",
"selected", NULL
@ -992,7 +987,14 @@ void
htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
const char *encoding ATTRIBUTE_UNUSED,
int format) {
int type = 0;
if (cur) {
type = cur->type;
cur->type = XML_HTML_DOCUMENT_NODE;
}
htmlNodeDumpFormatOutput(buf, cur, (xmlNodePtr) cur, NULL, format);
if (cur)
cur->type = (xmlElementType) type;
}
/**
@ -1195,6 +1197,4 @@ htmlSaveFileEnc(const char *filename, xmlDocPtr cur, const char *encoding) {
#endif /* LIBXML_OUTPUT_ENABLED */
#define bottom_HTMLtree
#include "elfgcchack.h"
#endif /* LIBXML_HTML_ENABLED */

View file

@ -1,5 +1,191 @@
NEWS file for libxml2
v2.10.0: Aug 17 2022
### Security
- [CVE-2022-2309] Reset nsNr in xmlCtxtReset
- Reserve byte for NUL terminator and report errors consistently in xmlBuf and
xmlBuffer (David Kilzer)
- Fix missing NUL terminators in xmlBuf and xmlBuffer functions (David Kilzer)
- Fix integer overflow in xmlBufferDump() (David Kilzer)
- xmlBufAvail() should return length without including a byte for NUL
terminator (David Kilzer)
- Fix ownership of xmlNodePtr & xmlAttrPtr fields in xmlSetTreeDoc() (David
Kilzer)
- Use xmlNewDocText in xmlXIncludeCopyRange
- Fix use-after-free bugs when calling xmlTextReaderClose() before
xmlFreeTextReader() on post-validating parser (David Kilzer)
- Use UPDATE_COMPAT() consistently in buf.c (David Kilzer)
- fix: xmlXPathParserContext could be double-delete in OOM case. (jinsub ahn)
### Removals and deprecations
- Disable XPointer location support by default
- Remove outdated xml2Conf.sh
- Deprecate module init and cleanup functions
- Remove obsolete XML Software Autoupdate (XSA) file
- Remove DOCBparser
- Remove obsolete Python test framework
- Remove broken VxWorks support
- Remove broken Mac OS 9 support
- Remove broken bakefile support
- Remove broken Visual Studio 2010 support
- Remove broken Windows CE support
- Deprecate IDREF-related functions in valid.h
- Deprecate legacy functions
- Disable legacy support by default
- Deprecate all functions in nanoftp.h
- Disable FTP support by default
- Add XML_DEPRECATED macro
- Remove elfgcchack.h
### Regressions
- Skip incorrectly opened HTML comments
- Restore behavior of htmlDocContentDumpFormatOutput() (David Kilzer)
### Bug fixes
- Fix memory leak with invalid XSD
- Make XPath depth check work with recursive invocations
- Fix memory leak in xmlLoadEntityContent error path
- Avoid double-free if malloc fails in inputPush
- Properly fold whitespace around the QName value when validating an XSD
schema. (Damjan Jovanovic)
- Add whitespace folding for some atomic data types that it's missing on.
(Damjan Jovanovic)
- Don't add IDs containing unexpanded entity references
### Improvements
- Avoid calling xmlSetTreeDoc
- Simplify xmlFreeNode
- Don't reset nsDef when changing node content
- Fix unintended fall-through in xmlNodeAddContentLen
- Remove unused xmlBuf functions (David Kilzer)
- Implement xpath1() XPointer scheme
- Add configuration flag for XPointer locations support
- Fix compiler warnings in Python code
- Mark more static data as `const` (David Kilzer)
- Make xmlStaticCopyNode non-recursive
- Clean up encoding switching code
- Simplify recursive pthread mutex
- Use non-recursive mutex in dict.c
- Fix parser progress checks
- Avoid arithmetic on freed pointers
- Improve buffer allocation scheme
- Remove unneeded #includes
- Add support for some non-standard escapes in regular expressions. (Damjan
Jovanovic)
- htmlParseComment: handle abruptly-closed comments (Mike Dalessio)
- Add let variable tag support (Oliver Diehl)
- Add value-of tag support (Oliver Diehl)
- Remove useless call to xmlRelaxNGCleanupTypes
- Don't include ICU headers in public headers
- Update `xmlStrlen()` to use POSIX / ISO C `strlen()` (Mike Dalessio)
- Fix unused variable warnings with disabled features
- Only warn on invalid redeclarations of predefined entities
- Remove unneeded code in xmlreader.c
- Rework validation context flags
### Portability
- Use NAN/INFINITY if available to init XPath NaN/Inf (Sergey Kosukhin)
- Fix Python tests on macOS
- Fix xmlCleanupThreads on Windows
- Fix reinitialization of library on Windows
- Don't mix declarations and code in runtest.c
- Use portable python shebangs (David Seifert)
- Use critical sections as mutex on Windows
- Don't set HAVE_WIN32_THREADS in win32config.h
- Use stdint.h with newer MSVC
- Remove cruft from win32config.h
- Remove isinf/isnan emulation in win32config.h
- Always fopen files with "rb"
- Remove __DJGPP__ checks
- Remove useless __CYGWIN__ checks
### Build system
- Don't autogenerate doc/examples/Makefile.am
- cmake: Install libxml.m4 on UNIX-like platforms (Daniel E)
- cmake: Use symbol versioning on UNIX-like platforms (Daniel E)
- Port genUnicode.py to Python 3
- Port gentest.py to Python 3
- cmake: Fix build without thread support
- cmake: Install documentation in CMAKE_INSTALL_DOCDIR
- cmake: Remove non needed files in docs dir (Daniel E)
- configure: move XML_PRIVATE_LIBS after WIN32_EXTRA_LIBADD is set
(Christopher Degawa)
- Move local Autoconf macros into m4 directory
- Use XML_PRIVATE_LIBS in libxml2_la_LIBADD
- Update libxml-2.0-uninstalled.pc.in
- Remove LIBS from XML_PRIVATE_LIBS
- Add WIN32_EXTRA_LIBADD to XML_PRIVATE_LIBS
- Don't overlink executables
- cmake: Adjust paths for UNIX or UNIX-like target systems (Daniel Engberg)
- build: Make use of variables in libxml's pkg-config file (Daniel Engberg)
- Avoid obsolescent `test -a` constructs (David Seifert)
- Move AM_MAINTAINER_MODE to AM section
- configure.ac: make AM_SILENT_RULES([yes]) unconditional (David Seifert)
- Streamline documentation installation
- Don't try to recreate COPYING symlink
- Detect libm using libtool's macros (David Seifert)
- configure.ac: disable static libraries by default (David Seifert)
- python/Makefile.am: nest python docs in $(docdir) (David Seifert)
- python/Makefile.am: rely on global AM_INIT_AUTOMAKE (David Seifert)
- Makefile.am: install examples more idiomatically (David Seifert)
- configure.ac: remove useless AC_SUBST (David Seifert)
- Respect `--sysconfdir` in source files (David Seifert)
- Ignore configure backup file created by recent autoreconf too (Vadim Zeitlin)
- Only install *.html and *.c example files
- Remove --with-html-dir option
- Rework documentation build system
- Remove old website
- Use AM_PATH_PYTHON/PKG_CHECK_MODULES for python bindings (David Seifert)
- Update genChRanges.py
- Update build_glob.py
- Remove ICONV_CONST test
- Remove obsolete AC_HEADER checks
- Don't check for standard C89 library functions
- Don't check for standard C89 headers
- Remove special configuration for certain maintainers
### Test suite, CI
- Disable network in API tests
- testapi: remove leading slash from "/missing.xml" (Mike Gilbert)
- Build Autotools CI tests out of source tree (VPATH)
- Add --with-minimum build to CI tests
- Fix warnings when testing --with-minimum build
- cmake: Run all tests when threads are disabled
- Also build CI tests with -Werror
- Move doc/examples tests to new test suite
- Simplify 'make check' targets
- Fix schemas and relaxng tests
- Remove unused result files
- Allow missing result files in runtest
- Move regexp tests to runtest
- Move SVG tests to runtest.c
- Move testModule to new test suite
- Move testThreads to new test suite
- Remove major parts of old test suite
- Make testchar return an error on failure (Tony Tascioglu)
- Add CI job for static build
- python/tests: open() relative to test scripts (David Seifert)
- Port some test scripts to Python 3
### Documentation
- Improve documentation of tree manipulation API
- Update xml2-config man page
- Consolidate man pages
- Rename xmlcatalog_man.xml
- Make examples a standalone HTML page
- Fix documentation in entities.c
- Add note about optimization flags
NEWS file for libxml2
v2.9.14: May 02 2022:
- Security:

View file

@ -44,6 +44,11 @@ configure and build the library:
./configure [possible options]
make
Note that by default, no optimization options are used. You have to
enable them manually, for example with:
CFLAGS='-O2 -fno-semantic-interposition' ./configure
Now you can run the test suite with:
make check

View file

@ -126,55 +126,6 @@ inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
#endif /* LIBXML_HTML_ENABLED */
#ifdef LIBXML_DOCB_ENABLED
/**
* initdocbDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default DocBook SAX version 1 handler
* DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
*/
void
initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = NULL;
hdlr->elementDecl = NULL;
hdlr->notationDecl = NULL;
hdlr->unparsedEntityDecl = NULL;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = NULL;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = NULL;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#endif /* LIBXML_DOCB_ENABLED */
#endif /* LIBXML_SAX1_ENABLED */
#define bottom_SAX
#include "elfgcchack.h"
#endif /* LIBXML_LEGACY_ENABLED */

View file

@ -180,31 +180,6 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
NULL, 0, 0, msg, str1);
}
/**
* xmlNsErrMsg:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @str1: an error string
* @str2: an error string
*
* Handle a namespace error
*/
static void LIBXML_ATTR_FORMAT(3,0)
xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2)
{
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF))
return;
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
XML_ERR_ERROR, NULL, 0,
(const char *) str1, (const char *) str2,
NULL, 0, 0, msg, str1, str2);
}
/**
* xmlNsWarnMsg:
* @ctxt: an XML parser context
@ -709,6 +684,9 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
xmlAttributePtr attr;
xmlChar *name = NULL, *prefix = NULL;
/* Avoid unused variable warning if features are disabled. */
(void) attr;
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@ -776,6 +754,9 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlElementPtr elem = NULL;
/* Avoid unused variable warning if features are disabled. */
(void) elem;
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@ -822,6 +803,9 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNotationPtr nota = NULL;
/* Avoid unused variable warning if features are disabled. */
(void) nota;
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@ -1050,7 +1034,32 @@ xmlSAX2EndDocument(void *ctx)
}
}
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
/**
* xmlNsErrMsg:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @str1: an error string
* @str2: an error string
*
* Handle a namespace error
*/
static void LIBXML_ATTR_FORMAT(3,0)
xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2)
{
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF))
return;
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
XML_ERR_ERROR, NULL, 0,
(const char *) str1, (const char *) str2,
NULL, 0, 0, msg, str1, str2);
}
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
@ -1144,6 +1153,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
/* Avoid unused variable warning if features are disabled. */
(void) nsret;
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
@ -1206,6 +1218,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
/* Avoid unused variable warning if features are disabled. */
(void) nsret;
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
@ -1368,7 +1383,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
/* Don't create IDs containing entity references */
(ret->children != NULL) &&
(ret->children->type == XML_TEXT_NODE) &&
(ret->children->next == NULL)) {
xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@ -1379,16 +1399,16 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
*
* Open issue: normalization of the value.
*/
if (xmlValidateNCName(value, 1) != 0) {
if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
(const char *) value, NULL);
(const char *) content, NULL);
}
xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
error:
@ -1747,7 +1767,8 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
if ((ctxt->validate) &&
((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@ -1756,7 +1777,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
}
#endif /* LIBXML_VALID_ENABLED */
@ -2120,7 +2141,12 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
/* Don't create IDs containing entity references */
(ret->children != NULL) &&
(ret->children->type == XML_TEXT_NODE) &&
(ret->children->next == NULL)) {
xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@ -2133,27 +2159,20 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
*
* Open issue: normalization of the value.
*/
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)
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#ifdef LIBXML_VALID_ENABLED
if (xmlValidateNCName(dup, 1) != 0) {
if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
(const char *) dup, NULL);
(const char *) content, NULL);
}
#endif
#endif
xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
/* might be worth duplicate entry points and not copy */
if (dup == NULL)
dup = xmlStrndup(value, valueend - value);
xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
if (dup == NULL)
dup = xmlStrndup(value, valueend - value);
xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
}
if (dup != NULL)
@ -2405,7 +2424,8 @@ xmlSAX2StartElementNs(void *ctx,
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
if ((ctxt->validate) &&
((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@ -2414,7 +2434,7 @@ xmlSAX2StartElementNs(void *ctx,
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
}
#endif /* LIBXML_VALID_ENABLED */
}
@ -2613,9 +2633,10 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
}
} else {
/* Mixed content, first time */
if (type == XML_TEXT_NODE)
if (type == XML_TEXT_NODE) {
lastChild = xmlSAX2TextNode(ctxt, ch, len);
else
lastChild->doc = ctxt->myDoc;
} else
lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
if (lastChild != NULL) {
xmlAddChild(ctxt->node, lastChild);
@ -2908,6 +2929,9 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
/**
* xmlDefaultSAXHandlerInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default SAX2 handler
*/
void
@ -2966,6 +2990,9 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
/**
* htmlDefaultSAXHandlerInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default SAX handler
*/
void
@ -2975,63 +3002,3 @@ htmlDefaultSAXHandlerInit(void)
}
#endif /* LIBXML_HTML_ENABLED */
#ifdef LIBXML_DOCB_ENABLED
/**
* xmlSAX2InitDocbDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default DocBook SAX2 handler
*/
void
xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr)
{
if ((hdlr == NULL) || (hdlr->initialized != 0))
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = NULL;
hdlr->elementDecl = NULL;
hdlr->notationDecl = NULL;
hdlr->unparsedEntityDecl = NULL;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = NULL;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = NULL;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
/**
* docbDefaultSAXHandlerInit:
*
* Initialize the default SAX handler
*/
void
docbDefaultSAXHandlerInit(void)
{
xmlSAX2InitDocbDefaultSAXHandler((xmlSAXHandlerPtr) &docbDefaultSAXHandler);
}
#endif /* LIBXML_DOCB_ENABLED */
#define bottom_SAX2
#include "elfgcchack.h"

View file

@ -17,12 +17,8 @@
#include <string.h> /* for memset() only ! */
#include <limits.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/tree.h>
#include <libxml/globals.h>
@ -131,12 +127,11 @@ xmlBufCreate(void) {
xmlBufMemoryError(NULL, "creating buffer");
return(NULL);
}
ret->compat_use = 0;
ret->use = 0;
ret->error = 0;
ret->buffer = NULL;
ret->size = xmlDefaultBufferSize;
ret->compat_size = xmlDefaultBufferSize;
UPDATE_COMPAT(ret);
ret->alloc = xmlBufferAllocScheme;
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
if (ret->content == NULL) {
@ -167,13 +162,12 @@ xmlBufCreateSize(size_t size) {
xmlBufMemoryError(NULL, "creating buffer");
return(NULL);
}
ret->compat_use = 0;
ret->use = 0;
ret->error = 0;
ret->buffer = NULL;
ret->alloc = xmlBufferAllocScheme;
ret->size = (size ? size + 1 : 0); /* +1 for ending null */
ret->compat_size = (ret->size > INT_MAX ? INT_MAX : ret->size);
UPDATE_COMPAT(ret);
if (ret->size){
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
if (ret->content == NULL) {
@ -215,8 +209,7 @@ xmlBufDetach(xmlBufPtr buf) {
buf->content = NULL;
buf->size = 0;
buf->use = 0;
buf->compat_use = 0;
buf->compat_size = 0;
UPDATE_COMPAT(buf);
return ret;
}
@ -245,15 +238,9 @@ xmlBufCreateStatic(void *mem, size_t size) {
xmlBufMemoryError(NULL, "creating buffer");
return(NULL);
}
if (size < INT_MAX) {
ret->compat_use = size;
ret->compat_size = size;
} else {
ret->compat_use = INT_MAX;
ret->compat_size = INT_MAX;
}
ret->use = size;
ret->size = size;
UPDATE_COMPAT(ret);
ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE;
ret->content = (xmlChar *) mem;
ret->error = 0;
@ -449,9 +436,11 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
if (len < buf->size - buf->use)
return(buf->size - buf->use);
if (len > SIZE_MAX - buf->use)
return(buf->size - buf->use - 1);
if (len >= SIZE_MAX - buf->use) {
xmlBufMemoryError(buf, "growing buffer past SIZE_MAX");
return(0);
}
if (buf->size > (size_t) len) {
size = buf->size > SIZE_MAX / 2 ? SIZE_MAX : buf->size * 2;
@ -464,7 +453,7 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
/*
* Used to provide parsing limits
*/
if ((buf->use + len >= XML_MAX_TEXT_LENGTH) ||
if ((buf->use + len + 1 >= XML_MAX_TEXT_LENGTH) ||
(buf->size >= XML_MAX_TEXT_LENGTH)) {
xmlBufMemoryError(buf, "buffer error: text too long\n");
return(0);
@ -492,7 +481,7 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
}
buf->size = size;
UPDATE_COMPAT(buf)
return(buf->size - buf->use);
return(buf->size - buf->use - 1);
}
/**
@ -518,24 +507,6 @@ xmlBufGrow(xmlBufPtr buf, int len) {
return((int) ret);
}
/**
* xmlBufInflate:
* @buf: the buffer
* @len: the minimum extra free size to allocate
*
* Grow the available space of an XML buffer, adding at least @len bytes
*
* Returns 0 if successful or -1 in case of error
*/
int
xmlBufInflate(xmlBufPtr buf, size_t len) {
if (buf == NULL) return(-1);
xmlBufGrowInternal(buf, len + buf->size);
if (buf->error)
return(-1);
return(0);
}
/**
* xmlBufDump:
* @file: the file output
@ -622,34 +593,9 @@ xmlBufAddLen(xmlBufPtr buf, size_t len) {
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (len > (buf->size - buf->use))
if (len >= (buf->size - buf->use))
return(-1);
buf->use += len;
UPDATE_COMPAT(buf)
if (buf->size > buf->use)
buf->content[buf->use] = 0;
else
return(-1);
return(0);
}
/**
* xmlBufErase:
* @buf: the buffer
* @len: the size to erase at the end
*
* Sometime data need to be erased at the end of the buffer
*
* Returns -1 in case of error and 0 otherwise
*/
int
xmlBufErase(xmlBufPtr buf, size_t len) {
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (len > buf->use)
return(-1);
buf->use -= len;
buf->content[buf->use] = 0;
UPDATE_COMPAT(buf)
return(0);
@ -698,10 +644,11 @@ xmlBufUse(const xmlBufPtr buf)
* @buf: the buffer
*
* Function to find how much free space is allocated but not
* used in the buffer. It does not account for the terminating zero
* usually needed
* used in the buffer. It reserves one byte for the NUL
* terminator character that is usually needed, so there is
* no need to subtract 1 from the result anymore.
*
* Returns the amount or 0 if none or an error occurred
* Returns the amount, or 0 if none or if an error occurred.
*/
size_t
@ -711,7 +658,7 @@ xmlBufAvail(const xmlBufPtr buf)
return 0;
CHECK_COMPAT(buf)
return(buf->size - buf->use);
return((buf->size > buf->use) ? (buf->size - buf->use - 1) : 0);
}
/**
@ -829,6 +776,8 @@ xmlBufResize(xmlBufPtr buf, size_t size)
} else {
if (buf->content == NULL) {
rebuf = (xmlChar *) xmlMallocAtomic(newSize);
buf->use = 0;
rebuf[buf->use] = 0;
} else if (buf->size - buf->use < 100) {
rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
} else {
@ -892,9 +841,12 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
if (len < 0) return -1;
if (len == 0) return 0;
/* Note that both buf->size and buf->use can be zero here. */
if ((size_t) len >= buf->size - buf->use) {
if ((size_t) len >= SIZE_MAX - buf->use)
if ((size_t) len >= SIZE_MAX - buf->use) {
xmlBufMemoryError(buf, "growing buffer past SIZE_MAX");
return(-1);
}
needSize = buf->use + len + 1;
if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
/*
@ -918,87 +870,6 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
return 0;
}
/**
* xmlBufAddHead:
* @buf: the buffer
* @str: the #xmlChar string
* @len: the number of #xmlChar to add
*
* Add a string range to the beginning of an XML buffer.
* if len == -1, the length of @str is recomputed.
*
* Returns 0 successful, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
unsigned int needSize;
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
if (str == NULL) {
#ifdef DEBUG_BUFFER
xmlGenericError(xmlGenericErrorContext,
"xmlBufAddHead: str == NULL\n");
#endif
return -1;
}
if (len < -1) {
#ifdef DEBUG_BUFFER
xmlGenericError(xmlGenericErrorContext,
"xmlBufAddHead: len < 0\n");
#endif
return -1;
}
if (len == 0) return 0;
if (len < 0)
len = xmlStrlen(str);
if (len <= 0) return -1;
if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
size_t start_buf = buf->content - buf->contentIO;
if (start_buf > (unsigned int) len) {
/*
* We can add it in the space previously shrunk
*/
buf->content -= len;
memmove(&buf->content[0], str, len);
buf->use += len;
buf->size += len;
UPDATE_COMPAT(buf)
return(0);
}
}
needSize = buf->use + len + 2;
if (needSize > buf->size){
if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
/*
* Used to provide parsing limits
*/
if (needSize >= XML_MAX_TEXT_LENGTH) {
xmlBufMemoryError(buf, "buffer error: text too long\n");
return(-1);
}
}
if (!xmlBufResize(buf, needSize)){
xmlBufMemoryError(buf, "growing buffer");
return XML_ERR_NO_MEMORY;
}
}
memmove(&buf->content[len], &buf->content[0], buf->use);
memmove(&buf->content[0], str, len);
buf->use += len;
buf->content[buf->use] = 0;
UPDATE_COMPAT(buf)
return 0;
}
/**
* xmlBufCat:
* @buf: the buffer to add to
@ -1034,49 +905,6 @@ xmlBufCCat(xmlBufPtr buf, const char *str) {
return xmlBufCat(buf, (const xmlChar *) str);
}
/**
* xmlBufWriteCHAR:
* @buf: the XML buffer
* @string: the string to add
*
* routine which manages and grows an output buffer. This one adds
* xmlChars at the end of the buffer.
*
* Returns 0 if successful, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string) {
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
return(-1);
return(xmlBufCat(buf, string));
}
/**
* xmlBufWriteChar:
* @buf: the XML buffer output
* @string: the string to add
*
* routine which manage and grows an output buffer. This one add
* C chars at the end of the array.
*
* Returns 0 if successful, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlBufWriteChar(xmlBufPtr buf, const char *string) {
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
return(-1);
return(xmlBufCCat(buf, string));
}
/**
* xmlBufWriteQuotedString:
* @buf: the XML buffer output
@ -1159,8 +987,7 @@ xmlBufFromBuffer(xmlBufferPtr buffer) {
}
ret->use = buffer->use;
ret->size = buffer->size;
ret->compat_use = buffer->use;
ret->compat_size = buffer->size;
UPDATE_COMPAT(ret);
ret->error = 0;
ret->buffer = buffer;
ret->alloc = buffer->alloc;
@ -1329,5 +1156,3 @@ xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
return(0);
}
#define bottom_buf
#include "elfgcchack.h"

View file

@ -32,15 +32,11 @@ void xmlBufEmpty(xmlBufPtr buf);
/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
int xmlBufGrow(xmlBufPtr buf, int len);
int xmlBufInflate(xmlBufPtr buf, size_t len);
int xmlBufResize(xmlBufPtr buf, size_t len);
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
int xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len);
int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
int xmlBufCCat(xmlBufPtr buf, const char *str);
int xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string);
int xmlBufWriteChar(xmlBufPtr buf, const char *string);
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
size_t xmlBufAvail(const xmlBufPtr buf);
@ -48,7 +44,6 @@ size_t xmlBufLength(const xmlBufPtr buf);
/* size_t xmlBufUse(const xmlBufPtr buf); */
int xmlBufIsEmpty(const xmlBufPtr buf);
int xmlBufAddLen(xmlBufPtr buf, size_t len);
int xmlBufErase(xmlBufPtr buf, size_t len);
/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */

View file

@ -14,9 +14,7 @@
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>
#include <libxml/tree.h>
@ -1659,9 +1657,6 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
break;
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_FRAG_NODE: /* should be processed as document? */
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE: /* should be processed as document? */
#endif
#ifdef LIBXML_HTML_ENABLED
case XML_HTML_DOCUMENT_NODE: /* should be processed as document? */
#endif
@ -2229,6 +2224,5 @@ xmlC11NNormalizeString(const xmlChar * input,
return (buffer);
}
#endif /* LIBXML_OUTPUT_ENABLED */
#define bottom_c14n
#include "elfgcchack.h"
#endif /* LIBXML_C14N_ENABLED */

View file

@ -16,6 +16,8 @@
#include "libxml.h"
#ifdef LIBXML_CATALOG_ENABLED
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@ -28,10 +30,6 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/hash.h>
#include <libxml/uri.h>
@ -70,26 +68,20 @@
#define XML_URN_PUBID "urn:publicid:"
#define XML_CATAL_BREAK ((xmlChar *) -1)
#ifndef XML_XML_DEFAULT_CATALOG
#define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog"
#define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog"
#endif
#ifndef XML_SGML_DEFAULT_CATALOG
#define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog"
#define XML_SGML_DEFAULT_CATALOG "file://" SYSCONFDIR "/sgml/catalog"
#endif
#if defined(_WIN32) && defined(_MSC_VER)
#undef XML_XML_DEFAULT_CATALOG
static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog";
#if defined(_WIN32_WCE)
/* Windows CE don't have a A variant */
#define GetModuleHandleA GetModuleHandle
#define GetModuleFileNameA GetModuleFileName
#else
static char XML_XML_DEFAULT_CATALOG[256] = "file://" SYSCONFDIR "/xml/catalog";
#if !defined(_WINDOWS_)
void* __stdcall GetModuleHandleA(const char*);
unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long);
#endif
#endif
#endif
static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID);
static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename);
@ -3825,6 +3817,4 @@ xmlCatalogGetPublic(const xmlChar *pubID) {
return(NULL);
}
#define bottom_catalog
#include "elfgcchack.h"
#endif /* LIBXML_CATALOG_ENABLED */

View file

@ -332,5 +332,3 @@ xmlIsPubidChar(unsigned int ch) {
return(xmlIsPubidCharQ(ch));
}
#define bottom_chvalid
#include "elfgcchack.h"

View file

@ -19,13 +19,6 @@
/* Whether struct sockaddr::__ss_family exists */
/* #undef HAVE_BROKEN_SS_FAMILY */
/* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
@ -35,18 +28,9 @@
/* Define to 1 if you have the <dl.h> header file. */
/* #undef HAVE_DL_H */
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <float.h> header file. */
#define HAVE_FLOAT_H 1
/* Define to 1 if you have the `fprintf' function. */
#define HAVE_FPRINTF 1
/* Define to 1 if you have the `ftime' function. */
#define HAVE_FTIME 1
@ -68,21 +52,9 @@
/* Define if readline library is there (-lreadline) */
/* #undef HAVE_LIBREADLINE */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the `localtime' function. */
#define HAVE_LOCALTIME 1
/* Define to 1 if you have the <lzma.h> header file. */
/* #undef HAVE_LZMA_H */
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the <math.h> header file. */
#define HAVE_MATH_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
@ -97,9 +69,6 @@
# undef /**/ HAVE_MMAP
#endif
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the <netdb.h> header file. */
/* #undef HAVE_NETDB_H */
@ -109,18 +78,12 @@
/* Define to 1 if you have the <poll.h> header file. */
/* #undef HAVE_POLL_H */
/* Define to 1 if you have the `printf' function. */
#define HAVE_PRINTF 1
/* Define if <pthread.h> is there */
/* #undef HAVE_PTHREAD_H */
/* Define to 1 if you have the `putenv' function. */
/* #undef HAVE_PUTENV */
/* Define to 1 if you have the `rand' function. */
#define HAVE_RAND 1
/* Define to 1 if you have the `rand_r' function. */
/* #undef HAVE_RAND_R */
@ -130,56 +93,27 @@
/* Have shl_load based dso */
/* #undef HAVE_SHLLOAD */
/* Define to 1 if you have the `signal' function. */
#define HAVE_SIGNAL 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
/* Define to 1 if you have the `sprintf' function. */
#define HAVE_SPRINTF 1
/* Define to 1 if you have the `srand' function. */
#define HAVE_SRAND 1
/* Define to 1 if you have the `sscanf' function. */
#define HAVE_SSCANF 1
/* Define to 1 if you have the `stat' function. */
#define HAVE_STAT 1
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strftime' function. */
#define HAVE_STRFTIME 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/mman.h> header file. */
/* #undef HAVE_SYS_MMAN_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
@ -198,36 +132,21 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the `time' function. */
#define HAVE_TIME 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Whether va_copy() is available */
#define HAVE_VA_COPY 1
/* Define to 1 if you have the `vfprintf' function. */
#define HAVE_VFPRINTF 1
/* Define to 1 if you have the `vsnprintf' function. */
#define HAVE_VSNPRINTF 1
/* Define to 1 if you have the `vsprintf' function. */
#define HAVE_VSPRINTF 1
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
/* Whether __va_copy() is available */
#define HAVE___VA_COPY 1
/* Define as const if the declaration of iconv() needs const. */
/* #undef ICONV_CONST */
/* Define to the sub-directory where libtool stores uninstalled libraries. */
/* #undef LT_OBJDIR */
@ -265,7 +184,7 @@
/* #undef VA_LIST_IS_ARRAY */
/* Version number of package */
#define VERSION "2.9.14"
#define VERSION "2.10.0"
/* Determine what socket length (socklen_t) data type is */
#define XML_SOCKLEN_T int

View file

@ -12,12 +12,8 @@
#ifdef LIBXML_DEBUG_ENABLED
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
@ -409,9 +405,6 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
break;
@ -1615,9 +1608,6 @@ xmlLsCountNode(xmlNodePtr node) {
break;
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
list = ((xmlDocPtr) node)->children;
break;
case XML_ATTRIBUTE_NODE:
@ -1850,6 +1840,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -1862,6 +1853,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3008,6 +3000,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -3020,6 +3013,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3125,6 +3119,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -3137,6 +3132,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3202,6 +3198,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -3214,6 +3211,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3287,6 +3285,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -3299,6 +3298,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3365,6 +3365,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
@ -3377,6 +3378,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
@ -3418,6 +3420,5 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
}
#endif /* LIBXML_XPATH_ENABLED */
#define bottom_debugXML
#include "elfgcchack.h"
#endif /* LIBXML_DEBUG_ENABLED */

View file

@ -20,12 +20,8 @@
#include "libxml.h"
#include <limits.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
/*
* Following http://www.ocert.org/advisories/ocert-2011-003.html
@ -38,8 +34,7 @@
* list we will use the BigKey algo as soon as the hash size grows
* over MIN_DICT_SIZE so this actually works
*/
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) && \
!defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#define DICT_RANDOMIZATION
#endif
@ -132,7 +127,7 @@ struct _xmlDict {
* A mutex for modifying the reference counter for shared
* dictionaries.
*/
static xmlRMutexPtr xmlDictMutex = NULL;
static xmlMutexPtr xmlDictMutex = NULL;
/*
* Whether the dictionary mutex was initialized.
@ -151,8 +146,10 @@ static unsigned int rand_seed = 0;
/**
* xmlInitializeDict:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Do the dictionary mutex initialization.
* this function is deprecated
*
* Returns 0 if initialization was already done, and 1 if that
* call led to the initialization
@ -177,9 +174,9 @@ int __xmlInitializeDict(void) {
if (xmlDictInitialized)
return(1);
if ((xmlDictMutex = xmlNewRMutex()) == NULL)
if ((xmlDictMutex = xmlNewMutex()) == NULL)
return(0);
xmlRMutexLock(xmlDictMutex);
xmlMutexLock(xmlDictMutex);
#ifdef DICT_RANDOMIZATION
#ifdef HAVE_RAND_R
@ -190,7 +187,7 @@ int __xmlInitializeDict(void) {
#endif
#endif
xmlDictInitialized = 1;
xmlRMutexUnlock(xmlDictMutex);
xmlMutexUnlock(xmlDictMutex);
return(1);
}
@ -201,13 +198,13 @@ int __xmlRandom(void) {
if (xmlDictInitialized == 0)
__xmlInitializeDict();
xmlRMutexLock(xmlDictMutex);
xmlMutexLock(xmlDictMutex);
#ifdef HAVE_RAND_R
ret = rand_r(& rand_seed);
#else
ret = rand();
#endif
xmlRMutexUnlock(xmlDictMutex);
xmlMutexUnlock(xmlDictMutex);
return(ret);
}
#endif
@ -215,6 +212,11 @@ int __xmlRandom(void) {
/**
* xmlDictCleanup:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Free the dictionary mutex. Do not call unless sure the library
* is not in use anymore !
*/
@ -223,7 +225,7 @@ xmlDictCleanup(void) {
if (!xmlDictInitialized)
return;
xmlFreeRMutex(xmlDictMutex);
xmlFreeMutex(xmlDictMutex);
xmlDictInitialized = 0;
}
@ -648,9 +650,9 @@ xmlDictReference(xmlDictPtr dict) {
return(-1);
if (dict == NULL) return -1;
xmlRMutexLock(xmlDictMutex);
xmlMutexLock(xmlDictMutex);
dict->ref_counter++;
xmlRMutexUnlock(xmlDictMutex);
xmlMutexUnlock(xmlDictMutex);
return(0);
}
@ -812,14 +814,14 @@ xmlDictFree(xmlDictPtr dict) {
return;
/* decrement the counter, it may be shared by a parser and docs */
xmlRMutexLock(xmlDictMutex);
xmlMutexLock(xmlDictMutex);
dict->ref_counter--;
if (dict->ref_counter > 0) {
xmlRMutexUnlock(xmlDictMutex);
xmlMutexUnlock(xmlDictMutex);
return;
}
xmlRMutexUnlock(xmlDictMutex);
xmlMutexUnlock(xmlDictMutex);
if (dict->subdict != NULL) {
xmlDictFree(dict->subdict);
@ -1294,5 +1296,3 @@ xmlDictGetUsage(xmlDictPtr dict) {
return(limit);
}
#define bottom_dict
#include "elfgcchack.h"

File diff suppressed because it is too large Load diff

View file

@ -25,18 +25,13 @@
#include <string.h>
#include <limits.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef LIBXML_ICONV_ENABLED
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#endif
#include <libxml/encoding.h>
#include <libxml/xmlmemory.h>
#ifdef LIBXML_HTML_ENABLED
@ -48,6 +43,20 @@
#include "buf.h"
#include "enc.h"
#ifdef LIBXML_ICU_ENABLED
#include <unicode/ucnv.h>
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
#define ICU_PIVOT_BUF_SIZE 1024
typedef struct _uconv_t uconv_t;
struct _uconv_t {
UConverter *uconv; /* for conversion between an encoding and UTF-16 */
UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
UChar *pivot_source;
UChar *pivot_target;
};
#endif
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
@ -1399,6 +1408,9 @@ xmlNewCharEncodingHandler(const char *name,
/**
* xmlInitCharEncodingHandlers:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the char encoding support, it registers the default
* encoding supported.
* NOTE: while public, this function usually doesn't need to be called
@ -1459,6 +1471,11 @@ xmlInitCharEncodingHandlers(void) {
/**
* xmlCleanupCharEncodingHandlers:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the memory allocated for the char encoding support, it
* unregisters all the encoding handlers and the aliases.
*/
@ -1835,7 +1852,10 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
}
icv_inlen = *inlen;
icv_outlen = *outlen;
ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
/*
* Some versions take const, other versions take non-const input.
*/
ret = iconv(cd, (void *) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
*inlen -= icv_inlen;
*outlen -= icv_outlen;
if ((icv_inlen != 0) || (ret == (size_t) -1)) {
@ -2177,7 +2197,7 @@ xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
toconv = xmlBufUse(in);
if (toconv == 0)
return (0);
written = xmlBufAvail(out) - 1; /* count '\0' */
written = xmlBufAvail(out);
/*
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
* 45 chars should be sufficient to reach the end of the encoding
@ -2195,7 +2215,7 @@ xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
}
if (toconv * 2 >= written) {
xmlBufGrow(out, toconv * 2);
written = xmlBufAvail(out) - 1;
written = xmlBufAvail(out);
}
if (written > 360)
written = 360;
@ -2287,13 +2307,9 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
if ((toconv > 64 * 1024) && (flush == 0))
toconv = 64 * 1024;
written = xmlBufAvail(out);
if (written > 0)
written--; /* count '\0' */
if (toconv * 2 >= written) {
xmlBufGrow(out, toconv * 2);
written = xmlBufAvail(out);
if (written > 0)
written--; /* count '\0' */
}
if ((written > 128 * 1024) && (flush == 0))
written = 128 * 1024;
@ -2475,8 +2491,6 @@ xmlCharEncOutput(xmlOutputBufferPtr output, int init)
retry:
written = xmlBufAvail(out);
if (written > 0)
written--; /* count '\0' */
/*
* First specific handling of the initialization call
@ -2505,7 +2519,7 @@ retry:
toconv = 64 * 1024;
if (toconv * 4 >= written) {
xmlBufGrow(out, toconv * 4);
written = xmlBufAvail(out) - 1;
written = xmlBufAvail(out);
}
if (written > 256 * 1024)
written = 256 * 1024;
@ -2580,7 +2594,7 @@ retry:
"&#%d;", cur);
xmlBufShrink(in, len);
xmlBufGrow(out, charrefLen * 4);
c_out = xmlBufAvail(out) - 1;
c_out = xmlBufAvail(out);
c_in = charrefLen;
ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
charref, &c_in);
@ -2784,6 +2798,9 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
int tofree = 0;
int i, handler_in_list = 0;
/* Avoid unused variable warning if features are disabled. */
(void) handler_in_list;
if (handler == NULL) return(-1);
if (handler->name == NULL) return(-1);
if (handlers != NULL) {
@ -2927,7 +2944,7 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
static int
UTF8ToISO8859x(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen,
unsigned char const *xlattable) {
const unsigned char* const xlattable) {
const unsigned char* outstart = out;
const unsigned char* inend;
const unsigned char* instart = in;
@ -3117,7 +3134,7 @@ static unsigned short const xmlunicodetable_ISO8859_2 [128] = {
0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
"\x00\x00\x01\x05\x02\x04\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3166,7 +3183,7 @@ static unsigned short const xmlunicodetable_ISO8859_3 [128] = {
0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
"\x04\x00\x01\x06\x02\x05\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3219,7 +3236,7 @@ static unsigned short const xmlunicodetable_ISO8859_4 [128] = {
0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
"\x00\x00\x01\x05\x02\x03\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3268,7 +3285,7 @@ static unsigned short const xmlunicodetable_ISO8859_5 [128] = {
0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
};
static unsigned char const xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
"\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3317,7 +3334,7 @@ static unsigned short const xmlunicodetable_ISO8859_6 [128] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
"\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3362,7 +3379,7 @@ static unsigned short const xmlunicodetable_ISO8859_7 [128] = {
0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
"\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x06"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3415,7 +3432,7 @@ static unsigned short const xmlunicodetable_ISO8859_8 [128] = {
0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
"\x02\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3468,7 +3485,7 @@ static unsigned short const xmlunicodetable_ISO8859_9 [128] = {
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
"\x00\x00\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3513,7 +3530,7 @@ static unsigned short const xmlunicodetable_ISO8859_10 [128] = {
0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
};
static unsigned char const xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
"\x00\x00\x01\x06\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3566,7 +3583,7 @@ static unsigned short const xmlunicodetable_ISO8859_11 [128] = {
0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
"\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3615,7 +3632,7 @@ static unsigned short const xmlunicodetable_ISO8859_13 [128] = {
0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
};
static unsigned char const xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
"\x00\x00\x01\x04\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3668,7 +3685,7 @@ static unsigned short const xmlunicodetable_ISO8859_14 [128] = {
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
"\x00\x00\x01\x09\x04\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3733,7 +3750,7 @@ static unsigned short const xmlunicodetable_ISO8859_15 [128] = {
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
"\x00\x00\x01\x05\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3782,7 +3799,7 @@ static unsigned short const xmlunicodetable_ISO8859_16 [128] = {
0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_16 [48 + 9 * 64] = {
static const unsigned char xmltranscodetable_ISO8859_16 [48 + 9 * 64] = {
"\x00\x00\x01\x08\x02\x03\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@ -3976,5 +3993,3 @@ xmlRegisterCharEncodingHandlersISO8859x (void) {
#endif
#endif
#define bottom_encoding
#include "elfgcchack.h"

View file

@ -15,9 +15,8 @@
#include "libxml.h"
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/hash.h>
#include <libxml/entities.h>
@ -86,7 +85,7 @@ xmlEntitiesErrMemory(const char *extra)
* @code: the error code
* @msg: the message
*
* Handle an out of memory condition
* Raise an error.
*/
static void LIBXML_ATTR_FORMAT(2,0)
xmlEntitiesErr(xmlParserErrors code, const char *msg)
@ -94,6 +93,23 @@ xmlEntitiesErr(xmlParserErrors code, const char *msg)
__xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL);
}
/**
* xmlEntitiesWarn:
* @code: the error code
* @msg: the message
*
* Raise a warning.
*/
static void LIBXML_ATTR_FORMAT(2,0)
xmlEntitiesWarn(xmlParserErrors code, const char *msg, const xmlChar *str1)
{
__xmlRaiseError(NULL, NULL, NULL,
NULL, NULL, XML_FROM_TREE, code,
XML_ERR_WARNING, NULL, 0,
(const char *)str1, NULL, NULL, 0, 0,
msg, (const char *)str1, NULL);
}
/*
* xmlFreeEntity : clean-up an entity record.
*/
@ -255,9 +271,9 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
}
}
if (!valid) {
xmlEntitiesErr(XML_ERR_ENTITY_PROCESSING,
xmlEntitiesWarn(XML_ERR_ENTITY_PROCESSING,
"xmlAddEntity: invalid redeclaration of predefined"
" entity");
" entity '%s'", name);
return(NULL);
}
}
@ -1159,5 +1175,3 @@ xmlDumpEntitiesTable(xmlBufferPtr buf, xmlEntitiesTablePtr table) {
xmlHashScan(table, xmlDumpEntityDeclScan, buf);
}
#endif /* LIBXML_OUTPUT_ENABLED */
#define bottom_entities
#include "elfgcchack.h"

View file

@ -994,5 +994,3 @@ xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
return 0;
}
#define bottom_error
#include "elfgcchack.h"

View file

@ -14,9 +14,7 @@
#define IN_LIBXML
#include "libxml.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>
#include <libxml/globals.h>
@ -42,6 +40,9 @@ static xmlMutexPtr xmlThrDefMutex = NULL;
/**
* xmlInitGlobals:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Additional initialisation for multi-threading
*/
void xmlInitGlobals(void)
@ -136,7 +137,6 @@ xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
#include <libxml/globals.h>
#include <libxml/SAX.h>
#undef docbDefaultSAXHandler
#undef htmlDefaultSAXHandler
#undef oldXMLWDcompatibility
#undef xmlBufferAllocScheme
@ -443,44 +443,6 @@ xmlSAXHandlerV1 htmlDefaultSAXHandler = {
};
#endif /* LIBXML_HTML_ENABLED */
#ifdef LIBXML_DOCB_ENABLED
/**
* docbDefaultSAXHandler:
*
* Default old SAX v1 handler for SGML DocBook, builds the DOM tree
*/
xmlSAXHandlerV1 docbDefaultSAXHandler = {
xmlSAX2InternalSubset,
xmlSAX2IsStandalone,
xmlSAX2HasInternalSubset,
xmlSAX2HasExternalSubset,
xmlSAX2ResolveEntity,
xmlSAX2GetEntity,
xmlSAX2EntityDecl,
NULL,
NULL,
NULL,
NULL,
xmlSAX2SetDocumentLocator,
xmlSAX2StartDocument,
xmlSAX2EndDocument,
xmlSAX2StartElement,
xmlSAX2EndElement,
xmlSAX2Reference,
xmlSAX2Characters,
xmlSAX2IgnorableWhitespace,
NULL,
xmlSAX2Comment,
xmlParserWarning,
xmlParserError,
xmlParserError,
xmlSAX2GetParameterEntity,
NULL,
NULL,
0,
};
#endif /* LIBXML_DOCB_ENABLED */
/**
* xmlInitializeGlobalState:
* @gs: a pointer to a newly allocated global state
@ -504,9 +466,6 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
xmlMutexLock(xmlThrDefMutex);
#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
#endif
#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
#endif
@ -566,6 +525,11 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
/**
* xmlCleanupGlobals:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Additional cleanup for multi-threading
*/
void xmlCleanupGlobals(void)
@ -703,17 +667,6 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun
return(old);
}
#ifdef LIBXML_DOCB_ENABLED
#undef docbDefaultSAXHandler
xmlSAXHandlerV1 *
__docbDefaultSAXHandler(void) {
if (IS_MAIN_THREAD)
return (&docbDefaultSAXHandler);
else
return (&xmlGetGlobalState()->docbDefaultSAXHandler);
}
#endif
#ifdef LIBXML_HTML_ENABLED
#undef htmlDefaultSAXHandler
xmlSAXHandlerV1 *
@ -1124,5 +1077,3 @@ __xmlOutputBufferCreateFilenameValue(void) {
return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
}
#define bottom_globals
#include "elfgcchack.h"

View file

@ -21,20 +21,15 @@
#include "libxml.h"
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
/*
* Following http://www.ocert.org/advisories/ocert-2011-003.html
* it seems that having hash randomization might be a good idea
* when using XML with untrusted data
*/
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) && \
!defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#define HASH_RANDOMIZATION
#endif
@ -1142,5 +1137,3 @@ xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
}
}
#define bottom_hash
#include "elfgcchack.h"

View file

@ -1,121 +1,20 @@
#ifndef __LIBXML_WIN32_CONFIG__
#define __LIBXML_WIN32_CONFIG__
#define HAVE_CTYPE_H
#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
#include "wincecompat.h"
#else
#define HAVE_SYS_STAT_H
#define HAVE_STAT
#define HAVE_STDLIB_H
#define HAVE_TIME_H
#define HAVE_FCNTL_H
#include <io.h>
#include <direct.h>
#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
#define HAVE_STDINT_H
#endif
#include <libxml/xmlversion.h>
#ifndef ICONV_CONST
#define ICONV_CONST const
#endif
/*
* Windows platforms may define except
*/
#undef except
#define HAVE_ISINF
#define HAVE_ISNAN
#include <math.h>
#if defined(_MSC_VER) || defined(__BORLANDC__)
/* MS C-runtime has functions which can be used in order to determine if
a given floating-point variable contains NaN, (+-)INF. These are
preferred, because floating-point technology is considered proprietary
by MS and we can assume that their functions know more about their
oddities than we do. */
#include <float.h>
/* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass
function. */
#ifndef isinf
#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
: ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
#endif
/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
#ifndef isnan
#define isnan(d) (_isnan(d))
#endif
#else /* _MSC_VER */
#ifndef isinf
static int isinf (double d) {
int expon = 0;
double val = frexp (d, &expon);
if (expon == 1025) {
if (val == 0.5) {
return 1;
} else if (val == -0.5) {
return -1;
} else {
return 0;
}
} else {
return 0;
}
}
#endif
#ifndef isnan
static int isnan (double d) {
int expon = 0;
double val = frexp (d, &expon);
if (expon == 1025) {
if (val == 0.5) {
return 0;
} else if (val == -0.5) {
return 0;
} else {
return 1;
}
} else {
return 0;
}
}
#endif
#endif /* _MSC_VER */
#if defined(_MSC_VER)
#define mkdir(p,m) _mkdir(p)
#if _MSC_VER < 1900
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#endif
#elif defined(__MINGW32__)
#define mkdir(p,m) _mkdir(p)
#endif
/* Threading API to use should be specified here for compatibility reasons.
This is however best specified on the compiler's command-line. */
#if defined(LIBXML_THREAD_ENABLED)
#if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE)
#define HAVE_WIN32_THREADS
#endif
#endif
/* Some third-party libraries far from our control assume the following
is defined, which it is not if we don't include windows.h. */
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE (!(FALSE))
#define vsnprintf _vsnprintf
#endif
#endif /* __LIBXML_WIN32_CONFIG__ */

View file

@ -5,9 +5,6 @@
#if !defined __XML_WSOCKCOMPAT_H__
#define __XML_WSOCKCOMPAT_H__
#ifdef _WIN32_WCE
#include <winsock.h>
#else
#include <errno.h>
#include <winsock2.h>
@ -30,7 +27,6 @@
#include <wspiapi.h>
#define HAVE_GETADDRINFO
#endif
#endif
#undef XML_SOCKLEN_T
#define XML_SOCKLEN_T int

View file

@ -85,7 +85,7 @@ xmlCleanupPredefinedEntities(void)
{
}
static const char *xmlFeaturesList[] = {
static const char* const xmlFeaturesList[] = {
"validate",
"load subset",
"keep blanks",
@ -1337,7 +1337,6 @@ cdataBlock(void *ctx, const xmlChar * value, int len)
DEPRECATED("cdataBlock")
xmlSAX2CDataBlock(ctx, value, len);
}
#define bottom_legacy
#include "elfgcchack.h"
#endif /* LIBXML_LEGACY_ENABLED */

View file

@ -22,17 +22,6 @@
#endif
#endif
#if defined(macintosh)
#include "config-mac.h"
#elif defined(_WIN32_WCE)
/*
* Windows CE compatibility definitions and functions
* This is needed to compile libxml2 for Windows CE.
* At least I tested it with WinCE 5.0 for Emulator and WinCE 4.2/SH4 target
*/
#include <win32config.h>
#include <libxml/xmlversion.h>
#else
/*
* Currently supported platforms use either autoconf or
* copy to config.h own "preset" configuration file.
@ -40,9 +29,12 @@
*/
#include "config.h"
#include <libxml/xmlversion.h>
#endif
#include <libxml/xmlstring.h>
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif
#if defined(__Lynx__)
#include <stdio.h> /* pull definition of size_t */
#include <varargs.h>
@ -110,27 +102,14 @@ void __xmlGlobalInitMutexDestroy(void);
int __xmlInitializeDict(void);
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
/*
* internal thread safe random function
*/
int __xmlRandom(void);
#endif
XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg);
int xmlInputReadCallbackNop(void *context, char *buffer, int len);
#ifdef IN_LIBXML
#ifdef __GNUC__
#ifdef PIC
#ifdef __linux__
#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
#include "elfgcchack.h"
#endif
#endif
#endif
#endif
#endif
#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
# define LIBXML_STATIC
#endif

View file

@ -775,5 +775,3 @@ xmlListCopy(xmlListPtr cur, const xmlListPtr old)
}
/* xmlListUnique() */
/* xmlListSwap */
#define bottom_list
#include "elfgcchack.h"

View file

@ -6,7 +6,6 @@
#ifdef TESTING
#define STANDALONE
#define HAVE_STDLIB_H
#define HAVE_UNISTD_H
#define HAVE_SYS_SOCKET_H
#define HAVE_NETINET_IN_H
@ -19,10 +18,9 @@
#ifdef LIBXML_FTP_ENABLED
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -41,9 +39,6 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@ -56,9 +51,6 @@
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
@ -75,7 +67,7 @@
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
#include <wsockcompat.h>
#endif
@ -2114,5 +2106,3 @@ int main(int argc, char **argv) {
}
#endif /* STANDALONE */
#endif /* LIBXML_FTP_ENABLED */
#define bottom_nanoftp
#include "elfgcchack.h"

View file

@ -16,10 +16,9 @@
#ifdef LIBXML_HTTP_ENABLED
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -47,9 +46,6 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@ -60,9 +56,6 @@
#else
#include <poll.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
@ -73,7 +66,7 @@
#define XML_SOCKLEN_T unsigned int
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
#include <wsockcompat.h>
#endif
@ -1895,5 +1888,3 @@ int main(int argc, char **argv) {
}
#endif /* STANDALONE */
#endif /* LIBXML_HTTP_ENABLED */
#define bottom_nanohttp
#include "elfgcchack.h"

View file

@ -38,7 +38,7 @@
#define IN_LIBXML
#include "libxml.h"
#if defined(_WIN32) && !defined (__CYGWIN__)
#if defined(_WIN32)
#define XML_DIR_SEP '\\'
#else
#define XML_DIR_SEP '/'
@ -49,6 +49,8 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
@ -68,21 +70,6 @@
#include <libxml/xmlschemastypes.h>
#include <libxml/relaxng.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "buf.h"
#include "enc.h"
@ -302,7 +289,7 @@ unsigned int xmlParserMaxDepth = 256;
* List of XML prefixed PI allowed by W3C specs
*/
static const char *xmlW3CPIs[] = {
static const char* const xmlW3CPIs[] = {
"xml-stylesheet",
"xml-model",
NULL
@ -1104,6 +1091,10 @@ xmlHasFeature(xmlFeature feature)
static void
xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
xmlSAXHandlerPtr sax;
/* Avoid unused variable warning if features are disabled. */
(void) sax;
if (ctxt == NULL) return;
sax = ctxt->sax;
#ifdef LIBXML_SAX1_ENABLED
@ -1761,9 +1752,7 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
sizeof(ctxt->inputTab[0]));
if (ctxt->inputTab == NULL) {
xmlErrMemory(ctxt, NULL);
xmlFreeInputStream(value);
ctxt->inputMax /= 2;
value = NULL;
return (-1);
}
}
@ -2176,6 +2165,9 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyCharMultiByte(&b[i],v)
#define CUR_CONSUMED \
(ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))
/**
* xmlSkipBlankChars:
* @ctxt: the XML parser context
@ -6815,12 +6807,12 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
}
SKIP(3);
} else {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
xmlParseMarkupDecl(ctxt);
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
xmlHaltParser(ctxt);
goto error;
@ -7039,8 +7031,8 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
while (((RAW == '<') && (NXT(1) == '?')) ||
((RAW == '<') && (NXT(1) == '!')) ||
(RAW == '%')) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
GROW;
if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
@ -7049,7 +7041,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
xmlParseMarkupDecl(ctxt);
SKIP_BLANKS;
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
break;
}
@ -7240,7 +7232,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
ent->owner = 1;
while (list != NULL) {
list->parent = (xmlNodePtr) ent;
xmlSetTreeDoc(list, ent->doc);
if (list->doc != ent->doc)
xmlSetTreeDoc(list, ent->doc);
if (list->next == NULL)
ent->last = list;
list = list->next;
@ -8079,6 +8072,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
"xmlLoadEntityContent parameter error");
return(-1);
}
xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
input = xmlNewEntityInputStream(ctxt, entity);
if (input == NULL) {
@ -8094,6 +8088,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
*/
if (xmlPushInput(ctxt, input) < 0) {
xmlBufferFree(buf);
xmlFreeInputStream(input);
return(-1);
}
@ -8361,8 +8356,8 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
*/
while (((RAW != ']') || (ctxt->inputNr > baseInputNr)) &&
(ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
SKIP_BLANKS;
xmlParseMarkupDecl(ctxt);
@ -8377,7 +8372,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
xmlParseConditionalSections(ctxt);
}
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseInternalSubset: error detected in Markup declaration\n");
if (ctxt->inputNr > baseInputNr)
@ -8556,8 +8551,8 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
attname = xmlParseAttribute(ctxt, &attvalue);
if ((attname != NULL) && (attvalue != NULL)) {
@ -8622,7 +8617,7 @@ failed:
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"attributes construct error\n");
}
if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
(attname == NULL) && (attvalue == NULL)) {
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseStartTag: problem parsing attributes\n");
@ -9306,8 +9301,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
int len = -1, alloc = 0;
attname = xmlParseAttribute2(ctxt, prefix, localname,
@ -9488,7 +9483,7 @@ next_attr:
"attributes construct error\n");
break;
}
if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
(attname == NULL) && (attvalue == NULL)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseStartTag: problem parsing attributes\n");
@ -9872,8 +9867,8 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
GROW;
while ((RAW != 0) &&
(ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *test = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
const xmlChar *cur = ctxt->input->cur;
/*
@ -9932,7 +9927,7 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
GROW;
SHRINK;
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
xmlHaltParser(ctxt);
@ -10889,8 +10884,6 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
if ((ctxt == NULL) || (ctxt->input == NULL))
return(-1);
xmlDefaultSAXHandlerInit();
xmlDetectSAX2(ctxt);
GROW;
@ -11527,15 +11520,15 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
}
case XML_PARSER_CONTENT: {
const xmlChar *test;
unsigned int cons;
int id;
unsigned long cons;
if ((avail < 2) && (ctxt->inputNr == 1))
goto done;
cur = ctxt->input->cur[0];
next = ctxt->input->cur[1];
test = CUR_PTR;
cons = ctxt->input->consumed;
id = ctxt->input->id;
cons = CUR_CONSUMED;
if ((cur == '<') && (next == '/')) {
ctxt->instate = XML_PARSER_END_TAG;
break;
@ -11616,7 +11609,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->checkIndex = 0;
xmlParseCharData(ctxt, 0);
}
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
xmlHaltParser(ctxt);
@ -13590,7 +13583,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
ctxt->input_id = 2;
ctxt->instate = XML_PARSER_CONTENT;
fake = xmlNewComment(NULL);
fake = xmlNewDocComment(node->doc, NULL);
if (fake == NULL) {
xmlFreeParserCtxt(ctxt);
return(XML_ERR_NO_MEMORY);
@ -14827,6 +14820,8 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->nameNr = 0;
ctxt->name = NULL;
ctxt->nsNr = 0;
DICT_FREE(ctxt->version);
ctxt->version = NULL;
DICT_FREE(ctxt->encoding);
@ -15552,5 +15547,3 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
#define bottom_parser
#include "elfgcchack.h"

View file

@ -10,31 +10,15 @@
#define IN_LIBXML
#include "libxml.h"
#if defined(_WIN32) && !defined (__CYGWIN__)
#if defined(_WIN32)
#define XML_DIR_SEP '\\'
#else
#define XML_DIR_SEP '/'
#endif
#include <string.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
@ -300,7 +284,6 @@ int
xmlParserInputGrow(xmlParserInputPtr in, int len) {
int ret;
size_t indx;
const xmlChar *content;
if ((in == NULL) || (len < 0)) return(-1);
#ifdef DEBUG_INPUT
@ -325,22 +308,8 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
} else
return(0);
/*
* NOTE : in->base may be a "dangling" i.e. freed pointer in this
* block, but we use it really as an integer to do some
* pointer arithmetic. Insure will raise it as a bug but in
* that specific case, that's not !
*/
content = xmlBufContent(in->buf->buffer);
if (in->base != content) {
/*
* the buffer has been reallocated
*/
indx = in->cur - in->base;
in->base = content;
in->cur = &content[indx];
}
in->base = xmlBufContent(in->buf->buffer);
in->cur = in->base + indx;
in->end = xmlBufEnd(in->buf->buffer);
CHECK_BUFFER(in);
@ -358,8 +327,6 @@ void
xmlParserInputShrink(xmlParserInputPtr in) {
size_t used;
size_t ret;
size_t indx;
const xmlChar *content;
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
@ -372,7 +339,7 @@ xmlParserInputShrink(xmlParserInputPtr in) {
CHECK_BUFFER(in);
used = in->cur - xmlBufContent(in->buf->buffer);
used = in->cur - in->base;
/*
* Do not shrink on large buffers whose only a tiny fraction
* was consumed
@ -380,27 +347,17 @@ xmlParserInputShrink(xmlParserInputPtr in) {
if (used > INPUT_CHUNK) {
ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
if (ret > 0) {
in->cur -= ret;
used -= ret;
in->consumed += ret;
}
in->end = xmlBufEnd(in->buf->buffer);
}
CHECK_BUFFER(in);
if (xmlBufUse(in->buf->buffer) <= INPUT_CHUNK) {
xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
}
if (xmlBufUse(in->buf->buffer) > INPUT_CHUNK) {
return;
}
xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
content = xmlBufContent(in->buf->buffer);
if (in->base != content) {
/*
* the buffer has been reallocated
*/
indx = in->cur - in->base;
in->base = content;
in->cur = &content[indx];
}
in->base = xmlBufContent(in->buf->buffer);
in->cur = in->base + used;
in->end = xmlBufEnd(in->buf->buffer);
CHECK_BUFFER(in);
@ -909,9 +866,6 @@ xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
************************************************************************/
static int
xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
xmlCharEncodingHandlerPtr handler, int len);
static int
xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler, int len);
/**
@ -1011,55 +965,7 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
/* default encoding, no conversion should be needed */
ctxt->charset = XML_CHAR_ENCODING_UTF8;
return(0);
case XML_CHAR_ENCODING_UTF16LE:
break;
case XML_CHAR_ENCODING_UTF16BE:
break;
case XML_CHAR_ENCODING_UCS4LE:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "USC4 little endian", NULL);
break;
case XML_CHAR_ENCODING_UCS4BE:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "USC4 big endian", NULL);
break;
case XML_CHAR_ENCODING_EBCDIC:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "EBCDIC", NULL);
break;
case XML_CHAR_ENCODING_UCS4_2143:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "UCS4 2143", NULL);
break;
case XML_CHAR_ENCODING_UCS4_3412:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "UCS4 3412", NULL);
break;
case XML_CHAR_ENCODING_UCS2:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "UCS2", NULL);
break;
case XML_CHAR_ENCODING_8859_1:
case XML_CHAR_ENCODING_8859_2:
case XML_CHAR_ENCODING_8859_3:
case XML_CHAR_ENCODING_8859_4:
case XML_CHAR_ENCODING_8859_5:
case XML_CHAR_ENCODING_8859_6:
case XML_CHAR_ENCODING_8859_7:
case XML_CHAR_ENCODING_8859_8:
case XML_CHAR_ENCODING_8859_9:
/*
* We used to keep the internal content in the
* document encoding however this turns being unmaintainable
* So xmlGetCharEncodingHandler() will return non-null
* values for this now.
*/
if ((ctxt->inputNr == 1) &&
(ctxt->encoding == NULL) &&
(ctxt->input != NULL) &&
@ -1068,36 +974,20 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
}
ctxt->charset = enc;
return(0);
case XML_CHAR_ENCODING_2022_JP:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "ISO-2022-JP", NULL);
break;
case XML_CHAR_ENCODING_SHIFT_JIS:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "Shift_JIS", NULL);
break;
case XML_CHAR_ENCODING_EUC_JP:
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported %s\n",
BAD_CAST "EUC-JP", NULL);
break;
default:
break;
}
__xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"encoding not supported: %s\n",
BAD_CAST xmlGetCharEncodingName(enc), NULL);
/*
* TODO: We could recover from errors in external entities
* if we didn't stop the parser. But most callers of this
* function don't check the return value.
*/
xmlStopParser(ctxt);
return(-1);
}
}
/*
* TODO: We could recover from errors in external entities if we
* didn't stop the parser. But most callers of this function don't
* check the return value.
*/
if (handler == NULL) {
xmlStopParser(ctxt);
return(-1);
}
ctxt->charset = XML_CHAR_ENCODING_UTF8;
ret = xmlSwitchToEncodingInt(ctxt, handler, len);
ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
/*
* on encoding conversion errors, stop the parser
@ -1109,7 +999,7 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
}
/**
* xmlSwitchInputEncoding:
* xmlSwitchInputEncodingInt:
* @ctxt: the parser context
* @input: the input stream
* @handler: the encoding handler
@ -1131,6 +1021,8 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
if (input == NULL)
return (-1);
if (input->buf != NULL) {
ctxt->charset = XML_CHAR_ENCODING_UTF8;
if (input->buf->encoder != NULL) {
/*
* Check in case the auto encoding detection triggered
@ -1234,12 +1126,9 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
}
return (0);
} else if (input->length == 0) {
/*
* When parsing a static memory array one must know the
* size to be able to convert the buffer.
*/
xmlErrInternal(ctxt, "switching encoding : no input\n", NULL);
} else {
xmlErrInternal(ctxt,
"static memory buffer doesn't support encoding\n", NULL);
/*
* Callers assume that the input buffer takes ownership of the
* encoding handler. xmlCharEncCloseFunc frees unregistered
@ -1248,11 +1137,6 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
xmlCharEncCloseFunc(handler);
return (-1);
}
/*
* We should actually raise an error here, see issue #34.
*/
xmlCharEncCloseFunc(handler);
return (0);
}
/**
@ -1261,6 +1145,8 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* @input: the input stream
* @handler: the encoding handler
*
* DEPRECATED: Use xmlSwitchToEncoding
*
* change the input functions when discovering the character encoding
* of a given entity.
*
@ -1272,41 +1158,6 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
return(xmlSwitchInputEncodingInt(ctxt, input, handler, -1));
}
/**
* xmlSwitchToEncodingInt:
* @ctxt: the parser context
* @handler: the encoding handler
* @len: the length to convert or -1
*
* change the input functions when discovering the character encoding
* of a given entity, and convert only @len bytes of the output, this
* is needed on auto detect to allows any declared encoding later to
* convert the actual content after the xmlDecl
*
* Returns 0 in case of success, -1 otherwise
*/
static int
xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
xmlCharEncodingHandlerPtr handler, int len) {
int ret = 0;
if (handler != NULL) {
if (ctxt->input != NULL) {
ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
} else {
xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
NULL);
return(-1);
}
/*
* The parsing is now done in UTF8 natively
*/
ctxt->charset = XML_CHAR_ENCODING_UTF8;
} else
return(-1);
return(ret);
}
/**
* xmlSwitchToEncoding:
* @ctxt: the parser context
@ -1320,7 +1171,9 @@ xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
int
xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
{
return (xmlSwitchToEncodingInt(ctxt, handler, -1));
if (ctxt == NULL)
return(-1);
return(xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, -1));
}
/************************************************************************
@ -1597,7 +1450,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
return(-1);
}
xmlDefaultSAXHandlerInit();
xmlInitParser();
if (ctxt->dict == NULL)
ctxt->dict = xmlDictCreate();
@ -1733,7 +1586,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->options |= XML_PARSE_NOBLANKS;
}
ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
ctxt->vctxt.flags = XML_VCTXT_USE_PCTXT;
ctxt->vctxt.userData = ctxt;
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.warning = xmlParserValidityWarning;
@ -2162,5 +2015,3 @@ xmlKeepBlanksDefault(int val) {
return(old);
}
#define bottom_parserInternals
#include "elfgcchack.h"

View file

@ -516,9 +516,6 @@ restart:
goto rollback;
node = node->parent;
if ((node->type == XML_DOCUMENT_NODE) ||
#ifdef LIBXML_DOCB_ENABLED
(node->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(node->type == XML_HTML_DOCUMENT_NODE))
continue;
goto rollback;
@ -548,9 +545,6 @@ restart:
if ((node->type != XML_ELEMENT_NODE) &&
(node->type != XML_DOCUMENT_NODE) &&
#ifdef LIBXML_DOCB_ENABLED
(node->type != XML_DOCB_DOCUMENT_NODE) &&
#endif
(node->type != XML_HTML_DOCUMENT_NODE))
goto rollback;
@ -590,9 +584,6 @@ restart:
case XML_OP_PARENT:
if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE) ||
#ifdef LIBXML_DOCB_ENABLED
(node->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(node->type == XML_NAMESPACE_DECL))
goto rollback;
node = node->parent;
@ -631,9 +622,6 @@ restart:
goto rollback;
if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE) ||
#ifdef LIBXML_DOCB_ENABLED
(node->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(node->type == XML_NAMESPACE_DECL))
goto rollback;
node = node->parent;
@ -2616,6 +2604,4 @@ xmlPatternFromRoot(xmlPatternPtr comp) {
}
#define bottom_pattern
#include "elfgcchack.h"
#endif /* LIBXML_PATTERN_ENABLED */

View file

@ -2849,6 +2849,11 @@ xmlRelaxNGInitTypes(void)
/**
* xmlRelaxNGCleanupTypes:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the default Schemas type library associated to RelaxNG
*/
void
@ -7228,7 +7233,7 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
BAD_CAST "name", NULL);
if (node != NULL) {
xmlAddPrevSibling(cur->children, node);
text = xmlNewText(name);
text = xmlNewDocText(node->doc, name);
xmlAddChild(node, text);
text = node;
}
@ -11098,6 +11103,4 @@ xmlRelaxNGValidateDoc(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc)
return (ret);
}
#define bottom_relaxng
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */

File diff suppressed because it is too large Load diff

View file

@ -11,19 +11,11 @@
#include "libxml.h"
#include <string.h>
#include <stdlib.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#elif defined HAVE_WIN32_THREADS
@ -93,7 +85,7 @@ struct _xmlMutex {
#ifdef HAVE_PTHREAD_H
pthread_mutex_t lock;
#elif defined HAVE_WIN32_THREADS
HANDLE mutex;
CRITICAL_SECTION cs;
#elif defined HAVE_BEOS_THREADS
sem_id sem;
thread_id tid;
@ -114,7 +106,6 @@ struct _xmlRMutex {
pthread_cond_t cv;
#elif defined HAVE_WIN32_THREADS
CRITICAL_SECTION cs;
unsigned int count;
#elif defined HAVE_BEOS_THREADS
xmlMutexPtr lock;
thread_id tid;
@ -184,7 +175,7 @@ xmlNewMutex(void)
if (libxml_is_threaded != 0)
pthread_mutex_init(&tok->lock, NULL);
#elif defined HAVE_WIN32_THREADS
tok->mutex = CreateMutex(NULL, FALSE, NULL);
InitializeCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
free(tok);
@ -212,7 +203,7 @@ xmlFreeMutex(xmlMutexPtr tok)
if (libxml_is_threaded != 0)
pthread_mutex_destroy(&tok->lock);
#elif defined HAVE_WIN32_THREADS
CloseHandle(tok->mutex);
DeleteCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
delete_sem(tok->sem);
#endif
@ -234,7 +225,7 @@ xmlMutexLock(xmlMutexPtr tok)
if (libxml_is_threaded != 0)
pthread_mutex_lock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
WaitForSingleObject(tok->mutex, INFINITE);
EnterCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
if (acquire_sem(tok->sem) != B_NO_ERROR) {
#ifdef DEBUG_THREADS
@ -262,7 +253,7 @@ xmlMutexUnlock(xmlMutexPtr tok)
if (libxml_is_threaded != 0)
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
ReleaseMutex(tok->mutex);
LeaveCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
if (tok->tid == find_thread(NULL)) {
tok->tid = -1;
@ -297,7 +288,6 @@ xmlNewRMutex(void)
}
#elif defined HAVE_WIN32_THREADS
InitializeCriticalSection(&tok->cs);
tok->count = 0;
#elif defined HAVE_BEOS_THREADS
if ((tok->lock = xmlNewMutex()) == NULL) {
free(tok);
@ -366,7 +356,6 @@ xmlRMutexLock(xmlRMutexPtr tok)
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
EnterCriticalSection(&tok->cs);
tok->count++;
#elif defined HAVE_BEOS_THREADS
if (tok->lock->tid == find_thread(NULL)) {
tok->count++;
@ -402,10 +391,7 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
}
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
if (tok->count > 0) {
tok->count--;
LeaveCriticalSection(&tok->cs);
}
LeaveCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
if (tok->lock->tid == find_thread(NULL)) {
tok->count--;
@ -851,6 +837,9 @@ xmlUnlockLibrary(void)
/**
* xmlInitThreads:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* xmlInitThreads() is used to to initialize all the thread related
* data of the libxml2 library.
*/
@ -891,6 +880,11 @@ xmlInitThreads(void)
/**
* xmlCleanupThreads:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* xmlCleanupThreads() is used to to cleanup all the thread related
* data of the libxml2 library once processing has ended.
*
@ -912,8 +906,10 @@ xmlCleanupThreads(void)
if (libxml_is_threaded != 0)
pthread_key_delete(globalkey);
once_control = once_control_init;
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
#elif defined(HAVE_WIN32_THREADS)
#if !defined(HAVE_COMPILER_TLS)
if (globalkey != TLS_OUT_OF_INDEXES) {
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
xmlGlobalStateCleanupHelperParams *p;
EnterCriticalSection(&cleanup_helpers_cs);
@ -927,11 +923,17 @@ xmlCleanupThreads(void)
}
cleanup_helpers_head = 0;
LeaveCriticalSection(&cleanup_helpers_cs);
#endif
TlsFree(globalkey);
globalkey = TLS_OUT_OF_INDEXES;
}
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
DeleteCriticalSection(&cleanup_helpers_cs);
#endif
#endif
run_once.done = 0;
run_once.control = 0;
#endif
}
#ifdef LIBXML_THREAD_ENABLED
@ -1045,5 +1047,3 @@ DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
return TRUE;
}
#endif
#define bottom_threads
#include "elfgcchack.h"

View file

@ -21,12 +21,9 @@
#include <string.h> /* for memset() only ! */
#include <stddef.h>
#include <limits.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
@ -358,7 +355,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) || defined(LIBXML_LEGACY_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_LEGACY_ENABLED)
/**
* xmlValidateNCName:
* @value: the value to check
@ -1287,7 +1284,7 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
buf = xmlBufCreateSize(0);
if (buf == NULL) return(NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
q = cur;
while ((cur < end) && (*cur != 0)) {
@ -1508,7 +1505,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
buf = xmlBufCreateSize(0);
if (buf == NULL) return(NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
q = cur;
while (*cur != 0) {
@ -2224,7 +2221,8 @@ xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) {
* @content: the PI content
*
* Creation of a processing instruction element.
* Use xmlDocNewPI preferably to get string interning
*
* Use of this function is DISCOURAGED in favor of xmlNewDocPI.
*
* Returns a pointer to the new node object.
*/
@ -2240,6 +2238,8 @@ xmlNewPI(const xmlChar *name, const xmlChar *content) {
*
* Creation of a new node element. @ns is optional (NULL).
*
* Use of this function is DISCOURAGED in favor of xmlNewDocNode.
*
* Returns a pointer to the new node object. Uses xmlStrdup() to make
* copy of @name.
*/
@ -2281,6 +2281,8 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
*
* Creation of a new node element. @ns is optional (NULL).
*
* Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName.
*
* Returns a pointer to the new node object, with pointer @name as
* new node's name. Use xmlNewNode() if a copy of @name string is
* is needed as new node's name.
@ -2455,6 +2457,9 @@ xmlNewDocFragment(xmlDocPtr doc) {
* @content: the text content
*
* Creation of a new text node.
*
* Use of this function is DISCOURAGED in favor of xmlNewDocText.
*
* Returns a pointer to the new node object.
*/
xmlNodePtr
@ -2685,6 +2690,8 @@ xmlNewDocText(const xmlDoc *doc, const xmlChar *content) {
* @content: the text content
* @len: the text len.
*
* Use of this function is DISCOURAGED in favor of xmlNewDocTextLen.
*
* Creation of a new text node with an extra parameter for the content's length
* Returns a pointer to the new node object.
*/
@ -2736,6 +2743,8 @@ xmlNewDocTextLen(xmlDocPtr doc, const xmlChar *content, int len) {
* xmlNewComment:
* @content: the comment content
*
* Use of this function is DISCOURAGED in favor of xmlNewDocComment.
*
* Creation of a new node containing a comment.
* Returns a pointer to the new node object.
*/
@ -2815,6 +2824,20 @@ xmlNewDocComment(xmlDocPtr doc, const xmlChar *content) {
return(cur);
}
static const xmlChar *_copyStringForNewDictIfNeeded(xmlDictPtr oldDict, xmlDictPtr newDict, const xmlChar *oldValue) {
const xmlChar *newValue = oldValue;
if (oldValue) {
int oldDictOwnsOldValue = oldDict && (xmlDictOwns(oldDict, oldValue) == 1);
if (oldDictOwnsOldValue) {
if (newDict)
newValue = xmlDictLookup(newDict, oldValue, -1);
else
newValue = xmlStrdup(oldValue);
}
}
return newValue;
}
/**
* xmlSetTreeDoc:
* @tree: the top element
@ -2829,6 +2852,9 @@ xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
return;
if (tree->doc != doc) {
xmlDictPtr oldTreeDict = tree->doc ? tree->doc->dict : NULL;
xmlDictPtr newDict = doc ? doc->dict : NULL;
if(tree->type == XML_ELEMENT_NODE) {
prop = tree->properties;
while (prop != NULL) {
@ -2836,7 +2862,11 @@ xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
xmlRemoveID(tree->doc, prop);
}
prop->doc = doc;
if (prop->doc != doc) {
xmlDictPtr oldPropDict = prop->doc ? prop->doc->dict : NULL;
prop->name = _copyStringForNewDictIfNeeded(oldPropDict, newDict, prop->name);
prop->doc = doc;
}
xmlSetListDoc(prop->children, doc);
/*
@ -2865,6 +2895,10 @@ xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
} else if (tree->children != NULL) {
xmlSetListDoc(tree->children, doc);
}
tree->name = _copyStringForNewDictIfNeeded(oldTreeDict, newDict, tree->name);
tree->content = (xmlChar *)_copyStringForNewDictIfNeeded(oldTreeDict, NULL, tree->content);
/* FIXME: tree->ns should be updated as in xmlStaticCopyNode(). */
tree->doc = doc;
}
}
@ -2981,6 +3015,8 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
* When inserting after @cur, @prev is passed as @cur.
* If an existing attribute is found it is destroyed prior to adding @prop.
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the attribute being inserted or NULL in case of error.
*/
static xmlNodePtr
@ -3033,6 +3069,8 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
* If the new node is ATTRIBUTE, it is added into properties instead of children.
* If there is an attribute with equal name, it is first destroyed.
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the new node or NULL in case of error.
*/
xmlNodePtr
@ -3111,6 +3149,8 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
* If the new node is ATTRIBUTE, it is added into properties instead of children.
* If there is an attribute with equal name, it is first destroyed.
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the new node or NULL in case of error.
*/
xmlNodePtr
@ -3187,6 +3227,8 @@ xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
* If the new element was already inserted in a document it is
* first unlinked from its existing context.
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the new element or NULL in case of error.
*/
xmlNodePtr
@ -3263,6 +3305,8 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
* Add a list of node at the end of the child list of the parent
* merging adjacent TEXT nodes (@cur may be freed)
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the last child or NULL in case of error.
*/
xmlNodePtr
@ -3349,6 +3393,12 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
* If the new node is ATTRIBUTE, it is added into properties instead of children.
* If there is an attribute with equal name, it is first destroyed.
*
* All tree manipulation functions can safely move nodes within a document.
* But when moving nodes from one document to another, references to
* namespaces in element or attribute nodes are NOT fixed. In this case,
* you MUST call xmlReconciliateNs after the move operation to avoid
* memory errors.
*
* Returns the child or NULL in case of error.
*/
xmlNodePtr
@ -3706,9 +3756,6 @@ xmlFreeNodeList(xmlNodePtr cur) {
while (1) {
while ((cur->children != NULL) &&
(cur->type != XML_DOCUMENT_NODE) &&
#ifdef LIBXML_DOCB_ENABLED
(cur->type != XML_DOCB_DOCUMENT_NODE) &&
#endif
(cur->type != XML_HTML_DOCUMENT_NODE) &&
(cur->type != XML_DTD_NODE) &&
(cur->type != XML_ENTITY_REF_NODE)) {
@ -3719,9 +3766,6 @@ xmlFreeNodeList(xmlNodePtr cur) {
next = cur->next;
parent = cur->parent;
if ((cur->type == XML_DOCUMENT_NODE) ||
#ifdef LIBXML_DOCB_ENABLED
(cur->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(cur->type == XML_HTML_DOCUMENT_NODE)) {
xmlFreeDoc((xmlDocPtr) cur);
} else if (cur->type != XML_DTD_NODE) {
@ -3812,18 +3856,18 @@ xmlFreeNode(xmlNodePtr cur) {
if ((cur->children != NULL) &&
(cur->type != XML_ENTITY_REF_NODE))
xmlFreeNodeList(cur->children);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->properties != NULL))
xmlFreePropList(cur->properties);
if ((cur->type != XML_ELEMENT_NODE) &&
(cur->content != NULL) &&
(cur->type != XML_ENTITY_REF_NODE) &&
(cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_XINCLUDE_START) &&
(cur->content != (xmlChar *) &(cur->properties))) {
DICT_FREE(cur->content)
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) {
if (cur->properties != NULL)
xmlFreePropList(cur->properties);
if (cur->nsDef != NULL)
xmlFreeNsList(cur->nsDef);
} else if ((cur->content != NULL) &&
(cur->type != XML_ENTITY_REF_NODE) &&
(cur->content != (xmlChar *) &(cur->properties))) {
DICT_FREE(cur->content)
}
/*
@ -3836,11 +3880,6 @@ xmlFreeNode(xmlNodePtr cur) {
(cur->type != XML_COMMENT_NODE))
DICT_FREE(cur->name)
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->nsDef != NULL))
xmlFreeNsList(cur->nsDef);
xmlFree(cur);
}
@ -3928,6 +3967,8 @@ xmlUnlinkNode(xmlNodePtr cur) {
* at the same place. If @cur was already inserted in a document it is
* first unlinked from its existing context.
*
* See the note regarding namespaces in xmlAddChild.
*
* Returns the @old node
*/
xmlNodePtr
@ -4238,9 +4279,6 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
#ifdef LIBXML_TREE_ENABLED
return((xmlNodePtr) xmlCopyDoc((xmlDocPtr) node, extended));
#endif /* LIBXML_TREE_ENABLED */
@ -4299,6 +4337,14 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
/*
* Note that since ret->parent is already set, xmlAddChild will
* return early and not actually insert the node. It will only
* coalesce text nodes and unnecessarily call xmlSetTreeDoc.
* Assuming that the subtree to be copied always has its text
* nodes coalesced, the somewhat confusing call to xmlAddChild
* could be removed.
*/
tmp = xmlAddChild(parent, ret);
/* node could have coalesced */
if (tmp != ret)
@ -4354,8 +4400,49 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
}
ret->last = ret->children;
} else if ((node->children != NULL) && (extended != 2)) {
ret->children = xmlStaticCopyNodeList(node->children, doc, ret);
UPDATE_LAST_CHILD_AND_PARENT(ret)
xmlNodePtr cur, insert;
cur = node->children;
insert = ret;
while (cur != NULL) {
xmlNodePtr copy = xmlStaticCopyNode(cur, doc, insert, 2);
if (copy == NULL) {
xmlFreeNode(ret);
return(NULL);
}
/* Check for coalesced text nodes */
if (insert->last != copy) {
if (insert->last == NULL) {
insert->children = copy;
} else {
copy->prev = insert->last;
insert->last->next = copy;
}
insert->last = copy;
}
if ((cur->type != XML_ENTITY_REF_NODE) &&
(cur->children != NULL)) {
cur = cur->children;
insert = copy;
continue;
}
while (1) {
if (cur->next != NULL) {
cur = cur->next;
break;
}
cur = cur->parent;
insert = insert->parent;
if (cur == node) {
cur = NULL;
break;
}
}
}
}
out:
@ -5040,9 +5127,6 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_NAMESPACE_DECL:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return;
@ -5116,9 +5200,6 @@ xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return;
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
@ -5199,9 +5280,6 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return;
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
@ -5272,9 +5350,6 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
case XML_ATTRIBUTE_NODE:
break;
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE: {
xmlDocPtr doc = (xmlDocPtr) cur;
@ -5536,9 +5611,6 @@ xmlBufGetNodeContent(xmlBufPtr buf, const xmlNode *cur)
case XML_XINCLUDE_END:
break;
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
cur = cur->children;
while (cur!= NULL) {
@ -5586,6 +5658,7 @@ xmlNodeGetContent(const xmlNode *cur)
buf = xmlBufCreateSize(64);
if (buf == NULL)
return (NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
xmlBufGetNodeContent(buf, cur);
ret = xmlBufDetach(buf);
xmlBufFree(buf);
@ -5611,6 +5684,7 @@ xmlNodeGetContent(const xmlNode *cur)
buf = xmlBufCreate();
if (buf == NULL)
return (NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
xmlBufGetNodeContent(buf, cur);
@ -5626,9 +5700,6 @@ xmlNodeGetContent(const xmlNode *cur)
case XML_XINCLUDE_END:
return (NULL);
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE: {
xmlBufPtr buf;
xmlChar *ret;
@ -5636,6 +5707,7 @@ xmlNodeGetContent(const xmlNode *cur)
buf = xmlBufCreate();
if (buf == NULL)
return (NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
xmlBufGetNodeContent(buf, (xmlNodePtr) cur);
@ -5713,16 +5785,12 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
} else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
break;
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
break;
case XML_NOTATION_NODE:
break;
@ -5791,7 +5859,6 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
} else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
break;
case XML_DOCUMENT_NODE:
case XML_DTD_NODE:
@ -5800,9 +5867,6 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
break;
case XML_ELEMENT_DECL:
/* TODO !!! */
@ -5844,7 +5908,7 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
xmlNodePtr last, newNode, tmp;
last = cur->last;
newNode = xmlNewTextLen(content, len);
newNode = xmlNewDocTextLen(cur->doc, content, len);
if (newNode != NULL) {
tmp = xmlAddChild(cur, newNode);
if (tmp != newNode)
@ -5870,11 +5934,11 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
xmlDictOwns(cur->doc->dict, cur->content))) {
cur->content = xmlStrncatNew(cur->content, content, len);
cur->properties = NULL;
cur->nsDef = NULL;
break;
}
cur->content = xmlStrncat(cur->content, content, len);
} else {
cur->content = xmlStrncat(cur->content, content, len);
}
}
break;
case XML_DOCUMENT_NODE:
case XML_DTD_NODE:
case XML_HTML_DOCUMENT_NODE:
@ -5882,9 +5946,6 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
break;
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
@ -6534,6 +6595,9 @@ xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name,
{
xmlAttrPtr prop;
/* Avoid unused variable warning if features are disabled. */
(void) useDTD;
if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL))
return(NULL);
@ -7330,8 +7394,10 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
if (len < buf->size - buf->use)
return(0);
if (len > UINT_MAX - buf->use)
if (len >= UINT_MAX - buf->use) {
xmlTreeErrMemory("growing buffer past UINT_MAX");
return(-1);
}
if (buf->size > (size_t) len) {
size = buf->size > UINT_MAX / 2 ? UINT_MAX : buf->size * 2;
@ -7359,7 +7425,7 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
buf->content = newbuf;
}
buf->size = size;
return(buf->size - buf->use);
return(buf->size - buf->use - 1);
}
/**
@ -7372,7 +7438,7 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
*/
int
xmlBufferDump(FILE *file, xmlBufferPtr buf) {
int ret;
size_t ret;
if (buf == NULL) {
#ifdef DEBUG_BUFFER
@ -7391,7 +7457,7 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
if (file == NULL)
file = stdout;
ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
return(ret);
return(ret > INT_MAX ? INT_MAX : (int)ret);
}
/**
@ -7456,7 +7522,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
return 1;
if (size > UINT_MAX - 10) {
xmlTreeErrMemory("growing buffer");
xmlTreeErrMemory("growing buffer past UINT_MAX");
return 0;
}
@ -7478,7 +7544,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
}
break;
case XML_BUFFER_ALLOC_EXACT:
newSize = (size > UINT_MAX - 10 ? UINT_MAX : size + 10);;
newSize = (size > UINT_MAX - 10 ? UINT_MAX : size + 10);
break;
case XML_BUFFER_ALLOC_HYBRID:
if (buf->use < BASE_BUFFER_SIZE)
@ -7496,7 +7562,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
break;
default:
newSize = (size > UINT_MAX - 10 ? UINT_MAX : size + 10);;
newSize = (size > UINT_MAX - 10 ? UINT_MAX : size + 10);
break;
}
@ -7521,6 +7587,8 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
} else {
if (buf->content == NULL) {
rebuf = (xmlChar *) xmlMallocAtomic(newSize);
buf->use = 0;
rebuf[buf->use] = 0;
} else if (buf->size - buf->use < 100) {
rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
} else {
@ -7582,9 +7650,12 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
if (len < 0) return -1;
if (len == 0) return 0;
/* Note that both buf->size and buf->use can be zero here. */
if ((unsigned) len >= buf->size - buf->use) {
if ((unsigned) len >= UINT_MAX - buf->use)
if ((unsigned) len >= UINT_MAX - buf->use) {
xmlTreeErrMemory("growing buffer past UINT_MAX");
return XML_ERR_NO_MEMORY;
}
needSize = buf->use + len + 1;
if (!xmlBufferResize(buf, needSize)){
xmlTreeErrMemory("growing buffer");
@ -7649,11 +7720,17 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
memmove(&buf->content[0], str, len);
buf->use += len;
buf->size += len;
buf->content[buf->use] = 0;
return(0);
}
}
needSize = buf->use + len + 2;
if (needSize > buf->size){
/* Note that both buf->size and buf->use can be zero here. */
if ((unsigned) len >= buf->size - buf->use) {
if ((unsigned) len >= UINT_MAX - buf->use) {
xmlTreeErrMemory("growing buffer past UINT_MAX");
return(-1);
}
needSize = buf->use + len + 1;
if (!xmlBufferResize(buf, needSize)){
xmlTreeErrMemory("growing buffer");
return XML_ERR_NO_MEMORY;
@ -10170,5 +10247,3 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
return (0);
}
#define bottom_tree
#include "elfgcchack.h"

View file

@ -98,10 +98,7 @@
# include <stdarg.h>
#endif
#include <stddef.h>
#if defined( HAVE_ERRNO_H ) || defined( __VMS )
#include <errno.h>
#endif
#ifndef NULL
# define NULL 0

View file

@ -2383,7 +2383,7 @@ xmlCanonicPath(const xmlChar *path)
* For Windows implementations, additional work needs to be done to
* replace backslashes in pathnames with "forward slashes"
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
int len = 0;
char *p = NULL;
#endif
@ -2455,7 +2455,7 @@ xmlCanonicPath(const xmlChar *path)
path_processing:
/* For Windows implementations, replace backslashes with 'forward slashes' */
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
/*
* Create a URI structure
*/
@ -2534,7 +2534,7 @@ xmlPathToURI(const xmlChar *path)
cal = xmlCanonicPath(path);
if (cal == NULL)
return(NULL);
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
/* xmlCanonicPath can return an URI on Windows (is that the intended behaviour?)
If 'cal' is a valid URI already then we are done here, as continuing would make
it invalid. */
@ -2558,5 +2558,3 @@ xmlPathToURI(const xmlChar *path)
xmlFree(cal);
return(ret);
}
#define bottom_uri
#include "elfgcchack.h"

View file

@ -11,10 +11,7 @@
#include "libxml.h"
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/hash.h>
@ -64,10 +61,9 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
/* Use the special values to detect if it is part of a parsing
/* Look up flag to detect if it is part of a parsing
context */
if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
long delta = (char *) ctxt - (char *) ctxt->userData;
if ((delta > 0) && (delta < 250))
pctxt = ctxt->userData;
@ -104,10 +100,9 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
/* Use the special values to detect if it is part of a parsing
/* Look up flag to detect if it is part of a parsing
context */
if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
long delta = (char *) ctxt - (char *) ctxt->userData;
if ((delta > 0) && (delta < 250))
pctxt = ctxt->userData;
@ -151,10 +146,9 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt,
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
/* Use the special values to detect if it is part of a parsing
/* Look up flag to detect if it is part of a parsing
context */
if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
long delta = (char *) ctxt - (char *) ctxt->userData;
if ((delta > 0) && (delta < 250))
pctxt = ctxt->userData;
@ -194,10 +188,9 @@ xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
/* Use the special values to detect if it is part of a parsing
/* Look up flag to detect if it is part of a parsing
context */
if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
long delta = (char *) ctxt - (char *) ctxt->userData;
if ((delta > 0) && (delta < 250))
pctxt = ctxt->userData;
@ -235,10 +228,9 @@ xmlErrValidWarning(xmlValidCtxtPtr ctxt,
if (ctxt != NULL) {
channel = ctxt->warning;
data = ctxt->userData;
/* Use the special values to detect if it is part of a parsing
/* Look up flag to detect if it is part of a parsing
context */
if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
long delta = (char *) ctxt - (char *) ctxt->userData;
if ((delta > 0) && (delta < 250))
pctxt = ctxt->userData;
@ -526,11 +518,6 @@ xmlValidPrintNode(xmlNodePtr cur) {
case XML_HTML_DOCUMENT_NODE:
xmlGenericError(xmlGenericErrorContext, "?html? ");
break;
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
xmlGenericError(xmlGenericErrorContext, "?docb? ");
break;
#endif
case XML_DTD_NODE:
xmlGenericError(xmlGenericErrorContext, "?dtd? ");
break;
@ -1614,9 +1601,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
* and flag it by setting a special parent value
* so the parser doesn't unallocate it.
*/
if ((ctxt != NULL) &&
((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
(ctxt->finishDtd == XML_CTXT_FINISH_DTD_1))) {
if ((ctxt != NULL) && (ctxt->flags & XML_VCTXT_USE_PCTXT)) {
ret->content = content;
if (content != NULL)
content->parent = (xmlElementContentPtr) 1;
@ -2643,13 +2628,7 @@ xmlIsStreaming(xmlValidCtxtPtr ctxt) {
if (ctxt == NULL)
return(0);
/*
* These magic values are also abused to detect whether we're validating
* while parsing a document. In this case, userData points to the parser
* context.
*/
if ((ctxt->finishDtd != XML_CTXT_FINISH_DTD_0) &&
(ctxt->finishDtd != XML_CTXT_FINISH_DTD_1))
if ((ctxt->flags & XML_VCTXT_USE_PCTXT) == 0)
return(0);
pctxt = ctxt->userData;
return(pctxt->parseMode == XML_PARSE_READER);
@ -3014,6 +2993,8 @@ xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED,
* @value: the value name
* @attr: the attribute holding the Ref
*
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Register a new ref declaration
*
* Returns NULL if not, otherwise the new xmlRefPtr
@ -3114,6 +3095,8 @@ failed:
* xmlFreeRefTable:
* @table: An ref table
*
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Deallocate the memory used by an Ref hash table.
*/
void
@ -3127,6 +3110,8 @@ xmlFreeRefTable(xmlRefTablePtr table) {
* @elem: the element carrying the attribute
* @attr: the attribute
*
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Determine whether an attribute is of type Ref. In case we have DTD(s)
* then this is simple, otherwise we use an heuristic: name Ref (upper
* or lowercase).
@ -3169,6 +3154,8 @@ xmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
* @doc: the document
* @attr: the attribute
*
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Remove the given attribute from the Ref table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
@ -3225,6 +3212,8 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
* @doc: pointer to the document
* @ID: the ID value
*
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Find the set of references for the supplied ID.
*
* Returns NULL if not found, otherwise node set for the ID.
@ -5290,9 +5279,6 @@ xmlSnprintfElements(char *buf, int size, xmlNodePtr node, int glob) {
break;
case XML_ATTRIBUTE_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
@ -6678,8 +6664,8 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
}
/* trick to get correct line id report */
save = ctxt->finishDtd;
ctxt->finishDtd = 0;
save = ctxt->flags;
ctxt->flags &= ~XML_VCTXT_USE_PCTXT;
/*
* Check all the NOTATION/NOTATIONS attributes
@ -6695,7 +6681,7 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
ctxt->valid = 1;
xmlHashScan(table, xmlValidateCheckRefCallback, ctxt);
ctxt->finishDtd = save;
ctxt->flags = save;
return(ctxt->valid);
}
@ -7157,5 +7143,3 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
}
#endif /* LIBXML_VALID_ENABLED */
#define bottom_valid
#include "elfgcchack.h"

View file

@ -881,6 +881,7 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
return(result);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xmlXIncludeGetNthChild:
* @cur: the node
@ -987,7 +988,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
int len;
if (content == NULL) {
tmp = xmlNewTextLen(NULL, 0);
tmp = xmlNewDocTextLen(target, NULL, 0);
} else {
len = index2;
if ((cur == start) && (index1 > 1)) {
@ -996,7 +997,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
} else {
len = index2;
}
tmp = xmlNewTextLen(content, len);
tmp = xmlNewDocTextLen(target, content, len);
}
/* single sub text node selection */
if (list == NULL)
@ -1047,13 +1048,13 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
const xmlChar *content = cur->content;
if (content == NULL) {
tmp = xmlNewTextLen(NULL, 0);
tmp = xmlNewDocTextLen(target, NULL, 0);
} else {
if (index1 > 1) {
content += (index1 - 1);
index1 = 0;
}
tmp = xmlNewText(content);
tmp = xmlNewDocText(target, content);
}
last = list = tmp;
listParent = cur->parent;
@ -1120,6 +1121,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
}
return(list);
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXIncludeBuildNodeList:
@ -1163,9 +1165,6 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_XINCLUDE_END:
break;
case XML_XINCLUDE_START: {
@ -1221,7 +1220,7 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
}
break;
}
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: {
xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
if (set == NULL)
@ -1243,10 +1242,10 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
}
case XPATH_RANGE:
return(xmlXIncludeCopyRange(ctxt, target, source, obj));
#endif
case XPATH_POINT:
/* points are ignored in XInclude */
break;
#endif
default:
break;
}
@ -1598,7 +1597,9 @@ loaded:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_STRING:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
#endif
case XPATH_USERS:
case XPATH_XSLT_TREE:
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
@ -1620,9 +1621,11 @@ loaded:
return(-1);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_RANGE:
case XPATH_LOCATIONSET:
break;
#endif
}
set = xptr->nodesetval;
if (set != NULL) {
@ -1639,9 +1642,6 @@ loaded:
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
continue;
case XML_ATTRIBUTE_NODE:
@ -1849,7 +1849,7 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
*/
for (i = 0; i < ctxt->txtNr; i++) {
if (xmlStrEqual(URL, ctxt->txturlTab[i])) {
node = xmlNewText(ctxt->txtTab[i]);
node = xmlNewDocText(ctxt->doc, ctxt->txtTab[i]);
goto loaded;
}
}
@ -1898,7 +1898,7 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
if (buf->encoder)
xmlCharEncCloseFunc(buf->encoder);
buf->encoder = xmlGetCharEncodingHandler(enc);
node = xmlNewText(NULL);
node = xmlNewDocText(ctxt->doc, NULL);
/*
* Scan all chars from the resource and add the to the node
@ -2238,6 +2238,9 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlAddPrevSibling(cur, end);
}
/*
* FIXME: xmlUnlinkNode doesn't coalesce text nodes.
*/
xmlUnlinkNode(cur);
xmlFreeNode(cur);
} else {
@ -2652,5 +2655,3 @@ xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
#else /* !LIBXML_XINCLUDE_ENABLED */
#endif
#define bottom_xinclude
#include "elfgcchack.h"

View file

@ -13,24 +13,8 @@
#ifdef LIBXML_XPTR_ENABLED
#include <string.h> /* for memset() only */
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
@ -179,5 +163,3 @@ xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
return(ret);
}
#endif /* LIBXML_XPTR_ENABLED */
#define bottom_xlink
#include "elfgcchack.h"

View file

@ -12,11 +12,8 @@
#include "libxml.h"
#include <string.h>
#include <stddef.h>
#ifdef HAVE_ERRNO_H
#include <stdlib.h>
#include <errno.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -30,9 +27,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
@ -40,17 +34,15 @@
#include <lzma.h>
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
#ifdef __REACTOS__
#include <winnls.h>
#else /* __REACTOS__ */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif /* __REACTOS__ */
#endif
#if defined(_WIN32_WCE)
#include <winnls.h> /* for CP_UTF8 */
#include <io.h>
#include <direct.h>
#endif
#ifndef S_ISDIR
@ -134,7 +126,7 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
* *
************************************************************************/
static const char *IOerr[] = {
static const char* const IOerr[] = {
"Unknown IO error", /* UNKNOWN */
"Permission denied", /* EACCES */
"Resource temporarily unavailable",/* EAGAIN */
@ -194,7 +186,7 @@ static const char *IOerr[] = {
"unknown address family", /* EAFNOSUPPORT */
};
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
/**
* __xmlIOWin32UTF8ToWChar:
* @u8String: uft-8 string
@ -252,7 +244,6 @@ __xmlIOErr(int domain, int code, const char *extra)
unsigned int idx;
if (code == 0) {
#ifdef HAVE_ERRNO_H
if (errno == 0) code = 0;
#ifdef EACCES
else if (errno == EACCES) code = XML_IO_EACCES;
@ -408,7 +399,6 @@ __xmlIOErr(int domain, int code, const char *extra)
else if (errno == EAFNOSUPPORT) code = XML_IO_EAFNOSUPPORT;
#endif
else code = XML_IO_UNKNOWN;
#endif /* HAVE_ERRNO_H */
}
idx = 0;
if (code >= XML_IO_UNKNOWN) idx = code - XML_IO_UNKNOWN;
@ -599,7 +589,7 @@ xmlPopOutputCallbacks(void)
* *
************************************************************************/
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
/**
* xmlWrapOpenUtf8:
@ -700,7 +690,7 @@ int
xmlCheckFilename (const char *path)
{
#ifdef HAVE_STAT
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
struct _stat stat_buffer;
#else
struct stat stat_buffer;
@ -710,7 +700,7 @@ xmlCheckFilename (const char *path)
return(0);
#ifdef HAVE_STAT
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
/*
* On Windows stat and wstat do not work with long pathname,
* which start with '\\?\'
@ -841,20 +831,20 @@ xmlFileOpen_real (const char *filename) {
}
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[17];
#else
path = &filename[16];
#endif
} else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[8];
#else
path = &filename[7];
#endif
} else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:/", 6)) {
/* lots of generators seems to lazy to read RFC 1738 */
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[6];
#else
path = &filename[5];
@ -867,10 +857,10 @@ xmlFileOpen_real (const char *filename) {
return(NULL);
#endif
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
fd = xmlWrapOpenUtf8(path, 0);
#else
fd = fopen(path, "r");
fd = fopen(path, "rb");
#endif /* WIN32 */
if (fd == NULL) xmlIOErr(0, path);
return((void *) fd);
@ -923,13 +913,13 @@ xmlFileOpenW (const char *filename) {
}
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17))
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[17];
#else
path = &filename[16];
#endif
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[8];
#else
path = &filename[7];
@ -940,7 +930,7 @@ xmlFileOpenW (const char *filename) {
if (path == NULL)
return(NULL);
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
fd = xmlWrapOpenUtf8(path, 1);
#elif(__MVS__)
fd = fopen(path, "w");
@ -1113,13 +1103,13 @@ xmlGzfileOpen_real (const char *filename) {
}
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17))
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[17];
#else
path = &filename[16];
#endif
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[8];
#else
path = &filename[7];
@ -1132,7 +1122,7 @@ xmlGzfileOpen_real (const char *filename) {
if (!xmlCheckFilename(path))
return(NULL);
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
fd = xmlWrapGzOpenUtf8(path, "rb");
#else
fd = gzopen(path, "rb");
@ -1144,7 +1134,7 @@ xmlGzfileOpen_real (const char *filename) {
* xmlGzfileOpen:
* @filename: the URI for matching
*
* Wrapper around xmlGzfileOpen if the open fais, it will
* Wrapper around xmlGzfileOpen_real if the open fails, it will
* try to unescape @filename
*/
static void *
@ -1192,13 +1182,13 @@ xmlGzfileOpenW (const char *filename, int compression) {
}
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17))
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[17];
#else
path = &filename[16];
#endif
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &filename[8];
#else
path = &filename[7];
@ -1209,7 +1199,7 @@ xmlGzfileOpenW (const char *filename, int compression) {
if (path == NULL)
return(NULL);
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
#if defined(_WIN32)
fd = xmlWrapGzOpenUtf8(path, mode);
#else
fd = gzopen(path, mode);
@ -2405,10 +2395,7 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
xmlFree(ret);
return(NULL);
}
/* try to avoid a performance problem with Windows realloc() */
if (xmlBufGetAllocationScheme(ret->buffer) == XML_BUFFER_ALLOC_EXACT)
xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
ret->encoder = encoder;
if (encoder != NULL) {
@ -3564,7 +3551,7 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
* how many bytes to consume and how many bytes to store.
*/
cons = len;
chunk = xmlBufAvail(out->buffer) - 1;
chunk = xmlBufAvail(out->buffer);
/*
* make sure we have enough room to save first, if this is
@ -3769,16 +3756,12 @@ xmlParserGetDirectory(const char *filename) {
char dir[1024];
char *cur;
#ifdef _WIN32_WCE /* easy way by now ... wince does not have dirs! */
return NULL;
#endif
if (xmlInputCallbackInitialized == 0)
xmlRegisterDefaultInputCallbacks();
if (filename == NULL) return(NULL);
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
#else
# define IS_XMLPGD_SEP(ch) (ch=='/')
@ -3825,6 +3808,9 @@ xmlParserGetDirectory(const char *filename) {
*/
xmlParserInputPtr
xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
/* Avoid unused variable warning if features are disabled. */
(void) ctxt;
#ifdef LIBXML_HTTP_ENABLED
if ((ret != NULL) && (ret->buf != NULL) &&
(ret->buf->readcallback == xmlIOHTTPRead) &&
@ -3892,13 +3878,13 @@ static int xmlNoNetExists(const char *URL) {
return(0);
if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file://localhost/", 17))
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &URL[17];
#else
path = &URL[16];
#endif
else if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
#if defined (_WIN32)
path = &URL[8];
#else
path = &URL[7];
@ -4137,5 +4123,3 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
return(input);
}
#define bottom_xmlIO
#include "elfgcchack.h"

View file

@ -11,10 +11,7 @@
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
@ -43,7 +40,7 @@ static char *filename = NULL;
#ifndef XML_SGML_DEFAULT_CATALOG
#define XML_SGML_DEFAULT_CATALOG "/etc/sgml/catalog"
#define XML_SGML_DEFAULT_CATALOG SYSCONFDIR "/sgml/catalog"
#endif
/************************************************************************

View file

@ -10,19 +10,16 @@
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#ifdef HAVE_SYS_TIMEB_H
#include <sys/timeb.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@ -42,9 +39,6 @@
#define MAP_FAILED ((void *) -1)
#endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#ifdef HAVE_LIBHISTORY
@ -87,7 +81,7 @@
#endif
#ifndef XML_XML_DEFAULT_CATALOG
#define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog"
#define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog"
#endif
typedef enum {
@ -445,16 +439,13 @@ endTimer(const char *fmt, ...)
msec *= 1000;
msec += (end.tv_usec - begin.tv_usec) / 1000;
#ifndef HAVE_STDARG_H
#error "endTimer required stdarg functions"
#endif
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, " took %ld ms\n", msec);
}
#elif defined(HAVE_TIME_H)
#else
/*
* No gettimeofday function, so we have to make do with calling clock.
* This is obviously less accurate, but there's little we can do about
@ -479,44 +470,11 @@ endTimer(const char *fmt, ...)
end = clock();
msec = ((end - begin) * 1000) / CLOCKS_PER_SEC;
#ifndef HAVE_STDARG_H
#error "endTimer required stdarg functions"
#endif
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, " took %ld ms\n", msec);
}
#else
/*
* We don't have a gettimeofday or time.h, so we just don't do timing
*/
static void
startTimer(void)
{
/*
* Do nothing
*/
}
static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
endTimer(char *format, ...)
{
/*
* We cannot do anything because we don't have a timing function
*/
#ifdef HAVE_STDARG_H
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
fprintf(stderr, " was not timed\n");
#else
/* We don't have gettimeofday, time or stdarg.h, what crazy world is
* this ?!
*/
#endif
}
#endif
/************************************************************************
* *
@ -2202,13 +2160,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if ((filename[0] == '-') && (filename[1] == 0)) {
f = stdin;
} 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
}
if (f != NULL) {
int res;
@ -2276,15 +2228,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
/* '-' Usually means stdin -<sven@zen.org> */
if ((filename[0] == '-') && (filename[1] == 0)) {
f = stdin;
f = stdin;
} 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
}
if (f != NULL) {
int ret;
@ -2327,13 +2273,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} else {
FILE *f;
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
f = fopen(filename, "rb");
#elif defined(__OS400__)
f = fopen(filename, "rb");
#else
f = fopen(filename, "r");
#endif
if (f != NULL) {
if (rectxt == NULL)
doc = xmlReadIO(myRead, myClose, f, filename, NULL,
@ -3846,13 +3786,15 @@ main(int argc, char **argv) {
xmlRelaxNGFree(relaxngschemas);
if (wxschemas != NULL)
xmlSchemaFree(wxschemas);
xmlRelaxNGCleanupTypes();
#endif
#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
if (patternc != NULL)
xmlFreePattern(patternc);
#endif
/* Avoid unused label warning if features are disabled. */
goto error;
error:
xmlCleanupParser();
xmlMemoryDump();

View file

@ -8,26 +8,9 @@
#include "libxml.h"
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#include <time.h>
/* #define DEBUG_MEMORY */
@ -759,11 +742,9 @@ xmlMemDisplay(FILE *fp)
MEMHDR *p;
unsigned idx;
int nb = 0;
#if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
time_t currentTime;
char buf[500];
struct tm * tstruct;
#endif
#endif
FILE *old_fp = fp;
@ -774,12 +755,10 @@ xmlMemDisplay(FILE *fp)
}
#ifdef MEM_LIST
#if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
currentTime = time(NULL);
tstruct = localtime(&currentTime);
strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
fprintf(fp," %s\n\n", buf);
#endif
fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
@ -956,6 +935,9 @@ xmlMemoryDump(void)
/**
* xmlInitMemory:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the memory layer.
*
* Returns 0 on success
@ -963,9 +945,7 @@ xmlMemoryDump(void)
int
xmlInitMemory(void)
{
#ifdef HAVE_STDLIB_H
char *breakpoint;
#endif
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlInitMemory()\n");
@ -978,18 +958,14 @@ xmlInitMemory(void)
xmlMemInitialized = 1;
xmlMemMutex = xmlNewMutex();
#ifdef HAVE_STDLIB_H
breakpoint = getenv("XML_MEM_BREAKPOINT");
if (breakpoint != NULL) {
sscanf(breakpoint, "%ud", &xmlMemStopAtBlock);
}
#endif
#ifdef HAVE_STDLIB_H
breakpoint = getenv("XML_MEM_TRACE");
if (breakpoint != NULL) {
sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
}
#endif
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
@ -1001,6 +977,11 @@ xmlInitMemory(void)
/**
* xmlCleanupMemory:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Free up all the memory allocated by the library for its own
* use. This should not be called by user level code.
*/
@ -1159,5 +1140,3 @@ xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
return(0);
}
#define bottom_xmlmemory
#include "elfgcchack.h"

View file

@ -301,7 +301,7 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
#endif /* HAVE_SHLLOAD */
#endif /* ! HAVE_DLOPEN */
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -341,14 +341,7 @@ static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
XML_IGNORE_PEDANTIC_WARNINGS
#ifdef _WIN32_WCE
/*
* GetProcAddressA seems only available on WinCE
*/
*symbol = GetProcAddressA(handle, name);
#else
*symbol = GetProcAddress(handle, name);
#endif
return (NULL == *symbol) ? -1 : 0;
XML_POP_WARNINGS
}
@ -463,6 +456,4 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
#endif /* HAVE_OS2 */
#define bottom_xmlmodule
#include "elfgcchack.h"
#endif /* LIBXML_MODULES_ENABLED */

View file

@ -20,13 +20,8 @@
#ifdef LIBXML_READER_ENABLED
#include <string.h> /* for memset() only ! */
#include <stdarg.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/xmlIO.h>
@ -228,116 +223,6 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader);
static void xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur);
static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur);
/**
* xmlFreeID:
* @not: A id
*
* Deallocate the memory used by an id definition
*/
static void
xmlFreeID(xmlIDPtr id) {
xmlDictPtr dict = NULL;
if (id == NULL) return;
if (id->doc != NULL)
dict = id->doc->dict;
if (id->value != NULL)
DICT_FREE(id->value)
if (id->name != NULL)
DICT_FREE(id->name)
xmlFree(id);
}
/**
* xmlTextReaderRemoveID:
* @doc: the document
* @attr: the attribute
*
* Remove the given attribute from the ID table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
*/
static int
xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
xmlIDTablePtr table;
xmlIDPtr id;
xmlChar *ID;
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
table = (xmlIDTablePtr) doc->ids;
if (table == NULL)
return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
id = xmlHashLookup(table, ID);
xmlFree(ID);
if (id == NULL || id->attr != attr) {
return(-1);
}
id->name = attr->name;
attr->name = NULL;
id->attr = NULL;
return(0);
}
/**
* xmlTextReaderWalkRemoveRef:
* @data: Contents of current link
* @user: Value supplied by the user
*
* Returns 0 to abort the walk or 1 to continue
*/
static int
xmlTextReaderWalkRemoveRef(const void *data, void *user)
{
xmlRefPtr ref = (xmlRefPtr)data;
xmlAttrPtr attr = (xmlAttrPtr)user;
if (ref->attr == attr) { /* Matched: remove and terminate walk */
ref->name = xmlStrdup(attr->name);
ref->attr = NULL;
return 0;
}
return 1;
}
/**
* xmlTextReaderRemoveRef:
* @doc: the document
* @attr: the attribute
*
* Remove the given attribute from the Ref table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
*/
static int
xmlTextReaderRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
xmlListPtr ref_list;
xmlRefTablePtr table;
xmlChar *ID;
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
table = (xmlRefTablePtr) doc->refs;
if (table == NULL)
return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
ref_list = xmlHashLookup(table, ID);
xmlFree(ID);
if(ref_list == NULL)
return (-1);
xmlListWalk(ref_list, xmlTextReaderWalkRemoveRef, attr);
return(0);
}
/**
* xmlTextReaderFreeProp:
* @reader: the xmlTextReaderPtr used
@ -358,15 +243,6 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
xmlDeregisterNodeDefaultValue((xmlNodePtr) cur);
/* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL)) {
if (xmlIsID(cur->parent->doc, cur->parent, cur))
xmlTextReaderRemoveID(cur->parent->doc, cur);
if (((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL)) &&
(xmlIsRef(cur->parent->doc, cur->parent, cur)))
xmlTextReaderRemoveRef(cur->parent->doc, cur);
}
if (cur->children != NULL)
xmlTextReaderFreeNodeList(reader, cur->children);
@ -570,22 +446,6 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
}
}
static void
xmlTextReaderFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlFreeID((xmlIDPtr) id);
}
/**
* xmlTextReaderFreeIDTable:
* @table: An id table
*
* Deallocate the memory used by an ID hash table.
*/
static void
xmlTextReaderFreeIDTable(xmlIDTablePtr table) {
xmlHashFree(table, xmlTextReaderFreeIDTableEntry);
}
/**
* xmlTextReaderFreeDoc:
* @reader: the xmlTextReaderPtr used
@ -605,7 +465,7 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
/*
* Do this before freeing the children list to avoid ID lookups
*/
if (cur->ids != NULL) xmlTextReaderFreeIDTable((xmlIDTablePtr) cur->ids);
if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
cur->ids = NULL;
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
cur->refs = NULL;
@ -1320,6 +1180,7 @@ xmlTextReaderCollectSiblings(xmlNodePtr node)
buffer = xmlBufferCreate();
if (buffer == NULL)
return NULL;
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
for ( ; node != NULL; node = node->next) {
switch (node->type) {
@ -1524,9 +1385,6 @@ get_next_node:
reader->node = reader->node->parent;
if ((reader->node == NULL) ||
(reader->node->type == XML_DOCUMENT_NODE) ||
#ifdef LIBXML_DOCB_ENABLED
(reader->node->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(reader->node->type == XML_HTML_DOCUMENT_NODE)) {
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
val = xmlParseChunk(reader->ctxt, "", 0, 1);
@ -1776,11 +1634,14 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
buff = xmlBufferCreate();
if (buff == NULL)
return NULL;
xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
for (cur_node = reader->node->children; cur_node != NULL;
cur_node = cur_node->next) {
/* XXX: Why is the node copied? */
node = xmlDocCopyNode(cur_node, doc, 1);
/* XXX: Why do we need a second buffer? */
buff2 = xmlBufferCreate();
xmlBufferSetAllocationScheme(buff2, XML_BUFFER_ALLOC_DOUBLEIT);
if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) {
xmlFreeNode(node);
xmlBufferFree(buff2);
@ -1830,6 +1691,7 @@ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
node = xmlDocCopyNode(node, doc, 1);
}
buff = xmlBufferCreate();
xmlBufferSetAllocationScheme(buff, XML_BUFFER_ALLOC_DOUBLEIT);
if (xmlNodeDump(buff, doc, node, 0, 0) == -1) {
xmlFreeNode(node);
xmlBufferFree(buff);
@ -2160,7 +2022,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
}
/* no operation on a reader should require a huge buffer */
xmlBufSetAllocationScheme(ret->buffer,
XML_BUFFER_ALLOC_BOUNDED);
XML_BUFFER_ALLOC_DOUBLEIT);
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
if (ret->sax == NULL) {
xmlBufFree(ret->buffer);
@ -2319,36 +2181,16 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
xmlFree(reader->patternTab);
}
#endif
if (reader->faketext != NULL) {
xmlFreeNode(reader->faketext);
}
if (reader->mode != XML_TEXTREADER_MODE_CLOSED)
xmlTextReaderClose(reader);
if (reader->ctxt != NULL) {
if (reader->dict == reader->ctxt->dict)
reader->dict = NULL;
#ifdef LIBXML_VALID_ENABLED
if ((reader->ctxt->vctxt.vstateTab != NULL) &&
(reader->ctxt->vctxt.vstateMax > 0)){
#ifdef LIBXML_REGEXP_ENABLED
while (reader->ctxt->vctxt.vstateNr > 0)
xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
#endif /* LIBXML_REGEXP_ENABLED */
xmlFree(reader->ctxt->vctxt.vstateTab);
reader->ctxt->vctxt.vstateTab = NULL;
reader->ctxt->vctxt.vstateMax = 0;
}
#endif /* LIBXML_VALID_ENABLED */
if (reader->ctxt->myDoc != NULL) {
if (reader->preserve == 0)
xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc);
reader->ctxt->myDoc = NULL;
}
if (reader->allocs & XML_TEXTREADER_CTXT)
xmlFreeParserCtxt(reader->ctxt);
}
if (reader->sax != NULL)
xmlFree(reader->sax);
if ((reader->input != NULL) && (reader->allocs & XML_TEXTREADER_INPUT))
xmlFreeParserInputBuffer(reader->input);
if (reader->buffer != NULL)
xmlBufFree(reader->buffer);
if (reader->entTab != NULL)
@ -2379,7 +2221,23 @@ xmlTextReaderClose(xmlTextReaderPtr reader) {
reader->node = NULL;
reader->curnode = NULL;
reader->mode = XML_TEXTREADER_MODE_CLOSED;
if (reader->faketext != NULL) {
xmlFreeNode(reader->faketext);
reader->faketext = NULL;
}
if (reader->ctxt != NULL) {
#ifdef LIBXML_VALID_ENABLED
if ((reader->ctxt->vctxt.vstateTab != NULL) &&
(reader->ctxt->vctxt.vstateMax > 0)){
#ifdef LIBXML_REGEXP_ENABLED
while (reader->ctxt->vctxt.vstateNr > 0)
xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
#endif /* LIBXML_REGEXP_ENABLED */
xmlFree(reader->ctxt->vctxt.vstateTab);
reader->ctxt->vctxt.vstateTab = NULL;
reader->ctxt->vctxt.vstateMax = 0;
}
#endif /* LIBXML_VALID_ENABLED */
xmlStopParser(reader->ctxt);
if (reader->ctxt->myDoc != NULL) {
if (reader->preserve == 0)
@ -3118,9 +2976,6 @@ xmlTextReaderNodeType(xmlTextReaderPtr reader) {
return(XML_READER_TYPE_COMMENT);
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(XML_READER_TYPE_DOCUMENT);
case XML_DOCUMENT_FRAG_NODE:
return(XML_READER_TYPE_DOCUMENT_FRAGMENT);
@ -3275,9 +3130,6 @@ xmlTextReaderName(xmlTextReaderPtr reader) {
return(xmlStrdup(BAD_CAST "#comment"));
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(xmlStrdup(BAD_CAST "#document"));
case XML_DOCUMENT_FRAG_NODE:
return(xmlStrdup(BAD_CAST "#document-fragment"));
@ -3346,9 +3198,6 @@ xmlTextReaderConstName(xmlTextReaderPtr reader) {
return(CONSTSTR(BAD_CAST "#comment"));
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(CONSTSTR(BAD_CAST "#document"));
case XML_DOCUMENT_FRAG_NODE:
return(CONSTSTR(BAD_CAST "#document-fragment"));
@ -3707,7 +3556,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
return (NULL);
}
xmlBufSetAllocationScheme(reader->buffer,
XML_BUFFER_ALLOC_BOUNDED);
XML_BUFFER_ALLOC_DOUBLEIT);
} else
xmlBufEmpty(reader->buffer);
xmlBufGetNodeContent(reader->buffer, node);
@ -3717,7 +3566,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
xmlBufFree(reader->buffer);
reader->buffer = xmlBufCreateSize(100);
xmlBufSetAllocationScheme(reader->buffer,
XML_BUFFER_ALLOC_BOUNDED);
XML_BUFFER_ALLOC_DOUBLEIT);
ret = BAD_CAST "";
}
return(ret);
@ -5231,7 +5080,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
}
/* no operation on a reader should require a huge buffer */
xmlBufSetAllocationScheme(reader->buffer,
XML_BUFFER_ALLOC_BOUNDED);
XML_BUFFER_ALLOC_DOUBLEIT);
if (reader->sax == NULL)
reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
if (reader->sax == NULL) {
@ -6028,6 +5877,5 @@ main(int argc, char **argv)
}
#endif
#endif /* NOT_USED_YET */
#define bottom_xmlreader
#include "elfgcchack.h"
#endif /* LIBXML_READER_ENABLED */

View file

@ -23,12 +23,7 @@
#include <stdio.h>
#include <string.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <libxml/tree.h>
#include <libxml/parserInternals.h>
@ -36,9 +31,6 @@
#include <libxml/xmlautomata.h>
#include <libxml/xmlunicode.h>
#ifndef INT_MAX
#define INT_MAX 123456789 /* easy to flag and big enough for our needs */
#endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t) -1)
#endif
@ -4908,6 +4900,47 @@ xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) {
}
}
static int parse_escaped_codeunit(xmlRegParserCtxtPtr ctxt)
{
int val = 0, i, cur;
for (i = 0; i < 4; i++) {
NEXT;
val *= 16;
cur = CUR;
if (cur >= '0' && cur <= '9') {
val += cur - '0';
} else if (cur >= 'A' && cur <= 'F') {
val += cur - 'A' + 10;
} else if (cur >= 'a' && cur <= 'f') {
val += cur - 'a' + 10;
} else {
ERROR("Expecting hex digit");
return -1;
}
}
return val;
}
static int parse_escaped_codepoint(xmlRegParserCtxtPtr ctxt)
{
int val = parse_escaped_codeunit(ctxt);
if (0xD800 <= val && val <= 0xDBFF) {
NEXT;
if (CUR == '\\') {
NEXT;
if (CUR == 'u') {
int low = parse_escaped_codeunit(ctxt);
if (0xDC00 <= low && low <= 0xDFFF) {
return (val - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;
}
}
}
ERROR("Invalid low surrogate pair code unit");
val = -1;
}
return val;
}
/**
* xmlFAParseCharClassEsc:
* @ctxt: a regexp parser context
@ -4970,7 +5003,25 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) {
(cur == '|') || (cur == '.') || (cur == '?') || (cur == '*') ||
(cur == '+') || (cur == '(') || (cur == ')') || (cur == '{') ||
(cur == '}') || (cur == 0x2D) || (cur == 0x5B) || (cur == 0x5D) ||
(cur == 0x5E)) {
(cur == 0x5E) ||
/* Non-standard escape sequences:
* Java 1.8|.NET Core 3.1|MSXML 6 */
(cur == '!') || /* + | + | + */
(cur == '"') || /* + | + | + */
(cur == '#') || /* + | + | + */
(cur == '$') || /* + | + | + */
(cur == '%') || /* + | + | + */
(cur == ',') || /* + | + | + */
(cur == '/') || /* + | + | + */
(cur == ':') || /* + | + | + */
(cur == ';') || /* + | + | + */
(cur == '=') || /* + | + | + */
(cur == '>') || /* | + | + */
(cur == '@') || /* + | + | + */
(cur == '`') || /* + | + | + */
(cur == '~') || /* + | + | + */
(cur == 'u')) { /* | + | + */
if (ctxt->atom == NULL) {
ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL);
if (ctxt->atom != NULL) {
@ -4984,6 +5035,13 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) {
case 't':
ctxt->atom->codepoint = '\t';
break;
case 'u':
cur = parse_escaped_codepoint(ctxt);
if (cur < 0) {
return;
}
ctxt->atom->codepoint = cur;
break;
default:
ctxt->atom->codepoint = cur;
}
@ -8267,6 +8325,5 @@ xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt) {
}
#endif /* LIBXML_EXPR_ENABLED */
#define bottom_xmlregexp
#include "elfgcchack.h"
#endif /* LIBXML_REGEXP_ENABLED */

View file

@ -474,6 +474,7 @@ xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table) {
*/
return;
}
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
xmlDumpNotationTable(buffer, table);
xmlBufMergeBuffer(buf, buffer);
}
@ -497,6 +498,7 @@ xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem) {
*/
return;
}
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
xmlDumpElementDecl(buffer, elem);
xmlBufMergeBuffer(buf, buffer);
}
@ -520,6 +522,7 @@ xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr) {
*/
return;
}
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
xmlDumpAttributeDecl(buffer, attr);
xmlBufMergeBuffer(buf, buffer);
}
@ -542,6 +545,7 @@ xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent) {
*/
return;
}
xmlBufferSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
xmlDumpEntityDecl(buffer, ent);
xmlBufMergeBuffer(buf, buffer);
}
@ -1375,7 +1379,7 @@ xhtmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
(htmlIsBooleanAttr(cur->name))) {
if (cur->children != NULL)
xmlFreeNode(cur->children);
cur->children = xmlNewText(cur->name);
cur->children = xmlNewDocText(cur->doc, cur->name);
if (cur->children != NULL)
cur->children->parent = (xmlNodePtr) cur;
}
@ -2731,5 +2735,3 @@ xmlSaveFile(const char *filename, xmlDocPtr cur) {
#endif /* LIBXML_OUTPUT_ENABLED */
#define bottom_xmlsave
#include "elfgcchack.h"

View file

@ -24634,6 +24634,7 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt,
int valNeeded)
{
int ret;
xmlChar *stripped;
const xmlChar *nsName;
xmlChar *local, *prefix = NULL;
@ -24650,7 +24651,10 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt,
* NOTE: xmlSplitQName2 will always return a duplicated
* strings.
*/
local = xmlSplitQName2(value, &prefix);
/* TODO: Export and use xmlSchemaStrip instead */
stripped = xmlSchemaCollapseString(value);
local = xmlSplitQName2(stripped ? stripped : value, &prefix);
xmlFree(stripped);
if (local == NULL)
local = xmlStrdup(value);
/*
@ -26463,13 +26467,15 @@ default_psvi:
normValue = xmlSchemaNormalizeValue(inode->typeDef,
inode->decl->value);
if (normValue != NULL) {
textChild = xmlNewText(BAD_CAST normValue);
textChild = xmlNewDocText(inode->node->doc,
BAD_CAST normValue);
xmlFree(normValue);
} else
textChild = xmlNewText(inode->decl->value);
textChild = xmlNewDocText(inode->node->doc,
inode->decl->value);
if (textChild == NULL) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlNewText()");
"calling xmlNewDocText()");
goto internal_error;
} else
xmlAddChild(inode->node, textChild);
@ -27815,17 +27821,6 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
} while (cur != NULL);
vctxt->aidcs = NULL;
}
if (vctxt->idcMatcherCache != NULL) {
xmlSchemaIDCMatcherPtr matcher = vctxt->idcMatcherCache, tmp;
while (matcher) {
tmp = matcher;
matcher = matcher->nextCached;
xmlSchemaIDCFreeMatcherList(tmp);
}
vctxt->idcMatcherCache = NULL;
}
if (vctxt->idcNodes != NULL) {
int i;
@ -27892,6 +27887,21 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
xmlFree(vctxt->filename);
vctxt->filename = NULL;
}
/*
* Note that some cleanup functions can move items to the cache,
* so the cache shouldn't be freed too early.
*/
if (vctxt->idcMatcherCache != NULL) {
xmlSchemaIDCMatcherPtr matcher = vctxt->idcMatcherCache, tmp;
while (matcher) {
tmp = matcher;
matcher = matcher->nextCached;
xmlSchemaIDCFreeMatcherList(tmp);
}
vctxt->idcMatcherCache = NULL;
}
}
/**
@ -29170,6 +29180,4 @@ xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt)
return (ctxt->parserCtxt);
}
#define bottom_xmlschemas
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */

View file

@ -18,6 +18,9 @@
#ifdef LIBXML_SCHEMAS_ENABLED
#include <string.h>
#include <math.h>
#include <float.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
@ -30,13 +33,6 @@
#include <libxml/schemasInternals.h>
#include <libxml/xmlschemastypes.h>
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#define DEBUG
#ifndef LIBXML_XPATH_ENABLED
@ -627,6 +623,11 @@ xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
/**
* xmlSchemaCleanupTypes:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the default XML Schemas type library
*/
void
@ -3308,6 +3309,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
if (cur == NULL)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
if (*cur == '-') {
sign = 1;
cur++;
@ -3316,6 +3319,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
if (ret < 0)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
if (*cur != 0)
goto return1;
if (type->builtInType == XML_SCHEMAS_LONG) {
@ -3380,9 +3385,13 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
if (cur == NULL)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
if (ret < 0)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
if (*cur != 0)
goto return1;
if (type->builtInType == XML_SCHEMAS_ULONG) {
@ -6276,6 +6285,4 @@ xmlSchemaGetValType(xmlSchemaValPtr val)
return (val->type);
}
#define bottom_xmlschemastypes
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */

View file

@ -424,13 +424,7 @@ xmlStrsub(const xmlChar *str, int start, int len) {
int
xmlStrlen(const xmlChar *str) {
size_t len = 0;
if (str == NULL) return(0);
while (*str != 0) { /* non input consuming */
str++;
len++;
}
size_t len = str ? strlen((const char *)str) : 0;
return(len > INT_MAX ? 0 : len);
}
@ -1051,5 +1045,3 @@ xmlEscapeFormatString(xmlChar **msg)
return *msg;
}
#define bottom_xmlstring
#include "elfgcchack.h"

View file

@ -34,7 +34,7 @@ typedef struct {
} xmlUnicodeNameTable;
static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname);
static xmlIntFunc *xmlUnicodeLookup(const xmlUnicodeNameTable *tptr, const char *tname);
static const xmlUnicodeRange xmlUnicodeBlocks[] = {
{"AegeanNumbers", xmlUCSIsAegeanNumbers},
@ -166,7 +166,7 @@ static const xmlUnicodeRange xmlUnicodeBlocks[] = {
{"YiSyllables", xmlUCSIsYiSyllables},
{"YijingHexagramSymbols", xmlUCSIsYijingHexagramSymbols}};
static xmlUnicodeRange xmlUnicodeCats[] = {
static const xmlUnicodeRange xmlUnicodeCats[] = {
{"C", xmlUCSIsCatC},
{"Cc", xmlUCSIsCatCc},
{"Cf", xmlUCSIsCatCf},
@ -212,7 +212,7 @@ static const xmlChSRange xmlCS[] = {{0x0, 0x1f}, {0x7f, 0x9f},
static const xmlChLRange xmlCL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
{0xe0020, 0xe007f}, {0xf0000, 0xf0000}, {0xffffd, 0xffffd},
{0x100000, 0x100000}, {0x10fffd, 0x10fffd} };
static xmlChRangeGroup xmlCG = {18,7,xmlCS,xmlCL};
static const xmlChRangeGroup xmlCG = {18,7,xmlCS,xmlCL};
static const xmlChSRange xmlCfS[] = {{0xad, 0xad}, {0x600, 0x603},
{0x6dd, 0x6dd}, {0x70f, 0x70f}, {0x17b4, 0x17b5}, {0x200b, 0x200f},
@ -220,7 +220,7 @@ static const xmlChSRange xmlCfS[] = {{0xad, 0xad}, {0x600, 0x603},
{0xfff9, 0xfffb} };
static const xmlChLRange xmlCfL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
{0xe0020, 0xe007f} };
static xmlChRangeGroup xmlCfG = {11,3,xmlCfS,xmlCfL};
static const xmlChRangeGroup xmlCfG = {11,3,xmlCfS,xmlCfL};
static const xmlChSRange xmlLS[] = {{0x41, 0x5a}, {0x61, 0x7a},
{0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, {0xd8, 0xf6},
@ -309,7 +309,7 @@ static const xmlChLRange xmlLL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
{0x1d736, 0x1d74e}, {0x1d750, 0x1d76e}, {0x1d770, 0x1d788},
{0x1d78a, 0x1d7a8}, {0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7c9},
{0x20000, 0x20000}, {0x2a6d6, 0x2a6d6}, {0x2f800, 0x2fa1d} };
static xmlChRangeGroup xmlLG = {279,50,xmlLS,xmlLL};
static const xmlChRangeGroup xmlLG = {279,50,xmlLS,xmlLL};
static const xmlChSRange xmlLlS[] = {{0x61, 0x7a}, {0xaa, 0xaa},
{0xb5, 0xb5}, {0xba, 0xba}, {0xdf, 0xf6}, {0xf8, 0xff}, {0x101, 0x101},
@ -421,7 +421,7 @@ static const xmlChLRange xmlLlL[] = {{0x10428, 0x1044f}, {0x1d41a, 0x1d433},
{0x1d6fc, 0x1d714}, {0x1d716, 0x1d71b}, {0x1d736, 0x1d74e},
{0x1d750, 0x1d755}, {0x1d770, 0x1d788}, {0x1d78a, 0x1d78f},
{0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7c9} };
static xmlChRangeGroup xmlLlG = {396,28,xmlLlS,xmlLlL};
static const xmlChRangeGroup xmlLlG = {396,28,xmlLlS,xmlLlL};
static const xmlChSRange xmlLmS[] = {{0x2b0, 0x2c1}, {0x2c6, 0x2d1},
{0x2e0, 0x2e4}, {0x2ee, 0x2ee}, {0x37a, 0x37a}, {0x559, 0x559},
@ -429,7 +429,7 @@ static const xmlChSRange xmlLmS[] = {{0x2b0, 0x2c1}, {0x2c6, 0x2d1},
{0x17d7, 0x17d7}, {0x1843, 0x1843}, {0x1d2c, 0x1d61}, {0x3005, 0x3005},
{0x3031, 0x3035}, {0x303b, 0x303b}, {0x309d, 0x309e}, {0x30fc, 0x30fe},
{0xff70, 0xff70}, {0xff9e, 0xff9f} };
static xmlChRangeGroup xmlLmG = {20,0,xmlLmS,NULL};
static const xmlChRangeGroup xmlLmG = {20,0,xmlLmS,NULL};
static const xmlChSRange xmlLoS[] = {{0x1bb, 0x1bb}, {0x1c0, 0x1c3},
{0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a}, {0x641, 0x64a},
@ -492,12 +492,12 @@ static const xmlChLRange xmlLoL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
{0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835},
{0x10837, 0x10838}, {0x1083c, 0x1083c}, {0x1083f, 0x1083f},
{0x20000, 0x20000}, {0x2a6d6, 0x2a6d6}, {0x2f800, 0x2fa1d} };
static xmlChRangeGroup xmlLoG = {211,20,xmlLoS,xmlLoL};
static const xmlChRangeGroup xmlLoG = {211,20,xmlLoS,xmlLoL};
static const xmlChSRange xmlLtS[] = {{0x1c5, 0x1c5}, {0x1c8, 0x1c8},
{0x1cb, 0x1cb}, {0x1f2, 0x1f2}, {0x1f88, 0x1f8f}, {0x1f98, 0x1f9f},
{0x1fa8, 0x1faf}, {0x1fbc, 0x1fbc}, {0x1fcc, 0x1fcc}, {0x1ffc, 0x1ffc} };
static xmlChRangeGroup xmlLtG = {10,0,xmlLtS,NULL};
static const xmlChRangeGroup xmlLtG = {10,0,xmlLtS,NULL};
static const xmlChSRange xmlLuS[] = {{0x41, 0x5a}, {0xc0, 0xd6},
{0xd8, 0xde}, {0x100, 0x100}, {0x102, 0x102}, {0x104, 0x104},
@ -608,7 +608,7 @@ static const xmlChLRange xmlLuL[] = {{0x10400, 0x10427}, {0x1d400, 0x1d419},
{0x1d608, 0x1d621}, {0x1d63c, 0x1d655}, {0x1d670, 0x1d689},
{0x1d6a8, 0x1d6c0}, {0x1d6e2, 0x1d6fa}, {0x1d71c, 0x1d734},
{0x1d756, 0x1d76e}, {0x1d790, 0x1d7a8} };
static xmlChRangeGroup xmlLuG = {390,31,xmlLuS,xmlLuL};
static const xmlChRangeGroup xmlLuG = {390,31,xmlLuS,xmlLuL};
static const xmlChSRange xmlMS[] = {{0x300, 0x357}, {0x35d, 0x36f},
{0x483, 0x486}, {0x488, 0x489}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
@ -642,7 +642,7 @@ static const xmlChSRange xmlMS[] = {{0x300, 0x357}, {0x35d, 0x36f},
static const xmlChLRange xmlML[] = {{0x1d165, 0x1d169}, {0x1d16d, 0x1d172},
{0x1d17b, 0x1d182}, {0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad},
{0xe0100, 0xe01ef} };
static xmlChRangeGroup xmlMG = {113,6,xmlMS,xmlML};
static const xmlChRangeGroup xmlMG = {113,6,xmlMS,xmlML};
static const xmlChSRange xmlMcS[] = {{0x903, 0x903}, {0x93e, 0x940},
{0x949, 0x94c}, {0x982, 0x983}, {0x9be, 0x9c0}, {0x9c7, 0x9c8},
@ -660,7 +660,7 @@ static const xmlChSRange xmlMcS[] = {{0x903, 0x903}, {0x93e, 0x940},
{0x17c7, 0x17c8}, {0x1923, 0x1926}, {0x1929, 0x192b}, {0x1930, 0x1931},
{0x1933, 0x1938} };
static const xmlChLRange xmlMcL[] = {{0x1d165, 0x1d166}, {0x1d16d, 0x1d172} };
static xmlChRangeGroup xmlMcG = {55,2,xmlMcS,xmlMcL};
static const xmlChRangeGroup xmlMcG = {55,2,xmlMcS,xmlMcL};
static const xmlChSRange xmlMnS[] = {{0x300, 0x357}, {0x35d, 0x36f},
{0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9}, {0x5bb, 0x5bd},
@ -692,7 +692,7 @@ static const xmlChSRange xmlMnS[] = {{0x300, 0x357}, {0x35d, 0x36f},
{0xfe00, 0xfe0f}, {0xfe20, 0xfe23} };
static const xmlChLRange xmlMnL[] = {{0x1d167, 0x1d169}, {0x1d17b, 0x1d182},
{0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad}, {0xe0100, 0xe01ef} };
static xmlChRangeGroup xmlMnG = {108,5,xmlMnS,xmlMnL};
static const xmlChRangeGroup xmlMnG = {108,5,xmlMnS,xmlMnL};
static const xmlChSRange xmlNS[] = {{0x30, 0x39}, {0xb2, 0xb3},
{0xb9, 0xb9}, {0xbc, 0xbe}, {0x660, 0x669}, {0x6f0, 0x6f9},
@ -707,7 +707,7 @@ static const xmlChSRange xmlNS[] = {{0x30, 0x39}, {0xb2, 0xb3},
{0x3251, 0x325f}, {0x3280, 0x3289}, {0x32b1, 0x32bf}, {0xff10, 0xff19} };
static const xmlChLRange xmlNL[] = {{0x10107, 0x10133}, {0x10320, 0x10323},
{0x1034a, 0x1034a}, {0x104a0, 0x104a9}, {0x1d7ce, 0x1d7ff} };
static xmlChRangeGroup xmlNG = {42,5,xmlNS,xmlNL};
static const xmlChRangeGroup xmlNG = {42,5,xmlNS,xmlNL};
static const xmlChSRange xmlNdS[] = {{0x30, 0x39}, {0x660, 0x669},
{0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
@ -716,7 +716,7 @@ static const xmlChSRange xmlNdS[] = {{0x30, 0x39}, {0x660, 0x669},
{0xf20, 0xf29}, {0x1040, 0x1049}, {0x1369, 0x1371}, {0x17e0, 0x17e9},
{0x1810, 0x1819}, {0x1946, 0x194f}, {0xff10, 0xff19} };
static const xmlChLRange xmlNdL[] = {{0x104a0, 0x104a9}, {0x1d7ce, 0x1d7ff} };
static xmlChRangeGroup xmlNdG = {21,2,xmlNdS,xmlNdL};
static const xmlChRangeGroup xmlNdG = {21,2,xmlNdS,xmlNdL};
static const xmlChSRange xmlNoS[] = {{0xb2, 0xb3}, {0xb9, 0xb9},
{0xbc, 0xbe}, {0x9f4, 0x9f9}, {0xbf0, 0xbf2}, {0xf2a, 0xf33},
@ -725,7 +725,7 @@ static const xmlChSRange xmlNoS[] = {{0xb2, 0xb3}, {0xb9, 0xb9},
{0x2776, 0x2793}, {0x3192, 0x3195}, {0x3220, 0x3229}, {0x3251, 0x325f},
{0x3280, 0x3289}, {0x32b1, 0x32bf} };
static const xmlChLRange xmlNoL[] = {{0x10107, 0x10133}, {0x10320, 0x10323} };
static xmlChRangeGroup xmlNoG = {20,2,xmlNoS,xmlNoL};
static const xmlChRangeGroup xmlNoG = {20,2,xmlNoS,xmlNoL};
static const xmlChSRange xmlPS[] = {{0x21, 0x23}, {0x25, 0x2a},
{0x2c, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40}, {0x5b, 0x5d}, {0x5f, 0x5f},
@ -749,13 +749,13 @@ static const xmlChSRange xmlPS[] = {{0x21, 0x23}, {0x25, 0x2a},
{0xff0c, 0xff0f}, {0xff1a, 0xff1b}, {0xff1f, 0xff20}, {0xff3b, 0xff3d},
{0xff3f, 0xff3f}, {0xff5b, 0xff5b}, {0xff5d, 0xff5d}, {0xff5f, 0xff65} };
static const xmlChLRange xmlPL[] = {{0x10100, 0x10101}, {0x1039f, 0x1039f} };
static xmlChRangeGroup xmlPG = {84,2,xmlPS,xmlPL};
static const xmlChRangeGroup xmlPG = {84,2,xmlPS,xmlPL};
static const xmlChSRange xmlPdS[] = {{0x2d, 0x2d}, {0x58a, 0x58a},
{0x1806, 0x1806}, {0x2010, 0x2015}, {0x301c, 0x301c}, {0x3030, 0x3030},
{0x30a0, 0x30a0}, {0xfe31, 0xfe32}, {0xfe58, 0xfe58}, {0xfe63, 0xfe63},
{0xff0d, 0xff0d} };
static xmlChRangeGroup xmlPdG = {11,0,xmlPdS,NULL};
static const xmlChRangeGroup xmlPdG = {11,0,xmlPdS,NULL};
static const xmlChSRange xmlPeS[] = {{0x29, 0x29}, {0x5d, 0x5d},
{0x7d, 0x7d}, {0xf3b, 0xf3b}, {0xf3d, 0xf3d}, {0x169c, 0x169c},
@ -774,7 +774,7 @@ static const xmlChSRange xmlPeS[] = {{0x29, 0x29}, {0x5d, 0x5d},
{0xfe48, 0xfe48}, {0xfe5a, 0xfe5a}, {0xfe5c, 0xfe5c}, {0xfe5e, 0xfe5e},
{0xff09, 0xff09}, {0xff3d, 0xff3d}, {0xff5d, 0xff5d}, {0xff60, 0xff60},
{0xff63, 0xff63} };
static xmlChRangeGroup xmlPeG = {63,0,xmlPeS,NULL};
static const xmlChRangeGroup xmlPeG = {63,0,xmlPeS,NULL};
static const xmlChSRange xmlPoS[] = {{0x21, 0x23}, {0x25, 0x27},
{0x2a, 0x2a}, {0x2c, 0x2c}, {0x2e, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40},
@ -795,7 +795,7 @@ static const xmlChSRange xmlPoS[] = {{0x21, 0x23}, {0x25, 0x27},
{0xff0a, 0xff0a}, {0xff0c, 0xff0c}, {0xff0e, 0xff0f}, {0xff1a, 0xff1b},
{0xff1f, 0xff20}, {0xff3c, 0xff3c}, {0xff61, 0xff61}, {0xff64, 0xff64} };
static const xmlChLRange xmlPoL[] = {{0x10100, 0x10101}, {0x1039f, 0x1039f} };
static xmlChRangeGroup xmlPoG = {72,2,xmlPoS,xmlPoL};
static const xmlChRangeGroup xmlPoG = {72,2,xmlPoS,xmlPoL};
static const xmlChSRange xmlPsS[] = {{0x28, 0x28}, {0x5b, 0x5b},
{0x7b, 0x7b}, {0xf3a, 0xf3a}, {0xf3c, 0xf3c}, {0x169b, 0x169b},
@ -814,7 +814,7 @@ static const xmlChSRange xmlPsS[] = {{0x28, 0x28}, {0x5b, 0x5b},
{0xfe41, 0xfe41}, {0xfe43, 0xfe43}, {0xfe47, 0xfe47}, {0xfe59, 0xfe59},
{0xfe5b, 0xfe5b}, {0xfe5d, 0xfe5d}, {0xff08, 0xff08}, {0xff3b, 0xff3b},
{0xff5b, 0xff5b}, {0xff5f, 0xff5f}, {0xff62, 0xff62} };
static xmlChRangeGroup xmlPsG = {65,0,xmlPsS,NULL};
static const xmlChRangeGroup xmlPsG = {65,0,xmlPsS,NULL};
static const xmlChSRange xmlSS[] = {{0x24, 0x24}, {0x2b, 0x2b},
{0x3c, 0x3e}, {0x5e, 0x5e}, {0x60, 0x60}, {0x7c, 0x7c}, {0x7e, 0x7e},
@ -857,13 +857,13 @@ static const xmlChLRange xmlSL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
{0x1d6db, 0x1d6db}, {0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715},
{0x1d735, 0x1d735}, {0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f},
{0x1d789, 0x1d789}, {0x1d7a9, 0x1d7a9}, {0x1d7c3, 0x1d7c3} };
static xmlChRangeGroup xmlSG = {133,20,xmlSS,xmlSL};
static const xmlChRangeGroup xmlSG = {133,20,xmlSS,xmlSL};
static const xmlChSRange xmlScS[] = {{0x24, 0x24}, {0xa2, 0xa5},
{0x9f2, 0x9f3}, {0xaf1, 0xaf1}, {0xbf9, 0xbf9}, {0xe3f, 0xe3f},
{0x17db, 0x17db}, {0x20a0, 0x20b1}, {0xfdfc, 0xfdfc}, {0xfe69, 0xfe69},
{0xff04, 0xff04}, {0xffe0, 0xffe1}, {0xffe5, 0xffe6} };
static xmlChRangeGroup xmlScG = {13,0,xmlScS,NULL};
static const xmlChRangeGroup xmlScG = {13,0,xmlScS,NULL};
static const xmlChSRange xmlSkS[] = {{0x5e, 0x5e}, {0x60, 0x60},
{0xa8, 0xa8}, {0xaf, 0xaf}, {0xb4, 0xb4}, {0xb8, 0xb8}, {0x2c2, 0x2c5},
@ -871,7 +871,7 @@ static const xmlChSRange xmlSkS[] = {{0x5e, 0x5e}, {0x60, 0x60},
{0x384, 0x385}, {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, {0x1fcd, 0x1fcf},
{0x1fdd, 0x1fdf}, {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x309b, 0x309c},
{0xff3e, 0xff3e}, {0xff40, 0xff40}, {0xffe3, 0xffe3} };
static xmlChRangeGroup xmlSkG = {22,0,xmlSkS,NULL};
static const xmlChRangeGroup xmlSkG = {22,0,xmlSkS,NULL};
static const xmlChSRange xmlSmS[] = {{0x2b, 0x2b}, {0x3c, 0x3e},
{0x7c, 0x7c}, {0x7e, 0x7e}, {0xac, 0xac}, {0xb1, 0xb1}, {0xd7, 0xd7},
@ -890,7 +890,7 @@ static const xmlChLRange xmlSmL[] = {{0x1d6c1, 0x1d6c1}, {0x1d6db, 0x1d6db},
{0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715}, {0x1d735, 0x1d735},
{0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f}, {0x1d789, 0x1d789},
{0x1d7a9, 0x1d7a9}, {0x1d7c3, 0x1d7c3} };
static xmlChRangeGroup xmlSmG = {48,10,xmlSmS,xmlSmL};
static const xmlChRangeGroup xmlSmG = {48,10,xmlSmS,xmlSmL};
static const xmlChSRange xmlSoS[] = {{0xa6, 0xa7}, {0xa9, 0xa9},
{0xae, 0xae}, {0xb0, 0xb0}, {0xb6, 0xb6}, {0x482, 0x482},
@ -923,15 +923,15 @@ static const xmlChLRange xmlSoL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
{0x1d000, 0x1d0f5}, {0x1d100, 0x1d126}, {0x1d12a, 0x1d164},
{0x1d16a, 0x1d16c}, {0x1d183, 0x1d184}, {0x1d18c, 0x1d1a9},
{0x1d1ae, 0x1d1dd}, {0x1d300, 0x1d356} };
static xmlChRangeGroup xmlSoG = {103,10,xmlSoS,xmlSoL};
static const xmlChRangeGroup xmlSoG = {103,10,xmlSoS,xmlSoL};
static const xmlChSRange xmlZS[] = {{0x20, 0x20}, {0xa0, 0xa0},
{0x1680, 0x1680}, {0x180e, 0x180e}, {0x2000, 0x200a}, {0x2028, 0x2029},
{0x202f, 0x202f}, {0x205f, 0x205f}, {0x3000, 0x3000} };
static xmlChRangeGroup xmlZG = {9,0,xmlZS,NULL};
static const xmlChRangeGroup xmlZG = {9,0,xmlZS,NULL};
static xmlUnicodeNameTable xmlUnicodeBlockTbl = {xmlUnicodeBlocks, 128};
static xmlUnicodeNameTable xmlUnicodeCatTbl = {xmlUnicodeCats, 36};
static const xmlUnicodeNameTable xmlUnicodeBlockTbl = {xmlUnicodeBlocks, 128};
static const xmlUnicodeNameTable xmlUnicodeCatTbl = {xmlUnicodeCats, 36};
/**
* xmlUnicodeLookup:
@ -943,7 +943,7 @@ static xmlUnicodeNameTable xmlUnicodeCatTbl = {xmlUnicodeCats, 36};
* Returns pointer to range function if found, otherwise NULL
*/
static xmlIntFunc
*xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname) {
*xmlUnicodeLookup(const xmlUnicodeNameTable *tptr, const char *tname) {
int low, high, mid, cmp;
const xmlUnicodeRange *sptr;
@ -3174,6 +3174,4 @@ xmlUCSIsCat(int code, const char *cat) {
return (func(code));
}
#define bottom_xmlunicode
#include "elfgcchack.h"
#endif /* LIBXML_UNICODE_ENABLED */

View file

@ -1541,7 +1541,7 @@ static int
xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
const unsigned char *data)
{
static unsigned char dtable[64] =
static const unsigned char dtable[64] =
{'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
@ -1674,7 +1674,7 @@ xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out,
{
int count;
int sum;
static char hex[16] =
static const char hex[16] =
{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int i;
@ -4733,6 +4733,4 @@ xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer,
return sum;
}
#define bottom_xmlwriter
#include "elfgcchack.h"
#endif

View file

@ -25,22 +25,9 @@
#include <limits.h>
#include <string.h>
#include <stddef.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
@ -49,7 +36,7 @@
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
#include <libxml/hash.h>
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
#include <libxml/xpointer.h>
#endif
#ifdef LIBXML_DEBUG_ENABLED
@ -495,16 +482,25 @@ double xmlXPathNINF = 0.0;
/**
* xmlXPathInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the XPath environment
*/
ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
void
xmlXPathInit(void) {
#if defined(NAN) && defined(INFINITY)
xmlXPathNAN = NAN;
xmlXPathPINF = INFINITY;
xmlXPathNINF = -INFINITY;
#else
/* MSVC doesn't allow division by zero in constant expressions. */
double zero = 0.0;
xmlXPathNAN = 0.0 / zero;
xmlXPathPINF = 1.0 / zero;
xmlXPathNINF = -xmlXPathPINF;
#endif
}
/**
@ -590,7 +586,7 @@ static int xmlXPathDisableOptimizer = 0;
/*
* The array xmlXPathErrorMessages corresponds to the enum xmlXPathError
*/
static const char *xmlXPathErrorMessages[] = {
static const char* const xmlXPathErrorMessages[] = {
"Ok\n",
"Number encoding\n",
"Unfinished literal\n",
@ -911,7 +907,7 @@ typedef enum {
XPATH_OP_PREDICATE,
XPATH_OP_FILTER, /* 16 */
XPATH_OP_SORT /* 17 */
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
,XPATH_OP_RANGETO
#endif
} xmlXPathOp;
@ -1362,7 +1358,7 @@ xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
fprintf(output, "%d", i + 1);
xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1);
}
#if defined(LIBXML_XPTR_ENABLED)
#if defined(LIBXML_XPTR_LOCS_ENABLED)
static void
xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
int i;
@ -1385,7 +1381,7 @@ xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1);
}
}
#endif /* LIBXML_XPTR_ENABLED */
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPathDebugDumpObject:
@ -1454,6 +1450,7 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
xmlDebugDumpString(output, cur->stringval);
fprintf(output, "\n");
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(output, "Object is a point : index %d in node", cur->index);
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1);
@ -1489,12 +1486,11 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
}
break;
case XPATH_LOCATIONSET:
#if defined(LIBXML_XPTR_ENABLED)
fprintf(output, "Object is a Location Set:\n");
xmlXPathDebugDumpLocationSet(output,
(xmlLocationSetPtr) cur->user, depth);
#endif
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(output, "Object is user defined\n");
break;
@ -1662,7 +1658,7 @@ xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
case XPATH_OP_ARG: fprintf(output, "ARG"); break;
case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break;
case XPATH_OP_FILTER: fprintf(output, "FILTER"); break;
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break;
#endif
default:
@ -1854,6 +1850,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_STRING:
cache->dbgReusedString++;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
cache->dbgReusedPoint++;
break;
@ -1863,6 +1860,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET:
cache->dbgReusedLocset++;
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
cache->dbgReusedUsers++;
break;
@ -1921,6 +1919,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
xmlXPathDebugObjMaxString =
xmlXPathDebugObjCounterString;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
if (! isCached)
xmlXPathDebugObjTotalPoint++;
@ -1948,6 +1947,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
xmlXPathDebugObjMaxLocset =
xmlXPathDebugObjCounterLocset;
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
if (! isCached)
xmlXPathDebugObjTotalUsers++;
@ -2008,6 +2008,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_STRING:
cache->dbgCachedString++;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
cache->dbgCachedPoint++;
break;
@ -2017,6 +2018,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET:
cache->dbgCachedLocset++;
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
cache->dbgCachedUsers++;
break;
@ -2045,6 +2047,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_STRING:
xmlXPathDebugObjCounterString--;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlXPathDebugObjCounterPoint--;
break;
@ -2054,6 +2057,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET:
xmlXPathDebugObjCounterLocset--;
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlXPathDebugObjCounterUsers--;
break;
@ -2706,9 +2710,11 @@ xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
res = xmlXPathCastNumberToString(val->floatval);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO;
break;
}
@ -5387,8 +5393,10 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
switch (val->type) {
case XPATH_BOOLEAN:
case XPATH_NUMBER:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
break;
case XPATH_STRING:
ret->stringval = xmlStrdup(val->stringval);
@ -5432,8 +5440,8 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
/* Do not deallocate the copied tree value */
ret->boolval = 0;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:
#ifdef LIBXML_XPTR_ENABLED
{
xmlLocationSetPtr loc = val->user;
ret->user = (void *) xmlXPtrLocationSetMerge(NULL, loc);
@ -5476,7 +5484,7 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval);
}
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (obj->type == XPATH_LOCATIONSET) {
if (obj->user != NULL)
xmlXPtrFreeLocationSet(obj->user);
@ -5566,7 +5574,7 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
goto obj_cached;
}
break;
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:
if (obj->user != NULL) {
xmlXPtrFreeLocationSet(obj->user);
@ -5769,9 +5777,11 @@ xmlXPathCastToString(xmlXPathObjectPtr val) {
break;
}
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
ret = xmlStrdup((const xmlChar *) "");
break;
@ -5814,9 +5824,11 @@ xmlXPathConvertString(xmlXPathObjectPtr val) {
res = xmlXPathCastNumberToString(val->floatval);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO;
break;
}
@ -5934,9 +5946,11 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
ret = xmlXPathCastBooleanToNumber(val->boolval);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO;
ret = xmlXPathNAN;
break;
@ -6046,9 +6060,11 @@ xmlXPathCastToBoolean (xmlXPathObjectPtr val) {
ret = val->boolval;
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO;
ret = 0;
break;
@ -6985,9 +7001,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
ret = (arg1->boolval == ret);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
case XPATH_NODESET:
@ -7042,9 +7060,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
case XPATH_NODESET:
@ -7103,9 +7123,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
case XPATH_NODESET:
@ -7114,9 +7136,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
case XPATH_NODESET:
@ -7199,9 +7223,11 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval, 0);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
}
@ -7284,9 +7310,11 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval,1);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO
break;
}
@ -7651,9 +7679,6 @@ xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(((xmlDocPtr) ctxt->context->node)->children);
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
@ -7709,9 +7734,6 @@ xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return(NULL);
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(xmlDocGetRootElement((xmlDocPtr) cur));
default:
return(NULL);
@ -7772,9 +7794,6 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
case XML_XINCLUDE_START:
case XML_DOCUMENT_FRAG_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
return(contextNode);
default:
@ -7799,9 +7818,6 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
break;
/* Not sure if we need those here. */
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
if (cur != start)
return(cur);
@ -7968,9 +7984,6 @@ xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(NULL);
case XML_NAMESPACE_DECL: {
xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
@ -8041,9 +8054,6 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(NULL);
case XML_NAMESPACE_DECL: {
xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
@ -8102,9 +8112,6 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
return(NULL);
}
return(NULL);
@ -10618,7 +10625,7 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
"PathExpr: Type search\n");
#endif
lc = 1;
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (ctxt->xptr &&
xmlStrEqual(name, BAD_CAST "range-to")) {
lc = 1;
@ -11269,7 +11276,7 @@ xmlXPathIsAxisName(const xmlChar *name) {
*/
static void
xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
int rangeto = 0;
int op2 = -1;
#endif
@ -11294,7 +11301,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
/*
* The modification needed for XPointer change to the production
*/
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
if (ctxt->xptr) {
name = xmlXPathParseNCName(ctxt);
if ((name != NULL) && (xmlStrEqual(name, BAD_CAST "range-to"))) {
@ -11379,7 +11386,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
#endif
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
eval_predicates:
#endif
op1 = ctxt->comp->last;
@ -11390,7 +11397,7 @@ eval_predicates:
xmlXPathCompPredicate(ctxt, 0);
}
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
if (rangeto) {
PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0);
} else
@ -11733,7 +11740,7 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
xpctxt->proximityPosition = oldpp;
}
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xmlXPathLocationSetFilter:
* @ctxt: the XPath Parser context
@ -11850,7 +11857,7 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
xpctxt->contextSize = oldcs;
xpctxt->proximityPosition = oldpp;
}
#endif /* LIBXML_XPTR_ENABLED */
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPathCompOpEvalPredicate:
@ -12268,9 +12275,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
switch (cur->type) {
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
@ -12909,7 +12913,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
if (ctxt->value == NULL)
return (total);
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* Hum are we filtering the result of an XPointer expression
*/
@ -12924,7 +12928,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total);
}
#endif /* LIBXML_XPTR_ENABLED */
#endif /* LIBXML_XPTR_LOCS_ENABLED */
CHECK_TYPE0(XPATH_NODESET);
set = ctxt->value->nodesetval;
@ -13332,7 +13336,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
if (ctxt->value == NULL)
break;
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* Hum are we filtering the result of an XPointer expression
*/
@ -13342,7 +13346,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
1, locset->locNr);
break;
}
#endif /* LIBXML_XPTR_ENABLED */
#endif /* LIBXML_XPTR_LOCS_ENABLED */
CHECK_TYPE0(XPATH_NODESET);
set = ctxt->value->nodesetval;
@ -13363,7 +13367,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlXPathNodeSetSort(ctxt->value->nodesetval);
}
break;
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO:{
xmlXPathObjectPtr range;
xmlXPathObjectPtr res, obj;
@ -13521,7 +13525,7 @@ rangeto_error:
ctxt->context->proximityPosition = oldpp;
break;
}
#endif /* LIBXML_XPTR_ENABLED */
#endif /* LIBXML_XPTR_LOCS_ENABLED */
default:
xmlGenericError(xmlGenericErrorContext,
"XPath: unknown precompiled operation %d\n", op->op);
@ -13700,9 +13704,6 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
cur = ctxt->node;
break;
case XML_ATTRIBUTE_NODE:
@ -13883,19 +13884,18 @@ static int
xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
{
xmlXPathCompExprPtr comp;
int oldDepth;
if ((ctxt == NULL) || (ctxt->comp == NULL))
return(-1);
ctxt->context->depth = 0;
if (ctxt->valueTab == NULL) {
/* Allocate the value stack */
ctxt->valueTab = (xmlXPathObjectPtr *)
xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
if (ctxt->valueTab == NULL) {
xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
xmlFree(ctxt);
return(-1);
}
ctxt->valueNr = 0;
ctxt->valueMax = 10;
@ -13942,11 +13942,13 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
"xmlXPathRunEval: last is less than zero\n");
return(-1);
}
oldDepth = ctxt->context->depth;
if (toBool)
return(xmlXPathCompOpEvalToBoolean(ctxt,
&comp->steps[comp->last], 0));
else
xmlXPathCompOpEval(ctxt, &comp->steps[comp->last]);
ctxt->context->depth = oldDepth;
return(0);
}
@ -14032,7 +14034,7 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
return(res->nodesetval->nodeNr != 0);
case XPATH_STRING:
return((res->stringval != NULL) && (res->stringval[0] != 0));
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:{
xmlLocationSetPtr ptr = res->user;
if (ptr == NULL)
@ -14217,6 +14219,7 @@ xmlXPathCompExprPtr
xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
xmlXPathParserContextPtr pctxt;
xmlXPathCompExprPtr comp;
int oldDepth = 0;
#ifdef XPATH_STREAMING
comp = xmlXPathTryStreamCompile(ctxt, str);
@ -14230,8 +14233,10 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
if (pctxt == NULL)
return NULL;
if (ctxt != NULL)
ctxt->depth = 0;
oldDepth = ctxt->depth;
xmlXPathCompileExpr(pctxt, 1);
if (ctxt != NULL)
ctxt->depth = oldDepth;
if( pctxt->error != XPATH_EXPRESSION_OK )
{
@ -14252,8 +14257,10 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
comp = pctxt->comp;
if ((comp->nbStep > 1) && (comp->last >= 0)) {
if (ctxt != NULL)
ctxt->depth = 0;
oldDepth = ctxt->depth;
xmlXPathOptimizeExpression(pctxt, &comp->steps[comp->last]);
if (ctxt != NULL)
ctxt->depth = oldDepth;
}
pctxt->comp = NULL;
}
@ -14409,6 +14416,7 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
#ifdef XPATH_STREAMING
xmlXPathCompExprPtr comp;
#endif
int oldDepth = 0;
if (ctxt == NULL) return;
@ -14422,8 +14430,10 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
#endif
{
if (ctxt->context != NULL)
ctxt->context->depth = 0;
oldDepth = ctxt->context->depth;
xmlXPathCompileExpr(ctxt, 1);
if (ctxt->context != NULL)
ctxt->context->depth = oldDepth;
CHECK_ERROR;
/* Check for trailing characters. */
@ -14432,9 +14442,11 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
if ((ctxt->comp->nbStep > 1) && (ctxt->comp->last >= 0)) {
if (ctxt->context != NULL)
ctxt->context->depth = 0;
oldDepth = ctxt->context->depth;
xmlXPathOptimizeExpression(ctxt,
&ctxt->comp->steps[ctxt->comp->last]);
if (ctxt->context != NULL)
ctxt->context->depth = oldDepth;
}
}
@ -14725,5 +14737,3 @@ xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
}
#endif /* LIBXML_XPATH_ENABLED */
#define bottom_xpath
#include "elfgcchack.h"

View file

@ -132,6 +132,7 @@ xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
* A few helper functions for child sequences *
* *
************************************************************************/
#ifdef LIBXML_XPTR_LOCS_ENABLED
/* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
/**
@ -177,6 +178,7 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
}
return(i);
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPtrGetNthChild:
@ -205,6 +207,7 @@ xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
return(cur);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
/************************************************************************
* *
* Handling of XPointer specific types *
@ -836,6 +839,7 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
ret->user = (void *) val;
return(ret);
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/************************************************************************
* *
@ -996,7 +1000,8 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
XP_ERROR(XPTR_SYNTAX_ERROR);
}
if (xmlStrEqual(name, (xmlChar *) "xpointer")) {
if (xmlStrEqual(name, (xmlChar *) "xpointer") ||
xmlStrEqual(name, (xmlChar *) "xpath1")) {
const xmlChar *oldBase = ctxt->base;
const xmlChar *oldCur = ctxt->cur;
@ -1010,6 +1015,9 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
ctxt->context->proximityPosition = 1;
ctxt->context->contextSize = 1;
#ifdef LIBXML_XPTR_LOCS_ENABLED
ctxt->xptr = xmlStrEqual(name, (xmlChar *) "xpointer");
#endif
xmlXPathEvalExpr(ctxt);
ctxt->base = oldBase;
ctxt->cur = oldCur;
@ -1125,12 +1133,14 @@ xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
xmlXPathObjectPtr obj = ctxt->value;
switch (obj->type) {
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: {
xmlLocationSetPtr loc = ctxt->value->user;
if ((loc != NULL) && (loc->locNr > 0))
return;
break;
}
#endif
case XPATH_NODESET: {
xmlNodeSetPtr loc = ctxt->value->nodesetval;
if ((loc != NULL) && (loc->nodeNr > 0))
@ -1269,6 +1279,7 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
* *
************************************************************************/
#ifdef LIBXML_XPTR_LOCS_ENABLED
static
void xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
static
@ -1283,6 +1294,7 @@ static
void xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs);
static
void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPtrNewContext:
@ -1298,10 +1310,13 @@ void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
xmlXPathContextPtr
xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) {
xmlXPathContextPtr ret;
(void) here;
(void) origin;
ret = xmlXPathNewContext(doc);
if (ret == NULL)
return(ret);
#ifdef LIBXML_XPTR_LOCS_ENABLED
ret->xptr = 1;
ret->here = here;
ret->origin = origin;
@ -1320,6 +1335,7 @@ xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) {
xmlXPtrHereFunction);
xmlXPathRegisterFunc(ret, (xmlChar *)" origin",
xmlXPtrOriginFunction);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
return(ret);
}
@ -1349,12 +1365,13 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
ctxt = xmlXPathNewParserContext(str, ctx);
if (ctxt == NULL)
return(NULL);
ctxt->xptr = 1;
xmlXPtrEvalXPointer(ctxt);
if ((ctxt->value != NULL) &&
(ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_LOCATIONSET)) {
#ifdef LIBXML_XPTR_LOCS_ENABLED
(ctxt->value->type != XPATH_LOCATIONSET) &&
#endif
(ctxt->value->type != XPATH_NODESET)) {
xmlXPtrErr(ctxt, XML_XPTR_EVAL_FAILED,
"xmlXPtrEval: evaluation failed to return a node set\n",
NULL);
@ -1395,6 +1412,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
return(res);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xmlXPtrBuildRangeNodeList:
* @range: a range object
@ -1601,9 +1619,6 @@ xmlXPtrBuildNodeList(xmlXPathObjectPtr obj) {
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
break;
@ -2951,8 +2966,7 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
NEXT;
SKIP_BLANKS;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#define bottom_xpointer
#include "elfgcchack.h"
#endif

View file

@ -11,10 +11,8 @@
#ifdef LIBXML_LZMA_ENABLED
#include <string.h>
#ifdef HAVE_ERRNO_H
#include <stdlib.h>
#include <errno.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -28,9 +26,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
@ -389,6 +384,10 @@ xz_head(xz_statep state)
int flags;
unsigned len;
/* Avoid unused variable warning if features are disabled. */
(void) flags;
(void) len;
/* allocate read buffers and inflate memory */
if (state->size == 0) {
/* allocate buffers */
@ -536,6 +535,10 @@ xz_decomp(xz_statep state)
lzma_action action = LZMA_RUN;
/* Avoid unused variable warning if features are disabled. */
(void) crc;
(void) len;
/* fill output buffer up to end of deflate stream */
had = strm->avail_out;
do {