2626#define NUMERIC_MASK 0x1000
2727
2828typedef struct {
29- const Py_UNICODE upper ;
30- const Py_UNICODE lower ;
31- const Py_UNICODE title ;
29+ const Py_UCS4 upper ;
30+ const Py_UCS4 lower ;
31+ const Py_UCS4 title ;
3232 const unsigned char decimal ;
3333 const unsigned char digit ;
3434 const unsigned short flags ;
@@ -37,15 +37,13 @@ typedef struct {
3737#include "unicodetype_db.h"
3838
3939static const _PyUnicode_TypeRecord *
40- gettyperecord (Py_UNICODE code )
40+ gettyperecord (Py_UCS4 code )
4141{
4242 int index ;
4343
44- #ifdef Py_UNICODE_WIDE
4544 if (code >= 0x110000 )
4645 index = 0 ;
4746 else
48- #endif
4947 {
5048 index = index1 [(code >>SHIFT )];
5149 index = index2 [(index <<SHIFT )+ (code & ((1 <<SHIFT )- 1 ))];
@@ -57,7 +55,7 @@ gettyperecord(Py_UNICODE code)
5755/* Returns the titlecase Unicode characters corresponding to ch or just
5856 ch if no titlecase mapping is known. */
5957
60- Py_UNICODE _PyUnicode_ToTitlecase (register Py_UNICODE ch )
58+ Py_UCS4 _PyUnicode_ToTitlecase (register Py_UCS4 ch )
6159{
6260 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
6361 int delta = ctype -> title ;
@@ -74,7 +72,7 @@ Py_UNICODE _PyUnicode_ToTitlecase(register Py_UNICODE ch)
7472/* Returns 1 for Unicode characters having the category 'Lt', 0
7573 otherwise. */
7674
77- int _PyUnicode_IsTitlecase (Py_UNICODE ch )
75+ int _PyUnicode_IsTitlecase (Py_UCS4 ch )
7876{
7977 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
8078
@@ -84,7 +82,7 @@ int _PyUnicode_IsTitlecase(Py_UNICODE ch)
8482/* Returns 1 for Unicode characters having the XID_Start property, 0
8583 otherwise. */
8684
87- int _PyUnicode_IsXidStart (Py_UNICODE ch )
85+ int _PyUnicode_IsXidStart (Py_UCS4 ch )
8886{
8987 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
9088
@@ -94,7 +92,7 @@ int _PyUnicode_IsXidStart(Py_UNICODE ch)
9492/* Returns 1 for Unicode characters having the XID_Continue property,
9593 0 otherwise. */
9694
97- int _PyUnicode_IsXidContinue (Py_UNICODE ch )
95+ int _PyUnicode_IsXidContinue (Py_UCS4 ch )
9896{
9997 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
10098
@@ -104,14 +102,14 @@ int _PyUnicode_IsXidContinue(Py_UNICODE ch)
104102/* Returns the integer decimal (0-9) for Unicode characters having
105103 this property, -1 otherwise. */
106104
107- int _PyUnicode_ToDecimalDigit (Py_UNICODE ch )
105+ int _PyUnicode_ToDecimalDigit (Py_UCS4 ch )
108106{
109107 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
110108
111109 return (ctype -> flags & DECIMAL_MASK ) ? ctype -> decimal : -1 ;
112110}
113111
114- int _PyUnicode_IsDecimalDigit (Py_UNICODE ch )
112+ int _PyUnicode_IsDecimalDigit (Py_UCS4 ch )
115113{
116114 if (_PyUnicode_ToDecimalDigit (ch ) < 0 )
117115 return 0 ;
@@ -121,14 +119,14 @@ int _PyUnicode_IsDecimalDigit(Py_UNICODE ch)
121119/* Returns the integer digit (0-9) for Unicode characters having
122120 this property, -1 otherwise. */
123121
124- int _PyUnicode_ToDigit (Py_UNICODE ch )
122+ int _PyUnicode_ToDigit (Py_UCS4 ch )
125123{
126124 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
127125
128126 return (ctype -> flags & DIGIT_MASK ) ? ctype -> digit : -1 ;
129127}
130128
131- int _PyUnicode_IsDigit (Py_UNICODE ch )
129+ int _PyUnicode_IsDigit (Py_UCS4 ch )
132130{
133131 if (_PyUnicode_ToDigit (ch ) < 0 )
134132 return 0 ;
@@ -138,7 +136,7 @@ int _PyUnicode_IsDigit(Py_UNICODE ch)
138136/* Returns the numeric value as double for Unicode characters having
139137 this property, -1.0 otherwise. */
140138
141- int _PyUnicode_IsNumeric (Py_UNICODE ch )
139+ int _PyUnicode_IsNumeric (Py_UCS4 ch )
142140{
143141 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
144142
@@ -158,7 +156,7 @@ int _PyUnicode_IsNumeric(Py_UNICODE ch)
158156 * Zp Separator, Paragraph ('\u2029', PARAGRAPH SEPARATOR)
159157 * Zs (Separator, Space) other than ASCII space('\x20').
160158*/
161- int _PyUnicode_IsPrintable (Py_UNICODE ch )
159+ int _PyUnicode_IsPrintable (Py_UCS4 ch )
162160{
163161 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
164162
@@ -170,7 +168,7 @@ int _PyUnicode_IsPrintable(Py_UNICODE ch)
170168/* Returns 1 for Unicode characters having the category 'Ll', 0
171169 otherwise. */
172170
173- int _PyUnicode_IsLowercase (Py_UNICODE ch )
171+ int _PyUnicode_IsLowercase (Py_UCS4 ch )
174172{
175173 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
176174
@@ -180,7 +178,7 @@ int _PyUnicode_IsLowercase(Py_UNICODE ch)
180178/* Returns 1 for Unicode characters having the category 'Lu', 0
181179 otherwise. */
182180
183- int _PyUnicode_IsUppercase (Py_UNICODE ch )
181+ int _PyUnicode_IsUppercase (Py_UCS4 ch )
184182{
185183 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
186184
@@ -190,7 +188,7 @@ int _PyUnicode_IsUppercase(Py_UNICODE ch)
190188/* Returns the uppercase Unicode characters corresponding to ch or just
191189 ch if no uppercase mapping is known. */
192190
193- Py_UNICODE _PyUnicode_ToUppercase (Py_UNICODE ch )
191+ Py_UCS4 _PyUnicode_ToUppercase (Py_UCS4 ch )
194192{
195193 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
196194 int delta = ctype -> upper ;
@@ -204,7 +202,7 @@ Py_UNICODE _PyUnicode_ToUppercase(Py_UNICODE ch)
204202/* Returns the lowercase Unicode characters corresponding to ch or just
205203 ch if no lowercase mapping is known. */
206204
207- Py_UNICODE _PyUnicode_ToLowercase (Py_UNICODE ch )
205+ Py_UCS4 _PyUnicode_ToLowercase (Py_UCS4 ch )
208206{
209207 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
210208 int delta = ctype -> lower ;
@@ -218,7 +216,7 @@ Py_UNICODE _PyUnicode_ToLowercase(Py_UNICODE ch)
218216/* Returns 1 for Unicode characters having the category 'Ll', 'Lu', 'Lt',
219217 'Lo' or 'Lm', 0 otherwise. */
220218
221- int _PyUnicode_IsAlpha (Py_UNICODE ch )
219+ int _PyUnicode_IsAlpha (Py_UCS4 ch )
222220{
223221 const _PyUnicode_TypeRecord * ctype = gettyperecord (ch );
224222
@@ -230,27 +228,27 @@ int _PyUnicode_IsAlpha(Py_UNICODE ch)
230228/* Export the interfaces using the wchar_t type for portability
231229 reasons: */
232230
233- int _PyUnicode_IsLowercase (Py_UNICODE ch )
231+ int _PyUnicode_IsLowercase (Py_UCS4 ch )
234232{
235233 return iswlower (ch );
236234}
237235
238- int _PyUnicode_IsUppercase (Py_UNICODE ch )
236+ int _PyUnicode_IsUppercase (Py_UCS4 ch )
239237{
240238 return iswupper (ch );
241239}
242240
243- Py_UNICODE _PyUnicode_ToLowercase (Py_UNICODE ch )
241+ Py_UCS4 _PyUnicode_ToLowercase (Py_UCS4 ch )
244242{
245243 return towlower (ch );
246244}
247245
248- Py_UNICODE _PyUnicode_ToUppercase (Py_UNICODE ch )
246+ Py_UCS4 _PyUnicode_ToUppercase (Py_UCS4 ch )
249247{
250248 return towupper (ch );
251249}
252250
253- int _PyUnicode_IsAlpha (Py_UNICODE ch )
251+ int _PyUnicode_IsAlpha (Py_UCS4 ch )
254252{
255253 return iswalpha (ch );
256254}
0 commit comments