[PATCH] Thread-safe libgfortran (PRs fortran/14943 and fortran/21647)
Alan Modra
amodra@bigpond.net.au
Wed Nov 23 06:09:00 GMT 2005
On Wed, Nov 23, 2005 at 04:18:42PM +1030, Alan Modra wrote:
> On Wed, Nov 23, 2005 at 12:20:17AM -0500, David Edelsohn wrote:
> > gfortran.dg/dev_null.f90
> > gfortran.dg/write_to_null.f90
> >
> > are failing with a "File already opened in another unit" error. This
[snip]
> > if (u2 != NULL
> > && (options.stdin_unit < 0 || u->unit_number != options.stdin_unit)
> > && (options.stdout_unit < 0 || u->unit_number != options.stdout_unit)
> > && (options.stderr_unit < 0 || u->unit_number != options.stderr_unit))
>
> I think that ought to be u2->unit_number rather than u->unit_number.
> Testing...
Yes, that cured it. OK to apply?
* io/open.c (new_unit): Use the right unit number when checking
for stdin, stdout, stderr.
Index: libgfortran/io/open.c
===================================================================
--- libgfortran/io/open.c (revision 107379)
+++ libgfortran/io/open.c (working copy)
@@ -339,9 +339,9 @@ new_unit (st_parameter_open *opp, gfc_un
if ((opp->common.flags & IOPARM_OPEN_HAS_FILE) != 0)
u2 = find_file (opp->file, opp->file_len);
if (u2 != NULL
- && (options.stdin_unit < 0 || u->unit_number != options.stdin_unit)
- && (options.stdout_unit < 0 || u->unit_number != options.stdout_unit)
- && (options.stderr_unit < 0 || u->unit_number != options.stderr_unit))
+ && (options.stdin_unit < 0 || u2->unit_number != options.stdin_unit)
+ && (options.stdout_unit < 0 || u2->unit_number != options.stdout_unit)
+ && (options.stderr_unit < 0 || u2->unit_number != options.stderr_unit))
{
unlock_unit (u2);
generate_error (&opp->common, ERROR_ALREADY_OPEN, NULL);
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Fortran
mailing list