mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-10-26 12:25:09 +03:00
more fixes and extending the tests coverage adding a type init interface
* gentest.py testapi.c: more fixes and extending the tests coverage * relaxng.c include/libxml/relaxng.h: adding a type init interface * include/libxml/xmlerror.h parser.c xmlreader.c xmlwriter.c: more cleanups and bug fixes raised by the regression tests Daniel
This commit is contained in:
parent
e43cc574e4
commit
dd6d300896
@ -1,3 +1,10 @@
|
||||
Wed Nov 3 15:19:22 CET 2004 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* gentest.py testapi.c: more fixes and extending the tests coverage
|
||||
* relaxng.c include/libxml/relaxng.h: adding a type init interface
|
||||
* include/libxml/xmlerror.h parser.c xmlreader.c xmlwriter.c: more
|
||||
cleanups and bug fixes raised by the regression tests
|
||||
|
||||
Wed Nov 3 12:49:30 CET 2004 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* gentest.py testapi.c: more fixes and extending the tests coverage
|
||||
|
33
gentest.py
33
gentest.py
@ -15,14 +15,25 @@ except:
|
||||
#
|
||||
skipped_modules = [ "SAX", "SAX2", "xlink", "threads", "globals",
|
||||
"xpathInternals", "xmlunicode", "parserInternals", "xmlmemory",
|
||||
"xmlversion", "debugXML" ]
|
||||
"xmlversion", "debugXML", "xmlexports" ]
|
||||
|
||||
#
|
||||
# Some function really need to be skipped for the tests.
|
||||
#
|
||||
skipped_functions = [ "xmlFdRead", "xmlReadFd", "xmlCtxtReadFd",
|
||||
"htmlFdRead", "htmlReadFd", "htmlCtxtReadFd",
|
||||
"xmlCleanupParser", "xmlStrcat", "xmlStrncat" ]
|
||||
skipped_functions = [
|
||||
# block on I/O
|
||||
"xmlFdRead", "xmlReadFd", "xmlCtxtReadFd",
|
||||
"htmlFdRead", "htmlReadFd", "htmlCtxtReadFd",
|
||||
"xmlReaderNewFd",
|
||||
# library state cleanup, generate false leak informations and other
|
||||
# troubles, heavillyb tested otherwise.
|
||||
"xmlCleanupParser", "xmlRelaxNGCleanupTypes",
|
||||
# hard to avoid leaks in the tests
|
||||
"xmlStrcat", "xmlStrncat",
|
||||
# unimplemented
|
||||
"xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml",
|
||||
"xmlTextReaderReadString"
|
||||
]
|
||||
|
||||
#
|
||||
# Those functions have side effect on the global state
|
||||
@ -141,6 +152,7 @@ int main(void) {
|
||||
int blocks, mem;
|
||||
|
||||
xmlInitParser();
|
||||
xmlRelaxNGInitTypes();
|
||||
|
||||
LIBXML_TEST_VERSION
|
||||
|
||||
@ -236,7 +248,7 @@ def type_convert(str, name, info, module, function, pos):
|
||||
known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr",
|
||||
"xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput",
|
||||
"xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr",
|
||||
"xmlTextWriterPtr" ];
|
||||
"xmlTextWriterPtr", "xmlTextReaderPtr" ];
|
||||
|
||||
def is_known_param_type(name):
|
||||
for type in known_param_types:
|
||||
@ -379,6 +391,17 @@ static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val)
|
||||
if (val != NULL) xmlFreeTextWriter(val);
|
||||
}
|
||||
|
||||
#define gen_nb_xmlTextReaderPtr 4
|
||||
static xmlTextReaderPtr gen_xmlTextReaderPtr(int no) {
|
||||
if (no == 0) return(xmlNewTextReaderFilename("test/ent2"));
|
||||
if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml"));
|
||||
if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd"));
|
||||
return(NULL);
|
||||
}
|
||||
static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val) {
|
||||
if (val != NULL) xmlFreeTextReader(val);
|
||||
}
|
||||
|
||||
""");
|
||||
|
||||
#
|
||||
|
@ -94,6 +94,12 @@ typedef enum {
|
||||
XML_RELAXNGP_FREE_DOC = 1,
|
||||
XML_RELAXNGP_CRNG = 2
|
||||
} xmlRelaxNGParserFlag;
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGInitTypes (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGCleanupTypes (void);
|
||||
|
||||
/*
|
||||
* Interfaces for parsing.
|
||||
*/
|
||||
@ -153,8 +159,6 @@ XMLPUBFUN void XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGCleanupTypes (void);
|
||||
/*
|
||||
* Interfaces for progressive validation when possible
|
||||
*/
|
||||
|
@ -58,7 +58,8 @@ typedef enum {
|
||||
XML_FROM_C14N, /* The Canonicalization module */
|
||||
XML_FROM_XSLT, /* The XSLT engine from libxslt */
|
||||
XML_FROM_VALID, /* The XML DTD validation with valid context */
|
||||
XML_FROM_CHECK /* The error checking module */
|
||||
XML_FROM_CHECK, /* The error checking module */
|
||||
XML_FROM_WRITER /* The xmlwriter module */
|
||||
} xmlErrorDomain;
|
||||
|
||||
/**
|
||||
|
1
parser.c
1
parser.c
@ -12117,6 +12117,7 @@ xmlCleanupParser(void) {
|
||||
#endif
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
xmlSchemaCleanupTypes();
|
||||
xmlRelaxNGCleanupTypes();
|
||||
#endif
|
||||
xmlCleanupGlobals();
|
||||
xmlResetLastError();
|
||||
|
@ -2781,7 +2781,7 @@ xmlRelaxNGRegisterTypeLibrary(const xmlChar * namespace, void *data,
|
||||
*
|
||||
* Returns 0 in case of success and -1 in case of error.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
xmlRelaxNGInitTypes(void)
|
||||
{
|
||||
if (xmlRelaxNGTypeInitialized != 0)
|
||||
|
@ -1825,7 +1825,7 @@ xmlTextReaderNextSibling(xmlTextReaderPtr reader) {
|
||||
if (reader == NULL)
|
||||
return(-1);
|
||||
if (reader->doc == NULL) {
|
||||
TODO
|
||||
/* TODO */
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -4629,6 +4629,9 @@ xmlReaderNewWalker(xmlTextReaderPtr reader, xmlDocPtr doc)
|
||||
if (reader == NULL)
|
||||
return (-1);
|
||||
|
||||
if (reader->input != NULL) {
|
||||
xmlFreeParserInputBuffer(reader->input);
|
||||
}
|
||||
if (reader->ctxt != NULL) {
|
||||
xmlCtxtReset(reader->ctxt);
|
||||
}
|
||||
|
164
xmlwriter.c
164
xmlwriter.c
@ -95,6 +95,51 @@ static int
|
||||
xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer,
|
||||
xmlTextWriterStackEntry * p);
|
||||
|
||||
/**
|
||||
* xmlWriterErrMsg:
|
||||
* @ctxt: a writer context
|
||||
* @error: the error number
|
||||
* @msg: the error message
|
||||
*
|
||||
* Handle a writer error
|
||||
*/
|
||||
static void
|
||||
xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error,
|
||||
const char *msg)
|
||||
{
|
||||
if (ctxt != NULL) {
|
||||
__xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt,
|
||||
NULL, XML_FROM_WRITER, error, XML_ERR_FATAL,
|
||||
NULL, 0, NULL, NULL, NULL, 0, 0, msg);
|
||||
} else {
|
||||
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error,
|
||||
XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlWriterErrMsgInt:
|
||||
* @ctxt: a writer context
|
||||
* @error: the error number
|
||||
* @msg: the error message
|
||||
* @val: an int
|
||||
*
|
||||
* Handle a writer error
|
||||
*/
|
||||
static void
|
||||
xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error,
|
||||
const char *msg, int val)
|
||||
{
|
||||
if (ctxt != NULL) {
|
||||
__xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt,
|
||||
NULL, XML_FROM_WRITER, error, XML_ERR_FATAL,
|
||||
NULL, 0, NULL, NULL, NULL, val, 0, msg, val);
|
||||
} else {
|
||||
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error,
|
||||
XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, val, 0, msg, val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNewTextWriter:
|
||||
* @out: an xmlOutputBufferPtr
|
||||
@ -110,7 +155,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
|
||||
ret = (xmlTextWriterPtr) xmlMalloc(sizeof(xmlTextWriter));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriter : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -121,7 +166,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
(xmlListDataCompare)
|
||||
xmlCmpTextWriterStackEntry);
|
||||
if (ret->nodes == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriter : out of memory!\n");
|
||||
xmlFree(ret);
|
||||
return NULL;
|
||||
@ -132,7 +177,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
(xmlListDataCompare)
|
||||
xmlCmpTextWriterNsStackEntry);
|
||||
if (ret->nsstack == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriter : out of memory!\n");
|
||||
xmlListDelete(ret->nodes);
|
||||
xmlFree(ret);
|
||||
@ -147,7 +192,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
xmlListDelete(ret->nodes);
|
||||
xmlListDelete(ret->nsstack);
|
||||
xmlFree(ret);
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriter : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -172,14 +217,14 @@ xmlNewTextWriterFilename(const char *uri, int compression)
|
||||
|
||||
out = xmlOutputBufferCreateFilename(uri, NULL, compression);
|
||||
if (out == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriterFilename : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = xmlNewTextWriter(out);
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriterFilename : out of memory!\n");
|
||||
xmlOutputBufferClose(out);
|
||||
return NULL;
|
||||
@ -213,14 +258,14 @@ xmlNewTextWriterMemory(xmlBufferPtr buf, int compression ATTRIBUTE_UNUSED)
|
||||
xmlTextWriterCloseMemCallback,
|
||||
(void *) buf, NULL);
|
||||
if (out == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriterMemory : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = xmlNewTextWriter(out);
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlNewTextWriterMemory : out of memory!\n");
|
||||
xmlOutputBufferClose(out);
|
||||
return NULL;
|
||||
@ -247,7 +292,7 @@ xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt,
|
||||
xmlOutputBufferPtr out;
|
||||
|
||||
if (ctxt == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterPushParser : invalid context!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -258,14 +303,14 @@ xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt,
|
||||
xmlTextWriterCloseDocCallback,
|
||||
(void *) ctxt, NULL);
|
||||
if (out == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterPushParser : error at xmlOutputBufferCreateIO!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = xmlNewTextWriter(out);
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterPushParser : error at xmlNewTextWriter!\n");
|
||||
xmlOutputBufferClose(out);
|
||||
return NULL;
|
||||
@ -300,7 +345,7 @@ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression)
|
||||
|
||||
ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL);
|
||||
if (ctxt == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -313,14 +358,14 @@ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression)
|
||||
ctxt->myDoc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
|
||||
if (ctxt->myDoc == NULL) {
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterDoc : error at xmlNewDoc!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = xmlNewTextWriterPushParser(ctxt, compression);
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -352,7 +397,7 @@ xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression)
|
||||
xmlParserCtxtPtr ctxt;
|
||||
|
||||
if (doc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterTree : invalid document tree!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -365,7 +410,7 @@ xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression)
|
||||
|
||||
ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL);
|
||||
if (ctxt == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -378,7 +423,7 @@ xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression)
|
||||
ret = xmlNewTextWriterPushParser(ctxt, compression);
|
||||
if (ret == NULL) {
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -441,14 +486,14 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
|
||||
xmlCharEncodingHandlerPtr encoder;
|
||||
|
||||
if ((writer == NULL) || (writer->out == NULL)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartDocument : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
lk = xmlListFront(writer->nodes);
|
||||
if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartDocument : not allowed in this context!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -457,7 +502,7 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
|
||||
if (encoding != NULL) {
|
||||
encoder = xmlFindCharEncodingHandler(encoding);
|
||||
if (encoder == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDocument : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -555,7 +600,7 @@ xmlTextWriterEndDocument(xmlTextWriterPtr writer)
|
||||
xmlTextWriterStackEntry *p;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterEndDocument : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -638,7 +683,7 @@ xmlTextWriterStartComment(xmlTextWriterPtr writer)
|
||||
xmlTextWriterStackEntry *p;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartComment : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -675,7 +720,7 @@ xmlTextWriterStartComment(xmlTextWriterPtr writer)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartElement : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -717,14 +762,14 @@ xmlTextWriterEndComment(xmlTextWriterPtr writer)
|
||||
xmlTextWriterStackEntry *p;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterEndComment : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
lk = xmlListFront(writer->nodes);
|
||||
if (lk == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterEndComment : not allowed in this context!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -799,7 +844,7 @@ xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
|
||||
xmlChar *buf;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteVFormatComment : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -896,14 +941,14 @@ xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartElement : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(name);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartElement : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -1201,13 +1246,13 @@ xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, const xmlChar * content,
|
||||
xmlTextWriterStackEntry *p;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteRawLen : invalid writer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((content == NULL) || (len < 0)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteRawLen : invalid content!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -1704,7 +1749,7 @@ xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
|
||||
p = (xmlTextWriterNsStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartAttributeNS : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -1712,7 +1757,7 @@ xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
|
||||
p->prefix = buf;
|
||||
p->uri = xmlStrdup(namespaceURI);
|
||||
if (p->uri == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartAttributeNS : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -2241,7 +2286,7 @@ xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
|
||||
return -1;
|
||||
|
||||
if (xmlStrcasecmp(target, (const xmlChar *) "xml") == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartPI : target name [Xx][Mm][Ll] is reserved for xml standardization!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -2271,7 +2316,7 @@ xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
|
||||
break;
|
||||
case XML_TEXTWRITER_PI:
|
||||
case XML_TEXTWRITER_PI_TEXT:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartPI : nested PI!\n");
|
||||
return -1;
|
||||
default:
|
||||
@ -2283,14 +2328,14 @@ xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartPI : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(target);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartPI : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -2493,7 +2538,7 @@ xmlTextWriterStartCDATA(xmlTextWriterPtr writer)
|
||||
p->state = XML_TEXTWRITER_TEXT;
|
||||
break;
|
||||
case XML_TEXTWRITER_CDATA:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartCDATA : CDATA not allowed in this context!\n");
|
||||
return -1;
|
||||
default:
|
||||
@ -2505,7 +2550,7 @@ xmlTextWriterStartCDATA(xmlTextWriterPtr writer)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartCDATA : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -2682,7 +2727,7 @@ xmlTextWriterStartDTD(xmlTextWriterPtr writer,
|
||||
sum = 0;
|
||||
lk = xmlListFront(writer->nodes);
|
||||
if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartDTD : DTD allowed only in prolog!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -2690,14 +2735,14 @@ xmlTextWriterStartDTD(xmlTextWriterPtr writer,
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTD : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(name);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTD : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -2717,7 +2762,7 @@ xmlTextWriterStartDTD(xmlTextWriterPtr writer,
|
||||
|
||||
if (pubid != 0) {
|
||||
if (sysid == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterStartDTD : system identifier needed!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -3029,14 +3074,14 @@ xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, const xmlChar * name)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDElement : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(name);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDElement : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -3266,14 +3311,14 @@ xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name)
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDAttlist : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(name);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDAttlist : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -3505,14 +3550,14 @@ xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
|
||||
p = (xmlTextWriterStackEntry *)
|
||||
xmlMalloc(sizeof(xmlTextWriterStackEntry));
|
||||
if (p == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDElement : out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->name = xmlStrdup(name);
|
||||
if (p->name == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterStartDTDElement : out of memory!\n");
|
||||
xmlFree(p);
|
||||
return -1;
|
||||
@ -3824,7 +3869,7 @@ xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer,
|
||||
xmlTextWriterStackEntry *p;
|
||||
|
||||
if (writer == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDTDExternalEntityContents: xmlTextWriterPtr invalid!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -3832,7 +3877,7 @@ xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer,
|
||||
sum = 0;
|
||||
lk = xmlListFront(writer->nodes);
|
||||
if (lk == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -3846,20 +3891,20 @@ xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer,
|
||||
break;
|
||||
case XML_TEXTWRITER_DTD_PENT:
|
||||
if (ndataid != NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDTDExternalEntityContents: notation not allowed with parameter entities!\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pubid != 0) {
|
||||
if (sysid == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDTDExternalEntityContents: system identifier needed!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -4248,7 +4293,7 @@ xmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len)
|
||||
int rc;
|
||||
|
||||
if ((rc = xmlParseChunk(ctxt, (const char *) str, len, 0)) != 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDocCallback : XML error %d !\n",
|
||||
rc);
|
||||
return -1;
|
||||
@ -4272,7 +4317,7 @@ xmlTextWriterCloseDocCallback(void *context)
|
||||
int rc;
|
||||
|
||||
if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlTextWriterWriteDocCallback : XML error %d !\n",
|
||||
rc);
|
||||
return -1;
|
||||
@ -4300,7 +4345,7 @@ xmlTextWriterVSprintf(const char *format, va_list argptr)
|
||||
size = BUFSIZ;
|
||||
buf = (xmlChar *) xmlMalloc(size);
|
||||
if (buf == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterVSprintf : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -4311,7 +4356,7 @@ xmlTextWriterVSprintf(const char *format, va_list argptr)
|
||||
size += BUFSIZ;
|
||||
buf = (xmlChar *) xmlMalloc(size);
|
||||
if (buf == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
"xmlTextWriterVSprintf : out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -4332,9 +4377,6 @@ xmlTextWriterStartDocumentCallback(void *ctx)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlDocPtr doc;
|
||||
|
||||
#ifdef DEBUG_SAX
|
||||
xmlGenericError(xmlGenericErrorContext, "SAX.startDocument()\n");
|
||||
#endif
|
||||
if (ctxt->html) {
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (ctxt->myDoc == NULL)
|
||||
@ -4349,7 +4391,7 @@ xmlTextWriterStartDocumentCallback(void *ctx)
|
||||
return;
|
||||
}
|
||||
#else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
|
||||
"libxml2 built without HTML support\n");
|
||||
ctxt->errNo = XML_ERR_INTERNAL_ERROR;
|
||||
ctxt->instate = XML_PARSER_EOF;
|
||||
|
Loading…
Reference in New Issue
Block a user