From: Janne Blomqvist <blomqvist.janne@gmail.com>
To: Fortran List <fortran@gcc.gnu.org>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, libfortran] PR 49296 List read of file without EOR
Date: Sat, 11 Jun 2011 10:22:00 -0000 [thread overview]
Message-ID: <BANLkTi=aX=B9tDAQVtVc_bB43CxsY4aJdw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 312 bytes --]
Hi,
attached patch fixes PR 49296. A new test for the testsuite is also included.
Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
2011-06-11 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/49296
* io/list_read.c (read_character): Accept EOF as a separator when
reading string.
--
Janne Blomqvist
[-- Attachment #2: read_list_eof.diff --]
[-- Type: text/x-patch, Size: 1123 bytes --]
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 38a92e1..baf2f54 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1022,7 +1022,7 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
for (;;)
{
if ((c = next_char (dtp)) == EOF)
- goto eof;
+ goto done_eof;
switch (c)
{
case '"':
@@ -1068,26 +1068,26 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
invalid. */
done:
c = next_char (dtp);
- eof:
- if (is_separator (c) || c == '!')
+ done_eof:
+ if (is_separator (c) || c == '!' || c == EOF)
{
unget_char (dtp, c);
eat_separator (dtp);
dtp->u.p.saved_type = BT_CHARACTER;
free_line (dtp);
}
- else
+ else
{
free_saved (dtp);
- if (c == EOF)
- {
- hit_eof (dtp);
- return;
- }
snprintf (message, MSGLEN, "Invalid string input in item %d",
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
}
+ return;
+
+ eof:
+ free_saved (dtp);
+ hit_eof (dtp);
}
[-- Attachment #3: read_list_eof_1.f90 --]
[-- Type: text/x-fortran, Size: 669 bytes --]
! { dg-do run }
! PR 49296 List formatted read of file without EOR marker (\n).
program read_list_eof_1
implicit none
integer, parameter :: strmx = 255
character(len=strmx) :: s1, s2
call genfil ()
open (unit=20, file='read.dat', form='FORMATTED', action='READ', &
status='OLD')
read (20, fmt=*) s1, s2
close (20, status='delete')
if (trim(s1) /= "abcd" .or. trim(s2) /= "efgh") then
call abort ()
end if
contains
subroutine genfil
open(10, file='read.dat', form='unformatted', action='write', &
status='replace', access='stream')
write(10) 'abcd efgh'
close(10)
end subroutine genfil
end program read_list_eof_1
next reply other threads:[~2011-06-11 10:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 10:22 Janne Blomqvist [this message]
2011-06-17 19:24 ` Janne Blomqvist
2011-06-18 1:29 ` jerry DeLisle
2011-07-03 21:57 Janne Blomqvist
2011-07-12 9:05 ` Janne Blomqvist
2011-07-12 12:32 ` Jerry DeLisle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTi=aX=B9tDAQVtVc_bB43CxsY4aJdw@mail.gmail.com' \
--to=blomqvist.janne@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).