]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix regression when writing formatted sequential to a pipe.
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 21 Feb 2013 19:03:10 +0000 (21:03 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 21 Feb 2013 19:03:10 +0000 (21:03 +0200)
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

libgfortran/ChangeLog
libgfortran/io/open.c
libgfortran/io/unix.c

index 39606c8f13a61102241467c965d2d9f159e46c7f..54ac5738c0147af87cc21f40ae8e358399b8d882 100644 (file)
@@ -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
index 28957673efff6d14e7b13e1fba80f37f1bd6b0e6..d9cfde853f5b0957f0a33599aa214dc56b370c66 100644 (file)
@@ -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;
+    }
 }
 
 
index ba8392d21a1f5c6728b6a3a7a1eb1ec617c768fa..8b9d7a773425224106446105f6d2bb43be4fa5f6 100644 (file)
@@ -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