summaryrefslogtreecommitdiff
path: root/gcc/ada/a-textio.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-10 13:51:40 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-10 13:51:40 +0000
commit8ee79a8446354ac1a9e20fd284e879a3d55860ba (patch)
tree63cfc97375650994bb335d260cabbdfd63f70efd /gcc/ada/a-textio.adb
parent7189d17fd684291638652f906a2c14487fe77419 (diff)
downloadgcc-8ee79a8446354ac1a9e20fd284e879a3d55860ba.tar.gz
2005-02-09 Robert Dewar <dewar@adacore.com>
* a-strunb.ads, a-strunb.adb: Add missing pragma Ada_05 statements Fix name of Set routine * a-strfix.ads, a-strfix.adb: Add new index functions from AI-301 to fixed packages. * a-stwise.ads, a-stwise.adb, a-stwifi.ads, a-stwifi.adb, a-strsea.ads, a-strsea.adb: Add new index functions from AI-301 to fixed packages * a-witeio.ads, a-witeio.adb, a-textio.ads, a-textio.adb: New function forms of Get_Line subprograms for AI-301. * a-wtcoau.adb, a-wtcoau.ads, a-wtcoio.adb, a-wtcoio.ads, a-wtedit.adb, a-wtedit.adb, a-wtedit.ads, a-wttest.adb, a-wttest.ads, a-strmap.ads, a-strmap.adb, a-stwima.adb, a-stwima.ads: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94810 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-textio.adb')
-rw-r--r--gcc/ada/a-textio.adb171
1 files changed, 111 insertions, 60 deletions
diff --git a/gcc/ada/a-textio.adb b/gcc/ada/a-textio.adb
index 7afb804ff9c..3fc95f02bd8 100644
--- a/gcc/ada/a-textio.adb
+++ b/gcc/ada/a-textio.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 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- --
@@ -60,7 +60,6 @@ package body Ada.Text_IO is
function AFCB_Allocate (Control_Block : Text_AFCB) return FCB.AFCB_Ptr is
pragma Unreferenced (Control_Block);
-
begin
return new Text_AFCB;
end AFCB_Allocate;
@@ -118,7 +117,7 @@ package body Ada.Text_IO is
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
- function Col (File : in File_Type) return Positive_Count is
+ function Col (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Col;
@@ -135,9 +134,9 @@ package body Ada.Text_IO is
procedure Create
(File : in out File_Type;
- Mode : in File_Mode := Out_File;
- Name : in String := "";
- Form : in String := "")
+ Mode : File_Mode := Out_File;
+ Name : String := "";
+ Form : String := "")
is
Dummy_File_Control_Block : Text_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
@@ -212,8 +211,8 @@ package body Ada.Text_IO is
-- End_Of_File --
-----------------
- function End_Of_File (File : in File_Type) return Boolean is
- ch : int;
+ function End_Of_File (File : File_Type) return Boolean is
+ ch : int;
begin
FIO.Check_Read_Status (AP (File));
@@ -270,7 +269,7 @@ package body Ada.Text_IO is
-- End_Of_Line --
-----------------
- function End_Of_Line (File : in File_Type) return Boolean is
+ function End_Of_Line (File : File_Type) return Boolean is
ch : int;
begin
@@ -301,7 +300,7 @@ package body Ada.Text_IO is
-- End_Of_Page --
-----------------
- function End_Of_Page (File : in File_Type) return Boolean is
+ function End_Of_Page (File : File_Type) return Boolean is
ch : int;
begin
@@ -357,7 +356,7 @@ package body Ada.Text_IO is
-- Flush --
-----------
- procedure Flush (File : in File_Type) is
+ procedure Flush (File : File_Type) is
begin
FIO.Flush (AP (File));
end Flush;
@@ -371,7 +370,7 @@ package body Ada.Text_IO is
-- Form --
----------
- function Form (File : in File_Type) return String is
+ function Form (File : File_Type) return String is
begin
return FIO.Form (AP (File));
end Form;
@@ -381,7 +380,7 @@ package body Ada.Text_IO is
---------
procedure Get
- (File : in File_Type;
+ (File : File_Type;
Item : out Character)
is
ch : int;
@@ -430,7 +429,7 @@ package body Ada.Text_IO is
end Get;
procedure Get
- (File : in File_Type;
+ (File : File_Type;
Item : out String)
is
ch : int;
@@ -489,7 +488,7 @@ package body Ada.Text_IO is
-- More work required here ???
procedure Get_Immediate
- (File : in File_Type;
+ (File : File_Type;
Item : out Character)
is
ch : int;
@@ -530,7 +529,7 @@ package body Ada.Text_IO is
end Get_Immediate;
procedure Get_Immediate
- (File : in File_Type;
+ (File : File_Type;
Item : out Character;
Available : out Boolean)
is
@@ -594,7 +593,7 @@ package body Ada.Text_IO is
--------------
procedure Get_Line
- (File : in File_Type;
+ (File : File_Type;
Item : out String;
Last : out Natural)
is
@@ -712,6 +711,58 @@ package body Ada.Text_IO is
Get_Line (Current_In, Item, Last);
end Get_Line;
+ function Get_Line (File : File_Type) return String is
+ Buffer : String (1 .. 500);
+ Last : Natural;
+
+ function Get_Rest (S : String) return String;
+ -- This is a recursive function that reads the rest of the line and
+ -- returns it. S is the part read so far.
+
+ --------------
+ -- Get_Rest --
+ --------------
+
+ function Get_Rest (S : String) return String is
+
+ -- Each time we allocate a buffer the same size as what we have
+ -- read so far. This limits us to a logarithmic number of calls
+ -- to Get_Rest and also ensures only a linear use of stack space.
+
+ Buffer : String (1 .. S'Length);
+ Last : Natural;
+
+ begin
+ Get_Line (File, Buffer, Last);
+
+ declare
+ R : constant String := S & Buffer (1 .. Last);
+ begin
+ if Last < Buffer'Last then
+ return R;
+ else
+ return Get_Rest (R);
+ end if;
+ end;
+ end Get_Rest;
+
+ -- Start of processing for Get_Line
+
+ begin
+ Get_Line (File, Buffer, Last);
+
+ if Last < Buffer'Last then
+ return Buffer (1 .. Last);
+ else
+ return Get_Rest (Buffer (1 .. Last));
+ end if;
+ end Get_Line;
+
+ function Get_Line return String is
+ begin
+ return Get_Line (Current_In);
+ end Get_Line;
+
----------
-- Getc --
----------
@@ -733,7 +784,7 @@ package body Ada.Text_IO is
-- Is_Open --
-------------
- function Is_Open (File : in File_Type) return Boolean is
+ function Is_Open (File : File_Type) return Boolean is
begin
return FIO.Is_Open (AP (File));
end Is_Open;
@@ -746,7 +797,7 @@ package body Ada.Text_IO is
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
- function Line (File : in File_Type) return Positive_Count is
+ function Line (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Line;
@@ -761,7 +812,7 @@ package body Ada.Text_IO is
-- Line_Length --
-----------------
- function Line_Length (File : in File_Type) return Count is
+ function Line_Length (File : File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Line_Length;
@@ -777,7 +828,7 @@ package body Ada.Text_IO is
----------------
procedure Look_Ahead
- (File : in File_Type;
+ (File : File_Type;
Item : out Character;
End_Of_Line : out Boolean)
is
@@ -818,7 +869,7 @@ package body Ada.Text_IO is
-- Mode --
----------
- function Mode (File : in File_Type) return File_Mode is
+ function Mode (File : File_Type) return File_Mode is
begin
return To_TIO (FIO.Mode (AP (File)));
end Mode;
@@ -827,7 +878,7 @@ package body Ada.Text_IO is
-- Name --
----------
- function Name (File : in File_Type) return String is
+ function Name (File : File_Type) return String is
begin
return FIO.Name (AP (File));
end Name;
@@ -837,8 +888,8 @@ package body Ada.Text_IO is
--------------
procedure New_Line
- (File : in File_Type;
- Spacing : in Positive_Count := 1)
+ (File : File_Type;
+ Spacing : Positive_Count := 1)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
@@ -867,7 +918,7 @@ package body Ada.Text_IO is
File.Col := 1;
end New_Line;
- procedure New_Line (Spacing : in Positive_Count := 1) is
+ procedure New_Line (Spacing : Positive_Count := 1) is
begin
New_Line (Current_Out, Spacing);
end New_Line;
@@ -876,7 +927,7 @@ package body Ada.Text_IO is
-- New_Page --
--------------
- procedure New_Page (File : in File_Type) is
+ procedure New_Page (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
@@ -925,9 +976,9 @@ package body Ada.Text_IO is
procedure Open
(File : in out File_Type;
- Mode : in File_Mode;
- Name : in String;
- Form : in String := "")
+ Mode : File_Mode;
+ Name : String;
+ Form : String := "")
is
Dummy_File_Control_Block : Text_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
@@ -955,7 +1006,7 @@ package body Ada.Text_IO is
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
- function Page (File : in File_Type) return Positive_Count is
+ function Page (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Page;
@@ -970,7 +1021,7 @@ package body Ada.Text_IO is
-- Page_Length --
-----------------
- function Page_Length (File : in File_Type) return Count is
+ function Page_Length (File : File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Page_Length;
@@ -986,8 +1037,8 @@ package body Ada.Text_IO is
---------
procedure Put
- (File : in File_Type;
- Item : in Character)
+ (File : File_Type;
+ Item : Character)
is
begin
FIO.Check_Write_Status (AP (File));
@@ -1003,7 +1054,7 @@ package body Ada.Text_IO is
File.Col := File.Col + 1;
end Put;
- procedure Put (Item : in Character) is
+ procedure Put (Item : Character) is
begin
FIO.Check_Write_Status (AP (Current_Out));
@@ -1025,8 +1076,8 @@ package body Ada.Text_IO is
---------
procedure Put
- (File : in File_Type;
- Item : in String)
+ (File : File_Type;
+ Item : String)
is
begin
FIO.Check_Write_Status (AP (File));
@@ -1052,7 +1103,7 @@ package body Ada.Text_IO is
end if;
end Put;
- procedure Put (Item : in String) is
+ procedure Put (Item : String) is
begin
Put (Current_Out, Item);
end Put;
@@ -1062,8 +1113,8 @@ package body Ada.Text_IO is
--------------
procedure Put_Line
- (File : in File_Type;
- Item : in String)
+ (File : File_Type;
+ Item : String)
is
Ilen : Natural := Item'Length;
Istart : Natural := Item'First;
@@ -1127,7 +1178,7 @@ package body Ada.Text_IO is
end;
end Put_Line;
- procedure Put_Line (Item : in String) is
+ procedure Put_Line (Item : String) is
begin
Put_Line (Current_Out, Item);
end Put_Line;
@@ -1231,7 +1282,7 @@ package body Ada.Text_IO is
procedure Reset
(File : in out File_Type;
- Mode : in File_Mode)
+ Mode : File_Mode)
is
begin
-- Don't allow change of mode for current file (RM A.10.2(5))
@@ -1273,8 +1324,8 @@ package body Ada.Text_IO is
-------------
procedure Set_Col
- (File : in File_Type;
- To : in Positive_Count)
+ (File : File_Type;
+ To : Positive_Count)
is
ch : int;
@@ -1333,7 +1384,7 @@ package body Ada.Text_IO is
end if;
end Set_Col;
- procedure Set_Col (To : in Positive_Count) is
+ procedure Set_Col (To : Positive_Count) is
begin
Set_Col (Current_Out, To);
end Set_Col;
@@ -1342,7 +1393,7 @@ package body Ada.Text_IO is
-- Set_Error --
---------------
- procedure Set_Error (File : in File_Type) is
+ procedure Set_Error (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Err := File;
@@ -1352,7 +1403,7 @@ package body Ada.Text_IO is
-- Set_Input --
---------------
- procedure Set_Input (File : in File_Type) is
+ procedure Set_Input (File : File_Type) is
begin
FIO.Check_Read_Status (AP (File));
Current_In := File;
@@ -1363,8 +1414,8 @@ package body Ada.Text_IO is
--------------
procedure Set_Line
- (File : in File_Type;
- To : in Positive_Count)
+ (File : File_Type;
+ To : Positive_Count)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
@@ -1401,7 +1452,7 @@ package body Ada.Text_IO is
end if;
end Set_Line;
- procedure Set_Line (To : in Positive_Count) is
+ procedure Set_Line (To : Positive_Count) is
begin
Set_Line (Current_Out, To);
end Set_Line;
@@ -1410,7 +1461,7 @@ package body Ada.Text_IO is
-- Set_Line_Length --
---------------------
- procedure Set_Line_Length (File : in File_Type; To : in Count) is
+ procedure Set_Line_Length (File : File_Type; To : Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
@@ -1424,7 +1475,7 @@ package body Ada.Text_IO is
File.Line_Length := To;
end Set_Line_Length;
- procedure Set_Line_Length (To : in Count) is
+ procedure Set_Line_Length (To : Count) is
begin
Set_Line_Length (Current_Out, To);
end Set_Line_Length;
@@ -1433,7 +1484,7 @@ package body Ada.Text_IO is
-- Set_Output --
----------------
- procedure Set_Output (File : in File_Type) is
+ procedure Set_Output (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Out := File;
@@ -1443,7 +1494,7 @@ package body Ada.Text_IO is
-- Set_Page_Length --
---------------------
- procedure Set_Page_Length (File : in File_Type; To : in Count) is
+ procedure Set_Page_Length (File : File_Type; To : Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
@@ -1457,7 +1508,7 @@ package body Ada.Text_IO is
File.Page_Length := To;
end Set_Page_Length;
- procedure Set_Page_Length (To : in Count) is
+ procedure Set_Page_Length (To : Count) is
begin
Set_Page_Length (Current_Out, To);
end Set_Page_Length;
@@ -1467,8 +1518,8 @@ package body Ada.Text_IO is
---------------
procedure Skip_Line
- (File : in File_Type;
- Spacing : in Positive_Count := 1)
+ (File : File_Type;
+ Spacing : Positive_Count := 1)
is
ch : int;
@@ -1548,7 +1599,7 @@ package body Ada.Text_IO is
end loop;
end Skip_Line;
- procedure Skip_Line (Spacing : in Positive_Count := 1) is
+ procedure Skip_Line (Spacing : Positive_Count := 1) is
begin
Skip_Line (Current_In, Spacing);
end Skip_Line;
@@ -1557,7 +1608,7 @@ package body Ada.Text_IO is
-- Skip_Page --
---------------
- procedure Skip_Page (File : in File_Type) is
+ procedure Skip_Page (File : File_Type) is
ch : int;
begin
@@ -1712,7 +1763,7 @@ package body Ada.Text_IO is
procedure Write
(File : in out Text_AFCB;
- Item : in Stream_Element_Array)
+ Item : Stream_Element_Array)
is
function Has_Translated_Characters return Boolean;