From b194358018f737bca23084dd5d1a2834783a6f1a Mon Sep 17 00:00:00 2001 From: jvdelisle Date: Thu, 21 Feb 2008 02:33:17 +0000 Subject: [PATCH 1/1] 2008-02-20 Jerry DeLisle PR libfortran/34974 * gfortran.dg/fmt_t_7.f: New test. PR libfortran/35132 * gfortran.dg/streamio_15.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132513 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gfortran.dg/fmt_t_7.f | 16 +++++++++++++ gcc/testsuite/gfortran.dg/streamio_15.f90 | 37 +++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/fmt_t_7.f create mode 100644 gcc/testsuite/gfortran.dg/streamio_15.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 764f99fb756..91306f0822b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2008-02-20 Jerry DeLisle + PR libfortran/34974 + * gfortran.dg/fmt_t_7.f: New test. + + PR libfortran/35132 + * gfortran.dg/streamio_15.f90: New test. + +2008-02-20 Jerry DeLisle + PR libfortran/35036 * gfortran.dg/fmt_zero_digits.f90: Revise test. diff --git a/gcc/testsuite/gfortran.dg/fmt_t_7.f b/gcc/testsuite/gfortran.dg/fmt_t_7.f new file mode 100644 index 00000000000..443cd2f2d55 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/fmt_t_7.f @@ -0,0 +1,16 @@ +! { dg-do run } +! PR34974 null bytes when reverse-tabbing long records +! Test case prpared by Jerry DeLisle + program test + character(1) :: a, b, c + write (10,'(t50000,a,t1,a)') 'b', 'a' + close (10) + open (10, access="stream") + read (10, pos=1) a + read (10, pos=50000) b + read (10, pos=25474) c + close (10, status="delete") + if (a /= "a") call abort + if (b /= "b") call abort + if (c /= " ") call abort + end diff --git a/gcc/testsuite/gfortran.dg/streamio_15.f90 b/gcc/testsuite/gfortran.dg/streamio_15.f90 new file mode 100644 index 00000000000..4d1638e561a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/streamio_15.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! PR35132 Formatted stream I/O write should truncate. +! Test case adapted from PR by Jerry DeLisle +program main + implicit none + character(len=6) :: c + integer :: i + open(20,file="foo.txt",form="formatted",access="stream") + write(20,'(A)') '123456' + write(20,'(A)') 'abcdef' + write(20,'(A)') 'qwerty' + rewind 20 + ! Skip over the first line + read(20,'(A)') c + if (c.ne.'123456') call abort + ! Save the position + inquire(20,pos=i) + if (i.ne.8) call abort + ! Read in the complete line... + read(20,'(A)') c + if (c.ne.'abcdef') call abort + ! Write out the first four characters + write(20,'(A)',pos=i,advance="no") 'ASDF' + ! Fill up the rest of the line. Here, we know the length. If we + ! don't, things will be a bit more complicated. + write(20,'(A)') c(5:6) + ! Copy the file to standard output + rewind 20 + c = "" + read(20,'(A)') c + if (c.ne.'123456') call abort + read(20,'(A)') c + if (c.ne.'ASDFef') call abort + read(20,'(A)', iostat=i) c + if (i /= -1) call abort + close (20, status="delete") +end program main -- 2.11.0