summaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-11 10:52:18 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-11 10:52:18 +0000
commitf22f0b38ad0198eec2c2a7d559fffd11ac224d7a (patch)
tree52efaae296e32e1cb15ce5aac3ccf45942fdb8fe /libgfortran/io
parent9bfd25a7df9b8143fda651de2a4f9622cbae595c (diff)
downloadgcc-f22f0b38ad0198eec2c2a7d559fffd11ac224d7a.tar.gz
Return error when trying to seek a non-seekable buffered file
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174947 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/unix.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index e3ae6072290..25cb559db01 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -560,6 +560,11 @@ buf_write (unix_stream * s, const void * buf, ssize_t nbyte)
static gfc_offset
buf_seek (unix_stream * s, gfc_offset offset, int whence)
{
+ if (s->file_length == -1)
+ {
+ errno = ESPIPE;
+ return -1;
+ }
switch (whence)
{
case SEEK_SET:
@@ -585,7 +590,7 @@ buf_seek (unix_stream * s, gfc_offset offset, int whence)
static gfc_offset
buf_tell (unix_stream * s)
{
- return s->logical_offset;
+ return buf_seek (s, 0, SEEK_CUR);
}
static int