aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2007-07-01 15:46:33 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2007-07-01 15:46:33 +0000
commitc767280aa7c122ac885f4fbd2b0a39514a85f838 (patch)
tree89ec55d6060d58b8db565dd6e1618622e425623b /libgfortran
parent36bd43039bd1b42563052ce0991a977adb96f968 (diff)
downloadgcc-c767280aa7c122ac885f4fbd2b0a39514a85f838.zip
gcc-c767280aa7c122ac885f4fbd2b0a39514a85f838.tar.gz
gcc-c767280aa7c122ac885f4fbd2b0a39514a85f838.tar.bz2
re PR fortran/32554 ([4.2 Only] Bug in P formatting)
2007-07-01 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/32554 * io/write.c (output_float): Set edigits to a fixed size, avoiding variation in field width calculation and eliminate buffer overrun. From-SVN: r126173
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/write.c19
2 files changed, 9 insertions, 16 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 1b6a6bd..ac234b5 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/32554
+ * io/write.c (output_float): Set edigits to a fixed size, avoiding
+ variation in field width calculation and eliminate buffer overrun.
+
2007-07-01 Janne Blomqvist <jb@gcc.gnu.org>
* runtime/memory.c (internal_realloc): Use index_type for size
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index f156d19..766d268 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -466,7 +466,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
int nblanks;
int i;
sign_t sign;
- double abslog;
ft = f->format;
w = f->u.real.w;
@@ -495,21 +494,9 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
value = value + 0.5;
}
- /* Printf always prints at least two exponent digits. */
- if (value == 0)
- edigits = 2;
- else
- {
-#if defined(HAVE_GFC_REAL_10) || defined(HAVE_GFC_REAL_16)
- abslog = fabs((double) log10l(value));
-#else
- abslog = fabs(log10(value));
-#endif
- if (abslog < 100)
- edigits = 2;
- else
- edigits = 1 + (int) log10(abslog);
- }
+ /* printf pads blanks for us on the exponent so we just need it big enough
+ to handle the largest number of exponent digits expected. */
+ edigits=4;
if (ft == FMT_F || ft == FMT_EN
|| ((ft == FMT_D || ft == FMT_E) && dtp->u.p.scale_factor != 0))