* config/i386/uwin.h: Remove SUBTARGET_PROLOGUE.
[official-gcc.git] / gcc / ada / a-tiinau.adb
blobc043570f14ea09cac75dedd9d3a2e42b278797de
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . T E X T _ I O . I N T E G E R _ A U X --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2001 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 with Ada.Text_IO.Generic_Aux; use Ada.Text_IO.Generic_Aux;
36 with System.Img_BIU; use System.Img_BIU;
37 with System.Img_Int; use System.Img_Int;
38 with System.Img_LLB; use System.Img_LLB;
39 with System.Img_LLI; use System.Img_LLI;
40 with System.Img_LLW; use System.Img_LLW;
41 with System.Img_WIU; use System.Img_WIU;
42 with System.Val_Int; use System.Val_Int;
43 with System.Val_LLI; use System.Val_LLI;
45 package body Ada.Text_IO.Integer_Aux is
47 -----------------------
48 -- Local Subprograms --
49 -----------------------
51 procedure Load_Integer
52 (File : in File_Type;
53 Buf : out String;
54 Ptr : in out Natural);
55 -- This is an auxiliary routine that is used to load an possibly signed
56 -- integer literal value from the input file into Buf, starting at Ptr + 1.
57 -- On return, Ptr is set to the last character stored.
59 -------------
60 -- Get_Int --
61 -------------
63 procedure Get_Int
64 (File : in File_Type;
65 Item : out Integer;
66 Width : in Field)
68 Buf : String (1 .. Field'Last);
69 Ptr : aliased Integer := 1;
70 Stop : Integer := 0;
72 begin
73 if Width /= 0 then
74 Load_Width (File, Width, Buf, Stop);
75 String_Skip (Buf, Ptr);
76 else
77 Load_Integer (File, Buf, Stop);
78 end if;
80 Item := Scan_Integer (Buf, Ptr'Access, Stop);
81 Check_End_Of_Field (Buf, Stop, Ptr, Width);
82 end Get_Int;
84 -------------
85 -- Get_LLI --
86 -------------
88 procedure Get_LLI
89 (File : in File_Type;
90 Item : out Long_Long_Integer;
91 Width : in Field)
93 Buf : String (1 .. Field'Last);
94 Ptr : aliased Integer := 1;
95 Stop : Integer := 0;
97 begin
98 if Width /= 0 then
99 Load_Width (File, Width, Buf, Stop);
100 String_Skip (Buf, Ptr);
101 else
102 Load_Integer (File, Buf, Stop);
103 end if;
105 Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop);
106 Check_End_Of_Field (Buf, Stop, Ptr, Width);
107 end Get_LLI;
109 --------------
110 -- Gets_Int --
111 --------------
113 procedure Gets_Int
114 (From : in String;
115 Item : out Integer;
116 Last : out Positive)
118 Pos : aliased Integer;
120 begin
121 String_Skip (From, Pos);
122 Item := Scan_Integer (From, Pos'Access, From'Last);
123 Last := Pos - 1;
125 exception
126 when Constraint_Error =>
127 Last := Pos - 1;
128 raise Data_Error;
129 end Gets_Int;
131 --------------
132 -- Gets_LLI --
133 --------------
135 procedure Gets_LLI
136 (From : in String;
137 Item : out Long_Long_Integer;
138 Last : out Positive)
140 Pos : aliased Integer;
142 begin
143 String_Skip (From, Pos);
144 Item := Scan_Long_Long_Integer (From, Pos'Access, From'Last);
145 Last := Pos - 1;
147 exception
148 when Constraint_Error =>
149 Last := Pos - 1;
150 raise Data_Error;
151 end Gets_LLI;
153 ------------------
154 -- Load_Integer --
155 ------------------
157 procedure Load_Integer
158 (File : in File_Type;
159 Buf : out String;
160 Ptr : in out Natural)
162 Hash_Loc : Natural;
163 Loaded : Boolean;
165 begin
166 Load_Skip (File);
167 Load (File, Buf, Ptr, '+', '-');
169 Load_Digits (File, Buf, Ptr, Loaded);
171 if Loaded then
172 Load (File, Buf, Ptr, '#', ':', Loaded);
174 if Loaded then
175 Hash_Loc := Ptr;
176 Load_Extended_Digits (File, Buf, Ptr);
177 Load (File, Buf, Ptr, Buf (Hash_Loc));
178 end if;
180 Load (File, Buf, Ptr, 'E', 'e', Loaded);
182 if Loaded then
184 -- Note: it is strange to allow a minus sign, since the syntax
185 -- does not, but that is what ACVC test CE3704F, case (6) wants.
187 Load (File, Buf, Ptr, '+', '-');
188 Load_Digits (File, Buf, Ptr);
189 end if;
190 end if;
191 end Load_Integer;
193 -------------
194 -- Put_Int --
195 -------------
197 procedure Put_Int
198 (File : in File_Type;
199 Item : in Integer;
200 Width : in Field;
201 Base : in Number_Base)
203 Buf : String (1 .. Integer'Max (Field'Last, Width));
204 Ptr : Natural := 0;
206 begin
207 if Base = 10 and then Width = 0 then
208 Set_Image_Integer (Item, Buf, Ptr);
209 elsif Base = 10 then
210 Set_Image_Width_Integer (Item, Width, Buf, Ptr);
211 else
212 Set_Image_Based_Integer (Item, Base, Width, Buf, Ptr);
213 end if;
215 Put_Item (File, Buf (1 .. Ptr));
216 end Put_Int;
218 -------------
219 -- Put_LLI --
220 -------------
222 procedure Put_LLI
223 (File : in File_Type;
224 Item : in Long_Long_Integer;
225 Width : in Field;
226 Base : in Number_Base)
228 Buf : String (1 .. Integer'Max (Field'Last, Width));
229 Ptr : Natural := 0;
231 begin
232 if Base = 10 and then Width = 0 then
233 Set_Image_Long_Long_Integer (Item, Buf, Ptr);
234 elsif Base = 10 then
235 Set_Image_Width_Long_Long_Integer (Item, Width, Buf, Ptr);
236 else
237 Set_Image_Based_Long_Long_Integer (Item, Base, Width, Buf, Ptr);
238 end if;
240 Put_Item (File, Buf (1 .. Ptr));
241 end Put_LLI;
243 --------------
244 -- Puts_Int --
245 --------------
247 procedure Puts_Int
248 (To : out String;
249 Item : in Integer;
250 Base : in Number_Base)
252 Buf : String (1 .. Integer'Max (Field'Last, To'Length));
253 Ptr : Natural := 0;
255 begin
256 if Base = 10 then
257 Set_Image_Width_Integer (Item, To'Length, Buf, Ptr);
258 else
259 Set_Image_Based_Integer (Item, Base, To'Length, Buf, Ptr);
260 end if;
262 if Ptr > To'Length then
263 raise Layout_Error;
264 else
265 To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
266 end if;
267 end Puts_Int;
269 --------------
270 -- Puts_LLI --
271 --------------
273 procedure Puts_LLI
274 (To : out String;
275 Item : in Long_Long_Integer;
276 Base : in Number_Base)
278 Buf : String (1 .. Integer'Max (Field'Last, To'Length));
279 Ptr : Natural := 0;
281 begin
282 if Base = 10 then
283 Set_Image_Width_Long_Long_Integer (Item, To'Length, Buf, Ptr);
284 else
285 Set_Image_Based_Long_Long_Integer (Item, Base, To'Length, Buf, Ptr);
286 end if;
288 if Ptr > To'Length then
289 raise Layout_Error;
290 else
291 To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
292 end if;
293 end Puts_LLI;
295 end Ada.Text_IO.Integer_Aux;