This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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,libgfortran] PR31051 gfortran bug with x and t format descriptors.


:addpatch fortran:

Hi,

This one is not too bad. The attached patch adjusts position when in writing mode to account for pending spaces (1x). Regression tested and NIST tested on X86-64-Gnu/Linux.

OK for trunk?

This is strictly speaking a regression against g77. However, I don't feel too strong about it because there is no need really to do a T format preceded by spaces because the T format overrides anything the space does. If anyone else feels differently, let me know, since this could go to 4.2 under the rules.

I will work up the test case from the PR. (attached) I also attached a g77 version for those curious.

Regards,

Jerry

2007-03-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/31051
	* io/transfer.c (formatted_transfer_scalar): Adjust position for pending
	spaces when in writing mode.  Clean up some formatting.
Index: transfer.c
===================================================================
*** transfer.c	(revision 122763)
--- transfer.c	(working copy)
*************** formatted_transfer_scalar (st_parameter_
*** 1155,1161 ****
  	/* Format codes that don't transfer data.  */
  	case FMT_X:
  	case FMT_TR:
! 	  consume_data_flag = 0 ;
  
  	  pos = bytes_used + f->u.n + dtp->u.p.skips;
  	  dtp->u.p.skips = f->u.n + dtp->u.p.skips;
--- 1155,1161 ----
  	/* Format codes that don't transfer data.  */
  	case FMT_X:
  	case FMT_TR:
! 	  consume_data_flag = 0;
  
  	  pos = bytes_used + f->u.n + dtp->u.p.skips;
  	  dtp->u.p.skips = f->u.n + dtp->u.p.skips;
*************** formatted_transfer_scalar (st_parameter_
*** 1171,1176 ****
--- 1171,1177 ----
  	      write_x (dtp, dtp->u.p.skips, dtp->u.p.pending_spaces);
  	      dtp->u.p.skips = dtp->u.p.pending_spaces = 0;
  	    }
+ 
  	  if (dtp->u.p.mode == READING)
  	    read_x (dtp, f->u.n);
  
*************** formatted_transfer_scalar (st_parameter_
*** 1178,1183 ****
--- 1179,1186 ----
  
  	case FMT_TL:
  	case FMT_T:
+ 	  consume_data_flag = 0;
+ 
  	  if (f->format == FMT_TL)
  	    {
  
*************** formatted_transfer_scalar (st_parameter_
*** 1196,1203 ****
  	    }
  	  else /* FMT_T */
  	    {
! 	      consume_data_flag = 0;
! 	      pos = f->u.n - 1;
  	    }
  
  	  /* Standard 10.6.1.1: excessive left tabbing is reset to the
--- 1199,1208 ----
  	    }
  	  else /* FMT_T */
  	    {
! 	      if (dtp->u.p.mode == READING)
! 		pos = f->u.n - 1;
! 	      else
! 		pos = f->u.n - dtp->u.p.pending_spaces - 1;
  	    }
  
  	  /* Standard 10.6.1.1: excessive left tabbing is reset to the
program t
   integer, parameter :: N = 9
   character(len=40) :: fmt
   character(len=2), dimension(N) :: y

   y = 'a '
   fmt = '(a,1x,(t7, 3a))'
   write(*, fmt) 'xxxx', (y(i), i = 1,N)
end program t
      integer n,i
      character(len=40) :: fmt
      character(len=2):: y(9)
      do i=1,9
        y(i) = 'a '
      enddo
      fmt = '(a,1x,(t7, 3a))'
      write(*, fmt) 'xxxx', (y(i), i = 1,9)
      end

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