mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +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:
@ -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 */
|
||||
))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user