1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-01 10:06:59 +03:00

some cleanups when chasing unappropriate stdout output. Daniel

* debugXML.c tree.c xmlIO.c xmlmemory.c: some cleanups when chasing
  unappropriate stdout output.
Daniel
This commit is contained in:
Daniel Veillard
2001-11-22 18:20:37 +00:00
parent 566d4dfac3
commit cd337f0bc6
5 changed files with 38 additions and 29 deletions

View File

@ -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> 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 * include/libxml/tree.h: Fixed a couple of macro errors pointed out

View File

@ -314,7 +314,7 @@ xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
xmlDebugDumpString(output, attr->defaultValue); xmlDebugDumpString(output, attr->defaultValue);
fprintf(output, "\""); fprintf(output, "\"");
} }
printf("\n"); fprintf(output, "\n");
/* /*
* Do a bit of checking * Do a bit of checking
@ -388,7 +388,7 @@ xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
buf[5000] = 0; buf[5000] = 0;
fprintf(output, "%s", buf); fprintf(output, "%s", buf);
} }
printf("\n"); fprintf(output, "\n");
/* /*
* Do a bit of checking * Do a bit of checking
@ -1529,9 +1529,9 @@ xmlShellBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
base = xmlNodeGetBase(node->doc, node); base = xmlNodeGetBase(node->doc, node);
if (base == NULL) { if (base == NULL) {
printf(" No base found !!!\n"); fprintf(stdout, " No base found !!!\n");
} else { } else {
printf("%s\n", base); fprintf(stdout, "%s\n", base);
xmlFree(base); xmlFree(base);
} }
return (0); return (0);
@ -1599,7 +1599,7 @@ xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
else else
xmlElemDump(stdout, ctxt->doc, node); xmlElemDump(stdout, ctxt->doc, node);
} }
printf("\n"); fprintf(stdout, "\n");
return (0); return (0);
} }
@ -1630,7 +1630,7 @@ xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
doc = htmlParseFile(filename, NULL); doc = htmlParseFile(filename, NULL);
#else #else
printf("HTML support not compiled in\n"); fprintf(stdout, "HTML support not compiled in\n");
doc = NULL; doc = NULL;
#endif /* LIBXML_HTML_ENABLED */ #endif /* LIBXML_HTML_ENABLED */
} else { } else {
@ -1850,11 +1850,11 @@ xmlShellDu(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
while (node != NULL) { while (node != NULL) {
if ((node->type == XML_DOCUMENT_NODE) || if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE)) { (node->type == XML_HTML_DOCUMENT_NODE)) {
printf("/\n"); fprintf(stdout, "/\n");
} else if (node->type == XML_ELEMENT_NODE) { } else if (node->type == XML_ELEMENT_NODE) {
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
printf(" "); fprintf(stdout, " ");
printf("%s\n", node->name); fprintf(stdout, "%s\n", node->name);
} else { } else {
} }
@ -2053,22 +2053,22 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
if (!strcmp(command, "bye")) if (!strcmp(command, "bye"))
break; break;
if (!strcmp(command, "help")) { if (!strcmp(command, "help")) {
printf("\tbase display XML base of the node\n"); fprintf(stdout, "\tbase display XML base of the node\n");
printf("\tbye leave shell\n"); fprintf(stdout, "\tbye leave shell\n");
printf("\tcat [node] display node or current node\n"); fprintf(stdout, "\tcat [node] display node or current node\n");
printf("\tcd [path] change directory to path or to root\n"); fprintf(stdout, "\tcd [path] change directory to path or to root\n");
printf("\tdir [path] dumps informations about the node (namespace, attributes, content)\n"); fprintf(stdout, "\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"); fprintf(stdout, "\tdu [path] show the structure of the subtree under path or the current node\n");
printf("\texit leave shell\n"); fprintf(stdout, "\texit leave shell\n");
printf("\thelp display this help\n"); fprintf(stdout, "\thelp display this help\n");
printf("\tfree display memory usage\n"); fprintf(stdout, "\tfree display memory usage\n");
printf("\tload [name] load a new document with name\n"); fprintf(stdout, "\tload [name] load a new document with name\n");
printf("\tls [path] list contents of path or the current directory\n"); fprintf(stdout, "\tls [path] list contents of path or the current directory\n");
printf("\tpwd display current working directory\n"); fprintf(stdout, "\tpwd display current working directory\n");
printf("\tquit leave shell\n"); fprintf(stdout, "\tquit leave shell\n");
printf("\tsave [name] save this document to name or the original name\n"); fprintf(stdout, "\tsave [name] save this document to name or the original name\n");
printf("\tvalidate check the document for errors\n"); fprintf(stdout, "\tvalidate check the document for errors\n");
printf("\twrite [name] write the current node to the filename\n"); fprintf(stdout, "\twrite [name] write the current node to the filename\n");
} else if (!strcmp(command, "validate")) { } else if (!strcmp(command, "validate")) {
xmlShellValidate(ctxt, arg, NULL, NULL); xmlShellValidate(ctxt, arg, NULL, NULL);
} else if (!strcmp(command, "load")) { } else if (!strcmp(command, "load")) {
@ -2090,7 +2090,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
char dir[500]; char dir[500];
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
printf("%s\n", dir); fprintf(stdout, "%s\n", dir);
} else if (!strcmp(command, "du")) { } else if (!strcmp(command, "du")) {
xmlShellDu(ctxt, NULL, ctxt->node, NULL); xmlShellDu(ctxt, NULL, ctxt->node, NULL);
} else if (!strcmp(command, "base")) { } else if (!strcmp(command, "base")) {
@ -2280,7 +2280,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
indx < list->nodesetval->nodeNr; indx < list->nodesetval->nodeNr;
indx++) { indx++) {
if (i > 0) if (i > 0)
printf(" -------\n"); fprintf(stdout, " -------\n");
xmlShellCat(ctxt, NULL, xmlShellCat(ctxt, NULL,
list->nodesetval-> list->nodesetval->
nodeTab[indx], NULL); nodeTab[indx], NULL);

3
tree.c
View File

@ -4929,7 +4929,8 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
#endif #endif
return(0); return(0);
} }
if (file == NULL) file = stdout; if (file == NULL)
file = stdout;
ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file); ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
return(ret); return(ret);
} }

View File

@ -399,6 +399,8 @@ xmlFileClose (void * context) {
return(0); return(0);
if (fil == stdout) if (fil == stdout)
return(0); return(0);
if (fil == stderr)
return(0);
return ( ( fclose((FILE *) context) == EOF ) ? -1 : 0 ); return ( ( fclose((FILE *) context) == EOF ) ? -1 : 0 );
} }

View File

@ -642,7 +642,8 @@ xmlMemoryDump(void)
FILE *dump; FILE *dump;
dump = fopen(".memdump", "w"); dump = fopen(".memdump", "w");
if (dump == NULL) xmlMemoryDumpFile = stdout; if (dump == NULL)
xmlMemoryDumpFile = stderr;
else xmlMemoryDumpFile = dump; else xmlMemoryDumpFile = dump;
xmlMemDisplay(xmlMemoryDumpFile); xmlMemDisplay(xmlMemoryDumpFile);