aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorPaul Brook <pbrook@gcc.gnu.org>2004-10-04 15:33:18 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2004-10-04 15:33:18 +0000
commit06e4f02a16465f976c9f1a179fd2c60fb76e9659 (patch)
tree4114a0c97da613eea429829446e76db65fd5d026 /libgfortran
parentf3e41701124d2c5a838c28b99bbc4d8fd69e381e (diff)
downloadgcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.zip
gcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.tar.gz
gcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.tar.bz2
re PR libfortran/17706 (reading a value of 0.0 gives a value of -0.0)
2004-10-04 Paul Brook <paul@codesourcery.com> Bud Davis <bdavis9659@comcast.net> PR fortran/17706 PR fortran/16434 * io/format.c (parse_format_list): Set repeat count for S, SP, SS, BN and BZ formats. * io/write.c (output_float): Don't output minus zero. libgfortran/ * gfortran/pr17706.f90: New test. * gfortran.dg/g77/f77-edit-s-out.f: Remove xfail. Actually apply the patch this time. From-SVN: r88513
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/io/format.c1
-rw-r--r--libgfortran/io/write.c17
2 files changed, 16 insertions, 2 deletions
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c
index 23b8d5e..0e42810 100644
--- a/libgfortran/io/format.c
+++ b/libgfortran/io/format.c
@@ -552,6 +552,7 @@ format_item:
case FMT_BN:
case FMT_BZ:
get_fnode (&head, &tail, t);
+ tail->repeat = 1;
goto between_desc;
case FMT_COLON:
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 4e22b70..f98ec1f 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -425,9 +425,12 @@ output_float (fnode *f, double value, int len)
}
/* Round the value. */
- if (nbefore + nafter < ndigits && nbefore + nafter > 0)
+ if (nbefore + nafter == 0)
+ ndigits = 0;
+ else if (nbefore + nafter < ndigits)
{
- i = nbefore + nafter;
+ ndigits = nbefore + nafter;
+ i = ndigits;
if (digits[i] >= '5')
{
/* Propagate the carry. */
@@ -513,6 +516,16 @@ output_float (fnode *f, double value, int len)
if (out == NULL)
return;
+ /* Zero values always output as positive, even if the value was negative
+ before rounding. */
+ for (i = 0; i < ndigits; i++)
+ {
+ if (digits[i] != '0')
+ break;
+ }
+ if (i == ndigits)
+ sign = calculate_sign (0);
+
/* Work out how much padding is needed. */
nblanks = w - (nbefore + nzero + nafter + edigits + 1);
if (sign != SIGN_NONE)