* io/transfer.c (read_sf): Call fbuf_getptr only at the end,
and subtract n, dtp->u.p.sf_seen_eor and seen_comma from it.
* gfortran.dg/pr47878.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170476
138bc75d-0d04-0410-961f-
82ee72b054a4
+2011-02-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/47878
+ * gfortran.dg/pr47878.f90: New test.
+
2011-02-24 Richard Guenther <rguenther@suse.de>
PR testsuite/47801
2011-02-24 Richard Guenther <rguenther@suse.de>
PR testsuite/47801
--- /dev/null
+! PR fortran/47878
+! { dg-do run }
+ integer :: a(5)
+ open (99, recl = 40)
+ write (99, '(5i3)') 1, 2, 3
+ rewind (99)
+ read (99, '(5i3)') a
+ if (any (a.ne.(/1, 2, 3, 0, 0/))) call abort
+ close (99, status = 'delete')
+end
+2011-02-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/47878
+ * io/transfer.c (read_sf): Call fbuf_getptr only at the end,
+ and subtract n, dtp->u.p.sf_seen_eor and seen_comma from it.
+
2011-02-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
2011-02-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Andy Vaught
Namelist transfer functions contributed by Paul Thomas
Free Software Foundation, Inc.
Contributed by Andy Vaught
Namelist transfer functions contributed by Paul Thomas
read_sf (st_parameter_dt *dtp, int * length)
{
static char *empty_string[0];
read_sf (st_parameter_dt *dtp, int * length)
{
static char *empty_string[0];
int q, q2;
int n, lorig, seen_comma;
int q, q2;
int n, lorig, seen_comma;
/* Read data into format buffer and scan through it. */
lorig = *length;
/* Read data into format buffer and scan through it. */
lorig = *length;
- base = fbuf_getptr (dtp->u.p.current_unit);
- if (base == NULL)
- return NULL;
if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
dtp->u.p.size_used += (GFC_IO_INT) n;
if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
dtp->u.p.size_used += (GFC_IO_INT) n;
+ /* We can't call fbuf_getptr before the loop doing fbuf_getc, because
+ fbuf_getc might reallocate the buffer. So return current pointer
+ minus all the advances, which is n plus up to two characters
+ of newline or comma. */
+ return fbuf_getptr (dtp->u.p.current_unit)
+ - n - dtp->u.p.sf_seen_eor - seen_comma;