summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-29 17:31:04 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-29 17:31:04 +0000
commit12b900077ae9316a12fc85b2b92e8ce0b558dcac (patch)
treee69ac08764003fae3205b41012afee45c9b480ca /libgfortran
parentf4af8ac8bc485d3c5251ad80df71f4af0e5fe142 (diff)
downloadgcc-12b900077ae9316a12fc85b2b92e8ce0b558dcac.tar.gz
2011-01-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/47434 * io/write_float.def (write_infnan): Use calculate_sign to determine if the sign should be given and check field widths accordingly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169390 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog12
-rw-r--r--libgfortran/io/write_float.def46
2 files changed, 44 insertions, 14 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 5e0c7623e97..dc10be50cb0 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/47434
+ * io/write_float.def (write_infnan): Use calculate_sign to determine
+ if the sign should be given and check field widths accordingly.
+
2011-01-29 Kai Tietz <kai.tietz@onevision.com>
* intrinsics/ctime.c (ctime_r): Improve implementation.
@@ -38,6 +44,12 @@
2011-01-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/47285
+ * io/write_float.def (write_infnan): Adjust processor selected width
+ to 3 if NaN.
+
+2011-01-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/47285
* io/write_float.def (output_float): Return SUCCESS or FAILURE and use
the result to set the padding.
diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def
index a74b34a0214..a77b3042768 100644
--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -660,15 +660,26 @@ write_infnan (st_parameter_dt *dtp, const fnode *f, int isnan_flag, int sign_bit
{
char * p, fin;
int nb = 0;
+ sign_t sign;
+ int mark;
if (f->format != FMT_B && f->format != FMT_O && f->format != FMT_Z)
{
+ sign = calculate_sign (dtp, sign_bit);
+ mark = (sign == S_PLUS || sign == S_MINUS) ? 8 : 7;
+
nb = f->u.real.w;
/* If the field width is zero, the processor must select a width
not zero. 4 is chosen to allow output of '-Inf' or '+Inf' */
- if (nb == 0) nb = 4;
+ if (nb == 0)
+ {
+ if (isnan_flag)
+ nb = 3;
+ else
+ nb = (sign == S_PLUS || sign == S_MINUS) ? 4 : 3;
+ }
p = write_block (dtp, nb);
if (p == NULL)
return;
@@ -720,24 +731,28 @@ write_infnan (st_parameter_dt *dtp, const fnode *f, int isnan_flag, int sign_bit
if (unlikely (is_char4_unit (dtp)))
{
gfc_char4_t *p4 = (gfc_char4_t *) p;
- if (nb > 8)
+
+ if (nb > mark)
/* We have room, so output 'Infinity' */
memcpy4 (p4 + nb - 8, "Infinity", 8);
else
- /* For the case of width equals 8, there is not enough room
+ /* For the case of width equals mark, there is not enough room
for the sign and 'Infinity' so we go with 'Inf' */
memcpy4 (p4 + nb - 3, "Inf", 3);
- if (nb < 9 && nb > 3)
- /* Put the sign in front of Inf */
- p4[nb - 4] = (gfc_char4_t) fin;
- else if (nb > 8)
- /* Put the sign in front of Infinity */
- p4[nb - 9] = (gfc_char4_t) fin;
+ if (sign == S_PLUS || sign == S_MINUS)
+ {
+ if (nb < 9 && nb > 3)
+ /* Put the sign in front of Inf */
+ p4[nb - 4] = (gfc_char4_t) fin;
+ else if (nb > 8)
+ /* Put the sign in front of Infinity */
+ p4[nb - 9] = (gfc_char4_t) fin;
+ }
return;
}
- if (nb > 8)
+ if (nb > mark)
/* We have room, so output 'Infinity' */
memcpy(p + nb - 8, "Infinity", 8);
else
@@ -745,10 +760,13 @@ write_infnan (st_parameter_dt *dtp, const fnode *f, int isnan_flag, int sign_bit
for the sign and 'Infinity' so we go with 'Inf' */
memcpy(p + nb - 3, "Inf", 3);
- if (nb < 9 && nb > 3)
- p[nb - 4] = fin; /* Put the sign in front of Inf */
- else if (nb > 8)
- p[nb - 9] = fin; /* Put the sign in front of Infinity */
+ if (sign == S_PLUS || sign == S_MINUS)
+ {
+ if (nb < 9 && nb > 3)
+ p[nb - 4] = fin; /* Put the sign in front of Inf */
+ else if (nb > 8)
+ p[nb - 9] = fin; /* Put the sign in front of Infinity */
+ }
}
else
{