This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[fortran] patch for PR 14334 - L edit descriptor broken
- From: Bud Davis <bdavis9659 at comcast dot net>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Feb 2004 12:30:52 -0600
- Subject: [fortran] patch for PR 14334 - L edit descriptor broken
The L edit descriptor was broken because the output string was being
used to decide to print 'T' or 'F'.
ChangeLog
2004-02-28 Bud Davis <bdavis9659@comcast.net>
* write.c (write_l): PR 14334-Use extract_int
for 'L' edit descriptor.
Here is a test case that checks L1 and L4, true and false, and
calls abort on error.
! PR 14334, L edit descriptor does not work
!
! this test uses L1 and L4 to print TRUE and FALSE
logical true,false
character*10 b
integer i
logical debug
debug = .FALSE.
true = .TRUE.
false = .FALSE.
b=''
write(b,'(L1)')true
if(debug)print*,'b=',b(1:1)
if (b(1:1).ne.'T') then
print*,'expected T got ',b(1:1),' fmt L1'
call abort
endif
write(b,'(L1)')false
if(debug)print*,'b=',b(1:1)
if (b(1:1).ne.'F') then
print*,'expected F got ',b(1:1),' fmt L1'
call abort
endif
write(b,'(L4)')true
if(debug)print*,'b=',b(1:4)
if (b(1:4).ne.' T') then
print*,'expected T got ',b(1:4),' fmt L4'
call abort
endif
write(b,'(L4)')false
if(debug)print*,'b=',b(1:4)
if (b(1:4).ne.' F') then
print*,'expected F got ',b(1:4),' fmt L4'
call abort
endif
end
No additional test suite failures. Tested i686/linux
Index: gcc/libgfortran/io/write.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/Attic/write.c,v
retrieving revision 1.1.2.7
diff -c -3 -p -r1.1.2.7 write.c
*** gcc/libgfortran/io/write.c 1 Jan 2004 13:57:04 -0000 1.1.2.7
--- gcc/libgfortran/io/write.c 28 Feb 2004 18:23:01 -0000
*************** write_a (fnode * f, const char *source,
*** 55,72 ****
}
}
-
- void
- write_l (fnode * f, char *p, int len)
- {
- p = write_block (f->u.w);
- if (p == NULL)
- return;
-
- memset (p, ' ', f->u.w - 1);
- p[f->u.w - 1] = *((int *) p) ? 'T' : 'F';
- }
-
static int64_t
extract_int (const void *p, int len)
{
--- 55,60 ----
*************** done:
*** 488,493 ****
--- 476,495 ----
return ;
}
+ void
+ write_l (fnode * f, char *source, int len)
+ {
+ char *p;
+ int64_t n;
+
+ p = write_block (f->u.w);
+ if (p == NULL)
+ return;
+
+ memset (p, ' ', f->u.w - 1);
+ n = extract_int (source, len);
+ p[f->u.w - 1] = (n) ? 'T' : 'F';
+ }
/* write_float() -- output a real number according to its format */