mirror of git://gcc.gnu.org/git/gcc.git
PR 49296 List directed read of string ending in EOF.
libgfortran ChangeLog entry: 2011-06-18 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/49296 * io/list_read.c (read_character): Accept EOF as a separator when reading string. testsuite ChangeLog entry: 2011-06-18 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/48296 * gfortran.dg/read_list_eof_1.f90: New test. From-SVN: r175166
This commit is contained in:
parent
c96b410243
commit
d3ff9ee468
|
@ -1,3 +1,8 @@
|
||||||
|
2011-06-18 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libfortran/48296
|
||||||
|
* gfortran.dg/read_list_eof_1.f90: New test.
|
||||||
|
|
||||||
2011-06-18 Jakub Jelinek <jakub@redhat.com>
|
2011-06-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR target/49411
|
PR target/49411
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
! { dg-do run }
|
||||||
|
! PR 49296 List formatted read of file without EOR marker (\n).
|
||||||
|
program read_list_eof_1
|
||||||
|
implicit none
|
||||||
|
character(len=100) :: s
|
||||||
|
call genfil ()
|
||||||
|
open (unit=20, file='read.dat', form='FORMATTED', action='READ', &
|
||||||
|
status='OLD')
|
||||||
|
read (20, fmt=*) s
|
||||||
|
close (20, status='delete')
|
||||||
|
if (trim(s) /= "a") then
|
||||||
|
call abort ()
|
||||||
|
end if
|
||||||
|
|
||||||
|
contains
|
||||||
|
subroutine genfil
|
||||||
|
open(10, file='read.dat', form='unformatted', action='write', &
|
||||||
|
status='replace', access='stream')
|
||||||
|
write(10) 'a'
|
||||||
|
close(10)
|
||||||
|
end subroutine genfil
|
||||||
|
end program read_list_eof_1
|
|
@ -1,3 +1,9 @@
|
||||||
|
2011-06-18 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libfortran/49296
|
||||||
|
* io/list_read.c (read_character): Accept EOF as a separator when
|
||||||
|
reading string.
|
||||||
|
|
||||||
2011-06-17 Daniel Carrera <dcarrera@gmail.com>
|
2011-06-17 Daniel Carrera <dcarrera@gmail.com>
|
||||||
|
|
||||||
* caf/single.c (_gfortran_caf_register): Store the address
|
* caf/single.c (_gfortran_caf_register): Store the address
|
||||||
|
|
|
@ -1022,7 +1022,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if ((c = next_char (dtp)) == EOF)
|
if ((c = next_char (dtp)) == EOF)
|
||||||
goto eof;
|
goto done_eof;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '"':
|
case '"':
|
||||||
|
@ -1068,26 +1068,26 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
|
||||||
invalid. */
|
invalid. */
|
||||||
done:
|
done:
|
||||||
c = next_char (dtp);
|
c = next_char (dtp);
|
||||||
eof:
|
done_eof:
|
||||||
if (is_separator (c) || c == '!')
|
if (is_separator (c) || c == '!' || c == EOF)
|
||||||
{
|
{
|
||||||
unget_char (dtp, c);
|
unget_char (dtp, c);
|
||||||
eat_separator (dtp);
|
eat_separator (dtp);
|
||||||
dtp->u.p.saved_type = BT_CHARACTER;
|
dtp->u.p.saved_type = BT_CHARACTER;
|
||||||
free_line (dtp);
|
free_line (dtp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free_saved (dtp);
|
free_saved (dtp);
|
||||||
if (c == EOF)
|
|
||||||
{
|
|
||||||
hit_eof (dtp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snprintf (message, MSGLEN, "Invalid string input in item %d",
|
snprintf (message, MSGLEN, "Invalid string input in item %d",
|
||||||
dtp->u.p.item_count);
|
dtp->u.p.item_count);
|
||||||
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
|
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
eof:
|
||||||
|
free_saved (dtp);
|
||||||
|
hit_eof (dtp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue