1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ T E X T _ I O . F L O A T _ A U X --
9 -- $Revision: 1.1.16.1 $
11 -- Copyright (C) 1992-1998 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 with Ada
.Wide_Text_IO
.Generic_Aux
; use Ada
.Wide_Text_IO
.Generic_Aux
;
38 with System
.Img_Real
; use System
.Img_Real
;
39 with System
.Val_Real
; use System
.Val_Real
;
41 package body Ada
.Wide_Text_IO
.Float_Aux
is
49 Item
: out Long_Long_Float;
52 Buf
: String (1 .. Field
'Last);
54 Ptr
: aliased Integer := 1;
58 Load_Width
(File
, Width
, Buf
, Stop
);
59 String_Skip
(Buf
, Ptr
);
61 Load_Real
(File
, Buf
, Stop
);
64 Item
:= Scan_Real
(Buf
, Ptr
'Access, Stop
);
66 Check_End_Of_Field
(File
, Buf
, Stop
, Ptr
, Width
);
75 Item
: out Long_Long_Float;
78 Pos
: aliased Integer;
81 String_Skip
(From
, Pos
);
82 Item
:= Scan_Real
(From
, Pos
'Access, From
'Last);
86 when Constraint_Error
=>
103 -- Skip initial blanks and load possible sign
106 Load
(File
, Buf
, Ptr
, '+', '-');
110 Load
(File
, Buf
, Ptr
, '.', Loaded
);
113 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
115 -- Hopeless junk if no digits loaded
121 -- Otherwise must have digits to start
124 Load_Digits
(File
, Buf
, Ptr
, Loaded
);
126 -- Hopeless junk if no digits loaded
134 Load
(File
, Buf
, Ptr
, '#', ':', Loaded
);
140 Load
(File
, Buf
, Ptr
, '.', Loaded
);
143 Load_Extended_Digits
(File
, Buf
, Ptr
);
145 -- Case of nnn#xxx.[xxx]# or nnn#xxx#
148 Load_Extended_Digits
(File
, Buf
, Ptr
);
149 Load
(File
, Buf
, Ptr
, '.', Loaded
);
152 Load_Extended_Digits
(File
, Buf
, Ptr
);
155 -- As usual, it seems strange to allow mixed base characters,
156 -- but that is what ACVC tests expect, see CE3804M, case (3).
158 Load
(File
, Buf
, Ptr
, '#', ':');
161 -- Case of nnn.[nnn] or nnn
164 Load
(File
, Buf
, Ptr
, '.', Loaded
);
167 Load_Digits
(File
, Buf
, Ptr
);
172 -- Deal with exponent
174 Load
(File
, Buf
, Ptr
, 'E', 'e', Loaded
);
177 Load
(File
, Buf
, Ptr
, '+', '-');
178 Load_Digits
(File
, Buf
, Ptr
);
187 (File
: in File_Type
;
188 Item
: in Long_Long_Float;
193 Buf
: String (1 .. Field
'Last);
197 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
, Aft
, Exp
);
198 Put_Item
(File
, Buf
(1 .. Ptr
));
207 Item
: in Long_Long_Float;
211 Buf
: String (1 .. Field
'Last);
215 Set_Image_Real
(Item
, Buf
, Ptr
, Fore
=> 1, Aft
=> Aft
, Exp
=> Exp
);
217 if Ptr
> To
'Length then
221 for J
in 1 .. Ptr
loop
222 To
(To
'Last - Ptr
+ J
) := Buf
(J
);
225 for J
in To
'First .. To
'Last - Ptr
loop
231 end Ada
.Wide_Text_IO
.Float_Aux
;