From: Jerry DeLisle <jvdelisle@charter.net>
To: gfortran <fortran@gcc.gnu.org>
Subject: [patch, libgfortran] [4.9/5/6/7 Regression] incorrect reading of values from file on Windows
Date: Mon, 18 Apr 2016 22:16:00 -0000 [thread overview]
Message-ID: <57155CC5.7060405@charter.net> (raw)
[-- 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
reply other threads:[~2016-04-18 22:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57155CC5.7060405@charter.net \
--to=jvdelisle@charter.net \
--cc=fortran@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).