better parser options coverage more cleanups. Daniel
* gentest.py testapi.c: better parser options coverage
* SAX2.c xpath.c: more cleanups.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 73bf142..808483b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Nov 8 18:16:43 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+ * gentest.py testapi.c: better parser options coverage
+ * SAX2.c xpath.c: more cleanups.
+
Tue Nov 9 01:50:08 CET 2004 Daniel Veillard <daniel@veillard.com>
* testapi.c: trying to fix some optional support brokenness
diff --git a/SAX2.c b/SAX2.c
index d339087..b95e555 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2393,9 +2393,10 @@
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr ret;
- xmlNodePtr parent = ctxt->node;
+ xmlNodePtr parent;
if (ctx == NULL) return;
+ parent = ctxt->node;
#ifdef DEBUG_SAX
xmlGenericError(xmlGenericErrorContext,
"SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data);
diff --git a/gentest.py b/gentest.py
index c0bba90..b77b885 100755
--- a/gentest.py
+++ b/gentest.py
@@ -278,6 +278,9 @@
res = 'const_char_ptr_ptr'
if res == 'FILE_ptr' and module == 'debugXML':
res = 'debug_FILE_ptr';
+ if res == 'int' and name == 'options':
+ if module == 'parser' or module == 'xmlreader':
+ res = 'parseroptions'
return res
diff --git a/testapi.c b/testapi.c
index dbfaf53..79bc2c0 100644
--- a/testapi.c
+++ b/testapi.c
@@ -219,6 +219,19 @@
static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
+#define gen_nb_parseroptions 5
+
+static int gen_parseroptions(int no, int nr ATTRIBUTE_UNUSED) {
+ if (no == 0) return(XML_PARSE_NOBLANKS | XML_PARSE_RECOVER);
+ if (no == 1) return(XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_DTDVALID | XML_PARSE_NOCDATA);
+ if (no == 2) return(XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE | XML_PARSE_NSCLEAN);
+ if (no == 3) return(XML_PARSE_XINCLUDE | XML_PARSE_NODICT);
+ return(XML_PARSE_SAX1);
+}
+
+static void des_parseroptions(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+
#if 0
#define gen_nb_long 4
@@ -12804,13 +12817,13 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(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);
+ options = gen_parseroptions(n_options, 4);
ret_val = xmlCtxtReadDoc(ctxt, cur, URL, encoding, options);
desret_xmlDocPtr(ret_val);
@@ -12819,7 +12832,7 @@
des_const_xmlChar_ptr(n_cur, cur, 1);
des_filepath(n_URL, URL, 2);
des_const_char_ptr(n_encoding, encoding, 3);
- des_int(n_options, options, 4);
+ des_parseroptions(n_options, options, 4);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlCtxtReadDoc",
@@ -12861,12 +12874,12 @@
for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
filename = gen_filepath(n_filename, 1);
encoding = gen_const_char_ptr(n_encoding, 2);
- options = gen_int(n_options, 3);
+ options = gen_parseroptions(n_options, 3);
ret_val = xmlCtxtReadFile(ctxt, filename, encoding, options);
desret_xmlDocPtr(ret_val);
@@ -12874,7 +12887,7 @@
des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
des_filepath(n_filename, filename, 1);
des_const_char_ptr(n_encoding, encoding, 2);
- des_int(n_options, options, 3);
+ des_parseroptions(n_options, options, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlCtxtReadFile",
@@ -12920,14 +12933,14 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
buffer = gen_const_char_ptr(n_buffer, 1);
size = gen_int(n_size, 2);
URL = gen_filepath(n_URL, 3);
encoding = gen_const_char_ptr(n_encoding, 4);
- options = gen_int(n_options, 5);
+ options = gen_parseroptions(n_options, 5);
ret_val = xmlCtxtReadMemory(ctxt, buffer, size, URL, encoding, options);
desret_xmlDocPtr(ret_val);
@@ -12937,7 +12950,7 @@
des_int(n_size, size, 2);
des_filepath(n_URL, URL, 3);
des_const_char_ptr(n_encoding, encoding, 4);
- des_int(n_options, options, 5);
+ des_parseroptions(n_options, options, 5);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlCtxtReadMemory",
@@ -13065,16 +13078,16 @@
int n_options;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
- for (n_options = 0;n_options < gen_nb_int;n_options++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
- options = gen_int(n_options, 1);
+ options = gen_parseroptions(n_options, 1);
ret_val = xmlCtxtUseOptions(ctxt, options);
desret_int(ret_val);
call_tests++;
des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
- des_int(n_options, options, 1);
+ des_parseroptions(n_options, options, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlCtxtUseOptions",
@@ -14059,13 +14072,13 @@
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_data = 0;n_data < gen_nb_const_char_ptr;n_data++) {
for (n_datalen = 0;n_datalen < gen_nb_int;n_datalen++) {
- for (n_options = 0;n_options < gen_nb_int;n_options++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) {
mem_base = xmlMemBlocks();
node = gen_xmlNodePtr(n_node, 0);
data = gen_const_char_ptr(n_data, 1);
datalen = gen_int(n_datalen, 2);
- options = gen_int(n_options, 3);
+ options = gen_parseroptions(n_options, 3);
lst = gen_xmlNodePtr_ptr(n_lst, 4);
ret_val = xmlParseInNodeContext(node, data, datalen, options, lst);
@@ -14074,7 +14087,7 @@
des_xmlNodePtr(n_node, node, 0);
des_const_char_ptr(n_data, data, 1);
des_int(n_datalen, datalen, 2);
- des_int(n_options, options, 3);
+ des_parseroptions(n_options, options, 3);
des_xmlNodePtr_ptr(n_lst, lst, 4);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
@@ -14351,12 +14364,12 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
cur = gen_const_xmlChar_ptr(n_cur, 0);
URL = gen_filepath(n_URL, 1);
encoding = gen_const_char_ptr(n_encoding, 2);
- options = gen_int(n_options, 3);
+ options = gen_parseroptions(n_options, 3);
ret_val = xmlReadDoc(cur, URL, encoding, options);
desret_xmlDocPtr(ret_val);
@@ -14364,7 +14377,7 @@
des_const_xmlChar_ptr(n_cur, cur, 0);
des_filepath(n_URL, URL, 1);
des_const_char_ptr(n_encoding, encoding, 2);
- des_int(n_options, options, 3);
+ des_parseroptions(n_options, options, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReadDoc",
@@ -14401,18 +14414,18 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
filename = gen_filepath(n_filename, 0);
encoding = gen_const_char_ptr(n_encoding, 1);
- options = gen_int(n_options, 2);
+ options = gen_parseroptions(n_options, 2);
ret_val = xmlReadFile(filename, encoding, options);
desret_xmlDocPtr(ret_val);
call_tests++;
des_filepath(n_filename, filename, 0);
des_const_char_ptr(n_encoding, encoding, 1);
- des_int(n_options, options, 2);
+ des_parseroptions(n_options, options, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReadFile",
@@ -14453,13 +14466,13 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
buffer = gen_const_char_ptr(n_buffer, 0);
size = gen_int(n_size, 1);
URL = gen_filepath(n_URL, 2);
encoding = gen_const_char_ptr(n_encoding, 3);
- options = gen_int(n_options, 4);
+ options = gen_parseroptions(n_options, 4);
ret_val = xmlReadMemory(buffer, size, URL, encoding, options);
desret_xmlDocPtr(ret_val);
@@ -14468,7 +14481,7 @@
des_int(n_size, size, 1);
des_filepath(n_URL, URL, 2);
des_const_char_ptr(n_encoding, encoding, 3);
- des_int(n_options, options, 4);
+ des_parseroptions(n_options, options, 4);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReadMemory",
@@ -28016,12 +28029,12 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
cur = gen_const_xmlChar_ptr(n_cur, 0);
URL = gen_filepath(n_URL, 1);
encoding = gen_const_char_ptr(n_encoding, 2);
- options = gen_int(n_options, 3);
+ options = gen_parseroptions(n_options, 3);
ret_val = xmlReaderForDoc(cur, URL, encoding, options);
desret_xmlTextReaderPtr(ret_val);
@@ -28029,7 +28042,7 @@
des_const_xmlChar_ptr(n_cur, cur, 0);
des_filepath(n_URL, URL, 1);
des_const_char_ptr(n_encoding, encoding, 2);
- des_int(n_options, options, 3);
+ des_parseroptions(n_options, options, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderForDoc",
@@ -28068,18 +28081,18 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
filename = gen_filepath(n_filename, 0);
encoding = gen_const_char_ptr(n_encoding, 1);
- options = gen_int(n_options, 2);
+ options = gen_parseroptions(n_options, 2);
ret_val = xmlReaderForFile(filename, encoding, options);
desret_xmlTextReaderPtr(ret_val);
call_tests++;
des_filepath(n_filename, filename, 0);
des_const_char_ptr(n_encoding, encoding, 1);
- des_int(n_options, options, 2);
+ des_parseroptions(n_options, options, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderForFile",
@@ -28122,13 +28135,13 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
buffer = gen_const_char_ptr(n_buffer, 0);
size = gen_int(n_size, 1);
URL = gen_filepath(n_URL, 2);
encoding = gen_const_char_ptr(n_encoding, 3);
- options = gen_int(n_options, 4);
+ options = gen_parseroptions(n_options, 4);
ret_val = xmlReaderForMemory(buffer, size, URL, encoding, options);
desret_xmlTextReaderPtr(ret_val);
@@ -28137,7 +28150,7 @@
des_int(n_size, size, 1);
des_filepath(n_URL, URL, 2);
des_const_char_ptr(n_encoding, encoding, 3);
- des_int(n_options, options, 4);
+ des_parseroptions(n_options, options, 4);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderForMemory",
@@ -28184,13 +28197,13 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
reader = gen_xmlTextReaderPtr(n_reader, 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);
+ options = gen_parseroptions(n_options, 4);
ret_val = xmlReaderNewDoc(reader, cur, URL, encoding, options);
desret_int(ret_val);
@@ -28199,7 +28212,7 @@
des_const_xmlChar_ptr(n_cur, cur, 1);
des_filepath(n_URL, URL, 2);
des_const_char_ptr(n_encoding, encoding, 3);
- des_int(n_options, options, 4);
+ des_parseroptions(n_options, options, 4);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderNewDoc",
@@ -28243,12 +28256,12 @@
for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) {
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
reader = gen_xmlTextReaderPtr(n_reader, 0);
filename = gen_filepath(n_filename, 1);
encoding = gen_const_char_ptr(n_encoding, 2);
- options = gen_int(n_options, 3);
+ options = gen_parseroptions(n_options, 3);
ret_val = xmlReaderNewFile(reader, filename, encoding, options);
desret_int(ret_val);
@@ -28256,7 +28269,7 @@
des_xmlTextReaderPtr(n_reader, reader, 0);
des_filepath(n_filename, filename, 1);
des_const_char_ptr(n_encoding, encoding, 2);
- des_int(n_options, options, 3);
+ des_parseroptions(n_options, options, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderNewFile",
@@ -28304,14 +28317,14 @@
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++) {
+ for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
mem_base = xmlMemBlocks();
reader = gen_xmlTextReaderPtr(n_reader, 0);
buffer = gen_const_char_ptr(n_buffer, 1);
size = gen_int(n_size, 2);
URL = gen_filepath(n_URL, 3);
encoding = gen_const_char_ptr(n_encoding, 4);
- options = gen_int(n_options, 5);
+ options = gen_parseroptions(n_options, 5);
ret_val = xmlReaderNewMemory(reader, buffer, size, URL, encoding, options);
desret_int(ret_val);
@@ -28321,7 +28334,7 @@
des_int(n_size, size, 2);
des_filepath(n_URL, URL, 3);
des_const_char_ptr(n_encoding, encoding, 4);
- des_int(n_options, options, 5);
+ des_parseroptions(n_options, options, 5);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlReaderNewMemory",
diff --git a/xpath.c b/xpath.c
index 12d1346..f445ed2 100644
--- a/xpath.c
+++ b/xpath.c
@@ -4867,7 +4867,7 @@
xmlXPathObjectPtr arg1, arg2, argtmp;
int ret = 0;
- if ((ctxt == NULL) || (ctxt->context == NULL)) return;
+ if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {
@@ -4951,7 +4951,7 @@
xmlXPathObjectPtr arg1, arg2, argtmp;
int ret = 0;
- if ((ctxt == NULL) || (ctxt->context == NULL)) return;
+ if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {
@@ -5051,7 +5051,7 @@
int ret = 0, arg1i = 0, arg2i = 0;
xmlXPathObjectPtr arg1, arg2;
- if ((ctxt == NULL) || (ctxt->context == NULL)) return;
+ if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {