+2010-04-01 Janne Blomqvist <jb@gcc.gnu.org>
+ Manfred Schwarb <manfred99@gmx.ch>
+
+ PR libfortran/43605
+ * gfortran.dg/ftell_3.f90: New test.
+
2010-04-01 Richard Guenther <rguenther@suse.de>
PR middle-end/43614
--- /dev/null
+! { dg-do run }
+! PR43605 FTELL intrinsic returns incorrect position
+! Contributed by Janne Blomqvist and Manfred Schwarb
+program ftell_3
+ integer :: i
+ character(len=99) :: buffer
+ open(10, form='formatted', status='scratch', position='rewind')
+ write(10, '(a)') '123456'
+ write(10, '(a)') '789'
+ write(10, '(a)') 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
+ write(10, '(a)') 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'
+ rewind(10)
+ read(10, '(a)') buffer
+ call ftell(10, i)
+ if(i /= 7) then
+ call abort()
+ end if
+ close(10)
+end program ftell_3
+2010-04-01 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/43605
+ * io/intrinsics.c (ftell): Reset fbuf, correct offset.
+ (FTELL_SUB): Likewise.
+
2010-03-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/43265
/* Implementation of the FGET, FGETC, FPUT, FPUTC, FLUSH
FTELL, TTYNAM and ISATTY intrinsics.
- Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
Libgfortran is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
PREFIX(ftell) (int * unit)
{
gfc_unit * u = find_unit (*unit);
- size_t ret;
+ gfc_offset ret;
if (u == NULL)
return ((size_t) -1);
- ret = (size_t) stell (u->s);
+ ret = stell (u->s) + fbuf_reset (u);
unlock_unit (u);
return ret;
}
*offset = -1; \
else \
{ \
- *offset = stell (u->s); \
+ *offset = stell (u->s) + fbuf_reset (u); \
unlock_unit (u); \
} \
}