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]

Re: [patch, libfortran] [4.4/4.5 Regression] changed BACKSPACE behaviour at end of file.


On Sun, Jun 7, 2009 at 12:25, Tobias Burnus<burnus@net-b.de> wrote:
> Jerry DeLisle wrote:
>> The following patch fixes this regression.
>> Regression tested and NIST tested on x86-64.
>> OK for trunk and 4.4.1? (with ChangeLog and a test case of course)
> Looks OK. Thanks.
>
> Tobias
>
>> Index: list_read.c
>> ===================================================================
>> --- list_read.c ? ?(revision 147996)
>> +++ list_read.c ? ?(working copy)
>> @@ -1687,6 +1687,11 @@ list_formatted_read_scalar (st_parameter
>> ? ?if (setjmp (eof_jump))
>> ? ? ?{
>> ? ? ? ?generate_error (&dtp->common, LIBERROR_END, NULL);
>> + ? ?if (!is_internal_unit (dtp))
>> + ? ? ?{
>> + ? ? ? ?dtp->u.p.current_unit->endfile = AFTER_ENDFILE;
>> + ? ? ? ?dtp->u.p.current_unit->current_record = 0;
>> + ? ? ?}
>> ? ? ? ?goto cleanup;
>> ? ? ?}

FWIW, we have the hit_eof() function so that we don't have to
duplicate EOF handling all over the place. Based on a quick look, a
call to hit_eof() could replace the generate_error call as well as all
the added lines in the patch above.

Secondly, I made a proper dejagnu testcase out of the test in the PR,
backspace_11.f90:

! { dg-do run }
! PR 40334 backspace regression
program backspace_11
  implicit none
  character(len=5) :: str
  open(10, access='sequential', status='scratch')
  write(10,'(A)')'HELLO'
  rewind(10)

  do
     read(10,'(A)',end=1) str
  enddo
1 backspace 10
  !the file pointer is now at EOF

  read(10,*,end=2) str
  call abort
2 backspace 10
  !the file pointer is now at EOF

  read(10,'(A)',end=3) str
  call abort
3 continue
end program backspace_11


I'll commit it as obvious when I'll get back home to my usual
development machine, unless somebody objects.


-- 
Janne Blomqvist


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