diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-22 19:09:11 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-22 19:09:11 +0000 |
commit | f23886abacad045dae2b04895dddea4aaec2db1c (patch) | |
tree | ddee91463b1c5b5ef8aaf5e8a3581d490478bed9 /libgfortran/io/file_pos.c | |
parent | e88209700fe9871b7e94de36a676bdbd86d64a36 (diff) | |
download | ppe42-gcc-f23886abacad045dae2b04895dddea4aaec2db1c.tar.gz ppe42-gcc-f23886abacad045dae2b04895dddea4aaec2db1c.zip |
2006-03-22 Thomas Koenig <Thomas.Koenig@onlien.de>
PR fortran/19303
* gfortran.h (gfc_option_t): Add record_marker.
* lang.opt: Add -frecord-marker=4 and -frecord-marker=8.
* trans-decl.c: Add gfor_fndecl_set_record_marker.
(gfc_build_builtin_function_decls): Set
gfor_fndecl_set_record_marker.
(gfc_generate_function_code): If we are in the main program
and -frecord-marker was provided, call set_record_marker.
* options.c (gfc_handle_option): Add handling for
-frecord-marker=4 and -frecord-marker=8.
* invoke.texi: Document -frecord-marker.
2006-03-22 Thomas Koenig <Thomas.Koenig@onlien.de>
PR fortran/19303
* libgfortran.h (compile_options_t): Add record_marker.
* runtime/compile_options.c (set_record_marker):
New function.
* io/open.c: If we have four-byte record markers, use
GFC_INTEGER_4_HUGE as default record length.
* io/file_pos.c (unformatted_backspace): Handle
different size record markers.
* io/transfer.c (us_read): Likewise.
(us_write): Likewise.
(next_record_r): Likewise.
(write_us_marker): Likewise.
(next_record_w): Likewise.
2006-03-22 Thomas Koenig <Thomas.Koenig@online.de>
PR fortran/19303
* gfortran.dg/record_marker_1.f90: New test case.
* gfortran.dg/record_marker_2.f: New test case.
* gfortran.dg/record_marker_3.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io/file_pos.c')
-rw-r--r-- | libgfortran/io/file_pos.c | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c index 5d247d9c6b3..fd6333a667e 100644 --- a/libgfortran/io/file_pos.c +++ b/libgfortran/io/file_pos.c @@ -104,21 +104,71 @@ static void unformatted_backspace (st_parameter_filepos *fpp, gfc_unit *u) { gfc_offset m, new; - int length; + GFC_INTEGER_4 m4; + GFC_INTEGER_8 m8; + int length, length_read; char *p; - length = sizeof (gfc_offset); + if (compile_options.record_marker == 0) + length = sizeof (gfc_offset); + else + length = compile_options.record_marker; + + length_read = length; - p = salloc_r_at (u->s, &length, + p = salloc_r_at (u->s, &length_read, file_position (u->s) - length); - if (p == NULL) + if (p == NULL || length_read != length) goto io_error; /* Only CONVERT_NATIVE and CONVERT_SWAP are valid here. */ if (u->flags.convert == CONVERT_NATIVE) - memcpy (&m, p, sizeof (gfc_offset)); + { + switch (compile_options.record_marker) + { + case 0: + memcpy (&m, p, sizeof(gfc_offset)); + break; + + case sizeof(GFC_INTEGER_4): + memcpy (&m4, p, sizeof (m4)); + m = m4; + break; + + case sizeof(GFC_INTEGER_8): + memcpy (&m8, p, sizeof (m8)); + m = m8; + break; + + default: + runtime_error ("Illegal value for record marker"); + break; + } + } else - reverse_memcpy (&m, p, sizeof (gfc_offset)); + { + switch (compile_options.record_marker) + { + case 0: + reverse_memcpy (&m, p, sizeof(gfc_offset)); + break; + + case sizeof(GFC_INTEGER_4): + reverse_memcpy (&m4, p, sizeof (m4)); + m = m4; + break; + + case sizeof(GFC_INTEGER_8): + reverse_memcpy (&m8, p, sizeof (m8)); + m = m8; + break; + + default: + runtime_error ("Illegal value for record marker"); + break; + } + + } if ((new = file_position (u->s) - m - 2*length) < 0) new = 0; |