better handling of conditional features more testing on parser contexts

* gentest.py testapi.c: better handling of conditional features
* HTMLparser.c SAX2.c parserInternals.c xmlwriter.c: more testing
  on parser contexts closed leaks, error messages
Daniel
diff --git a/testapi.c b/testapi.c
index ea7b40c..610e8fc 100644
--- a/testapi.c
+++ b/testapi.c
@@ -175,6 +175,7 @@
 #include <libxml/xmlwriter.h>
 #include <libxml/xpath.h>
 #include <libxml/xpointer.h>
+#include <libxml/debugXML.h>
 
 #define gen_nb_void_ptr 2
 
@@ -404,9 +405,10 @@
 static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
 
-#define gen_nb_xmlParserCtxtPtr 2
+#define gen_nb_xmlParserCtxtPtr 3
 static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 0) return(xmlNewParserCtxt());
+    if (no == 1) return(xmlCreateMemoryParserCtxt("<doc/>", 6));
     return(NULL);
 }
 static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
@@ -416,7 +418,9 @@
 
 #define gen_nb_xmlSAXHandlerPtr 2
 static xmlSAXHandlerPtr gen_xmlSAXHandlerPtr(int no, int nr ATTRIBUTE_UNUSED) {
+#ifdef LIBXML_SAX1_ENABLED
     if (no == 0) return((xmlSAXHandlerPtr) &xmlDefaultSAXHandler);
+#endif
     return(NULL);
 }
 static void des_xmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, xmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -424,12 +428,16 @@
 
 #define gen_nb_xmlValidCtxtPtr 2
 static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
+#ifdef LIBXML_VALID_ENABLED
     if (no == 0) return(xmlNewValidCtxt());
+#endif
     return(NULL);
 }
 static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
+#ifdef LIBXML_VALID_ENABLED
     if (val != NULL)
         xmlFreeValidCtxt(val);
+#endif
 }
 
 #define gen_nb_xmlParserInputBufferPtr 8
@@ -777,6 +785,95 @@
 }
 #endif
 
