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>
* gentest.py: fixed test file corruption problem

View File

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

View File

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

View File

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

View File

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

View File

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

9126
testapi.c

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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