Patchwork [libfortran] PR44931 Inquire by UNIT on stdin, stdout, and stderr for NAME

login
register
mail settings
Submitter Jerry DeLisle
Date Aug. 14, 2010, 4:22 a.m.
Message ID <4C661A09.3000806@verizon.net>
Download mbox | patch
Permalink /patch/61727/
State New
Headers show

Comments

Jerry DeLisle - Aug. 14, 2010, 4:22 a.m.
Hi,

This patch is the second part of this fix and adds support for the NAME = for 
the preconnected units on MingW platforms.

Kai, will you please test. Test case should give:

	   0 CONERR$
	   5 CONIN$
	   6 CONOUT$

on MingW, otherwise something like this for other systems:

            0 /dev/pts/1
            5 /dev/pts/1
            6 /dev/pts/1


Regression tested on x86-64.

OK for trunk if passes MingW?

Regards,

Jerry

2010-08-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/44931
	* io/inquire.c (inquire_via_unit): Add special case for __MINGW32__ to
	return special file names CONIN$, CONOUT$, and CONERR$.
Tobias Burnus - Aug. 14, 2010, 8:05 a.m.
Am 14.08.2010 06:22, schrieb Jerry DeLisle:
> This patch is the second part of this fix and adds support for the 
> NAME = for the preconnected units on MingW platforms.
>
> Regression tested on x86-64.
> OK for trunk if passes MingW?

OK. Thanks for the patch!

Tobias

> 2010-08-14  Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
>     PR libfortran/44931
>     * io/inquire.c (inquire_via_unit): Add special case for 
> __MINGW32__ to
>     return special file names CONIN$, CONOUT$, and CONERR$.

Patch

Index: inquire.c
===================================================================
--- inquire.c	(revision 163225)
+++ inquire.c	(working copy)
@@ -83,8 +83,25 @@  inquire_via_unit (st_parameter_inquire *iqp, gfc_u
 	    fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
 	}
       else
+	fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+#elif defined __MINGW32__
+    switch (u->unit_number)
+      {
+	case options.stdin_unit:
+	  fstrcpy (iqp->name, iqp->name_len, "CONIN$", sizeof("CONIN$"));
+	  break;
+	case options.stdout_unit:
+	  fstrcpy (iqp->name, iqp->name_len, "CONOUT$", sizeof("CONOUT$"));
+	  break;
+	case options.stderr_unit:
+	  fstrcpy (iqp->name, iqp->name_len, "CONERR$", sizeof("CONERR$"));
+	  break;
+	default:
+	  fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+      }
+#else
+    fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
 #endif
-	fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
     }
 
   if ((cf & IOPARM_INQUIRE_HAS_ACCESS) != 0)