35
35
#include "php_unicode.h"
36
36
#include "unicode_data.h"
37
37
38
+ extern const mbfl_encoding mbfl_encoding_8859_9 ;
39
+
38
40
ZEND_EXTERN_MODULE_GLOBALS (mbstring )
39
41
40
42
static bool prop_lookup (unsigned long code , unsigned long n )
@@ -118,14 +120,14 @@ static inline unsigned mph_lookup(
118
120
mph_lookup(code, _uccase_##type##_g, _uccase_##type##_g_size, \
119
121
_uccase_##type##_table, _uccase_##type##_table_size)
120
122
121
- static unsigned php_unicode_toupper_raw (unsigned code , enum mbfl_no_encoding enc )
123
+ static unsigned php_unicode_toupper_raw (unsigned code , const mbfl_encoding * enc )
122
124
{
123
125
/* After the ASCII characters, the first codepoint with an uppercase version
124
126
* is 0xB5 (MICRO SIGN) */
125
127
if (code < 0xB5 ) {
126
128
/* Fast path for ASCII */
127
129
if (code >= 0x61 && code <= 0x7A ) {
128
- if (UNEXPECTED (enc == mbfl_no_encoding_8859_9 && code == 0x69 )) {
130
+ if (UNEXPECTED (enc == & mbfl_encoding_8859_9 && code == 0x69 )) {
129
131
return 0x130 ;
130
132
}
131
133
return code - 0x20 ;
@@ -140,14 +142,14 @@ static unsigned php_unicode_toupper_raw(unsigned code, enum mbfl_no_encoding enc
140
142
}
141
143
}
142
144
143
- static unsigned php_unicode_tolower_raw (unsigned code , enum mbfl_no_encoding enc )
145
+ static unsigned php_unicode_tolower_raw (unsigned code , const mbfl_encoding * enc )
144
146
{
145
147
/* After the ASCII characters, the first codepoint with a lowercase version
146
148
* is 0xC0 (LATIN CAPITAL LETTER A WITH GRAVE) */
147
149
if (code < 0xC0 ) {
148
150
/* Fast path for ASCII */
149
151
if (code >= 0x41 && code <= 0x5A ) {
150
- if (UNEXPECTED (enc == mbfl_no_encoding_8859_9 && code == 0x0049L )) {
152
+ if (UNEXPECTED (enc == & mbfl_encoding_8859_9 && code == 0x0049L )) {
151
153
return 0x0131L ;
152
154
}
153
155
return code + 0x20 ;
@@ -156,7 +158,7 @@ static unsigned php_unicode_tolower_raw(unsigned code, enum mbfl_no_encoding enc
156
158
} else {
157
159
unsigned new_code = CASE_LOOKUP (code , lower );
158
160
if (new_code != CODE_NOT_FOUND ) {
159
- if (UNEXPECTED (enc == mbfl_no_encoding_8859_9 && code == 0x130 )) {
161
+ if (UNEXPECTED (enc == & mbfl_encoding_8859_9 && code == 0x130 )) {
160
162
return 0x69 ;
161
163
}
162
164
return new_code ;
@@ -165,7 +167,7 @@ static unsigned php_unicode_tolower_raw(unsigned code, enum mbfl_no_encoding enc
165
167
}
166
168
}
167
169
168
- static unsigned php_unicode_totitle_raw (unsigned code , enum mbfl_no_encoding enc )
170
+ static unsigned php_unicode_totitle_raw (unsigned code , const mbfl_encoding * enc )
169
171
{
170
172
unsigned new_code = CASE_LOOKUP (code , title );
171
173
if (new_code != CODE_NOT_FOUND ) {
@@ -176,12 +178,12 @@ static unsigned php_unicode_totitle_raw(unsigned code, enum mbfl_no_encoding enc
176
178
return php_unicode_toupper_raw (code , enc );
177
179
}
178
180
179
- static unsigned php_unicode_tofold_raw (unsigned code , enum mbfl_no_encoding enc )
181
+ static unsigned php_unicode_tofold_raw (unsigned code , const mbfl_encoding * enc )
180
182
{
181
183
if (code < 0x80 ) {
182
184
/* Fast path for ASCII */
183
185
if (code >= 0x41 && code <= 0x5A ) {
184
- if (UNEXPECTED (enc == mbfl_no_encoding_8859_9 && code == 0x49 )) {
186
+ if (UNEXPECTED (enc == & mbfl_encoding_8859_9 && code == 0x49 )) {
185
187
return 0x131 ;
186
188
}
187
189
return code + 0x20 ;
@@ -190,7 +192,7 @@ static unsigned php_unicode_tofold_raw(unsigned code, enum mbfl_no_encoding enc)
190
192
} else {
191
193
unsigned new_code = CASE_LOOKUP (code , fold );
192
194
if (new_code != CODE_NOT_FOUND ) {
193
- if (UNEXPECTED (enc == mbfl_no_encoding_8859_9 && code == 0x130 )) {
195
+ if (UNEXPECTED (enc == & mbfl_encoding_8859_9 && code == 0x130 )) {
194
196
return 0x69 ;
195
197
}
196
198
return new_code ;
@@ -199,28 +201,28 @@ static unsigned php_unicode_tofold_raw(unsigned code, enum mbfl_no_encoding enc)
199
201
}
200
202
}
201
203
202
- static inline unsigned php_unicode_tolower_simple (unsigned code , enum mbfl_no_encoding enc ) {
204
+ static inline unsigned php_unicode_tolower_simple (unsigned code , const mbfl_encoding * enc ) {
203
205
code = php_unicode_tolower_raw (code , enc );
204
206
if (UNEXPECTED (code > 0xffffff )) {
205
207
return _uccase_extra_table [code & 0xffffff ];
206
208
}
207
209
return code ;
208
210
}
209
- static inline unsigned php_unicode_toupper_simple (unsigned code , enum mbfl_no_encoding enc ) {
211
+ static inline unsigned php_unicode_toupper_simple (unsigned code , const mbfl_encoding * enc ) {
210
212
code = php_unicode_toupper_raw (code , enc );
211
213
if (UNEXPECTED (code > 0xffffff )) {
212
214
return _uccase_extra_table [code & 0xffffff ];
213
215
}
214
216
return code ;
215
217
}
216
- static inline unsigned php_unicode_totitle_simple (unsigned code , enum mbfl_no_encoding enc ) {
218
+ static inline unsigned php_unicode_totitle_simple (unsigned code , const mbfl_encoding * enc ) {
217
219
code = php_unicode_totitle_raw (code , enc );
218
220
if (UNEXPECTED (code > 0xffffff )) {
219
221
return _uccase_extra_table [code & 0xffffff ];
220
222
}
221
223
return code ;
222
224
}
223
- static inline unsigned php_unicode_tofold_simple (unsigned code , enum mbfl_no_encoding enc ) {
225
+ static inline unsigned php_unicode_tofold_simple (unsigned code , const mbfl_encoding * enc ) {
224
226
code = php_unicode_tofold_raw (code , enc );
225
227
if (UNEXPECTED (code > 0xffffff )) {
226
228
return _uccase_extra_table [code & 0xffffff ];
@@ -284,7 +286,6 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
284
286
uint32_t wchar_buf [64 ], converted_buf [192 ];
285
287
unsigned int state = 0 , title_mode = 0 ;
286
288
unsigned char * in = (unsigned char * )srcstr ;
287
- enum mbfl_no_encoding enc = src_encoding -> no_encoding ;
288
289
/* In rare cases, we need to scan backwards through the previously converted codepoints to see
289
290
* if special conversion rules should be used for the Greek letter sigma */
290
291
uint32_t * converted_end = NULL ;
@@ -302,21 +303,21 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
302
303
case PHP_UNICODE_CASE_UPPER_SIMPLE :
303
304
for (int i = 0 ; i < out_len ; i ++ ) {
304
305
uint32_t w = wchar_buf [i ];
305
- * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_toupper_simple (w , enc );
306
+ * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_toupper_simple (w , src_encoding );
306
307
}
307
308
break ;
308
309
309
310
case PHP_UNICODE_CASE_LOWER_SIMPLE :
310
311
for (int i = 0 ; i < out_len ; i ++ ) {
311
312
uint32_t w = wchar_buf [i ];
312
- * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_tolower_simple (w , enc );
313
+ * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_tolower_simple (w , src_encoding );
313
314
}
314
315
break ;
315
316
316
317
case PHP_UNICODE_CASE_FOLD_SIMPLE :
317
318
for (int i = 0 ; i < out_len ; i ++ ) {
318
319
uint32_t w = wchar_buf [i ];
319
- * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_tofold_simple (w , enc );
320
+ * p ++ = (UNEXPECTED (w > 0xFFFFFF )) ? w : php_unicode_tofold_simple (w , src_encoding );
320
321
}
321
322
break ;
322
323
@@ -327,7 +328,7 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
327
328
* p ++ = w ;
328
329
continue ;
329
330
}
330
- * p ++ = title_mode ? php_unicode_tolower_simple (w , enc ) : php_unicode_totitle_simple (w , enc );
331
+ * p ++ = title_mode ? php_unicode_tolower_simple (w , src_encoding ) : php_unicode_totitle_simple (w , src_encoding );
331
332
if (!php_unicode_is_case_ignorable (w )) {
332
333
title_mode = php_unicode_is_cased (w );
333
334
}
@@ -341,7 +342,7 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
341
342
* p ++ = w ;
342
343
continue ;
343
344
}
344
- w = php_unicode_toupper_raw (w , enc );
345
+ w = php_unicode_toupper_raw (w , src_encoding );
345
346
if (UNEXPECTED (w > 0xFFFFFF )) {
346
347
p = emit_special_casing_sequence (w , p );
347
348
} else {
@@ -394,7 +395,7 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
394
395
}
395
396
}
396
397
}
397
- w = php_unicode_tolower_raw (w , enc );
398
+ w = php_unicode_tolower_raw (w , src_encoding );
398
399
if (UNEXPECTED (w > 0xFFFFFF )) {
399
400
p = emit_special_casing_sequence (w , p );
400
401
} else {
@@ -410,7 +411,7 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
410
411
* p ++ = w ;
411
412
continue ;
412
413
}
413
- w = php_unicode_tofold_raw (w , enc );
414
+ w = php_unicode_tofold_raw (w , src_encoding );
414
415
if (UNEXPECTED (w > 0xFFFFFF )) {
415
416
p = emit_special_casing_sequence (w , p );
416
417
} else {
@@ -426,7 +427,7 @@ MBSTRING_API zend_string *php_unicode_convert_case(php_case_mode case_mode, cons
426
427
* p ++ = w ;
427
428
continue ;
428
429
}
429
- uint32_t w2 = title_mode ? php_unicode_tolower_raw (w , enc ) : php_unicode_totitle_raw (w , enc );
430
+ uint32_t w2 = title_mode ? php_unicode_tolower_raw (w , src_encoding ) : php_unicode_totitle_raw (w , src_encoding );
430
431
if (UNEXPECTED (w2 > 0xFFFFFF )) {
431
432
p = emit_special_casing_sequence (w2 , p );
432
433
} else {
0 commit comments