OSDN Git Service

2006-05-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libgfortran / io / unix.c
index 1293b24..560047f 100644 (file)
@@ -569,6 +569,7 @@ fd_seek (unix_stream * s, gfc_offset offset)
     }
 
   s->physical_offset = s->logical_offset = offset;
+  s->active = 0;
 
   return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;
 }
@@ -586,7 +587,7 @@ fd_truncate (unix_stream * s)
 
   /* non-seekable files, like terminals and fifo's fail the lseek.
      Using ftruncate on a seekable special file (like /dev/null)
-     is undefined, so we treat it as if the ftruncate failed.
+     is undefined, so we treat it as if the ftruncate succeeded.
   */
 #ifdef HAVE_FTRUNCATE
   if (s->special_file || ftruncate (s->fd, s->logical_offset))
@@ -597,7 +598,7 @@ fd_truncate (unix_stream * s)
 #endif
     {
       s->physical_offset = s->file_length = 0;
-      return FAILURE;
+      return SUCCESS;
     }
 
   s->physical_offset = s->file_length = s->logical_offset;
@@ -928,7 +929,8 @@ mem_truncate (unix_stream * s __attribute__ ((unused)))
 static try
 mem_close (unix_stream * s)
 {
-  free_mem (s);
+  if (s != NULL)
+    free_mem (s);
 
   return SUCCESS;
 }