* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
@ 2010-07-14 15:44 ` burnus at gcc dot gnu dot org
2010-07-15 21:39 ` jkrahn at nc dot rr dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-14 15:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2010-07-14 15:44 -------
Some remarks:
a) The note 9.63 is nonnormative - still one should try to follow it
b) Most of my compilers simply use "", ifort uses "/dev/pts/3" (for
stdin/out/err), and Portland uses the same as gfortran: stdin, stdout, stderr.
c) gfortran prints "/dev/pts/3" when calling ttynam() with the relevant unit
numbers.
d) The name "stdin" etc. is set "for error reporting" at
http://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgfortran/io/unit.c;hb=HEAD#l86
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
2010-07-14 15:44 ` [Bug fortran/44931] " burnus at gcc dot gnu dot org
@ 2010-07-15 21:39 ` jkrahn at nc dot rr dot com
2010-07-15 21:49 ` jkrahn at nc dot rr dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jkrahn at nc dot rr dot com @ 2010-07-15 21:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jkrahn at nc dot rr dot com 2010-07-15 21:39 -------
Intel Fortran currently returns the actual device name (e.g. "/dev/pts/3") but
also uses "stdin" if the input is from a pipe. I sent a similar low-priority
bug report to Intel, and they tentatively agree that the "stdin" string is
probably not a good convention. I will let you know if I hear more.
G77 and Sun Fortran treat stdio units as unnamed in all cases (tty or file
I/O), setting NAME='' and NAMED=.FALSE. (Hmm... does gfortran always set
NAMED=TRUE?)
IMHO, if stdio units have a name, like "/dev/pts/3", it should be used. If no
name is available from the OS, the Fortran side should also be unnamed. Then,
you are just giving Fortran the most accurate info available from the OS.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
2010-07-14 15:44 ` [Bug fortran/44931] " burnus at gcc dot gnu dot org
2010-07-15 21:39 ` jkrahn at nc dot rr dot com
@ 2010-07-15 21:49 ` jkrahn at nc dot rr dot com
2010-07-24 4:08 ` jvdelisle at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jkrahn at nc dot rr dot com @ 2010-07-15 21:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jkrahn at nc dot rr dot com 2010-07-15 21:49 -------
I noticed that Fedora now include symlinks for /dev/stdin, /dev/stdout,
/dev/stderr. It would be reasonable to use those path names if there is an
interest in avoiding blank names. This convention may not hold on all
platforms, but those device names probably will not exist otherwise.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (2 preceding siblings ...)
2010-07-15 21:49 ` jkrahn at nc dot rr dot com
@ 2010-07-24 4:08 ` jvdelisle at gcc dot gnu dot org
2010-07-24 8:22 ` burnus at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-24 4:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jvdelisle at gcc dot gnu dot org 2010-07-24 04:08 -------
Created an attachment (id=21296)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21296&action=view)
Proposed pathc
This patch uses ttyname to get the /dev/pts/* name. I have not tried this on a
Windows system yet to see what it does.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (3 preceding siblings ...)
2010-07-24 4:08 ` jvdelisle at gcc dot gnu dot org
@ 2010-07-24 8:22 ` burnus at gcc dot gnu dot org
2010-07-25 0:48 ` jvdelisle at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-24 8:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2010-07-24 08:22 -------
(In reply to comment #5)
> Created an attachment (id=21296)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21296&action=view) [edit]
> Proposed pathc
+ if (u->unit_number == options.stdin_unit
+ || u->unit_number == options.stdout_unit
+ || u->unit_number == options.stderr_unit)
Will this work for
open(6,file="test.dat")
inquire(6,file=str)
if (str /= "test.dat") call abort()
?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (4 preceding siblings ...)
2010-07-24 8:22 ` burnus at gcc dot gnu dot org
@ 2010-07-25 0:48 ` jvdelisle at gcc dot gnu dot org
2010-07-29 1:32 ` jvdelisle at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-25 0:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jvdelisle at gcc dot gnu dot org 2010-07-25 00:48 -------
test_inquire.f90:17.10:
inquire(6,file=str1)
1
Error: INQUIRE statement at (1) cannot contain both FILE and UNIT specifiers
However, with a simple modification to the patch the following works.
open(6,file="test.dat")
inquire(6,name=str1)
if (str1 /= "test.dat") call abort()
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (5 preceding siblings ...)
2010-07-25 0:48 ` jvdelisle at gcc dot gnu dot org
@ 2010-07-29 1:32 ` jvdelisle at gcc dot gnu dot org
2010-07-29 8:26 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-29 1:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jvdelisle at gcc dot gnu dot org 2010-07-29 01:32 -------
Subject: Bug 44931
Author: jvdelisle
Date: Thu Jul 29 01:32:23 2010
New Revision: 162667
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162667
Log:
2010-07-28 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.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/inquire.c
trunk/libgfortran/io/unix.c
trunk/libgfortran/io/unix.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (6 preceding siblings ...)
2010-07-29 1:32 ` jvdelisle at gcc dot gnu dot org
@ 2010-07-29 8:26 ` burnus at gcc dot gnu dot org
2010-07-30 1:47 ` jvdelisle at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-29 8:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from burnus at gcc dot gnu dot org 2010-07-29 08:26 -------
The committed patch has added:
+#ifdef HAVE_TTYNAME
+ if (u->unit_number == options.stdin_unit
+ || u->unit_number == options.stdout_unit
+ || u->unit_number == options.stderr_unit)
+ {
+ char * tmp = ttyname (((unix_stream *) u->s)->fd);
+ if (tmp != NULL)
+ {
+ int tmplen = strlen (tmp);
+ fstrcpy (iqp->name, iqp->name_len, tmp, tmplen);
+ }
+ else /* If ttyname does not work, go with the default. */
+ fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+ }
+ else
+#endif
+ fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+ }
For MINGW I would suggest to remove the last three lines and add the following:
+ 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
+ }
Note: This was written as is - there might be typos and it might not be even
compile.
Note 2: Kai says that on MINGW, HAVE_TTYNAME is not defined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (7 preceding siblings ...)
2010-07-29 8:26 ` burnus at gcc dot gnu dot org
@ 2010-07-30 1:47 ` jvdelisle at gcc dot gnu dot org
2010-08-04 10:02 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-30 1:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jvdelisle at gcc dot gnu dot org 2010-07-30 01:47 -------
Reply to comment #9.
Yes, this is what I was thinking. I wanted to float the first step out there to
see what else we would discover. As seen in PR 45131 there are other oddities
we need to deal with.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (8 preceding siblings ...)
2010-07-30 1:47 ` jvdelisle at gcc dot gnu dot org
@ 2010-08-04 10:02 ` burnus at gcc dot gnu dot org
2010-08-14 18:59 ` jvdelisle at gcc dot gnu dot org
2010-08-17 3:14 ` jvdelisle at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-08-04 10:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from burnus at gcc dot gnu dot org 2010-08-04 10:02 -------
(In reply to comment #10)
> Reply to comment #9.
>
> Yes, this is what I was thinking. I wanted to float the first step out there to
> see what else we would discover.
I think now that there are essentially no test suite failures (except some old
ones one more obscure targets), one could add a patch similar to the one in
comment 9...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (9 preceding siblings ...)
2010-08-04 10:02 ` burnus at gcc dot gnu dot org
@ 2010-08-14 18:59 ` jvdelisle at gcc dot gnu dot org
2010-08-17 3:14 ` jvdelisle at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-08-14 18:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jvdelisle at gcc dot gnu dot org 2010-08-14 18:59 -------
Subject: Bug 44931
Author: jvdelisle
Date: Sat Aug 14 18:59:18 2010
New Revision: 163245
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163245
Log:
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$.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/inquire.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
2010-07-13 20:51 [Bug fortran/44931] New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin" jkrahn at nc dot rr dot com
` (10 preceding siblings ...)
2010-08-14 18:59 ` jvdelisle at gcc dot gnu dot org
@ 2010-08-17 3:14 ` jvdelisle at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-08-17 3:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jvdelisle at gcc dot gnu dot org 2010-08-17 03:13 -------
Closing now
--
jvdelisle at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931
^ permalink raw reply [flat|nested] 14+ messages in thread