re PR libfortran/14897 ('T' edit descriptor output incorrect)
authorBud Davis <bdavis@gcc.gnu.org>
Wed, 9 Jun 2004 01:03:02 +0000 (01:03 +0000)
committerBud Davis <bdavis@gcc.gnu.org>
Wed, 9 Jun 2004 01:03:02 +0000 (01:03 +0000)
2004-06-09  Bud Davis  <bdavis9659@comcast.net>

PR gfortran/14897
* gfortran.fortran-torture/execute/t_edit.f90

  * io/transfer.c (formatted_transfer): position is unique
         for T and TL edit descriptors.
  (data_transfer_init): set record length to size of internal
         file.

From-SVN: r82808

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/t_edit.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/transfer.c

index 00f5518815af35d5067a8eea676b4621b0db4c19..d726cf08f69cbf487d6a367b5e7501b2c6bde1f2 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-09  Bud Davis  <bdavis9659@comcast.net>
+
+       PR gfortran/14897
+       * gfortran.fortran-torture/execute/t_edit.f90
+
 2004-06-09  Bud Davis  <bdavis9659@comcast.net>
                                                                                     
         PR gfortran/15755
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/t_edit.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/t_edit.f90
new file mode 100644 (file)
index 0000000..9746f31
--- /dev/null
@@ -0,0 +1,11 @@
+!pr 14897  T edit descriptor broken
+      implicit none
+      character*80 line
+      WRITE(line,'(T5,A,T10,A,T15,A)')'AA','BB','CC'
+      if (line.ne.'    AA   BB   CC    ') call abort
+      WRITE(line,'(5HAAAAA,TL4,4HABCD)')
+      if (line.ne.'AABCD') call abort
+      END
+
+
+
index ab7d37633db876d8427bd7db0a2fffd7392c716d..e9f17ee05bd24d98e8ecd75d5e6088fbb883ace9 100644 (file)
@@ -1,3 +1,11 @@
+2004-06-09  Bud Davis  <bdavis9659@comcaste.net>
+
+       PR gfortran/14897
+       * io/transfer.c (formatted_transfer): position is unique
+         for T and TL edit descriptors.
+       (data_transfer_init): set record length to size of internal
+         file.
+
 2004-06-09  Bud Davis  <bdavis9659@comcast.net>
 
        PR gfortran/15755
index d5ef5c68d7fd03723841bec5e032d8222715ce1d..04b7c5a7ac23c3c7cddd9e19d5c12309085e2734 100644 (file)
@@ -608,14 +608,18 @@ formatted_transfer (bt type, void *p, int len)
 
          break;
 
-        case FMT_T:
-           pos = f->u.n ;
-           pos= current_unit->recl - current_unit->bytes_left - pos;
-                         /* fall through */
-
         case FMT_TL:
-           consume_data_flag = 0 ;
-           pos = f->u.n ;
+        case FMT_T:
+           if (f->format==FMT_TL)
+             {
+                pos = f->u.n ;
+                pos= current_unit->recl - current_unit->bytes_left - pos;
+             }
+           else // FMT==T
+             {
+                consume_data_flag = 0 ;
+                pos = f->u.n - 1; 
+             }
 
            if (pos < 0 || pos >= current_unit->recl )
            {
@@ -898,8 +902,12 @@ data_transfer_init (int read_flag)
   if (current_unit == NULL)
     return;
 
-  if (is_internal_unit() && g.mode==WRITING)
-    empty_internal_buffer (current_unit->s);
+  if (is_internal_unit())
+    {
+      current_unit->recl = file_length(current_unit->s);
+      if (g.mode==WRITING)
+        empty_internal_buffer (current_unit->s);
+    }
 
   /* Check the action */