From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3889 invoked by alias); 25 Jul 2010 09:00:33 -0000 Received: (qmail 3873 invoked by uid 22791); 25 Jul 2010 09:00:32 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_BG X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 25 Jul 2010 09:00:26 +0000 Received: from [192.168.178.22] (port-92-204-52-63.dynamic.qsc.de [92.204.52.63]) by mx02.qsc.de (Postfix) with ESMTP id 980DC1E551; Sun, 25 Jul 2010 11:00:23 +0200 (CEST) Message-ID: <4C4BFD27.806@net-b.de> Date: Sun, 25 Jul 2010 09:00:00 -0000 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: Jerry DeLisle CC: gfortran , gcc patches Subject: Re: [patch, libfortran] PR44931 For INPUT_UNIT, INQUIRE NAME= should not return "stdin" References: <4C4B8BA3.2070202@verizon.net> In-Reply-To: <4C4B8BA3.2070202@verizon.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg01980.txt.bz2 Dear Jerry, Dave, and Kai, Dave and Kai: I have CCed you as I have a question regarding MinGW/Cygwin. Jerry DeLisle wrote: > 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. Kai, Dave: The idea is that INQUIRE returns for stdin, stdout, and stderr a "filename", which can be used to '(re)open' ([re]associate) a Fortran I/O unit number with those standard I/O "streams". (Non normative note in the standard: "the value [for NAME=] returned [by "INQUIRE(UNIT=...,NAME=...)"] shall be suitable for use as the value of the file-name-expr in the FILE= specifier in an OPEN statement.") Under Unix, ttynam should roughly do this, but I fear it might not work under Windows - in particular under MinGW(.org,64). Or does it? Would it be an option to use conout$, conin$ and conerr$ for those? I think on MinGW, libgfortran (io/unix.c) uses them directly (well conerr$ = conout$) while on cygwin those are mapped to /dev/con{in,out,err}. At least for MinGW this seems to be required as Windows does not seem to have a tty concept. For Cygwin the Unix approach should work. > OK for trunk? I think you need to guard the use of ttyname by #ifdef HAVE_TTYNAME ... #else ... #endif Besides, I wonder whether using "" as string is better than using the default std{in,out,err} in case ttyname fails. (This happens for instance if the standard I/O redirected to a file or pipe.) Otherwise, the patch looks fine to me. Tobias > 2010-07-24 Jerry DeLisle > > 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.