+/* cut and pasted from autogenerated to avoid troubles */
+#define gen_nb_const_xmlChar_ptr_ptr 1
+static xmlChar ** gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, const xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+
+#define gen_nb_unsigned_char_ptr 1
+static unsigned char * gen_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+
+#define gen_nb_const_unsigned_char_ptr 1
+static unsigned char * gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, const unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+
+#ifdef LIBXML_HTML_ENABLED
+#define gen_nb_const_htmlNodePtr 1
+static htmlNodePtr gen_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, const htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+#endif
+
+#ifdef LIBXML_HTML_ENABLED
+#define gen_nb_htmlDocPtr 3
+static htmlDocPtr gen_htmlDocPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    if (no == 0) return(htmlNewDoc(NULL, NULL));
+    if (no == 1) return(htmlReadMemory("<html/>", 7, "test", NULL, 0));
+    return(NULL);
+}
+static void des_htmlDocPtr(int no ATTRIBUTE_UNUSED, htmlDocPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    if ((val != NULL) && (val != api_doc) && (val->doc != api_doc))
+        xmlFreeDoc(val);
+}
+static void desret_htmlDocPtr(htmlDocPtr val) {
+    if ((val != NULL) && (val != api_doc) && (val->doc != api_doc))
+        xmlFreeDoc(val);
+}
+#define gen_nb_htmlParserCtxtPtr 3
+static htmlParserCtxtPtr gen_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    if (no == 0) return(xmlNewParserCtxt());
+    if (no == 1) return(htmlCreateMemoryParserCtxt("<html/>", 7));
+    return(NULL);
+}
+static void des_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, htmlParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    if (val != NULL)
+        htmlFreeParserCtxt(val);
+}
+static void desret_htmlParserCtxtPtr(htmlParserCtxtPtr val) {
+    if (val != NULL)
+        htmlFreeParserCtxt(val);
+}
+#endif
+
+#ifdef LIBXML_XPATH_ENABLED
+#define gen_nb_xmlNodeSetPtr 1
+static xmlNodeSetPtr gen_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, xmlNodeSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+#endif
+
+#ifdef LIBXML_DEBUG_ENABLED
+#define gen_nb_xmlShellCtxtPtr 1
+static xmlShellCtxtPtr gen_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, xmlShellCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+#endif
+
+#ifdef LIBXML_PATTERN_ENABLED
+#define gen_nb_xmlPatternPtr 1
+static xmlPatternPtr gen_xmlPatternPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_xmlPatternPtr(int no ATTRIBUTE_UNUSED, xmlPatternPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+#endif
+
 /************************************************************************
  *									*
  *   WARNING: end of the manually maintained part of the test code	*
@@ -785,6 +882,7 @@
  ************************************************************************/
 
 /* CUT HERE: everything below that line is generated */
+#ifdef LIBXML_HTML_ENABLED
 #define gen_nb_htmlParserOption 4
 static htmlParserOption gen_htmlParserOption(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(HTML_PARSE_NOBLANKS);
@@ -798,6 +896,9 @@
 static void desret_htmlParserOption(htmlParserOption val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_HTML_ENABLED
 #define gen_nb_htmlStatus 4
 static htmlStatus gen_htmlStatus(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(HTML_DEPRECATED);
@@ -811,6 +912,8 @@
 static void desret_htmlStatus(htmlStatus val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
 #define gen_nb_xlinkActuate 3
 static xlinkActuate gen_xlinkActuate(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XLINK_ACTUATE_AUTO);
@@ -887,6 +990,7 @@
 static void desret_xmlBufferAllocationScheme(xmlBufferAllocationScheme val ATTRIBUTE_UNUSED) {
 }
 
+#ifdef LIBXML_CATALOG_ENABLED
 #define gen_nb_xmlCatalogAllow 4
 static xmlCatalogAllow gen_xmlCatalogAllow(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_CATA_ALLOW_ALL);
@@ -900,6 +1004,9 @@
 static void desret_xmlCatalogAllow(xmlCatalogAllow val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_CATALOG_ENABLED
 #define gen_nb_xmlCatalogPrefer 3
 static xmlCatalogPrefer gen_xmlCatalogPrefer(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_CATA_PREFER_NONE);
@@ -912,6 +1019,8 @@
 static void desret_xmlCatalogPrefer(xmlCatalogPrefer val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
 #define gen_nb_xmlElementContentOccur 4
 static xmlElementContentOccur gen_xmlElementContentOccur(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_ELEMENT_CONTENT_MULT);
@@ -1055,6 +1164,7 @@
 static void desret_xmlParserOption(xmlParserOption val ATTRIBUTE_UNUSED) {
 }
 
+#ifdef LIBXML_READER_ENABLED
 #define gen_nb_xmlParserProperties 4
 static xmlParserProperties gen_xmlParserProperties(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_PARSER_DEFAULTATTRS);
@@ -1068,6 +1178,9 @@
 static void desret_xmlParserProperties(xmlParserProperties val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_READER_ENABLED
 #define gen_nb_xmlParserSeverities 4
 static xmlParserSeverities gen_xmlParserSeverities(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_PARSER_SEVERITY_ERROR);
@@ -1081,6 +1194,9 @@
 static void desret_xmlParserSeverities(xmlParserSeverities val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_READER_ENABLED
 #define gen_nb_xmlReaderTypes 4
 static xmlReaderTypes gen_xmlReaderTypes(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_READER_TYPE_ATTRIBUTE);
@@ -1094,6 +1210,9 @@
 static void desret_xmlReaderTypes(xmlReaderTypes val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlRelaxNGParserFlag 3
 static xmlRelaxNGParserFlag gen_xmlRelaxNGParserFlag(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_RELAXNGP_CRNG);
@@ -1106,6 +1225,9 @@
 static void desret_xmlRelaxNGParserFlag(xmlRelaxNGParserFlag val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlRelaxNGValidErr 4
 static xmlRelaxNGValidErr gen_xmlRelaxNGValidErr(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_RELAXNG_ERR_ATTREXTRANS);
@@ -1119,6 +1241,9 @@
 static void desret_xmlRelaxNGValidErr(xmlRelaxNGValidErr val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlSchemaContentType 4
 static xmlSchemaContentType gen_xmlSchemaContentType(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_SCHEMA_CONTENT_ANY);
@@ -1132,6 +1257,9 @@
 static void desret_xmlSchemaContentType(xmlSchemaContentType val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlSchemaTypeType 4
 static xmlSchemaTypeType gen_xmlSchemaTypeType(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_SCHEMA_FACET_ENUMERATION);
@@ -1145,6 +1273,9 @@
 static void desret_xmlSchemaTypeType(xmlSchemaTypeType val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlSchemaValType 4
 static xmlSchemaValType gen_xmlSchemaValType(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_SCHEMAS_ANYSIMPLETYPE);
@@ -1158,6 +1289,9 @@
 static void desret_xmlSchemaValType(xmlSchemaValType val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlSchemaValidError 4
 static xmlSchemaValidError gen_xmlSchemaValidError(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_SCHEMAS_ERR_);
@@ -1171,6 +1305,9 @@
 static void desret_xmlSchemaValidError(xmlSchemaValidError val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 #define gen_nb_xmlSchemaValidOption 1
 static xmlSchemaValidOption gen_xmlSchemaValidOption(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_SCHEMA_VAL_VC_I_CREATE);
@@ -1181,6 +1318,9 @@
 static void desret_xmlSchemaValidOption(xmlSchemaValidOption val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_READER_ENABLED
 #define gen_nb_xmlTextReaderMode 4
 static xmlTextReaderMode gen_xmlTextReaderMode(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XML_TEXTREADER_MODE_CLOSED);
@@ -1194,6 +1334,9 @@
 static void desret_xmlTextReaderMode(xmlTextReaderMode val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_XPATH_ENABLED
 #define gen_nb_xmlXPathError 4
 static xmlXPathError gen_xmlXPathError(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XPATH_ENCODING_ERROR);
@@ -1207,6 +1350,9 @@
 static void desret_xmlXPathError(xmlXPathError val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
+#ifdef LIBXML_XPATH_ENABLED
 #define gen_nb_xmlXPathObjectType 4
 static xmlXPathObjectType gen_xmlXPathObjectType(int no, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) return(XPATH_BOOLEAN);
@@ -1220,6 +1366,8 @@
 static void desret_xmlXPathObjectType(xmlXPathObjectType val ATTRIBUTE_UNUSED) {
 }
 
+#endif
+
 #include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/SAX2.h>
@@ -1352,20 +1500,6 @@
 }
 
 
-#define gen_nb_unsigned_char_ptr 1
-static unsigned char * gen_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_const_unsigned_char_ptr 1
-static unsigned char * gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, const unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_UTF8ToHtml(void) {
     int test_ret = 0;
@@ -1420,6 +1554,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_HTML_ENABLED
 
 #define gen_nb_const_htmlElemDesc_ptr 1
 static htmlElemDesc * gen_const_htmlElemDesc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -1427,6 +1562,8 @@
 }
 static void des_const_htmlElemDesc_ptr(int no ATTRIBUTE_UNUSED, const htmlElemDesc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_htmlAttrAllowed(void) {
@@ -1475,6 +1612,16 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_HTML_ENABLED
+
+#define gen_nb_htmlNodePtr 1
+static htmlNodePtr gen_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_htmlNodePtr(int no ATTRIBUTE_UNUSED, htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+#endif
+
 
 static int
 test_htmlAutoCloseTag(void) {
@@ -1490,20 +1637,20 @@
     htmlNodePtr elem; /* the HTML element */
     int n_elem;
 
-    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) {
     for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_elem = 0;n_elem < gen_nb_htmlNodePtr;n_elem++) {
         mem_base = xmlMemBlocks();
-        doc = gen_xmlDocPtr(n_doc, 0);
+        doc = gen_htmlDocPtr(n_doc, 0);
         name = gen_const_xmlChar_ptr(n_name, 1);
-        elem = gen_xmlNodePtr(n_elem, 2);
+        elem = gen_htmlNodePtr(n_elem, 2);
 
         ret_val = htmlAutoCloseTag(doc, name, elem);
         desret_int(ret_val);
         call_tests++;
-        des_xmlDocPtr(n_doc, doc, 0);
+        des_htmlDocPtr(n_doc, doc, 0);
         des_const_xmlChar_ptr(n_name, name, 1);
-        des_xmlNodePtr(n_elem, elem, 2);
+        des_htmlNodePtr(n_elem, elem, 2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlAutoCloseTag",
@@ -1543,7 +1690,7 @@
         size = gen_int(n_size, 1);
 
         ret_val = htmlCreateMemoryParserCtxt(buffer, size);
-        desret_xmlParserCtxtPtr(ret_val);
+        desret_htmlParserCtxtPtr(ret_val);
         call_tests++;
         des_const_char_ptr(n_buffer, buffer, 0);
         des_int(n_size, size, 1);
@@ -1564,6 +1711,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_HTML_ENABLED
 
 #define gen_nb_htmlSAXHandlerPtr 1
 static htmlSAXHandlerPtr gen_htmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -1571,6 +1719,8 @@
 }
 static void des_htmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, htmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_htmlCreatePushParserCtxt(void) {
@@ -1608,7 +1758,7 @@
         enc = gen_xmlCharEncoding(n_enc, 5);
 
         ret_val = htmlCreatePushParserCtxt(sax, user_data, chunk, size, filename, enc);
-        desret_xmlParserCtxtPtr(ret_val);
+        desret_htmlParserCtxtPtr(ret_val);
         call_tests++;
         des_htmlSAXHandlerPtr(n_sax, sax, 0);
         des_userdata(n_user_data, user_data, 1);
@@ -1661,22 +1811,22 @@
     int options; /* a combination of htmlParserOption(s) */
     int n_options;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
     for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
     for (n_options = 0;n_options < gen_nb_int;n_options++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         cur = gen_const_xmlChar_ptr(n_cur, 1);
         URL = gen_filepath(n_URL, 2);
         encoding = gen_const_char_ptr(n_encoding, 3);
         options = gen_int(n_options, 4);
 
         ret_val = htmlCtxtReadDoc(ctxt, cur, URL, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_const_xmlChar_ptr(n_cur, cur, 1);
         des_filepath(n_URL, URL, 2);
         des_const_char_ptr(n_encoding, encoding, 3);
@@ -1721,20 +1871,20 @@
     int options; /* a combination of htmlParserOption(s) */
     int n_options;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
     for (n_options = 0;n_options < gen_nb_int;n_options++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         filename = gen_filepath(n_filename, 1);
         encoding = gen_const_char_ptr(n_encoding, 2);
         options = gen_int(n_options, 3);
 
         ret_val = htmlCtxtReadFile(ctxt, filename, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_filepath(n_filename, filename, 1);
         des_const_char_ptr(n_encoding, encoding, 2);
         des_int(n_options, options, 3);
@@ -1780,14 +1930,14 @@
     int options; /* a combination of htmlParserOption(s) */
     int n_options;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) {
     for (n_size = 0;n_size < gen_nb_int;n_size++) {
     for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
     for (n_options = 0;n_options < gen_nb_int;n_options++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         buffer = gen_const_char_ptr(n_buffer, 1);
         size = gen_int(n_size, 2);
         URL = gen_filepath(n_URL, 3);
@@ -1795,9 +1945,9 @@
         options = gen_int(n_options, 5);
 
         ret_val = htmlCtxtReadMemory(ctxt, buffer, size, URL, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_const_char_ptr(n_buffer, buffer, 1);
         des_int(n_size, size, 2);
         des_filepath(n_URL, URL, 3);
@@ -1838,13 +1988,13 @@
     htmlParserCtxtPtr ctxt; /* an HTML parser context */
     int n_ctxt;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
 
         htmlCtxtReset(ctxt);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlCtxtReset",
@@ -1873,16 +2023,16 @@
     int options; /* a combination of htmlParserOption(s) */
     int n_options;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_options = 0;n_options < gen_nb_int;n_options++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         options = gen_int(n_options, 1);
 
         ret_val = htmlCtxtUseOptions(ctxt, options);
         desret_int(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_int(n_options, options, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
@@ -2160,17 +2310,17 @@
     htmlNodePtr elem; /* the HTML element */
     int n_elem;
 
-    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) {
+    for (n_elem = 0;n_elem < gen_nb_htmlNodePtr;n_elem++) {
         mem_base = xmlMemBlocks();
-        doc = gen_xmlDocPtr(n_doc, 0);
-        elem = gen_xmlNodePtr(n_elem, 1);
+        doc = gen_htmlDocPtr(n_doc, 0);
+        elem = gen_htmlNodePtr(n_elem, 1);
 
         ret_val = htmlIsAutoClosed(doc, elem);
         desret_int(ret_val);
         call_tests++;
-        des_xmlDocPtr(n_doc, doc, 0);
-        des_xmlNodePtr(n_elem, elem, 1);
+        des_htmlDocPtr(n_doc, doc, 0);
+        des_htmlNodePtr(n_elem, elem, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlIsAutoClosed",
@@ -2223,13 +2373,6 @@
 }
 
 
-#define gen_nb_const_xmlNodePtr 1
-static htmlNodePtr gen_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, const htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_htmlNodeStatus(void) {
     int test_ret = 0;
@@ -2242,16 +2385,16 @@
     int legacy; /* whether to allow deprecated elements (YES is faster here for Element nodes) */
     int n_legacy;
 
-    for (n_node = 0;n_node < gen_nb_const_xmlNodePtr;n_node++) {
+    for (n_node = 0;n_node < gen_nb_const_htmlNodePtr;n_node++) {
     for (n_legacy = 0;n_legacy < gen_nb_int;n_legacy++) {
         mem_base = xmlMemBlocks();
-        node = gen_const_xmlNodePtr(n_node, 0);
+        node = gen_const_htmlNodePtr(n_node, 0);
         legacy = gen_int(n_legacy, 1);
 
         ret_val = htmlNodeStatus(node, legacy);
         desret_htmlStatus(ret_val);
         call_tests++;
-        des_const_xmlNodePtr(n_node, node, 0);
+        des_const_htmlNodePtr(n_node, node, 0);
         des_int(n_legacy, legacy, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
@@ -2281,14 +2424,14 @@
     htmlParserCtxtPtr ctxt; /* an HTML parser context */
     int n_ctxt;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
 
         ret_val = htmlParseCharRef(ctxt);
         desret_int(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlParseCharRef",
@@ -2322,20 +2465,21 @@
     int terminate; /* last chunk indicator */
     int n_terminate;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) {
     for (n_size = 0;n_size < gen_nb_int;n_size++) {
     for (n_terminate = 0;n_terminate < gen_nb_int;n_terminate++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         chunk = gen_const_char_ptr(n_chunk, 1);
         size = gen_int(n_size, 2);
         terminate = gen_int(n_terminate, 3);
 
         ret_val = htmlParseChunk(ctxt, chunk, size, terminate);
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
         desret_int(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_const_char_ptr(n_chunk, chunk, 1);
         des_int(n_size, size, 2);
         des_int(n_terminate, terminate, 3);
@@ -2381,7 +2525,7 @@
         encoding = gen_const_char_ptr(n_encoding, 1);
 
         ret_val = htmlParseDoc(cur, encoding);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_xmlChar_ptr(n_cur, cur, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -2413,14 +2557,15 @@
     htmlParserCtxtPtr ctxt; /* an HTML parser context */
     int n_ctxt;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
 
         ret_val = htmlParseDocument(ctxt);
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
         desret_int(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlParseDocument",
@@ -2446,13 +2591,13 @@
     htmlParserCtxtPtr ctxt; /* an HTML parser context */
     int n_ctxt;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
 
         htmlParseElement(ctxt);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlParseElement",
@@ -2469,13 +2614,6 @@
 }
 
 
-#define gen_nb_const_xmlChar_ptr_ptr 1
-static xmlChar ** gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, const xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_htmlParseEntityRef(void) {
     int test_ret = 0;
@@ -2488,16 +2626,16 @@
     xmlChar ** str; /* location to store the entity name */
     int n_str;
 
-    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) {
     for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr_ptr;n_str++) {
         mem_base = xmlMemBlocks();
-        ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+        ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0);
         str = gen_const_xmlChar_ptr_ptr(n_str, 1);
 
         ret_val = htmlParseEntityRef(ctxt, str);
         desret_const_htmlEntityDesc_ptr(ret_val);
         call_tests++;
-        des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+        des_htmlParserCtxtPtr(n_ctxt, ctxt, 0);
         des_const_xmlChar_ptr_ptr(n_str, str, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
@@ -2534,7 +2672,7 @@
         encoding = gen_const_char_ptr(n_encoding, 1);
 
         ret_val = htmlParseFile(filename, encoding);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_filepath(n_filename, filename, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -2575,7 +2713,7 @@
         options = gen_int(n_options, 3);
 
         ret_val = htmlReadDoc(cur, URL, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_const_xmlChar_ptr(n_cur, cur, 0);
         des_filepath(n_URL, URL, 1);
@@ -2626,7 +2764,7 @@
         options = gen_int(n_options, 2);
 
         ret_val = htmlReadFile(filename, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_filepath(n_filename, filename, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -2682,7 +2820,7 @@
         options = gen_int(n_options, 4);
 
         ret_val = htmlReadMemory(buffer, size, URL, encoding, options);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_const_char_ptr(n_buffer, buffer, 0);
         des_int(n_size, size, 1);
@@ -2740,7 +2878,7 @@
         userData = gen_userdata(n_userData, 3);
 
         ret_val = htmlSAXParseDoc(cur, encoding, sax, userData);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_xmlChar_ptr(n_cur, cur, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -2795,7 +2933,7 @@
         userData = gen_userdata(n_userData, 3);
 
         ret_val = htmlSAXParseFile(filename, encoding, sax, userData);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_filepath(n_filename, filename, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -3086,14 +3224,14 @@
     htmlDocPtr doc; /* the document */
     int n_doc;
 
-    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) {
         mem_base = xmlMemBlocks();
-        doc = gen_xmlDocPtr(n_doc, 0);
+        doc = gen_htmlDocPtr(n_doc, 0);
 
         ret_val = htmlGetMetaEncoding(doc);
         desret_const_xmlChar_ptr(ret_val);
         call_tests++;
-        des_xmlDocPtr(n_doc, doc, 0);
+        des_htmlDocPtr(n_doc, doc, 0);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
             printf("Leak of %d blocks found in htmlGetMetaEncoding",
@@ -3163,7 +3301,7 @@
         ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1);
 
         ret_val = htmlNewDoc(URI, ExternalID);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_const_xmlChar_ptr(n_URI, URI, 0);
         des_const_xmlChar_ptr(n_ExternalID, ExternalID, 1);
@@ -3204,7 +3342,7 @@
         ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1);
 
         ret_val = htmlNewDocNoDtD(URI, ExternalID);
-        desret_xmlDocPtr(ret_val);
+        desret_htmlDocPtr(ret_val);
         call_tests++;
         des_const_xmlChar_ptr(n_URI, URI, 0);
         des_const_xmlChar_ptr(n_ExternalID, ExternalID, 1);
@@ -3667,16 +3805,16 @@
     xmlChar * encoding; /* the encoding string */
     int n_encoding;
 
-    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) {
     for (n_encoding = 0;n_encoding < gen_nb_const_xmlChar_ptr;n_encoding++) {
         mem_base = xmlMemBlocks();
-        doc = gen_xmlDocPtr(n_doc, 0);
+        doc = gen_htmlDocPtr(n_doc, 0);
         encoding = gen_const_xmlChar_ptr(n_encoding, 1);
 
         ret_val = htmlSetMetaEncoding(doc, encoding);
         desret_int(ret_val);
         call_tests++;
-        des_xmlDocPtr(n_doc, doc, 0);
+        des_htmlDocPtr(n_doc, doc, 0);
         des_const_xmlChar_ptr(n_encoding, encoding, 1);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
@@ -3727,6 +3865,7 @@
 test_docbDefaultSAXHandlerInit(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_DOCB_ENABLED
     int mem_base;
 
         mem_base = xmlMemBlocks();
@@ -3740,6 +3879,7 @@
 	    test_ret++;
             printf("\n");
         }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -3750,6 +3890,7 @@
 test_htmlDefaultSAXHandlerInit(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
     int mem_base;
 
         mem_base = xmlMemBlocks();
@@ -3763,6 +3904,7 @@
 	    test_ret++;
             printf("\n");
         }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -4088,6 +4230,7 @@
 test_xmlSAX2EndElement(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     void * ctx; /* the user data (XML parser context) */
     int n_ctx;
@@ -4115,6 +4258,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -5049,6 +5193,7 @@
 test_xmlSAX2StartElement(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     void * ctx; /* the user data (XML parser context) */
     int n_ctx;
@@ -5083,6 +5228,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -5237,6 +5383,7 @@
 test_xmlSAXDefaultVersion(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     int version; /* the version, 1 or 2 */
@@ -5259,6 +5406,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -5352,13 +5500,6 @@
     return(test_ret);
 }
 
-#define gen_nb_xmlNodeSetPtr 1
-static xmlNodeSetPtr gen_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, xmlNodeSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_xmlC14NDocDumpMemory(void) {
     int test_ret = 0;
@@ -5602,6 +5743,7 @@
 	printf("Module c14n: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_CATALOG_ENABLED
 
 #define gen_nb_xmlCatalogPtr 1
 static xmlCatalogPtr gen_xmlCatalogPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -5609,6 +5751,8 @@
 }
 static void des_xmlCatalogPtr(int no ATTRIBUTE_UNUSED, xmlCatalogPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlACatalogAdd(void) {
@@ -7542,13 +7686,6 @@
 }
 
 
-#define gen_nb_xmlShellCtxtPtr 1
-static xmlShellCtxtPtr gen_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, xmlShellCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_xmlShellBase(void) {
     int test_ret = 0;
@@ -8445,6 +8582,7 @@
 test_UTF8Toisolat1(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_OUTPUT_ENABLED
     int mem_base;
     int ret_val;
     unsigned char * out; /* a pointer to an array of bytes to store the result */
@@ -8488,6 +8626,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -9207,6 +9346,7 @@
 test_xmlCleanupPredefinedEntities(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_LEGACY_ENABLED
     int mem_base;
 
         mem_base = xmlMemBlocks();
@@ -9220,6 +9360,7 @@
 	    test_ret++;
             printf("\n");
         }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -9569,6 +9710,7 @@
 test_xmlInitializePredefinedEntities(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_LEGACY_ENABLED
     int mem_base;
 
         mem_base = xmlMemBlocks();
@@ -9582,6 +9724,7 @@
 	    test_ret++;
             printf("\n");
         }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13136,6 +13279,7 @@
 test_xmlGetFeature(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_LEGACY_ENABLED
     int mem_base;
     int ret_val;
     xmlParserCtxtPtr ctxt; /* an XML/HTML parser context */
@@ -13172,6 +13316,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13189,6 +13334,7 @@
 test_xmlGetFeaturesList(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_LEGACY_ENABLED
     int mem_base;
     int ret_val;
     int * len; /* the length of the features name array (input/output) */
@@ -13218,6 +13364,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13228,6 +13375,7 @@
 test_xmlIOParseDTD(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_VALID_ENABLED
     int mem_base;
     xmlDtdPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block or NULL */
@@ -13265,6 +13413,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13549,6 +13698,7 @@
 test_xmlParseBalancedChunkMemory(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the document the chunk pertains to */
@@ -13577,7 +13727,11 @@
         depth = gen_int(n_depth, 3);
         string = gen_const_xmlChar_ptr(n_string, 4);
         lst = gen_xmlNodePtr_ptr(n_lst, 5);
+        
+#ifdef LIBXML_SAX1_ENABLED
         if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
+#endif
+
 
         ret_val = xmlParseBalancedChunkMemory(doc, sax, user_data, depth, string, lst);
         desret_int(ret_val);
@@ -13607,6 +13761,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13617,6 +13772,7 @@
 test_xmlParseBalancedChunkMemoryRecover(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the document the chunk pertains to */
@@ -13649,7 +13805,11 @@
         string = gen_const_xmlChar_ptr(n_string, 4);
         lst = gen_xmlNodePtr_ptr(n_lst, 5);
         recover = gen_int(n_recover, 6);
+        
+#ifdef LIBXML_SAX1_ENABLED
         if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
+#endif
+
 
         ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, string, lst, recover);
         desret_int(ret_val);
@@ -13682,6 +13842,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13715,6 +13876,7 @@
         terminate = gen_int(n_terminate, 3);
 
         ret_val = xmlParseChunk(ctxt, chunk, size, terminate);
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
         desret_int(ret_val);
         call_tests++;
         des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
@@ -13800,6 +13962,7 @@
 test_xmlParseDTD(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_VALID_ENABLED
     int mem_base;
     xmlDtdPtr ret_val;
     xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */
@@ -13829,6 +13992,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13839,6 +14003,7 @@
 test_xmlParseDoc(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlChar * cur; /* a pointer to an array of xmlChar */
@@ -13861,6 +14026,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13881,6 +14047,7 @@
         ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
 
         ret_val = xmlParseDocument(ctxt);
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
         desret_int(ret_val);
         call_tests++;
         des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
@@ -13903,6 +14070,7 @@
 test_xmlParseEntity(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     const char * filename; /* the filename */
@@ -13925,6 +14093,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -13945,6 +14114,7 @@
         ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
 
         ret_val = xmlParseExtParsedEnt(ctxt);
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}
         desret_int(ret_val);
         call_tests++;
         des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
@@ -13967,6 +14137,7 @@
 test_xmlParseExternalEntity(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the document the chunk pertains to */
@@ -14031,6 +14202,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14041,6 +14213,7 @@
 test_xmlParseFile(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     const char * filename; /* the filename */
@@ -14063,6 +14236,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14133,6 +14307,7 @@
 test_xmlParseMemory(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     char * buffer; /* an pointer to a char array */
@@ -14162,6 +14337,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14219,6 +14395,13 @@
 static void des_const_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, const xmlParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
 
+#define gen_nb_const_xmlNodePtr 1
+static xmlNodePtr gen_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+    return(NULL);
+}
+static void des_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, const xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+
 static int
 test_xmlParserFindNodeInfo(void) {
     int test_ret = 0;
@@ -14526,6 +14709,7 @@
 test_xmlRecoverDoc(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlChar * cur; /* a pointer to an array of xmlChar */
@@ -14548,6 +14732,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14558,6 +14743,7 @@
 test_xmlRecoverFile(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     const char * filename; /* the filename */
@@ -14580,6 +14766,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14590,6 +14777,7 @@
 test_xmlRecoverMemory(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     char * buffer; /* an pointer to a char array */
@@ -14619,6 +14807,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14629,6 +14818,7 @@
 test_xmlSAXParseDTD(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDtdPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14665,6 +14855,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14675,6 +14866,7 @@
 test_xmlSAXParseDoc(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14711,6 +14903,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14721,6 +14914,7 @@
 test_xmlSAXParseEntity(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14750,6 +14944,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14760,6 +14955,7 @@
 test_xmlSAXParseFile(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14796,6 +14992,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14806,6 +15003,7 @@
 test_xmlSAXParseFileWithData(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14849,6 +15047,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14859,6 +15058,7 @@
 test_xmlSAXParseMemory(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14902,6 +15102,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14912,6 +15113,7 @@
 test_xmlSAXParseMemoryWithData(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlDocPtr ret_val;
     xmlSAXHandlerPtr sax; /* the SAX handler block */
@@ -14962,6 +15164,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -14972,6 +15175,7 @@
 test_xmlSAXUserParseFile(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     xmlSAXHandlerPtr sax; /* a SAX handler */
@@ -14988,7 +15192,11 @@
         sax = gen_xmlSAXHandlerPtr(n_sax, 0);
         user_data = gen_userdata(n_user_data, 1);
         filename = gen_filepath(n_filename, 2);
+        
+#ifdef LIBXML_SAX1_ENABLED
         if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
+#endif
+
 
         ret_val = xmlSAXUserParseFile(sax, user_data, filename);
         desret_int(ret_val);
@@ -15009,6 +15217,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -15019,6 +15228,7 @@
 test_xmlSAXUserParseMemory(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     int ret_val;
     xmlSAXHandlerPtr sax; /* a SAX handler */
@@ -15039,7 +15249,11 @@
         user_data = gen_userdata(n_user_data, 1);
         buffer = gen_const_char_ptr(n_buffer, 2);
         size = gen_int(n_size, 3);
+        
+#ifdef LIBXML_SAX1_ENABLED
         if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
+#endif
+
 
         ret_val = xmlSAXUserParseMemory(sax, user_data, buffer, size);
         desret_int(ret_val);
@@ -15063,6 +15277,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -15083,6 +15298,7 @@
 test_xmlSetFeature(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_LEGACY_ENABLED
     int mem_base;
     int ret_val;
     xmlParserCtxtPtr ctxt; /* an XML/HTML parser context */
@@ -15119,6 +15335,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -15129,6 +15346,7 @@
 test_xmlSetupParserForBuffer(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_SAX1_ENABLED
     int mem_base;
     xmlParserCtxtPtr ctxt; /* an XML parser context */
     int n_ctxt;
@@ -15163,6 +15381,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -15173,6 +15392,7 @@
 test_xmlStopParser(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_PUSH_ENABLED
     int mem_base;
     xmlParserCtxtPtr ctxt; /* an XML parser context */
     int n_ctxt;
@@ -15193,6 +15413,7 @@
             printf("\n");
         }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -15322,7 +15543,7 @@
         encoding = gen_const_char_ptr(n_encoding, 1);
 
         ret_val = htmlCreateFileParserCtxt(filename, encoding);
-        desret_xmlParserCtxtPtr(ret_val);
+        desret_htmlParserCtxtPtr(ret_val);
         call_tests++;
         des_fileoutput(n_filename, filename, 0);
         des_const_char_ptr(n_encoding, encoding, 1);
@@ -16652,13 +16873,6 @@
     return(test_ret);
 }
 
-#define gen_nb_xmlPatternPtr 1
-static xmlPatternPtr gen_xmlPatternPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-    return(NULL);
-}
-static void des_xmlPatternPtr(int no ATTRIBUTE_UNUSED, xmlPatternPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
 static int
 test_xmlPatternMatch(void) {
     int test_ret = 0;
@@ -16721,6 +16935,7 @@
 	printf("Module pattern: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlRelaxNGPtr 1
 static xmlRelaxNGPtr gen_xmlRelaxNGPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16728,6 +16943,8 @@
 }
 static void des_xmlRelaxNGPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlRelaxNGDump(void) {
@@ -16810,6 +17027,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlRelaxNGParserCtxtPtr 1
 static xmlRelaxNGParserCtxtPtr gen_xmlRelaxNGParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16817,6 +17035,9 @@
 }
 static void des_xmlRelaxNGParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlRelaxNGValidityErrorFunc_ptr 1
 static xmlRelaxNGValidityErrorFunc * gen_xmlRelaxNGValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16824,6 +17045,9 @@
 }
 static void des_xmlRelaxNGValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidityErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlRelaxNGValidityWarningFunc_ptr 1
 static xmlRelaxNGValidityWarningFunc * gen_xmlRelaxNGValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16831,6 +17055,9 @@
 }
 static void des_xmlRelaxNGValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidityWarningFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_void_ptr_ptr 1
 static void ** gen_void_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16838,6 +17065,8 @@
 }
 static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlRelaxNGGetParserErrors(void) {
@@ -16893,6 +17122,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlRelaxNGValidCtxtPtr 1
 static xmlRelaxNGValidCtxtPtr gen_xmlRelaxNGValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -16900,6 +17130,8 @@
 }
 static void des_xmlRelaxNGValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlRelaxNGGetValidErrors(void) {
@@ -17650,6 +17882,7 @@
 test_xmlAttrSerializeTxtContent(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_OUTPUT_ENABLED
     int mem_base;
     xmlBufferPtr buf; /* the XML buffer output */
     int n_buf;
@@ -17691,6 +17924,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -19775,6 +20009,7 @@
 test_xmlNewChild(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     xmlNodePtr ret_val;
     xmlNodePtr parent; /* the parent node */
@@ -19818,6 +20053,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -20163,6 +20399,7 @@
 test_xmlNewDocRawNode(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     xmlNodePtr ret_val;
     xmlDocPtr doc; /* the document */
@@ -20206,6 +20443,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -20624,6 +20862,7 @@
 test_xmlNewProp(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     xmlAttrPtr ret_val;
     xmlNodePtr node; /* the holding node */
@@ -20660,6 +20899,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -20741,6 +20981,7 @@
 test_xmlNewTextChild(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     xmlNodePtr ret_val;
     xmlNodePtr parent; /* the parent node */
@@ -20784,6 +21025,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -21582,6 +21824,7 @@
 test_xmlReconciliateNs(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
     xmlDocPtr doc; /* the document */
@@ -21611,6 +21854,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -22670,6 +22914,7 @@
 test_xmlValidateNCName(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
     xmlChar * value; /* the value to check */
@@ -22699,6 +22944,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -22709,6 +22955,7 @@
 test_xmlValidateNMToken(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
     xmlChar * value; /* the value to check */
@@ -22738,6 +22985,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -22748,6 +22996,7 @@
 test_xmlValidateName(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
     xmlChar * value; /* the value to check */
@@ -22777,6 +23026,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -22787,6 +23037,7 @@
 test_xmlValidateQName(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_TREE_ENABLED
     int mem_base;
     int ret_val;
     xmlChar * value; /* the value to check */
@@ -22816,6 +23067,7 @@
         }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -24385,6 +24637,7 @@
 test_xmlSprintfElementContent(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_OUTPUT_ENABLED
     int mem_base;
     char * buf; /* an output buffer */
     int n_buf;
@@ -24419,6 +24672,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -24539,6 +24793,7 @@
 test_xmlValidGetPotentialChildren(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_VALID_ENABLED
     int mem_base;
     int ret_val;
     xmlElementContent * ctree; /* an element content tree */
@@ -24582,6 +24837,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -24592,6 +24848,7 @@
 test_xmlValidGetValidElements(void) {
     int test_ret = 0;
 
+#ifdef LIBXML_VALID_ENABLED
     int mem_base;
     int ret_val;
     xmlNode * prev; /* an element to insert after */
@@ -24635,6 +24892,7 @@
     }
     }
     }
+#endif
 
     function_tests++;
     return(test_ret);
@@ -25815,6 +26073,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_XINCLUDE_ENABLED
 
 #define gen_nb_xmlXIncludeCtxtPtr 1
 static xmlXIncludeCtxtPtr gen_xmlXIncludeCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -25822,6 +26081,8 @@
 }
 static void des_xmlXIncludeCtxtPtr(int no ATTRIBUTE_UNUSED, xmlXIncludeCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlXIncludeProcessNode(void) {
@@ -27467,6 +27728,7 @@
 	printf("Module xmlIO: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_AUTOMATA_ENABLED
 
 #define gen_nb_xmlAutomataPtr 1
 static xmlAutomataPtr gen_xmlAutomataPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -27474,6 +27736,8 @@
 }
 static void des_xmlAutomataPtr(int no ATTRIBUTE_UNUSED, xmlAutomataPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlAutomataCompile(void) {
@@ -27528,6 +27792,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_AUTOMATA_ENABLED
 
 #define gen_nb_xmlAutomataStatePtr 1
 static xmlAutomataStatePtr gen_xmlAutomataStatePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -27535,6 +27800,8 @@
 }
 static void des_xmlAutomataStatePtr(int no ATTRIBUTE_UNUSED, xmlAutomataStatePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlAutomataNewAllTrans(void) {
@@ -29310,6 +29577,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_READER_ENABLED
 
 #define gen_nb_xmlTextReaderErrorFunc_ptr 1
 static xmlTextReaderErrorFunc * gen_xmlTextReaderErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -29317,6 +29585,8 @@
 }
 static void des_xmlTextReaderErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlTextReaderErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlTextReaderGetErrorHandler(void) {
@@ -29676,6 +29946,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_READER_ENABLED
 
 #define gen_nb_xmlTextReaderLocatorPtr 1
 static xmlTextReaderLocatorPtr gen_xmlTextReaderLocatorPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -29683,6 +29954,8 @@
 }
 static void des_xmlTextReaderLocatorPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderLocatorPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlTextReaderLocatorBaseURI(void) {
@@ -30816,6 +31089,7 @@
 	printf("Module xmlreader: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_REGEXP_ENABLED
 
 #define gen_nb_xmlRegExecCtxtPtr 1
 static xmlRegExecCtxtPtr gen_xmlRegExecCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -30823,6 +31097,8 @@
 }
 static void des_xmlRegExecCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRegExecCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlRegExecPushString(void) {
@@ -30926,6 +31202,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_REGEXP_ENABLED
 
 #define gen_nb_xmlRegexpPtr 1
 static xmlRegexpPtr gen_xmlRegexpPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -30933,6 +31210,8 @@
 }
 static void des_xmlRegexpPtr(int no ATTRIBUTE_UNUSED, xmlRegexpPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlRegNewExecCtxt(void) {
@@ -31084,6 +31363,7 @@
 	printf("Module xmlregexp: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_OUTPUT_ENABLED
 
 #define gen_nb_xmlSaveCtxtPtr 1
 static xmlSaveCtxtPtr gen_xmlSaveCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31091,6 +31371,8 @@
 }
 static void des_xmlSaveCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSaveCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSaveClose(void) {
@@ -31299,6 +31581,7 @@
 	printf("Module xmlsave: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaPtr 1
 static xmlSchemaPtr gen_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31306,6 +31589,8 @@
 }
 static void des_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, xmlSchemaPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaDump(void) {
@@ -31347,6 +31632,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaParserCtxtPtr 1
 static xmlSchemaParserCtxtPtr gen_xmlSchemaParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31354,6 +31640,9 @@
 }
 static void des_xmlSchemaParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaValidityErrorFunc_ptr 1
 static xmlSchemaValidityErrorFunc * gen_xmlSchemaValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31361,6 +31650,9 @@
 }
 static void des_xmlSchemaValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValidityErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaValidityWarningFunc_ptr 1
 static xmlSchemaValidityWarningFunc * gen_xmlSchemaValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31368,6 +31660,8 @@
 }
 static void des_xmlSchemaValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValidityWarningFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaGetParserErrors(void) {
@@ -31423,6 +31717,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaValidCtxtPtr 1
 static xmlSchemaValidCtxtPtr gen_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31430,6 +31725,8 @@
 }
 static void des_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaGetValidErrors(void) {
@@ -31878,6 +32175,7 @@
 	printf("Module xmlschemas: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaFacetPtr 1
 static xmlSchemaFacetPtr gen_xmlSchemaFacetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31885,6 +32183,9 @@
 }
 static void des_xmlSchemaFacetPtr(int no ATTRIBUTE_UNUSED, xmlSchemaFacetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaTypePtr 1
 static xmlSchemaTypePtr gen_xmlSchemaTypePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -31892,6 +32193,8 @@
 }
 static void des_xmlSchemaTypePtr(int no ATTRIBUTE_UNUSED, xmlSchemaTypePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaCheckFacet(void) {
@@ -32006,6 +32309,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaValPtr 1
 static xmlSchemaValPtr gen_xmlSchemaValPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -32013,6 +32317,8 @@
 }
 static void des_xmlSchemaValPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaCompareValues(void) {
@@ -32232,6 +32538,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_SCHEMAS_ENABLED
 
 #define gen_nb_xmlSchemaValPtr_ptr 1
 static xmlSchemaValPtr * gen_xmlSchemaValPtr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -32239,6 +32546,8 @@
 }
 static void des_xmlSchemaValPtr_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValPtr * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlSchemaValPredefTypeNode(void) {
@@ -39639,7 +39948,7 @@
         compression = gen_int(n_compression, 1);
 
         ret_val = xmlNewTextWriterPushParser(ctxt, compression);
-        if (ret_val != NULL) ctxt = NULL;
+        if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL;
         desret_xmlTextWriterPtr(ret_val);
         call_tests++;
         des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
@@ -42672,6 +42981,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_XPATH_ENABLED
 
 #define gen_nb_xmlXPathCompExprPtr 1
 static xmlXPathCompExprPtr gen_xmlXPathCompExprPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -42679,6 +42989,9 @@
 }
 static void des_xmlXPathCompExprPtr(int no ATTRIBUTE_UNUSED, xmlXPathCompExprPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
+#ifdef LIBXML_XPATH_ENABLED
 
 #define gen_nb_xmlXPathContextPtr 1
 static xmlXPathContextPtr gen_xmlXPathContextPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -42686,6 +42999,8 @@
 }
 static void des_xmlXPathContextPtr(int no ATTRIBUTE_UNUSED, xmlXPathContextPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlXPathCompiledEval(void) {
@@ -43211,6 +43526,7 @@
 	printf("Module xpath: %d errors\n", test_ret);
     return(test_ret);
 }
+#ifdef LIBXML_XPATH_ENABLED
 
 #define gen_nb_xmlXPathParserContextPtr 1
 static xmlXPathParserContextPtr gen_xmlXPathParserContextPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -43218,6 +43534,8 @@
 }
 static void des_xmlXPathParserContextPtr(int no ATTRIBUTE_UNUSED, xmlXPathParserContextPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_valuePop(void) {
@@ -47597,6 +47915,7 @@
     return(test_ret);
 }
 
+#ifdef LIBXML_XPTR_ENABLED
 
 #define gen_nb_xmlLocationSetPtr 1
 static xmlLocationSetPtr gen_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@@ -47604,6 +47923,8 @@
 }
 static void des_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, xmlLocationSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
 }
+#endif
+
 
 static int
 test_xmlXPtrLocationSetAdd(void) {