diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-10 08:35:39 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-10 08:35:39 +0000 |
commit | 3ee4ff514ef78664456ace6cb94f6f47d5b054c3 (patch) | |
tree | c9a0285e6fdb6b7376373f67ac64eea33c65e9fc /libgfortran | |
parent | 681996faa0d6a8c18c3df8b352603c9596a81e11 (diff) | |
download | gcc-3ee4ff514ef78664456ace6cb94f6f47d5b054c3.tar.gz |
2005-04-10 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/17992
PR libfortran/19568
PR libfortran/19595
PR libfortran/20005
PR libfortran/20092
PR libfortran/20131
PR libfortran/20138
PR libfortran/20661
PR libfortran/20744
* io/transfer.c (top level): eor_condition: New static variable.
(read_sf): Remove unnecessary zeroing of buffer (there is enough
information in its length).
Return a string of length 0 (to be padded by caller) if EOR was
seen previously.
Remove erroneous special casing of EOR for standard input.
Set eor_condition for non-advancing I/O if an end of line was
detected.
Increment ioparm.size if necessary.
(formatted_transfer): Skip the function if there is an EOR condition.
(data_transfer_init): Initialize eor_condition to zero (false).
(next_record_r): Clear sf_seen_eor if a \n has been seen already.
(finalize_transfer): If there is an EOR condition, raise the error.
2005-04-10 Thomas Koenig <Thomas.Koenig@online.de>
* eor_handling_1.f90: New test case.
* eor_handling_2.f90: New test case.
* eor_handling_3.f90: New test case.
* eor_handling_4.f90: New test case.
* eor_handling_5.f90: New test case.
* noadv_size.f90: New test case.
* pad_no.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97943 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 25 | ||||
-rw-r--r-- | libgfortran/io/transfer.c | 45 |
2 files changed, 62 insertions, 8 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 46fc3b3dedf..fcb4ff3ae88 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,28 @@ +2005-04-10 Thomas Koenig <Thomas.Koenig@online.de> + + PR libfortran/17992 + PR libfortran/19568 + PR libfortran/19595 + PR libfortran/20005 + PR libfortran/20092 + PR libfortran/20131 + PR libfortran/20138 + PR libfortran/20661 + PR libfortran/20744 + * io/transfer.c (top level): eor_condition: New static variable. + (read_sf): Remove unnecessary zeroing of buffer (there is enough + information in its length). + Return a string of length 0 (to be padded by caller) if EOR was + seen previously. + Remove erroneous special casing of EOR for standard input. + Set eor_condition for non-advancing I/O if an end of line was + detected. + Increment ioparm.size if necessary. + (formatted_transfer): Skip the function if there is an EOR condition. + (data_transfer_init): Initialize eor_condition to zero (false). + (next_record_r): Clear sf_seen_eor if a \n has been seen already. + (finalize_transfer): If there is an EOR condition, raise the error. + 2005-04-09 Bud Davis <bdavis@gfortran.org> Steven G. Kargl <kargls@comcast.net> diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index f86a8527245..77e943964d8 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -79,6 +79,7 @@ export_proto(transfer_complex); gfc_unit *current_unit = NULL; static int sf_seen_eor = 0; +static int eor_condition = 0; char scratch[SCRATCH_SIZE] = { }; static char *line_buffer = NULL; @@ -150,7 +151,13 @@ read_sf (int *length) else p = base = data; - memset(base,'\0',*length); + /* If we have seen an eor previously, return a length of 0. The + caller is responsible for correctly padding the input field. */ + if (sf_seen_eor) + { + *length = 0; + return base; + } current_unit->bytes_left = options.default_recl; readlen = 1; @@ -179,13 +186,16 @@ read_sf (int *length) if (readlen < 1 || *q == '\n' || *q == '\r') { - /* ??? What is this for? */ - if (current_unit->unit_number == options.stdin_unit) - { - if (n <= 0) - continue; - } /* Unexpected end of line. */ + + /* If we see an EOR during non-advancing I/O, we need to skip + the rest of the I/O statement. Set the corresponding flag. */ + if (advance_status == ADVANCE_NO) + eor_condition = 1; + + /* Without padding, terminate the I/O statement without assigning + the value. With padding, the value still needs to be assigned, + so we can just continue with a short read. */ if (current_unit->flags.pad == PAD_NO) { generate_error (ERROR_EOR, NULL); @@ -204,6 +214,9 @@ read_sf (int *length) } while (n < *length); + if (ioparm.size != NULL) + *ioparm.size += *length; + return base; } @@ -434,6 +447,11 @@ formatted_transfer (bt type, void *p, int len) if (type == BT_COMPLEX) type = BT_REAL; + /* If there's an EOR condition, we simulate finalizing the transfer + by doing nothing. */ + if (eor_condition) + return; + for (;;) { /* If reversion has occurred and there is another real data item, @@ -1121,6 +1139,7 @@ data_transfer_init (int read_flag) g.first_item = 1; g.item_count = 0; sf_seen_eor = 0; + eor_condition = 0; pre_position (); @@ -1236,7 +1255,10 @@ next_record_r (int done) length = 1; /* sf_read has already terminated input because of an '\n' */ if (sf_seen_eor) - break; + { + sf_seen_eor=0; + break; + } do { @@ -1402,6 +1424,13 @@ next_record (int done) static void finalize_transfer (void) { + + if (eor_condition) + { + generate_error (ERROR_EOR, NULL); + return; + } + if (ioparm.library_return != LIBRARY_OK) return; |