diff options
author | Bud Davis <bdavis9659@comcast.net> | 2004-06-12 12:50:54 +0000 |
---|---|---|
committer | Bud Davis <bdavis@gcc.gnu.org> | 2004-06-12 12:50:54 +0000 |
commit | 8204210bd612ade3760c5c9eec6d6b1368dee15b (patch) | |
tree | b352ec80ae8b4024e59c79a5dd8215afaac2ac8e /libgfortran/io | |
parent | 3d27dbd01aa4a707a4c179d6f4b12d2bce16d097 (diff) | |
download | gcc-8204210bd612ade3760c5c9eec6d6b1368dee15b.zip gcc-8204210bd612ade3760c5c9eec6d6b1368dee15b.tar.gz gcc-8204210bd612ade3760c5c9eec6d6b1368dee15b.tar.bz2 |
re PR libfortran/12839 (incorrect IO of Inf)
2004-06-12 Bud Davis <bdavis9659@comcast.net>
PR gfortran/12839
* gfortran.fortran-torture/execute/nan_inf_fmt.f90: New test.
* io/write.c(write_float): format inf and nan IAW F2003.
From-SVN: r83024
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/write.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 0719f88..e4f597c 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -515,11 +515,14 @@ write_float (fnode *f, const char *source, int len) if (res == 0) { nb = f->u.real.w; - if (nb <= 4) - nb = 4; p = write_block (nb); - memset (p, ' ' , 1); - + if (nb < 3) + { + memset (p, '*',nb); + return; + } + + memset(p, ' ', nb); res = isinf (n); if (res != 0) { @@ -527,11 +530,18 @@ write_float (fnode *f, const char *source, int len) fin = '+'; else fin = '-'; - - memset (p + 1, fin, nb - 1); + + if (nb > 7) + memcpy(p + nb - 8, "Infinity", 8); + else + memcpy(p + nb - 3, "Inf", 3); + if (nb < 8) + memset(p + nb - 4, fin, 1); + else if (nb > 8) + memset(p + nb - 9, fin, 1); } else - sprintf(p + 1, "NaN"); + memcpy(p + nb - 3, "NaN", 3); return; } } |