This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, libfortran] Fix PR 34887, regression vs. g77


Hello world,

the attached patch fixes PR 34887, a regression vs. g77.  Thanks to
Jerry for confiming that I was looking at the right place.

Regression-tested on i686-pc-linux-gnu.  OK for trunk?

We've been ambivalent about fixing regressions vs. g77 during a
regression-only phase in the past.  IMHO, this patch is simple
enough so that we can risk a commit, but I don't feel strongly
about this.  I'll leave the date of commit to the reviewer.

	Thomas

2008-01-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfofortran/34887
	* io/transfer.c (next_record_w): Always move to the farthest
	position when completing the record (also when we are
	processing a slash edit descriptor).

2008-01-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfofortran/34887
	* gfortran.dg/x_slash_2.f:  New test.

Index: transfer.c
===================================================================
--- transfer.c	(revision 131679)
+++ transfer.c	(working copy)
@@ -2560,21 +2560,18 @@ next_record_w (st_parameter_dt *dtp, int
 	}
       else
 	{
-	  /* If this is the last call to next_record move to the farthest
-	  position reached in preparation for completing the record.
-	  (for file unit) */
-	  if (done)
-	    {
-	      m = dtp->u.p.current_unit->recl -
-			dtp->u.p.current_unit->bytes_left;
-	      if (max_pos > m)
-		{
-		  length = (int) (max_pos - m);
-		  p = salloc_w (dtp->u.p.current_unit->s, &length);
-		}
- 	    }
 	  size_t len;
 	  const char crlf[] = "\r\n";
+
+	  /* Move to the farthest position reached in preparation for
+	  completing the record.  (for file unit) */
+	  m = dtp->u.p.current_unit->recl -
+	    dtp->u.p.current_unit->bytes_left;
+	  if (max_pos > m)
+	    {
+	      length = (int) (max_pos - m);
+	      p = salloc_w (dtp->u.p.current_unit->s, &length);
+	    }
 #ifdef HAVE_CRLF
 	  len = 2;
 #else
! { dg-do run }
! PR 34887 - reverse tabs followed by a slash used to confuse I/O.
      program main
      character(len=2) :: b, a
      open(10,form="formatted")
      write (10,'(3X, A, T1, A,/)') 'aa', 'bb'
      rewind(10)
      read (10,'(A2,1X,A2)') b,a
      if (a /= 'aa' .or. b /= 'bb') call abort
      close(10,status="delete")
      end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]