diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2024-02-12 13:12:08 -0800 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2024-02-12 15:29:04 -0800 |
commit | 153ce7a78edbe339fa0b1cd314dea0554f59faf0 (patch) | |
tree | 8d11b9cdbb397e2f6ea2d06112d76a0f310c92fd /libgfortran | |
parent | 065dddc6e07a917c57c7955db13b1fe77abbcabc (diff) |
libgfortran: Adjust bytes_left and pos for access="STREAM".
During tab edits, the pos (position) and bytes_used
Variables were not being set correctly for stream I/O.
Since stream I/O does not have 'real' records, the
format buffer active length must be used instead of
the record length variable.
PR libgfortran/109358
libgfortran/ChangeLog:
* io/transfer.c (formatted_transfer_scalar_write): Adjust
bytes_used and pos variable for stream access.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr109358.f90: New test.
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/io/transfer.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 80b60dfeb9f..99ef96a9e7c 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -2072,11 +2072,11 @@ formatted_transfer_scalar_write (st_parameter_dt *dtp, bt type, void *p, int kin dtp->u.p.skips = dtp->u.p.pending_spaces = 0; } - bytes_used = dtp->u.p.current_unit->recl - - dtp->u.p.current_unit->bytes_left; - if (is_stream_io(dtp)) - bytes_used = 0; + bytes_used = dtp->u.p.current_unit->fbuf->act; + else + bytes_used = dtp->u.p.current_unit->recl + - dtp->u.p.current_unit->bytes_left; switch (t) { @@ -2452,7 +2452,11 @@ formatted_transfer_scalar_write (st_parameter_dt *dtp, bt type, void *p, int kin p = ((char *) p) + size; } - pos = dtp->u.p.current_unit->recl - dtp->u.p.current_unit->bytes_left; + if (is_stream_io(dtp)) + pos = dtp->u.p.current_unit->fbuf->act; + else + pos = dtp->u.p.current_unit->recl - dtp->u.p.current_unit->bytes_left; + dtp->u.p.max_pos = (dtp->u.p.max_pos > pos) ? dtp->u.p.max_pos : pos; } |