1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- A D A . W I D E _ T E X T _ I O . D E C I M A L _ 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.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux;
36 with Ada.Wide_Text_IO.Float_Aux; use Ada.Wide_Text_IO.Float_Aux;
38 with System.Img_Dec; use System.Img_Dec;
39 with System.Img_LLD; use System.Img_LLD;
40 with System.Val_Dec; use System.Val_Dec;
41 with System.Val_LLD; use System.Val_LLD;
43 package body Ada.Wide_Text_IO.Decimal_Aux is
55 Buf : String (1 .. Field'Last);
56 Ptr : aliased Integer;
62 Load_Width (File, Width, Buf, Stop);
63 String_Skip (Buf, Ptr);
65 Load_Real (File, Buf, Stop);
69 Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale);
70 Check_End_Of_Field (Buf, Stop, Ptr, Width);
82 return Long_Long_Integer
84 Buf : String (1 .. Field'Last);
85 Ptr : aliased Integer;
87 Item : Long_Long_Integer;
91 Load_Width (File, Width, Buf, Stop);
92 String_Skip (Buf, Ptr);
94 Load_Real (File, Buf, Stop);
98 Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale);
99 Check_End_Of_Field (Buf, Stop, Ptr, Width);
109 Last : access Positive;
113 Pos : aliased Integer;
117 String_Skip (From, Pos);
118 Item := Scan_Decimal (From, Pos'Access, From'Last, Scale);
123 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 =>
167 Buf : String (1 .. Field'Last);
171 Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
172 Put_Item (File, Buf (1 .. Ptr));
181 Item : Long_Long_Integer;
187 Buf : String (1 .. Field'Last);
191 Set_Image_Long_Long_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
192 Put_Item (File, Buf (1 .. Ptr));
206 Buf : String (1 .. Field'Last);
212 Fore := To'Length - 1 - Aft;
214 Fore := To'Length - 2 - Aft - Exp;
221 Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
223 if Ptr > To'Length then
226 To := Buf (1 .. Ptr);
236 Item : Long_Long_Integer;
241 Buf : String (1 .. Field'Last);
247 Fore := To'Length - 1 - Aft;
249 Fore := To'Length - 2 - Aft - Exp;
256 Set_Image_Long_Long_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp);
258 if Ptr > To'Length then
261 To := Buf (1 .. Ptr);
265 end Ada.Wide_Text_IO.Decimal_Aux;