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 --
10 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
35 with Ada
.Text_IO
.Generic_Aux
; use Ada
.Text_IO
.Generic_Aux
;
37 with System
.Img_BIU
; use System
.Img_BIU
;
38 with System
.Img_Int
; use System
.Img_Int
;
39 with System
.Img_LLB
; use System
.Img_LLB
;
40 with System
.Img_LLI
; use System
.Img_LLI
;
41 with System
.Img_LLW
; use System
.Img_LLW
;
42 with System
.Img_WIU
; use System
.Img_WIU
;
43 with System
.Val_Int
; use System
.Val_Int
;
44 with System
.Val_LLI
; use System
.Val_LLI
;
46 package body Ada
.Text_IO
.Integer_Aux
is
48 -----------------------
49 -- Local Subprograms --
50 -----------------------
52 procedure Load_Integer
55 Ptr
: in out Natural);
56 -- This is an auxiliary routine that is used to load an possibly signed
57 -- integer literal value from the input file into Buf, starting at Ptr + 1.
58 -- On return, Ptr is set to the last character stored.
69 Buf
: String (1 .. Field
'Last);
70 Ptr
: aliased Integer := 1;
75 Load_Width
(File
, Width
, Buf
, Stop
);
76 String_Skip
(Buf
, Ptr
);
78 Load_Integer
(File
, Buf
, Stop
);
81 Item
:= Scan_Integer
(Buf
, Ptr
'Access, Stop
);
82 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
91 Item
: out Long_Long_Integer;
94 Buf
: String (1 .. Field
'Last);
95 Ptr
: aliased Integer := 1;
100 Load_Width
(File
, Width
, Buf
, Stop
);
101 String_Skip
(Buf
, Ptr
);
103 Load_Integer
(File
, Buf
, Stop
);
106 Item
:= Scan_Long_Long_Integer
(Buf
, Ptr
'Access, Stop
);
107 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
119 Pos
: aliased Integer;
122 String_Skip
(From
, Pos
);
123 Item
:= Scan_Integer
(From
, Pos
'Access, From
'Last);
127 when Constraint_Error
=>
138 Item
: out Long_Long_Integer;
141 Pos
: aliased Integer;
144 String_Skip
(From
, Pos
);
145 Item
:= Scan_Long_Long_Integer
(From
, Pos
'Access, From
'Last);
149 when Constraint_Error
=>
158 procedure Load_Integer
159 (File
: in File_Type
;
161 Ptr
: in out Natural)
168 Load
(File
, Buf
, Ptr
, '+', '-');
170 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
173 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
177 Load_Extended_Digits
(File
, Buf
, Ptr
);
178 Load
(File
, Buf
, Ptr
, Buf
(Hash_Loc
));
181 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
185 -- Note: it is strange to allow a minus sign, since the syntax
186 -- does not, but that is what ACVC test CE3704F, case (6) wants.
188 Load
(File
, Buf
, Ptr
, '+', '-');
189 Load_Digits
(File
, Buf
, Ptr
);
199 (File
: in File_Type
;
202 Base
: in Number_Base
)
204 Buf
: String (1 .. Integer'Max (Field
'Last, Width
));
208 if Base
= 10 and then Width
= 0 then
209 Set_Image_Integer
(Item
, Buf
, Ptr
);
211 Set_Image_Width_Integer
(Item
, Width
, Buf
, Ptr
);
213 Set_Image_Based_Integer
(Item
, Base
, Width
, Buf
, Ptr
);
216 Put_Item
(File
, Buf
(1 .. Ptr
));
224 (File
: in File_Type
;
225 Item
: in Long_Long_Integer;
227 Base
: in Number_Base
)
229 Buf
: String (1 .. Integer'Max (Field
'Last, Width
));
233 if Base
= 10 and then Width
= 0 then
234 Set_Image_Long_Long_Integer
(Item
, Buf
, Ptr
);
236 Set_Image_Width_Long_Long_Integer
(Item
, Width
, Buf
, Ptr
);
238 Set_Image_Based_Long_Long_Integer
(Item
, Base
, Width
, Buf
, Ptr
);
241 Put_Item
(File
, Buf
(1 .. Ptr
));
251 Base
: in Number_Base
)
253 Buf
: String (1 .. Integer'Max (Field
'Last, To
'Length));
258 Set_Image_Width_Integer
(Item
, To
'Length, Buf
, Ptr
);
260 Set_Image_Based_Integer
(Item
, Base
, To
'Length, Buf
, Ptr
);
263 if Ptr
> To
'Length then
266 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
276 Item
: in Long_Long_Integer;
277 Base
: in Number_Base
)
279 Buf
: String (1 .. Integer'Max (Field
'Last, To
'Length));
284 Set_Image_Width_Long_Long_Integer
(Item
, To
'Length, Buf
, Ptr
);
286 Set_Image_Based_Long_Long_Integer
(Item
, Base
, To
'Length, Buf
, Ptr
);
289 if Ptr
> To
'Length then
292 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
296 end Ada
.Text_IO
.Integer_Aux
;