Mainline vs 4.0 Branch, IEEE exceptionals
Jerry DeLisle
jvdelisle@verizon.net
Sun Jul 24 03:08:00 GMT 2005
Gads, I think we are cobbled up (out of sync). In the process of
preparing to commit IEEE exceptions to 4.0 branch I could not get a
clean diff between write.c in mainline and write.c in 4.0. I can do a
copy paste of just the write_float function that I changed from mainline
to 4.0 or we could just port the whole file over from mainline.
I will try the copy of write_float function and regtest. It looks like
some of FX (?) fixups for large numbers have not been put over to 4.0.
Here is a diff after I copy just the function over to my 4.0 branch.
Notice the use of GFC_REAL_LARGEST in mainline, but not in 4.0 yet.
This is outside of my changes.
I could also just apply the changes to the portions of write.c that I
changed, but that still leaves us out of sync.
I will hold on committing anything to 4.0 until further instructed.
Jerry
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.23.2.10
diff -c -3 -p -r1.23.2.10 write.c
*** write.c 14 Jul 2005 17:17:14 -0000 1.23.2.10
--- write.c 24 Jul 2005 02:41:59 -0000
*************** write_l (fnode * f, char *source, int le
*** 689,695 ****
static void
write_float (fnode *f, const char *source, int len)
{
! double n;
int nb =0, res, save_scale_factor;
char * p, fin;
fnode *f2 = NULL;
--- 689,695 ----
static void
write_float (fnode *f, const char *source, int len)
{
! GFC_REAL_LARGEST n;
int nb =0, res, save_scale_factor;
char * p, fin;
fnode *f2 = NULL;
*************** write_float (fnode *f, const char *sourc
*** 698,707 ****
if (f->format != FMT_B && f->format != FMT_O && f->format != FMT_Z)
{
! res = isfinite (n);
if (res == 0)
{
nb = f->u.real.w;
p = write_block (nb);
if (nb < 3)
{
--- 698,715 ----
if (f->format != FMT_B && f->format != FMT_O && f->format != FMT_Z)
{
! /* TODO: there are some systems where isfinite is not able to work
! with long double variables. We should detect this case and
! provide our own version for isfinite. */
! res = isfinite (n);
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)
{
*************** write_float (fnode *f, const char *sourc
*** 710,731 ****
}
memset(p, ' ', nb);
! res = !isnan (n);
if (res != 0)
{
! if (signbit(n))
! fin = '-';
else
! fin = '+';
!
! if (nb > 7)
! memcpy(p + nb - 8, "Infinity", 8);
else
memcpy(p + nb - 3, "Inf", 3);
! if (nb < 8 && nb > 3)
! p[nb - 4] = fin;
else if (nb > 8)
! p[nb - 9] = fin;
}
else
memcpy(p + nb - 3, "NaN", 3);
--- 718,764 ----
}
memset(p, ' ', nb);
! res = !isnan (n);
if (res != 0)
{
! if (signbit(n))
! {
!
! /* 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
!
! /* 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; /* Put the sign in front of Inf */
else if (nb > 8)
! p[nb - 9] = fin; /* Put the sign in front of Infinity */
}
else
memcpy(p + nb - 3, "NaN", 3);
*************** write_float (fnode *f, const char *sourc
*** 735,747 ****
if (f->format != FMT_G)
{
! output_float (f, n, 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);
--- 768,780 ----
if (f->format != FMT_G)
{
! output_float (f, n);
}
else
{
save_scale_factor = g.scale_factor;
! f2 = calculate_G_format(f, n, &nb);
! output_float (f2, n);
g.scale_factor = save_scale_factor;
if (f2 != NULL)
free_mem(f2);
More information about the Fortran
mailing list