Remove some compile time warnings about duplicate definitions.
[official-gcc.git] / gcc / ada / a-wtdeau.adb
blob830c93c93b720a0890ab51b5a6ec7565e0d2ecfa
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- A D A . W I D E _ T E X T _ I O . D E C I M A L _ A U X --
6 -- --
7 -- B o d y --
8 -- --
9 -- $Revision: 1.3 $
10 -- --
11 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 with Ada.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux;
37 with Ada.Wide_Text_IO.Float_Aux; use Ada.Wide_Text_IO.Float_Aux;
39 with System.Img_Dec; use System.Img_Dec;
40 with System.Img_LLD; use System.Img_LLD;
41 with System.Val_Dec; use System.Val_Dec;
42 with System.Val_LLD; use System.Val_LLD;
44 package body Ada.Wide_Text_IO.Decimal_Aux is
46 -------------
47 -- Get_Dec --
48 -------------
50 function Get_Dec
51 (File : File_Type;
52 Width : Field;
53 Scale : Integer)
54 return Integer
56 Buf : String (1 .. Field'Last);
57 Ptr : aliased Integer;
58 Stop : Integer := 0;
59 Item : Integer;
61 begin
62 if Width /= 0 then
63 Load_Width (File, Width, Buf, Stop);
64 String_Skip (Buf, Ptr);
65 else
66 Load_Real (File, Buf, Stop);
67 Ptr := 1;
68 end if;
70 Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale);
71 Check_End_Of_Field (File, Buf, Stop, Ptr, Width);
72 return Item;
73 end Get_Dec;
75 -------------
76 -- Get_LLD --
77 -------------
79 function Get_LLD
80 (File : File_Type;
81 Width : Field;
82 Scale : Integer)
83 return Long_Long_Integer
85 Buf : String (1 .. Field'Last);
86 Ptr : aliased Integer;
87 Stop : Integer := 0;
88 Item : Long_Long_Integer;
90 begin
91 if Width /= 0 then
92 Load_Width (File, Width, Buf, Stop);
93 String_Skip (Buf, Ptr);
94 else
95 Load_Real (File, Buf, Stop);
96 Ptr := 1;
97 end if;
99 Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale);
100 Check_End_Of_Field (File, Buf, Stop, Ptr, Width);
101 return Item;
102 end Get_LLD;
104 --------------
105 -- Gets_Dec --
106 --------------
108 function Gets_Dec
109 (From : String;
110 Last : access Positive;
111 Scale : Integer)
112 return Integer
114 Pos : aliased Integer;
115 Item : Integer;
117 begin
118 String_Skip (From, Pos);
119 Item := Scan_Decimal (From, Pos'Access, From'Last, Scale);
120 Last.all := Pos - 1;
121 return Item;
123 exception
124 when Constraint_Error =>
125 Last.all := Pos - 1;
126 raise Data_Error;
128 end Gets_Dec;
130 --------------
131 -- Gets_LLD --
132 --------------
134 function Gets_LLD
135 (From : String;
136 Last : access Positive;
137 Scale : Integer)
138 return Long_Long_Integer
140 Pos : aliased Integer;
141 Item : Long_Long_Integer;
143 begin
144 String_Skip (From, Pos);
145 Item := Scan_Long_Long_Decimal (From, Pos'Access, From'Last, Scale);
146 Last.all := Pos - 1;
147 return Item;
149 exception
150 when Constraint_Error =>
151 Last.all := Pos - 1;
152 raise Data_Error;
154 end Gets_LLD;
156 -------------
157 -- Put_Dec --
158 -------------
160 procedure Put_Dec
161 (File : File_Type;
162 Item : Integer;
163 Fore : Field;
164 Aft : Field;
165 Exp : Field;
166 Scale : Integer)
168 Buf : String (1 .. Field'Last);
169 Ptr : Natural := 0;
171 begin
172 Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
173 Put_Item (File, Buf (1 .. Ptr));
174 end Put_Dec;
176 -------------
177 -- Put_LLD --
178 -------------
180 procedure Put_LLD
181 (File : File_Type;
182 Item : Long_Long_Integer;
183 Fore : Field;
184 Aft : Field;
185 Exp : Field;
186 Scale : Integer)
188 Buf : String (1 .. Field'Last);
189 Ptr : Natural := 0;
191 begin
192 Set_Image_Long_Long_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
193 Put_Item (File, Buf (1 .. Ptr));
194 end Put_LLD;
196 --------------
197 -- Puts_Dec --
198 --------------
200 procedure Puts_Dec
201 (To : out String;
202 Item : Integer;
203 Aft : Field;
204 Exp : Field;
205 Scale : Integer)
207 Buf : String (1 .. Field'Last);
208 Fore : Integer;
209 Ptr : Natural := 0;
211 begin
212 if Exp = 0 then
213 Fore := To'Length - 1 - Aft;
214 else
215 Fore := To'Length - 2 - Aft - Exp;
216 end if;
218 if Fore < 1 then
219 raise Layout_Error;
220 end if;
222 Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
224 if Ptr > To'Length then
225 raise Layout_Error;
226 else
227 To := Buf (1 .. Ptr);
228 end if;
229 end Puts_Dec;
231 --------------
232 -- Puts_Dec --
233 --------------
235 procedure Puts_LLD
236 (To : out String;
237 Item : Long_Long_Integer;
238 Aft : Field;
239 Exp : Field;
240 Scale : Integer)
242 Buf : String (1 .. Field'Last);
243 Fore : Integer;
244 Ptr : Natural := 0;
246 begin
247 if Exp = 0 then
248 Fore := To'Length - 1 - Aft;
249 else
250 Fore := To'Length - 2 - Aft - Exp;
251 end if;
253 if Fore < 1 then
254 raise Layout_Error;
255 end if;
257 Set_Image_Long_Long_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
259 if Ptr > To'Length then
260 raise Layout_Error;
261 else
262 To := Buf (1 .. Ptr);
263 end if;
264 end Puts_LLD;
266 end Ada.Wide_Text_IO.Decimal_Aux;