re PR libfortran/20755 (gfortran - prints the same number with 1p4G12.3 two different ways)

PR libfortran/20755
	* write.c (write_float): A G edit descriptor may locally change
	the scale factor, but it needs to be restored afterwards.

	* gfortran.dg/pr20755.f: New test.

From-SVN: r97627
This commit is contained in:
Francois-Xavier Coudert 2005-04-05 16:20:10 +02:00 committed by François-Xavier Coudert
parent 9e9126f355
commit 51e9d74cb8
4 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2005-04-05 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20755
* gfortran.dg/pr20755.f: New test.
2005-04-05 Feng Wang <fengwang@nudt.edu.cn>
* gfortran.dg/pr15959.f90: New test.

View File

@ -0,0 +1,10 @@
! PR libfortran/20755
! { dg-do run }
character*30 s
write (s,2000) 0.0, 0.02
if (s .ne. " 0.00 2.000E-02") call abort
write (s,2000) 0.01, 0.02
if (s .ne. " 1.000E-02 2.000E-02") call abort
2000 format (1P2G12.3)
end

View File

@ -1,3 +1,9 @@
2005-04-05 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20755
* write.c (write_float): A G edit descriptor may locally change
the scale factor, but it needs to be restored afterwards.
2005-04-03 Dale Ranta <dir@lanl.gov>
Francois-Xavier Coudert <coudert@clipper.ens.fr>

View File

@ -674,7 +674,7 @@ static void
write_float (fnode *f, const char *source, int len)
{
double n;
int nb =0, res;
int nb =0, res, save_scale_factor;
char * p, fin;
fnode *f2 = NULL;
@ -723,8 +723,10 @@ write_float (fnode *f, const char *source, int len)
}
else
{
save_scale_factor = g.scale_factor;
f2 = calculate_G_format(f, n, len, &nb);
output_float (f2, n, len);
g.scale_factor = save_scale_factor;
if (f2 != NULL)
free_mem(f2);