Commit 06e4f02a by Paul Brook

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
parent f3e41701
...@@ -16,5 +16,5 @@ C ( dg-output "^" } ...@@ -16,5 +16,5 @@ C ( dg-output "^" }
write(*,40) 0 ! { dg-output " \\+0(\n|\r\n|\r)" } 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 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)" } write(*,50) 11 ! { dg-output "\\*\\*(\n|\r\n|\r)" }
C { dg-output "\$" {xfail *-*-*} } gfortran PR 16434 C { dg-output "\$" }
end end
...@@ -552,6 +552,7 @@ format_item: ...@@ -552,6 +552,7 @@ format_item:
case FMT_BN: case FMT_BN:
case FMT_BZ: case FMT_BZ:
get_fnode (&head, &tail, t); get_fnode (&head, &tail, t);
tail->repeat = 1;
goto between_desc; goto between_desc;
case FMT_COLON: case FMT_COLON:
......
...@@ -425,9 +425,12 @@ output_float (fnode *f, double value, int len) ...@@ -425,9 +425,12 @@ output_float (fnode *f, double value, int len)
} }
/* Round the value. */ /* 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') if (digits[i] >= '5')
{ {
/* Propagate the carry. */ /* Propagate the carry. */
...@@ -513,6 +516,16 @@ output_float (fnode *f, double value, int len) ...@@ -513,6 +516,16 @@ output_float (fnode *f, double value, int len)
if (out == NULL) if (out == NULL)
return; 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. */ /* Work out how much padding is needed. */
nblanks = w - (nbefore + nzero + nafter + edigits + 1); nblanks = w - (nbefore + nzero + nafter + edigits + 1);
if (sign != SIGN_NONE) if (sign != SIGN_NONE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment