]>
Commit | Line | Data |
---|---|---|
cacbc350 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
edd63e9b | 3 | -- GNAT RUN-TIME COMPONENTS -- |
cacbc350 RK |
4 | -- -- |
5 | -- S Y S T E M . W W D _ W C H A R -- | |
6 | -- -- | |
7 | -- B o d y -- | |
8 | -- -- | |
748086b7 | 9 | -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- |
cacbc350 RK |
10 | -- -- |
11 | -- GNAT is free software; you can redistribute it and/or modify it under -- | |
12 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
748086b7 | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
cacbc350 RK |
14 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
15 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
748086b7 JJ |
16 | -- or FITNESS FOR A PARTICULAR PURPOSE. -- |
17 | -- -- | |
18 | -- As a special exception under Section 7 of GPL version 3, you are granted -- | |
19 | -- additional permissions described in the GCC Runtime Library Exception, -- | |
20 | -- version 3.1, as published by the Free Software Foundation. -- | |
21 | -- -- | |
22 | -- You should have received a copy of the GNU General Public License and -- | |
23 | -- a copy of the GCC Runtime Library Exception along with this program; -- | |
24 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | |
25 | -- <http://www.gnu.org/licenses/>. -- | |
cacbc350 RK |
26 | -- -- |
27 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 28 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
cacbc350 RK |
29 | -- -- |
30 | ------------------------------------------------------------------------------ | |
31 | ||
82c80734 RD |
32 | with Interfaces; use Interfaces; |
33 | ||
34 | with System.WWd_Char; | |
35 | ||
cacbc350 RK |
36 | package body System.Wwd_WChar is |
37 | ||
82c80734 RD |
38 | ------------------------------------ |
39 | -- Wide_Wide_Width_Wide_Character -- | |
40 | ------------------------------------ | |
41 | ||
42 | -- This is the case where we are talking about the Wide_Wide_Image of | |
43 | -- a Wide_Character, which is always the same character sequence as the | |
44 | -- Wide_Image of the same Wide_Character. | |
45 | ||
46 | function Wide_Wide_Width_Wide_Character | |
47 | (Lo, Hi : Wide_Character) return Natural | |
48 | is | |
49 | begin | |
50 | return Wide_Width_Wide_Character (Lo, Hi); | |
51 | end Wide_Wide_Width_Wide_Character; | |
52 | ||
53 | ------------------------------------ | |
54 | -- Wide_Wide_Width_Wide_Wide_Char -- | |
55 | ------------------------------------ | |
56 | ||
57 | function Wide_Wide_Width_Wide_Wide_Char | |
58 | (Lo, Hi : Wide_Wide_Character) return Natural | |
59 | is | |
82c80734 RD |
60 | LV : constant Unsigned_32 := Wide_Wide_Character'Pos (Lo); |
61 | HV : constant Unsigned_32 := Wide_Wide_Character'Pos (Hi); | |
62 | ||
63 | begin | |
64 | -- Return zero if empty range | |
65 | ||
66 | if LV > HV then | |
67 | return 0; | |
edd63e9b ES |
68 | |
69 | -- Return max value (12) for wide character (Hex_hhhhhhhh) | |
70 | ||
71 | elsif HV > 255 then | |
72 | return 12; | |
82c80734 RD |
73 | |
74 | -- If any characters in normal character range, then use normal | |
75 | -- Wide_Wide_Width attribute on this range to find out a starting point. | |
76 | -- Otherwise start with zero. | |
77 | ||
edd63e9b ES |
78 | else |
79 | return | |
82c80734 RD |
80 | System.WWd_Char.Wide_Wide_Width_Character |
81 | (Lo => Character'Val (LV), | |
82 | Hi => Character'Val (Unsigned_32'Min (255, HV))); | |
82c80734 | 83 | end if; |
82c80734 RD |
84 | end Wide_Wide_Width_Wide_Wide_Char; |
85 | ||
cacbc350 RK |
86 | ------------------------------- |
87 | -- Wide_Width_Wide_Character -- | |
88 | ------------------------------- | |
89 | ||
90 | function Wide_Width_Wide_Character | |
82c80734 | 91 | (Lo, Hi : Wide_Character) return Natural |
cacbc350 | 92 | is |
82c80734 RD |
93 | LV : constant Unsigned_32 := Wide_Character'Pos (Lo); |
94 | HV : constant Unsigned_32 := Wide_Character'Pos (Hi); | |
cacbc350 RK |
95 | |
96 | begin | |
82c80734 | 97 | -- Return zero if empty range |
cacbc350 | 98 | |
82c80734 RD |
99 | if LV > HV then |
100 | return 0; | |
edd63e9b ES |
101 | |
102 | -- Return max value (12) for wide character (Hex_hhhhhhhh) | |
103 | ||
104 | elsif HV > 255 then | |
105 | return 12; | |
cacbc350 | 106 | |
82c80734 RD |
107 | -- If any characters in normal character range, then use normal |
108 | -- Wide_Wide_Width attribute on this range to find out a starting point. | |
109 | -- Otherwise start with zero. | |
cacbc350 | 110 | |
edd63e9b ES |
111 | else |
112 | return | |
82c80734 RD |
113 | System.WWd_Char.Wide_Width_Character |
114 | (Lo => Character'Val (LV), | |
115 | Hi => Character'Val (Unsigned_32'Min (255, HV))); | |
82c80734 | 116 | end if; |
cacbc350 RK |
117 | end Wide_Width_Wide_Character; |
118 | ||
82c80734 RD |
119 | ------------------------------------ |
120 | -- Wide_Width_Wide_Wide_Character -- | |
121 | ------------------------------------ | |
122 | ||
82c80734 RD |
123 | function Wide_Width_Wide_Wide_Character |
124 | (Lo, Hi : Wide_Wide_Character) return Natural | |
125 | is | |
82c80734 | 126 | begin |
edd63e9b | 127 | return Wide_Wide_Width_Wide_Wide_Char (Lo, Hi); |
82c80734 RD |
128 | end Wide_Width_Wide_Wide_Character; |
129 | ||
cacbc350 | 130 | end System.Wwd_WChar; |