OSDN Git Service

PR target/50678
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-textio.adb
index 0dd5463..721deca 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- --
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Ada.Streams;          use Ada.Streams;
-with Interfaces.C_Streams; use Interfaces.C_Streams;
+with Ada.Streams;             use Ada.Streams;
+with Interfaces.C_Streams;    use Interfaces.C_Streams;
 
 with System.File_IO;
 with System.CRTL;
-with System.WCh_Cnv;       use System.WCh_Cnv;
-with System.WCh_Con;       use System.WCh_Con;
+with System.WCh_Cnv;          use System.WCh_Cnv;
+with System.WCh_Con;          use System.WCh_Con;
 
 with Ada.Unchecked_Conversion;
 with Ada.Unchecked_Deallocation;
@@ -691,113 +691,11 @@ package body Ada.Text_IO is
    procedure Get_Line
      (File : File_Type;
       Item : out String;
-      Last : out Natural)
-   is
-      ch : int;
-
-   begin
-      FIO.Check_Read_Status (AP (File));
-      Last := Item'First - 1;
-
-      --  Immediate exit for null string, this is a case in which we do not
-      --  need to test for end of file and we do not skip a line mark under
-      --  any circumstances.
-
-      if Last >= Item'Last then
-         return;
-      end if;
-
-      --  Here we have at least one character, if we are immediately before
-      --  a line mark, then we will just skip past it storing no characters.
-
-      if File.Before_LM then
-         File.Before_LM := False;
-         File.Before_LM_PM := False;
-
-      --  Otherwise we need to read some characters
-
-      else
-         ch := Getc (File);
-
-         --  If we are at the end of file now, it means we are trying to
-         --  skip a file terminator and we raise End_Error (RM A.10.7(20))
-
-         if ch = EOF then
-            raise End_Error;
-         end if;
-
-         --  Loop through characters. Don't bother if we hit a page mark,
-         --  since in normal files, page marks can only follow line marks
-         --  in any case and we only promise to treat the page nonsense
-         --  correctly in the absense of such rogue page marks.
-
-         loop
-            --  Exit the loop if read is terminated by encountering line mark
-
-            exit when ch = LM;
-
-            --  Otherwise store the character, note that we know that ch is
-            --  something other than LM or EOF. It could possibly be a page
-            --  mark if there is a stray page mark in the middle of a line,
-            --  but this is not an official page mark in any case, since
-            --  official page marks can only follow a line mark. The whole
-            --  page business is pretty much nonsense anyway, so we do not
-            --  want to waste time trying to make sense out of non-standard
-            --  page marks in the file! This means that the behavior of
-            --  Get_Line is different from repeated Get of a character, but
-            --  that's too bad. We only promise that page numbers etc make
-            --  sense if the file is formatted in a standard manner.
-
-            --  Note: we do not adjust the column number because it is quicker
-            --  to adjust it once at the end of the operation than incrementing
-            --  it each time around the loop.
-
-            Last := Last + 1;
-            Item (Last) := Character'Val (ch);
-
-            --  All done if the string is full, this is the case in which
-            --  we do not skip the following line mark. We need to adjust
-            --  the column number in this case.
-
-            if Last = Item'Last then
-               File.Col := File.Col + Count (Item'Length);
-               return;
-            end if;
-
-            --  Otherwise read next character. We also exit from the loop if
-            --  we read an end of file. This is the case where the last line
-            --  is not terminated with a line mark, and we consider that there
-            --  is an implied line mark in this case (this is a non-standard
-            --  file, but it is nice to treat it reasonably).
-
-            ch := Getc (File);
-            exit when ch = EOF;
-         end loop;
-      end if;
-
-      --  We have skipped past, but not stored, a line mark. Skip following
-      --  page mark if one follows, but do not do this for a non-regular
-      --  file (since otherwise we get annoying wait for an extra character)
-
-      File.Line := File.Line + 1;
-      File.Col := 1;
-
-      if File.Before_LM_PM then
-         File.Line := 1;
-         File.Before_LM_PM := False;
-         File.Page := File.Page + 1;
-
-      elsif File.Is_Regular_File then
-         ch := Getc (File);
-
-         if ch = PM and then File.Is_Regular_File then
-            File.Line := 1;
-            File.Page := File.Page + 1;
-         else
-            Ungetc (ch, File);
-         end if;
-      end if;
-   end Get_Line;
+      Last : out Natural) is separate;
+   --  The implementation of Ada.Text_IO.Get_Line is split into a subunit so
+   --  that different implementations can be used on different systems. In
+   --  particular the standard implementation uses low level stuff that is
+   --  not appropriate for the JVM and .NET implementations.
 
    procedure Get_Line
      (Item : out String;