Bug 19679 - DOS files don't work for formatted input if line length is exceeded
Summary: DOS files don't work for formatted input if line length is exceeded
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Francois-Xavier Coudert
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2005-01-28 22:59 UTC by Thomas Koenig
Modified: 2005-03-25 13:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-17 12:16:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2005-01-28 22:59:54 UTC
CR-LF (the DOS convenction for text files) as record separators
don't work well for formatted input, either:

$ cat dosfile-2.f
      program main
      write (12,'(2A)') '   1',achar(13)
      write (12,'(2A)') '   2',achar(13)
      rewind(12)
      read(12,'(I4)') n1
      print *,n1
      read(12,'(I5)') n2
      print *,n2
      end
$ gfortran dosfile-2.f
$ ./a.out
           1
At line 7 of file dosfile-2.f
Fortran runtime error: Bad value during integer read
$ gfortran -v ; gfortran -dumpmachine
Using built-in specs.
Configured with: ../gcc/configure --prefix=/home/ig25 --enable-languages=c,f95
Thread model: posix
gcc version 4.0.0 20050127 (experimental)
i686-pc-linux-gnu
$ od -c fort.12
0000000               1  \r  \n               2  \r  \n
0000014
Comment 1 Francois-Xavier Coudert 2005-03-17 12:16:56 UTC
Patch proposed: http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01510.html
Comment 2 GCC Commits 2005-03-25 13:35:36 UTC
Subject: Bug 19679

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	fxcoudert@gcc.gnu.org	2005-03-25 13:35:29

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/io : list_read.c transfer.c 
Added files:
	gcc/testsuite/gfortran.dg: dos_eol.f 

Log message:
	PR libfortran/19678
	PR libfortran/19679
	* gfortran.dg/dos_eol.f: New test.
	
	PR libfortran/19678
	* list_read.c (next_char, eat_separator, finish_separator, read_real)
	(namelist_read): Add support for '\r' as well as '\n' as EOL
	character.
	
	PR libfortran/19679
	* list_read.c (read_sf): Add a '\r' in a test to support DOS
	line-endings when line length is exceeded.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5216&r2=1.5217
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/dos_eol.f.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.177&r2=1.178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/list_read.c.diff?cvsroot=gcc&r1=1.14&r2=1.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.32&r2=1.33

Comment 3 Francois-Xavier Coudert 2005-03-25 13:38:31 UTC
Fixed.
Comment 4 GCC Commits 2005-03-25 13:41:15 UTC
Subject: Bug 19679

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	fxcoudert@gcc.gnu.org	2005-03-25 13:40:20

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/io : list_read.c transfer.c 
Added files:
	gcc/testsuite/gfortran.dg: dos_eol.f 

Log message:
	PR libfortran/19678
	* list_read.c (next_char, eat_separator, finish_separator, read_real)
	(namelist_read): Add support for '\r' as well as '\n' as EOL
	character.
	
	PR libfortran/19679
	* list_read.c (read_sf): Add a '\r' in a test to support DOS
	line-endings when line length is exceeded.
	
	PR libfortran/19678
	PR libfortran/19679
	* gfortran.dg/dos_eol.f: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.68&r2=1.5084.2.69
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/dos_eol.f.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.10&r2=1.163.2.11
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/list_read.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.14&r2=1.14.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.32&r2=1.32.2.1