aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/write.c
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2011-04-29 14:56:02 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2011-04-29 14:56:02 +0000
commita3f02fe44c80ce4f76b9f24cd17a4abbe412eb4b (patch)
tree7c17b1373c610a14b69aea91b26798d2921a7d89 /libgfortran/io/write.c
parenteb6c3df1a0e34edc7a243c781a1b8842e3fc285c (diff)
downloadgcc-a3f02fe44c80ce4f76b9f24cd17a4abbe412eb4b.zip
gcc-a3f02fe44c80ce4f76b9f24cd17a4abbe412eb4b.tar.gz
gcc-a3f02fe44c80ce4f76b9f24cd17a4abbe412eb4b.tar.bz2
re PR libfortran/48488 (Wrong default format for real numbers)
2011-04-29 Jerry DeLisle <jvdelisle@gcc.gnu.org> Janne Blomqvist <jb@gcc.gnu.org> PR libgfortran/48488 PR libgfortran/48602 PR libgfortran/48615 PR libgfortran/48684 PR libgfortran/48787 * io/write.c (write_d, write_e, write_f, write_en, write_es): Add precision compemsation parameter to call. (set_fnode_default): Adjust default widths to assure round trip on write and read. (write_real): Adjust call to write_float. (write_real_g0): Calculate compensation for extra precision and adjust call to write_float. * io/write_float.def (output_float_FMT_G_): Use volatile rather than asm volatile to avoid optimization issue. Correctly calculate the number of blanks (nb) to be appended and simplify calculation logic. (write_float): Increase MIN_FIELD_WIDTH by one to accomodate the new default widths. Eliminate the code that attempted to reduce the the precision used in later sprintf functions. Add call parameter to compensate for extra precision. Co-Authored-By: Janne Blomqvist <jb@gcc.gnu.org> From-SVN: r173166
Diffstat (limited to 'libgfortran/io/write.c')
-rw-r--r--libgfortran/io/write.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 5338162..bf02ad8 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1155,35 +1155,35 @@ write_z (st_parameter_dt *dtp, const fnode *f, const char *source, int len)
void
write_d (st_parameter_dt *dtp, const fnode *f, const char *p, int len)
{
- write_float (dtp, f, p, len);
+ write_float (dtp, f, p, len, 0);
}
void
write_e (st_parameter_dt *dtp, const fnode *f, const char *p, int len)
{
- write_float (dtp, f, p, len);
+ write_float (dtp, f, p, len, 0);
}
void
write_f (st_parameter_dt *dtp, const fnode *f, const char *p, int len)
{
- write_float (dtp, f, p, len);
+ write_float (dtp, f, p, len, 0);
}
void
write_en (st_parameter_dt *dtp, const fnode *f, const char *p, int len)
{
- write_float (dtp, f, p, len);
+ write_float (dtp, f, p, len, 0);
}
void
write_es (st_parameter_dt *dtp, const fnode *f, const char *p, int len)
{
- write_float (dtp, f, p, len);
+ write_float (dtp, f, p, len, 0);
}
@@ -1432,8 +1432,8 @@ set_fnode_default (st_parameter_dt *dtp, fnode *f, int length)
switch (length)
{
case 4:
- f->u.real.w = 15;
- f->u.real.d = 8;
+ f->u.real.w = 16;
+ f->u.real.d = 9;
f->u.real.e = 2;
break;
case 8:
@@ -1442,13 +1442,13 @@ set_fnode_default (st_parameter_dt *dtp, fnode *f, int length)
f->u.real.e = 3;
break;
case 10:
- f->u.real.w = 29;
- f->u.real.d = 20;
+ f->u.real.w = 30;
+ f->u.real.d = 21;
f->u.real.e = 4;
break;
case 16:
- f->u.real.w = 44;
- f->u.real.d = 35;
+ f->u.real.w = 45;
+ f->u.real.d = 36;
f->u.real.e = 4;
break;
default:
@@ -1468,7 +1468,7 @@ write_real (st_parameter_dt *dtp, const char *source, int length)
int org_scale = dtp->u.p.scale_factor;
dtp->u.p.scale_factor = 1;
set_fnode_default (dtp, &f, length);
- write_float (dtp, &f, source , length);
+ write_float (dtp, &f, source , length, 1);
dtp->u.p.scale_factor = org_scale;
}
@@ -1476,12 +1476,20 @@ write_real (st_parameter_dt *dtp, const char *source, int length)
void
write_real_g0 (st_parameter_dt *dtp, const char *source, int length, int d)
{
- fnode f ;
+ fnode f;
+ int comp_d;
set_fnode_default (dtp, &f, length);
if (d > 0)
f.u.real.d = d;
+
+ /* Compensate for extra digits when using scale factor, d is not
+ specified, and the magnitude is such that E editing is used. */
+ if (dtp->u.p.scale_factor > 0 && d == 0)
+ comp_d = 1;
+ else
+ comp_d = 0;
dtp->u.p.g0_no_blanks = 1;
- write_float (dtp, &f, source , length);
+ write_float (dtp, &f, source , length, comp_d);
dtp->u.p.g0_no_blanks = 0;
}