summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-21 19:03:10 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-21 19:03:10 +0000
commit6dfa90cc960b6d4d50faeb3fbb8c4ee6134e4e16 (patch)
tree26f483a5c4fc248264b7e8d76bab4ca11eb5159a /libgfortran
parent3309ecdd01f80c7c67186a5b583bce2e2b5023ca (diff)
downloadgcc-6dfa90cc960b6d4d50faeb3fbb8c4ee6134e4e16.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196210 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/open.c8
-rw-r--r--libgfortran/io/unix.c15
3 files changed, 18 insertions, 12 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 39606c8f13a..54ac5738c01 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2013-02-19 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
PR target/56347
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 28957673eff..d9cfde853f5 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 ba8392d21a1..8b9d7a77342 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