From: Francois-Xavier Coudert Date: Wed, 16 Mar 2005 18:09:03 +0000 (+0100) Subject: write.c (output_float): special check when writing 0.0 with EN and ES formats. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dcdeec06a01f230623864bbfa564c71d9f11f201;p=gcc.git write.c (output_float): special check when writing 0.0 with EN and ES formats. * write.c (output_float): special check when writing 0.0 with EN and ES formats. * pr20480.f90: New test. From-SVN: r96566 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 466b77e9816..e3e9cec70b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-03-16 Francois-Xavier Coudert + + PR libfortran/20480 + * pr20480.f90: New test. + 2005-03-16 Richard Henderson PR middle-end/15700 diff --git a/gcc/testsuite/gfortran.dg/pr20480.f90 b/gcc/testsuite/gfortran.dg/pr20480.f90 new file mode 100644 index 00000000000..12e53009d91 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr20480.f90 @@ -0,0 +1,9 @@ +! { dg-do run } +! PR libfortran/20480 +! fxcoudert@gcc.gnu.org + character(len=80) c + write (c,'(ES12.3)') 0.0 + if (trim(adjustl(c)) .ne. '0.000E+00') call abort () + write (c,'(EN12.3)') 0.0 + if (trim(adjustl(c)) .ne. '0.000E+00') call abort () + end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index ac7e067e5c9..43a2d9d39fb 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2005-03-16 Francois-Xavier Coudert + + PR libfortran/20480 + * write.c (output_float): special check when writing 0.0 with + EN and ES formats. + 2005-03-11 Francois-Xavier Coudert PR libfortran/20124 diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 9c255d7d69e..88e5280b338 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -411,7 +411,8 @@ output_float (fnode *f, double value, int len) case FMT_EN: /* The exponent must be a multiple of three, with 1-3 digits before the decimal point. */ - e--; + if (value != 0.0) + e--; if (e >= 0) nbefore = e % 3; else @@ -428,7 +429,8 @@ output_float (fnode *f, double value, int len) break; case FMT_ES: - e--; + if (value != 0.0) + e--; nbefore = 1; nzero = 0; nafter = d;