aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2006-02-24 18:16:25 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2006-02-24 18:16:25 +0000
commitc5418dcb96ee2bdffa835d6e0f3adb617abb1822 (patch)
tree5e671113bd77714f30e86a5773c4f55f1480218f /libgfortran
parent69ca35491357cd22ed769ea202f3a7f32b9f599b (diff)
downloadgcc-c5418dcb96ee2bdffa835d6e0f3adb617abb1822.zip
gcc-c5418dcb96ee2bdffa835d6e0f3adb617abb1822.tar.gz
gcc-c5418dcb96ee2bdffa835d6e0f3adb617abb1822.tar.bz2
re PR libfortran/26423 (Error on binary I/O for large array)
2006-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/26423 * io/unix.c (fd_seek): Revert change from 25949. (fd_read): Same. (fd_write): Same. From-SVN: r111420
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/unix.c16
2 files changed, 17 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index f56bf57..a570af4 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2006-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/26423
+ * io/unix.c (fd_seek): Revert change from 25949.
+ (fd_read): Same.
+ (fd_write): Same.
+
2006-02-19 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* io/open.c (edit_modes): Correct abusive copy-pasting.
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 40ad2d8..1293b24 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -562,9 +562,15 @@ fd_sfree (unix_stream * s)
static try
fd_seek (unix_stream * s, gfc_offset offset)
{
- s->logical_offset = offset;
+ if (s->physical_offset == offset) /* Are we lucky and avoid syscall? */
+ {
+ s->logical_offset = offset;
+ return SUCCESS;
+ }
- return SUCCESS;
+ s->physical_offset = s->logical_offset = offset;
+
+ return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;
}
@@ -666,8 +672,7 @@ fd_read (unix_stream * s, void * buf, size_t * nbytes)
return errno;
}
- if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset
- && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
+ if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
{
*nbytes = 0;
return errno;
@@ -715,8 +720,7 @@ fd_write (unix_stream * s, const void * buf, size_t * nbytes)
return errno;
}
- if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset
- && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
+ if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
{
*nbytes = 0;
return errno;