1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-02-04 01:47:02 +03:00

added a new configure option --with-push, some cleanups, chased code size

* HTMLparser.c Makefile.am configure.in legacy.c parser.c
  parserInternals.c testHTML.c xmllint.c include/libxml/HTMLparser.h
  include/libxml/parser.h include/libxml/parserInternals.h
  include/libxml/xmlversion.h.in: added a new configure
  option --with-push, some cleanups, chased code size anomalies.
  Now a library configured --with-minimum is around 150KB,
  sounds good enough.
Daniel
This commit is contained in:
Daniel Veillard 2003-09-30 12:36:01 +00:00
parent cd10104959
commit 73b013fc17
13 changed files with 464 additions and 373 deletions

View File

@ -1,3 +1,13 @@
Tue Sep 30 14:30:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c Makefile.am configure.in legacy.c parser.c
parserInternals.c testHTML.c xmllint.c include/libxml/HTMLparser.h
include/libxml/parser.h include/libxml/parserInternals.h
include/libxml/xmlversion.h.in: added a new configure
option --with-push, some cleanups, chased code size anomalies.
Now a library configured --with-minimum is around 150KB,
sounds good enough.
Tue Sep 30 12:31:00 AEST 2003 Malcolm Tredinnick <malcolm@commsecure.com.au>
* libxml-2.0-uninstalled.pc.in: New file for building against

View File

