1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-23 15:01:05 +03:00

preparing a beta3 solving the ABI problems make sure the global variables

* configure.in: preparing a beta3 solving the ABI problems
* globals.c parser.c parserInternals.c testHTML.c HTMLparser.c SAX.c
  include/libxml/globals.h include/libxml/SAX.h: make sure the
  global variables for the default SAX handler are V1 ones to
  avoid ABI compat problems.
* xmlreader.c: cleanup of uneeded code
* hash.c: fix a comment
Daniel
This commit is contained in:
Daniel Veillard
2003-09-25 14:29:29 +00:00
parent 7a02cfe0d7
commit 092643b52d
14 changed files with 169 additions and 443 deletions

View File

@ -1,3 +1,13 @@
Thu Sep 25 16:23:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
* configure.in: preparing a beta3 solving the ABI problems
* globals.c parser.c parserInternals.c testHTML.c HTMLparser.c SAX.c
include/libxml/globals.h include/libxml/SAX.h: make sure the
global variables for the default SAX handler are V1 ones to
avoid ABI compat problems.
* xmlreader.c: cleanup of uneeded code
* hash.c: fix a comment
Thu Sep 25 14:16:51 CEST 2003 Daniel Veillard <daniel@veillard.com> Thu Sep 25 14:16:51 CEST 2003 Daniel Veillard <daniel@veillard.com>
* SAX2.c hash.c parser.c include/libxml/xmlexports.h * SAX2.c hash.c parser.c include/libxml/xmlexports.h

View File

