@@ -81,19 +81,20 @@ PHP_FUNCTION(grapheme_strlen)
81
81
/* {{{ Find position of first occurrence of a string within another */
82
82
PHP_FUNCTION (grapheme_strpos )
83
83
{
84
- char * haystack , * needle ;
85
- size_t haystack_len , needle_len ;
84
+ char * haystack , * needle , * locale = "" ;
85
+ size_t haystack_len , needle_len , locale_len ;
86
86
const char * found ;
87
87
zend_long loffset = 0 ;
88
88
int32_t offset = 0 ;
89
89
size_t noffset = 0 ;
90
90
zend_long ret_pos ;
91
91
92
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
92
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
93
93
Z_PARAM_STRING (haystack , haystack_len )
94
94
Z_PARAM_STRING (needle , needle_len )
95
95
Z_PARAM_OPTIONAL
96
96
Z_PARAM_LONG (loffset )
97
+ Z_PARAM_STRING (locale , locale_len )
97
98
ZEND_PARSE_PARAMETERS_END ();
98
99
99
100
if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -121,7 +122,7 @@ PHP_FUNCTION(grapheme_strpos)
121
122
}
122
123
123
124
/* do utf16 part of the strpos */
124
- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* fIgnoreCase */ , 0 /* last */ );
125
+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* fIgnoreCase */ , 0 , locale /* last */ );
125
126
126
127
if ( ret_pos >= 0 ) {
127
128
RETURN_LONG (ret_pos );
@@ -134,19 +135,20 @@ PHP_FUNCTION(grapheme_strpos)
134
135
/* {{{ Find position of first occurrence of a string within another, ignoring case differences */
135
136
PHP_FUNCTION (grapheme_stripos )
136
137
{
137
- char * haystack , * needle ;
138
- size_t haystack_len , needle_len ;
138
+ char * haystack , * needle , * locale = "" ;
139
+ size_t haystack_len , needle_len , locale_len = 0 ;
139
140
const char * found ;
140
141
zend_long loffset = 0 ;
141
142
int32_t offset = 0 ;
142
143
zend_long ret_pos ;
143
144
int is_ascii ;
144
145
145
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
146
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
146
147
Z_PARAM_STRING (haystack , haystack_len )
147
148
Z_PARAM_STRING (needle , needle_len )
148
149
Z_PARAM_OPTIONAL
149
150
Z_PARAM_LONG (loffset )
151
+ Z_PARAM_STRING (locale , locale_len )
150
152
ZEND_PARSE_PARAMETERS_END ();
151
153
152
154
if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -185,7 +187,7 @@ PHP_FUNCTION(grapheme_stripos)
185
187
}
186
188
187
189
/* do utf16 part of the strpos */
188
- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* fIgnoreCase */ , 0 /*last */ );
190
+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* fIgnoreCase */ , 0 , locale /*last */ );
189
191
190
192
if ( ret_pos >= 0 ) {
191
193
RETURN_LONG (ret_pos );
@@ -200,17 +202,19 @@ PHP_FUNCTION(grapheme_stripos)
200
202
PHP_FUNCTION (grapheme_strrpos )
201
203
{
202
204
char * haystack , * needle ;
203
- size_t haystack_len , needle_len ;
205
+ char * locale = "" ;
206
+ size_t haystack_len , needle_len , locale_len ;
204
207
zend_long loffset = 0 ;
205
208
int32_t offset = 0 ;
206
209
zend_long ret_pos ;
207
210
int is_ascii ;
208
211
209
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
212
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
210
213
Z_PARAM_STRING (haystack , haystack_len )
211
214
Z_PARAM_STRING (needle , needle_len )
212
215
Z_PARAM_OPTIONAL
213
216
Z_PARAM_LONG (loffset )
217
+ Z_PARAM_STRING (locale , locale_len )
214
218
ZEND_PARSE_PARAMETERS_END ();
215
219
216
220
if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -242,7 +246,7 @@ PHP_FUNCTION(grapheme_strrpos)
242
246
/* else we need to continue via utf16 */
243
247
}
244
248
245
- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* f_ignore_case */ , 1 /* last */ );
249
+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* f_ignore_case */ , 1 , locale /* last */ );
246
250
247
251
if ( ret_pos >= 0 ) {
248
252
RETURN_LONG (ret_pos );
@@ -257,18 +261,19 @@ PHP_FUNCTION(grapheme_strrpos)
257
261
/* {{{ Find position of last occurrence of a string within another, ignoring case */
258
262
PHP_FUNCTION (grapheme_strripos )
259
263
{
260
- char * haystack , * needle ;
261
- size_t haystack_len , needle_len ;
264
+ char * haystack , * needle , * locale = "" ;
265
+ size_t haystack_len , needle_len , locale_len = 0 ;
262
266
zend_long loffset = 0 ;
263
267
int32_t offset = 0 ;
264
268
zend_long ret_pos ;
265
269
int is_ascii ;
266
270
267
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
271
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
268
272
Z_PARAM_STRING (haystack , haystack_len )
269
273
Z_PARAM_STRING (needle , needle_len )
270
274
Z_PARAM_OPTIONAL
271
275
Z_PARAM_LONG (loffset )
276
+ Z_PARAM_STRING (locale , locale_len )
272
277
ZEND_PARSE_PARAMETERS_END ();
273
278
274
279
if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -309,7 +314,7 @@ PHP_FUNCTION(grapheme_strripos)
309
314
/* else we need to continue via utf16 */
310
315
}
311
316
312
- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* f_ignore_case */ , 1 /*last */ );
317
+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* f_ignore_case */ , 1 , locale /*last */ );
313
318
314
319
if ( ret_pos >= 0 ) {
315
320
RETURN_LONG (ret_pos );
@@ -324,10 +329,10 @@ PHP_FUNCTION(grapheme_strripos)
324
329
/* {{{ Returns part of a string */
325
330
PHP_FUNCTION (grapheme_substr )
326
331
{
327
- char * str ;
332
+ char * str , * locale = "" ;
328
333
zend_string * u8_sub_str ;
329
334
UChar * ustr ;
330
- size_t str_len ;
335
+ size_t str_len , locale_len ;
331
336
int32_t ustr_len ;
332
337
zend_long lstart = 0 , length = 0 ;
333
338
int32_t start = 0 ;
@@ -339,11 +344,12 @@ PHP_FUNCTION(grapheme_substr)
339
344
int32_t (* iter_func )(UBreakIterator * );
340
345
bool no_length = true;
341
346
342
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
347
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
343
348
Z_PARAM_STRING (str , str_len )
344
349
Z_PARAM_LONG (lstart )
345
350
Z_PARAM_OPTIONAL
346
351
Z_PARAM_LONG_OR_NULL (length , no_length )
352
+ Z_PARAM_STRING (locale , locale_len )
347
353
ZEND_PARSE_PARAMETERS_END ();
348
354
349
355
if (lstart < INT32_MIN || lstart > INT32_MAX ) {
@@ -537,17 +543,18 @@ PHP_FUNCTION(grapheme_substr)
537
543
/* {{{ strstr_common_handler */
538
544
static void strstr_common_handler (INTERNAL_FUNCTION_PARAMETERS , int f_ignore_case )
539
545
{
540
- char * haystack , * needle ;
546
+ char * haystack , * needle , * locale = "" ;
541
547
const char * found ;
542
- size_t haystack_len , needle_len ;
548
+ size_t haystack_len , needle_len , locale_len = 0 ;
543
549
int32_t ret_pos , uchar_pos ;
544
550
bool part = false;
545
551
546
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
552
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
547
553
Z_PARAM_STRING (haystack , haystack_len )
548
554
Z_PARAM_STRING (needle , needle_len )
549
555
Z_PARAM_OPTIONAL
550
556
Z_PARAM_BOOL (part )
557
+ Z_PARAM_STRING (locale , locale_len )
551
558
ZEND_PARSE_PARAMETERS_END ();
552
559
553
560
if ( !f_ignore_case ) {
@@ -574,7 +581,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
574
581
}
575
582
576
583
/* need to work in utf16 */
577
- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , 0 , & uchar_pos , f_ignore_case , 0 /*last */ );
584
+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , 0 , & uchar_pos , f_ignore_case , 0 , locale /*last */ );
578
585
579
586
if ( ret_pos < 0 ) {
580
587
RETURN_FALSE ;
@@ -919,14 +926,17 @@ PHP_FUNCTION(grapheme_levenshtein)
919
926
zend_long cost_ins = 1 ;
920
927
zend_long cost_rep = 1 ;
921
928
zend_long cost_del = 1 ;
929
+ char * locale = "" ;
930
+ size_t locale_len = 0 ;
922
931
923
- ZEND_PARSE_PARAMETERS_START (2 , 5 )
932
+ ZEND_PARSE_PARAMETERS_START (2 , 6 )
924
933
Z_PARAM_STR (string1 )
925
934
Z_PARAM_STR (string2 )
926
935
Z_PARAM_OPTIONAL
927
936
Z_PARAM_LONG (cost_ins )
928
937
Z_PARAM_LONG (cost_rep )
929
938
Z_PARAM_LONG (cost_del )
939
+ Z_PARAM_STRING (locale , locale_len )
930
940
ZEND_PARSE_PARAMETERS_END ();
931
941
932
942
if (cost_ins <= 0 || cost_ins > UINT_MAX / 4 ) {
@@ -1043,7 +1053,7 @@ PHP_FUNCTION(grapheme_levenshtein)
1043
1053
RETVAL_FALSE ;
1044
1054
goto out_bi2 ;
1045
1055
}
1046
- UCollator * collator = ucol_open ("" , & ustatus );
1056
+ UCollator * collator = ucol_open (locale , & ustatus );
1047
1057
if (U_FAILURE (ustatus )) {
1048
1058
intl_error_set_code (NULL , ustatus );
1049
1059
0 commit comments