some cleanups when chasing unappropriate stdout output. Daniel
* debugXML.c tree.c xmlIO.c xmlmemory.c: some cleanups when chasing
unappropriate stdout output.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 59df1a9..3db9cab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Nov 22 19:19:10 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+ * debugXML.c tree.c xmlIO.c xmlmemory.c: some cleanups when chasing
+ unappropriate stdout output.
+
Thu Nov 22 13:58:14 CET 2001 Daniel Veillard <daniel@veillard.com>
* include/libxml/tree.h: Fixed a couple of macro errors pointed out
diff --git a/debugXML.c b/debugXML.c
index adc08d4..aa3eaf9 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -314,7 +314,7 @@
xmlDebugDumpString(output, attr->defaultValue);
fprintf(output, "\"");
}
- printf("\n");
+ fprintf(output, "\n");
/*
* Do a bit of checking
@@ -388,7 +388,7 @@
buf[5000] = 0;
fprintf(output, "%s", buf);
}
- printf("\n");
+ fprintf(output, "\n");
/*
* Do a bit of checking
@@ -1529,9 +1529,9 @@
base = xmlNodeGetBase(node->doc, node);
if (base == NULL) {
- printf(" No base found !!!\n");
+ fprintf(stdout, " No base found !!!\n");
} else {
- printf("%s\n", base);
+ fprintf(stdout, "%s\n", base);
xmlFree(base);
}
return (0);
@@ -1599,7 +1599,7 @@
else
xmlElemDump(stdout, ctxt->doc, node);
}
- printf("\n");
+ fprintf(stdout, "\n");
return (0);
}
@@ -1630,7 +1630,7 @@
#ifdef LIBXML_HTML_ENABLED
doc = htmlParseFile(filename, NULL);
#else
- printf("HTML support not compiled in\n");
+ fprintf(stdout, "HTML support not compiled in\n");
doc = NULL;
#endif /* LIBXML_HTML_ENABLED */
} else {
@@ -1850,11 +1850,11 @@
while (node != NULL) {
if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE)) {
- printf("/\n");
+ fprintf(stdout, "/\n");
} else if (node->type == XML_ELEMENT_NODE) {
for (i = 0; i < indent; i++)
- printf(" ");
- printf("%s\n", node->name);
+ fprintf(stdout, " ");
+ fprintf(stdout, "%s\n", node->name);
} else {
}
@@ -2053,22 +2053,22 @@
if (!strcmp(command, "bye"))
break;
if (!strcmp(command, "help")) {
- printf("\tbase display XML base of the node\n");
- printf("\tbye leave shell\n");
- printf("\tcat [node] display node or current node\n");
- printf("\tcd [path] change directory to path or to root\n");
- printf("\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
- printf("\tdu [path] show the structure of the subtree under path or the current node\n");
- printf("\texit leave shell\n");
- printf("\thelp display this help\n");
- printf("\tfree display memory usage\n");
- printf("\tload [name] load a new document with name\n");
- printf("\tls [path] list contents of path or the current directory\n");
- printf("\tpwd display current working directory\n");
- printf("\tquit leave shell\n");
- printf("\tsave [name] save this document to name or the original name\n");
- printf("\tvalidate check the document for errors\n");
- printf("\twrite [name] write the current node to the filename\n");
+ fprintf(stdout, "\tbase display XML base of the node\n");
+ fprintf(stdout, "\tbye leave shell\n");
+ fprintf(stdout, "\tcat [node] display node or current node\n");
+ fprintf(stdout, "\tcd [path] change directory to path or to root\n");
+ fprintf(stdout, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
+ fprintf(stdout, "\tdu [path] show the structure of the subtree under path or the current node\n");
+ fprintf(stdout, "\texit leave shell\n");
+ fprintf(stdout, "\thelp display this help\n");
+ fprintf(stdout, "\tfree display memory usage\n");
+ fprintf(stdout, "\tload [name] load a new document with name\n");
+ fprintf(stdout, "\tls [path] list contents of path or the current directory\n");
+ fprintf(stdout, "\tpwd display current working directory\n");
+ fprintf(stdout, "\tquit leave shell\n");
+ fprintf(stdout, "\tsave [name] save this document to name or the original name\n");
+ fprintf(stdout, "\tvalidate check the document for errors\n");
+ fprintf(stdout, "\twrite [name] write the current node to the filename\n");
} else if (!strcmp(command, "validate")) {
xmlShellValidate(ctxt, arg, NULL, NULL);
} else if (!strcmp(command, "load")) {
@@ -2090,7 +2090,7 @@
char dir[500];
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
- printf("%s\n", dir);
+ fprintf(stdout, "%s\n", dir);
} else if (!strcmp(command, "du")) {
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
} else if (!strcmp(command, "base")) {
@@ -2280,7 +2280,7 @@
indx < list->nodesetval->nodeNr;
indx++) {
if (i > 0)
- printf(" -------\n");
+ fprintf(stdout, " -------\n");
xmlShellCat(ctxt, NULL,
list->nodesetval->
nodeTab[indx], NULL);
diff --git a/tree.c b/tree.c
index c55f4ff..12a8333 100644
--- a/tree.c
+++ b/tree.c
@@ -4929,7 +4929,8 @@
#endif
return(0);
}
- if (file == NULL) file = stdout;
+ if (file == NULL)
+ file = stdout;
ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
return(ret);
}
diff --git a/xmlIO.c b/xmlIO.c
index 929cee0..7fd101c 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -399,6 +399,8 @@
return(0);
if (fil == stdout)
return(0);
+ if (fil == stderr)
+ return(0);
return ( ( fclose((FILE *) context) == EOF ) ? -1 : 0 );
}
diff --git a/xmlmemory.c b/xmlmemory.c
index aa82c4e..e511570 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -642,7 +642,8 @@
FILE *dump;
dump = fopen(".memdump", "w");
- if (dump == NULL) xmlMemoryDumpFile = stdout;
+ if (dump == NULL)
+ xmlMemoryDumpFile = stderr;
else xmlMemoryDumpFile = dump;
xmlMemDisplay(xmlMemoryDumpFile);