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 I X E D _ I O --
9 -- Copyright (C) 2020-2023, 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 package body Ada
.Wide_Wide_Text_IO
.Fixed_Aux
is
46 Buf
: String (1 .. Field
'Last);
47 Ptr
: aliased Integer;
53 Load_Width
(File
, Width
, Buf
, Stop
);
54 String_Skip
(Buf
, Ptr
);
56 Load_Real
(File
, Buf
, Stop
);
60 Item
:= Scan
(Buf
, Ptr
'Access, Stop
, Num
, Den
);
61 Check_End_Of_Field
(Buf
, Stop
, Ptr
, Width
);
75 Pos
: aliased Integer;
79 String_Skip
(From
, Pos
);
80 Item
:= Scan
(From
, Pos
'Access, From
'Last, Num
, Den
);
85 when Constraint_Error
=>
105 Buf
: String (1 .. Field
'Last);
109 Set_Image
(Item
, Buf
, Ptr
, Num
, Den
, For0
, Aft0
, Fore
, Aft
, Exp
);
110 Put_Item
(File
, Buf
(1 .. Ptr
));
127 Buf
: String (1 .. Positive'Max (Field
'Last, To
'Length));
132 -- Compute Fore, allowing for the decimal dot and Aft digits
134 Fore
:= To
'Length - 1 - Field
'Max (1, Aft
);
136 -- Allow for Exp and one more for E if exponent present
139 Fore
:= Fore
- 1 - Field
'Max (2, Exp
);
142 -- Make sure we have enough room
144 if Fore
< 1 + Boolean'Pos (Item
< 0) then
148 -- Do the conversion and check length of result
150 Set_Image
(Item
, Buf
, Ptr
, Num
, Den
, For0
, Aft0
, Fore
, Aft
, Exp
);
152 if Ptr
> To
'Length then
155 To
:= Buf
(1 .. Ptr
);
159 end Ada
.Wide_Wide_Text_IO
.Fixed_Aux
;