1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

legacy: Merge SAX.c into legacy.c

This commit is contained in:
Nick Wellnhofer 2024-06-16 19:16:47 +02:00
parent 1341deac13
commit 33a1f8978d
8 changed files with 100 additions and 146 deletions

View File

@ -276,7 +276,6 @@ set(
parserInternals.c
pattern.c
relaxng.c
SAX.c
SAX2.c
schematron.c
threads.c

View File

@ -62,9 +62,6 @@ libxml2_la_SOURCES += nanohttp.c
endif
if WITH_LEGACY_SOURCES
libxml2_la_SOURCES += legacy.c
if WITH_SAX1_SOURCES
libxml2_la_SOURCES += SAX.c
endif
endif
if WITH_LZMA_SOURCES
libxml2_la_SOURCES += xzlib.c

130
SAX.c
View File

@ -1,130 +0,0 @@
/*
* SAX.c : Old SAX v1 handlers to build a tree.
* Deprecated except for compatibility
*
* See Copyright for the status of this software.
*
* Daniel Veillard <daniel@veillard.com>
*/
#define IN_LIBXML
#include "libxml.h"
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/SAX.h>
#include <libxml/uri.h>
#include <libxml/valid.h>
#include <libxml/HTMLtree.h>
#include <libxml/SAX2.h>
#ifdef LIBXML_LEGACY_ENABLED
#ifdef LIBXML_SAX1_ENABLED
/**
* initxmlDefaultSAXHandler:
* @hdlr: the SAX handler
* @warning: flag if non-zero sets the handler warning procedure
*
* Initialize the default XML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
*/
void
initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = xmlSAX2ExternalSubset;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = xmlSAX2AttributeDecl;
hdlr->elementDecl = xmlSAX2ElementDecl;
hdlr->notationDecl = xmlSAX2NotationDecl;
hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2Characters;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
if (warning == 0)
hdlr->warning = NULL;
else
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#ifdef LIBXML_HTML_ENABLED
/**
* inithtmlDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default HTML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
*/
void
inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = NULL;
hdlr->hasInternalSubset = NULL;
hdlr->hasExternalSubset = NULL;
hdlr->resolveEntity = NULL;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = NULL;
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 = NULL;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#endif /* LIBXML_HTML_ENABLED */
#endif /* LIBXML_SAX1_ENABLED */
#endif /* LIBXML_LEGACY_ENABLED */

View File

@ -7607,14 +7607,14 @@ Could we use @subtypes for this?'/>
<return type='void'/>
<arg name='handler' type='xmlGenericErrorFunc *' info='the handler'/>
</function>
<function name='inithtmlDefaultSAXHandler' file='SAX' module='SAX'>
<cond>defined(LIBXML_LEGACY_ENABLED) &amp;&amp; defined(LIBXML_SAX1_ENABLED) &amp;&amp; defined(LIBXML_HTML_ENABLED)</cond>
<function name='inithtmlDefaultSAXHandler' file='SAX' module='legacy'>
<cond>defined(LIBXML_LEGACY_ENABLED)</cond>
<info>Initialize the default HTML SAX version 1 handler DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks</info>
<return type='void'/>
<arg name='hdlr' type='xmlSAXHandlerV1 *' info='the SAX handler'/>
</function>
<function name='initxmlDefaultSAXHandler' file='SAX' module='SAX'>
<cond>defined(LIBXML_LEGACY_ENABLED) &amp;&amp; defined(LIBXML_SAX1_ENABLED)</cond>
<function name='initxmlDefaultSAXHandler' file='SAX' module='legacy'>
<cond>defined(LIBXML_LEGACY_ENABLED)</cond>
<info>Initialize the default XML SAX version 1 handler DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks</info>
<return type='void'/>
<arg name='hdlr' type='xmlSAXHandlerV1 *' info='the SAX handler'/>

View File

@ -181,17 +181,13 @@ XMLPUBFUN void
const xmlChar *value,
int len);
#ifdef LIBXML_SAX1_ENABLED
XML_DEPRECATED
XMLPUBFUN void
initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
int warning);
#ifdef LIBXML_HTML_ENABLED
XML_DEPRECATED
XMLPUBFUN void
inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif
#endif /* LIBXML_SAX1_ENABLED */
#ifdef __cplusplus
}

View File

@ -17,6 +17,7 @@
#include <libxml/tree.h>
#include <libxml/entities.h>
#include <libxml/SAX.h>
#include <libxml/SAX2.h>
#include <libxml/parserInternals.h>
#include <libxml/HTMLparser.h>
@ -1350,6 +1351,98 @@ cdataBlock(void *ctx, const xmlChar * value, int len)
xmlSAX2CDataBlock(ctx, value, len);
}
/**
* initxmlDefaultSAXHandler:
* @hdlr: the SAX handler
* @warning: flag if non-zero sets the handler warning procedure
*
* Initialize the default XML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
*/
void
initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = xmlSAX2ExternalSubset;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = xmlSAX2AttributeDecl;
hdlr->elementDecl = xmlSAX2ElementDecl;
hdlr->notationDecl = xmlSAX2NotationDecl;
hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2Characters;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
if (warning == 0)
hdlr->warning = NULL;
else
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
/**
* inithtmlDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default HTML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
*/
void
inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = NULL;
hdlr->hasInternalSubset = NULL;
hdlr->hasExternalSubset = NULL;
hdlr->resolveEntity = NULL;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = NULL;
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 = NULL;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
/*
* nanoftp.h
*/

View File

@ -622,7 +622,6 @@ xml_opt_src = [
[want_pattern, ['pattern.c']],
[want_reader, ['xmlreader.c']],
[want_regexps, ['xmlregexp.c', 'xmlunicode.c']],
[want_sax1, ['SAX.c']],
[want_schemas, ['relaxng.c', 'xmlschemas.c', 'xmlschemastypes.c']],
[want_schemas and not want_xpath, ['xpath.c']],
[want_schematron, ['schematron.c']],

View File

@ -20,7 +20,7 @@
* different ranges of character are actually implanted either in
* parserInternals.h or parserInternals.c
* The DOM tree build is realized from the default SAX callbacks in
* the module SAX.c.
* the module SAX2.c.
* The routines doing the validation checks are in valid.c and called either
* from the SAX callbacks or as standalone functions using a preparsed
* document.
@ -4395,8 +4395,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *attlen, int *alloc,
if ((val == '&') && (!replaceEntities)) {
/*
* The reparsing will be done in xmlStringGetNodeList()
* called by the attribute() function in SAX.c
* The reparsing will be done in xmlNodeParseContent()
* called from SAX2.c
*/
xmlSBufAddCString(&buf, "&#38;", 5);
inSpace = 0;