diff mbox

[Fortran] PR56696 - Fix EOF detection for listed-directed real_read

Message ID 514DB593.5050401@net-b.de
State New
Headers show

Commit Message

Tobias Burnus March 23, 2013, 2 p.m. UTC
This patch fixes the 4.8/4.9 regression, reported by Keith Refson.

The patch which caused the regression (PR55818, Rev. 194809) allowed to 
list-direct read "1<EOF>" as real variable. Seemingly, the handling went 
to far to also affect reading a real from "<EOF>".

I am not completely sure whether the patch is correct, but I think it 
is. I tried character, complex and integer, but those are seemingly not 
affected from the regression.

OK for the trunk and the 4.8 branch?

Tobias

Comments

Janne Blomqvist March 23, 2013, 9:48 p.m. UTC | #1
On Sat, Mar 23, 2013 at 4:00 PM, Tobias Burnus <burnus@net-b.de> wrote:
> This patch fixes the 4.8/4.9 regression, reported by Keith Refson.
>
> The patch which caused the regression (PR55818, Rev. 194809) allowed to
> list-direct read "1<EOF>" as real variable. Seemingly, the handling went to
> far to also affect reading a real from "<EOF>".
>
> I am not completely sure whether the patch is correct, but I think it is. I
> tried character, complex and integer, but those are seemingly not affected
> from the regression.
>
> OK for the trunk and the 4.8 branch?

Ok, thanks for the patch, and to Keith as well for reporting and the testcase.
diff mbox

Patch

2013-03-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56696
	* io/list_read.c (read_real): Fix EOF diagnostic.

2013-03-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56696
	* gfortran.dg/eof_5.f90: New.

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index aa7c8c0..ec45570 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1423,27 +1423,26 @@  read_real (st_parameter_dt *dtp, void * dest, int length)
       push_char (dtp, c);
       break;
 
     case '.':
       push_char (dtp, c);
       seen_dp = 1;
       break;
 
     case '+':
     case '-':
       goto got_sign;
 
     CASE_SEPARATORS:
-    case EOF:
       unget_char (dtp, c);		/* Single null.  */
       eat_separator (dtp);
       return;
 
     case 'i':
     case 'I':
     case 'n':
     case 'N':
       goto inf_nan;
 
     default:
       goto bad_real;
     }

--- /dev/null	2013-03-23 13:45:03.324112203 +0100
+++ gcc/gcc/testsuite/gfortran.dg/eof_5.f90	2013-03-23 14:55:47.783990895 +0100
@@ -0,0 +1,21 @@ 
+! { dg-do run }
+!
+! PR fortran/56696
+!
+! Contributed by Keith Refson
+!
+
+program iotest
+   character(len=258) :: inp = ' 1.0 1.0 1.0'
+   character(len=7) :: inp2 = '1 2 3 4'
+   integer :: ios
+   real :: a1, a2, a3, a4
+
+   read(inp2,*,iostat=ios) a1, a2, a3, a4
+   if (ios /= 0) call abort ()
+
+   read(inp,*,iostat=ios) a1, a2, a3, a4
+   if (ios == 0) call abort ()
+!   write(*,*) 'IOSTAT=',ios
+end program iotest
+