added 2 new configure option: --with-reader --with-sax1 to allow removing

* Makefile.am SAX.c SAX2.c configure.in globals.c parser.c
  parserInternals.c testReader.c testSAX.c xmlIO.c xmllint.c
  xmlreader.c example/gjobread.c include/libxml/xmlversion.h.in:
  added 2 new configure option: --with-reader --with-sax1
  to allow removing the reader or non-xmlReadxxx() interfaces.
Daniel
This commit is contained in:
Daniel Veillard 2003-09-30 00:43:48 +00:00
parent 652327a727
commit 8127390f03
15 changed files with 201 additions and 19 deletions

View File

@ -1,3 +1,11 @@
Tue Sep 30 02:38:16 CEST 2003 Daniel Veillard <daniel@veillard.com>
* Makefile.am SAX.c SAX2.c configure.in globals.c parser.c
parserInternals.c testReader.c testSAX.c xmlIO.c xmllint.c
xmlreader.c example/gjobread.c include/libxml/xmlversion.h.in:
added 2 new configure option: --with-reader --with-sax1
to allow removing the reader or non-xmlReadxxx() interfaces.
Mon Sep 29 19:58:26 CEST 2003 Daniel Veillard <daniel@veillard.com> Mon Sep 29 19:58:26 CEST 2003 Daniel Veillard <daniel@veillard.com>
* configure.in entities.c tree.c valid.c xmllint.c * configure.in entities.c tree.c valid.c xmllint.c

View File

@ -122,7 +122,7 @@ check-local: tests
testall : tests SVGtests SAXtests testall : tests SVGtests SAXtests
tests: XMLtests XMLenttests NStests Readertests SAXtests @TEST_HTML@ @TEST_VALID@ URItests @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@ tests: XMLtests XMLenttests NStests Readertests @TEST_SAX@ @TEST_HTML@ @TEST_VALID@ URItests @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi) @(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi)
valgrind: valgrind:

2
SAX.c
View File

@ -28,6 +28,7 @@
#include <libxml/globals.h> #include <libxml/globals.h>
#include <libxml/SAX2.h> #include <libxml/SAX2.h>
#ifdef LIBXML_SAX1_ENABLED
/** /**
* initxmlDefaultSAXHandler: * initxmlDefaultSAXHandler:
* @hdlr: the SAX handler * @hdlr: the SAX handler
@ -75,6 +76,7 @@ initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
hdlr->initialized = 1; hdlr->initialized = 1;
} }
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED

19
SAX2.c
View File

@ -857,6 +857,7 @@ xmlSAX2EndDocument(void *ctx)
} }
} }
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED)
/** /**
* xmlSAX2AttributeInternal: * xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context) * @ctx: the user data (XML parser context)
@ -1588,8 +1589,8 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
#endif #endif
nodePop(ctxt); nodePop(ctxt);
} }
#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */
int nb_interned = 0;
/* /*
* xmlSAX2TextNode: * xmlSAX2TextNode:
* @ctxt: the parser context * @ctxt: the parser context
@ -2429,6 +2430,7 @@ xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
static int xmlSAX2DefaultVersionValue = 2; static int xmlSAX2DefaultVersionValue = 2;
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlSAXDefaultVersion: * xmlSAXDefaultVersion:
* @version: the version, 1 or 2 * @version: the version, 1 or 2
@ -2450,6 +2452,7 @@ xmlSAXDefaultVersion(int version)
xmlSAX2DefaultVersionValue = version; xmlSAX2DefaultVersionValue = version;
return(ret); return(ret);
} }
#endif /* LIBXML_SAX1_ENABLED */
/** /**
* xmlSAXVersion: * xmlSAXVersion:
@ -2464,16 +2467,18 @@ int
xmlSAXVersion(xmlSAXHandler *hdlr, int version) xmlSAXVersion(xmlSAXHandler *hdlr, int version)
{ {
if (hdlr == NULL) return(-1); if (hdlr == NULL) return(-1);
if (version == 1) { if (version == 2) {
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->initialized = 1;
} 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; hdlr->initialized = XML_SAX2_MAGIC;
#ifdef LIBXML_SAX1_ENABLED
} else if (version == 1) {
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->initialized = 1;
#endif /* LIBXML_SAX1_ENABLED */
} else } else
return(-1); return(-1);
hdlr->internalSubset = xmlSAX2InternalSubset; hdlr->internalSubset = xmlSAX2InternalSubset;
@ -2533,7 +2538,9 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
void void
xmlDefaultSAXHandlerInit(void) xmlDefaultSAXHandlerInit(void)
{ {
#ifdef LIBXML_SAX1_ENABLED
xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1); xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1);
#endif /* LIBXML_SAX1_ENABLED */
} }
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED

