This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran] patch for pr 17090-- runtime I/O error
- From: Bud Davis <bdavis9659 at comcast dot net>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Sun, 12 Sep 2004 20:13:06 -0500
- Subject: [gfortran] patch for pr 17090-- runtime I/O error
The list directed parser was confused by the trailing spaces in the
input:
160.9989 163.2918 164.4072 165.2249
^^^^^^
(spaces)
So, the fix is to add more special code to handle this situation !
Index: gcc/libgfortran/io/list_read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/list_read.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 list_read.c
*** gcc/libgfortran/io/list_read.c 31 Aug 2004 20:37:43 -0000 1.8
--- gcc/libgfortran/io/list_read.c 13 Sep 2004 01:04:26 -0000
*************** list_formatted_read (bt type, void *p, i
*** 1270,1276 ****
if (at_eol)
finish_separator ();
else
! eat_spaces ();
saved_type = BT_NULL;
repeat_count = 1;
--- 1270,1281 ----
if (at_eol)
finish_separator ();
else
! {
! eat_spaces ();
! /* trailing spaces prior to end of line */
! if (at_eol)
! finish_separator ();
! }
saved_type = BT_NULL;
repeat_count = 1;
2004-10-12 Bud Davis <bdavis9659@comcast.net>
PR fortran/17090
* io/list_read.c (list_formatted_read): Handle trailing spaces
at end of line.
and a test suite file, that fails before and passes after the patch is
applied:
! pr 17090 Runtime I/O error
! bdavis9659@comcast.net
! 10/12/2004
! list directed read with spaces between the last data item and the
! eoln cause missed data items.
! this is a libgfortran test case
implicit none
integer i,sum
real a(14)
data sum / 0 /
open(unit=9,status='SCRATCH')
write(9,*)1.0,2.0,3.0,4.0,' '
write(9,*)5.0,6.0,7.0,8.0,' '
write(9,*)9.0,10.0,11.0,12.0,13.0,14.0,' '
rewind(9)
read(9,*)a
do i = 1,14
sum = sum + a(i)
end do
if (sum.ne.105) call abort
end
tested on i686/gnu/linux (FC1) with no additional test suite failures.
--bud