diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-26 04:35:45 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-26 04:35:45 +0000 |
commit | af7608045328e18f25d6765acf8eb412742437cd (patch) | |
tree | 47c5d1a5bbaf45540c19e9a7ef06f27799fc240b /libgfortran/io | |
parent | 1dc5cee9479a543e3f9cdff03936297a04406bb4 (diff) | |
download | gcc-af7608045328e18f25d6765acf8eb412742437cd.tar.gz |
2006-10-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/29563
* io/io.h (st_parameter_dt): Add new flag at_eof.
* io/list_read.c (next_char): Set flag when EOF and return '\n' to
signal EOR. Check flag on next call and jump out.
* io/unit.c (get_internal_unit): Initialize new flag.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118059 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/io.h | 5 | ||||
-rw-r--r-- | libgfortran/io/list_read.c | 39 | ||||
-rw-r--r-- | libgfortran/io/unit.c | 1 |
3 files changed, 29 insertions, 16 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index ecc4a9de0ea..e009f17e3c4 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -415,7 +415,10 @@ typedef struct st_parameter_dt /* An internal unit specific flag used to identify that the associated unit is internal. */ unsigned unit_is_internal : 1; - /* 17 unused bits. */ + /* An internal unit specific flag to signify an EOF condition for list + directed read. */ + unsigned at_eof : 1; + /* 16 unused bits. */ char last_char; char nml_delim; diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index cddfd76877f..f10a0997617 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -163,26 +163,35 @@ next_char (st_parameter_dt *dtp) dtp->u.p.line_buffer_enabled = 0; } - /* Handle the end-of-record condition for internal array unit */ - if (is_array_io(dtp) && dtp->u.p.current_unit->bytes_left == 0) + /* Handle the end-of-record and end-of-file conditions for + internal array unit. */ + if (is_array_io(dtp)) { - c = '\n'; - record = next_array_record (dtp, dtp->u.p.current_unit->ls); - - /* Check for "end-of-file" condition */ - if (record == 0) + if (dtp->u.p.at_eof) longjmp (*dtp->u.p.eof_jump, 1); - record *= dtp->u.p.current_unit->recl; - - if (sseek (dtp->u.p.current_unit->s, record) == FAILURE) - longjmp (*dtp->u.p.eof_jump, 1); + /* Check for "end-of-record" condition. */ + if (dtp->u.p.current_unit->bytes_left == 0) + { + record = next_array_record (dtp, dtp->u.p.current_unit->ls); - dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl; - goto done; + /* Check for "end-of-file" condition. */ + if (record == 0) + { + dtp->u.p.at_eof = 1; + c = '\n'; + goto done; + } + + record *= dtp->u.p.current_unit->recl; + if (sseek (dtp->u.p.current_unit->s, record) == FAILURE) + longjmp (*dtp->u.p.eof_jump, 1); + + dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl; + } } - /* Get the next character and handle end-of-record conditions */ + /* Get the next character and handle end-of-record conditions. */ length = 1; @@ -196,7 +205,7 @@ next_char (st_parameter_dt *dtp) if (is_array_io(dtp)) { /* End of record is handled in the next pass through, above. The - check for NULL here is cautionary. */ + check for NULL here is cautionary. */ if (p == NULL) { generate_error (&dtp->common, ERROR_INTERNAL_UNIT, NULL); diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index 6a227845649..90e6d85f6da 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -430,6 +430,7 @@ get_internal_unit (st_parameter_dt *dtp) dtp->u.p.skips = 0; dtp->u.p.pending_spaces = 0; dtp->u.p.max_pos = 0; + dtp->u.p.at_eof = 0; /* This flag tells us the unit is assigned to internal I/O. */ |