Commit 8127390f authored by Daniel Veillard's avatar Daniel Veillard

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
parent 652327a7
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>
* configure.in entities.c tree.c valid.c xmllint.c
......
......@@ -122,7 +122,7 @@ check-local: tests
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)
valgrind:
......
......@@ -28,6 +28,7 @@
#include <libxml/globals.h>
#include <libxml/SAX2.h>
#ifdef LIBXML_SAX1_ENABLED
/**
* initxmlDefaultSAXHandler:
* @hdlr: the SAX handler
......@@ -75,6 +76,7 @@ initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
hdlr->initialized = 1;
}
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_HTML_ENABLED
......
......@@ -857,6 +857,7 @@ xmlSAX2EndDocument(void *ctx)
}
}
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED)
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
......@@ -1588,8 +1589,8 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
#endif
nodePop(ctxt);
}
#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */
int nb_interned = 0;
/*
* xmlSAX2TextNode:
* @ctxt: the parser context
......@@ -2429,6 +2430,7 @@ xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
static int xmlSAX2DefaultVersionValue = 2;
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlSAXDefaultVersion:
* @version: the version, 1 or 2
......@@ -2450,6 +2452,7 @@ xmlSAXDefaultVersion(int version)
xmlSAX2DefaultVersionValue = version;
return(ret);
}
#endif /* LIBXML_SAX1_ENABLED */
/**
* xmlSAXVersion:
......@@ -2464,16 +2467,18 @@ int
xmlSAXVersion(xmlSAXHandler *hdlr, int version)
{
if (hdlr == NULL) return(-1);
if (version == 1) {
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->initialized = 1;
} else if (version == 2) {
if (version == 2) {
hdlr->startElement = NULL;
hdlr->endElement = NULL;
hdlr->startElementNs = xmlSAX2StartElementNs;
hdlr->endElementNs = xmlSAX2EndElementNs;
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
return(-1);
hdlr->internalSubset = xmlSAX2InternalSubset;
......@@ -2533,7 +2538,9 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
void
xmlDefaultSAXHandlerInit(void)
{
#ifdef LIBXML_SAX1_ENABLED
xmlSAXVersion((xmlSAXHandlerPtr) &xmlDefaultSAXHandler, 1);
#endif /* LIBXML_SAX1_ENABLED */
}
#ifdef LIBXML_HTML_ENABLED
......
......@@ -623,6 +623,37 @@ else
fi
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,
[ --with-valid add the DTD validation support (on)])
if test "$with_minimum" = "yes" -a "$with_valid" = ""
......
......@@ -184,11 +184,18 @@ parseGjobFile(char *filename) {
xmlNsPtr ns;
xmlNodePtr cur;
#ifdef LIBXML_SAX1_ENABLED
/*
* build an XML tree from a the file;
*/
doc = xmlParseFile(filename);
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
......
......@@ -325,6 +325,7 @@ static const char *xmlTreeIndentStringThrDef = " ";
int xmlSaveNoEmptyTags = 0;
int xmlSaveNoEmptyTagsThrDef = 0;
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlDefaultSAXHandler:
*
......@@ -360,6 +361,7 @@ xmlSAXHandlerV1 xmlDefaultSAXHandler = {
xmlSAX2ExternalSubset,
0,
};
#endif /* LIBXML_SAX1_ENABLED */
/**
* xmlDefaultSAXLocator:
......@@ -483,7 +485,9 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->oldXMLWDcompatibility = 0;
gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
#ifdef LIBXML_SAX1_ENABLED
initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
#endif /* LIBXML_SAX1_ENABLED */
gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
......@@ -674,6 +678,7 @@ int xmlThrDefDefaultBufferSize(int v) {
return ret;
}
#ifdef LIBXML_SAX1_ENABLED
#undef xmlDefaultSAXHandler
xmlSAXHandlerV1 *
__xmlDefaultSAXHandler(void) {
......@@ -682,6 +687,7 @@ __xmlDefaultSAXHandler(void) {
else
return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
}
#endif /* LIBXML_SAX1_ENABLED */
#undef xmlDefaultSAXLocator
xmlSAXLocator *
......
......@@ -101,6 +101,24 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_OUTPUT_ENABLED
#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:
*
......
This diff is collapsed.
......@@ -2369,8 +2369,12 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding);
if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI);
if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem);
#ifdef LIBXML_SAX1_ENABLED
if ((ctxt->sax != NULL) &&
(ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler))
#else
if (ctxt->sax != NULL)
#endif /* LIBXML_SAX1_ENABLED */
xmlFree(ctxt->sax);
if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory);
if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
......
......@@ -8,6 +8,7 @@
#include "libxml.h"
#ifdef LIBXML_READER_ENABLED
#include <string.h>
#include <stdarg.h>
......@@ -130,3 +131,9 @@ int main(int argc, char **argv) {
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 */
......@@ -8,6 +8,7 @@
#include "libxml.h"
#ifdef LIBXML_SAX1_ENABLED
#include <string.h>
#include <stdarg.h>
......@@ -973,3 +974,9 @@ int main(int argc, char **argv) {
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 */
......@@ -2781,9 +2781,12 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
if (canonicFilename == NULL) {
if (xmlDefaultSAXHandler.error != NULL) {
xmlDefaultSAXHandler.error(NULL, "out of memory\n");
}
#if 0
xmlErrMemory(NULL, "failed to load entity");
#else
xmlGenericError(xmlGenericErrorContext,
"Memory allocation failed ! : failed to load entity\n");
#endif
return(NULL);
}
......
......@@ -149,9 +149,13 @@ static int dropdtd = 0;
static int catalogs = 0;
static int nocatalogs = 0;
#endif
#ifdef LIBXML_READER_ENABLED
static int stream = 0;
#endif /* LIBXML_READER_ENABLED */
static int chkregister = 0;
#ifdef LIBXML_SAX1_ENABLED
static int sax1 = 0;
#endif /* LIBXML_SAX1_ENABLED */
static int options = 0;
/*
......@@ -586,6 +590,7 @@ static void myClose(FILE *f) {
}
}
#ifdef LIBXML_READER_ENABLED
/************************************************************************
* *
* Stream Test processing *
......@@ -728,6 +733,7 @@ static void streamFile(char *filename) {
}
#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--debugent : debug the entities defined in the document\n");
#else
#ifdef LIBXML_READER_ENABLED
printf("\t--debug : dump the nodes content when using --stream\n");
#endif /* LIBXML_READER_ENABLED */
#endif
#ifdef LIBXML_TREE_ENABLED
printf("\t--copy : used to test the internal copy implementation\n");
......@@ -1357,7 +1365,9 @@ static void usage(const char *name) {
#endif
printf("\t--loaddtd : fetch external DTD\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");
#endif /* LIBXML_READER_ENABLED */
printf("\t--chkregister : verify the node registration code\n");
#ifdef LIBXML_SCHEMAS_ENABLED
printf("\t--relaxng schema : do RelaxNG validation against the schema\n");
......@@ -1583,14 +1593,18 @@ main(int argc, char **argv) {
#endif /* LIBXML_OUTPUT_ENABLED */
xmlKeepBlanksDefault(0);
}
#ifdef LIBXML_READER_ENABLED
else if ((!strcmp(argv[i], "-stream")) ||
(!strcmp(argv[i], "--stream"))) {
stream++;
}
#endif /* LIBXML_READER_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
else if ((!strcmp(argv[i], "-sax1")) ||
(!strcmp(argv[i], "--sax1"))) {
sax1++;
}
#endif /* LIBXML_SAX1_ENABLED */
else if ((!strcmp(argv[i], "-chkregister")) ||
(!strcmp(argv[i], "--chkregister"))) {
chkregister++;
......@@ -1632,10 +1646,12 @@ main(int argc, char **argv) {
}
#endif
#ifdef LIBXML_SAX1_ENABLED
if (sax1)
xmlSAXDefaultVersion(1);
else
xmlSAXDefaultVersion(2);
#endif /* LIBXML_SAX1_ENABLED */
if (chkregister) {
xmlRegisterNodeDefault(registerNode);
......@@ -1671,7 +1687,11 @@ main(int argc, char **argv) {
}
#ifdef LIBXML_SCHEMAS_ENABLED
if ((relaxng != NULL) && (stream == 0)) {
if ((relaxng != NULL)
#ifdef LIBXML_READER_ENABLED
&& (stream == 0)
#endif /* LIBXML_READER_ENABLED */
) {
xmlRelaxNGParserCtxtPtr ctxt;
/* forces loading the DTDs */
......@@ -1759,20 +1779,26 @@ main(int argc, char **argv) {
xmlParserCtxtPtr ctxt = NULL;
for (acount = 0;acount < repeat;acount++) {
#ifdef LIBXML_READER_ENABLED
if (stream != 0)
streamFile(argv[i]);
else {
#endif /* LIBXML_READER_ENABLED */
if (ctxt == NULL)
ctxt = xmlNewParserCtxt();
parseAndPrintFile(argv[i], ctxt);
#ifdef LIBXML_READER_ENABLED
}
#endif /* LIBXML_READER_ENABLED */
}
if (ctxt != NULL)
xmlFreeParserCtxt(ctxt);
} else {
#ifdef LIBXML_READER_ENABLED
if (stream != 0)
streamFile(argv[i]);
else
#endif /* LIBXML_READER_ENABLED */
parseAndPrintFile(argv[i], NULL);
}
files ++;
......
......@@ -21,6 +21,7 @@
#define IN_LIBXML
#include "libxml.h"
#ifdef LIBXML_READER_ENABLED
#include <string.h> /* for memset() only ! */
#include <stdarg.h>
......@@ -1501,20 +1502,24 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
"xmlNewTextReader : malloc failed\n");
return(NULL);
}
memcpy(ret->sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler));
xmlSAXVersion(ret->sax, 2);
ret->startElement = ret->sax->startElement;
ret->sax->startElement = xmlTextReaderStartElement;
ret->endElement = ret->sax->endElement;
ret->sax->endElement = xmlTextReaderEndElement;
#ifdef LIBXML_SAX1_ENABLED
if (ret->sax->initialized == XML_SAX2_MAGIC) {
#endif /* LIBXML_SAX1_ENABLED */
ret->startElementNs = ret->sax->startElementNs;
ret->sax->startElementNs = xmlTextReaderStartElementNs;
ret->endElementNs = ret->sax->endElementNs;
ret->sax->endElementNs = xmlTextReaderEndElementNs;
#ifdef LIBXML_SAX1_ENABLED
} else {
ret->startElementNs = NULL;
ret->endElementNs = NULL;
}
#endif /* LIBXML_SAX1_ENABLED */
ret->characters = ret->sax->characters;
ret->sax->characters = xmlTextReaderCharacters;
ret->sax->ignorableWhitespace = xmlTextReaderCharacters;
......@@ -3698,3 +3703,4 @@ int main(int argc, char **argv) {
}
#endif
#endif /* NOT_USED_YET */
#endif /* LIBXML_READER_ENABLED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment