This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Connect stderr to Unit 0 (PR libgfortran/19052)


	This patch connects stderr to Unit 0.  If I understand libgfortran
correctly, this should be separate from init_error_stream() used for
errors from within the library.

David

	* libgfortran.h (options_t): Add stderr_unit.
	* io/unit.c (init_units): Initialize stderr_unit.
	* io/unix.c (error_stream): New function.
	* runtime/environ.c (GFORTRAN_STDERR_UNIT): New environment variable.

Index: libgfortran.h
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/libgfortran.h,v
retrieving revision 1.20
diff -c -p -r1.20 libgfortran.h
*** libgfortran.h	27 Dec 2004 16:43:21 -0000	1.20
--- libgfortran.h	8 Jan 2005 18:38:28 -0000
*************** enum
*** 285,291 ****
  
  typedef struct
  {
!   int stdin_unit, stdout_unit, optional_plus;
    int allocate_init_flag, allocate_init_value;
    int locus;
  
--- 285,291 ----
  
  typedef struct
  {
!   int stdin_unit, stdout_unit, stderr_unit, optional_plus;
    int allocate_init_flag, allocate_init_value;
    int locus;
  
Index: io/unit.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/unit.c,v
retrieving revision 1.6
diff -c -p -r1.6 unit.c
*** io/unit.c	31 Aug 2004 19:49:33 -0000	1.6
--- io/unit.c	8 Jan 2005 18:38:28 -0000
*************** init_units (void)
*** 325,330 ****
--- 325,351 ----
        insert_unit (u);
      }
  
+   if (options.stderr_unit >= 0)
+     {				/* STDERR */
+       u = get_mem (sizeof (gfc_unit));
+ 
+       u->unit_number = options.stderr_unit;
+       u->s = error_stream ();
+ 
+       u->flags.action = ACTION_WRITE;
+ 
+       u->flags.access = ACCESS_SEQUENTIAL;
+       u->flags.form = FORM_FORMATTED;
+       u->flags.status = STATUS_OLD;
+       u->flags.blank = BLANK_ZERO;
+       u->flags.position = POSITION_ASIS;
+ 
+       u->recl = options.default_recl;
+       u->endfile = AT_ENDFILE;
+ 
+       insert_unit (u);
+     }
+ 
    /* Calculate the maximum file offset in a portable manner.
     * max will be the largest signed number for the type gfc_offset.
     *
Index: io/unix.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.18
diff -c -p -r1.18 unix.c
*** io/unix.c	8 Dec 2004 00:32:39 -0000	1.18
--- io/unix.c	8 Jan 2005 18:38:28 -0000
*************** input_stream (void)
*** 1140,1146 ****
  }
  
  
! /* output_stream()-- Return a stream pointer to the default input stream.
   * Called on initialization. */
  
  stream *
--- 1140,1146 ----
  }
  
  
! /* output_stream()-- Return a stream pointer to the default output stream.
   * Called on initialization. */
  
  stream *
*************** output_stream (void)
*** 1150,1155 ****
--- 1150,1165 ----
  }
  
  
+ /* error_stream()-- Return a stream pointer to the default error stream.
+  * Called on initialization. */
+ 
+ stream *
+ error_stream (void)
+ {
+ 
+   return fd_to_stream (STDERR_FILENO, PROT_WRITE);
+ }
+ 
  /* init_error_stream()-- Return a pointer to the error stream.  This
   * subroutine is called when the stream is needed, rather than at
   * initialization.  We want to work even if memory has been seriously
Index: runtime/environ.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/runtime/environ.c,v
retrieving revision 1.5
diff -c -p -r1.5 environ.c
*** runtime/environ.c	19 Dec 2004 18:54:00 -0000	1.5
--- runtime/environ.c	8 Jan 2005 18:38:28 -0000
*************** static variable variable_table[] = {
*** 434,439 ****
--- 434,444 ----
     "Unit number that will be preconnected to standard output\n"
     "(No preconnection if negative)"},
  
+   {"GFORTRAN_STDERR_UNIT", 0, &options.stderr_unit, init_integer,
+    show_integer,
+    "Unit number that will be preconnected to standard error\n"
+    "(No preconnection if negative)"},
+ 
    {"GFORTRAN_USE_STDERR", 1, &options.use_stderr, init_boolean,
     show_boolean,
     "Sends library output to standard error instead of standard output."},


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]