From 69774e69a79a32952263b0ac58c97c332aa6457c Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sun, 24 Jun 2007 18:54:50 +0000 Subject: [PATCH] re PR fortran/32446 (F0.n output format fails with large numbers) 2007-06-24 Jerry DeLisle PR libgfortran/32446 * io/write.c (output_float): Calculate ndigits correctly for large numbered formats that must pad zeros before the decimal point. From-SVN: r125985 --- libgfortran/ChangeLog | 6 ++++++ libgfortran/io/write.c | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 8df6b35529b4..fc31e65a6ec8 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2007-06-24 Jerry DeLisle + + PR libgfortran/32446 + * io/write.c (output_float): Calculate ndigits correctly for large + numbered formats that must pad zeros before the decimal point. + 2007-06-15 Rainer Orth PR libfortran/32345 diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index e0c507f47505..f156d19862be 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -810,16 +810,21 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) if (nbefore > 0) { if (nbefore > ndigits) - i = ndigits; + { + i = ndigits; + memcpy (out, digits, i); + ndigits = 0; + while (i < nbefore) + out[i++] = '0'; + } else - i = nbefore; - - memcpy (out, digits, i); - while (i < nbefore) - out[i++] = '0'; + { + i = nbefore; + memcpy (out, digits, i); + ndigits -= i; + } digits += i; - ndigits -= i; out += nbefore; } /* Output the decimal point. */ -- 2.47.2