From: Francois-Xavier Coudert Date: Fri, 19 Oct 2007 04:10:58 +0000 (+0000) Subject: re PR fortran/33795 (Environment variable GFORTRAN_UNBUFFERED_ not working) X-Git-Tag: releases/gcc-4.3.0~1940 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f94e1d88efeb405a810a72ad61ab637becb3761;p=thirdparty%2Fgcc.git re PR fortran/33795 (Environment variable GFORTRAN_UNBUFFERED_ not working) 2007-10-18 Francois-Xavier Coudert Jerry DeLisle PR libfortran/33795 * libgfortran.h: Add unbuffered_preconnected. * io/unix.c (output_stream): Set stream unbuffered flag if options.unbuffered_preconnected has been set. (error_stream): Ditto. * runtime/environ.c (variable_table): Add to environment variable table the entry: GFORTRAN_UNBUFFERED_PRECONNECTED. Co-Authored-By: Jerry DeLisle From-SVN: r129470 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 6dcc055c7dbb..a5415a0ae9a1 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2007-10-18 Francois-Xavier Coudert + Jerry DeLisle + + PR libfortran/33795 + * libgfortran.h: Add unbuffered_preconnected. + * io/unix.c (output_stream): Set stream unbuffered flag if + options.unbuffered_preconnected has been set. + (error_stream): Ditto. + * runtime/environ.c (variable_table): Add to environment variable table + the entry: GFORTRAN_UNBUFFERED_PRECONNECTED. + 2007-10-18 Francois-Xavier Coudert PR libfortran/32021 diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 9b61507e2740..93484ea014c1 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -1411,10 +1411,16 @@ input_stream (void) stream * output_stream (void) { + stream * s; + #if defined(HAVE_CRLF) && defined(HAVE_SETMODE) setmode (STDOUT_FILENO, O_BINARY); #endif - return fd_to_stream (STDOUT_FILENO, PROT_WRITE); + + s = fd_to_stream (STDOUT_FILENO, PROT_WRITE); + if (options.unbuffered_preconnected) + ((unix_stream *) s)->unbuffered = 1; + return s; } @@ -1424,10 +1430,16 @@ output_stream (void) stream * error_stream (void) { + stream * s; + #if defined(HAVE_CRLF) && defined(HAVE_SETMODE) setmode (STDERR_FILENO, O_BINARY); #endif - return fd_to_stream (STDERR_FILENO, PROT_WRITE); + + s = fd_to_stream (STDERR_FILENO, PROT_WRITE); + if (options.unbuffered_preconnected) + ((unix_stream *) s)->unbuffered = 1; + return s; } diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index 8d80998423db..a30ab19ab6bd 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -349,7 +349,7 @@ typedef struct int separator_len; const char *separator; - int use_stderr, all_unbuffered, default_recl; + int use_stderr, all_unbuffered, unbuffered_preconnected, default_recl; int fpe, dump_core, backtrace; } options_t; diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c index a7ee3a771cba..ba8283e68aa4 100644 --- a/libgfortran/runtime/environ.c +++ b/libgfortran/runtime/environ.c @@ -299,6 +299,10 @@ static variable variable_table[] = { "If TRUE, all output is unbuffered. This will slow down large writes " "but can be\nuseful for forcing data to be displayed immediately.", 0}, + {"GFORTRAN_UNBUFFERED_PRECONNECTED", 0, &options.unbuffered_preconnected, + init_boolean, show_boolean, + "If TRUE, output to preconnected units is unbuffered.", 0}, + {"GFORTRAN_SHOW_LOCUS", 1, &options.locus, init_boolean, show_boolean, "If TRUE, print filename and line number where runtime errors happen.", 0}, @@ -346,32 +350,6 @@ init_variables (void) } -/* check_buffered()-- Given an unit number n, determine if an override - * for the stream exists. Returns zero for unbuffered, one for - * buffered or two for not set. */ - -int -check_buffered (int n) -{ - char name[22 + sizeof (n) * 3]; - variable v; - int rv; - - if (options.all_unbuffered) - return 0; - - sprintf (name, "GFORTRAN_UNBUFFERED_%d", n); - - v.name = name; - v.value = 2; - v.var = &rv; - - init_boolean (&v); - - return rv; -} - - void show_variables (void) {