diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-02 06:22:23 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-02 06:22:23 +0000 |
commit | 38350e3b3f88c7ab07a867b5d34d6c74d28a3d06 (patch) | |
tree | b7882064a4e558562d0f7321b64b8535c9f23143 /libgfortran/io | |
parent | bd1c90cadf7595ecdfe5eabc7b3aa469f989258e (diff) | |
download | gcc-38350e3b3f88c7ab07a867b5d34d6c74d28a3d06.tar.gz |
Don't update the position flag for non-seekable files, check for stell() error.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162810 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/unit.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index a0018dbb4f7..1d522172635 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -714,12 +714,19 @@ close_units (void) void update_position (gfc_unit *u) { - if (stell (u->s) == 0) - u->flags.position = POSITION_REWIND; - else if (file_length (u->s) == stell (u->s)) - u->flags.position = POSITION_APPEND; - else - u->flags.position = POSITION_ASIS; + /* If unit is not seekable, this makes no sense (and the standard is + silent on this matter), and thus we don't change the position for + a non-seekable file. */ + if (is_seekable (u->s)) + { + gfc_offset cur = stell (u->s); + if (cur == 0) + u->flags.position = POSITION_REWIND; + else if (cur != -1 && (file_length (u->s) == cur)) + u->flags.position = POSITION_APPEND; + else + u->flags.position = POSITION_ASIS; + } } |