diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-21 21:23:52 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-21 21:23:52 +0000 |
commit | 4749905db26b07ca790a968c41f7e080f9c0dbd2 (patch) | |
tree | a2782d026ced11088ac3bddad90c020959504cdf /libgfortran/io/write_float.def | |
parent | 7133c3fde2b5fabad1d09481e852154a496543ae (diff) | |
download | gcc-4749905db26b07ca790a968c41f7e080f9c0dbd2.tar.gz |
2008-12-21 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/38398
* io/io.h (st_parameter_dt): Add new bit to keep track of when to
suppress blanks for g0 formatting.
* io/transfer.c (formatted_transfer_scalar): Always call write_real_g0
for g0 formatting.
* io.c (write.c): Do not use ES formatting and use new bit to suppress
blanks.
* io/write_float.def (output_float): Adjust the location of setting the
width so that it can be adjusted when suppressing blanks. Set number of
blanks to zero when dtp->u.p.g0_no_blanks is set. Do some minor code
clean-up and add some white space for readability.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142871 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io/write_float.def')
-rw-r--r-- | libgfortran/io/write_float.def | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index d8799f2ae03..a5d292ca76c 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -333,15 +333,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, else edigits = 0; - /* Pick a field size if none was specified. */ - if (w <= 0) - w = nbefore + nzero + nafter + (sign != S_NONE ? 2 : 1); - - /* Create the ouput buffer. */ - out = write_block (dtp, w); - if (out == NULL) - return; - /* Zero values always output as positive, even if the value was negative before rounding. */ for (i = 0; i < ndigits; i++) @@ -359,11 +350,26 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, sign = calculate_sign (dtp, 0); } + /* Pick a field size if none was specified. */ + if (w <= 0) + w = nbefore + nzero + nafter + (sign != S_NONE ? 2 : 1); + /* Work out how much padding is needed. */ nblanks = w - (nbefore + nzero + nafter + edigits + 1); if (sign != S_NONE) nblanks--; + if (dtp->u.p.g0_no_blanks) + { + w -= nblanks; + nblanks = 0; + } + + /* Create the ouput buffer. */ + out = write_block (dtp, w); + if (out == NULL) + return; + /* Check the value fits in the specified field width. */ if (nblanks < 0 || edigits == -1) { @@ -419,6 +425,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, digits += i; out += nbefore; } + /* Output the decimal point. */ *(out++) = dtp->u.p.current_unit->decimal_status == DECIMAL_POINT ? '.' : ','; @@ -461,12 +468,14 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, #endif memcpy (out, buffer, edigits); } + if (dtp->u.p.no_leading_blank) { out += edigits; memset( out , ' ' , nblanks ); dtp->u.p.no_leading_blank = 0; } + #undef STR #undef STR1 #undef MIN_FIELD_WIDTH @@ -606,7 +615,7 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \ int save_scale_factor, nb = 0;\ \ save_scale_factor = dtp->u.p.scale_factor;\ - newf = get_mem (sizeof (fnode));\ + newf = (fnode *) get_mem (sizeof (fnode));\ \ exp_d = calculate_exp_ ## x (d);\ if ((m > 0.0 && m < 0.1 - 0.05 / exp_d) || (m >= exp_d - 0.5 ) ||\ @@ -680,7 +689,7 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \ \ free_mem(newf);\ \ - if (nb > 0)\ + if (nb > 0 && !dtp->u.p.g0_no_blanks)\ { \ p = write_block (dtp, nb);\ if (p == NULL)\ |