re PR libfortran/34974 (null bytes when reverse-tabbing long records (regression...
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 21 Feb 2008 02:33:17 +0000 (02:33 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 21 Feb 2008 02:33:17 +0000 (02:33 +0000)
2008-02-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libfortran/34974
* gfortran.dg/fmt_t_7.f: New test.

PR libfortran/35132
* gfortran.dg/streamio_15.f90: New test.

From-SVN: r132513

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/fmt_t_7.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/streamio_15.f90 [new file with mode: 0644]

index 764f99fb7561b2098e58281d0da30e722f63d2c1..91306f0822bb29bdd95ca6cf0a36e8b0a44258c3 100644 (file)
@@ -1,3 +1,11 @@
+2008-02-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       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  <jvdelisle@gcc.gnu.org>
 
        PR libfortran/35036
diff --git a/gcc/testsuite/gfortran.dg/fmt_t_7.f b/gcc/testsuite/gfortran.dg/fmt_t_7.f
new file mode 100644 (file)
index 0000000..443cd2f
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }\r
+! PR34974 null bytes when reverse-tabbing long records\r
+! Test case prpared by Jerry DeLisle <jvdelisle@gcc.gnu.org>\r
+       program test\r
+       character(1) :: a, b, c\r
+       write (10,'(t50000,a,t1,a)') 'b', 'a'\r
+       close (10)\r
+       open (10, access="stream")\r
+       read (10, pos=1) a\r
+       read (10, pos=50000) b\r
+       read (10, pos=25474) c\r
+       close (10, status="delete")\r
+       if (a /= "a") call abort\r
+       if (b /= "b") call abort\r
+       if (c /= " ") call abort\r
+       end\r
diff --git a/gcc/testsuite/gfortran.dg/streamio_15.f90 b/gcc/testsuite/gfortran.dg/streamio_15.f90
new file mode 100644 (file)
index 0000000..4d1638e
--- /dev/null
@@ -0,0 +1,37 @@
+! { dg-do run }
+! PR35132 Formatted stream I/O write should truncate.
+! Test case adapted from PR by Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+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