mirror of git://gcc.gnu.org/git/gcc.git
re PR libfortran/26661 (Sequential formatted read goes too far)
2006-03-25 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/26661 * io/io.h: Add read_sf so it can be used by read_x. * io/transfer.c (read_sf): Pass no_error flag to read_sf. Use it to break out rather than error on EOF or EOR conditions. (read_block): Update call to read_sf. (read_block_direct): Ditto. * io/read.c (read_x): Use the modified read_sf instead of read_block. From-SVN: r112390
This commit is contained in:
parent
44f808b02d
commit
0853054e96
|
|
@ -1,3 +1,13 @@
|
||||||
|
2006-03-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libgfortran/26661
|
||||||
|
* io/io.h: Add read_sf so it can be used by read_x.
|
||||||
|
* io/transfer.c (read_sf): Pass no_error flag to read_sf. Use it to
|
||||||
|
break out rather than error on EOF or EOR conditions.
|
||||||
|
(read_block): Update call to read_sf.
|
||||||
|
(read_block_direct): Ditto.
|
||||||
|
* io/read.c (read_x): Use the modified read_sf instead of read_block.
|
||||||
|
|
||||||
2006-03-25 Thomas Koenig <Thomas.Koenig@online.de>
|
2006-03-25 Thomas Koenig <Thomas.Koenig@online.de>
|
||||||
|
|
||||||
PR libfortran/26735
|
PR libfortran/26735
|
||||||
|
|
|
||||||
|
|
@ -743,6 +743,9 @@ internal_proto(type_name);
|
||||||
extern void *read_block (st_parameter_dt *, int *);
|
extern void *read_block (st_parameter_dt *, int *);
|
||||||
internal_proto(read_block);
|
internal_proto(read_block);
|
||||||
|
|
||||||
|
extern char *read_sf (st_parameter_dt *, int *, int);
|
||||||
|
internal_proto(read_sf);
|
||||||
|
|
||||||
extern void *write_block (st_parameter_dt *, int);
|
extern void *write_block (st_parameter_dt *, int);
|
||||||
internal_proto(write_block);
|
internal_proto(write_block);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -847,7 +847,7 @@ read_x (st_parameter_dt *dtp, int n)
|
||||||
|
|
||||||
dtp->u.p.sf_read_comma = 0;
|
dtp->u.p.sf_read_comma = 0;
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
read_block (dtp, &n);
|
read_sf (dtp, &n, 1);
|
||||||
dtp->u.p.sf_read_comma = 1;
|
dtp->u.p.sf_read_comma = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ current_mode (st_parameter_dt *dtp)
|
||||||
For larger allocations, we are forced to allocate memory on the
|
For larger allocations, we are forced to allocate memory on the
|
||||||
heap. Hopefully this won't happen very often. */
|
heap. Hopefully this won't happen very often. */
|
||||||
|
|
||||||
static char *
|
char *
|
||||||
read_sf (st_parameter_dt *dtp, int *length)
|
read_sf (st_parameter_dt *dtp, int *length, int no_error)
|
||||||
{
|
{
|
||||||
char *base, *p, *q;
|
char *base, *p, *q;
|
||||||
int n, readlen, crlf;
|
int n, readlen, crlf;
|
||||||
|
|
@ -171,6 +171,8 @@ read_sf (st_parameter_dt *dtp, int *length)
|
||||||
EOR below. */
|
EOR below. */
|
||||||
if (readlen < 1 && n == 0)
|
if (readlen < 1 && n == 0)
|
||||||
{
|
{
|
||||||
|
if (no_error)
|
||||||
|
break;
|
||||||
generate_error (&dtp->common, ERROR_END, NULL);
|
generate_error (&dtp->common, ERROR_END, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +204,8 @@ read_sf (st_parameter_dt *dtp, int *length)
|
||||||
so we can just continue with a short read. */
|
so we can just continue with a short read. */
|
||||||
if (dtp->u.p.current_unit->flags.pad == PAD_NO)
|
if (dtp->u.p.current_unit->flags.pad == PAD_NO)
|
||||||
{
|
{
|
||||||
|
if (no_error)
|
||||||
|
break;
|
||||||
generate_error (&dtp->common, ERROR_EOR, NULL);
|
generate_error (&dtp->common, ERROR_EOR, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +269,7 @@ read_block (st_parameter_dt *dtp, int *length)
|
||||||
|
|
||||||
if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED &&
|
if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED &&
|
||||||
dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
||||||
return read_sf (dtp, length); /* Special case. */
|
return read_sf (dtp, length, 0); /* Special case. */
|
||||||
|
|
||||||
dtp->u.p.current_unit->bytes_left -= *length;
|
dtp->u.p.current_unit->bytes_left -= *length;
|
||||||
|
|
||||||
|
|
@ -315,7 +319,7 @@ read_block_direct (st_parameter_dt *dtp, void *buf, size_t *nbytes)
|
||||||
dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
length = (int *) nbytes;
|
length = (int *) nbytes;
|
||||||
data = read_sf (dtp, length); /* Special case. */
|
data = read_sf (dtp, length, 0); /* Special case. */
|
||||||
memcpy (buf, data, (size_t) *length);
|
memcpy (buf, data, (size_t) *length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue