]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libfortran/31099 (Runtime error on legal code using RECL)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 9 Mar 2007 21:51:39 +0000 (21:51 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 9 Mar 2007 21:51:39 +0000 (21:51 +0000)
2007-03-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libgfortran/31099
* io/open.c (new_unit): Initialize bytes_left and recl_subrecord.
* io/transfer.c (next_record_w): Set bytes left to record length for
sequential unformatted I/O.
(next_record_r): Ditto.
(read_block_direct): Fix test for exceeding bytes_left.

From-SVN: r122763

libgfortran/ChangeLog
libgfortran/io/open.c
libgfortran/io/transfer.c

index 889a70d5fc8ddddaf44ed9c4d21660097b0e5c89..7f906581425308a24ab9a4c51e49a86bf5518b6e 100644 (file)
@@ -1,3 +1,12 @@
+2007-03-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/31099
+       * io/open.c (new_unit): Initialize bytes_left and recl_subrecord.
+       * io/transfer.c (next_record_w): Set bytes left to record length for
+       sequential unformatted I/O.
+       (next_record_r): Ditto.
+       (read_block_direct): Fix test for exceeding bytes_left.
+
 2007-03-08  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/30947
index ef1ce1e02282861d821a0d2ab0e10b25e4dd4dfd..783c5e84503fc9c32e6daba9af7e77479c892af1 100644 (file)
@@ -437,6 +437,8 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags)
     {
       u->flags.has_recl = 1;
       u->recl = opp->recl_in;
+      u->recl_subrecord = u->recl;
+      u->bytes_left = u->recl;
     }
   else
     {
index a7632da55ae913dbfad2be18fd9fc19b1e8f8aaf..42f824939427798c020efbc587514c88cc184557 100644 (file)
@@ -434,11 +434,10 @@ read_block_direct (st_parameter_dt *dtp, void *buf, size_t *nbytes)
 
   /* Check whether we exceed the total record length.  */
 
-  if (dtp->u.p.current_unit->flags.has_recl)
+  if (dtp->u.p.current_unit->flags.has_recl
+      && (*nbytes > (size_t) dtp->u.p.current_unit->bytes_left))
     {
-      to_read_record =
-       *nbytes > (size_t) dtp->u.p.current_unit->bytes_left ?
-       *nbytes : (size_t) dtp->u.p.current_unit->bytes_left;
+      to_read_record = (size_t) dtp->u.p.current_unit->bytes_left;
       short_record = 1;
     }
   else
@@ -2152,6 +2151,7 @@ next_record_r (st_parameter_dt *dtp)
     
     case UNFORMATTED_SEQUENTIAL:
       next_record_r_unf (dtp, 1);
+      dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl;
       break;
 
     case FORMATTED_DIRECT:
@@ -2377,6 +2377,7 @@ next_record_w (st_parameter_dt *dtp, int done)
 
     case UNFORMATTED_SEQUENTIAL:
       next_record_w_unf (dtp, 0);
+      dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl;
       break;
 
     case FORMATTED_STREAM: