1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

more types, more coverage more problems fixed Daniel

* gentest.py testapi.c: more types, more coverage
* parser.c parserInternals.c relaxng.c valid.c xmlIO.c
  xmlschemastypes.c: more problems fixed
Daniel
This commit is contained in:
Daniel Veillard
2004-11-08 10:52:06 +00:00
parent 83d9c37d79
commit 4259532303
10 changed files with 5091 additions and 4110 deletions

View File

@@ -1,3 +1,9 @@
Mon Nov 8 11:24:57 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: more types, more coverage
* parser.c parserInternals.c relaxng.c valid.c xmlIO.c
xmlschemastypes.c: more problems fixed
Mon Nov 8 10:24:28 HKT 2004 William Brack <wbrack@mmm.com.hk> Mon Nov 8 10:24:28 HKT 2004 William Brack <wbrack@mmm.com.hk>
* gentest.py: fixed test file corruption problem * gentest.py: fixed test file corruption problem

View File

@@ -2428,7 +2428,9 @@ const htmlEntityDesc *
htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) { htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) {
const xmlChar *name; const xmlChar *name;
const htmlEntityDesc * ent = NULL; const htmlEntityDesc * ent = NULL;
*str = NULL;
if (str != NULL) *str = NULL;
if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
if (CUR == '&') { if (CUR == '&') {
NEXT; NEXT;
@@ -2439,7 +2441,8 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) {
} else { } else {
GROW; GROW;
if (CUR == ';') { if (CUR == ';') {
*str = name; if (str != NULL)
*str = name;
/* /*
* Lookup the entity in the table. * Lookup the entity in the table.
@@ -2451,7 +2454,8 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) {
htmlParseErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, htmlParseErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING,
"htmlParseEntityRef: expecting ';'\n", "htmlParseEntityRef: expecting ';'\n",
NULL, NULL); NULL, NULL);
*str = name; if (str != NULL)
*str = name;
} }
} }
} }

View File

@@ -35,6 +35,11 @@ skipped_functions = [
"htmlIORead", "htmlReadIO", "htmlCtxtReadIO", "htmlIORead", "htmlReadIO", "htmlCtxtReadIO",
"xmlReaderNewIO", "xmlBufferDump", "xmlNanoFTPConnect", "xmlReaderNewIO", "xmlBufferDump", "xmlNanoFTPConnect",
"xmlNanoFTPConnectTo", "xmlNanoFTPConnectTo",
# Complex I/O APIs
"xmlCreateIOParserCtxt", "xmlParserInputBufferCreateIO",
"xmlRegisterInputCallbacks", "xmlReaderForIO",
"xmlOutputBufferCreateIO", "xmlRegisterOutputCallbacks",
"xmlSaveToIO",
# library state cleanup, generate false leak informations and other # library state cleanup, generate false leak informations and other
# troubles, heavillyb tested otherwise. # troubles, heavillyb tested otherwise.
"xmlCleanupParser", "xmlRelaxNGCleanupTypes", "xmlSetListDoc", "xmlCleanupParser", "xmlRelaxNGCleanupTypes", "xmlSetListDoc",
@@ -64,7 +69,8 @@ skipped_memcheck = [ "xmlLoadCatalog", "xmlAddEncodingAlias",
"xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert", "xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert",
"xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers", "xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers",
"xmlInitCharEncodingHandlers", "xmlCatalogCleanup", "xmlInitCharEncodingHandlers", "xmlCatalogCleanup",
"htmlParseFile" # loads the catalogs "xmlSchemaGetBuiltInType",
"htmlParseFile", # loads the catalogs
] ]
# #
@@ -126,6 +132,7 @@ extra_post_call = {
"xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);",
"xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;",
"xmlNewTextWriterPushParser": "if (ret_val != NULL) ctxt = NULL;", "xmlNewTextWriterPushParser": "if (ret_val != NULL) ctxt = NULL;",
"xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;",
} }
modules = [] modules = []
@@ -440,17 +447,17 @@ test.write("""
static int static int
testlibxml2(void) testlibxml2(void)
{ {
int ret = 0; int test_ret = 0;
""") """)
for module in modules: for module in modules:
test.write(" ret += test_%s();\n" % module) test.write(" test_ret += test_%s();\n" % module)
test.write(""" test.write("""
printf("Total: %d functions, %d tests, %d errors\\n", printf("Total: %d functions, %d tests, %d errors\\n",
function_tests, call_tests, ret); function_tests, call_tests, test_ret);
return(ret); return(test_ret);
} }
""") """)
@@ -513,7 +520,7 @@ def generate_test(module, node):
test.write(""" test.write("""
static int static int
test_%s(void) { test_%s(void) {
int ret = 0; int test_ret = 0;
""" % (name)) """ % (name))
@@ -521,7 +528,7 @@ test_%s(void) {
add_missing_functions(name, module) add_missing_functions(name, module)
test.write(""" test.write("""
/* missing type support */ /* missing type support */
return(ret); return(test_ret);
} }
""") """)
@@ -623,7 +630,7 @@ test_%s(void) {
test.write(""" if (mem_base != xmlMemBlocks()) { test.write(""" if (mem_base != xmlMemBlocks()) {
printf("Leak of %%d blocks found in %s", printf("Leak of %%d blocks found in %s",
xmlMemBlocks() - mem_base); xmlMemBlocks() - mem_base);
ret++; test_ret++;
""" % (name)); """ % (name));
for arg in t_args: for arg in t_args:
(nam, type, rtype, info) = arg; (nam, type, rtype, info) = arg;
@@ -645,7 +652,7 @@ test_%s(void) {
test.write(""" test.write("""
function_tests++; function_tests++;
return(ret); return(test_ret);
} }
""") """)
@@ -671,7 +678,7 @@ for module in modules:
# header # header
test.write("""static int test.write("""static int
test_%s(void) { test_%s(void) {
int ret = 0; int test_ret = 0;
printf("Testing %s : %d of %d functions ...\\n"); printf("Testing %s : %d of %d functions ...\\n");
""" % (module, module, nb_tests - nb_tests_old, i)) """ % (module, module, nb_tests - nb_tests_old, i))
@@ -681,13 +688,13 @@ test_%s(void) {
name = function.xpathEval('string(@name)') name = function.xpathEval('string(@name)')
if is_skipped_function(name): if is_skipped_function(name):
continue continue
test.write(" ret += test_%s();\n" % (name)) test.write(" test_ret += test_%s();\n" % (name))
# footer # footer
test.write(""" test.write("""
if (ret != 0) if (test_ret != 0)
printf("Module %s: %%d errors\\n", ret); printf("Module %s: %%d errors\\n", test_ret);
return(ret); return(test_ret);
} }
""" % (module)) """ % (module))

View File

@@ -10059,6 +10059,8 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
xmlParserInputPtr inputStream; xmlParserInputPtr inputStream;
xmlParserInputBufferPtr buf; xmlParserInputBufferPtr buf;
if (ioread == NULL) return(NULL);
buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc); buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
if (buf == NULL) return(NULL); if (buf == NULL) return(NULL);

View File

@@ -913,6 +913,7 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
{ {
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
if (ctxt == NULL) return(-1);
switch (enc) { switch (enc) {
case XML_CHAR_ENCODING_ERROR: case XML_CHAR_ENCODING_ERROR:
__xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING,
@@ -1331,6 +1332,7 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
xmlCharEncoding enc) { xmlCharEncoding enc) {
xmlParserInputPtr inputStream; xmlParserInputPtr inputStream;
if (input == NULL) return(NULL);
if (xmlParserDebugEntities) if (xmlParserDebugEntities)
xmlGenericError(xmlGenericErrorContext, "new input from I/O\n"); xmlGenericError(xmlGenericErrorContext, "new input from I/O\n");
inputStream = xmlNewInputStream(ctxt); inputStream = xmlNewInputStream(ctxt);

View File

@@ -248,6 +248,7 @@ struct _xmlRelaxNGParserCtxt {
xmlAutomataStatePtr state; /* used to build the automata */ xmlAutomataStatePtr state; /* used to build the automata */
int crng; /* compact syntax and other flags */ int crng; /* compact syntax and other flags */
int freedoc; /* need to free the document */
}; };
#define FLAGS_IGNORABLE 1 #define FLAGS_IGNORABLE 1
@@ -6657,6 +6658,7 @@ xmlRelaxNGNewDocParserCtxt(xmlDocPtr doc)
} }
memset(ret, 0, sizeof(xmlRelaxNGParserCtxt)); memset(ret, 0, sizeof(xmlRelaxNGParserCtxt));
ret->document = copy; ret->document = copy;
ret->freedoc = 1;
ret->userData = xmlGenericErrorContext; ret->userData = xmlGenericErrorContext;
return (ret); return (ret);
} }
@@ -6693,6 +6695,8 @@ xmlRelaxNGFreeParserCtxt(xmlRelaxNGParserCtxtPtr ctxt)
xmlRelaxNGFreeDefine(ctxt->defTab[i]); xmlRelaxNGFreeDefine(ctxt->defTab[i]);
xmlFree(ctxt->defTab); xmlFree(ctxt->defTab);
} }
if ((ctxt->document != NULL) && (ctxt->freedoc))
xmlFreeDoc(ctxt->document);
xmlFree(ctxt); xmlFree(ctxt);
} }

9126
testapi.c

File diff suppressed because it is too large Load Diff

View File

@@ -1877,7 +1877,8 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
"Attribute %s of %s: invalid default value\n", "Attribute %s of %s: invalid default value\n",
elem, name, defaultValue); elem, name, defaultValue);
defaultValue = NULL; defaultValue = NULL;
ctxt->valid = 0; if (ctxt != NULL)
ctxt->valid = 0;
} }
#endif /* LIBXML_VALID_ENABLED */ #endif /* LIBXML_VALID_ENABLED */
@@ -1958,7 +1959,8 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID, xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
"Element %s has too may ID attributes defined : %s\n", "Element %s has too may ID attributes defined : %s\n",
elem, name, NULL); elem, name, NULL);
ctxt->valid = 0; if (ctxt != NULL)
ctxt->valid = 0;
} }
#endif /* LIBXML_VALID_ENABLED */ #endif /* LIBXML_VALID_ENABLED */

View File

@@ -3436,7 +3436,7 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
/* /*
* Do a local lookup * Do a local lookup
*/ */
if ((ctxt->catalogs != NULL) && if ((ctxt != NULL) && (ctxt->catalogs != NULL) &&
((pref == XML_CATA_ALLOW_ALL) || ((pref == XML_CATA_ALLOW_ALL) ||
(pref == XML_CATA_ALLOW_DOCUMENT))) { (pref == XML_CATA_ALLOW_DOCUMENT))) {
resource = xmlCatalogLocalResolve(ctxt->catalogs, resource = xmlCatalogLocalResolve(ctxt->catalogs,
@@ -3462,7 +3462,7 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
&& (!xmlSysIDExists((const char *) resource))) { && (!xmlSysIDExists((const char *) resource))) {
xmlChar *tmp = NULL; xmlChar *tmp = NULL;
if ((ctxt->catalogs != NULL) && if ((ctxt != NULL) && (ctxt->catalogs != NULL) &&
((pref == XML_CATA_ALLOW_ALL) || ((pref == XML_CATA_ALLOW_ALL) ||
(pref == XML_CATA_ALLOW_DOCUMENT))) { (pref == XML_CATA_ALLOW_DOCUMENT))) {
tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource); tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource);
@@ -3624,7 +3624,7 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
/* /*
* Do a local lookup * Do a local lookup
*/ */
if ((ctxt->catalogs != NULL) && if ((ctxt != NULL) && (ctxt->catalogs != NULL) &&
((pref == XML_CATA_ALLOW_ALL) || ((pref == XML_CATA_ALLOW_ALL) ||
(pref == XML_CATA_ALLOW_DOCUMENT))) { (pref == XML_CATA_ALLOW_DOCUMENT))) {
resource = xmlCatalogLocalResolve(ctxt->catalogs, resource = xmlCatalogLocalResolve(ctxt->catalogs,
@@ -3649,7 +3649,7 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
if ((resource != NULL) && (!xmlNoNetExists((const char *)resource))) { if ((resource != NULL) && (!xmlNoNetExists((const char *)resource))) {
xmlChar *tmp = NULL; xmlChar *tmp = NULL;
if ((ctxt->catalogs != NULL) && if ((ctxt != NULL) && (ctxt->catalogs != NULL) &&
((pref == XML_CATA_ALLOW_ALL) || ((pref == XML_CATA_ALLOW_ALL) ||
(pref == XML_CATA_ALLOW_DOCUMENT))) { (pref == XML_CATA_ALLOW_DOCUMENT))) {
tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource); tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource);

View File

@@ -749,7 +749,7 @@ xmlSchemaGetPredefinedType(const xmlChar *name, const xmlChar *ns) {
xmlSchemaTypePtr xmlSchemaTypePtr
xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type) xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type)
{ {
if (type->type != XML_SCHEMA_TYPE_BASIC) if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC))
return (NULL); return (NULL);
switch (type->builtInType) { switch (type->builtInType) {
case XML_SCHEMAS_NMTOKENS: case XML_SCHEMAS_NMTOKENS: