diff options
author | Bud Davis <bdavis9659@comcast.net> | 2005-01-22 03:51:12 +0000 |
---|---|---|
committer | Bud Davis <bdavis@gcc.gnu.org> | 2005-01-22 03:51:12 +0000 |
commit | b1a807057ecb701601141285c011ef637b97f3b7 (patch) | |
tree | 2558c3d156cfc7fc1cf142d5f1c70137cabcff5b /libgfortran/io | |
parent | 987732e0c88255f18d408d2ad35eb7bcff865083 (diff) | |
download | gcc-b1a807057ecb701601141285c011ef637b97f3b7.zip gcc-b1a807057ecb701601141285c011ef637b97f3b7.tar.gz gcc-b1a807057ecb701601141285c011ef637b97f3b7.tar.bz2 |
re PR libfortran/19314 (inquire(position=) segfaults at runtime)
2004-01-22 Bud Davis <bdavis9659@comcast.net>
PR fortran/19314
* io/inquire.c(inquire_via_unit): implement POSITION=.
* io/transfer.c(next_record): update position for
INQUIRE.
* io/rewind.c(st_rewind): update position for
INQUIRE.
* gfortran.dg/inquire_5.f90: New test.
From-SVN: r94060
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/inquire.c | 26 | ||||
-rw-r--r-- | libgfortran/io/rewind.c | 2 | ||||
-rw-r--r-- | libgfortran/io/transfer.c | 3 |
3 files changed, 25 insertions, 6 deletions
diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c index 4127f70..20fa8b3 100644 --- a/libgfortran/io/inquire.c +++ b/libgfortran/io/inquire.c @@ -166,13 +166,27 @@ inquire_via_unit (gfc_unit * u) if (ioparm.position != NULL) { if (u == NULL || u->flags.access == ACCESS_DIRECT) - p = undefined; + p = undefined; else - { - p = NULL; /* TODO: Try to decode what the standard says... */ - } - - cf_strcpy (ioparm.blank, ioparm.blank_len, p); + switch (u->flags.position) + { + case POSITION_REWIND: + p = "REWIND"; + break; + case POSITION_APPEND: + p = "APPEND"; + break; + case POSITION_ASIS: + p = "ASIS"; + break; + default: + /* if not direct access, it must be + either REWIND, APPEND, or ASIS. + ASIS seems to be the best default */ + p = "ASIS"; + break; + } + cf_strcpy (ioparm.position, ioparm.position_len, p); } if (ioparm.action != NULL) diff --git a/libgfortran/io/rewind.c b/libgfortran/io/rewind.c index d5ea31e..f0b0e90 100644 --- a/libgfortran/io/rewind.c +++ b/libgfortran/io/rewind.c @@ -66,6 +66,8 @@ st_rewind (void) u->current_record = 0; test_endfile (u); } + /* update position for INQUIRE */ + u->flags.position = POSITION_REWIND; } library_end (); diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 73ae853..114ed92 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1363,6 +1363,9 @@ next_record (int done) else next_record_w (done); + /* keep position up to date for INQUIRE */ + current_unit->flags.position = POSITION_ASIS; + current_unit->current_record = 0; if (current_unit->flags.access == ACCESS_DIRECT) { |