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] PR44931 Inquire by UNIT on stdin, stdout, and stderr for NAME


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$.
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)
integer :: i
character(30) :: aname

aname = "noname"
inquire(unit=0, name=aname)
print *, 0, aname
aname = "noname"
inquire(unit=5, name=aname)
print *, 5, aname
aname = "noname"
inquire(unit=6, name=aname)
print *, 6, aname
end



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