From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2980 invoked by alias); 20 Jun 2013 08:44:57 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2931 invoked by uid 48); 20 Jun 2013 08:44:53 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) Date: Thu, 20 Jun 2013 08:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg01067.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57633 --- Comment #5 from Tobias Burnus --- 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)