aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-04-05 16:20:10 +0200
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-04-05 14:20:10 +0000
commit51e9d74cb85e9640ce3958bb89fab245f44752c7 (patch)
treef31db877f1ff6847fae7b39c30d10d28a04bed21
parent9e9126f35508e7078eeeac4e81ea76a7a37fa1af (diff)
downloadgcc-51e9d74cb85e9640ce3958bb89fab245f44752c7.zip
gcc-51e9d74cb85e9640ce3958bb89fab245f44752c7.tar.gz
gcc-51e9d74cb85e9640ce3958bb89fab245f44752c7.tar.bz2
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
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr20755.f10
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/write.c4
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 58d473c..3c67aa3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gfortran.dg/pr20755.f b/gcc/testsuite/gfortran.dg/pr20755.f
new file mode 100644
index 0000000..07c72ae
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr20755.f
@@ -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
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index ebcac0b..51fe4a1 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -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>
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 556adea..d97caec 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -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);