annotate gcc/ada/libgnat/a-wtinio.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 . I N T E G E R _ 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.Integer_Aux;
kono
parents:
diff changeset
33 with System.WCh_Con; use System.WCh_Con;
kono
parents:
diff changeset
34 with System.WCh_WtS; use System.WCh_WtS;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package body Ada.Wide_Text_IO.Integer_IO is
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 Need_LLI : constant Boolean := Num'Base'Size > Integer'Size;
kono
parents:
diff changeset
39 -- Throughout this generic body, we distinguish between the case where type
kono
parents:
diff changeset
40 -- Integer is acceptable, and where a Long_Long_Integer is needed. This
kono
parents:
diff changeset
41 -- Boolean is used to test for these cases and since it is a constant, only
kono
parents:
diff changeset
42 -- code for the relevant case will be included in the instance.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 subtype TFT is Ada.Wide_Text_IO.File_Type;
kono
parents:
diff changeset
45 -- File type required for calls to routines in Aux
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 package Aux renames Ada.Wide_Text_IO.Integer_Aux;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 ---------
kono
parents:
diff changeset
50 -- Get --
kono
parents:
diff changeset
51 ---------
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 procedure Get
kono
parents:
diff changeset
54 (File : File_Type;
kono
parents:
diff changeset
55 Item : out Num;
kono
parents:
diff changeset
56 Width : Field := 0)
kono
parents:
diff changeset
57 is
kono
parents:
diff changeset
58 begin
kono
parents:
diff changeset
59 if Need_LLI then
kono
parents:
diff changeset
60 Aux.Get_LLI (TFT (File), Long_Long_Integer (Item), Width);
kono
parents:
diff changeset
61 else
kono
parents:
diff changeset
62 Aux.Get_Int (TFT (File), Integer (Item), Width);
kono
parents:
diff changeset
63 end if;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 exception
kono
parents:
diff changeset
66 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
67 end Get;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 procedure Get
kono
parents:
diff changeset
70 (Item : out Num;
kono
parents:
diff changeset
71 Width : Field := 0)
kono
parents:
diff changeset
72 is
kono
parents:
diff changeset
73 begin
kono
parents:
diff changeset
74 Get (Current_Input, Item, Width);
kono
parents:
diff changeset
75 end Get;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 procedure Get
kono
parents:
diff changeset
78 (From : Wide_String;
kono
parents:
diff changeset
79 Item : out Num;
kono
parents:
diff changeset
80 Last : out Positive)
kono
parents:
diff changeset
81 is
kono
parents:
diff changeset
82 S : constant String := Wide_String_To_String (From, WCEM_Upper);
kono
parents:
diff changeset
83 -- String on which we do the actual conversion. Note that the method
kono
parents:
diff changeset
84 -- used for wide character encoding is irrelevant, since if there is
kono
parents:
diff changeset
85 -- a character outside the Standard.Character range then the call to
kono
parents:
diff changeset
86 -- Aux.Gets will raise Data_Error in any case.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 begin
kono
parents:
diff changeset
89 if Need_LLI then
kono
parents:
diff changeset
90 Aux.Gets_LLI (S, Long_Long_Integer (Item), Last);
kono
parents:
diff changeset
91 else
kono
parents:
diff changeset
92 Aux.Gets_Int (S, Integer (Item), Last);
kono
parents:
diff changeset
93 end if;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 exception
kono
parents:
diff changeset
96 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
97 end Get;
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 ---------
kono
parents:
diff changeset
100 -- Put --
kono
parents:
diff changeset
101 ---------
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Put
kono
parents:
diff changeset
104 (File : File_Type;
kono
parents:
diff changeset
105 Item : Num;
kono
parents:
diff changeset
106 Width : Field := Default_Width;
kono
parents:
diff changeset
107 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
108 is
kono
parents:
diff changeset
109 begin
kono
parents:
diff changeset
110 if Need_LLI then
kono
parents:
diff changeset
111 Aux.Put_LLI (TFT (File), Long_Long_Integer (Item), Width, Base);
kono
parents:
diff changeset
112 else
kono
parents:
diff changeset
113 Aux.Put_Int (TFT (File), Integer (Item), Width, Base);
kono
parents:
diff changeset
114 end if;
kono
parents:
diff changeset
115 end Put;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Put
kono
parents:
diff changeset
118 (Item : Num;
kono
parents:
diff changeset
119 Width : Field := Default_Width;
kono
parents:
diff changeset
120 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
121 is
kono
parents:
diff changeset
122 begin
kono
parents:
diff changeset
123 Put (Current_Output, Item, Width, Base);
kono
parents:
diff changeset
124 end Put;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Put
kono
parents:
diff changeset
127 (To : out Wide_String;
kono
parents:
diff changeset
128 Item : Num;
kono
parents:
diff changeset
129 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
130 is
kono
parents:
diff changeset
131 S : String (To'First .. To'Last);
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134 if Need_LLI then
kono
parents:
diff changeset
135 Aux.Puts_LLI (S, Long_Long_Integer (Item), Base);
kono
parents:
diff changeset
136 else
kono
parents:
diff changeset
137 Aux.Puts_Int (S, Integer (Item), Base);
kono
parents:
diff changeset
138 end if;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 for J in S'Range loop
kono
parents:
diff changeset
141 To (J) := Wide_Character'Val (Character'Pos (S (J)));
kono
parents:
diff changeset
142 end loop;
kono
parents:
diff changeset
143 end Put;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 end Ada.Wide_Text_IO.Integer_IO;