annotate gcc/ada/libgnat/a-wtdeio.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . W I D E _ T E X T _ I O . D E C I M A L _ I O --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Ada.Wide_Text_IO.Decimal_Aux;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 with System.WCh_Con; use System.WCh_Con;
kono
parents:
diff changeset
35 with System.WCh_WtS; use System.WCh_WtS;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 package body Ada.Wide_Text_IO.Decimal_IO is
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 subtype TFT is Ada.Wide_Text_IO.File_Type;
kono
parents:
diff changeset
40 -- File type required for calls to routines in Aux
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 package Aux renames Ada.Wide_Text_IO.Decimal_Aux;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 Scale : constant Integer := Num'Scale;
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 ---------
kono
parents:
diff changeset
47 -- Get --
kono
parents:
diff changeset
48 ---------
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Get
kono
parents:
diff changeset
51 (File : File_Type;
kono
parents:
diff changeset
52 Item : out Num;
kono
parents:
diff changeset
53 Width : Field := 0)
kono
parents:
diff changeset
54 is
kono
parents:
diff changeset
55 begin
kono
parents:
diff changeset
56 if Num'Size > Integer'Size then
kono
parents:
diff changeset
57 Item := Num'Fixed_Value (Aux.Get_LLD (TFT (File), Width, Scale));
kono
parents:
diff changeset
58 else
kono
parents:
diff changeset
59 Item := Num'Fixed_Value (Aux.Get_Dec (TFT (File), Width, Scale));
kono
parents:
diff changeset
60 end if;
kono
parents:
diff changeset
61 exception
kono
parents:
diff changeset
62 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
63 end Get;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Get
kono
parents:
diff changeset
66 (Item : out Num;
kono
parents:
diff changeset
67 Width : Field := 0)
kono
parents:
diff changeset
68 is
kono
parents:
diff changeset
69 begin
kono
parents:
diff changeset
70 Get (Current_Input, Item, Width);
kono
parents:
diff changeset
71 end Get;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Get
kono
parents:
diff changeset
74 (From : Wide_String;
kono
parents:
diff changeset
75 Item : out Num;
kono
parents:
diff changeset
76 Last : out Positive)
kono
parents:
diff changeset
77 is
kono
parents:
diff changeset
78 S : constant String := Wide_String_To_String (From, WCEM_Upper);
kono
parents:
diff changeset
79 -- String on which we do the actual conversion. Note that the method
kono
parents:
diff changeset
80 -- used for wide character encoding is irrelevant, since if there is
kono
parents:
diff changeset
81 -- a character outside the Standard.Character range then the call to
kono
parents:
diff changeset
82 -- Aux.Gets will raise Data_Error in any case.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 begin
kono
parents:
diff changeset
85 if Num'Size > Integer'Size then
kono
parents:
diff changeset
86 -- Item := Num'Fixed_Value
kono
parents:
diff changeset
87 -- should write above, but gets assert error ???
kono
parents:
diff changeset
88 Item := Num
kono
parents:
diff changeset
89 (Aux.Gets_LLD (S, Last'Unrestricted_Access, Scale));
kono
parents:
diff changeset
90 else
kono
parents:
diff changeset
91 -- Item := Num'Fixed_Value
kono
parents:
diff changeset
92 -- should write above, but gets assert error ???
kono
parents:
diff changeset
93 Item := Num
kono
parents:
diff changeset
94 (Aux.Gets_Dec (S, Last'Unrestricted_Access, Scale));
kono
parents:
diff changeset
95 end if;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 exception
kono
parents:
diff changeset
98 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
99 end Get;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 ---------
kono
parents:
diff changeset
102 -- Put --
kono
parents:
diff changeset
103 ---------
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 procedure Put
kono
parents:
diff changeset
106 (File : File_Type;
kono
parents:
diff changeset
107 Item : Num;
kono
parents:
diff changeset
108 Fore : Field := Default_Fore;
kono
parents:
diff changeset
109 Aft : Field := Default_Aft;
kono
parents:
diff changeset
110 Exp : Field := Default_Exp)
kono
parents:
diff changeset
111 is
kono
parents:
diff changeset
112 begin
kono
parents:
diff changeset
113 if Num'Size > Integer'Size then
kono
parents:
diff changeset
114 Aux.Put_LLD
kono
parents:
diff changeset
115 (TFT (File), Long_Long_Integer'Integer_Value (Item),
kono
parents:
diff changeset
116 Fore, Aft, Exp, Scale);
kono
parents:
diff changeset
117 else
kono
parents:
diff changeset
118 Aux.Put_Dec
kono
parents:
diff changeset
119 (TFT (File), Integer'Integer_Value (Item), Fore, Aft, Exp, Scale);
kono
parents:
diff changeset
120 end if;
kono
parents:
diff changeset
121 end Put;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Put
kono
parents:
diff changeset
124 (Item : Num;
kono
parents:
diff changeset
125 Fore : Field := Default_Fore;
kono
parents:
diff changeset
126 Aft : Field := Default_Aft;
kono
parents:
diff changeset
127 Exp : Field := Default_Exp)
kono
parents:
diff changeset
128 is
kono
parents:
diff changeset
129 begin
kono
parents:
diff changeset
130 Put (Current_Output, Item, Fore, Aft, Exp);
kono
parents:
diff changeset
131 end Put;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 procedure Put
kono
parents:
diff changeset
134 (To : out Wide_String;
kono
parents:
diff changeset
135 Item : Num;
kono
parents:
diff changeset
136 Aft : Field := Default_Aft;
kono
parents:
diff changeset
137 Exp : Field := Default_Exp)
kono
parents:
diff changeset
138 is
kono
parents:
diff changeset
139 S : String (To'First .. To'Last);
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 begin
kono
parents:
diff changeset
142 if Num'Size > Integer'Size then
kono
parents:
diff changeset
143 Aux.Puts_LLD
kono
parents:
diff changeset
144 (S, Long_Long_Integer'Integer_Value (Item), Aft, Exp, Scale);
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 else
kono
parents:
diff changeset
147 Aux.Puts_Dec (S, Integer'Integer_Value (Item), Aft, Exp, Scale);
kono
parents:
diff changeset
148 end if;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 for J in S'Range loop
kono
parents:
diff changeset
151 To (J) := Wide_Character'Val (Character'Pos (S (J)));
kono
parents:
diff changeset
152 end loop;
kono
parents:
diff changeset
153 end Put;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 end Ada.Wide_Text_IO.Decimal_IO;