annotate gcc/ada/libgnat/a-wtmoio.adb @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 . M O D U L A R _ I O --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
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.Modular_Aux;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 with System.Unsigned_Types; use System.Unsigned_Types;
kono
parents:
diff changeset
35 with System.WCh_Con; use System.WCh_Con;
kono
parents:
diff changeset
36 with System.WCh_WtS; use System.WCh_WtS;
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 package body Ada.Wide_Text_IO.Modular_IO is
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 subtype TFT is Ada.Wide_Text_IO.File_Type;
kono
parents:
diff changeset
41 -- File type required for calls to routines in Aux
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 package Aux renames Ada.Wide_Text_IO.Modular_Aux;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 ---------
kono
parents:
diff changeset
46 -- Get --
kono
parents:
diff changeset
47 ---------
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 procedure Get
kono
parents:
diff changeset
50 (File : File_Type;
kono
parents:
diff changeset
51 Item : out Num;
kono
parents:
diff changeset
52 Width : Field := 0)
kono
parents:
diff changeset
53 is
kono
parents:
diff changeset
54 begin
kono
parents:
diff changeset
55 if Num'Size > Unsigned'Size then
kono
parents:
diff changeset
56 Aux.Get_LLU (TFT (File), Long_Long_Unsigned (Item), Width);
kono
parents:
diff changeset
57 else
kono
parents:
diff changeset
58 Aux.Get_Uns (TFT (File), Unsigned (Item), Width);
kono
parents:
diff changeset
59 end if;
kono
parents:
diff changeset
60
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 > Unsigned'Size then
kono
parents:
diff changeset
86 Aux.Gets_LLU (S, Long_Long_Unsigned (Item), Last);
kono
parents:
diff changeset
87 else
kono
parents:
diff changeset
88 Aux.Gets_Uns (S, Unsigned (Item), Last);
kono
parents:
diff changeset
89 end if;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 exception
kono
parents:
diff changeset
92 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
93 end Get;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 ---------
kono
parents:
diff changeset
96 -- Put --
kono
parents:
diff changeset
97 ---------
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 procedure Put
kono
parents:
diff changeset
100 (File : File_Type;
kono
parents:
diff changeset
101 Item : Num;
kono
parents:
diff changeset
102 Width : Field := Default_Width;
kono
parents:
diff changeset
103 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
104 is
kono
parents:
diff changeset
105 begin
kono
parents:
diff changeset
106 if Num'Size > Unsigned'Size then
kono
parents:
diff changeset
107 Aux.Put_LLU (TFT (File), Long_Long_Unsigned (Item), Width, Base);
kono
parents:
diff changeset
108 else
kono
parents:
diff changeset
109 Aux.Put_Uns (TFT (File), Unsigned (Item), Width, Base);
kono
parents:
diff changeset
110 end if;
kono
parents:
diff changeset
111 end Put;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Put
kono
parents:
diff changeset
114 (Item : Num;
kono
parents:
diff changeset
115 Width : Field := Default_Width;
kono
parents:
diff changeset
116 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
117 is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 Put (Current_Output, Item, Width, Base);
kono
parents:
diff changeset
120 end Put;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 procedure Put
kono
parents:
diff changeset
123 (To : out Wide_String;
kono
parents:
diff changeset
124 Item : Num;
kono
parents:
diff changeset
125 Base : Number_Base := Default_Base)
kono
parents:
diff changeset
126 is
kono
parents:
diff changeset
127 S : String (To'First .. To'Last);
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 begin
kono
parents:
diff changeset
130 if Num'Size > Unsigned'Size then
kono
parents:
diff changeset
131 Aux.Puts_LLU (S, Long_Long_Unsigned (Item), Base);
kono
parents:
diff changeset
132 else
kono
parents:
diff changeset
133 Aux.Puts_Uns (S, Unsigned (Item), Base);
kono
parents:
diff changeset
134 end if;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 for J in S'Range loop
kono
parents:
diff changeset
137 To (J) := Wide_Character'Val (Character'Pos (S (J)));
kono
parents:
diff changeset
138 end loop;
kono
parents:
diff changeset
139 end Put;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 end Ada.Wide_Text_IO.Modular_IO;