1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . F L O A T _ A U X --
9 -- Copyright (C) 1992-2007, 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
.Text_IO
.Generic_Aux
; use Ada
.Text_IO
.Generic_Aux
;
36 with System
.Img_Real
; use System
.Img_Real
;
37 with System
.Val_Real
; use System
.Val_Real
;
39 package body Ada
.Text_IO
.Float_Aux
is
47 Item
: out Long_Long_Float;
50 Buf
: String (1 .. Field
'Last);
52 Ptr
: aliased Integer := 1;
56 Load_Width
(File
, Width
, Buf
, Stop
);
57 String_Skip
(Buf
, Ptr
);
59 Load_Real
(File
, Buf
, Stop
);
62 Item
:= Scan_Real
(Buf
, Ptr
'Access, Stop
);
64 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
73 Item
: out Long_Long_Float;
76 Pos
: aliased Integer;
79 String_Skip
(From
, Pos
);
80 Item
:= Scan_Real
(From
, Pos
'Access, From
'Last);
84 when Constraint_Error
=>
100 -- Skip initial blanks, and load possible sign
103 Load
(File
, Buf
, Ptr
, '+', '-');
107 Load
(File
, Buf
, Ptr
, '.', Loaded
);
110 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
112 -- Hopeless junk if no digits loaded
118 -- Otherwise must have digits to start
121 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
123 -- Hopeless junk if no digits loaded
131 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
137 Load
(File
, Buf
, Ptr
, '.', Loaded
);
140 Load_Extended_Digits
(File
, Buf
, Ptr
);
141 Load
(File
, Buf
, Ptr
, '#', ':');
143 -- Case of nnn#xxx.[xxx]# or nnn#xxx#
146 Load_Extended_Digits
(File
, Buf
, Ptr
);
147 Load
(File
, Buf
, Ptr
, '.', Loaded
);
150 Load_Extended_Digits
(File
, Buf
, Ptr
);
153 -- As usual, it seems strange to allow mixed base characters,
154 -- but that is what ACVC tests expect, see CE3804M, case (3).
156 Load
(File
, Buf
, Ptr
, '#', ':');
159 -- Case of nnn.[nnn] or nnn
162 -- Prevent the potential processing of '.' in cases where the
163 -- initial digits have a trailing underscore.
165 if Buf
(Ptr
) = '_' then
169 Load
(File
, Buf
, Ptr
, '.', Loaded
);
172 Load_Digits
(File
, Buf
, Ptr
);
177 -- Deal with exponent
179 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
182 Load
(File
, Buf
, Ptr
, '+', '-');
183 Load_Digits
(File
, Buf
, Ptr
);
193 Item
: Long_Long_Float;
198 Buf
: String (1 .. 3 * Field
'Last + 2);
202 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
, Aft
, Exp
);
203 Put_Item
(File
, Buf
(1 .. Ptr
));
212 Item
: Long_Long_Float;
216 Buf
: String (1 .. 3 * Field
'Last + 2);
220 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
=> 1, Aft
=> Aft
, Exp
=> Exp
);
222 if Ptr
> To
'Length then
226 for J
in 1 .. Ptr
loop
227 To
(To
'Last - Ptr
+ J
) := Buf
(J
);
230 for J
in To
'First .. To
'Last - Ptr
loop
236 end Ada
.Text_IO
.Float_Aux
;