From 7c0de7535345f7d271c89d5121c7edfabd1e79f7 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 29 Sep 2012 17:38:46 +0000 Subject: re PR fortran/52724 (Internal read with character(kind=4) data) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2012-09-29 Thomas König PR fortran/52724 * list_read.c (next_char): Handle kind=4 characters. * unix.c (open_internal4): Correct lenth of internal file. 2012-09-29 Thomas König PR fortran/52724 * gfortran.dg/internal_readwrite_3.f90: New test. From-SVN: r191854 --- libgfortran/io/list_read.c | 13 ++++++++++--- libgfortran/io/unix.c | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'libgfortran/io') diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 9d301d6..403e719 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -199,9 +199,16 @@ next_char (st_parameter_dt *dtp) if (is_internal_unit (dtp)) { - char cc; - length = sread (dtp->u.p.current_unit->s, &cc, 1); - c = cc; + /* Check for kind=4 internal unit. */ + if (dtp->common.unit) + length = sread (dtp->u.p.current_unit->s, &c, sizeof (gfc_char4_t)); + else + { + char cc; + length = sread (dtp->u.p.current_unit->s, &cc, 1); + c = cc; + } + if (length < 0) { generate_error (&dtp->common, LIBERROR_OS, NULL); diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 1a9faea..805d4bb 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -959,7 +959,7 @@ open_internal4 (char *base, int length, gfc_offset offset) s->buffer = base; s->buffer_offset = offset; - s->active = s->file_length = length; + s->active = s->file_length = length * sizeof (gfc_char4_t); s->st.vptr = &mem4_vtable; -- cgit v1.1