[gfortran] patch for pr 16805--error on list directed internal read
Tue Aug 31 21:08:00 GMT 2004
On Sunday 29 August 2004 17:09, Bud Davis wrote:
> list directed I/I wants a '/n' or eoln set true, and these were never
> being set for internal I/O.
> no additional failures on i686/gnu/linux FC1.
> 2004-08-29 Bud Davis <email@example.com>
> PR fortran/pr16805
> * io/list_read.c (next_char): handle end for internal reads.
I don't think this is the correct solution. We should only returning NULL
from salloc_r on error, not on EOF/EOR.
The real solution is to implement internal files with multiple records (ie
arrays), then everything should just work.
Until that happens I've applied the fix below, and added your testcase.
Tested on i686-linux.
2004-08-31 Paul Brook <firstname.lastname@example.org>
* io/list_read.c (next_char): Don't signal EOF for internal files.
* io/unix.c (mem_alloc_r_at): Don't return NULL for incomplete reads.
2004-08-31 Bud Davis <email@example.com>
* gfortran.dg/list_read_2.f90: New test.
RCS file: /var/cvsroot/gcc-cvs/gcc/libgfortran/io/list_read.c,v
retrieving revision 1.7
diff -u -p -r1.7 list_read.c
--- io/list_read.c 31 Aug 2004 14:56:09 -0000 1.7
+++ io/list_read.c 31 Aug 2004 19:18:43 -0000
@@ -142,8 +142,17 @@ next_char (void)
if (length == 0)
- longjmp (g.eof_jump, 1);
- c = *p;
+ /* For internal files return a newline instead of signalling EOF. */
+ /* ??? This isn't quite right, but we don't handle internal files
+ with multiple records. */
+ if (is_internal_unit ())
+ c = '\n';
+ longjmp (g.eof_jump, 1);
+ c = *p;
at_eol = (c == '\n');
RCS file: /var/cvsroot/gcc-cvs/gcc/libgfortran/io/unix.c,v
retrieving revision 1.8
diff -u -p -r1.8 unix.c
--- io/unix.c 31 Aug 2004 15:53:31 -0000 1.8
+++ io/unix.c 31 Aug 2004 19:05:29 -0000
@@ -746,9 +746,6 @@ mem_alloc_r_at (unix_stream * s, int *le
if (where < s->buffer_offset || where > s->buffer_offset + s->active)
- if (is_internal_unit() && where + *len > s->file_length)
- return NULL;
s->logical_offset = where + *len;
n = s->buffer_offset + s->active - where;
More information about the Gcc-patches