1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . B O U N D E D _ I O --
9 -- Copyright (C) 1997-2017, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Text_IO
; use Ada
.Text_IO
;
33 with Ada
.Unchecked_Deallocation
;
35 package body Ada
.Text_IO
.Bounded_IO
is
37 type String_Access
is access all String;
39 procedure Free
(SA
: in out String_Access
);
40 -- Perform an unchecked deallocation of a non-null string
46 procedure Free
(SA
: in out String_Access
) is
47 Null_String
: constant String := "";
49 procedure Deallocate
is
50 new Ada
.Unchecked_Deallocation
(String, String_Access
);
53 -- Do not try to free statically allocated null string
55 if SA
.all /= Null_String
then
64 function Get_Line
return Bounded
.Bounded_String
is
66 return Bounded
.To_Bounded_String
(Get_Line
);
74 (File
: File_Type
) return Bounded
.Bounded_String
77 return Bounded
.To_Bounded_String
(Get_Line
(File
));
85 (Item
: out Bounded
.Bounded_String
)
87 Buffer
: String (1 .. 1000);
93 Get_Line
(Buffer
, Last
);
94 Str1
:= new String'(Buffer (1 .. Last));
96 while Last = Buffer'Last loop
97 Get_Line (Buffer, Last);
98 Str2 := new String'(Str1
.all & Buffer
(1 .. Last
));
103 Item
:= Bounded
.To_Bounded_String
(Str1
.all);
112 Item
: out Bounded
.Bounded_String
)
114 Buffer
: String (1 .. 1000);
116 Str1
: String_Access
;
117 Str2
: String_Access
;
120 Get_Line
(File
, Buffer
, Last
);
121 Str1
:= new String'(Buffer (1 .. Last));
123 while Last = Buffer'Last loop
124 Get_Line (File, Buffer, Last);
125 Str2 := new String'(Str1
.all & Buffer
(1 .. Last
));
130 Item
:= Bounded
.To_Bounded_String
(Str1
.all);
138 (Item
: Bounded
.Bounded_String
)
141 Put
(Bounded
.To_String
(Item
));
150 Item
: Bounded
.Bounded_String
)
153 Put
(File
, Bounded
.To_String
(Item
));
161 (Item
: Bounded
.Bounded_String
)
164 Put_Line
(Bounded
.To_String
(Item
));
173 Item
: Bounded
.Bounded_String
)
176 Put_Line
(File
, Bounded
.To_String
(Item
));
179 end Ada
.Text_IO
.Bounded_IO
;