@ -4102,10 +4102,10 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->nameMax = 10; ctxt->nameMax = 10;
ctxt->name = NULL; ctxt->name = NULL;
if (sax == NULL) ctxt->sax = &htmlDefaultSAXHandler; if (sax == NULL) ctxt->sax = (xmlSAXHandlerPtr) &htmlDefaultSAXHandler;
else { else {
ctxt->sax = sax; ctxt->sax = sax;
memcpy(sax, &htmlDefaultSAXHandler, sizeof(htmlSAXHandler)); memcpy(sax, &htmlDefaultSAXHandler, sizeof(xmlSAXHandlerV1));
} }
ctxt->userData = ctxt; ctxt->userData = ctxt;
ctxt->myDoc = NULL; ctxt->myDoc = NULL;
@ -5175,7 +5175,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
if(enc==XML_CHAR_ENCODING_UTF8 || buf->encoder) if(enc==XML_CHAR_ENCODING_UTF8 || buf->encoder)
ctxt->charset=XML_CHAR_ENCODING_UTF8; ctxt->charset=XML_CHAR_ENCODING_UTF8;
if (sax != NULL) { if (sax != NULL) {
if (ctxt->sax != &htmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &htmlDefaultSAXHandler)
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
ctxt->sax = (htmlSAXHandlerPtr) xmlMalloc(sizeof(htmlSAXHandler)); ctxt->sax = (htmlSAXHandlerPtr) xmlMalloc(sizeof(htmlSAXHandler));
if (ctxt->sax == NULL) { if (ctxt->sax == NULL) {

6
SAX.c
View File

@ -620,7 +620,7 @@ cdataBlock(void *ctx, const xmlChar *value, int len)
* DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
*/ */
void void
initxmlDefaultSAXHandler(xmlSAXHandler *hdlr, int warning) initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
{ {
if(hdlr->initialized == 1) if(hdlr->initialized == 1)
@ -669,7 +669,7 @@ initxmlDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
* DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
*/ */
void void
inithtmlDefaultSAXHandler(xmlSAXHandler *hdlr) inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{ {
if(hdlr->initialized == 1) if(hdlr->initialized == 1)
return; return;
@ -717,7 +717,7 @@ inithtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
* DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
*/ */
void void
initdocbDefaultSAXHandler(xmlSAXHandler *hdlr) initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{ {
if(hdlr->initialized == 1) if(hdlr->initialized == 1)
return; return;

25
SAX2.c
View File

@ -2412,17 +2412,6 @@ xmlSAXDefaultVersion(int version)
if ((version != 1) && (version != 2)) if ((version != 1) && (version != 2))
return(-1); return(-1);
xmlSAX2DefaultVersionValue = version; xmlSAX2DefaultVersionValue = version;
if (version == 1) {
xmlDefaultSAXHandler.startElement = xmlSAX2StartElement;
xmlDefaultSAXHandler.endElement = xmlSAX2EndElement;
xmlDefaultSAXHandler.startElementNs = NULL;
xmlDefaultSAXHandler.endElementNs = NULL;
} else if (version == 2) {
xmlDefaultSAXHandler.startElement = NULL;
xmlDefaultSAXHandler.endElement = NULL;
xmlDefaultSAXHandler.startElementNs = xmlSAX2StartElementNs;
xmlDefaultSAXHandler.endElementNs = xmlSAX2EndElementNs;
}
return(ret); return(ret);
} }
@ -2442,13 +2431,13 @@ xmlSAXVersion(xmlSAXHandler *hdlr, int version)
if (version == 1) { if (version == 1) {
hdlr->startElement = xmlSAX2StartElement; hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement; hdlr->endElement = xmlSAX2EndElement;
hdlr->startElementNs = NULL; hdlr->initialized = 1;
hdlr->endElementNs = NULL;
} else if (version == 2) { } else if (version == 2) {
hdlr->startElement = NULL; hdlr->startElement = NULL;
hdlr->endElement = NULL; hdlr->endElement = NULL;
hdlr->startElementNs = xmlSAX2StartElementNs; hdlr->startElementNs = xmlSAX2StartElementNs;
hdlr->endElementNs = xmlSAX2EndElementNs; hdlr->endElementNs = xmlSAX2EndElementNs;
hdlr->initialized = XML_SAX2_MAGIC;
} else } else
return(-1); return(-1);
hdlr->internalSubset = xmlSAX2InternalSubset; hdlr->internalSubset = xmlSAX2InternalSubset;
@ -2477,7 +2466,6 @@ xmlSAXVersion(xmlSAXHandler *hdlr, int version)
hdlr->error = xmlParserError; hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError; hdlr->fatalError = xmlParserError;
hdlr->initialized = XML_SAX2_MAGIC;
return(0); return(0);
} }
@ -2509,8 +2497,7 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
void void
xmlDefaultSAXHandlerInit(void) xmlDefaultSAXHandlerInit(void)
{ {
xmlSAX2InitDefaultSAXHandler(&xmlDefaultSAXHandler, xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1);
xmlGetWarningsDefaultValue);
} }
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
@ -2555,7 +2542,7 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
hdlr->error = xmlParserError; hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError; hdlr->fatalError = xmlParserError;
hdlr->initialized = XML_SAX2_MAGIC; hdlr->initialized = 1;
} }
/** /**
@ -2566,7 +2553,7 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
void void
htmlDefaultSAXHandlerInit(void) htmlDefaultSAXHandlerInit(void)
{ {
xmlSAX2InitHtmlDefaultSAXHandler(&htmlDefaultSAXHandler); xmlSAX2InitHtmlDefaultSAXHandler((xmlSAXHandlerPtr) &htmlDefaultSAXHandler);
} }
#endif /* LIBXML_HTML_ENABLED */ #endif /* LIBXML_HTML_ENABLED */
@ -2624,7 +2611,7 @@ xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr)
void void
docbDefaultSAXHandlerInit(void) docbDefaultSAXHandlerInit(void)
{ {
xmlSAX2InitDocbDefaultSAXHandler(&docbDefaultSAXHandler); xmlSAX2InitDocbDefaultSAXHandler((xmlSAXHandlerPtr) &docbDefaultSAXHandler);
} }
#endif /* LIBXML_DOCB_ENABLED */ #endif /* LIBXML_DOCB_ENABLED */

View File

@ -7,7 +7,7 @@ AC_CANONICAL_HOST
LIBXML_MAJOR_VERSION=2 LIBXML_MAJOR_VERSION=2
LIBXML_MINOR_VERSION=6 LIBXML_MINOR_VERSION=6
LIBXML_MICRO_VERSION=0 LIBXML_MICRO_VERSION=0
LIBXML_MICRO_VERSION_SUFFIX=beta2 LIBXML_MICRO_VERSION_SUFFIX=beta3
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION

View File

@ -62,6 +62,7 @@
<exports symbol='xmlXPtrWrapLocationSet'/> <exports symbol='xmlXPtrWrapLocationSet'/>
</file> </file>
<file name='SAX'> <file name='SAX'>
<exports symbol='_xmlSAXHandlerV1'/>
<exports symbol='attribute'/> <exports symbol='attribute'/>
<exports symbol='attributeDecl'/> <exports symbol='attributeDecl'/>
<exports symbol='cdataBlock'/> <exports symbol='cdataBlock'/>
@ -99,6 +100,8 @@
<exports symbol='startDocument'/> <exports symbol='startDocument'/>
<exports symbol='startElement'/> <exports symbol='startElement'/>
<exports symbol='unparsedEntityDecl'/> <exports symbol='unparsedEntityDecl'/>
<exports symbol='xmlSAXHandlerV1'/>
<exports symbol='xmlSAXHandlerV1Ptr'/>
</file> </file>
<file name='parserInternals'> <file name='parserInternals'>
<exports symbol='INPUT_CHUNK'/> <exports symbol='INPUT_CHUNK'/>
@ -783,7 +786,6 @@
</file> </file>
<file name='xmlmemory'> <file name='xmlmemory'>
<exports symbol='DEBUG_MEMORY'/> <exports symbol='DEBUG_MEMORY'/>
<exports symbol='_DEBUG_MEMORY_ALLOC_'/>
<exports symbol='xmlFreeFunc'/> <exports symbol='xmlFreeFunc'/>
<exports symbol='xmlGcMemGet'/> <exports symbol='xmlGcMemGet'/>
<exports symbol='xmlGcMemSetup'/> <exports symbol='xmlGcMemSetup'/>
@ -2374,6 +2376,7 @@
<arg name='c' info='an UNICODE value (int)'/> <arg name='c' info='an UNICODE value (int)'/>
</macro> </macro>
<macro name='LIBXML_AUTOMATA_ENABLED' file='xmlversion'> <macro name='LIBXML_AUTOMATA_ENABLED' file='xmlversion'>
<info>Whether the automata interfaces are compiled in</info>
</macro> </macro>
<macro name='LIBXML_C14N_ENABLED' file='xmlversion'> <macro name='LIBXML_C14N_ENABLED' file='xmlversion'>
<info>Whether the Canonicalization support is configured in</info> <info>Whether the Canonicalization support is configured in</info>
@ -2408,8 +2411,10 @@
<info>Whether ISO-8859-* support is made available in case iconv is not</info> <info>Whether ISO-8859-* support is made available in case iconv is not</info>
</macro> </macro>
<macro name='LIBXML_REGEXP_ENABLED' file='xmlversion'> <macro name='LIBXML_REGEXP_ENABLED' file='xmlversion'>
<info>Whether the regular expressions interfaces are compiled in</info>
</macro> </macro>
<macro name='LIBXML_SCHEMAS_ENABLED' file='xmlversion'> <macro name='LIBXML_SCHEMAS_ENABLED' file='xmlversion'>
<info>Whether the Schemas validation interfaces are compiled in</info>
</macro> </macro>
<macro name='LIBXML_TEST_VERSION' file='xmlversion'> <macro name='LIBXML_TEST_VERSION' file='xmlversion'>
<info>Macro to check that the libxml version in use is compatible with the version the software has been compiled against</info> <info>Macro to check that the libxml version in use is compatible with the version the software has been compiled against</info>
@ -2418,6 +2423,7 @@
<info>Whether the thread support is configured in</info> <info>Whether the thread support is configured in</info>
</macro> </macro>
<macro name='LIBXML_UNICODE_ENABLED' file='xmlversion'> <macro name='LIBXML_UNICODE_ENABLED' file='xmlversion'>
<info>Whether the Unicode related interfaces are compiled in</info>
</macro> </macro>
<macro name='LIBXML_VERSION' file='xmlversion'> <macro name='LIBXML_VERSION' file='xmlversion'>
<info>the version number: 1.2.3 value is 1002003</info> <info>the version number: 1.2.3 value is 1002003</info>
@ -2452,6 +2458,7 @@
<macro name='WITH_TRIO' file='xmlversion'> <macro name='WITH_TRIO' file='xmlversion'>
</macro> </macro>
<macro name='XMLCALL' file='xmlexports'> <macro name='XMLCALL' file='xmlexports'>
<info>Macros which declare the called convention for exported functions Windows platform with MS compiler Windows platform with Borland compiler Windows platform with GNU compiler (Mingw) Cygwin platform, GNU compiler</info>
</macro> </macro>
<macro name='XMLPUBFUN' file='xmlexports'> <macro name='XMLPUBFUN' file='xmlexports'>
</macro> </macro>
@ -2561,8 +2568,6 @@
<info>Macro to raise an XPath error and return 0.</info> <info>Macro to raise an XPath error and return 0.</info>
<arg name='X' info='the error code'/> <arg name='X' info='the error code'/>
</macro> </macro>
<macro name='_DEBUG_MEMORY_ALLOC_' file='xmlmemory'>
</macro>
<macro name='_REENTRANT' file='xmlexports'> <macro name='_REENTRANT' file='xmlexports'>
</macro> </macro>
<macro name='htmlDefaultSubelement' file='HTMLparser'> <macro name='htmlDefaultSubelement' file='HTMLparser'>
@ -3316,9 +3321,9 @@ actually an xmlCharEncoding'/>
<struct name='xmlGlobalState' file='globals' type='struct _xmlGlobalState'> <struct name='xmlGlobalState' file='globals' type='struct _xmlGlobalState'>
<field name='xmlParserVersion' type='const char *' info=''/> <field name='xmlParserVersion' type='const char *' info=''/>
<field name='xmlDefaultSAXLocator' type='xmlSAXLocator' info=''/> <field name='xmlDefaultSAXLocator' type='xmlSAXLocator' info=''/>
<field name='xmlDefaultSAXHandler' type='xmlSAXHandler' info=''/> <field name='xmlDefaultSAXHandler' type='xmlSAXHandlerV1' info=''/>
<field name='docbDefaultSAXHandler' type='xmlSAXHandler' info=''/> <field name='docbDefaultSAXHandler' type='xmlSAXHandlerV1' info=''/>
<field name='htmlDefaultSAXHandler' type='xmlSAXHandler' info=''/> <field name='htmlDefaultSAXHandler' type='xmlSAXHandlerV1' info=''/>
<field name='xmlFree' type='xmlFreeFunc' info=''/> <field name='xmlFree' type='xmlFreeFunc' info=''/>
<field name='xmlMalloc' type='xmlMallocFunc' info=''/> <field name='xmlMalloc' type='xmlMallocFunc' info=''/>
<field name='xmlMemStrdup' type='xmlStrdupFunc' info=''/> <field name='xmlMemStrdup' type='xmlStrdupFunc' info=''/>
@ -3610,6 +3615,37 @@ actually an xmlCharEncoding'/>
<field name='endElementNs' type='endElementNsSAX2Func' info=''/> <field name='endElementNs' type='endElementNsSAX2Func' info=''/>
</struct> </struct>
<typedef name='xmlSAXHandlerPtr' file='tree' type='xmlSAXHandler *'/> <typedef name='xmlSAXHandlerPtr' file='tree' type='xmlSAXHandler *'/>
<struct name='xmlSAXHandlerV1' file='SAX' type='struct _xmlSAXHandlerV1'>
<field name='internalSubset' type='internalSubsetSAXFunc' info=''/>
<field name='isStandalone' type='isStandaloneSAXFunc' info=''/>
<field name='hasInternalSubset' type='hasInternalSubsetSAXFunc' info=''/>
<field name='hasExternalSubset' type='hasExternalSubsetSAXFunc' info=''/>
<field name='resolveEntity' type='resolveEntitySAXFunc' info=''/>
<field name='getEntity' type='getEntitySAXFunc' info=''/>
<field name='entityDecl' type='entityDeclSAXFunc' info=''/>
<field name='notationDecl' type='notationDeclSAXFunc' info=''/>
<field name='attributeDecl' type='attributeDeclSAXFunc' info=''/>
<field name='elementDecl' type='elementDeclSAXFunc' info=''/>
<field name='unparsedEntityDecl' type='unparsedEntityDeclSAXFunc' info=''/>
<field name='setDocumentLocator' type='setDocumentLocatorSAXFunc' info=''/>
<field name='startDocument' type='startDocumentSAXFunc' info=''/>
<field name='endDocument' type='endDocumentSAXFunc' info=''/>
<field name='startElement' type='startElementSAXFunc' info=''/>
<field name='endElement' type='endElementSAXFunc' info=''/>
<field name='reference' type='referenceSAXFunc' info=''/>
<field name='characters' type='charactersSAXFunc' info=''/>
<field name='ignorableWhitespace' type='ignorableWhitespaceSAXFunc' info=''/>
<field name='processingInstruction' type='processingInstructionSAXFunc' info=''/>
<field name='comment' type='commentSAXFunc' info=''/>
<field name='warning' type='warningSAXFunc' info=''/>
<field name='error' type='errorSAXFunc' info=''/>
<field name='fatalError' type='fatalErrorSAXFunc' info=' unused error() get all the errors'/>
<field name='getParameterEntity' type='getParameterEntitySAXFunc' info=''/>
<field name='cdataBlock' type='cdataBlockSAXFunc' info=''/>
<field name='externalSubset' type='externalSubsetSAXFunc' info=''/>
<field name='initialized' type='unsigned int' info=''/>
</struct>
<typedef name='xmlSAXHandlerV1Ptr' file='SAX' type='xmlSAXHandlerV1 *'/>
<struct name='xmlSAXLocator' file='tree' type='struct _xmlSAXLocator'> <struct name='xmlSAXLocator' file='tree' type='struct _xmlSAXLocator'>
<field name='getPublicId' type='const xmlChar *(*getPublicId)' info=''/> <field name='getPublicId' type='const xmlChar *(*getPublicId)' info=''/>
<field name='getSystemId' type='const xmlChar *(*getSystemId)' info=''/> <field name='getSystemId' type='const xmlChar *(*getSystemId)' info=''/>
@ -3879,12 +3915,12 @@ actually an xmlCharEncoding'/>
<field name='value' type='xmlXPathObjectPtr' info=' the value'/> <field name='value' type='xmlXPathObjectPtr' info=' the value'/>
</struct> </struct>
<typedef name='xmlXPathVariablePtr' file='xpath' type='xmlXPathVariable *'/> <typedef name='xmlXPathVariablePtr' file='xpath' type='xmlXPathVariable *'/>
<variable name='docbDefaultSAXHandler' file='globals' type='xmlSAXHandler'/> <variable name='docbDefaultSAXHandler' file='globals' type='xmlSAXHandlerV1'/>
<variable name='htmlDefaultSAXHandler' file='globals' type='xmlSAXHandler'/> <variable name='htmlDefaultSAXHandler' file='globals' type='xmlSAXHandlerV1'/>
<variable name='oldXMLWDcompatibility' file='globals' type='int'/> <variable name='oldXMLWDcompatibility' file='globals' type='int'/>
<variable name='xmlBufferAllocScheme' file='globals' type='xmlBufferAllocationScheme'/> <variable name='xmlBufferAllocScheme' file='globals' type='xmlBufferAllocationScheme'/>
<variable name='xmlDefaultBufferSize' file='globals' type='int'/> <variable name='xmlDefaultBufferSize' file='globals' type='int'/>
<variable name='xmlDefaultSAXHandler' file='globals' type='xmlSAXHandler'/> <variable name='xmlDefaultSAXHandler' file='globals' type='xmlSAXHandlerV1'/>
<variable name='xmlDefaultSAXLocator' file='globals' type='xmlSAXLocator'/> <variable name='xmlDefaultSAXLocator' file='globals' type='xmlSAXLocator'/>
<variable name='xmlDeregisterNodeDefaultValue' file='globals' type='xmlDeregisterNodeFunc'/> <variable name='xmlDeregisterNodeDefaultValue' file='globals' type='xmlDeregisterNodeFunc'/>
<variable name='xmlDoValidityCheckingDefaultValue' file='globals' type='int'/> <variable name='xmlDoValidityCheckingDefaultValue' file='globals' type='int'/>
@ -4584,17 +4620,17 @@ actually an xmlCharEncoding'/>
<function name='initdocbDefaultSAXHandler' file='SAX'> <function name='initdocbDefaultSAXHandler' file='SAX'>
<info>Initialize the default DocBook SAX version 1 handler DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks</info> <info>Initialize the default DocBook SAX version 1 handler DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks</info>
<return type='void'/> <return type='void'/>
<arg name='hdlr' type='xmlSAXHandler *' info='the SAX handler'/> <arg name='hdlr' type='xmlSAXHandlerV1 *' info='the SAX handler'/>
</function> </function>
<function name='inithtmlDefaultSAXHandler' file='SAX'> <function name='inithtmlDefaultSAXHandler' file='SAX'>
<info>Initialize the default HTML SAX version 1 handler DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks</info> <info>Initialize the default HTML SAX version 1 handler DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks</info>
<return type='void'/> <return type='void'/>
<arg name='hdlr' type='xmlSAXHandler *' info='the SAX handler'/> <arg name='hdlr' type='xmlSAXHandlerV1 *' info='the SAX handler'/>
</function> </function>
<function name='initxmlDefaultSAXHandler' file='SAX'> <function name='initxmlDefaultSAXHandler' file='SAX'>
<info>Initialize the default XML SAX version 1 handler DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks</info> <info>Initialize the default XML SAX version 1 handler DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks</info>
<return type='void'/> <return type='void'/>
<arg name='hdlr' type='xmlSAXHandler *' info='the SAX handler'/> <arg name='hdlr' type='xmlSAXHandlerV1 *' info='the SAX handler'/>
<arg name='warning' type='int' info='flag if non-zero sets the handler warning procedure'/> <arg name='warning' type='int' info='flag if non-zero sets the handler warning procedure'/>
</function> </function>
<function name='inputPop' file='parserInternals'> <function name='inputPop' file='parserInternals'>
@ -6515,13 +6551,13 @@ actually an xmlCharEncoding'/>
<arg name='name' type='const xmlChar *' info='the name of the userdata'/> <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
</function> </function>
<function name='xmlHashQLookup2' file='hash'> <function name='xmlHashQLookup2' file='hash'>
<info></info> <info>Find the userdata specified by the QNames tuple</info>
<return type='void *' info=''/> <return type='void *' info='the pointer to the userdata'/>
<arg name='table' type='xmlHashTablePtr' info=''/> <arg name='table' type='xmlHashTablePtr' info='the hash table'/>
<arg name='prefix' type='const xmlChar *' info=''/> <arg name='prefix' type='const xmlChar *' info='the second prefix of the userdata'/>
<arg name='name' type='const xmlChar *' info=''/> <arg name='name' type='const xmlChar *' info='the name of the userdata'/>
<arg name='prefix2' type='const xmlChar *' info=''/> <arg name='prefix2' type='const xmlChar *' info=''/>
<arg name='name2' type='const xmlChar *' info=''/> <arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
</function> </function>
<function name='xmlHashQLookup3' file='hash'> <function name='xmlHashQLookup3' file='hash'>
<info>Find the userdata specified by the (@name, @name2, @name3) tuple.</info> <info>Find the userdata specified by the (@name, @name2, @name3) tuple.</info>
@ -8941,8 +8977,8 @@ actually an xmlCharEncoding'/>
<arg name='URI' type='const xmlChar *' info='the element namespace name if available'/> <arg name='URI' type='const xmlChar *' info='the element namespace name if available'/>
<arg name='nb_namespaces' type='int' info='number of namespace definitions on that node'/> <arg name='nb_namespaces' type='int' info='number of namespace definitions on that node'/>
<arg name='namespaces' type='const xmlChar **' info='pointer to the array of prefix/URI pairs namespace definitions'/> <arg name='namespaces' type='const xmlChar **' info='pointer to the array of prefix/URI pairs namespace definitions'/>
<arg name='nb_attributes' type='int' info='the number of attributes on that node nb_defaulted: the number of defaulted attributes.'/> <arg name='nb_attributes' type='int' info='the number of attributes on that node'/>
<arg name='nb_defaulted' type='int' info=''/> <arg name='nb_defaulted' type='int' info='the number of defaulted attributes.'/>
<arg name='attributes' type='const xmlChar **' info='pointer to the array of (localname/prefix/URI/value/end) attribute values.'/> <arg name='attributes' type='const xmlChar **' info='pointer to the array of (localname/prefix/URI/value/end) attribute values.'/>
</function> </function>
<function name='xmlSAX2UnparsedEntityDecl' file='SAX2'> <function name='xmlSAX2UnparsedEntityDecl' file='SAX2'>
@ -9573,15 +9609,15 @@ actually an xmlCharEncoding'/>
<arg name='value' type='const xmlChar *' info='the value of the attribute'/> <arg name='value' type='const xmlChar *' info='the value of the attribute'/>
</function> </function>
<function name='xmlStringLenDecodeEntities' file='parserInternals'> <function name='xmlStringLenDecodeEntities' file='parserInternals'>
<info></info> <info>Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= &apos;%&apos; Name &apos;;&apos;</info>
<return type='xmlChar *' info=''/> <return type='xmlChar *' info='A newly allocated string with the substitution done. The caller must deallocate it !'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info=''/> <arg name='ctxt' type='xmlParserCtxtPtr' info='the parser context'/>
<arg name='str' type='const xmlChar *' info=''/> <arg name='str' type='const xmlChar *' info='the input string'/>
<arg name='len' type='int' info=''/> <arg name='len' type='int' info='the string length'/>
<arg name='what' type='int' info=''/> <arg name='what' type='int' info='combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF'/>
<arg name='end' type='xmlChar' info=''/> <arg name='end' type='xmlChar' info='an end marker xmlChar, 0 if none'/>
<arg name='end2' type='xmlChar' info=''/> <arg name='end2' type='xmlChar' info='an end marker xmlChar, 0 if none'/>
<arg name='end3' type='xmlChar' info=''/> <arg name='end3' type='xmlChar' info='an end marker xmlChar, 0 if none'/>
</function> </function>
<function name='xmlStringLenGetNodeList' file='tree'> <function name='xmlStringLenGetNodeList' file='tree'>
<info>Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.</info> <info>Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.</info>
@ -9712,9 +9748,9 @@ actually an xmlCharEncoding'/>
<arg name='str' type='const xmlChar *' info='the string to intern.'/> <arg name='str' type='const xmlChar *' info='the string to intern.'/>
</function> </function>
<function name='xmlTextReaderConstXmlLang' file='xmlreader'> <function name='xmlTextReaderConstXmlLang' file='xmlreader'>
<info></info> <info>The xml:lang scope within which the node resides.</info>
<return type='const xmlChar *' info=''/> <return type='const xmlChar *' info='the xml:lang value or NULL if none exists.'/>
<arg name='reader' type='xmlTextReaderPtr' info=''/> <arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function> </function>
<function name='xmlTextReaderCurrentDoc' file='xmlreader'> <function name='xmlTextReaderCurrentDoc' file='xmlreader'>
<info>Hacking interface allowing to get the xmlDocPtr correponding to the current document being accessed by the xmlTextReader. This is dangerous because the associated node may be destroyed on the next Reads.</info> <info>Hacking interface allowing to get the xmlDocPtr correponding to the current document being accessed by the xmlTextReader. This is dangerous because the associated node may be destroyed on the next Reads.</info>

View File

@ -62,7 +62,7 @@ void xmlCleanupGlobals()
* Memory allocation routines * Memory allocation routines
*/ */
#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY) #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
#ifndef _DEBUG_MEMORY_ALLOC_ #ifndef __DEBUG_MEMORY_ALLOC__
extern void xmlMemFree(void *ptr); extern void xmlMemFree(void *ptr);
extern void * xmlMemMalloc(size_t size); extern void * xmlMemMalloc(size_t size);
extern void * xmlMemRealloc(void *ptr,size_t size); extern void * xmlMemRealloc(void *ptr,size_t size);
@ -328,9 +328,9 @@ int xmlSaveNoEmptyTagsThrDef = 0;
/** /**
* xmlDefaultSAXHandler: * xmlDefaultSAXHandler:
* *
* Default handler for XML, builds the DOM tree * Default SAX version1 handler for XML, builds the DOM tree
*/ */
xmlSAXHandler xmlDefaultSAXHandler = { xmlSAXHandlerV1 xmlDefaultSAXHandler = {
xmlSAX2InternalSubset, xmlSAX2InternalSubset,
xmlSAX2IsStandalone, xmlSAX2IsStandalone,
xmlSAX2HasInternalSubset, xmlSAX2HasInternalSubset,
@ -359,9 +359,6 @@ xmlSAXHandler xmlDefaultSAXHandler = {
xmlSAX2CDataBlock, xmlSAX2CDataBlock,
xmlSAX2ExternalSubset, xmlSAX2ExternalSubset,
0, 0,
NULL,
NULL,
NULL
}; };
/** /**
@ -381,9 +378,9 @@ xmlSAXLocator xmlDefaultSAXLocator = {
/** /**
* htmlDefaultSAXHandler: * htmlDefaultSAXHandler:
* *
* Default handler for HTML, builds the DOM tree * Default old SAX v1 handler for HTML, builds the DOM tree
*/ */
xmlSAXHandler htmlDefaultSAXHandler = { xmlSAXHandlerV1 htmlDefaultSAXHandler = {
xmlSAX2InternalSubset, xmlSAX2InternalSubset,
NULL, NULL,
NULL, NULL,
@ -412,9 +409,6 @@ xmlSAXHandler htmlDefaultSAXHandler = {
xmlSAX2CDataBlock, xmlSAX2CDataBlock,
NULL, NULL,
0, 0,
NULL,
NULL,
NULL
}; };
#endif /* LIBXML_HTML_ENABLED */ #endif /* LIBXML_HTML_ENABLED */
@ -422,9 +416,9 @@ xmlSAXHandler htmlDefaultSAXHandler = {
/** /**
* docbDefaultSAXHandler: * docbDefaultSAXHandler:
* *
* Default handler for SGML DocBook, builds the DOM tree * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
*/ */
xmlSAXHandler docbDefaultSAXHandler = { xmlSAXHandlerV1 docbDefaultSAXHandler = {
xmlSAX2InternalSubset, xmlSAX2InternalSubset,
xmlSAX2IsStandalone, xmlSAX2IsStandalone,
xmlSAX2HasInternalSubset, xmlSAX2HasInternalSubset,
@ -453,9 +447,6 @@ xmlSAXHandler docbDefaultSAXHandler = {
NULL, NULL,
NULL, NULL,
0, 0,
NULL,
NULL,
NULL
}; };
#endif /* LIBXML_DOCB_ENABLED */ #endif /* LIBXML_DOCB_ENABLED */
@ -483,16 +474,16 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
xmlMutexLock(xmlThrDefMutex); xmlMutexLock(xmlThrDefMutex);
#ifdef LIBXML_DOCB_ENABLED #ifdef LIBXML_DOCB_ENABLED
xmlSAX2InitDocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
#endif #endif
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
xmlSAX2InitHtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
#endif #endif
gs->oldXMLWDcompatibility = 0; gs->oldXMLWDcompatibility = 0;
gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
xmlSAX2InitDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
gs->xmlDefaultSAXLocator.getPublicId = getPublicId; gs->xmlDefaultSAXLocator.getPublicId = getPublicId;
gs->xmlDefaultSAXLocator.getSystemId = getSystemId; gs->xmlDefaultSAXLocator.getSystemId = getSystemId;
gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber; gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber;
@ -613,7 +604,7 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
#ifdef LIBXML_DOCB_ENABLED #ifdef LIBXML_DOCB_ENABLED
#undef docbDefaultSAXHandler #undef docbDefaultSAXHandler
xmlSAXHandler * xmlSAXHandlerV1 *
__docbDefaultSAXHandler(void) { __docbDefaultSAXHandler(void) {
if (IS_MAIN_THREAD) if (IS_MAIN_THREAD)
return (&docbDefaultSAXHandler); return (&docbDefaultSAXHandler);
@ -624,7 +615,7 @@ __docbDefaultSAXHandler(void) {
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
#undef htmlDefaultSAXHandler #undef htmlDefaultSAXHandler
xmlSAXHandler * xmlSAXHandlerV1 *
__htmlDefaultSAXHandler(void) { __htmlDefaultSAXHandler(void) {
if (IS_MAIN_THREAD) if (IS_MAIN_THREAD)
return (&htmlDefaultSAXHandler); return (&htmlDefaultSAXHandler);
@ -684,7 +675,7 @@ int xmlThrDefDefaultBufferSize(int v) {
} }
#undef xmlDefaultSAXHandler #undef xmlDefaultSAXHandler
xmlSAXHandler * xmlSAXHandlerV1 *
__xmlDefaultSAXHandler(void) { __xmlDefaultSAXHandler(void) {
if (IS_MAIN_THREAD) if (IS_MAIN_THREAD)
return (&xmlDefaultSAXHandler); return (&xmlDefaultSAXHandler);

2
hash.c
View File

@ -427,7 +427,7 @@ xmlHashQLookup(xmlHashTablePtr table, const xmlChar *prefix,
* @table: the hash table * @table: the hash table
* @prefix: the prefix of the userdata * @prefix: the prefix of the userdata
* @name: the name of the userdata * @name: the name of the userdata
* @prefix: the second prefix of the userdata * @prefix2: the second prefix of the userdata
* @name2: a second name of the userdata * @name2: a second name of the userdata
* *
* Find the userdata specified by the QNames tuple * Find the userdata specified by the QNames tuple

View File

@ -1,5 +1,5 @@
/* /*
* SAX.h : Default SAX handler interfaces. * SAX.h : Old SAX vewrsion1 handler interfaces.
* *
* See Copyright for the status of this software. * See Copyright for the status of this software.
* *
@ -19,6 +19,39 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
struct _xmlSAXHandlerV1 {
internalSubsetSAXFunc internalSubset;
isStandaloneSAXFunc isStandalone;
hasInternalSubsetSAXFunc hasInternalSubset;
hasExternalSubsetSAXFunc hasExternalSubset;
resolveEntitySAXFunc resolveEntity;
getEntitySAXFunc getEntity;
entityDeclSAXFunc entityDecl;
notationDeclSAXFunc notationDecl;
attributeDeclSAXFunc attributeDecl;
elementDeclSAXFunc elementDecl;
unparsedEntityDeclSAXFunc unparsedEntityDecl;
setDocumentLocatorSAXFunc setDocumentLocator;
startDocumentSAXFunc startDocument;
endDocumentSAXFunc endDocument;
startElementSAXFunc startElement;
endElementSAXFunc endElement;
referenceSAXFunc reference;
charactersSAXFunc characters;
ignorableWhitespaceSAXFunc ignorableWhitespace;
processingInstructionSAXFunc processingInstruction;
commentSAXFunc comment;
warningSAXFunc warning;
errorSAXFunc error;
fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
getParameterEntitySAXFunc getParameterEntity;
cdataBlockSAXFunc cdataBlock;
externalSubsetSAXFunc externalSubset;
unsigned int initialized;
};
XMLPUBFUN const xmlChar * XMLCALL XMLPUBFUN const xmlChar * XMLCALL
getPublicId (void *ctx); getPublicId (void *ctx);
XMLPUBFUN const xmlChar * XMLCALL XMLPUBFUN const xmlChar * XMLCALL
@ -147,15 +180,15 @@ XMLPUBFUN void XMLCALL
int len); int len);
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
initxmlDefaultSAXHandler (xmlSAXHandler *hdlr, initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
int warning); int warning);
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
inithtmlDefaultSAXHandler (xmlSAXHandler *hdlr); inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif #endif
#ifdef LIBXML_DOCB_ENABLED #ifdef LIBXML_DOCB_ENABLED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
initdocbDefaultSAXHandler (xmlSAXHandler *hdlr); initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -16,6 +16,7 @@
#include <libxml/xmlversion.h> #include <libxml/xmlversion.h>
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/SAX.h>
#include <libxml/SAX2.h> #include <libxml/SAX2.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
@ -70,9 +71,9 @@ struct _xmlGlobalState
const char *xmlParserVersion; const char *xmlParserVersion;
xmlSAXLocator xmlDefaultSAXLocator; xmlSAXLocator xmlDefaultSAXLocator;
xmlSAXHandler xmlDefaultSAXHandler; xmlSAXHandlerV1 xmlDefaultSAXHandler;
xmlSAXHandler docbDefaultSAXHandler; xmlSAXHandlerV1 docbDefaultSAXHandler;
xmlSAXHandler htmlDefaultSAXHandler; xmlSAXHandlerV1 htmlDefaultSAXHandler;
xmlFreeFunc xmlFree; xmlFreeFunc xmlFree;
xmlMallocFunc xmlMalloc; xmlMallocFunc xmlMalloc;
@ -183,22 +184,22 @@ XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
#endif /* LIBXML_THREAD_ALLOC_ENABLED */ #endif /* LIBXML_THREAD_ALLOC_ENABLED */
#ifdef LIBXML_DOCB_ENABLED #ifdef LIBXML_DOCB_ENABLED
XMLPUBFUN xmlSAXHandler * XMLCALL __docbDefaultSAXHandler(void); XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
#ifdef LIBXML_THREAD_ENABLED #ifdef LIBXML_THREAD_ENABLED
#define docbDefaultSAXHandler \ #define docbDefaultSAXHandler \
(*(__docbDefaultSAXHandler())) (*(__docbDefaultSAXHandler()))
#else #else
XMLPUBVAR xmlSAXHandler docbDefaultSAXHandler; XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
#endif #endif
#endif #endif
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
XMLPUBFUN xmlSAXHandler * XMLCALL __htmlDefaultSAXHandler(void); XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
#ifdef LIBXML_THREAD_ENABLED #ifdef LIBXML_THREAD_ENABLED
#define htmlDefaultSAXHandler \ #define htmlDefaultSAXHandler \
(*(__htmlDefaultSAXHandler())) (*(__htmlDefaultSAXHandler()))
#else #else
XMLPUBVAR xmlSAXHandler htmlDefaultSAXHandler; XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
#endif #endif
#endif #endif
@ -236,12 +237,12 @@ XMLPUBVAR int xmlDefaultBufferSize;
#endif #endif
XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v);
XMLPUBFUN xmlSAXHandler * XMLCALL __xmlDefaultSAXHandler(void); XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);
#ifdef LIBXML_THREAD_ENABLED #ifdef LIBXML_THREAD_ENABLED
#define xmlDefaultSAXHandler \ #define xmlDefaultSAXHandler \
(*(__xmlDefaultSAXHandler())) (*(__xmlDefaultSAXHandler()))
#else #else
XMLPUBVAR xmlSAXHandler xmlDefaultSAXHandler; XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
#endif #endif
XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void);

View File

@ -3491,6 +3491,8 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
} }
COPY_BUF(l,buf,nbchar,cur); COPY_BUF(l,buf,nbchar,cur);
if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) { if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) {
buf[nbchar] = 0;
/* /*
* OK the segment is to be consumed as chars. * OK the segment is to be consumed as chars.
*/ */
@ -3515,6 +3517,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
cur = CUR_CHAR(l); cur = CUR_CHAR(l);
} }
if (nbchar != 0) { if (nbchar != 0) {
buf[nbchar] = 0;
/* /*
* OK the segment is to be consumed as chars. * OK the segment is to be consumed as chars.
*/ */
@ -10092,7 +10095,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(NULL); return(NULL);
} }
if (sax != NULL) { if (sax != NULL) {
if (ctxt->sax != &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler)); ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
if (ctxt->sax == NULL) { if (ctxt->sax == NULL) {
@ -10185,7 +10188,7 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(NULL); return(NULL);
} }
if (sax != NULL) { if (sax != NULL) {
if (ctxt->sax != &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler)); ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
if (ctxt->sax == NULL) { if (ctxt->sax == NULL) {
@ -11506,7 +11509,7 @@ xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data,
ctxt = xmlCreateFileParserCtxt(filename); ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) return -1; if (ctxt == NULL) return -1;
if (ctxt->sax != &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
ctxt->sax = sax; ctxt->sax = sax;
xmlDetectSAX2(ctxt); xmlDetectSAX2(ctxt);

View File

@ -2219,7 +2219,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
return(-1); return(-1);
} }
else else
memcpy(ctxt->sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler)); xmlSAXVersion(ctxt->sax, 2);
ctxt->maxatts = 0; ctxt->maxatts = 0;
ctxt->atts = NULL; ctxt->atts = NULL;
@ -2371,7 +2371,8 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding); if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding);
if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI); if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI);
if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem); if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem);
if ((ctxt->sax != NULL) && (ctxt->sax != &xmlDefaultSAXHandler)) if ((ctxt->sax != NULL) &&
(ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler))
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory); if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory);
if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab); if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);

