re PR fortran/41328 (bad iostat when reading DOS file in a character array (non-advancing))
2009-09-12 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/41328 * io/transfer.c (read_sf): Adjust fbuf position and do proper fbuf reads to traverse CR, CR-LF, and LF style line ends. From-SVN: r151665
This commit is contained in:
parent
efcc709b4f
commit
ee3eb6a416
@ -1,3 +1,9 @@
|
|||||||
|
2009-09-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libgfortran/41328
|
||||||
|
* io/transfer.c (read_sf): Adjust fbuf position and do proper
|
||||||
|
fbuf reads to traverse CR, CR-LF, and LF style line ends.
|
||||||
|
|
||||||
2009-09-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
2009-09-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
PR libgfortran/41219
|
PR libgfortran/41219
|
||||||
|
@ -232,7 +232,9 @@ read_sf (st_parameter_dt *dtp, int * length, int no_error)
|
|||||||
|
|
||||||
if (q == '\n' || q == '\r')
|
if (q == '\n' || q == '\r')
|
||||||
{
|
{
|
||||||
/* Unexpected end of line. */
|
/* Unexpected end of line. Set the position. */
|
||||||
|
fbuf_seek (dtp->u.p.current_unit, n + 1 ,SEEK_CUR);
|
||||||
|
dtp->u.p.sf_seen_eor = 1;
|
||||||
|
|
||||||
/* If we see an EOR during non-advancing I/O, we need to skip
|
/* If we see an EOR during non-advancing I/O, we need to skip
|
||||||
the rest of the I/O statement. Set the corresponding flag. */
|
the rest of the I/O statement. Set the corresponding flag. */
|
||||||
@ -242,11 +244,16 @@ read_sf (st_parameter_dt *dtp, int * length, int no_error)
|
|||||||
/* If we encounter a CR, it might be a CRLF. */
|
/* If we encounter a CR, it might be a CRLF. */
|
||||||
if (q == '\r') /* Probably a CRLF */
|
if (q == '\r') /* Probably a CRLF */
|
||||||
{
|
{
|
||||||
if (n < *length && *(p + 1) == '\n')
|
/* See if there is an LF. Use fbuf_read rather then fbuf_getc so
|
||||||
dtp->u.p.sf_seen_eor = 2;
|
the position is not advanced unless it really is an LF. */
|
||||||
|
int readlen = 1;
|
||||||
|
p = fbuf_read (dtp->u.p.current_unit, &readlen);
|
||||||
|
if (*p == '\n' && readlen == 1)
|
||||||
|
{
|
||||||
|
dtp->u.p.sf_seen_eor = 2;
|
||||||
|
fbuf_seek (dtp->u.p.current_unit, 1 ,SEEK_CUR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
dtp->u.p.sf_seen_eor = 1;
|
|
||||||
|
|
||||||
/* Without padding, terminate the I/O statement without assigning
|
/* Without padding, terminate the I/O statement without assigning
|
||||||
the value. With padding, the value still needs to be assigned,
|
the value. With padding, the value still needs to be assigned,
|
||||||
@ -260,7 +267,7 @@ read_sf (st_parameter_dt *dtp, int * length, int no_error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*length = n;
|
*length = n;
|
||||||
break;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Short circuit the read if a comma is found during numeric input.
|
/* Short circuit the read if a comma is found during numeric input.
|
||||||
The flag is set to zero during character reads so that commas in
|
The flag is set to zero during character reads so that commas in
|
||||||
@ -274,13 +281,11 @@ read_sf (st_parameter_dt *dtp, int * length, int no_error)
|
|||||||
*length = n;
|
*length = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fbuf_seek (dtp->u.p.current_unit, n + dtp->u.p.sf_seen_eor + seen_comma,
|
fbuf_seek (dtp->u.p.current_unit, n + seen_comma, SEEK_CUR);
|
||||||
SEEK_CUR);
|
|
||||||
|
|
||||||
/* A short read implies we hit EOF, unless we hit EOR, a comma, or
|
/* A short read implies we hit EOF, unless we hit EOR, a comma, or
|
||||||
some other stuff. Set the relevant flags. */
|
some other stuff. Set the relevant flags. */
|
||||||
|
Loading…
Reference in New Issue
Block a user