OSDN Git Service

2010-10-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ststio.adb
index cf2f4ea..c5da571 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -32,6 +32,7 @@
 with Interfaces.C_Streams; use Interfaces.C_Streams;
 
 with System;               use System;
+with System.Communication; use System.Communication;
 with System.File_IO;
 with System.Soft_Links;
 with System.CRTL;
@@ -146,7 +147,7 @@ package body Ada.Streams.Stream_IO is
    function End_Of_File (File : File_Type) return Boolean is
    begin
       FIO.Check_Read_Status (AP (File));
-      return Count (File.Index) > Size (File);
+      return File.Index > Size (File);
    end End_Of_File;
 
    -----------
@@ -174,7 +175,7 @@ package body Ada.Streams.Stream_IO is
    function Index (File : File_Type) return Positive_Count is
    begin
       FIO.Check_File_Open (AP (File));
-      return Count (File.Index);
+      return File.Index;
    end Index;
 
    -------------
@@ -241,11 +242,7 @@ package body Ada.Streams.Stream_IO is
       --  (and furthermore there are situations (such as the case of writing
       --  a sequential Posix FIFO file) where the lseek would cause problems.
 
-      if Mode = Out_File then
-         File.Last_Op := Op_Write;
-      else
-         File.Last_Op := Op_Read;
-      end if;
+      File.Last_Op := (if Mode = Out_File then Op_Write else Op_Read);
    end Open;
 
    ----------
@@ -297,8 +294,8 @@ package body Ada.Streams.Stream_IO is
       end if;
 
       File.Index := File.Index + Count (Nread);
-      Last := Item'First + Stream_Element_Offset (Nread) - 1;
       File.Last_Op := Op_Read;
+      Last := Last_Index (Item'First, Nread);
    end Read;
 
    --  This version of Read is the primitive operation on the underlying