@ -4271,6 +4271,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
return(ctxt);
}
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
* Progressive parsing interfaces *
@ -5141,6 +5142,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
}
return((xmlParserErrors) ctxt->errNo);
}
#endif /* LIBXML_PUSH_ENABLED */
/************************************************************************
* *

View File

@ -122,7 +122,7 @@ check-local: tests
testall : tests SVGtests SAXtests
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@
tests: XMLtests XMLenttests NStests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @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:
@ -151,6 +151,8 @@ HTMLtests : testHTML$(EXEEXT)
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name error.$$name ; \
fi ; fi ; done)
HTMLPushtests : testHTML$(EXEEXT)
@echo "##"
@echo "## Push HTML regression tests"
@echo "##"
@ -230,6 +232,30 @@ XMLtests : xmllint$(EXEEXT)
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
@echo "##"
@echo "## XML regression tests on memory"
@echo "##"
@echo "## You should see two warnings on entity 'title.xml' for ent2"
@echo "##"
-@(for i in $(srcdir)/test/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/$$name ] ; then \
echo New test file $$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory $$i > $(srcdir)/result/$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
else \
echo Testing $$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory $$i > result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/$$name result.$$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory result.$$name > result2.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
XMLPushtests: xmllint$(EXEEXT)
@(echo > .memdump)
@echo "##"
@echo "## XML push regression tests"
@ -253,28 +279,6 @@ XMLtests : xmllint$(EXEEXT)
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
@echo "##"
@echo "## XML regression tests on memory"
@echo "##"
@echo "## You should see two warnings on entity 'title.xml' for ent2"
@echo "##"
-@(for i in $(srcdir)/test/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/$$name ] ; then \
echo New test file $$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory $$i > $(srcdir)/result/$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
else \
echo Testing $$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory $$i > result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/$$name result.$$name ; \
$(CHECKER) $(top_builddir)/xmllint --memory result.$$name > result2.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
NStests : xmllint$(EXEEXT)
@(echo > .memdump)

View File

@ -589,26 +589,6 @@ fi
AC_SUBST(WITH_HTTP)
AC_SUBST(HTTP_OBJ)
AC_ARG_WITH(html,
[ --with-html add the HTML support (on)])
if test "$with_minimum" = "yes" -a "$with_html" = ""
then
with_html=no
fi
if test "$with_html" = "no" ; then
echo Disabling HTML support
WITH_HTML=0
HTML_OBJ=
TEST_HTML=
else
WITH_HTML=1
HTML_OBJ="HTMLparser.o HTMLtree.o"
TEST_HTML=HTMLtests
fi
AC_SUBST(WITH_HTML)
AC_SUBST(HTML_OBJ)
AC_SUBST(TEST_HTML)
AC_ARG_WITH(legacy,
[ --with-legacy add deprecated APIs for compatibility (on)])
if test "$with_minimum" = "yes" -a "$with_legacy" = ""
@ -632,10 +612,13 @@ fi
if test "$with_reader" = "no" ; then
echo Disabling the xmlReader parsing interface
WITH_READER=0
READER_TEST=
else
WITH_READER=1
READER_TEST=Readertests
fi
AC_SUBST(WITH_READER)
AC_SUBST(READER_TEST)
AC_ARG_WITH(sax1,
[ --with-sax1 add the older SAX1 interface (on)])
@ -654,13 +637,56 @@ fi
AC_SUBST(WITH_SAX1)
AC_SUBST(TEST_SAX)
AC_ARG_WITH(push,
[ --with-push add the PUSH parser interfaces (on)])
if test "$with_minimum" = "yes" -a "$with_push" = ""
then
with_push=no
fi
if test "$with_push" = "no" ; then
echo Disabling the PUSH parser interfaces
WITH_PUSH=0
TEST_PUSH=
else
WITH_PUSH=1
TEST_PUSH="XMLPushtests"
fi
AC_SUBST(WITH_PUSH)
AC_SUBST(TEST_PUSH)
AC_ARG_WITH(html,
[ --with-html add the HTML support (on)])
if test "$with_minimum" = "yes" -a "$with_html" = ""
then
with_html=no
fi
if test "$with_html" = "no" ; then
echo Disabling HTML support
WITH_HTML=0
HTML_OBJ=
TEST_HTML=
else
WITH_HTML=1
HTML_OBJ="HTMLparser.o HTMLtree.o"
TEST_HTML=HTMLtests
if "$with_push" != "no" ; then
TEST_PHTML=HTMLPushtests
else
TEST_PHTML=
fi
fi
AC_SUBST(WITH_HTML)
AC_SUBST(HTML_OBJ)
AC_SUBST(TEST_HTML)
AC_SUBST(TEST_PHTML)
AC_ARG_WITH(valid,
[ --with-valid add the DTD validation support (on)])
if test "$with_minimum" = "yes" -a "$with_valid" = ""
then
with_valid=no
fi
if test "$with_html" = "no" ; then
if test "$with_valid" = "no" ; then
echo Disabling DTD validation support
WITH_VALID=0
TEST_VALID=
@ -863,7 +889,7 @@ fi
AC_SUBST(WITH_ISO8859X)
AC_ARG_WITH(schemas,
[ --with-schemas add experimental Schemas/RelaxNG support (on)])
[ --with-schemas add Relax-NG and experimental Schemas support (on)])
if test "$with_minimum" = "yes" -a "$with_schemas" = ""
then
with_schemas=no

View File

@ -136,11 +136,10 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
htmlHandleOmittedElem(int val);
#ifdef LIBXML_PUSH_ENABLED
/**
* Interfaces for the Push mode.
*/
XMLPUBFUN void XMLCALL
htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
void *user_data,
@ -153,6 +152,10 @@ XMLPUBFUN int XMLCALL
const char *chunk,
int size,
int terminate);
#endif /* LIBXML_PUSH_ENABLED */
XMLPUBFUN void XMLCALL
htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
/*
* New set of simpler/more flexible APIs

View File

@ -1000,6 +1000,7 @@ XMLPUBFUN int XMLCALL
const char *name,
void *value);
#ifdef LIBXML_PUSH_ENABLED
/*
* Interfaces for the Push mode.
*/
@ -1014,6 +1015,7 @@ XMLPUBFUN int XMLCALL
const char *chunk,
int size,
int terminate);
#endif /* LIBXML_PUSH_ENABLED */
/*
* Special I/O mode.

View File

@ -39,6 +39,18 @@ extern "C" {
* UNICODE version of the macros. *
* *
************************************************************************/
/**
* IS_BYTE_CHAR:
* @c: an byte value (int)
*
* Macro to check the following production in the XML spec:
*
* [2] Char ::= #x9 | #xA | #xD | [#x20...]
* any byte character in the accepted range
*/
#define IS_BYTE_CHAR(c) \
(((c) >= 0x20) || ((c) == 0x09) || ((c) == 0x0A) || ((c) == 0x0D))
/**
* IS_CHAR:
* @c: an UNICODE value (int)

View File

@ -101,6 +101,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_OUTPUT_ENABLED
#endif
/**
* LIBXML_PUSH_ENABLED:
*
* Whether the push parsing interfaces are configured in
*/
#if @WITH_PUSH@
#define LIBXML_PUSH_ENABLED
#endif
/**
* LIBXML_READER_ENABLED:
*

282
legacy.c
View File

@ -24,6 +24,288 @@ void xmlUpgradeOldNs(xmlDocPtr doc);
* *
************************************************************************/
static const char *xmlFeaturesList[] = {
"validate",
"load subset",
"keep blanks",
"disable SAX",
"fetch external entities",
"substitute entities",
"gather line info",
"user data",
"is html",
"is standalone",
"stop parser",
"document",
"is well formed",
"is valid",
"SAX block",
"SAX function internalSubset",
"SAX function isStandalone",
"SAX function hasInternalSubset",
"SAX function hasExternalSubset",
"SAX function resolveEntity",
"SAX function getEntity",
"SAX function entityDecl",
"SAX function notationDecl",
"SAX function attributeDecl",
"SAX function elementDecl",
"SAX function unparsedEntityDecl",
"SAX function setDocumentLocator",
"SAX function startDocument",
"SAX function endDocument",
"SAX function startElement",
"SAX function endElement",
"SAX function reference",
"SAX function characters",
"SAX function ignorableWhitespace",
"SAX function processingInstruction",
"SAX function comment",
"SAX function warning",
"SAX function error",
"SAX function fatalError",
"SAX function getParameterEntity",
"SAX function cdataBlock",
"SAX function externalSubset",
};
/**
* xmlGetFeaturesList:
* @len: the length of the features name array (input/output)
* @result: an array of string to be filled with the features name.
*
* Copy at most *@len feature names into the @result array
*
* Returns -1 in case or error, or the total number of features,
* len is updated with the number of strings copied,
* strings must not be deallocated
*/
int
xmlGetFeaturesList(int *len, const char **result) {
int ret, i;
ret = sizeof(xmlFeaturesList)/sizeof(xmlFeaturesList[0]);
if ((len == NULL) || (result == NULL))
return(ret);
if ((*len < 0) || (*len >= 1000))
return(-1);
if (*len > ret)
*len = ret;
for (i = 0;i < *len;i++)
result[i] = xmlFeaturesList[i];
return(ret);
}
/**
* xmlGetFeature:
* @ctxt: an XML/HTML parser context
* @name: the feature name
* @result: location to store the result
*
* Read the current value of one feature of this parser instance
*
* Returns -1 in case or error, 0 otherwise
*/
int
xmlGetFeature(xmlParserCtxtPtr ctxt, const char *name, void *result) {
if ((ctxt == NULL) || (name == NULL) || (result == NULL))
return(-1);
if (!strcmp(name, "validate")) {
*((int *) result) = ctxt->validate;
} else if (!strcmp(name, "keep blanks")) {
*((int *) result) = ctxt->keepBlanks;
} else if (!strcmp(name, "disable SAX")) {
*((int *) result) = ctxt->disableSAX;
} else if (!strcmp(name, "fetch external entities")) {
*((int *) result) = ctxt->loadsubset;
} else if (!strcmp(name, "substitute entities")) {
*((int *) result) = ctxt->replaceEntities;
} else if (!strcmp(name, "gather line info")) {
*((int *) result) = ctxt->record_info;
} else if (!strcmp(name, "user data")) {
*((void **)result) = ctxt->userData;
} else if (!strcmp(name, "is html")) {
*((int *) result) = ctxt->html;
} else if (!strcmp(name, "is standalone")) {
*((int *) result) = ctxt->standalone;
} else if (!strcmp(name, "document")) {
*((xmlDocPtr *) result) = ctxt->myDoc;
} else if (!strcmp(name, "is well formed")) {
*((int *) result) = ctxt->wellFormed;
} else if (!strcmp(name, "is valid")) {
*((int *) result) = ctxt->valid;
} else if (!strcmp(name, "SAX block")) {
*((xmlSAXHandlerPtr *) result) = ctxt->sax;
} else if (!strcmp(name, "SAX function internalSubset")) {
*((internalSubsetSAXFunc *) result) = ctxt->sax->internalSubset;
} else if (!strcmp(name, "SAX function isStandalone")) {
*((isStandaloneSAXFunc *) result) = ctxt->sax->isStandalone;
} else if (!strcmp(name, "SAX function hasInternalSubset")) {
*((hasInternalSubsetSAXFunc *) result) = ctxt->sax->hasInternalSubset;
} else if (!strcmp(name, "SAX function hasExternalSubset")) {
*((hasExternalSubsetSAXFunc *) result) = ctxt->sax->hasExternalSubset;
} else if (!strcmp(name, "SAX function resolveEntity")) {
*((resolveEntitySAXFunc *) result) = ctxt->sax->resolveEntity;
} else if (!strcmp(name, "SAX function getEntity")) {
*((getEntitySAXFunc *) result) = ctxt->sax->getEntity;
} else if (!strcmp(name, "SAX function entityDecl")) {
*((entityDeclSAXFunc *) result) = ctxt->sax->entityDecl;
} else if (!strcmp(name, "SAX function notationDecl")) {
*((notationDeclSAXFunc *) result) = ctxt->sax->notationDecl;
} else if (!strcmp(name, "SAX function attributeDecl")) {
*((attributeDeclSAXFunc *) result) = ctxt->sax->attributeDecl;
} else if (!strcmp(name, "SAX function elementDecl")) {
*((elementDeclSAXFunc *) result) = ctxt->sax->elementDecl;
} else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
*((unparsedEntityDeclSAXFunc *) result) = ctxt->sax->unparsedEntityDecl;
} else if (!strcmp(name, "SAX function setDocumentLocator")) {
*((setDocumentLocatorSAXFunc *) result) = ctxt->sax->setDocumentLocator;
} else if (!strcmp(name, "SAX function startDocument")) {
*((startDocumentSAXFunc *) result) = ctxt->sax->startDocument;
} else if (!strcmp(name, "SAX function endDocument")) {
*((endDocumentSAXFunc *) result) = ctxt->sax->endDocument;
} else if (!strcmp(name, "SAX function startElement")) {
*((startElementSAXFunc *) result) = ctxt->sax->startElement;
} else if (!strcmp(name, "SAX function endElement")) {
*((endElementSAXFunc *) result) = ctxt->sax->endElement;
} else if (!strcmp(name, "SAX function reference")) {
*((referenceSAXFunc *) result) = ctxt->sax->reference;
} else if (!strcmp(name, "SAX function characters")) {
*((charactersSAXFunc *) result) = ctxt->sax->characters;
} else if (!strcmp(name, "SAX function ignorableWhitespace")) {
*((ignorableWhitespaceSAXFunc *) result) = ctxt->sax->ignorableWhitespace;
} else if (!strcmp(name, "SAX function processingInstruction")) {
*((processingInstructionSAXFunc *) result) = ctxt->sax->processingInstruction;
} else if (!strcmp(name, "SAX function comment")) {
*((commentSAXFunc *) result) = ctxt->sax->comment;
} else if (!strcmp(name, "SAX function warning")) {
*((warningSAXFunc *) result) = ctxt->sax->warning;
} else if (!strcmp(name, "SAX function error")) {
*((errorSAXFunc *) result) = ctxt->sax->error;
} else if (!strcmp(name, "SAX function fatalError")) {
*((fatalErrorSAXFunc *) result) = ctxt->sax->fatalError;
} else if (!strcmp(name, "SAX function getParameterEntity")) {
*((getParameterEntitySAXFunc *) result) = ctxt->sax->getParameterEntity;
} else if (!strcmp(name, "SAX function cdataBlock")) {
*((cdataBlockSAXFunc *) result) = ctxt->sax->cdataBlock;
} else if (!strcmp(name, "SAX function externalSubset")) {
*((externalSubsetSAXFunc *) result) = ctxt->sax->externalSubset;
} else {
return(-1);
}
return(0);
}
/**
* xmlSetFeature:
* @ctxt: an XML/HTML parser context
* @name: the feature name
* @value: pointer to the location of the new value
*
* Change the current value of one feature of this parser instance
*
* Returns -1 in case or error, 0 otherwise
*/
int
xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) {
if ((ctxt == NULL) || (name == NULL) || (value == NULL))
return(-1);
if (!strcmp(name, "validate")) {
int newvalidate = *((int *) value);
if ((!ctxt->validate) && (newvalidate != 0)) {
if (ctxt->vctxt.warning == NULL)
ctxt->vctxt.warning = xmlParserValidityWarning;
if (ctxt->vctxt.error == NULL)
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.nodeMax = 0;
}
ctxt->validate = newvalidate;
} else if (!strcmp(name, "keep blanks")) {
ctxt->keepBlanks = *((int *) value);
} else if (!strcmp(name, "disable SAX")) {
ctxt->disableSAX = *((int *) value);
} else if (!strcmp(name, "fetch external entities")) {
ctxt->loadsubset = *((int *) value);
} else if (!strcmp(name, "substitute entities")) {
ctxt->replaceEntities = *((int *) value);
} else if (!strcmp(name, "gather line info")) {
ctxt->record_info = *((int *) value);
} else if (!strcmp(name, "user data")) {
ctxt->userData = *((void **)value);
} else if (!strcmp(name, "is html")) {
ctxt->html = *((int *) value);
} else if (!strcmp(name, "is standalone")) {
ctxt->standalone = *((int *) value);
} else if (!strcmp(name, "document")) {
ctxt->myDoc = *((xmlDocPtr *) value);
} else if (!strcmp(name, "is well formed")) {
ctxt->wellFormed = *((int *) value);
} else if (!strcmp(name, "is valid")) {
ctxt->valid = *((int *) value);
} else if (!strcmp(name, "SAX block")) {
ctxt->sax = *((xmlSAXHandlerPtr *) value);
} else if (!strcmp(name, "SAX function internalSubset")) {
ctxt->sax->internalSubset = *((internalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function isStandalone")) {
ctxt->sax->isStandalone = *((isStandaloneSAXFunc *) value);
} else if (!strcmp(name, "SAX function hasInternalSubset")) {
ctxt->sax->hasInternalSubset = *((hasInternalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function hasExternalSubset")) {
ctxt->sax->hasExternalSubset = *((hasExternalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function resolveEntity")) {
ctxt->sax->resolveEntity = *((resolveEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function getEntity")) {
ctxt->sax->getEntity = *((getEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function entityDecl")) {
ctxt->sax->entityDecl = *((entityDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function notationDecl")) {
ctxt->sax->notationDecl = *((notationDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function attributeDecl")) {
ctxt->sax->attributeDecl = *((attributeDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function elementDecl")) {
ctxt->sax->elementDecl = *((elementDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
ctxt->sax->unparsedEntityDecl = *((unparsedEntityDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function setDocumentLocator")) {
ctxt->sax->setDocumentLocator = *((setDocumentLocatorSAXFunc *) value);
} else if (!strcmp(name, "SAX function startDocument")) {
ctxt->sax->startDocument = *((startDocumentSAXFunc *) value);
} else if (!strcmp(name, "SAX function endDocument")) {
ctxt->sax->endDocument = *((endDocumentSAXFunc *) value);
} else if (!strcmp(name, "SAX function startElement")) {
ctxt->sax->startElement = *((startElementSAXFunc *) value);
} else if (!strcmp(name, "SAX function endElement")) {
ctxt->sax->endElement = *((endElementSAXFunc *) value);
} else if (!strcmp(name, "SAX function reference")) {
ctxt->sax->reference = *((referenceSAXFunc *) value);
} else if (!strcmp(name, "SAX function characters")) {
ctxt->sax->characters = *((charactersSAXFunc *) value);
} else if (!strcmp(name, "SAX function ignorableWhitespace")) {
ctxt->sax->ignorableWhitespace = *((ignorableWhitespaceSAXFunc *) value);
} else if (!strcmp(name, "SAX function processingInstruction")) {
ctxt->sax->processingInstruction = *((processingInstructionSAXFunc *) value);
} else if (!strcmp(name, "SAX function comment")) {
ctxt->sax->comment = *((commentSAXFunc *) value);
} else if (!strcmp(name, "SAX function warning")) {
ctxt->sax->warning = *((warningSAXFunc *) value);
} else if (!strcmp(name, "SAX function error")) {
ctxt->sax->error = *((errorSAXFunc *) value);
} else if (!strcmp(name, "SAX function fatalError")) {
ctxt->sax->fatalError = *((fatalErrorSAXFunc *) value);
} else if (!strcmp(name, "SAX function getParameterEntity")) {
ctxt->sax->getParameterEntity = *((getParameterEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function cdataBlock")) {
ctxt->sax->cdataBlock = *((cdataBlockSAXFunc *) value);
} else if (!strcmp(name, "SAX function externalSubset")) {
ctxt->sax->externalSubset = *((externalSubsetSAXFunc *) value);
} else {
return(-1);
}
return(0);
}
/**
* xmlDecodeEntities:
* @ctxt: the parser context

View File

@ -1419,7 +1419,7 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
* Characters referred to using character references must match the
* production for Char.
*/
if (IS_CHAR(val)) {
if (xmlIsChar(val)) {
return(val);
} else {
xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
@ -1503,7 +1503,7 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
* Characters referred to using character references must match the
* production for Char.
*/
if (IS_CHAR(val)) {
if (xmlIsChar(val)) {
return(val);
} else {
xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
@ -2754,11 +2754,11 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
}
while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
((xmlIsLetter(c)) || (xmlIsDigit(c)) ||
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c)))) {
if (count++ > 100) {
count = 0;
GROW;
@ -2796,16 +2796,16 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
int c;
c = CUR_SCHAR(cur, l);
if (!IS_LETTER(c) && (c != '_') &&
if (!xmlIsLetter(c) && (c != '_') &&
(c != ':')) {
return(NULL);
}
while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigentname.xml */
while ((xmlIsLetter(c)) || (xmlIsDigit(c)) || /* test bigentname.xml */
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c))) {
COPY_BUF(l,buf,len,c);
cur += l;
c = CUR_SCHAR(cur, l);
@ -2823,11 +2823,12 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
return(NULL);
}
memcpy(buffer, buf, len);
while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigentname.xml */
while ((xmlIsLetter(c)) || (xmlIsDigit(c)) ||
/* test bigentname.xml */
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c))) {
if (len + 10 > max) {
max *= 2;
buffer = (xmlChar *) xmlRealloc(buffer,
@ -2873,11 +2874,11 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
GROW;
c = CUR_CHAR(l);
while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigtoken.xml */
while ((xmlIsLetter(c)) || (xmlIsDigit(c)) || /* test bigtoken.xml */
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c))) {
if (count++ > 100) {
count = 0;
GROW;
@ -2899,11 +2900,11 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
return(NULL);
}
memcpy(buffer, buf, len);
while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigtoken.xml */
while ((xmlIsLetter(c)) || (xmlIsDigit(c)) || /* test bigtoken.xml */
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c))) {
if (count++ > 100) {
count = 0;
GROW;
@ -2984,7 +2985,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
* In practice it means we stop the loop only when back at parsing
* the initial entity and the quote is found
*/
while ((IS_CHAR(c)) && ((c != stop) || /* checked */
while ((xmlIsChar(c)) && ((c != stop) || /* checked */
(ctxt->input != input))) {
if (len + 5 >= size) {
size *= 2;
@ -3336,7 +3337,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
}
ctxt->instate = XML_PARSER_SYSTEM_LITERAL;
cur = CUR_CHAR(l);
while ((IS_CHAR(cur)) && (cur != stop)) { /* checked */
while ((xmlIsChar(cur)) && (cur != stop)) { /* checked */
if (len + 5 >= size) {
size *= 2;
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
@ -3362,7 +3363,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
}
buf[len] = 0;
ctxt->instate = (xmlParserInputState) state;
if (!IS_CHAR(cur)) {
if (!xmlIsChar(cur)) {
xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, NULL);
} else {
NEXT;
@ -3570,7 +3571,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
cur = CUR_CHAR(l);
while ((cur != '<') && /* checked */
(cur != '&') &&
(IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ {
(xmlIsChar(cur))) /* test also done in xmlCurrentChar() */ {
if ((cur == ']') && (NXT(1) == ']') &&
(NXT(2) == '>')) {
if (cdata) break;
@ -3753,7 +3754,7 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
NEXTL(rl);
cur = CUR_CHAR(l);
len = 0;
while (IS_CHAR(cur) && /* checked */
while (xmlIsChar(cur) && /* checked */
((cur != '>') ||
(r != '-') || (q != '-'))) {
if ((r == '-') && (q == '-')) {
@ -3788,7 +3789,7 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
}
}
buf[len] = 0;
if (!IS_CHAR(cur)) {
if (!xmlIsChar(cur)) {
xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated \n<!--%.50s\n", buf);
xmlFree(buf);
@ -3980,7 +3981,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
}
SKIP_BLANKS;
cur = CUR_CHAR(l);
while (IS_CHAR(cur) && /* checked */
while (xmlIsChar(cur) && /* checked */
((cur != '?') || (NXT(1) != '>'))) {
if (len + 5 >= size) {
size *= 2;
@ -6901,7 +6902,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
while ((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_CHAR((unsigned int) RAW))) {
(IS_BYTE_CHAR(RAW))) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
@ -7033,7 +7034,7 @@ xmlParseEndTag1(xmlParserCtxtPtr ctxt, int line) {
*/
GROW;
SKIP_BLANKS;
if ((!IS_CHAR((unsigned int) RAW)) || (RAW != '>')) {
if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) {
xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
} else
NEXT1;
@ -7115,10 +7116,10 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
}
while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
((xmlIsLetter(c)) || (xmlIsDigit(c)) ||
(c == '.') || (c == '-') || (c == '_') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
(xmlIsCombining(c)) ||
(xmlIsExtender(c)))) {
if (count++ > 100) {
count = 0;
GROW;
@ -7662,7 +7663,7 @@ reparse:
while ((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_CHAR((unsigned int) RAW))) {
(IS_BYTE_CHAR(RAW))) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int len = -1, alloc = 0;
@ -7996,7 +7997,7 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
*/
GROW;
SKIP_BLANKS;
if ((!IS_CHAR((unsigned int) RAW)) || (RAW != '>')) {
if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) {
xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
} else
NEXT1;
@ -8072,14 +8073,14 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
ctxt->instate = XML_PARSER_CDATA_SECTION;
r = CUR_CHAR(rl);
if (!IS_CHAR(r)) {
if (!xmlIsChar(r)) {
xmlFatalErr(ctxt, XML_ERR_CDATA_NOT_FINISHED, NULL);
ctxt->instate = XML_PARSER_CONTENT;
return;
}
NEXTL(rl);
s = CUR_CHAR(sl);
if (!IS_CHAR(s)) {
if (!xmlIsChar(s)) {
xmlFatalErr(ctxt, XML_ERR_CDATA_NOT_FINISHED, NULL);
ctxt->instate = XML_PARSER_CONTENT;
return;
@ -8091,7 +8092,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
xmlErrMemory(ctxt, NULL);
return;
}
while (IS_CHAR(cur) &&
while (xmlIsChar(cur) &&
((r != ']') || (s != ']') || (cur != '>'))) {
if (len + 5 >= size) {
size *= 2;
@ -8350,7 +8351,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
* Parse the content of the element:
*/
xmlParseContent(ctxt);
if (!IS_CHAR((unsigned int) RAW)) {
if (!IS_BYTE_CHAR(RAW)) {
ctxt->errNo = XML_ERR_TAG_NOT_FINISHED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
@ -9099,6 +9100,7 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
return(0);
}
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
* Progressive parsing interfaces *
@ -10274,6 +10276,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
return(ctxt);
}
#endif /* LIBXML_PUSH_ENABLED */
/**
* xmlCreateIOParserCtxt:

View File

@ -86,289 +86,6 @@ xmlCheckVersion(int version) {
}
}
static const char *xmlFeaturesList[] = {
"validate",
"load subset",
"keep blanks",
"disable SAX",
"fetch external entities",
"substitute entities",
"gather line info",
"user data",
"is html",
"is standalone",
"stop parser",
"document",
"is well formed",
"is valid",
"SAX block",
"SAX function internalSubset",
"SAX function isStandalone",
"SAX function hasInternalSubset",
"SAX function hasExternalSubset",
"SAX function resolveEntity",
"SAX function getEntity",
"SAX function entityDecl",
"SAX function notationDecl",
"SAX function attributeDecl",
"SAX function elementDecl",
"SAX function unparsedEntityDecl",
"SAX function setDocumentLocator",
"SAX function startDocument",
"SAX function endDocument",
"SAX function startElement",
"SAX function endElement",
"SAX function reference",
"SAX function characters",
"SAX function ignorableWhitespace",
"SAX function processingInstruction",
"SAX function comment",
"SAX function warning",
"SAX function error",
"SAX function fatalError",
"SAX function getParameterEntity",
"SAX function cdataBlock",
"SAX function externalSubset",
};
/**
* xmlGetFeaturesList:
* @len: the length of the features name array (input/output)
* @result: an array of string to be filled with the features name.
*
* Copy at most *@len feature names into the @result array
*
* Returns -1 in case or error, or the total number of features,
* len is updated with the number of strings copied,
* strings must not be deallocated
*/
int
xmlGetFeaturesList(int *len, const char **result) {
int ret, i;
ret = sizeof(xmlFeaturesList)/sizeof(xmlFeaturesList[0]);
if ((len == NULL) || (result == NULL))
return(ret);
if ((*len < 0) || (*len >= 1000))
return(-1);
if (*len > ret)
*len = ret;
for (i = 0;i < *len;i++)
result[i] = xmlFeaturesList[i];
return(ret);
}
/**
* xmlGetFeature:
* @ctxt: an XML/HTML parser context
* @name: the feature name
* @result: location to store the result
*
* Read the current value of one feature of this parser instance
*
* Returns -1 in case or error, 0 otherwise
*/
int
xmlGetFeature(xmlParserCtxtPtr ctxt, const char *name, void *result) {
if ((ctxt == NULL) || (name == NULL) || (result == NULL))
return(-1);
if (!strcmp(name, "validate")) {
*((int *) result) = ctxt->validate;
} else if (!strcmp(name, "keep blanks")) {
*((int *) result) = ctxt->keepBlanks;
} else if (!strcmp(name, "disable SAX")) {
*((int *) result) = ctxt->disableSAX;
} else if (!strcmp(name, "fetch external entities")) {
*((int *) result) = ctxt->loadsubset;
} else if (!strcmp(name, "substitute entities")) {
*((int *) result) = ctxt->replaceEntities;
} else if (!strcmp(name, "gather line info")) {
*((int *) result) = ctxt->record_info;
} else if (!strcmp(name, "user data")) {
*((void **)result) = ctxt->userData;
} else if (!strcmp(name, "is html")) {
*((int *) result) = ctxt->html;
} else if (!strcmp(name, "is standalone")) {
*((int *) result) = ctxt->standalone;
} else if (!strcmp(name, "document")) {
*((xmlDocPtr *) result) = ctxt->myDoc;
} else if (!strcmp(name, "is well formed")) {
*((int *) result) = ctxt->wellFormed;
} else if (!strcmp(name, "is valid")) {
*((int *) result) = ctxt->valid;
} else if (!strcmp(name, "SAX block")) {
*((xmlSAXHandlerPtr *) result) = ctxt->sax;
} else if (!strcmp(name, "SAX function internalSubset")) {
*((internalSubsetSAXFunc *) result) = ctxt->sax->internalSubset;
} else if (!strcmp(name, "SAX function isStandalone")) {
*((isStandaloneSAXFunc *) result) = ctxt->sax->isStandalone;
} else if (!strcmp(name, "SAX function hasInternalSubset")) {
*((hasInternalSubsetSAXFunc *) result) = ctxt->sax->hasInternalSubset;
} else if (!strcmp(name, "SAX function hasExternalSubset")) {
*((hasExternalSubsetSAXFunc *) result) = ctxt->sax->hasExternalSubset;
} else if (!strcmp(name, "SAX function resolveEntity")) {
*((resolveEntitySAXFunc *) result) = ctxt->sax->resolveEntity;
} else if (!strcmp(name, "SAX function getEntity")) {
*((getEntitySAXFunc *) result) = ctxt->sax->getEntity;
} else if (!strcmp(name, "SAX function entityDecl")) {
*((entityDeclSAXFunc *) result) = ctxt->sax->entityDecl;
} else if (!strcmp(name, "SAX function notationDecl")) {
*((notationDeclSAXFunc *) result) = ctxt->sax->notationDecl;
} else if (!strcmp(name, "SAX function attributeDecl")) {
*((attributeDeclSAXFunc *) result) = ctxt->sax->attributeDecl;
} else if (!strcmp(name, "SAX function elementDecl")) {
*((elementDeclSAXFunc *) result) = ctxt->sax->elementDecl;
} else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
*((unparsedEntityDeclSAXFunc *) result) = ctxt->sax->unparsedEntityDecl;
} else if (!strcmp(name, "SAX function setDocumentLocator")) {
*((setDocumentLocatorSAXFunc *) result) = ctxt->sax->setDocumentLocator;
} else if (!strcmp(name, "SAX function startDocument")) {
*((startDocumentSAXFunc *) result) = ctxt->sax->startDocument;
} else if (!strcmp(name, "SAX function endDocument")) {
*((endDocumentSAXFunc *) result) = ctxt->sax->endDocument;
} else if (!strcmp(name, "SAX function startElement")) {
*((startElementSAXFunc *) result) = ctxt->sax->startElement;
} else if (!strcmp(name, "SAX function endElement")) {
*((endElementSAXFunc *) result) = ctxt->sax->endElement;
} else if (!strcmp(name, "SAX function reference")) {
*((referenceSAXFunc *) result) = ctxt->sax->reference;
} else if (!strcmp(name, "SAX function characters")) {
*((charactersSAXFunc *) result) = ctxt->sax->characters;
} else if (!strcmp(name, "SAX function ignorableWhitespace")) {
*((ignorableWhitespaceSAXFunc *) result) = ctxt->sax->ignorableWhitespace;
} else if (!strcmp(name, "SAX function processingInstruction")) {
*((processingInstructionSAXFunc *) result) = ctxt->sax->processingInstruction;
} else if (!strcmp(name, "SAX function comment")) {
*((commentSAXFunc *) result) = ctxt->sax->comment;
} else if (!strcmp(name, "SAX function warning")) {
*((warningSAXFunc *) result) = ctxt->sax->warning;
} else if (!strcmp(name, "SAX function error")) {
*((errorSAXFunc *) result) = ctxt->sax->error;
} else if (!strcmp(name, "SAX function fatalError")) {
*((fatalErrorSAXFunc *) result) = ctxt->sax->fatalError;
} else if (!strcmp(name, "SAX function getParameterEntity")) {
*((getParameterEntitySAXFunc *) result) = ctxt->sax->getParameterEntity;
} else if (!strcmp(name, "SAX function cdataBlock")) {
*((cdataBlockSAXFunc *) result) = ctxt->sax->cdataBlock;
} else if (!strcmp(name, "SAX function externalSubset")) {
*((externalSubsetSAXFunc *) result) = ctxt->sax->externalSubset;
} else {
return(-1);
}
return(0);
}
/**
* xmlSetFeature:
* @ctxt: an XML/HTML parser context
* @name: the feature name
* @value: pointer to the location of the new value
*
* Change the current value of one feature of this parser instance
*
* Returns -1 in case or error, 0 otherwise
*/
int
xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) {
if ((ctxt == NULL) || (name == NULL) || (value == NULL))
return(-1);
if (!strcmp(name, "validate")) {
int newvalidate = *((int *) value);
if ((!ctxt->validate) && (newvalidate != 0)) {
if (ctxt->vctxt.warning == NULL)
ctxt->vctxt.warning = xmlParserValidityWarning;
if (ctxt->vctxt.error == NULL)
ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.nodeMax = 0;
}
ctxt->validate = newvalidate;
} else if (!strcmp(name, "keep blanks")) {
ctxt->keepBlanks = *((int *) value);
} else if (!strcmp(name, "disable SAX")) {
ctxt->disableSAX = *((int *) value);
} else if (!strcmp(name, "fetch external entities")) {
ctxt->loadsubset = *((int *) value);
} else if (!strcmp(name, "substitute entities")) {
ctxt->replaceEntities = *((int *) value);
} else if (!strcmp(name, "gather line info")) {
ctxt->record_info = *((int *) value);
} else if (!strcmp(name, "user data")) {
ctxt->userData = *((void **)value);
} else if (!strcmp(name, "is html")) {
ctxt->html = *((int *) value);
} else if (!strcmp(name, "is standalone")) {
ctxt->standalone = *((int *) value);
} else if (!strcmp(name, "document")) {
ctxt->myDoc = *((xmlDocPtr *) value);
} else if (!strcmp(name, "is well formed")) {
ctxt->wellFormed = *((int *) value);
} else if (!strcmp(name, "is valid")) {
ctxt->valid = *((int *) value);
} else if (!strcmp(name, "SAX block")) {
ctxt->sax = *((xmlSAXHandlerPtr *) value);
} else if (!strcmp(name, "SAX function internalSubset")) {
ctxt->sax->internalSubset = *((internalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function isStandalone")) {
ctxt->sax->isStandalone = *((isStandaloneSAXFunc *) value);
} else if (!strcmp(name, "SAX function hasInternalSubset")) {
ctxt->sax->hasInternalSubset = *((hasInternalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function hasExternalSubset")) {
ctxt->sax->hasExternalSubset = *((hasExternalSubsetSAXFunc *) value);
} else if (!strcmp(name, "SAX function resolveEntity")) {
ctxt->sax->resolveEntity = *((resolveEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function getEntity")) {
ctxt->sax->getEntity = *((getEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function entityDecl")) {
ctxt->sax->entityDecl = *((entityDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function notationDecl")) {
ctxt->sax->notationDecl = *((notationDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function attributeDecl")) {
ctxt->sax->attributeDecl = *((attributeDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function elementDecl")) {
ctxt->sax->elementDecl = *((elementDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
ctxt->sax->unparsedEntityDecl = *((unparsedEntityDeclSAXFunc *) value);
} else if (!strcmp(name, "SAX function setDocumentLocator")) {
ctxt->sax->setDocumentLocator = *((setDocumentLocatorSAXFunc *) value);
} else if (!strcmp(name, "SAX function startDocument")) {
ctxt->sax->startDocument = *((startDocumentSAXFunc *) value);
} else if (!strcmp(name, "SAX function endDocument")) {
ctxt->sax->endDocument = *((endDocumentSAXFunc *) value);
} else if (!strcmp(name, "SAX function startElement")) {
ctxt->sax->startElement = *((startElementSAXFunc *) value);
} else if (!strcmp(name, "SAX function endElement")) {
ctxt->sax->endElement = *((endElementSAXFunc *) value);
} else if (!strcmp(name, "SAX function reference")) {
ctxt->sax->reference = *((referenceSAXFunc *) value);
} else if (!strcmp(name, "SAX function characters")) {
ctxt->sax->characters = *((charactersSAXFunc *) value);
} else if (!strcmp(name, "SAX function ignorableWhitespace")) {
ctxt->sax->ignorableWhitespace = *((ignorableWhitespaceSAXFunc *) value);
} else if (!strcmp(name, "SAX function processingInstruction")) {
ctxt->sax->processingInstruction = *((processingInstructionSAXFunc *) value);
} else if (!strcmp(name, "SAX function comment")) {
ctxt->sax->comment = *((commentSAXFunc *) value);
} else if (!strcmp(name, "SAX function warning")) {
ctxt->sax->warning = *((warningSAXFunc *) value);
} else if (!strcmp(name, "SAX function error")) {
ctxt->sax->error = *((errorSAXFunc *) value);
} else if (!strcmp(name, "SAX function fatalError")) {
ctxt->sax->fatalError = *((fatalErrorSAXFunc *) value);
} else if (!strcmp(name, "SAX function getParameterEntity")) {
ctxt->sax->getParameterEntity = *((getParameterEntitySAXFunc *) value);
} else if (!strcmp(name, "SAX function cdataBlock")) {
ctxt->sax->cdataBlock = *((cdataBlockSAXFunc *) value);
} else if (!strcmp(name, "SAX function externalSubset")) {
ctxt->sax->externalSubset = *((externalSubsetSAXFunc *) value);
} else {
return(-1);
}
return(0);
}
/************************************************************************
* *
* Some functions to avoid too large macros *
@ -446,10 +163,8 @@ static int xmlBaseArray[] = {
*/
int
xmlIsBaseChar(int c) {
return(
(((c) < 0x0100) ? xmlBaseArray[c] :
( /* accelerator */
(((c) >= 0x0100) && ((c) <= 0x0131)) ||
if (c < 0x0100) return(xmlBaseArray[c]);
return((((c) >= 0x0100) && ((c) <= 0x0131)) ||
(((c) >= 0x0134) && ((c) <= 0x013E)) ||
(((c) >= 0x0141) && ((c) <= 0x0148)) ||
(((c) >= 0x014A) && ((c) <= 0x017E)) ||
@ -647,7 +362,8 @@ xmlIsBaseChar(int c) {
(((c) >= 0x3041) && ((c) <= 0x3094)) ||
(((c) >= 0x30A1) && ((c) <= 0x30FA)) ||
(((c) >= 0x3105) && ((c) <= 0x312C)) ||
(((c) >= 0xAC00) && ((c) <= 0xD7A3))) /* accelerators */ ))))));
(((c) >= 0xAC00) && ((c) <= 0xD7A3))) /* accelerators */
))));
}
/**

View File

@ -44,7 +44,9 @@ static int copy = 0;
static int sax = 0;
static int repeat = 0;
static int noout = 0;
#ifdef LIBXML_PUSH_ENABLED
static int push = 0;
#endif /* LIBXML_PUSH_ENABLED */
static char *encoding = NULL;
static int options = 0;
@ -619,6 +621,7 @@ parseSAXFile(char *filename) {
/*
* Empty callbacks for checking
*/
#ifdef LIBXML_PUSH_ENABLED
if (push) {
FILE *f;
@ -675,6 +678,7 @@ parseSAXFile(char *filename) {
}
}
} else {
#endif /* LIBXML_PUSH_ENABLED */
doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL);
if (doc != NULL) {
fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
@ -691,7 +695,9 @@ parseSAXFile(char *filename) {
xmlFreeDoc(doc);
}
}
#ifdef LIBXML_PUSH_ENABLED
}
#endif /* LIBXML_PUSH_ENABLED */
}
static void
@ -782,8 +788,10 @@ int main(int argc, char **argv) {
#endif
if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
copy++;
#ifdef LIBXML_PUSH_ENABLED
else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push")))
push++;
#endif /* LIBXML_PUSH_ENABLED */
else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax")))
sax++;
else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout")))
@ -831,7 +839,9 @@ int main(int argc, char **argv) {
printf("\t--sax : debug the sequence of SAX callbacks\n");
printf("\t--repeat : parse the file 100 times, for timing\n");
printf("\t--noout : do not print the result\n");
#ifdef LIBXML_PUSH_ENABLED
printf("\t--push : use the push mode parser\n");
#endif /* LIBXML_PUSH_ENABLED */
printf("\t--encode encoding : output in the given encoding\n");
}
xmlCleanupParser();

View File

@ -130,7 +130,9 @@ static int insert = 0;
static int html = 0;
#endif
static int htmlout = 0;
#ifdef LIBXML_PUSH_ENABLED
static int push = 0;
#endif /* LIBXML_PUSH_ENABLED */
#ifdef HAVE_SYS_MMAN_H
static int memory = 0;
#endif
@ -763,6 +765,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
#endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_HTML_ENABLED
#ifdef LIBXML_PUSH_ENABLED
else if ((html) && (push)) {
FILE *f;
@ -788,11 +791,13 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
fclose(f);
}
}
#endif /* LIBXML_PUSH_ENABLED */
else if (html) {
doc = htmlReadFile(filename, NULL, options);
}
#endif /* LIBXML_HTML_ENABLED */
else {
#ifdef LIBXML_PUSH_ENABLED
/*
* build an XML tree from a string;
*/
@ -829,7 +834,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
}
}
} else if (testIO) {
} else
#endif /* LIBXML_PUSH_ENABLED */
if (testIO) {
if ((filename[0] == '-') && (filename[1] == 0)) {
doc = xmlReadFd(0, NULL, NULL, options);
} else {
@ -1339,7 +1346,9 @@ static void usage(const char *name) {
#ifdef LIBXML_HTML_ENABLED
printf("\t--html : use the HTML parser\n");
#endif
#ifdef LIBXML_PUSH_ENABLED
printf("\t--push : use the push mode of the parser\n");
#endif /* LIBXML_PUSH_ENABLED */
#ifdef HAVE_SYS_MMAN_H
printf("\t--memory : parse from memory\n");
#endif
@ -1516,9 +1525,12 @@ main(int argc, char **argv) {
repeat *= 10;
else
repeat = 100;
} else if ((!strcmp(argv[i], "-push")) ||
}
#ifdef LIBXML_PUSH_ENABLED
else if ((!strcmp(argv[i], "-push")) ||
(!strcmp(argv[i], "--push")))
push++;
#endif /* LIBXML_PUSH_ENABLED */
#ifdef HAVE_SYS_MMAN_H
else if ((!strcmp(argv[i], "-memory")) ||
(!strcmp(argv[i], "--memory")))