1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . I N T E G E R _ A U X --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Wide_Wide_Text_IO
.Generic_Aux
; use Ada
.Wide_Wide_Text_IO
.Generic_Aux
;
34 with System
.Img_BIU
; use System
.Img_BIU
;
35 with System
.Img_Int
; use System
.Img_Int
;
36 with System
.Img_LLB
; use System
.Img_LLB
;
37 with System
.Img_LLI
; use System
.Img_LLI
;
38 with System
.Img_LLW
; use System
.Img_LLW
;
39 with System
.Img_WIU
; use System
.Img_WIU
;
40 with System
.Val_Int
; use System
.Val_Int
;
41 with System
.Val_LLI
; use System
.Val_LLI
;
43 package body Ada
.Wide_Wide_Text_IO
.Integer_Aux
is
45 -----------------------
46 -- Local Subprograms --
47 -----------------------
49 procedure Load_Integer
52 Ptr
: in out Natural);
53 -- This is an auxiliary routine that is used to load an possibly signed
54 -- integer literal value from the input file into Buf, starting at Ptr + 1.
55 -- On return, Ptr is set to the last character stored.
66 Buf
: String (1 .. Field
'Last);
67 Ptr
: aliased Integer := 1;
72 Load_Width
(File
, Width
, Buf
, Stop
);
73 String_Skip
(Buf
, Ptr
);
75 Load_Integer
(File
, Buf
, Stop
);
78 Item
:= Scan_Integer
(Buf
, Ptr
'Access, Stop
);
79 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
88 Item
: out Long_Long_Integer;
91 Buf
: String (1 .. Field
'Last);
92 Ptr
: aliased Integer := 1;
97 Load_Width
(File
, Width
, Buf
, Stop
);
98 String_Skip
(Buf
, Ptr
);
100 Load_Integer
(File
, Buf
, Stop
);
103 Item
:= Scan_Long_Long_Integer
(Buf
, Ptr
'Access, Stop
);
104 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
116 Pos
: aliased Integer;
119 String_Skip
(From
, Pos
);
120 Item
:= Scan_Integer
(From
, Pos
'Access, From
'Last);
124 when Constraint_Error
=>
134 Item
: out Long_Long_Integer;
137 Pos
: aliased Integer;
140 String_Skip
(From
, Pos
);
141 Item
:= Scan_Long_Long_Integer
(From
, Pos
'Access, From
'Last);
145 when Constraint_Error
=>
153 procedure Load_Integer
156 Ptr
: in out Natural)
163 Load
(File
, Buf
, Ptr
, '+', '-');
165 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
168 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
172 Load_Extended_Digits
(File
, Buf
, Ptr
);
173 Load
(File
, Buf
, Ptr
, Buf
(Hash_Loc
));
176 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
180 -- Note: it is strange to allow a minus sign, since the syntax
181 -- does not, but that is what ACVC test CE3704F, case (6) wants.
183 Load
(File
, Buf
, Ptr
, '+', '-');
184 Load_Digits
(File
, Buf
, Ptr
);
199 Buf
: String (1 .. Field
'Last);
203 if Base
= 10 and then Width
= 0 then
204 Set_Image_Integer
(Item
, Buf
, Ptr
);
206 Set_Image_Width_Integer
(Item
, Width
, Buf
, Ptr
);
208 Set_Image_Based_Integer
(Item
, Base
, Width
, Buf
, Ptr
);
211 Put_Item
(File
, Buf
(1 .. Ptr
));
220 Item
: Long_Long_Integer;
224 Buf
: String (1 .. Field
'Last);
228 if Base
= 10 and then Width
= 0 then
229 Set_Image_Long_Long_Integer
(Item
, Buf
, Ptr
);
231 Set_Image_Width_Long_Long_Integer
(Item
, Width
, Buf
, Ptr
);
233 Set_Image_Based_Long_Long_Integer
(Item
, Base
, Width
, Buf
, Ptr
);
236 Put_Item
(File
, Buf
(1 .. Ptr
));
248 Buf
: String (1 .. Field
'Last);
253 Set_Image_Width_Integer
(Item
, To
'Length, Buf
, Ptr
);
255 Set_Image_Based_Integer
(Item
, Base
, To
'Length, Buf
, Ptr
);
258 if Ptr
> To
'Length then
261 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
271 Item
: Long_Long_Integer;
274 Buf
: String (1 .. Field
'Last);
279 Set_Image_Width_Long_Long_Integer
(Item
, To
'Length, Buf
, Ptr
);
281 Set_Image_Based_Long_Long_Integer
(Item
, Base
, To
'Length, Buf
, Ptr
);
284 if Ptr
> To
'Length then
287 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
291 end Ada
.Wide_Wide_Text_IO
.Integer_Aux
;