From 06e6fdfb0064b570ee7f86cd7ed3e948b79cb1a2 Mon Sep 17 00:00:00 2001 From: jb Date: Sat, 17 Mar 2012 17:19:49 +0000 Subject: [PATCH] PR libfortran/52608 Move the removal of initial zeros. 2012-03-17 Janne Blomqvist PR libfortran/52608 * io/write_float.def (output_float): Move removal of initial zeros until after the scale factor has been applied. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185486 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 6 ++++++ libgfortran/io/write_float.def | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index d2b74ac..d593134 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2012-03-17 Janne Blomqvist + + PR libfortran/52608 + * io/write_float.def (output_float): Move removal of initial zeros + until after the scale factor has been applied. + 2012-03-16 Janne Blomqvist * io/unix.h (struct stream): Rename to stream_vtable. diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 07437f0..6521f3c 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -180,12 +180,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, /* Make sure the decimal point is a '.'; depending on the locale, this might not be the case otherwise. */ digits[nbefore] = '.'; - if (digits[0] == '0' && nbefore == 1) - { - digits++; - nbefore--; - ndigits--; - } if (p != 0) { if (p > 0) @@ -229,6 +223,13 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, nafter = d; } + while (digits[0] == '0' && nbefore > 0) + { + digits++; + nbefore--; + ndigits--; + } + expchar = 0; /* If we need to do rounding ourselves, get rid of the dot by moving the fractional part. */ -- 2.7.4