[patch, libfortran] PR114618 Format produces incorrect output when contains 1x, ok when uses " "

Jerry D jvdelisle2@gmail.com
Tue Jan 28 03:41:04 GMT 2025


Hello all,

The attached patch is part 1 of my effort to fix these X and T edit 
descriptor issues. This one cleans up some really ugly output.

Before the patch with the test case provided by the reporter:

PI.................^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931
REAL(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.14159274
DBLE(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931
RADIX..............^@^@^@^@^@^@^@^@^@^@^@ 3. 2
RANGE..............^@^@^@^@^@^@^@^@^@^@^@ 3. 307
PRECISION..........^@^@^@^@^@^@^@^@^@^@ 15

Which is complete garbage.

After the patch:

PI ................ 3.1415926535897931
REAL(PI) .......... 3.14159274
DBLE(PI) .......... 3.1415926535897931
RADIX ............. 2
RANGE ............. 307
PRECISION ......... 15

I greatly reduced the test case included in the patch. While working on 
this one I discovered other problems not addressed by this patch and I 
will address these through PR113897.

You will see some changes in the factoring of some of the code in the
case FMT_X:, case FMT_TR:, case FMT_TL:, case FMT_T:. I anticipate in 
part 2 that I will be doing more specific changes on these.

Regression tested on x86_64_linux_gnu.

OK for trunk?

Regards,

Jerry

Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Mon Jan 27 19:08:46 2025 -0800

     Fortran: Fix handling of the X edit descriptor.

     This patch is a partial fix of handling of X edit descriptors
     when combined with certain T edit descriptors.

             PR libfortran/114618

     libgfortran/ChangeLog:

           * io/transfer.c (formatted_transfer_scalar_write): Change name
             of vriable 'pos' to 'tab_pos' to improve clarity. Add new
             variable next_pos when calculating the maximum position.
             Update the calculation of pending spaces.

     gcc/testsuite/ChangeLog:

             * gfortran.dg/pr114618.f90: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixtabs-part1.diff
Type: text/x-patch
Size: 5310 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20250127/177073b4/attachment-0001.bin>


More information about the Fortran mailing list