1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . M O D U L A R _ A U X --
9 -- Copyright (C) 1992-2003 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 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Ada
.Wide_Wide_Text_IO
.Generic_Aux
; use Ada
.Wide_Wide_Text_IO
.Generic_Aux
;
36 with System
.Img_BIU
; use System
.Img_BIU
;
37 with System
.Img_Uns
; use System
.Img_Uns
;
38 with System
.Img_LLB
; use System
.Img_LLB
;
39 with System
.Img_LLU
; use System
.Img_LLU
;
40 with System
.Img_LLW
; use System
.Img_LLW
;
41 with System
.Img_WIU
; use System
.Img_WIU
;
42 with System
.Val_Uns
; use System
.Val_Uns
;
43 with System
.Val_LLU
; use System
.Val_LLU
;
45 package body Ada
.Wide_Wide_Text_IO
.Modular_Aux
is
47 use System
.Unsigned_Types
;
49 -----------------------
50 -- Local Subprograms --
51 -----------------------
53 procedure Load_Modular
56 Ptr
: in out Natural);
57 -- This is an auxiliary routine that is used to load an possibly signed
58 -- modular literal value from the input file into Buf, starting at Ptr + 1.
59 -- Ptr is left set to the last character stored.
67 Item
: out Long_Long_Unsigned
;
70 Buf
: String (1 .. Field
'Last);
72 Ptr
: aliased Integer := 1;
76 Load_Width
(File
, Width
, Buf
, Stop
);
77 String_Skip
(Buf
, Ptr
);
79 Load_Modular
(File
, Buf
, Stop
);
82 Item
:= Scan_Long_Long_Unsigned
(Buf
, Ptr
'Access, Stop
);
83 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
95 Buf
: String (1 .. Field
'Last);
97 Ptr
: aliased Integer := 1;
101 Load_Width
(File
, Width
, Buf
, Stop
);
102 String_Skip
(Buf
, Ptr
);
104 Load_Modular
(File
, Buf
, Stop
);
107 Item
:= Scan_Unsigned
(Buf
, Ptr
'Access, Stop
);
108 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
117 Item
: out Long_Long_Unsigned
;
120 Pos
: aliased Integer;
123 String_Skip
(From
, Pos
);
124 Item
:= Scan_Long_Long_Unsigned
(From
, Pos
'Access, From
'Last);
128 when Constraint_Error
=>
141 Pos
: aliased Integer;
144 String_Skip
(From
, Pos
);
145 Item
:= Scan_Unsigned
(From
, Pos
'Access, From
'Last);
149 when Constraint_Error
=>
157 procedure Load_Modular
160 Ptr
: in out Natural)
168 -- Note: it is a bit strange to allow a minus sign here, but it seems
169 -- consistent with the general behavior expected by the ACVC tests
170 -- which is to scan past junk and then signal data error, see ACVC
171 -- test CE3704F, case (6), which is for signed integer exponents,
172 -- which seems a similar case.
174 Load
(File
, Buf
, Ptr
, '+', '-');
175 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
178 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
182 Load_Extended_Digits
(File
, Buf
, Ptr
);
183 Load
(File
, Buf
, Ptr
, Buf
(Hash_Loc
));
186 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
190 -- Note: it is strange to allow a minus sign, since the syntax
191 -- does not, but that is what ACVC test CE3704F, case (6) wants
192 -- for the signed case, and there seems no good reason to treat
193 -- exponents differently for the signed and unsigned cases.
195 Load
(File
, Buf
, Ptr
, '+', '-');
196 Load_Digits
(File
, Buf
, Ptr
);
207 Item
: Long_Long_Unsigned
;
211 Buf
: String (1 .. Field
'Last);
215 if Base
= 10 and then Width
= 0 then
216 Set_Image_Long_Long_Unsigned
(Item
, Buf
, Ptr
);
218 Set_Image_Width_Long_Long_Unsigned
(Item
, Width
, Buf
, Ptr
);
220 Set_Image_Based_Long_Long_Unsigned
(Item
, Base
, Width
, Buf
, Ptr
);
223 Put_Item
(File
, Buf
(1 .. Ptr
));
236 Buf
: String (1 .. Field
'Last);
240 if Base
= 10 and then Width
= 0 then
241 Set_Image_Unsigned
(Item
, Buf
, Ptr
);
243 Set_Image_Width_Unsigned
(Item
, Width
, Buf
, Ptr
);
245 Set_Image_Based_Unsigned
(Item
, Base
, Width
, Buf
, Ptr
);
248 Put_Item
(File
, Buf
(1 .. Ptr
));
257 Item
: Long_Long_Unsigned
;
260 Buf
: String (1 .. Field
'Last);
265 Set_Image_Width_Long_Long_Unsigned
(Item
, To
'Length, Buf
, Ptr
);
267 Set_Image_Based_Long_Long_Unsigned
(Item
, Base
, To
'Length, Buf
, Ptr
);
270 if Ptr
> To
'Length then
273 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
286 Buf
: String (1 .. Field
'Last);
291 Set_Image_Width_Unsigned
(Item
, To
'Length, Buf
, Ptr
);
293 Set_Image_Based_Unsigned
(Item
, Base
, To
'Length, Buf
, Ptr
);
296 if Ptr
> To
'Length then
299 To
(To
'First .. To
'First + Ptr
- 1) := Buf
(1 .. Ptr
);
303 end Ada
.Wide_Wide_Text_IO
.Modular_Aux
;