Disregard this effort, I am back to doing things the old fashioned way
On 6/14/26 10:05 PM, Jerry D wrote:
See attached patch which cleans up I hope the last of the tabbing issues in
formatted output. I renamed the existing test case and created a new one to
test several variations.
Comments appreciated.
Regression tested on X86_64.
Ok for mainline? No plans to backport unless someone thinks its needed.
Best regards,
Jerry
---
When an X or TR edit descriptor advances the file position into
content that has already been written (e.g. after a backward T or
TL tab), formatted_transfer_scalar_write either corrupted the
pending_spaces accounting or overwrote the existing characters with
blanks.
Fix this by detecting the case where pending_spaces is negative and
skips is positive (the advance falls within already-written content)
and using write_x (skips, 0) to move the file position forward
without overwriting. Also, for stream I/O, compute bytes_used from
fbuf->pos (the current write position) rather than fbuf->act (the
high-water mark), since the two diverge after a backward tab followed
by a partial overwrite, which previously prevented this case from
being detected for stream units.
Assisted by: Claude Sonnet 4.6
PR libfortran/114618
libgfortran/ChangeLog:
* io/transfer.c (formatted_transfer_scalar_write): Use
fbuf->pos rather than fbuf->act for bytes_used with stream
I/O. When pending_spaces is negative and skips is positive,
advance the position with write_x (skips, 0) instead of
overwriting existing content.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr114618.f90: Move to...
* gfortran.dg/fmt_t_10.f90: ...here.
* gfortran.dg/fmt_t_11.f90: New test.
---