* [patch, libgfortran] [4.9/5/6/7 Regression] incorrect reading of values from file on Windows
@ 2016-04-18 22:16 Jerry DeLisle
0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2016-04-18 22:16 UTC (permalink / raw)
To: gfortran
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
Hi all,
The attached simple patch fixes the regression. The regression results in
failure to read correctly and not know it. This is due to the unhandled '/r'
being interpreted as a null value.
Regression tested on x86-64-linux. Though originally reported on Windows, it
does effect linux when a user uses a CR-LF combination.
OK for trunk and then backports as I can? If I hear nothing I will commit
tomorrow as simple patch.
New test case attaced.
Regards,
Jerry
2016-04-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/70684
* io/list_read (check_buffers): Add '\r' to check for end of line.
factor.
[-- Attachment #2: pr70684.diff --]
[-- Type: text/x-patch, Size: 363 bytes --]
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index e24b3922..b8e174c5 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -197,7 +197,7 @@ check_buffers (st_parameter_dt *dtp)
}
done:
- dtp->u.p.at_eol = (c == '\n' || c == EOF);
+ dtp->u.p.at_eol = (c == '\n' || c == '\r' || c == EOF);
return c;
}
[-- Attachment #3: list_read_14.f90 --]
[-- Type: text/x-fortran, Size: 826 bytes --]
! { dg-do run }
! PR70684 incorrect reading of values from file on Windows
program test
implicit none
integer,parameter :: isize=12
integer,parameter :: funit=12
integer :: i
character(1), parameter :: cr=char(13)
double precision, dimension(isize) :: a, res
res= (/ 1.0000000000000000, 2.0000000000000000, 3.0000000000000000, &
4.0000000000000000, 5.0000000000000000, 6.0000000000000000, &
7.0000000000000000, 8.0000000000000000, 9.0000000000000000, &
10.000000000000000, 11.000000000000000, 12.000000000000000 /)
do i=1,isize
a(i)=dble(i)
enddo
open(funit,status="scratch")
write(funit,'(1x,6(f25.20,'',''),a)') (a(i),i=1,6), cr
write(funit,'(1x,6(f25.20,'',''),a)') (a(i),i=7,12), cr
rewind(funit)
a=0d0
read(funit,*) (a(i),i=1,isize)
close(funit)
if (any(a /= res)) call abort
end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-18 22:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-18 22:16 [patch, libgfortran] [4.9/5/6/7 Regression] incorrect reading of values from file on Windows Jerry DeLisle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).