OSDN Git Service

2012-12-22 Thomas Koenig <tkoenig@gcc.gnu.org>
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 22 Dec 2012 10:46:37 +0000 (10:46 +0000)
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 22 Dec 2012 10:46:37 +0000 (10:46 +0000)
PR libfortran/30162
Backport from trunk
* io/unix.c (raw_tell):  If the lseek is done on a
non-seekable file, return 0.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@194694 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/unix.c

index a9c38c8..396b1af 100644 (file)
@@ -1,3 +1,10 @@
+2012-12-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/30162
+       Backport from trunk
+       * io/unix.c (raw_tell):  If the lseek is done on a
+       non-seekable file, return 0.
+
 2012-10-12  Thomas König  <tkoenig@gcc.gnu.org>
 
        PR libfortran/54736
index 6eef3f9..87c3788 100644 (file)
@@ -329,7 +329,15 @@ raw_seek (unix_stream * s, gfc_offset offset, int whence)
 static gfc_offset
 raw_tell (unix_stream * s)
 {
-  return lseek (s->fd, 0, SEEK_CUR);
+  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;
 }
 
 static gfc_offset