diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2010-04-01 19:22:57 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2010-04-01 19:22:57 +0300 |
commit | e76a3fde81380ce422994e1a0fb21322d2268341 (patch) | |
tree | e8d9448ab70a3f19bbb9217f201b291d412f9203 | |
parent | 5e9fb3dbde748212ff0b025dcf196da9b086b1c4 (diff) | |
download | gcc-e76a3fde81380ce422994e1a0fb21322d2268341.zip gcc-e76a3fde81380ce422994e1a0fb21322d2268341.tar.gz gcc-e76a3fde81380ce422994e1a0fb21322d2268341.tar.bz2 |
PR libfortran/43605 Fix FTELL for formatted files
Co-Authored-By: Manfred Schwarb <manfred99@gmx.ch>
From-SVN: r157914
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/ftell_3.f90 | 19 | ||||
-rw-r--r-- | libgfortran/ChangeLog | 6 | ||||
-rw-r--r-- | libgfortran/io/intrinsics.c | 10 |
4 files changed, 36 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c182186..8c48a0b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/testsuite/gfortran.dg/ftell_3.f90 b/gcc/testsuite/gfortran.dg/ftell_3.f90 new file mode 100644 index 0000000..1981678 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ftell_3.f90 @@ -0,0 +1,19 @@ +! { 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 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2385b64..495683c 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/libgfortran/io/intrinsics.c b/libgfortran/io/intrinsics.c index 9428b75..4beb013 100644 --- a/libgfortran/io/intrinsics.c +++ b/libgfortran/io/intrinsics.c @@ -1,8 +1,8 @@ /* 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 @@ -267,10 +267,10 @@ size_t 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; } @@ -286,7 +286,7 @@ PREFIX(ftell) (int * unit) *offset = -1; \ else \ { \ - *offset = stell (u->s); \ + *offset = stell (u->s) + fbuf_reset (u); \ unlock_unit (u); \ } \ } |