1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . I N T E G E R _ A U X --
11 -- Copyright (C) 1992-1999 Free Software Foundation, Inc. --
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. --
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. --
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). --
34 ------------------------------------------------------------------------------
36 with Ada.Text_IO.Generic_Aux; use Ada.Text_IO.Generic_Aux;
38 with System.Img_BIU; use System.Img_BIU;
39 with System.Img_Int; use System.Img_Int;
40 with System.Img_LLB; use System.Img_LLB;
41 with System.Img_LLI; use System.Img_LLI;
42 with System.Img_LLW; use System.Img_LLW;
43 with System.Img_WIU; use System.Img_WIU;
44 with System.Val_Int; use System.Val_Int;
45 with System.Val_LLI; use System.Val_LLI;
47 package body Ada.Text_IO.Integer_Aux is
49 -----------------------
50 -- Local Subprograms --
51 -----------------------
53 procedure Load_Integer
56 Ptr : in out Natural);
57 -- This is an auxiliary routine that is used to load an possibly signed
58 -- integer literal value from the input file into Buf, starting at Ptr + 1.
59 -- On return, Ptr is set to the last character stored.
70 Buf : String (1 .. Field'Last);
71 Ptr : aliased Integer := 1;
76 Load_Width (File, Width, Buf, Stop);
77 String_Skip (Buf, Ptr);
79 Load_Integer (File, Buf, Stop);
82 Item := Scan_Integer (Buf, Ptr'Access, Stop);
83 Check_End_Of_Field (File, Buf, Stop, Ptr, Width);
92 Item : out Long_Long_Integer;
95 Buf : String (1 .. Field'Last);
96 Ptr : aliased Integer := 1;
101 Load_Width (File, Width, Buf, Stop);
102 String_Skip (Buf, Ptr);
104 Load_Integer (File, Buf, Stop);
107 Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop);
108 Check_End_Of_Field (File, Buf, Stop, Ptr, Width);
120 Pos : aliased Integer;
123 String_Skip (From, Pos);
124 Item := Scan_Integer (From, Pos'Access, From'Last);
128 when Constraint_Error =>
139 Item : out Long_Long_Integer;
142 Pos : aliased Integer;
145 String_Skip (From, Pos);
146 Item := Scan_Long_Long_Integer (From, Pos'Access, From'Last);
150 when Constraint_Error =>
159 procedure Load_Integer
160 (File : in File_Type;
162 Ptr : in out Natural)
169 Load (File, Buf, Ptr, '+', '-');
171 Load_Digits (File, Buf, Ptr, Loaded);
174 Load (File, Buf, Ptr, '#', ':', Loaded);
178 Load_Extended_Digits (File, Buf, Ptr);
179 Load (File, Buf, Ptr, Buf (Hash_Loc));
182 Load (File, Buf, Ptr, 'E', 'e', Loaded);
186 -- Note: it is strange to allow a minus sign, since the syntax
187 -- does not, but that is what ACVC test CE3704F, case (6) wants.
189 Load (File, Buf, Ptr, '+', '-');
190 Load_Digits (File, Buf, Ptr);
200 (File : in File_Type;
203 Base : in Number_Base)
205 Buf : String (1 .. Integer'Max (Field'Last, Width));
209 if Base = 10 and then Width = 0 then
210 Set_Image_Integer (Item, Buf, Ptr);
212 Set_Image_Width_Integer (Item, Width, Buf, Ptr);
214 Set_Image_Based_Integer (Item, Base, Width, Buf, Ptr);
217 Put_Item (File, Buf (1 .. Ptr));
225 (File : in File_Type;
226 Item : in Long_Long_Integer;
228 Base : in Number_Base)
230 Buf : String (1 .. Integer'Max (Field'Last, Width));
234 if Base = 10 and then Width = 0 then
235 Set_Image_Long_Long_Integer (Item, Buf, Ptr);
237 Set_Image_Width_Long_Long_Integer (Item, Width, Buf, Ptr);
239 Set_Image_Based_Long_Long_Integer (Item, Base, Width, Buf, Ptr);
242 Put_Item (File, Buf (1 .. Ptr));
252 Base : in Number_Base)
254 Buf : String (1 .. Integer'Max (Field'Last, To'Length));
259 Set_Image_Width_Integer (Item, To'Length, Buf, Ptr);
261 Set_Image_Based_Integer (Item, Base, To'Length, Buf, Ptr);
264 if Ptr > To'Length then
267 To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
277 Item : in Long_Long_Integer;
278 Base : in Number_Base)
280 Buf : String (1 .. Integer'Max (Field'Last, To'Length));
285 Set_Image_Width_Long_Long_Integer (Item, To'Length, Buf, Ptr);
287 Set_Image_Based_Long_Long_Integer (Item, Base, To'Length, Buf, Ptr);
290 if Ptr > To'Length then
293 To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
297 end Ada.Text_IO.Integer_Aux;