diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-07-16 00:06:07 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-07-16 00:06:07 +0000 |
commit | 220907319a06129ee3ae791a436edc68eb332f68 (patch) | |
tree | fae3981640e6da4efbcd8912e6c43046dbdf1f02 | |
parent | 496be6838858455849f48b048b954f04809dd6e3 (diff) | |
download | libxml2-220907319a06129ee3ae791a436edc68eb332f68.tar.gz |
cleanup of global variables, marking some const or private. Daniel
* include/libxml/parserInternals.h include/libxml/HTMLparser.h
xmlIO.c tree.c parserInternals.c entities.c encoding.c
HTMLparser.c: cleanup of global variables, marking some
const or private.
Daniel
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | HTMLparser.c | 40 | ||||
-rw-r--r-- | encoding.c | 4 | ||||
-rw-r--r-- | entities.c | 5 | ||||
-rw-r--r-- | include/libxml/HTMLparser.h | 6 | ||||
-rw-r--r-- | include/libxml/parserInternals.h | 10 | ||||
-rw-r--r-- | parserInternals.c | 2 | ||||
-rw-r--r-- | tree.c | 15 | ||||
-rw-r--r-- | xmlIO.c | 12 |
9 files changed, 52 insertions, 49 deletions
@@ -1,3 +1,10 @@ +Mon Jul 16 20:05:27 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> + + * include/libxml/parserInternals.h include/libxml/HTMLparser.h + xmlIO.c tree.c parserInternals.c entities.c encoding.c + HTMLparser.c: cleanup of global variables, marking some + const or private. + Sun Jul 16 00:17:15 CEST 2001 Thomas Broyer <tbroyer@ltgt.net> * include/libxml/xpath.h: exported xmlXPath{NAN,PINF,NINF} diff --git a/HTMLparser.c b/HTMLparser.c index ea244f52..8812c3d0 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -48,7 +48,7 @@ /* #define DEBUG */ /* #define DEBUG_PUSH */ -int htmlOmittedDefaultValue = 1; +static int htmlOmittedDefaultValue = 1; xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len, xmlChar end, xmlChar end2, xmlChar end3); @@ -353,7 +353,8 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) { * * Name,Start Tag,End Tag,Save End,Empty,Deprecated,DTD,inline,Description */ -htmlElemDesc html40ElementTable[] = { +static const htmlElemDesc +html40ElementTable[] = { { "a", 0, 0, 0, 0, 0, 0, 1, "anchor " }, { "abbr", 0, 0, 0, 0, 0, 0, 1, "abbreviated form" }, { "acronym", 0, 0, 0, 0, 0, 0, 1, "" }, @@ -448,26 +449,9 @@ htmlElemDesc html40ElementTable[] = { }; /* - * start tags that imply the end of a current element - * any tag of each line implies the end of the current element if the type of - * that element is in the same line - */ -const char *htmlEquEnd[] = { -"dt", "dd", "li", "option", NULL, -"h1", "h2", "h3", "h4", "h5", "h6", NULL, -"ol", "menu", "dir", "address", "pre", "listing", "xmp", NULL, -NULL -}; -/* - * acording the HTML DTD, HR should be added to the 2nd line above, as it - * is not allowed within a H1, H2, H3, etc. But we should tolerate that case - * because many documents contain rules in headings... - */ - -/* * start tags that imply the end of current element */ -const char *htmlStartClose[] = { +static const char *htmlStartClose[] = { "form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "dl", "ul", "ol", "menu", "dir", "address", "pre", "listing", "xmp", "head", NULL, @@ -577,7 +561,7 @@ typedef struct { int priority; } elementPriority; -const elementPriority htmlEndPriority[] = { +static const elementPriority htmlEndPriority[] = { {"div", 150}, {"td", 160}, {"th", 160}, @@ -632,14 +616,14 @@ htmlInitAutoClose(void) { * * Returns the related htmlElemDescPtr or NULL if not found. */ -htmlElemDescPtr +const htmlElemDescPtr htmlTagLookup(const xmlChar *tag) { unsigned int i; for (i = 0; i < (sizeof(html40ElementTable) / sizeof(html40ElementTable[0]));i++) { if (!xmlStrcasecmp(tag, BAD_CAST html40ElementTable[i].name)) - return(&html40ElementTable[i]); + return((const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) &html40ElementTable[i]); } return(NULL); } @@ -1042,7 +1026,7 @@ htmlIsScriptAttribute(const xmlChar *name) { ************************************************************************/ -htmlEntityDesc html40EntitiesTable[] = { +static const htmlEntityDesc html40EntitiesTable[] = { /* * the 4 absolute ones, plus apostrophe. */ @@ -1353,7 +1337,7 @@ htmlEntityDesc html40EntitiesTable[] = { * * Returns the associated htmlEntityDescPtr if found, NULL otherwise. */ -htmlEntityDescPtr +const htmlEntityDescPtr htmlEntityLookup(const xmlChar *name) { unsigned int i; @@ -1363,7 +1347,7 @@ htmlEntityLookup(const xmlChar *name) { #ifdef DEBUG xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name); #endif - return(&html40EntitiesTable[i]); + return((const htmlEntityDescPtr) &html40EntitiesTable[i]); } } return(NULL); @@ -1379,7 +1363,7 @@ htmlEntityLookup(const xmlChar *name) { * * Returns the associated htmlEntityDescPtr if found, NULL otherwise. */ -htmlEntityDescPtr +const htmlEntityDescPtr htmlEntityValueLookup(unsigned int value) { unsigned int i; #ifdef DEBUG @@ -1394,7 +1378,7 @@ htmlEntityValueLookup(unsigned int value) { #ifdef DEBUG xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name); #endif - return(&html40EntitiesTable[i]); + return((const htmlEntityDescPtr) &html40EntitiesTable[i]); } #ifdef DEBUG if (lv > html40EntitiesTable[i].value) { @@ -45,8 +45,8 @@ #endif #include <libxml/xmlerror.h> -xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL; -xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL; +static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL; +static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL; typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias; typedef xmlCharEncodingAlias *xmlCharEncodingAliasPtr; @@ -26,7 +26,7 @@ struct xmlPredefinedEntityValue { const char *name; const char *value; }; -struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = { +static struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = { { "lt", "<" }, { "gt", ">" }, { "apos", "'" }, @@ -46,7 +46,8 @@ xmlHashTablePtr xmlPredefinedEntities = NULL; static void xmlFreeEntity(xmlEntityPtr entity) { if (entity == NULL) return; - if ((entity->children) && (entity->children->parent == entity)) + if ((entity->children) && + (entity == (xmlEntityPtr) entity->children->parent)) xmlFreeNodeList(entity->children); if (entity->name != NULL) xmlFree((char *) entity->name); diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h index 575360c8..10205a7c 100644 --- a/include/libxml/HTMLparser.h +++ b/include/libxml/HTMLparser.h @@ -58,9 +58,9 @@ struct _htmlEntityDesc { /* * There is only few public functions. */ -htmlElemDescPtr htmlTagLookup (const xmlChar *tag); -htmlEntityDescPtr htmlEntityLookup(const xmlChar *name); -htmlEntityDescPtr htmlEntityValueLookup(unsigned int value); +const htmlElemDescPtr htmlTagLookup (const xmlChar *tag); +const htmlEntityDescPtr htmlEntityLookup(const xmlChar *name); +const htmlEntityDescPtr htmlEntityValueLookup(unsigned int value); int htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem); diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h index e9b6bb46..5370ac1c 100644 --- a/include/libxml/parserInternals.h +++ b/include/libxml/parserInternals.h @@ -185,9 +185,13 @@ LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue; LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue; LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue; LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue; -LIBXML_DLL_IMPORT extern xmlChar xmlStringText[]; -LIBXML_DLL_IMPORT extern xmlChar xmlStringTextNoenc[]; -LIBXML_DLL_IMPORT extern xmlChar xmlStringComment[]; + +/** + * Global variables used for predefined strings + */ +LIBXML_DLL_IMPORT extern const xmlChar xmlStringText[]; +LIBXML_DLL_IMPORT extern const xmlChar xmlStringTextNoenc[]; +LIBXML_DLL_IMPORT extern const xmlChar xmlStringComment[]; /* * Function to finish teh work of the macros where needed diff --git a/parserInternals.c b/parserInternals.c index 43b97c40..8a3abd35 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -83,7 +83,7 @@ xmlCheckVersion(int version) { } -const char *xmlFeaturesList[] = { +static const char *xmlFeaturesList[] = { "validate", "load subset", "keep blanks", @@ -38,15 +38,22 @@ xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns); /************************************************************************ * * + * Deprecated * + * * + ************************************************************************/ +int oldXMLWDcompatibility = 0; + +/************************************************************************ + * * * A few static variables and macros * * * ************************************************************************/ -xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; -xmlChar xmlStringTextNoenc[] = +const xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; +const xmlChar xmlStringTextNoenc[] = { 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 }; -xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; -int oldXMLWDcompatibility = 0; +const xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; + int xmlIndentTreeOutput = 0; xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; @@ -96,9 +96,9 @@ typedef struct _xmlInputCallback { #define MAX_INPUT_CALLBACK 15 -xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK]; -int xmlInputCallbackNr = 0; -int xmlInputCallbackInitialized = 0; +static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK]; +static int xmlInputCallbackNr = 0; +static int xmlInputCallbackInitialized = 0; /* * Output I/O callback sets @@ -112,9 +112,9 @@ typedef struct _xmlOutputCallback { #define MAX_OUTPUT_CALLBACK 15 -xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK]; -int xmlOutputCallbackNr = 0; -int xmlOutputCallbackInitialized = 0; +static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK]; +static int xmlOutputCallbackNr = 0; +static int xmlOutputCallbackInitialized = 0; /************************************************************************ * * |