1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . F L O A T _ 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 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
35 with Ada
.Text_IO
.Generic_Aux
; use Ada
.Text_IO
.Generic_Aux
;
37 with System
.Img_Real
; use System
.Img_Real
;
38 with System
.Val_Real
; use System
.Val_Real
;
40 package body Ada
.Text_IO
.Float_Aux
is
48 Item
: out Long_Long_Float;
51 Buf
: String (1 .. Field
'Last);
53 Ptr
: aliased Integer := 1;
57 Load_Width
(File
, Width
, Buf
, Stop
);
58 String_Skip
(Buf
, Ptr
);
60 Load_Real
(File
, Buf
, Stop
);
63 Item
:= Scan_Real
(Buf
, Ptr
'Access, Stop
);
65 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
74 Item
: out Long_Long_Float;
77 Pos
: aliased Integer;
80 String_Skip
(From
, Pos
);
81 Item
:= Scan_Real
(From
, Pos
'Access, From
'Last);
85 when Constraint_Error
=>
102 -- Skip initial blanks, and load possible sign
105 Load
(File
, Buf
, Ptr
, '+', '-');
109 Load
(File
, Buf
, Ptr
, '.', Loaded
);
112 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
114 -- Hopeless junk if no digits loaded
120 -- Otherwise must have digits to start
123 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
125 -- Hopeless junk if no digits loaded
133 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
139 Load
(File
, Buf
, Ptr
, '.', Loaded
);
142 Load_Extended_Digits
(File
, Buf
, Ptr
);
144 -- Case of nnn#xxx.[xxx]# or nnn#xxx#
147 Load_Extended_Digits
(File
, Buf
, Ptr
);
148 Load
(File
, Buf
, Ptr
, '.', Loaded
);
151 Load_Extended_Digits
(File
, Buf
, Ptr
);
154 -- As usual, it seems strange to allow mixed base characters,
155 -- but that is what ACVC tests expect, see CE3804M, case (3).
157 Load
(File
, Buf
, Ptr
, '#', ':');
160 -- Case of nnn.[nnn] or nnn
163 Load
(File
, Buf
, Ptr
, '.', Loaded
);
166 Load_Digits
(File
, Buf
, Ptr
);
171 -- Deal with exponent
173 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
176 Load
(File
, Buf
, Ptr
, '+', '-');
177 Load_Digits
(File
, Buf
, Ptr
);
186 (File
: in File_Type
;
187 Item
: in Long_Long_Float;
192 Buf
: String (1 .. 3 * Field
'Last + 2);
196 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
, Aft
, Exp
);
197 Put_Item
(File
, Buf
(1 .. Ptr
));
206 Item
: in Long_Long_Float;
210 Buf
: String (1 .. 3 * Field
'Last + 2);
214 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
=> 1, Aft
=> Aft
, Exp
=> Exp
);
216 if Ptr
> To
'Length then
220 for J
in 1 .. Ptr
loop
221 To
(To
'Last - Ptr
+ J
) := Buf
(J
);
224 for J
in To
'First .. To
'Last - Ptr
loop
230 end Ada
.Text_IO
.Float_Aux
;