diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-01-20 06:33:49 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-01-20 06:33:49 +0000 |
commit | 17c2c96cdcde260adce0c535e501f08371f5990e (patch) | |
tree | dedbc43dcc55e290acd9a5c365727c56e2e2ac08 /libgfortran/io/inquire.c | |
parent | e08c673e0571253b8624c8c5d9a8886109c1adb2 (diff) | |
download | gcc-17c2c96cdcde260adce0c535e501f08371f5990e.zip gcc-17c2c96cdcde260adce0c535e501f08371f5990e.tar.gz gcc-17c2c96cdcde260adce0c535e501f08371f5990e.tar.bz2 |
inquire.c (inquire_via_unit): If a unit is opened...
2008-01-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* io/inquire.c (inquire_via_unit): If a unit is opened, return values
according to the open action for DIRECT, FORMATTED, and UNFORMATTED.
(inquire_via_filename): Return "UNKNOWN" for SEQUENTIAL, DIRECT,
FORAMATTED, and UNFORMATTED inquiries.
* io/unix.c (inquire_sequential): Return "UNKNOWN" when appropriate
for files that are not opened. (inquire_direct): Same.
(inquire_formatted): Same.
From-SVN: r131672
Diffstat (limited to 'libgfortran/io/inquire.c')
-rw-r--r-- | libgfortran/io/inquire.c | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c index 493b223..ec46285 100644 --- a/libgfortran/io/inquire.c +++ b/libgfortran/io/inquire.c @@ -99,21 +99,39 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u) if (u == NULL) p = inquire_sequential (NULL, 0); else - { - /* disallow an open direct access file to be accessed sequentially */ - if (u->flags.access == ACCESS_DIRECT) - p = "NO"; - else - p = inquire_sequential (u->file, u->file_len); - } + switch (u->flags.access) + { + case ACCESS_DIRECT: + case ACCESS_STREAM: + p = "NO"; + break; + case ACCESS_SEQUENTIAL: + p = "YES"; + break; + default: + internal_error (&iqp->common, "inquire_via_unit(): Bad access"); + } cf_strcpy (iqp->sequential, iqp->sequential_len, p); } if ((cf & IOPARM_INQUIRE_HAS_DIRECT) != 0) { - p = (u == NULL) ? inquire_direct (NULL, 0) : - inquire_direct (u->file, u->file_len); + if (u == NULL) + p = inquire_direct (NULL, 0); + else + switch (u->flags.access) + { + case ACCESS_SEQUENTIAL: + case ACCESS_STREAM: + p = "NO"; + break; + case ACCESS_DIRECT: + p = "YES"; + break; + default: + internal_error (&iqp->common, "inquire_via_unit(): Bad access"); + } cf_strcpy (iqp->direct, iqp->direct_len, p); } @@ -140,16 +158,40 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u) if ((cf & IOPARM_INQUIRE_HAS_FORMATTED) != 0) { - p = (u == NULL) ? inquire_formatted (NULL, 0) : - inquire_formatted (u->file, u->file_len); + if (u == NULL) + p = inquire_formatted (NULL, 0); + else + switch (u->flags.form) + { + case FORM_FORMATTED: + p = "YES"; + break; + case FORM_UNFORMATTED: + p = "NO"; + break; + default: + internal_error (&iqp->common, "inquire_via_unit(): Bad form"); + } cf_strcpy (iqp->formatted, iqp->formatted_len, p); } if ((cf & IOPARM_INQUIRE_HAS_UNFORMATTED) != 0) { - p = (u == NULL) ? inquire_unformatted (NULL, 0) : - inquire_unformatted (u->file, u->file_len); + if (u == NULL) + p = inquire_unformatted (NULL, 0); + else + switch (u->flags.form) + { + case FORM_FORMATTED: + p = "NO"; + break; + case FORM_UNFORMATTED: + p = "YES"; + break; + default: + internal_error (&iqp->common, "inquire_via_unit(): Bad form"); + } cf_strcpy (iqp->unformatted, iqp->unformatted_len, p); } @@ -359,13 +401,13 @@ inquire_via_filename (st_parameter_inquire *iqp) if ((cf & IOPARM_INQUIRE_HAS_SEQUENTIAL) != 0) { - p = inquire_sequential (iqp->file, iqp->file_len); + p = "UNKNOWN"; cf_strcpy (iqp->sequential, iqp->sequential_len, p); } if ((cf & IOPARM_INQUIRE_HAS_DIRECT) != 0) { - p = inquire_direct (iqp->file, iqp->file_len); + p = "UNKNOWN"; cf_strcpy (iqp->direct, iqp->direct_len, p); } @@ -374,13 +416,13 @@ inquire_via_filename (st_parameter_inquire *iqp) if ((cf & IOPARM_INQUIRE_HAS_FORMATTED) != 0) { - p = inquire_formatted (iqp->file, iqp->file_len); + p = "UNKNOWN"; cf_strcpy (iqp->formatted, iqp->formatted_len, p); } if ((cf & IOPARM_INQUIRE_HAS_UNFORMATTED) != 0) { - p = inquire_unformatted (iqp->file, iqp->file_len); + p = "UNKNOWN"; cf_strcpy (iqp->unformatted, iqp->unformatted_len, p); } |