Commit 835681c8 by Jerry DeLisle Committed by Jerry DeLisle

re PR libfortran/24489 (read_block wrong execution order)

2005-10-23  Jerry DeLisle  <jvdelisle@verizon.net>

        PR libgfortran/24489
        * io/transfer.c (read_block): Change the order of execution to not read
        past end-of-record.
        (read_block_direct): Same change.

From-SVN: r105840
parent 9da73725
2005-10-23 Jerry DeLisle <jvdelisle@verizon.net>
PR libgfortran/24489
* io/transfer.c (read_block): Change the order of execution to not read
past end-of-record.
(read_block_direct): Same change.
2005-10-23 Francois-Xavier Coudert <coudert@clipper.ens.fr> 2005-10-23 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/23272 PR libfortran/23272
......
...@@ -248,10 +248,6 @@ read_block (int *length) ...@@ -248,10 +248,6 @@ read_block (int *length)
char *source; char *source;
int nread; int nread;
if (current_unit->flags.form == FORM_FORMATTED &&
current_unit->flags.access == ACCESS_SEQUENTIAL)
return read_sf (length); /* Special case. */
if (current_unit->bytes_left < *length) if (current_unit->bytes_left < *length)
{ {
if (current_unit->flags.pad == PAD_NO) if (current_unit->flags.pad == PAD_NO)
...@@ -263,6 +259,10 @@ read_block (int *length) ...@@ -263,6 +259,10 @@ read_block (int *length)
*length = current_unit->bytes_left; *length = current_unit->bytes_left;
} }
if (current_unit->flags.form == FORM_FORMATTED &&
current_unit->flags.access == ACCESS_SEQUENTIAL)
return read_sf (length); /* Special case. */
current_unit->bytes_left -= *length; current_unit->bytes_left -= *length;
nread = *length; nread = *length;
...@@ -295,15 +295,6 @@ read_block_direct (void * buf, size_t * nbytes) ...@@ -295,15 +295,6 @@ read_block_direct (void * buf, size_t * nbytes)
void *data; void *data;
size_t nread; size_t nread;
if (current_unit->flags.form == FORM_FORMATTED &&
current_unit->flags.access == ACCESS_SEQUENTIAL)
{
length = (int*) nbytes;
data = read_sf (length); /* Special case. */
memcpy (buf, data, (size_t) *length);
return;
}
if (current_unit->bytes_left < *nbytes) if (current_unit->bytes_left < *nbytes)
{ {
if (current_unit->flags.pad == PAD_NO) if (current_unit->flags.pad == PAD_NO)
...@@ -315,6 +306,15 @@ read_block_direct (void * buf, size_t * nbytes) ...@@ -315,6 +306,15 @@ read_block_direct (void * buf, size_t * nbytes)
*nbytes = current_unit->bytes_left; *nbytes = current_unit->bytes_left;
} }
if (current_unit->flags.form == FORM_FORMATTED &&
current_unit->flags.access == ACCESS_SEQUENTIAL)
{
length = (int*) nbytes;
data = read_sf (length); /* Special case. */
memcpy (buf, data, (size_t) *length);
return;
}
current_unit->bytes_left -= *nbytes; current_unit->bytes_left -= *nbytes;
nread = *nbytes; nread = *nbytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment