public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows
@ 2013-06-17 8:52 burnus at gcc dot gnu.org
2013-06-17 8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-17 8:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
Bug ID: 57633
Summary: I/O: Problem with formatted read: reading an
incomplete record under Windows
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jb at gcc dot gnu.org, jvdelisle at gcc dot gnu.org
The following seems to be a Windows only problem as I cannot reproduce it under
Linux. See
https://groups.google.com/forum/?fromgroups#!topic/comp.lang.fortran/mtERtiPKqu0
testcase.txt file:
line1,1,
line2
Produces the following output
line1 1
0
Expected:
line1 1
line2 5
Comment by BAF:
------------------------------------------------------------
"I can confirm these result with the exact same program under mingw32
gfortran 4.8.0 20130302 (experimental) [trunk revision 196403].
To eliminate the concern about the end of line/record character for the
second line of the file, I added a third line, so that the data file is now
line1,1,
line2
line3
The output remains the same, i.e.
line1 1
0
Very strange. If I change the second read statement to be be
read(11,*)s1
(i.e., change the formatted read to a list directed form), the output
changes to what would be expected in either case
line1 1
line2 5
Seems like the "bug" is related to the formatted read.
------------------------------------------------------------
Test program:
program teststuff
implicit none
integer::a
character(len=10)::s1
open(11,file="testcase.txt")
read(11,*)s1,a
write(*,*)s1,a
read(11,"(a)")s1
write(*,*)s1, len_trim(s1)
end program teststuff
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
@ 2013-06-17 8:55 ` burnus at gcc dot gnu.org
2013-06-17 9:20 ` dominiq at lps dot ens.fr
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-17 8:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|I/O: Problem with formatted |I/O: Problem with formatted
|read: reading an incomplete |read: reading CR-LF files
|record under Windows |(\r\n)
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
I can reproduce the issue using the following test file:
printf "line1,1,\r\nline2\r\nline3" > testcase.txt
It works if one has \n instead of \r\n
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
2013-06-17 8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
@ 2013-06-17 9:20 ` dominiq at lps dot ens.fr
2013-06-18 1:38 ` jvdelisle at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-17 9:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-06-17
Ever confirmed|0 |1
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
2013-06-17 8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
2013-06-17 9:20 ` dominiq at lps dot ens.fr
@ 2013-06-18 1:38 ` jvdelisle at gcc dot gnu.org
2013-06-20 8:44 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-06-18 1:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
We need to audit all places where '\n' is used and make sure we are taking care
of the '\r' properly in read.c , etc.
Then review what were are doing when we get a premature end of record.
Maybe we are skipping a code path related to read buffers, like fbuf.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2013-06-18 1:38 ` jvdelisle at gcc dot gnu.org
@ 2013-06-20 8:44 ` burnus at gcc dot gnu.org
2013-06-20 9:12 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-20 8:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem seems to be
2012 finish_list_read (st_parameter_dt *dtp)
...
2019 if (dtp->u.p.at_eol)
2020 {
2021 dtp->u.p.at_eol = 0;
2022 return;
2023 }
2024
2025 err = eat_line (dtp);
as at_eol == 1.
Draft patch:
The first hunk solves the actual problem of this PR.
The second one handles the case "abc\rdef" where \r is not followed by \n and
does not start a new record. (Note: gfortran does not handle pre-MacOS X line
breaks of the form "\r", only Windows \r\n and Unix (Linux, MacOS X,...) "\n".)
- that's unrelated to this PR.
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -244,3 +244,3 @@ next_char (st_parameter_dt *dtp)
done:
- dtp->u.p.at_eol = (c == '\n' || c == '\r' || c == EOF);
+ dtp->u.p.at_eol = (c == '\n' || c == EOF);
return c;
@@ -336,3 +336,2 @@ eat_separator (st_parameter_dt *dtp)
case '\r':
- dtp->u.p.at_eol = 1;
if ((n = next_char(dtp)) == EOF)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2013-06-20 8:44 ` burnus at gcc dot gnu.org
@ 2013-06-20 9:12 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-20 9:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: http://gcc.gnu.org/ml/fortran/2013-06/msg00109.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2013-06-20 9:12 ` burnus at gcc dot gnu.org
@ 2013-06-20 10:55 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-20 10:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on the 4.9 trunk.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n)
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2013-06-20 10:55 ` burnus at gcc dot gnu.org
@ 2013-06-20 10:55 ` burnus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-20 10:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Author: burnus
Date: Thu Jun 20 10:55:03 2013
New Revision: 200238
URL: http://gcc.gnu.org/viewcvs?rev=200238&root=gcc&view=rev
Log:
2013-06-20 Tobias Burnus <burnus@net-b.de>
PR fortran/57633
* io/list_read.c (next_char, eat_separator): Don't set EOL for \r.
2013-06-20 Tobias Burnus <burnus@net-b.de>
PR fortran/57633
* gfortran.dg/list_read_11.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/list_read_11.f90
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/list_read.c
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-06-20 10:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17 8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
2013-06-17 8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
2013-06-17 9:20 ` dominiq at lps dot ens.fr
2013-06-18 1:38 ` jvdelisle at gcc dot gnu.org
2013-06-20 8:44 ` burnus at gcc dot gnu.org
2013-06-20 9:12 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
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).