re PR libfortran/17706 (reading a value of 0.0 gives a value of -0.0)
authorPaul Brook <pbrook@gcc.gnu.org>
Mon, 4 Oct 2004 15:33:18 +0000 (15:33 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Mon, 4 Oct 2004 15:33:18 +0000 (15:33 +0000)
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

gcc/testsuite/gfortran.dg/g77/f77-edit-s-out.f
libgfortran/io/format.c
libgfortran/io/write.c

index b5205a8bf538906d8ea826108e883220868abdf4..89a8df2caffd313a1f4ef8cdb1ebc568e23a4a04 100644 (file)
@@ -16,5 +16,5 @@ C ( dg-output "^" }
       write(*,40) 0           ! { dg-output " \\+0(\n|\r\n|\r)" }
 C 15.5.9 - Note 5: When SP editing is in effect, the plus sign is not optional
       write(*,50) 11          ! { dg-output "\\*\\*(\n|\r\n|\r)" }
-C { dg-output "\$" {xfail *-*-*} } gfortran PR 16434
+C { dg-output "\$" }
       end
index 23b8d5ebf1bea72477da1f895fea9705b89a730d..0e42810873ef0c946ee5fe783014318b07108a20 100644 (file)
@@ -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:
index 4e22b703ea82a24906d27c4d3f36b7fdd8acdf69..f98ec1f1f36196203da9a6bbf89dd18db4b69537 100644 (file)
@@ -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)