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
diff --git a/ChangeLog b/ChangeLog
index 5765cd7..b416401 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 ea244f5..8812c3d 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 @@
  *
  * 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 @@
 };
 
 /*
- * 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 @@
     int priority;
 } elementPriority;
 
-const elementPriority htmlEndPriority[] = {
+static const elementPriority htmlEndPriority[] = {
     {"div",   150},
     {"td",    160},
     {"th",    160},
@@ -632,14 +616,14 @@
  *
  * 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 @@
  ************************************************************************/
 
 
-htmlEntityDesc  html40EntitiesTable[] = {
+static const htmlEntityDesc  html40EntitiesTable[] = {
 /*
  * the 4 absolute ones, plus apostrophe.
  */
@@ -1353,7 +1337,7 @@
  *
  * Returns the associated htmlEntityDescPtr if found, NULL otherwise.
  */
-htmlEntityDescPtr
+const htmlEntityDescPtr
 htmlEntityLookup(const xmlChar *name) {
     unsigned int i;
 
@@ -1363,7 +1347,7 @@
 #ifdef DEBUG
             xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name);
 #endif
-            return(&html40EntitiesTable[i]);
+            return((const htmlEntityDescPtr) &html40EntitiesTable[i]);
 	}
     }
     return(NULL);
@@ -1379,7 +1363,7 @@
  *
  * Returns the associated htmlEntityDescPtr if found, NULL otherwise.
  */
-htmlEntityDescPtr
+const htmlEntityDescPtr
 htmlEntityValueLookup(unsigned int value) {
     unsigned int i;
 #ifdef DEBUG
@@ -1394,7 +1378,7 @@
 #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) {
diff --git a/encoding.c b/encoding.c
index 4b08ab1..aa73f77 100644
--- a/encoding.c
+++ b/encoding.c
@@ -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;
diff --git a/entities.c b/entities.c
index 4ecb98c..1d0700d 100644
--- a/entities.c
+++ b/entities.c
@@ -26,7 +26,7 @@
     const char *name;
     const char *value;
 };
-struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = {
+static struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = {
     { "lt", "<" },
     { "gt", ">" },
     { "apos", "'" },
@@ -46,7 +46,8 @@
 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 575360c..10205a7 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -58,9 +58,9 @@
 /*
  * 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 e9b6bb4..5370ac1 100644
--- a/include/libxml/parserInternals.h
+++ b/include/libxml/parserInternals.h
@@ -185,9 +185,13 @@
 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 43b97c4..8a3abd3 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -83,7 +83,7 @@
 }
 
 
-const char *xmlFeaturesList[] = {
+static const char *xmlFeaturesList[] = {
     "validate",
     "load subset",
     "keep blanks",
diff --git a/tree.c b/tree.c
index 6be2c05..8b5cd1e 100644
--- a/tree.c
+++ b/tree.c
@@ -38,15 +38,22 @@
 
 /************************************************************************
  *									*
+ *			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;
 
diff --git a/xmlIO.c b/xmlIO.c
index 2922932..db245d0 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -96,9 +96,9 @@
 
 #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 @@
 
 #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;
 
 /************************************************************************
  *									*