mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
more cleanup through the I/O error path Daniel
* error.c tree.c xmlIO.c xmllint.c: more cleanup through the I/O error path Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Wed Oct 8 21:18:12 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* error.c tree.c xmlIO.c xmllint.c: more cleanup through the
|
||||||
|
I/O error path
|
||||||
|
|
||||||
Wed Oct 8 20:57:27 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
Wed Oct 8 20:57:27 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xmlIO.c: better handling of error cases
|
* xmlIO.c: better handling of error cases
|
||||||
|
7
error.c
7
error.c
@ -350,9 +350,14 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
|
|||||||
if (code == XML_ERR_OK)
|
if (code == XML_ERR_OK)
|
||||||
return;
|
return;
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
|
int len;
|
||||||
|
len = xmlStrlen((const xmlChar *)str);
|
||||||
|
if ((len > 0) && (str[len - 1] != '\n'))
|
||||||
channel(data, "%s", str);
|
channel(data, "%s", str);
|
||||||
|
else
|
||||||
|
channel(data, "%s\n", str);
|
||||||
} else {
|
} else {
|
||||||
channel(data, "%s", "out of memory error");
|
channel(data, "%s\n", "out of memory error");
|
||||||
}
|
}
|
||||||
if (code == XML_ERR_OK)
|
if (code == XML_ERR_OK)
|
||||||
return;
|
return;
|
||||||
|
9
xmlIO.c
9
xmlIO.c
@ -1974,12 +1974,13 @@ xmlFreeParserInputBuffer(xmlParserInputBufferPtr in) {
|
|||||||
* Returns the number of byte written or -1 in case of error.
|
* Returns the number of byte written or -1 in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlOutputBufferClose(xmlOutputBufferPtr out) {
|
xmlOutputBufferClose(xmlOutputBufferPtr out)
|
||||||
|
{
|
||||||
int written;
|
int written;
|
||||||
int err_rc = 0;
|
int err_rc = 0;
|
||||||
|
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return(-1);
|
return (-1);
|
||||||
if (out->writecallback != NULL)
|
if (out->writecallback != NULL)
|
||||||
xmlOutputBufferFlush(out);
|
xmlOutputBufferFlush(out);
|
||||||
if (out->closecallback != NULL) {
|
if (out->closecallback != NULL) {
|
||||||
@ -1998,8 +1999,10 @@ xmlOutputBufferClose(xmlOutputBufferPtr out) {
|
|||||||
out->buffer = NULL;
|
out->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out->error)
|
||||||
|
err_rc = -1;
|
||||||
xmlFree(out);
|
xmlFree(out);
|
||||||
return( ( err_rc == 0 ) ? written : err_rc );
|
return ((err_rc == 0) ? written : err_rc);
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
|
@ -1066,7 +1066,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
|||||||
out = fopen(output,"wb");
|
out = fopen(output,"wb");
|
||||||
}
|
}
|
||||||
if (out != NULL) {
|
if (out != NULL) {
|
||||||
xmlDocDump(out, doc);
|
if (xmlDocDump(out, doc) < 0)
|
||||||
|
progresult = 6;
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
Reference in New Issue
Block a user