[Patch, Fortran] PR60286 - fix INQUIRE for write= with stdout/stdin/stderr
Tobias Burnus
burnus@net-b.de
Fri Feb 21 07:37:00 GMT 2014
Hi,
Janus Weil wrote:
>> Namely, either unconditionally using for UNIT=:
>>
>> if ((cf & IOPARM_INQUIRE_HAS_READWRITE) != 0)
>> p = (u->flags.action == ACTION_READWRITE) ? yes : no;
>>
>> We probably still need some special case for stdin/stdout/stderr.
> Do we? If the new version of the patch works correctly, then it seems
> that we don't?
I wrote that before carefully checking the code and actually doing the
modification. unit.c's init_units sets them correctly.
>> * Advantage of access(): Gives the true file mode by the OS.
>> * Advantage of the open mode: Gives the permissions for which the
>> unit was opened.
> Is there actually a difference?
Well, you can do:
open(99, file="test.dat", action="write")
write(99, *) 6
rewind(99)
read(99, *) i
end
If you look at the file permissions of the generated file, they are -
here- '-rw-r--r--', i.e. for the user readable and writable.
However, the code will fail due to the action='write' at run time with:
Fortran runtime error: Cannot read from file opened for WRITE
That's another reason for using the action mode with by-unit inquire.
> In any case I think INQUIRE with FILE should use the former, while
> INQUIRE with UNIT should use the latter, which is apparently what your
> new patch does.
I concur - hence, I implemented it that way.
> I like the new version much better, because it is more general and
> even simpler. To my taste it is ok for trunk ...
Committed as Rev. 207979.
Thanks for the review!
Tobias
More information about the Fortran
mailing list