public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/44931]  New: For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
@ 2010-07-13 20:51 jkrahn at nc dot rr dot com
  2010-07-14 15:44 ` [Bug fortran/44931] " burnus at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: jkrahn at nc dot rr dot com @ 2010-07-13 20:51 UTC (permalink / raw)
  To: gcc-bugs

The F2003 spec has the following not about the NAME= specifier:
--------
NOTE 9.63
If this specifier appears in an INQUIRE by file statement, its value is not
necessarily the same as the name given in the FILE= specifier. However, the
value returned shall be suitable for use as the value of the file-name-expr in
the FILE= specifier in an OPEN statement.

The processor may return a file name qualified by a user identification,
device, directory, or other relevant information.
--------

The second part of the note suggests that a dummy name like "stdin" may be
acceptable, but it does not conform to the first part of the note. OPEN will
accept "stdin" as a normal filename. The easiest implementation is to return
the actual stdin device name. Otherwise, just leave it unnamed.

Obviously, the same is true of standard output and error units.


-- 
           Summary: For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jkrahn at nc dot rr dot com


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 ` 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

* [Bug fortran/44931] For INPUT_UNIT, INQUIRE NAME= should not return "stdin"
       [not found] <bug-44931-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-04 19:30 ` jb at gcc dot gnu.org
  0 siblings, 0 replies; 14+ messages in thread
From: jb at gcc dot gnu.org @ 2010-11-04 19:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44931

--- Comment #14 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-11-04 19:29:33 UTC ---
Author: jb
Date: Thu Nov  4 19:29:28 2010
New Revision: 166325

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166325
Log:
PR 44931 Move struct unix_stream to unix.c

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/inquire.c
    trunk/libgfortran/io/unix.c
    trunk/libgfortran/io/unix.h


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-11-04 19:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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
2010-08-14 18:59 ` jvdelisle at gcc dot gnu dot org
2010-08-17  3:14 ` jvdelisle at gcc dot gnu dot org
     [not found] <bug-44931-4@http.gcc.gnu.org/bugzilla/>
2010-11-04 19:30 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).