summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-24 02:24:15 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-24 02:24:15 +0000
commit0d3a9bae0df3714fc11e6479ab8c25e44f1da0c5 (patch)
treeb5c2c10083bd892859507b8b4697dae1b7b318bb /libgfortran
parenta90a8381955267452d7adf08c0a1a72d3ef4534e (diff)
downloadgcc-0d3a9bae0df3714fc11e6479ab8c25e44f1da0c5.tar.gz
2005-07-23 Jerry DeLisle <jvdelisle@verizon.net>
* io/write.c (write_float): Revise output of IEEE exceptional values to comply with F95 and F2003 standards. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102324 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/io/write.c38
2 files changed, 39 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 747ef9e9023..3e37aacb211 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-23 Jerry DeLisle <jvdelisle@verizon.net>
+
+ * io/write.c (write_float): Revise output of IEEE exceptional
+ values to comply with F95 and F2003 standards.
+
2005-07-22 Jerry DeLisle <jvdelisle@verizon.net>
PR libfortran/22570
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 54bf480fdf3..a702de18a2a 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -772,6 +772,11 @@ write_float (fnode *f, const char *source, int len)
if (res == 0)
{
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;
p = write_block (nb);
if (nb < 3)
{
@@ -784,18 +789,43 @@ write_float (fnode *f, const char *source, int len)
if (res != 0)
{
if (signbit(n))
- fin = '-';
+ {
+
+ /* If the sign is negative and the width is 3, there is
+ insufficient room to output '-Inf', so output asterisks */
+
+ if (nb == 3)
+ {
+ memset (p, '*',nb);
+ return;
+ }
+
+ /* The negative sign is mandatory */
+
+ fin = '-';
+ }
else
- fin = '+';
+
+ /* The positive sign is optional, but we output it for
+ consistency */
+
+ fin = '+';
if (nb > 8)
+
+ /* We have room, so output 'Infinity' */
+
memcpy(p + nb - 8, "Infinity", 8);
else
+
+ /* For the case of width equals 8, there is not enough room
+ 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;
+ p[nb - 4] = fin; /* Put the sign in front of Inf */
else if (nb > 8)
- p[nb - 9] = fin;
+ p[nb - 9] = fin; /* Put the sign in front of Infinity */
}
else
memcpy(p + nb - 3, "NaN", 3);