From b1a807057ecb701601141285c011ef637b97f3b7 Mon Sep 17 00:00:00 2001 From: Bud Davis Date: Sat, 22 Jan 2005 03:51:12 +0000 Subject: re PR libfortran/19314 (inquire(position=) segfaults at runtime) 2004-01-22 Bud Davis 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 --- libgfortran/io/inquire.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'libgfortran/io/inquire.c') 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) -- cgit v1.1