View File

@ -623,6 +623,37 @@ else
fi fi
AC_SUBST(WITH_LEGACY) AC_SUBST(WITH_LEGACY)
AC_ARG_WITH(reader,
[ --with-reader add the xmlReader parsing interface (on)])
if test "$with_minimum" = "yes" -a "$with_reader" = ""
then
with_reader=no
fi
if test "$with_reader" = "no" ; then
echo Disabling the xmlReader parsing interface
WITH_READER=0
else
WITH_READER=1
fi
AC_SUBST(WITH_READER)
AC_ARG_WITH(sax1,
[ --with-sax1 add the older SAX1 interface (on)])
if test "$with_minimum" = "yes" -a "$with_sax1" = ""
then
with_sax1=no
fi
if test "$with_sax1" = "no" ; then
echo Disabling the older SAX1 interface
WITH_SAX1=0
TEST_SAX=
else
WITH_SAX1=1
TEST_SAX=SAXtests
fi
AC_SUBST(WITH_SAX1)
AC_SUBST(TEST_SAX)
AC_ARG_WITH(valid, AC_ARG_WITH(valid,
[ --with-valid add the DTD validation support (on)]) [ --with-valid add the DTD validation support (on)])
if test "$with_minimum" = "yes" -a "$with_valid" = "" if test "$with_minimum" = "yes" -a "$with_valid" = ""

View File

