diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2013-02-21 21:03:10 +0200 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2013-02-21 21:03:10 +0200 |
commit | 68aab0e225dbafdaa8115092b0ed829ab5c9d161 (patch) | |
tree | 26f483a5c4fc248264b7e8d76bab4ca11eb5159a /libgfortran/io | |
parent | a4a66330d53ed57deec63c7f1018d5e52c92ca4c (diff) | |
download | gcc-68aab0e225dbafdaa8115092b0ed829ab5c9d161.zip gcc-68aab0e225dbafdaa8115092b0ed829ab5c9d161.tar.gz gcc-68aab0e225dbafdaa8115092b0ed829ab5c9d161.tar.bz2 |
Fix regression when writing formatted sequential to a pipe.
2013-02-21 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/30162
* io/open.c (test_endfile): Call stell only if size != 0.
* io/unix.c (raw_tell): Revert r194679.
(raw_size): Return size field only for regular files, otherwise 0.
From-SVN: r196210
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/open.c | 8 | ||||
-rw-r--r-- | libgfortran/io/unix.c | 15 |
2 files changed, 11 insertions, 12 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 2895767..d9cfde8 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -152,8 +152,12 @@ static const st_option async_opt[] = static void test_endfile (gfc_unit * u) { - if (u->endfile == NO_ENDFILE && ssize (u->s) == stell (u->s)) - u->endfile = AT_ENDFILE; + if (u->endfile == NO_ENDFILE) + { + gfc_offset sz = ssize (u->s); + if (sz == 0 || sz == stell (u->s)) + u->endfile = AT_ENDFILE; + } } diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index ba8392d..8b9d7a7 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -342,15 +342,7 @@ raw_seek (unix_stream * s, gfc_offset offset, int whence) static gfc_offset raw_tell (unix_stream * s) { - gfc_offset x; - x = lseek (s->fd, 0, SEEK_CUR); - - /* Non-seekable files should always be assumed to be at - current position. */ - if (x == -1 && errno == ESPIPE) - x = 0; - - return x; + return lseek (s->fd, 0, SEEK_CUR); } static gfc_offset @@ -360,7 +352,10 @@ raw_size (unix_stream * s) int ret = fstat (s->fd, &statbuf); if (ret == -1) return ret; - return statbuf.st_size; + if (S_ISREG (statbuf.st_mode)) + return statbuf.st_size; + else + return 0; } static int |