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
This commit is contained in:
Paul Brook 2004-10-04 15:33:18 +00:00
parent f3e4170112
commit 06e4f02a16
3 changed files with 17 additions and 3 deletions

View 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

View 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:

View 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)