mirror of git://gcc.gnu.org/git/gcc.git
Return error when trying to seek a non-seekable buffered file
From-SVN: r174947
This commit is contained in:
parent
5ea0705af7
commit
09ad57ec8f
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-06-11 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
|
* io/unix.c (buf_seek): Return error if file is not seekable.
|
||||||
|
(buf_tell): Call buf_seek.
|
||||||
|
|
||||||
2011-06-11 Janne Blomqvist <jb@gcc.gnu.org>
|
2011-06-11 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
* io/unix.c (fd_to_stream): Figure out if a fd is seekable by
|
* io/unix.c (fd_to_stream): Figure out if a fd is seekable by
|
||||||
|
|
|
||||||
|
|
@ -560,6 +560,11 @@ buf_write (unix_stream * s, const void * buf, ssize_t nbyte)
|
||||||
static gfc_offset
|
static gfc_offset
|
||||||
buf_seek (unix_stream * s, gfc_offset offset, int whence)
|
buf_seek (unix_stream * s, gfc_offset offset, int whence)
|
||||||
{
|
{
|
||||||
|
if (s->file_length == -1)
|
||||||
|
{
|
||||||
|
errno = ESPIPE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
switch (whence)
|
switch (whence)
|
||||||
{
|
{
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
|
|
@ -585,7 +590,7 @@ buf_seek (unix_stream * s, gfc_offset offset, int whence)
|
||||||
static gfc_offset
|
static gfc_offset
|
||||||
buf_tell (unix_stream * s)
|
buf_tell (unix_stream * s)
|
||||||
{
|
{
|
||||||
return s->logical_offset;
|
return buf_seek (s, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue