Commit 4432df23 authored by Daniel Veillard's avatar Daniel Veillard

cleanup, creating a new legacy.c module, made sure make tests ran in

* Makefile.am: cleanup, creating a new legacy.c module,
  made sure make tests ran in reduced conditions
* SAX.c SAX2.c configure.in entities.c globals.c parser.c
  parserInternals.c tree.c valid.c xlink.c xmlIO.c xmlcatalog.c
  xmlmemory.c xpath.c xmlmemory.c include/libxml/xmlversion.h.in:
  increased the modularization, allow to configure out
  validation code and legacy code, added a configuration
  option --with-minimum compiling only the mandatory code
  which then shrink to 200KB.
Daniel
parent 9ee35f36
Sun Sep 28 20:53:17 CEST 2003 Daniel Veillard <daniel@veillard.com>
* Makefile.am: cleanup, creating a new legacy.c module,
made sure make tests ran in reduced conditions
* SAX.c SAX2.c configure.in entities.c globals.c parser.c
parserInternals.c tree.c valid.c xlink.c xmlIO.c xmlcatalog.c
xmlmemory.c xpath.c xmlmemory.c include/libxml/xmlversion.h.in:
increased the modularization, allow to configure out
validation code and legacy code, added a configuration
option --with-minimum compiling only the mandatory code
which then shrink to 200KB.
Sun Sep 28 02:15:07 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: fix a bug raised by the Mips compiler.
......
......@@ -26,7 +26,8 @@ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
legacy.c
else
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
......@@ -34,7 +35,8 @@ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c
xmlreader.c relaxng.c dict.c SAX2.c \
legacy.c
endif
DEPS = $(top_builddir)/libxml2.la
......@@ -120,7 +122,7 @@ check-local: tests
testall : tests SVGtests SAXtests
tests: XMLtests XMLenttests NStests Readertests SAXtests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests C14Ntests Scripttests Catatests @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests
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@
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi)
valgrind:
......@@ -720,7 +722,7 @@ $(srcdir)/dba100000.xml: dbgenattr.pl
@echo "## generating dba100000.xml"
@(dbgenattr.pl 100000 > $(srcdir)/dba100000.xml)
Timingtests: $(srcdir)/dba100000.xml
Timingtests: xmllint$(EXEEXT) $(srcdir)/dba100000.xml
@echo "##"
@echo "## Timing tests to try to detect performance"
@echo "## as well a memory usage breakage when streaming"
......@@ -744,6 +746,8 @@ Timingtests: $(srcdir)/dba100000.xml
if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
exit 0)
VTimingtests: xmllint$(EXEEXT)
-@(xmllint --noout --timing --valid --repeat $(srcdir)/test/valid/REC-xml-19980210.xml; \
MEM=`cat .memdump | grep "MEMORY ALLOCATED" | awk '{ print $$7}'`;\
if [ "$$MEM" != "" ] ; then echo Using $$MEM bytes ; fi ; \
......
......@@ -28,589 +28,6 @@
#include <libxml/globals.h>
#include <libxml/SAX2.h>
/* #define DEBUG_SAX */
/* #define DEBUG_SAX_TREE */
static int deprecated_msg = 0;
#define DEPRECATED(n) \
if (deprecated_msg == 0) \
xmlGenericError(xmlGenericErrorContext, \
"Use of deprecated SAXv1 function %s\n", n); \
deprecated_msg++;
/**
* getPublicId:
* @ctx: the user data (XML parser context)
*
* Provides the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
* DEPRECATED: use xmlSAX2GetPublicId()
*
* Returns a xmlChar *
*/
const xmlChar *
getPublicId(void *ctx)
{
DEPRECATED("getPublicId")
return(xmlSAX2GetPublicId(ctx));
}
/**
* getSystemId:
* @ctx: the user data (XML parser context)
*
* Provides the system ID, basically URL or filename e.g.
* http://www.sgmlsource.com/dtds/memo.dtd
* DEPRECATED: use xmlSAX2GetSystemId()
*
* Returns a xmlChar *
*/
const xmlChar *
getSystemId(void *ctx)
{
DEPRECATED("getSystemId")
return(xmlSAX2GetSystemId(ctx));
}
/**
* getLineNumber:
* @ctx: the user data (XML parser context)
*
* Provide the line number of the current parsing point.
* DEPRECATED: use xmlSAX2GetLineNumber()
*
* Returns an int
*/
int
getLineNumber(void *ctx)
{
DEPRECATED("getLineNumber")
return(xmlSAX2GetLineNumber(ctx));
}
/**
* getColumnNumber:
* @ctx: the user data (XML parser context)
*
* Provide the column number of the current parsing point.
* DEPRECATED: use xmlSAX2GetColumnNumber()
*
* Returns an int
*/
int
getColumnNumber(void *ctx)
{
DEPRECATED("getColumnNumber")
return(xmlSAX2GetColumnNumber(ctx));
}
/**
* isStandalone:
* @ctx: the user data (XML parser context)
*
* Is this document tagged standalone ?
* DEPRECATED: use xmlSAX2IsStandalone()
*
* Returns 1 if true
*/
int
isStandalone(void *ctx)
{
DEPRECATED("isStandalone")
return(xmlSAX2IsStandalone(ctx));
}
/**
* hasInternalSubset:
* @ctx: the user data (XML parser context)
*
* Does this document has an internal subset
* DEPRECATED: use xmlSAX2HasInternalSubset()
*
* Returns 1 if true
*/
int
hasInternalSubset(void *ctx)
{
DEPRECATED("hasInternalSubset")
return(xmlSAX2HasInternalSubset(ctx));
}
/**
* hasExternalSubset:
* @ctx: the user data (XML parser context)
*
* Does this document has an external subset
* DEPRECATED: use xmlSAX2HasExternalSubset()
*
* Returns 1 if true
*/
int
hasExternalSubset(void *ctx)
{
DEPRECATED("hasExternalSubset")
return(xmlSAX2HasExternalSubset(ctx));
}
/**
* internalSubset:
* @ctx: the user data (XML parser context)
* @name: the root element name
* @ExternalID: the external ID
* @SystemID: the SYSTEM ID (e.g. filename or URL)
*
* Callback on internal subset declaration.
* DEPRECATED: use xmlSAX2InternalSubset()
*/
void
internalSubset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
DEPRECATED("internalSubset")
xmlSAX2InternalSubset(ctx, name, ExternalID, SystemID);
}
/**
* externalSubset:
* @ctx: the user data (XML parser context)
* @name: the root element name
* @ExternalID: the external ID
* @SystemID: the SYSTEM ID (e.g. filename or URL)
*
* Callback on external subset declaration.
* DEPRECATED: use xmlSAX2ExternalSubset()
*/
void
externalSubset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
DEPRECATED("externalSubset")
xmlSAX2ExternalSubset(ctx, name, ExternalID, SystemID);
}
/**
* resolveEntity:
* @ctx: the user data (XML parser context)
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
*
* The entity loader, to control the loading of external entities,
* the application can either:
* - override this resolveEntity() callback in the SAX block
* - or better use the xmlSetExternalEntityLoader() function to
* set up it's own entity resolution routine
* DEPRECATED: use xmlSAX2ResolveEntity()
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/
xmlParserInputPtr
resolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
{
DEPRECATED("resolveEntity")
return(xmlSAX2ResolveEntity(ctx, publicId, systemId));
}
/**
* getEntity:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Get an entity by name
* DEPRECATED: use xmlSAX2GetEntity()
*
* Returns the xmlEntityPtr if found.
*/
xmlEntityPtr
getEntity(void *ctx, const xmlChar *name)
{
DEPRECATED("getEntity")
return(xmlSAX2GetEntity(ctx, name));
}
/**
* getParameterEntity:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Get a parameter entity by name
* DEPRECATED: use xmlSAX2GetParameterEntity()
*
* Returns the xmlEntityPtr if found.
*/
xmlEntityPtr
getParameterEntity(void *ctx, const xmlChar *name)
{
DEPRECATED("getParameterEntity")
return(xmlSAX2GetParameterEntity(ctx, name));
}
/**
* entityDecl:
* @ctx: the user data (XML parser context)
* @name: the entity name
* @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
*
* An entity definition has been parsed
* DEPRECATED: use xmlSAX2EntityDecl()
*/
void
entityDecl(void *ctx, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
{
DEPRECATED("entityDecl")
xmlSAX2EntityDecl(ctx, name, type, publicId, systemId, content);
}
/**
* attributeDecl:
* @ctx: the user data (XML parser context)
* @elem: the name of the element
* @fullname: the attribute name
* @type: the attribute type
* @def: the type of default value
* @defaultValue: the attribute default value
* @tree: the tree of enumerated value set
*
* An attribute definition has been parsed
* DEPRECATED: use xmlSAX2AttributeDecl()
*/
void
attributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
int type, int def, const xmlChar *defaultValue,
xmlEnumerationPtr tree)
{
DEPRECATED("attributeDecl")
xmlSAX2AttributeDecl(ctx, elem, fullname, type, def, defaultValue, tree);
}
/**
* elementDecl:
* @ctx: the user data (XML parser context)
* @name: the element name
* @type: the element type
* @content: the element value tree
*
* An element definition has been parsed
* DEPRECATED: use xmlSAX2ElementDecl()
*/
void
elementDecl(void *ctx, const xmlChar * name, int type,
xmlElementContentPtr content)
{
DEPRECATED("elementDecl")
xmlSAX2ElementDecl(ctx, name, type, content);
}
/**
* notationDecl:
* @ctx: the user data (XML parser context)
* @name: The name of the notation
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
*
* What to do when a notation declaration has been parsed.
* DEPRECATED: use xmlSAX2NotationDecl()
*/
void
notationDecl(void *ctx, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId)
{
DEPRECATED("notationDecl")
xmlSAX2NotationDecl(ctx, name, publicId, systemId);
}
/**
* unparsedEntityDecl:
* @ctx: the user data (XML parser context)
* @name: The name of the entity
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @notationName: the name of the notation
*
* What to do when an unparsed entity declaration is parsed
* DEPRECATED: use xmlSAX2UnparsedEntityDecl()
*/
void
unparsedEntityDecl(void *ctx, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *notationName)
{
DEPRECATED("unparsedEntityDecl")
xmlSAX2UnparsedEntityDecl(ctx, name, publicId, systemId, notationName);
}
/**
* setDocumentLocator:
* @ctx: the user data (XML parser context)
* @loc: A SAX Locator
*
* Receive the document locator at startup, actually xmlDefaultSAXLocator
* Everything is available on the context, so this is useless in our case.
* DEPRECATED
*/
void
setDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
{
DEPRECATED("setDocumentLocator")
}
/**
* startDocument:
* @ctx: the user data (XML parser context)
*
* called when the document start being processed.
* DEPRECATED: use xmlSAX2StartDocument()
*/
void
startDocument(void *ctx)
{
DEPRECATED("startDocument")
xmlSAX2StartDocument(ctx);
}
/**
* endDocument:
* @ctx: the user data (XML parser context)
*
* called when the document end has been detected.
* DEPRECATED: use xmlSAX2EndDocument()
*/
void
endDocument(void *ctx)
{
DEPRECATED("endDocument")
xmlSAX2EndDocument(ctx);
}
/**
* attribute:
* @ctx: the user data (XML parser context)
* @fullname: The attribute name, including namespace prefix
* @value: The attribute value
*
* Handle an attribute that has been read by the parser.
* The default handling is to convert the attribute into an
* DOM subtree and past it in a new xmlAttr element added to
* the element.
* DEPRECATED: use xmlSAX2Attribute()
*/
void
attribute(void *ctx ATTRIBUTE_UNUSED, const xmlChar *fullname ATTRIBUTE_UNUSED, const xmlChar *value ATTRIBUTE_UNUSED)
{
DEPRECATED("attribute")
}
/**
* startElement:
* @ctx: the user data (XML parser context)
* @fullname: The element name, including namespace prefix
* @atts: An array of name/value attributes pairs, NULL terminated
*
* called when an opening tag has been processed.
* DEPRECATED: use xmlSAX2StartElement()
*/
void
startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
{
DEPRECATED("startElement")
xmlSAX2StartElement(ctx, fullname, atts);
}
/**
* endElement:
* @ctx: the user data (XML parser context)
* @name: The element name
*
* called when the end of an element has been detected.
* DEPRECATED: use xmlSAX2EndElement()
*/
void
endElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
{
DEPRECATED("endElement")
xmlSAX2EndElement(ctx, name);
}
/**
* reference:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* called when an entity reference is detected.
* DEPRECATED: use xmlSAX2Reference()
*/
void
reference(void *ctx, const xmlChar *name)
{
DEPRECATED("reference")
xmlSAX2Reference(ctx, name);
}
/**
* characters:
* @ctx: the user data (XML parser context)
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some chars from the parser.
* DEPRECATED: use xmlSAX2Characters()
*/
void
characters(void *ctx, const xmlChar *ch, int len)
{
DEPRECATED("characters")
xmlSAX2Characters(ctx, ch, len);
}
/**
* ignorableWhitespace:
* @ctx: the user data (XML parser context)
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some ignorable whitespaces from the parser.
* UNUSED: by default the DOM building will use characters
* DEPRECATED: use xmlSAX2IgnorableWhitespace()
*/
void
ignorableWhitespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED)
{
DEPRECATED("ignorableWhitespace")
}
/**
* processingInstruction:
* @ctx: the user data (XML parser context)
* @target: the target name
* @data: the PI data's
*
* A processing instruction has been parsed.
* DEPRECATED: use xmlSAX2ProcessingInstruction()
*/
void
processingInstruction(void *ctx, const xmlChar *target,
const xmlChar *data)
{
DEPRECATED("processingInstruction")
xmlSAX2ProcessingInstruction(ctx, target, data);
}
/**
* globalNamespace:
* @ctx: the user data (XML parser context)
* @href: the namespace associated URN
* @prefix: the namespace prefix
*
* An old global namespace has been parsed.
* DEPRECATED
*/
void
globalNamespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *href ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED)
{
DEPRECATED("globalNamespace")
}
/**
* setNamespace:
* @ctx: the user data (XML parser context)
* @name: the namespace prefix
*
* Set the current element namespace.
* DEPRECATED
*/
void
setNamespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name ATTRIBUTE_UNUSED)
{
DEPRECATED("setNamespace")
}
/**
* getNamespace:
* @ctx: the user data (XML parser context)
*
* Get the current element namespace.
* DEPRECATED
*
* Returns the xmlNsPtr or NULL if none
*/
xmlNsPtr
getNamespace(void *ctx ATTRIBUTE_UNUSED)
{
DEPRECATED("getNamespace")
return(NULL);
}
/**
* checkNamespace:
* @ctx: the user data (XML parser context)
* @namespace: the namespace to check against
*
* Check that the current element namespace is the same as the
* one read upon parsing.
* DEPRECATED
*
* Returns 1 if true 0 otherwise
*/
int
checkNamespace(void *ctx ATTRIBUTE_UNUSED, xmlChar *namespace ATTRIBUTE_UNUSED)
{
DEPRECATED("checkNamespace")
return(0);
}
/**
* namespaceDecl:
* @ctx: the user data (XML parser context)
* @href: the namespace associated URN
* @prefix: the namespace prefix
*
* A namespace has been parsed.
* DEPRECATED
*/
void
namespaceDecl(void *ctx ATTRIBUTE_UNUSED, const xmlChar *href ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED)
{
DEPRECATED("namespaceDecl")
}
/**
* comment:
* @ctx: the user data (XML parser context)
* @value: the comment content
*
* A comment has been parsed.
* DEPRECATED: use xmlSAX2Comment()
*/
void
comment(void *ctx, const xmlChar *value)
{
DEPRECATED("comment")
xmlSAX2Comment(ctx, value);
}
/**
* cdataBlock:
* @ctx: the user data (XML parser context)
* @value: The pcdata content
* @len: the block length
*
* called when a pcdata block has been parsed
* DEPRECATED: use xmlSAX2CDataBlock()
*/
void
cdataBlock(void *ctx, const xmlChar *value, int len)
{
DEPRECATED("cdataBlock")
xmlSAX2CDataBlock(ctx, value, len);
}
/**
* initxmlDefaultSAXHandler:
* @hdlr: the SAX handler
......
......@@ -560,12 +560,14 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
xmlFreeEnumeration(tree);
return;
}
#ifdef LIBXML_VALID_ENABLED
if (ctxt->vctxt.valid == 0)
ctxt->valid = 0;
if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) &&
(ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset != NULL))
ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
attr);
#endif /* LIBXML_VALID_ENABLED */
if (prefix != NULL)
xmlFree(prefix);
if (name != NULL)
......@@ -606,12 +608,14 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
name);
return;
}
#ifdef LIBXML_VALID_ENABLED
if (elem == NULL)
ctxt->valid = 0;
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &=
xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
#endif /* LIBXML_VALID_ENABLED */
}
/**
......@@ -654,11 +658,13 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
"SAX.xmlSAX2NotationDecl(%s) called while not in subset\n", name);
return;
}
#ifdef LIBXML_VALID_ENABLED
if (nota == NULL) ctxt->valid = 0;
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
nota);
#endif /* LIBXML_VALID_ENABLED */
}
/**
......@@ -827,9 +833,11 @@ xmlSAX2EndDocument(void *ctx)
xmlGenericError(xmlGenericErrorContext,
"SAX.xmlSAX2EndDocument()\n");
#endif
#ifdef LIBXML_VALID_ENABLED
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
#endif /* LIBXML_VALID_ENABLED */
/*
* Grab the encoding if it was added on-the-fly
......@@ -904,6 +912,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
return;
}
#ifdef LIBXML_VALID_ENABLED
/*
* Do the last stage of the attribute normalization
* Needed for HTML too:
......@@ -918,6 +927,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
}
if (nval != NULL)
value = nval;
#else
nval = NULL;
#endif /* LIBXML_VALID_ENABLED */