@ -184,11 +184,18 @@ parseGjobFile(char *filename) {
xmlNsPtr ns; xmlNsPtr ns;
xmlNodePtr cur; xmlNodePtr cur;
#ifdef LIBXML_SAX1_ENABLED
/* /*
* build an XML tree from a the file; * build an XML tree from a the file;
*/ */
doc = xmlParseFile(filename); doc = xmlParseFile(filename);
if (doc == NULL) return(NULL); if (doc == NULL) return(NULL);
#else
/*
* the library has been compiled without some of the old interfaces
*/
return(NULL);
#endif /* LIBXML_SAX1_ENABLED */
/* /*
* Check the document is of the right kind * Check the document is of the right kind

View File

@ -325,6 +325,7 @@ static const char *xmlTreeIndentStringThrDef = " ";
int xmlSaveNoEmptyTags = 0; int xmlSaveNoEmptyTags = 0;
int xmlSaveNoEmptyTagsThrDef = 0; int xmlSaveNoEmptyTagsThrDef = 0;
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlDefaultSAXHandler: * xmlDefaultSAXHandler:
* *
@ -360,6 +361,7 @@ xmlSAXHandlerV1 xmlDefaultSAXHandler = {
xmlSAX2ExternalSubset, xmlSAX2ExternalSubset,
0, 0,
}; };
#endif /* LIBXML_SAX1_ENABLED */
/** /**
* xmlDefaultSAXLocator: * xmlDefaultSAXLocator:
@ -483,7 +485,9 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->oldXMLWDcompatibility = 0; gs->oldXMLWDcompatibility = 0;
gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
#ifdef LIBXML_SAX1_ENABLED
initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
#endif /* LIBXML_SAX1_ENABLED */
gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId; gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId; gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber; gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
@ -674,6 +678,7 @@ int xmlThrDefDefaultBufferSize(int v) {
return ret; return ret;
} }
#ifdef LIBXML_SAX1_ENABLED
#undef xmlDefaultSAXHandler #undef xmlDefaultSAXHandler
xmlSAXHandlerV1 * xmlSAXHandlerV1 *
__xmlDefaultSAXHandler(void) { __xmlDefaultSAXHandler(void) {
@ -682,6 +687,7 @@ __xmlDefaultSAXHandler(void) {
else else
return (&xmlGetGlobalState()->xmlDefaultSAXHandler); return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
} }
#endif /* LIBXML_SAX1_ENABLED */
#undef xmlDefaultSAXLocator #undef xmlDefaultSAXLocator
xmlSAXLocator * xmlSAXLocator *

View File

@ -101,6 +101,24 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_OUTPUT_ENABLED #define LIBXML_OUTPUT_ENABLED
#endif #endif
/**
* LIBXML_READER_ENABLED:
*
* Whether the xmlReader parsing interface is configured in
*/
#if @WITH_READER@
#define LIBXML_READER_ENABLED
#endif
/**
* LIBXML_SAX1_ENABLED:
*
* Whether the older SAX1 interface is configured in
*/
#if @WITH_SAX1@
#define LIBXML_SAX1_ENABLED
#endif
/** /**
* LIBXML_FTP_ENABLED: * LIBXML_FTP_ENABLED:
* *

View File

@ -111,9 +111,11 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
void *user_data, int depth, const xmlChar *URL, void *user_data, int depth, const xmlChar *URL,
const xmlChar *ID, xmlNodePtr *list); const xmlChar *ID, xmlNodePtr *list);
#ifdef LIBXML_LEGACY_ENABLED
static void static void
xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode, xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,
xmlNodePtr lastNode); xmlNodePtr lastNode);
#endif /* LIBXML_LEGACY_ENABLED */
static xmlParserErrors static xmlParserErrors
xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt, xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
@ -520,16 +522,19 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
static void static void
xmlDetectSAX2(xmlParserCtxtPtr ctxt) { xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL) return; if (ctxt == NULL) return;
#ifdef LIBXML_SAX1_ENABLED
if ((ctxt->sax) && (ctxt->sax->initialized == XML_SAX2_MAGIC) && if ((ctxt->sax) && (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
((ctxt->sax->startElementNs != NULL) || ((ctxt->sax->startElementNs != NULL) ||
(ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1; (ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1;
#else
ctxt->sax2 = 1;
#endif /* LIBXML_SAX1_ENABLED */
ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3); ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5); ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36); ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
} }
#ifdef SAX2
typedef struct _xmlDefAttrs xmlDefAttrs; typedef struct _xmlDefAttrs xmlDefAttrs;
typedef xmlDefAttrs *xmlDefAttrsPtr; typedef xmlDefAttrs *xmlDefAttrsPtr;
struct _xmlDefAttrs { struct _xmlDefAttrs {
@ -537,7 +542,6 @@ struct _xmlDefAttrs {
int maxAttrs; /* the size of the array */ int maxAttrs; /* the size of the array */
const xmlChar *values[4]; /* array of localname/prefix/values */ const xmlChar *values[4]; /* array of localname/prefix/values */
}; };
#endif
/** /**
* xmlAddDefAttrs: * xmlAddDefAttrs:
@ -5884,8 +5888,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
list = list->next; list = list->next;
} }
list = ent->children; list = ent->children;
#ifdef LIBXML_LEGACY_ENABLED
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, list, NULL); xmlAddEntityReference(ent, list, NULL);
#endif /* LIBXML_LEGACY_ENABLED */
} }
} else { } else {
ent->owner = 1; ent->owner = 1;
@ -5939,8 +5945,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
break; break;
cur = cur->next; cur = cur->next;
} }
#ifdef LIBXML_LEGACY_ENABLED
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, firstChild, nw); xmlAddEntityReference(ent, firstChild, nw);
#endif /* LIBXML_LEGACY_ENABLED */
} else if (list == NULL) { } else if (list == NULL) {
xmlNodePtr nw = NULL, cur, next, last, xmlNodePtr nw = NULL, cur, next, last,
firstChild = NULL; firstChild = NULL;
@ -5972,8 +5980,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
cur = next; cur = next;
} }
ent->owner = 1; ent->owner = 1;
#ifdef LIBXML_LEGACY_ENABLED
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, firstChild, nw); xmlAddEntityReference(ent, firstChild, nw);
#endif /* LIBXML_LEGACY_ENABLED */
} else { } else {
/* /*
* the name change is to avoid coalescing of the * the name change is to avoid coalescing of the
@ -6738,6 +6748,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
NEXT; NEXT;
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlParseAttribute: * xmlParseAttribute:
* @ctxt: an XML parser context * @ctxt: an XML parser context
@ -7079,6 +7090,7 @@ void
xmlParseEndTag(xmlParserCtxtPtr ctxt) { xmlParseEndTag(xmlParserCtxtPtr ctxt) {
xmlParseEndTag1(ctxt, 0); xmlParseEndTag1(ctxt, 0);
} }
#endif /* LIBXML_SAX1_ENABLED */
/************************************************************************ /************************************************************************
* * * *
@ -8246,10 +8258,14 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
spacePush(ctxt, *ctxt->space); spacePush(ctxt, *ctxt->space);
line = ctxt->input->line; line = ctxt->input->line;
#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax2) if (ctxt->sax2)
#endif /* LIBXML_SAX1_ENABLED */
name = xmlParseStartTag2(ctxt, &prefix, &URI); name = xmlParseStartTag2(ctxt, &prefix, &URI);
#ifdef LIBXML_SAX1_ENABLED
else else
name = xmlParseStartTag(ctxt); name = xmlParseStartTag(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
if (name == NULL) { if (name == NULL) {
spacePop(ctxt); spacePop(ctxt);
return; return;
@ -8277,10 +8293,12 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax != NULL) && (ctxt->sax->endElementNs != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->endElementNs != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->endElementNs(ctxt->userData, name, prefix, URI); ctxt->sax->endElementNs(ctxt->userData, name, prefix, URI);
#ifdef LIBXML_SAX1_ENABLED
} else { } else {
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->endElement(ctxt->userData, name); ctxt->sax->endElement(ctxt->userData, name);
#endif /* LIBXML_SAX1_ENABLED */
} }
namePop(ctxt); namePop(ctxt);
spacePop(ctxt); spacePop(ctxt);
@ -8357,8 +8375,11 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
if (ctxt->sax2) { if (ctxt->sax2) {
xmlParseEndTag2(ctxt, prefix, URI, line, ctxt->nsNr - nsNr); xmlParseEndTag2(ctxt, prefix, URI, line, ctxt->nsNr - nsNr);
namePop(ctxt); namePop(ctxt);
} else }
#ifdef LIBXML_SAX1_ENABLED
else
xmlParseEndTag1(ctxt, line); xmlParseEndTag1(ctxt, line);
#endif /* LIBXML_SAX1_ENABLED */
/* /*
* Capture end position and add node * Capture end position and add node
@ -9469,10 +9490,14 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
spacePush(ctxt, -1); spacePush(ctxt, -1);
else else
spacePush(ctxt, *ctxt->space); spacePush(ctxt, *ctxt->space);
#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax2) if (ctxt->sax2)
#endif /* LIBXML_SAX1_ENABLED */
name = xmlParseStartTag2(ctxt, &prefix, &URI); name = xmlParseStartTag2(ctxt, &prefix, &URI);
#ifdef LIBXML_SAX1_ENABLED
else else
name = xmlParseStartTag(ctxt); name = xmlParseStartTag(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
if (name == NULL) { if (name == NULL) {
spacePop(ctxt); spacePop(ctxt);
ctxt->instate = XML_PARSER_EOF; ctxt->instate = XML_PARSER_EOF;
@ -9503,11 +9528,13 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->endElementNs(ctxt->userData, name, ctxt->sax->endElementNs(ctxt->userData, name,
prefix, URI); prefix, URI);
#ifdef LIBXML_SAX1_ENABLED
} else { } else {
if ((ctxt->sax != NULL) && if ((ctxt->sax != NULL) &&
(ctxt->sax->endElement != NULL) && (ctxt->sax->endElement != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->endElement(ctxt->userData, name); ctxt->sax->endElement(ctxt->userData, name);
#endif /* LIBXML_SAX1_ENABLED */
} }
spacePop(ctxt); spacePop(ctxt);
if (ctxt->nameNr == 0) { if (ctxt->nameNr == 0) {
@ -9528,8 +9555,10 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
} }
if (ctxt->sax2) if (ctxt->sax2)
nameNsPush(ctxt, name, prefix, URI, ctxt->nsNr - nsNr); nameNsPush(ctxt, name, prefix, URI, ctxt->nsNr - nsNr);
#ifdef LIBXML_SAX1_ENABLED
else else
namePush(ctxt, name); namePush(ctxt, name);
#endif /* LIBXML_SAX1_ENABLED */
ctxt->instate = XML_PARSER_CONTENT; ctxt->instate = XML_PARSER_CONTENT;
break; break;
@ -9641,8 +9670,11 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
(void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0, (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0,
(int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1]); (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1]);
nameNsPop(ctxt); nameNsPop(ctxt);
} else }
#ifdef LIBXML_SAX1_ENABLED
else
xmlParseEndTag1(ctxt, 0); xmlParseEndTag1(ctxt, 0);
#endif /* LIBXML_SAX1_ENABLED */
if (ctxt->nameNr == 0) { if (ctxt->nameNr == 0) {
ctxt->instate = XML_PARSER_EPILOG; ctxt->instate = XML_PARSER_EPILOG;
} else { } else {
@ -10179,7 +10211,9 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(NULL); return(NULL);
} }
if (sax != NULL) { if (sax != NULL) {
#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
#endif /* LIBXML_SAX1_ENABLED */
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) {
@ -10272,7 +10306,9 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(NULL); return(NULL);
} }
if (sax != NULL) { if (sax != NULL) {
#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
#endif /* LIBXML_SAX1_ENABLED */
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) {
@ -10887,6 +10923,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
return(ret); return(ret);
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlParseExternalEntity: * xmlParseExternalEntity:
* @doc: the document the chunk pertains to * @doc: the document the chunk pertains to
@ -10940,6 +10977,7 @@ xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax,
return xmlParseBalancedChunkMemoryRecover( doc, sax, user_data, return xmlParseBalancedChunkMemoryRecover( doc, sax, user_data,
depth, string, lst, 0 ); depth, string, lst, 0 );
} }
#endif /* LIBXML_SAX1_ENABLED */
/** /**
* xmlParseBalancedChunkMemoryInternal: * xmlParseBalancedChunkMemoryInternal:
@ -11090,6 +11128,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
return(ret); return(ret);
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlParseBalancedChunkMemoryRecover: * xmlParseBalancedChunkMemoryRecover:
* @doc: the document the chunk pertains to * @doc: the document the chunk pertains to
@ -11300,6 +11339,7 @@ xmlDocPtr
xmlParseEntity(const char *filename) { xmlParseEntity(const char *filename) {
return(xmlSAXParseEntity(NULL, filename)); return(xmlSAXParseEntity(NULL, filename));
} }
#endif /* LIBXML_SAX1_ENABLED */
/** /**
* xmlCreateEntityParserCtxt: * xmlCreateEntityParserCtxt:
@ -11385,9 +11425,7 @@ xmlCreateFileParserCtxt(const char *filename)
ctxt = xmlNewParserCtxt(); ctxt = xmlNewParserCtxt();
if (ctxt == NULL) { if (ctxt == NULL) {
if (xmlDefaultSAXHandler.error != NULL) { xmlErrMemory(NULL, "cannot allocate parser context");
xmlDefaultSAXHandler.error(NULL, "out of memory\n");
}
return(NULL); return(NULL);
} }
@ -11407,6 +11445,7 @@ xmlCreateFileParserCtxt(const char *filename)
return(ctxt); return(ctxt);
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlSAXParseFileWithData: * xmlSAXParseFileWithData:
* @sax: the SAX handler block * @sax: the SAX handler block
@ -11598,7 +11637,9 @@ xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data,
ctxt = xmlCreateFileParserCtxt(filename); ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) return -1; if (ctxt == NULL) return -1;
#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler) if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
#endif /* LIBXML_SAX1_ENABLED */
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
ctxt->sax = sax; ctxt->sax = sax;
xmlDetectSAX2(ctxt); xmlDetectSAX2(ctxt);
@ -11622,6 +11663,7 @@ xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data,
return ret; return ret;
} }
#endif /* LIBXML_SAX1_ENABLED */
/************************************************************************ /************************************************************************
* * * *
@ -11677,6 +11719,7 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
return(ctxt); return(ctxt);
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlSAXParseMemoryWithData: * xmlSAXParseMemoryWithData:
* @sax: the SAX handler block * @sax: the SAX handler block
@ -11822,6 +11865,7 @@ int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
return ret; return ret;
} }
#endif /* LIBXML_SAX1_ENABLED */
/** /**
* xmlCreateDocParserCtxt: * xmlCreateDocParserCtxt:
@ -11841,6 +11885,7 @@ xmlCreateDocParserCtxt(const xmlChar *cur) {
return(xmlCreateMemoryParserCtxt((const char *)cur, len)); return(xmlCreateMemoryParserCtxt((const char *)cur, len));
} }
#ifdef LIBXML_SAX1_ENABLED
/** /**
* xmlSAXParseDoc: * xmlSAXParseDoc:
* @sax: the SAX handler block * @sax: the SAX handler block
@ -11898,7 +11943,9 @@ xmlDocPtr
xmlParseDoc(xmlChar *cur) { xmlParseDoc(xmlChar *cur) {
return(xmlSAXParseDoc(NULL, cur, 0)); return(xmlSAXParseDoc(NULL, cur, 0));
} }
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_LEGACY_ENABLED
/************************************************************************ /************************************************************************
* * * *
* Specific function to keep track of entities references * * Specific function to keep track of entities references *
@ -11937,6 +11984,7 @@ xmlSetEntityReferenceFunc(xmlEntityReferenceFunc func)
{ {
xmlEntityRefFunc = func; xmlEntityRefFunc = func;
} }
#endif /* LIBXML_LEGACY_ENABLED */
/************************************************************************ /************************************************************************
* * * *
@ -12175,6 +12223,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
options -= XML_PARSE_DTDVALID; options -= XML_PARSE_DTDVALID;
} else } else
ctxt->validate = 0; ctxt->validate = 0;
#ifdef LIBXML_SAX1_ENABLED
if (options & XML_PARSE_SAX1) { if (options & XML_PARSE_SAX1) {
ctxt->sax->startElement = xmlSAX2StartElement; ctxt->sax->startElement = xmlSAX2StartElement;
ctxt->sax->endElement = xmlSAX2EndElement; ctxt->sax->endElement = xmlSAX2EndElement;
@ -12183,6 +12232,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
ctxt->sax->initialized = 1; ctxt->sax->initialized = 1;
options -= XML_PARSE_SAX1; options -= XML_PARSE_SAX1;
} }
#endif /* LIBXML_SAX1_ENABLED */
if (options & XML_PARSE_NODICT) { if (options & XML_PARSE_NODICT) {
ctxt->dictNames = 0; ctxt->dictNames = 0;
options -= XML_PARSE_NODICT; options -= XML_PARSE_NODICT;

View File

@ -2369,8 +2369,12 @@ 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);
#ifdef LIBXML_SAX1_ENABLED
if ((ctxt->sax != NULL) && if ((ctxt->sax != NULL) &&
(ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)) (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler))
#else
if (ctxt->sax != NULL)
#endif /* LIBXML_SAX1_ENABLED */
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

@ -8,6 +8,7 @@
#include "libxml.h" #include "libxml.h"
#ifdef LIBXML_READER_ENABLED
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
@ -130,3 +131,9 @@ int main(int argc, char **argv) {
return(0); return(0);
} }
#else
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
printf("%s : xmlReader parser support not compiled in\n", argv[0]);
return(0);
}
#endif /* LIBXML_READER_ENABLED */

View File

@ -8,6 +8,7 @@
#include "libxml.h" #include "libxml.h"
#ifdef LIBXML_SAX1_ENABLED
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
@ -973,3 +974,9 @@ int main(int argc, char **argv) {
return(0); return(0);
} }
#else
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
printf("%s : SAX1 parsing support not compiled in\n", argv[0]);
return(0);
}
#endif /* LIBXML_SAX1_ENABLED */

