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, libfortran] PR32784 CONIN$, CONOUT$, and CONERR$ for Cygwin and mingw


The attached patch provides mapping the special file names to standard IO. This is an extension requested quite a ways back.

Applied and tested / regression tested on Cygwin running on WinNT workstation. I do not have a working mingw set-up and would much appreciate someone building and testing for that system.

OK for trunk if so tested and passes?

Regards,

Jerry

2009-06-13 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	* io/unic.c (open_external): Translate CONIN$, CONOUT$, and CONERR$ to
	stdin, stdout, and stderr for ming32 or cygwin systems.


Index: unix.c
===================================================================
--- unix.c	(revision 148233)
+++ unix.c	(working copy)
@@ -119,7 +119,14 @@ id_from_fd (const int fd)
 #define S_IWOTH 0
 #endif
 
+#ifdef __CYGWIN__
+#define HAVE_DOS_CONIO
+#endif
 
+#ifdef __MINGW32__
+#define HAVE_DOS_CONIO
+#endif
+
 /* Unix and internal stream I/O module */
 
 static const int BUFFER_SIZE = 8192;
@@ -993,6 +1000,33 @@ open_external (st_parameter_open *opp, unit_flags
 {
   int fd, prot;
 
+#ifdef HAVE_DOS_CONIO
+  if ((opp->common.flags & IOPARM_OPEN_HAS_FILE) != 0)
+    {
+      if (strncmp (opp->file, "CONOUT$", 7) == 0)
+	{
+	  fd = STDOUT_FILENO;
+	  prot = PROT_WRITE;
+	  flags->action = ACTION_WRITE;
+	  return fd_to_stream (fd, prot);
+	}
+      if (strncmp (opp->file, "CONIN$", 6) == 0)
+	{
+	  fd = STDIN_FILENO;
+	  prot = PROT_READ;
+	  flags->action = ACTION_READ;
+	  return fd_to_stream (fd, prot);
+	}
+      if (strncmp (opp->file, "CONERR$", 7) == 0)
+	{
+	  fd = STDERR_FILENO;
+	  prot = PROT_WRITE;
+	  flags->action = ACTION_WRITE;
+	  return fd_to_stream (fd, prot);
+	}
+    }
+#endif
+
   if (flags->status == STATUS_SCRATCH)
     {
       fd = tempfile (opp);

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