diff options
author | Thomas Koenig <Thomas.Koenig@online.de> | 2006-02-06 20:12:44 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2006-02-06 20:12:44 +0000 |
commit | eaa90d25da32a3329c9e434f8117c9122de1fa80 (patch) | |
tree | 26ecd24fc3063b5ecd6f0ba237736b4549d61fd5 /libgfortran/io | |
parent | 431ef78e8e7568263dbd2b56d55460c5b0b45c6e (diff) | |
download | gcc-eaa90d25da32a3329c9e434f8117c9122de1fa80.zip gcc-eaa90d25da32a3329c9e434f8117c9122de1fa80.tar.gz gcc-eaa90d25da32a3329c9e434f8117c9122de1fa80.tar.bz2 |
re PR fortran/23815 (Add -byteswapio flag)
2005-02-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23815
* gfortran.texi: Document the GFORTRAN_CONVERT_UNIT environment
variable.
* invoke.texi: Mention the "Runtime" chapter.
Document the -fconvert= option.
* gfortran.h: Add options_convert.
* lang.opt: Add fconvert=little-endian, fconvert=big-endian,
fconvert=native and fconvert=swap.
* trans-decl.c (top level): Add gfor_fndecl_set_convert.
(gfc_build_builtin_function_decls): Set gfor_fndecl_set_convert.
(gfc_generate_function_code): If -fconvert was specified,
and this is the main program, add a call to set_convert().
* options.c: Handle the -fconvert options.
2005-02-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23815
* runtime/environ.c (init_unformatted): Add GFORTRAN_CONVERT_UNIT
environment variable.
(top level): Add defines, type and static variables for
GFORTRAN_CONVERT_UNIT handling.
(search_unit): New function.
(match_word): New function.
(match_integer): New function.
(next_token): New function.
(push_token): New function.
(mark_single): New function.
(mark_range): New funciton.
(do_parse): New function.
(init_unformatted): New function.
(get_unformatted_convert): New function.
* runtime/compile_options.c: Add set_convert().
* libgfortran.h: Add convert to compile_options_t.
* io/open.c (st_open): Call get_unformatted_convert to get
unit default; if CONVERT_NONE is returned, check for
the presence of a CONVERT specifier and use it.
As default, use compile_options.convert.
* io/io.h (top level): Add CONVERT_NONE to unit_convert, to signal
"nothing has been set".
(top level): Add prototype for get_unformatted_convert.
2005-02-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23815
* unf_io_convert_4.f90: New test.
From-SVN: r110664
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/io.h | 7 | ||||
-rw-r--r-- | libgfortran/io/open.c | 64 |
2 files changed, 43 insertions, 28 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index e364171..31b4927 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -207,7 +207,7 @@ typedef enum unit_mode; typedef enum -{ CONVERT_NATIVE, CONVERT_SWAP, CONVERT_BIG, CONVERT_LITTLE } +{ CONVERT_NONE=-1, CONVERT_NATIVE, CONVERT_SWAP, CONVERT_BIG, CONVERT_LITTLE } unit_convert; #define CHARACTER1(name) \ @@ -884,3 +884,8 @@ dec_waiting_unlocked (gfc_unit *u) } #endif + +/* ../runtime/environ.c This is here because we return unit_convert. */ + +unit_convert get_unformatted_convert (int); +internal_proto(get_unformatted_convert); diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 3dc2b11..1459f8f 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -502,6 +502,7 @@ st_open (st_parameter_open *opp) unit_flags flags; gfc_unit *u = NULL; GFC_INTEGER_4 cf = opp->common.flags; + unit_convert conv; library_start (&opp->common); @@ -539,35 +540,44 @@ st_open (st_parameter_open *opp) find_option (&opp->common, opp->status, opp->status_len, status_opt, "Bad STATUS parameter in OPEN statement"); - if (cf & IOPARM_OPEN_HAS_CONVERT) + /* First, we check wether the convert flag has been set via environment + variable. This overrides the convert tag in the open statement. */ + + conv = get_unformatted_convert (opp->common.unit); + + if (conv == CONVERT_NONE) { - unit_convert conv; - conv = find_option (&opp->common, opp->convert, opp->convert_len, - convert_opt, "Bad CONVERT parameter in OPEN statement"); - /* We use l8_to_l4_offset, which is 0 on little-endian machines - and 1 on big-endian machines. */ - switch (conv) - { - case CONVERT_NATIVE: - case CONVERT_SWAP: - break; - - case CONVERT_BIG: - conv = l8_to_l4_offset ? CONVERT_NATIVE : CONVERT_SWAP; - break; - - case CONVERT_LITTLE: - conv = l8_to_l4_offset ? CONVERT_SWAP : CONVERT_NATIVE; - break; - - default: - internal_error (&opp->common, "Illegal value for CONVERT"); - break; - } - flags.convert = conv; + /* Nothing has been set by environment variable, check the convert tag. */ + if (cf & IOPARM_OPEN_HAS_CONVERT) + conv = find_option (&opp->common, opp->convert, opp->convert_len, + convert_opt, + "Bad CONVERT parameter in OPEN statement"); + else + conv = compile_options.convert; } - else - flags.convert = CONVERT_NATIVE; + + /* We use l8_to_l4_offset, which is 0 on little-endian machines + and 1 on big-endian machines. */ + switch (conv) + { + case CONVERT_NATIVE: + case CONVERT_SWAP: + break; + + case CONVERT_BIG: + conv = l8_to_l4_offset ? CONVERT_NATIVE : CONVERT_SWAP; + break; + + case CONVERT_LITTLE: + conv = l8_to_l4_offset ? CONVERT_SWAP : CONVERT_NATIVE; + break; + + default: + internal_error (&opp->common, "Illegal value for CONVERT"); + break; + } + + flags.convert = conv; if (opp->common.unit < 0) generate_error (&opp->common, ERROR_BAD_OPTION, |