diff options
author | dfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-04 18:02:18 +0000 |
---|---|---|
committer | dfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-04 18:02:18 +0000 |
commit | 7d86687017fb9bfa58571cfc46f786f539ba2601 (patch) | |
tree | f5fbb8c905ad4fe8db79b23d98f6fdde28648680 /libgfortran | |
parent | 71ac9b47b872934e8d78ff35882d69f845545fbd (diff) | |
download | gcc-7d86687017fb9bfa58571cfc46f786f539ba2601.tar.gz |
gcc/fortran:
2007-05-04 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539
* intrinsic.c (add_subroutines): Added FSEEK.
* intrinsic.h (gfc_resolve_fseek_sub, gfc_check_fseek_sub): New.
* iresolve.c (gfc_resolve_fseek_sub): New.
* check.c (gfc_check_fseek_sub): New.
* intrinsic.texi (FSEEK): Updated.
gcc/testsuite:
2007-05-01 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539
* gfortran.dg/fseek.f90: New test.
libgfortran:
2007-05-04 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539
* io/intrinsics.c (fseek_sub): New.
* io/unix.c (fd_fseek): Change logical and physical offsets only
if seek succeeds.
* gfortran.map (fseek_sub): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124437 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 8 | ||||
-rw-r--r-- | libgfortran/gfortran.map | 1 | ||||
-rw-r--r-- | libgfortran/io/intrinsics.c | 28 | ||||
-rw-r--r-- | libgfortran/io/unix.c | 10 |
4 files changed, 44 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 52f15066293..806b17d1d95 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2007-05-04 Daniel Franke <franke.daniel@gmail.com> + + PR fortran/22539 + * io/intrinsics.c (fseek_sub): New. + * io/unix.c (fd_fseek): Change logical and physical offsets only + if seek succeeds. + * gfortran.map (fseek_sub): New. + 2007-05-04 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR libfortran/31210 diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map index 830651f87eb..19b458b7b64 100644 --- a/libgfortran/gfortran.map +++ b/libgfortran/gfortran.map @@ -128,6 +128,7 @@ GFORTRAN_1.0 { _gfortran_fraction_r4; _gfortran_fraction_r8; _gfortran_free; + _gfortran_fseek_sub; _gfortran_fstat_i4; _gfortran_fstat_i4_sub; _gfortran_fstat_i8; diff --git a/libgfortran/io/intrinsics.c b/libgfortran/io/intrinsics.c index ab99b25e5a5..2402f486926 100644 --- a/libgfortran/io/intrinsics.c +++ b/libgfortran/io/intrinsics.c @@ -228,6 +228,34 @@ flush_i8 (GFC_INTEGER_8 *unit) } } +/* FSEEK intrinsic */ + +extern void fseek_sub (int *, GFC_IO_INT *, int *, int *); +export_proto(fseek_sub); + +void +fseek_sub (int * unit, GFC_IO_INT * offset, int * whence, int * status) +{ + gfc_unit * u = find_unit (*unit); + try result = FAILURE; + + if (u != NULL && is_seekable(u->s)) + { + if (*whence == 0) + result = sseek(u->s, *offset); /* SEEK_SET */ + else if (*whence == 1) + result = sseek(u->s, file_position(u->s) + *offset); /* SEEK_CUR */ + else if (*whence == 2) + result = sseek(u->s, file_length(u->s) + *offset); /* SEEK_END */ + + unlock_unit (u); + } + + if (status) + *status = (result == FAILURE ? -1 : 0); +} + + /* FTELL intrinsic */ diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 458983c4595..cdac0d7dfdd 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -601,10 +601,14 @@ fd_seek (unix_stream * s, gfc_offset offset) return SUCCESS; } - s->physical_offset = s->logical_offset = offset; - s->active = 0; + if (lseek (s->fd, offset, SEEK_SET) >= 0) + { + s->physical_offset = s->logical_offset = offset; + s->active = 0; + return SUCCESS; + } - return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS; + return FAILURE; } |