fixed the main issues reported by Peter Breitenlohner cleanup speedup

* catalog.c: fixed the main issues reported by Peter Breitenlohner
* parser.c: cleanup
* valid.c: speedup patch from Petr Pajas
Daniel
diff --git a/valid.c b/valid.c
index 33a2a9a..22e41e6 100644
--- a/valid.c
+++ b/valid.c
@@ -2715,6 +2715,19 @@
 }
 
 /**
+ * xmlDummyCompare
+ * @data0:  Value supplied by the user
+ * @data1:  Value supplied by the user
+ *
+ * Do nothing, return 0. Used to create unordered lists.
+ */
+static int
+xmlDummyCompare(const void *data0, const void *data1)
+{
+    return (0);
+}
+
+/**
  * xmlAddRef:
  * @ctxt:  the validation context
  * @doc:  pointer to the document
@@ -2784,7 +2797,7 @@
      */
 
     if (NULL == (ref_list = xmlHashLookup(table, value))) {
-        if (NULL == (ref_list = xmlListCreate(xmlFreeRef, NULL))) {
+        if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) {
 	    xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
 		    "xmlAddRef: Reference list creation failed!\n",
 		    NULL);