View File

@ -2781,9 +2781,12 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL); canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
if (canonicFilename == NULL) { if (canonicFilename == NULL) {
if (xmlDefaultSAXHandler.error != NULL) { #if 0
xmlDefaultSAXHandler.error(NULL, "out of memory\n"); xmlErrMemory(NULL, "failed to load entity");
} #else
xmlGenericError(xmlGenericErrorContext,
"Memory allocation failed ! : failed to load entity\n");
#endif
return(NULL); return(NULL);
} }

View File

@ -149,9 +149,13 @@ static int dropdtd = 0;
static int catalogs = 0; static int catalogs = 0;
static int nocatalogs = 0; static int nocatalogs = 0;
#endif #endif
#ifdef LIBXML_READER_ENABLED
static int stream = 0; static int stream = 0;
#endif /* LIBXML_READER_ENABLED */
static int chkregister = 0; static int chkregister = 0;
#ifdef LIBXML_SAX1_ENABLED
static int sax1 = 0; static int sax1 = 0;
#endif /* LIBXML_SAX1_ENABLED */
static int options = 0; static int options = 0;
/* /*
@ -586,6 +590,7 @@ static void myClose(FILE *f) {
} }
} }
#ifdef LIBXML_READER_ENABLED
/************************************************************************ /************************************************************************
* * * *
* Stream Test processing * * Stream Test processing *
@ -728,6 +733,7 @@ static void streamFile(char *filename) {
} }
#endif #endif
} }
#endif /* LIBXML_READER_ENABLED */
/************************************************************************ /************************************************************************
* * * *
@ -1302,7 +1308,9 @@ static void usage(const char *name) {
printf("\t--shell : run a navigating shell\n"); printf("\t--shell : run a navigating shell\n");
printf("\t--debugent : debug the entities defined in the document\n"); printf("\t--debugent : debug the entities defined in the document\n");
#else #else
#ifdef LIBXML_READER_ENABLED
printf("\t--debug : dump the nodes content when using --stream\n"); printf("\t--debug : dump the nodes content when using --stream\n");
#endif /* LIBXML_READER_ENABLED */
#endif #endif
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
printf("\t--copy : used to test the internal copy implementation\n"); printf("\t--copy : used to test the internal copy implementation\n");
@ -1357,7 +1365,9 @@ static void usage(const char *name) {
#endif #endif
printf("\t--loaddtd : fetch external DTD\n"); printf("\t--loaddtd : fetch external DTD\n");
printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n"); printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
#ifdef LIBXML_READER_ENABLED
printf("\t--stream : use the streaming interface to process very large files\n"); printf("\t--stream : use the streaming interface to process very large files\n");
#endif /* LIBXML_READER_ENABLED */
printf("\t--chkregister : verify the node registration code\n"); printf("\t--chkregister : verify the node registration code\n");
#ifdef LIBXML_SCHEMAS_ENABLED #ifdef LIBXML_SCHEMAS_ENABLED
printf("\t--relaxng schema : do RelaxNG validation against the schema\n"); printf("\t--relaxng schema : do RelaxNG validation against the schema\n");
@ -1583,14 +1593,18 @@ main(int argc, char **argv) {
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
xmlKeepBlanksDefault(0); xmlKeepBlanksDefault(0);
} }
#ifdef LIBXML_READER_ENABLED
else if ((!strcmp(argv[i], "-stream")) || else if ((!strcmp(argv[i], "-stream")) ||
(!strcmp(argv[i], "--stream"))) { (!strcmp(argv[i], "--stream"))) {
stream++; stream++;
} }
#endif /* LIBXML_READER_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
else if ((!strcmp(argv[i], "-sax1")) || else if ((!strcmp(argv[i], "-sax1")) ||
(!strcmp(argv[i], "--sax1"))) { (!strcmp(argv[i], "--sax1"))) {
sax1++; sax1++;
} }
#endif /* LIBXML_SAX1_ENABLED */
else if ((!strcmp(argv[i], "-chkregister")) || else if ((!strcmp(argv[i], "-chkregister")) ||
(!strcmp(argv[i], "--chkregister"))) { (!strcmp(argv[i], "--chkregister"))) {
chkregister++; chkregister++;
@ -1632,10 +1646,12 @@ main(int argc, char **argv) {
} }
#endif #endif
#ifdef LIBXML_SAX1_ENABLED
if (sax1) if (sax1)
xmlSAXDefaultVersion(1); xmlSAXDefaultVersion(1);
else else
xmlSAXDefaultVersion(2); xmlSAXDefaultVersion(2);
#endif /* LIBXML_SAX1_ENABLED */
if (chkregister) { if (chkregister) {
xmlRegisterNodeDefault(registerNode); xmlRegisterNodeDefault(registerNode);
@ -1671,7 +1687,11 @@ main(int argc, char **argv) {
} }
#ifdef LIBXML_SCHEMAS_ENABLED #ifdef LIBXML_SCHEMAS_ENABLED
if ((relaxng != NULL) && (stream == 0)) { if ((relaxng != NULL)
#ifdef LIBXML_READER_ENABLED
&& (stream == 0)
#endif /* LIBXML_READER_ENABLED */
) {
xmlRelaxNGParserCtxtPtr ctxt; xmlRelaxNGParserCtxtPtr ctxt;
/* forces loading the DTDs */ /* forces loading the DTDs */
@ -1759,20 +1779,26 @@ main(int argc, char **argv) {
xmlParserCtxtPtr ctxt = NULL; xmlParserCtxtPtr ctxt = NULL;
for (acount = 0;acount < repeat;acount++) { for (acount = 0;acount < repeat;acount++) {
#ifdef LIBXML_READER_ENABLED
if (stream != 0) if (stream != 0)
streamFile(argv[i]); streamFile(argv[i]);
else { else {
#endif /* LIBXML_READER_ENABLED */
if (ctxt == NULL) if (ctxt == NULL)
ctxt = xmlNewParserCtxt(); ctxt = xmlNewParserCtxt();
parseAndPrintFile(argv[i], ctxt); parseAndPrintFile(argv[i], ctxt);
#ifdef LIBXML_READER_ENABLED
} }
#endif /* LIBXML_READER_ENABLED */
} }
if (ctxt != NULL) if (ctxt != NULL)
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
} else { } else {
#ifdef LIBXML_READER_ENABLED
if (stream != 0) if (stream != 0)
streamFile(argv[i]); streamFile(argv[i]);
else else
#endif /* LIBXML_READER_ENABLED */
parseAndPrintFile(argv[i], NULL); parseAndPrintFile(argv[i], NULL);
} }
files ++; files ++;

View File

@ -21,6 +21,7 @@
#define IN_LIBXML #define IN_LIBXML
#include "libxml.h" #include "libxml.h"
#ifdef LIBXML_READER_ENABLED
#include <string.h> /* for memset() only ! */ #include <string.h> /* for memset() only ! */
#include <stdarg.h> #include <stdarg.h>
@ -1501,20 +1502,24 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
"xmlNewTextReader : malloc failed\n"); "xmlNewTextReader : malloc failed\n");
return(NULL); return(NULL);
} }
memcpy(ret->sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler)); xmlSAXVersion(ret->sax, 2);
ret->startElement = ret->sax->startElement; ret->startElement = ret->sax->startElement;
ret->sax->startElement = xmlTextReaderStartElement; ret->sax->startElement = xmlTextReaderStartElement;
ret->endElement = ret->sax->endElement; ret->endElement = ret->sax->endElement;
ret->sax->endElement = xmlTextReaderEndElement; ret->sax->endElement = xmlTextReaderEndElement;
#ifdef LIBXML_SAX1_ENABLED
if (ret->sax->initialized == XML_SAX2_MAGIC) { if (ret->sax->initialized == XML_SAX2_MAGIC) {
#endif /* LIBXML_SAX1_ENABLED */
ret->startElementNs = ret->sax->startElementNs; ret->startElementNs = ret->sax->startElementNs;
ret->sax->startElementNs = xmlTextReaderStartElementNs; ret->sax->startElementNs = xmlTextReaderStartElementNs;
ret->endElementNs = ret->sax->endElementNs; ret->endElementNs = ret->sax->endElementNs;
ret->sax->endElementNs = xmlTextReaderEndElementNs; ret->sax->endElementNs = xmlTextReaderEndElementNs;
#ifdef LIBXML_SAX1_ENABLED
} else { } else {
ret->startElementNs = NULL; ret->startElementNs = NULL;
ret->endElementNs = NULL; ret->endElementNs = NULL;
} }
#endif /* LIBXML_SAX1_ENABLED */
ret->characters = ret->sax->characters; ret->characters = ret->sax->characters;
ret->sax->characters = xmlTextReaderCharacters; ret->sax->characters = xmlTextReaderCharacters;
ret->sax->ignorableWhitespace = xmlTextReaderCharacters; ret->sax->ignorableWhitespace = xmlTextReaderCharacters;
@ -3698,3 +3703,4 @@ int main(int argc, char **argv) {
} }
#endif #endif
#endif /* NOT_USED_YET */ #endif /* NOT_USED_YET */
#endif /* LIBXML_READER_ENABLED */