View File

@ -75,7 +75,10 @@ xmlSAXHandler emptySAXHandlerStruct = {
NULL, /* getParameterEntity */ NULL, /* getParameterEntity */
NULL, /* cdataBlock */ NULL, /* cdataBlock */
NULL, /* externalSubset */ NULL, /* externalSubset */
1 1,
NULL,
NULL,
NULL
}; };
xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
@ -595,7 +598,10 @@ xmlSAXHandler debugSAXHandlerStruct = {
getParameterEntityDebug, getParameterEntityDebug,
cdataDebug, cdataDebug,
NULL, NULL,
1 1,
NULL,
NULL,
NULL
}; };
xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;

View File

@ -143,348 +143,6 @@ static const char *xmlTextReaderIsEmpty = "This element is empty";
#define CONSTSTR(str) xmlDictLookup(reader->ctxt->dict, (str), -1) #define CONSTSTR(str) xmlDictLookup(reader->ctxt->dict, (str), -1)
#define CONSTQSTR(p, str) xmlDictQLookup(reader->ctxt->dict, (p), (str)) #define CONSTQSTR(p, str) xmlDictQLookup(reader->ctxt->dict, (p), (str))
/************************************************************************
* *
* Our own version of the freeing routines as we recycle nodes *
* *
************************************************************************/
static void xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur);
static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur);
/**
* xmlTextReaderFreeEntityWrapper:
* @entity: An entity
* @name: its name
*
* Deallocate the memory used by an entities in the hash table.
*/
static void
xmlTextReaderFreeEntityWrapper(xmlEntityPtr entity,
const xmlChar *name ATTRIBUTE_UNUSED) {
if (entity == NULL) return;
if ((entity->children) && (entity->owner == 1) &&
(entity == (xmlEntityPtr) entity->children->parent)) {
xmlDocPtr doc;
xmlTextReaderPtr reader = NULL;
doc = entity->doc;
if (doc != NULL)
reader = doc->_private;
xmlTextReaderFreeNodeList(reader, entity->children);
}
if (entity->name != NULL)
xmlFree((char *) entity->name);
if (entity->ExternalID != NULL)
xmlFree((char *) entity->ExternalID);
if (entity->SystemID != NULL)
xmlFree((char *) entity->SystemID);
if (entity->URI != NULL)
xmlFree((char *) entity->URI);
if (entity->content != NULL)
xmlFree((char *) entity->content);
if (entity->orig != NULL)
xmlFree((char *) entity->orig);
xmlFree(entity);
}
/**
* xmlTextReaderFreeEntitiesTable:
* @table: An entity table
*
* Deallocate the memory used by an entities hash table.
*/
static void
xmlTextReaderFreeEntitiesTable(xmlEntitiesTablePtr table) {
xmlHashFree(table, (xmlHashDeallocator) xmlTextReaderFreeEntityWrapper);
}
/**
* xmlTextReaderFreeDtd:
* @cur: the DTD structure to free up
*
* Free a DTD structure.
*/
static void
xmlTextReaderFreeDtd(xmlTextReaderPtr reader, xmlDtdPtr cur) {
if (cur == NULL) return;
if (cur->children != NULL) {
xmlNodePtr next, c = cur->children;
/*
* Cleanup all the DTD comments they are not in the DTD
* indexes.
*/
while (c != NULL) {
next = c->next;
if ((c->type == XML_COMMENT_NODE) || (c->type == XML_PI_NODE)) {
xmlUnlinkNode(c);
xmlTextReaderFreeNode(reader, c);
}
c = next;
}
}
if (cur->name != NULL) xmlFree((char *) cur->name);
if (cur->SystemID != NULL) xmlFree((char *) cur->SystemID);
if (cur->ExternalID != NULL) xmlFree((char *) cur->ExternalID);
/* TODO !!! */
if (cur->notations != NULL)
xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
if (cur->elements != NULL)
xmlFreeElementTable((xmlElementTablePtr) cur->elements);
if (cur->attributes != NULL)
xmlFreeAttributeTable((xmlAttributeTablePtr) cur->attributes);
if (cur->pentities != NULL)
xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->pentities);
if (cur->entities != NULL)
xmlTextReaderFreeEntitiesTable((xmlEntitiesTablePtr) cur->entities);
xmlFree(cur);
}
/**
* xmlTextReaderFreeProp:
* @reader: the xmlTextReaderPtr used
* @cur: the node
*
* Free a node.
*/
static void
xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
if (cur == NULL) return;
/* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL) &&
((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL))) {
if (xmlIsID(cur->parent->doc, cur->parent, cur))
xmlRemoveID(cur->parent->doc, cur);
}
if (cur->children != NULL)
xmlTextReaderFreeNodeList(reader, cur->children);
if ((reader != NULL) && (reader->ctxt != NULL) &&
(xmlDictOwns(reader->ctxt->dict, cur->name) != 1) &&
(cur->name != NULL))
xmlFree((xmlChar *)cur->name);
if ((reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeAttrsNr < 100)) {
cur->next = reader->ctxt->freeAttrs;
reader->ctxt->freeAttrs = cur;
reader->ctxt->freeAttrsNr++;
} else {
xmlFree(cur);
}
}
/**
* xmlTextReaderFreePropList:
* @reader: the xmlTextReaderPtr used
* @cur: the first property in the list
*
* Free a property and all its siblings, all the children are freed too.
*/
static void
xmlTextReaderFreePropList(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlAttrPtr next;
if (cur == NULL) return;
while (cur != NULL) {
next = cur->next;
xmlTextReaderFreeProp(reader, cur);
cur = next;
}
}
/**
* xmlTextReaderFreeNodeList:
* @reader: the xmlTextReaderPtr used
* @cur: the first node in the list
*
* Free a node and all its siblings, this is a recursive behaviour, all
* the children are freed too.
*/
static void
xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlNodePtr next;
if (cur == NULL) return;
if (cur->type == XML_NAMESPACE_DECL) {
xmlFreeNsList((xmlNsPtr) cur);
return;
}
if ((cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
xmlFreeDoc((xmlDocPtr) cur);
return;
}
while (cur != NULL) {
next = cur->next;
/* unroll to speed up freeing the document */
if (cur->type != XML_DTD_NODE) {
if ((cur->children != NULL) &&
(cur->type != XML_ENTITY_REF_NODE))
xmlTextReaderFreeNodeList(reader, cur->children);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->properties != NULL))
xmlTextReaderFreePropList(reader, cur->properties);
if ((cur->type != XML_ELEMENT_NODE) &&
(cur->type != XML_XINCLUDE_START) &&
(cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_ENTITY_REF_NODE)) {
if (cur->content != NULL) xmlFree(cur->content);
}
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->nsDef != NULL))
xmlFreeNsList(cur->nsDef);
/*
* we don't free element names here they are interned now
*/
if (cur->type == XML_ELEMENT_NODE) {
if ((reader != NULL) && (reader->ctxt != NULL) &&
(xmlDictOwns(reader->ctxt->dict, cur->name) != 1) &&
(cur->name != NULL))
xmlFree((xmlChar *)cur->name);
} else if ((cur->type != XML_TEXT_NODE) &&
(cur->type != XML_COMMENT_NODE) &&
(cur->name != NULL))
xmlFree((xmlChar *)cur->name);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE)) &&
(reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeElemsNr < 100)) {
cur->next = reader->ctxt->freeElems;
reader->ctxt->freeElems = cur;
reader->ctxt->freeElemsNr++;
} else {
xmlFree(cur);
}
}
cur = next;
}
}
/**
* xmlTextReaderFreeNode:
* @reader: the xmlTextReaderPtr used
* @cur: the node
*
* Free a node, this is a recursive behaviour, all the children are freed too.
* This doesn't unlink the child from the list, use xmlUnlinkNode() first.
*/
static void
xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
if (cur->type == XML_DTD_NODE) {
xmlTextReaderFreeDtd(reader, (xmlDtdPtr) cur);
return;
}
if (cur->type == XML_NAMESPACE_DECL) {
xmlFreeNs((xmlNsPtr) cur);
return;
}
if (cur->type == XML_ATTRIBUTE_NODE) {
xmlTextReaderFreeProp(reader, (xmlAttrPtr) cur);
return;
}
if ((cur->children != NULL) &&
(cur->type != XML_ENTITY_REF_NODE))
xmlTextReaderFreeNodeList(reader, cur->children);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->properties != NULL))
xmlTextReaderFreePropList(reader, cur->properties);
if ((cur->type != XML_ELEMENT_NODE) &&
(cur->type != XML_XINCLUDE_START) &&
(cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_ENTITY_REF_NODE)) {
if (cur->content != NULL) xmlFree(cur->content);
}
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
(cur->nsDef != NULL))
xmlFreeNsList(cur->nsDef);
/*
* we don't free names here they are interned now
*/
if (cur->type == XML_ELEMENT_NODE) {
if ((reader != NULL) && (reader->ctxt != NULL) &&
(xmlDictOwns(reader->ctxt->dict, cur->name) != 1) &&
(cur->name != NULL))
xmlFree((xmlChar *)cur->name);
} else if ((cur->type != XML_TEXT_NODE) &&
(cur->type != XML_COMMENT_NODE) &&
(cur->name != NULL))
xmlFree((xmlChar *)cur->name);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE)) &&
(reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeElemsNr < 100)) {
cur->next = reader->ctxt->freeElems;
reader->ctxt->freeElems = cur;
reader->ctxt->freeElemsNr++;
} else {
xmlFree(cur);
}
}
/**
* xmlTextReaderFreeDoc:
* @reader: the xmlTextReaderPtr used
* @cur: pointer to the document
*
* Free up all the structures used by a document, tree included.
*/
static void
xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
xmlDtdPtr extSubset, intSubset;
if (cur == NULL) return;
/*
* Do this before freeing the children list to avoid ID lookups
*/
if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
cur->ids = NULL;
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
cur->refs = NULL;
extSubset = cur->extSubset;
intSubset = cur->intSubset;
if (intSubset == extSubset)
extSubset = NULL;
if (extSubset != NULL) {
xmlUnlinkNode((xmlNodePtr) cur->extSubset);
cur->extSubset = NULL;
xmlTextReaderFreeDtd(reader, extSubset);
}
if (intSubset != NULL) {
xmlUnlinkNode((xmlNodePtr) cur->intSubset);
cur->intSubset = NULL;
xmlTextReaderFreeDtd(reader, intSubset);
}
if (cur->children != NULL) xmlTextReaderFreeNodeList(reader, cur->children);
if (cur->version != NULL) xmlFree((char *) cur->version);
if (cur->name != NULL) xmlFree((char *) cur->name);
if (cur->encoding != NULL) xmlFree((char *) cur->encoding);
if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs);
if (cur->URL != NULL) xmlFree((char *) cur->URL);
xmlFree(cur);
}
/************************************************************************ /************************************************************************
* * * *
* The reader core parser * * The reader core parser *