From a9e65e8be296953aa4f6df75b2cae7d0e70f5d2b Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Tue, 30 Oct 2001 10:32:36 +0000 Subject: [PATCH] closing bug #62711, the library should never close stdin or stdout. Daniel * xmlIO.c: closing bug #62711, the library should never close stdin or stdout. Daniel --- ChangeLog | 5 +++++ xmlIO.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7aafa2c3..c84fd18a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 30 11:31:19 CET 2001 Daniel Veillard + + * xmlIO.c: closing bug #62711, the library should never + close stdin or stdout. + Tue Oct 30 10:46:12 CET 2001 Daniel Veillard * uri.c: second pass at fixing #63336, using Joel Young diff --git a/xmlIO.c b/xmlIO.c index fac91324..ceb9c4f1 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -392,6 +392,13 @@ xmlFileWrite (void * context, const char * buffer, int len) { */ static int xmlFileClose (void * context) { + FILE *fil; + + fil = (FILE *) context; + if (fil == stdin) + return(0); + if (fil == stdout) + return(0); return ( ( fclose((FILE *) context) == EOF ) ? -1 : 0 ); } @@ -440,7 +447,7 @@ xmlGzfileOpen (const char *filename) { gzFile fd; if (!strcmp(filename, "-")) { - fd = gzdopen(fileno(stdin), "rb"); + fd = gzdopen(dup(0), "rb"); return((void *) fd); } @@ -482,7 +489,7 @@ xmlGzfileOpenW (const char *filename, int compression) { sprintf(mode, "wb%d", compression); if (!strcmp(filename, "-")) { - fd = gzdopen(1, mode); + fd = gzdopen(dup(1), mode); return((void *) fd); }