[patch, libfortran] [4.4/4.5 Regression] changed BACKSPACE behaviour at end of file.
Jerry DeLisle
jvdelisle@verizon.net
Sun Jun 7 20:25:00 GMT 2009
Janne Blomqvist wrote:
> 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.
>
>
Sounds good Janne! I did think about using hit_eof when I came up with the
patch since I copied that chunk right out of hit_eof. It is probably better for
maintenance.
I decided to wait until I have time to look at the whole use of longjmp. Is
there any advantage or disadvantage to using longjmp? I did not see value in
doing both a longjmp and a call to hiteof().
Regards,
Jerry
More information about the Fortran
mailing list