diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2010-08-02 09:22:23 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2010-08-02 09:22:23 +0300 |
commit | 35713675572db7b845a85240329235520195ff49 (patch) | |
tree | b7882064a4e558562d0f7321b64b8535c9f23143 /libgfortran | |
parent | 0093ddee9684ad9df246c464c97114f9aaa27c2b (diff) | |
download | gcc-35713675572db7b845a85240329235520195ff49.zip gcc-35713675572db7b845a85240329235520195ff49.tar.gz gcc-35713675572db7b845a85240329235520195ff49.tar.bz2 |
Don't update the position flag for non-seekable files, check for stell() error.
From-SVN: r162810
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 5 | ||||
-rw-r--r-- | libgfortran/io/unit.c | 19 |
2 files changed, 18 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index f11ede9..700cb60 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2010-08-02 Janne Blomqvist <jb@gcc.gnu.org> + + * io/unit.c (update_position): Don't update the position flag for + non-seekable files, check for stell() error. + 2010-08-01 Janne Blomqvist <jb@gcc.gnu.org> * io/unix.c (file_exists): Use access(2) instead of stat(2) to diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index a0018db..1d52217 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; + } } |