[patch, libfortran] PR44931 For INPUT_UNIT, INQUIRE NAME= should not return "stdin"

Jerry DeLisle jvdelisle@verizon.net
Sun Jul 25 00:56:00 GMT 2010


Hi Folks,

The attach patch uses ttyname to return the device file name for inquire by unit.

Regression tested on x86-64.

Test case attached, but the reulst are system dependent so I will not add it to 
the testsuite.

OK for trunk?

Regards,

Jerry

2010-07-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/44931
	* io/inquire.c (inquire_via_unit): Use ttyname to return actual device
	file name for stdin, stdout, and stderr.  If ttyname does not succeed
	fall back to default names for these units. Include string.h to allow
	using strlen function.
	* unix.c: Remove typedef of unix_stream structure, move to unix.h.
	* unix.h: Add typedef of unix_stream structure so that it is
	accessible to inquire.c.


program test_inquire
   character(80) :: str1
   open(10, file="myfilename")
   str1 = ""
   inquire(unit=6, name=str1)
   print *, 1,str1
   str1 = ""
   inquire(unit=5, name=str1)
   print *, 2,str1
   str1 = ""
   inquire(unit=37, name=str1)
   print *, 3,str1
   str1 = ""  ! Empty string since no connection has been made to unit 37
   inquire(unit=10, name=str1)
   print *, 4,str1
   open(6,file="test.dat")
   inquire(6,name=str1)
   if (str1 /= "test.dat") call abort()
   open(6,file="/dev/pts/2")
   print *, 5,str1
end program test_inquire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr44931.diff
Type: text/x-patch
Size: 3303 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100725/a9b38ba6/attachment.bin>


More information about the Gcc-patches mailing list