[Ada] Warn on import of parent package
[official-gcc.git] / gcc / ada / libgnat / a-wwboio.adb
blob7c26981feff1707eeddfc5f1cc964beb659ce22a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . W I D E _ T E X T _ I O . W I D E _ B O U N D E D _ I O --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1997-2021, Free Software Foundation, Inc. --
10 -- --
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. --
17 -- --
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. --
21 -- --
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/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 with Ada.Unchecked_Deallocation;
34 package body Ada.Wide_Text_IO.Wide_Bounded_IO is
36 type Wide_String_Access is access all Wide_String;
38 procedure Free (WSA : in out Wide_String_Access);
39 -- Perform an unchecked deallocation of a non-null string
41 ----------
42 -- Free --
43 ----------
45 procedure Free (WSA : in out Wide_String_Access) is
46 Null_Wide_String : constant Wide_String := "";
48 procedure Deallocate is
49 new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
51 begin
52 -- Do not try to free statically allocated null string
54 if WSA.all /= Null_Wide_String then
55 Deallocate (WSA);
56 end if;
57 end Free;
59 --------------
60 -- Get_Line --
61 --------------
63 function Get_Line return Wide_Bounded.Bounded_Wide_String is
64 begin
65 return Wide_Bounded.To_Bounded_Wide_String (Get_Line);
66 end Get_Line;
68 --------------
69 -- Get_Line --
70 --------------
72 function Get_Line
73 (File : File_Type) return Wide_Bounded.Bounded_Wide_String
75 begin
76 return Wide_Bounded.To_Bounded_Wide_String (Get_Line (File));
77 end Get_Line;
79 --------------
80 -- Get_Line --
81 --------------
83 procedure Get_Line
84 (Item : out Wide_Bounded.Bounded_Wide_String)
86 Buffer : Wide_String (1 .. 1000);
87 Last : Natural;
88 Str1 : Wide_String_Access;
89 Str2 : Wide_String_Access;
91 begin
92 Get_Line (Buffer, Last);
93 Str1 := new Wide_String'(Buffer (1 .. Last));
95 while Last = Buffer'Last loop
96 Get_Line (Buffer, Last);
97 Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last));
98 Free (Str1);
99 Str1 := Str2;
100 end loop;
102 Item := Wide_Bounded.To_Bounded_Wide_String (Str1.all);
103 end Get_Line;
105 --------------
106 -- Get_Line --
107 --------------
109 procedure Get_Line
110 (File : File_Type;
111 Item : out Wide_Bounded.Bounded_Wide_String)
113 Buffer : Wide_String (1 .. 1000);
114 Last : Natural;
115 Str1 : Wide_String_Access;
116 Str2 : Wide_String_Access;
118 begin
119 Get_Line (File, Buffer, Last);
120 Str1 := new Wide_String'(Buffer (1 .. Last));
122 while Last = Buffer'Last loop
123 Get_Line (File, Buffer, Last);
124 Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last));
125 Free (Str1);
126 Str1 := Str2;
127 end loop;
129 Item := Wide_Bounded.To_Bounded_Wide_String (Str1.all);
130 end Get_Line;
132 ---------
133 -- Put --
134 ---------
136 procedure Put
137 (Item : Wide_Bounded.Bounded_Wide_String)
139 begin
140 Put (Wide_Bounded.To_Wide_String (Item));
141 end Put;
143 ---------
144 -- Put --
145 ---------
147 procedure Put
148 (File : File_Type;
149 Item : Wide_Bounded.Bounded_Wide_String)
151 begin
152 Put (File, Wide_Bounded.To_Wide_String (Item));
153 end Put;
155 --------------
156 -- Put_Line --
157 --------------
159 procedure Put_Line
160 (Item : Wide_Bounded.Bounded_Wide_String)
162 begin
163 Put_Line (Wide_Bounded.To_Wide_String (Item));
164 end Put_Line;
166 --------------
167 -- Put_Line --
168 --------------
170 procedure Put_Line
171 (File : File_Type;
172 Item : Wide_Bounded.Bounded_Wide_String)
174 begin
175 Put_Line (File, Wide_Bounded.To_Wide_String (Item));
176 end Put_Line;
178 end Ada.Wide_Text_IO.Wide_Bounded_IO;