1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- A D A . T E X T _ I O . D E C I M A L _ A U X --
11 -- Copyright (C) 1992-2001 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
.Text_IO
.Generic_Aux
; use Ada
.Text_IO
.Generic_Aux
;
37 with Ada
.Text_IO
.Float_Aux
; use Ada
.Text_IO
.Float_Aux
;
39 with System
.Img_Dec
; use System
.Img_Dec
;
40 with System
.Img_LLD
; use System
.Img_LLD
;
41 with System
.Val_Dec
; use System
.Val_Dec
;
42 with System
.Val_LLD
; use System
.Val_LLD
;
44 package body Ada
.Text_IO
.Decimal_Aux
is
56 Buf
: String (1 .. Field
'Last);
57 Ptr
: aliased Integer;
63 Load_Width
(File
, Width
, Buf
, Stop
);
64 String_Skip
(Buf
, Ptr
);
66 Load_Real
(File
, Buf
, Stop
);
70 Item
:= Scan_Decimal
(Buf
, Ptr
'Access, Stop
, Scale
);
71 Check_End_Of_Field
(File
, Buf
, Stop
, Ptr
, Width
);
83 return Long_Long_Integer
85 Buf
: String (1 .. Field
'Last);
86 Ptr
: aliased Integer;
88 Item
: Long_Long_Integer;
92 Load_Width
(File
, Width
, Buf
, Stop
);
93 String_Skip
(Buf
, Ptr
);
95 Load_Real
(File
, Buf
, Stop
);
99 Item
:= Scan_Long_Long_Decimal
(Buf
, Ptr
'Access, Stop
, Scale
);
100 Check_End_Of_Field
(File
, Buf
, Stop
, Ptr
, Width
);
110 Last
: access Positive;
114 Pos
: aliased Integer;
118 String_Skip
(From
, Pos
);
119 Item
:= Scan_Decimal
(From
, Pos
'Access, From
'Last, Scale
);
124 when Constraint_Error
=>
135 Last
: access Positive;
137 return Long_Long_Integer
139 Pos
: aliased Integer;
140 Item
: Long_Long_Integer;
143 String_Skip
(From
, Pos
);
144 Item
:= Scan_Long_Long_Decimal
(From
, Pos
'Access, From
'Last, Scale
);
149 when Constraint_Error
=>
159 (File
: in File_Type
;
166 Buf
: String (1 .. Field
'Last);
170 Set_Image_Decimal
(Item
, Buf
, Ptr
, Scale
, Fore
, Aft
, Exp
);
171 Put_Item
(File
, Buf
(1 .. Ptr
));
179 (File
: in File_Type
;
180 Item
: in Long_Long_Integer;
186 Buf
: String (1 .. Field
'Last);
190 Set_Image_Long_Long_Decimal
(Item
, Buf
, Ptr
, Scale
, Fore
, Aft
, Exp
);
191 Put_Item
(File
, Buf
(1 .. Ptr
));
205 Buf
: String (1 .. Field
'Last);
211 Fore
:= To
'Length - 1 - Aft
;
213 Fore
:= To
'Length - 2 - Aft
- Exp
;
220 Set_Image_Decimal
(Item
, Buf
, Ptr
, Scale
, Fore
, Aft
, Exp
);
222 if Ptr
> To
'Length then
225 To
:= Buf
(1 .. Ptr
);
235 Item
: in Long_Long_Integer;
240 Buf
: String (1 .. Field
'Last);
246 Fore
:= To
'Length - 1 - Aft
;
248 Fore
:= To
'Length - 2 - Aft
- Exp
;
255 Set_Image_Long_Long_Decimal
(Item
, Buf
, Ptr
, Scale
, Fore
, Aft
, Exp
);
257 if Ptr
> To
'Length then
260 To
:= Buf
(1 .. Ptr
);
264 end Ada
.Text_IO
.Decimal_Aux
;