1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . F L O A T _ A U X --
9 -- Copyright (C) 1992-2014, 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_Real
; use System
.Img_Real
;
35 with System
.Val_Real
; use System
.Val_Real
;
37 package body Ada
.Wide_Wide_Text_IO
.Float_Aux
is
45 Item
: out Long_Long_Float;
48 Buf
: String (1 .. Field
'Last);
50 Ptr
: aliased Integer := 1;
54 Load_Width
(File
, Width
, Buf
, Stop
);
55 String_Skip
(Buf
, Ptr
);
57 Load_Real
(File
, Buf
, Stop
);
60 Item
:= Scan_Real
(Buf
, Ptr
'Access, Stop
);
62 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
71 Item
: out Long_Long_Float;
74 Pos
: aliased Integer;
77 String_Skip
(From
, Pos
);
78 Item
:= Scan_Real
(From
, Pos
'Access, From
'Last);
82 when Constraint_Error
=>
98 -- Skip initial blanks and load possible sign
101 Load
(File
, Buf
, Ptr
, '+', '-');
105 Load
(File
, Buf
, Ptr
, '.', Loaded
);
108 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
110 -- Hopeless junk if no digits loaded
116 -- Otherwise must have digits to start
119 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
121 -- Hopeless junk if no digits loaded
127 -- Deal with based case. We recognize either the standard '#' or the
128 -- allowed alternative replacement ':' (see RM J.2(3)).
130 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
136 Load
(File
, Buf
, Ptr
, '.', Loaded
);
139 Load_Extended_Digits
(File
, Buf
, Ptr
);
140 Load
(File
, Buf
, Ptr
, '#', ':');
142 -- Case of nnn#xxx.[xxx]# or nnn#xxx#
145 Load_Extended_Digits
(File
, Buf
, Ptr
);
146 Load
(File
, Buf
, Ptr
, '.', Loaded
);
149 Load_Extended_Digits
(File
, Buf
, Ptr
);
152 -- As usual, it seems strange to allow mixed base characters,
153 -- but that is what ACVC tests expect, see CE3804M, case (3).
155 Load
(File
, Buf
, Ptr
, '#', ':');
158 -- Case of nnn.[nnn] or nnn
161 -- Prevent the potential processing of '.' in cases where the
162 -- initial digits have a trailing underscore.
164 if Buf
(Ptr
) = '_' then
168 Load
(File
, Buf
, Ptr
, '.', Loaded
);
171 Load_Digits
(File
, Buf
, Ptr
);
176 -- Deal with exponent
178 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
181 Load
(File
, Buf
, Ptr
, '+', '-');
182 Load_Digits
(File
, Buf
, Ptr
);
192 Item
: Long_Long_Float;
197 Buf
: String (1 .. Field
'Last);
201 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
, Aft
, Exp
);
202 Put_Item
(File
, Buf
(1 .. Ptr
));
211 Item
: Long_Long_Float;
215 Buf
: String (1 .. Field
'Last);
219 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
=> 1, Aft
=> Aft
, Exp
=> Exp
);
221 if Ptr
> To
'Length then
225 for J
in 1 .. Ptr
loop
226 To
(To
'Last - Ptr
+ J
) := Buf
(J
);
229 for J
in To
'First .. To
'Last - Ptr
loop
235 end Ada
.Wide_Wide_Text_IO
.Float_Aux
;