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.
--- /dev/null
+! { dg-do run }
+! PR109358, test that tabs during stream io are correct.
+program tabs
+ implicit none
+ integer :: fd
+ character(64) :: line
+ open(newunit=fd, file="otabs.txt", form="formatted", access="stream")
+ write(fd, "(i4, t40, i4, t20, i5.5)") 1234, 5555, 67890
+ close(fd)
+ open(newunit=fd, file="otabs.txt", form="formatted")
+ read(fd,"(a)") line
+ close(fd, status='delete')
+ if (line .ne. "1234 67890 5555") stop 10
+end program tabs
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)
{
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;
}