Bug 19678 - DOS files don't work for list directed input
DOS files don't work for list directed input
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: libfortran
4.0.0
: P2 normal
: 4.0.0
Assigned To: Francois-Xavier Coudert
: patch
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-01-28 22:54 UTC by Thomas Koenig
Modified: 2005-03-25 13:38 UTC (History)
2 users (show)

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


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:54:25 UTC
This time, the right bug report...

CR-LF (the DOS convenction for text files) as record separators
don't work for list-directed input.

$ cat dosfile.f
      program main
      write (10,'(2A)') '1',achar(13)
      rewind(10)
      read(10,*) n
      print *,n
      end
$ gfortran dosfile.f
$ ./a.out
At line 4 of file dosfile.f
Fortran runtime error: Bad integer for item 1 in list input
$ g77 dosfile.f
$ ./a.out
 1
$ od -c fort.10
0000000   1  \r  \n
0000003
$ gfortran -v
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)
Comment 1 Paul Thomas 2005-02-02 12:40:55 UTC
It's funny that you signal this.  I was going to suggest to the list that I fix 
it.  I was not sure that it really is a bug but it is a nuisance and is very 
easily fixed.
Comment 2 Thomas Koenig 2005-02-07 08:48:19 UTC
g77 can do this:

$ cat dosfile.f
      write(10,'(2A)') '1',achar(13)
      rewind(10)
      read (10,*) n
      print *,n
      end
$ g77 dosfile.f
$ ./a.out
 1
$ g77 -v
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=ia64-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
Comment 3 Francois-Xavier Coudert 2005-02-24 13:46:04 UTC
I submitted a patch to fix this bug. See
http://gcc.gnu.org/ml/fortran/2005-02/msg00303.html
Comment 4 CVS Commits 2005-03-25 13:35:36 UTC
Subject: Bug 19678

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 5 Francois-Xavier Coudert 2005-03-25 13:37:22 UTC
Fixed.
Comment 6 CVS Commits 2005-03-25 13:41:13 UTC
Subject: Bug 19678

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