@@ -81,19 +81,20 @@ PHP_FUNCTION(grapheme_strlen)
8181/* {{{ Find position of first occurrence of a string within another */
8282PHP_FUNCTION (grapheme_strpos )
8383{
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 = 0 ;
8686 const char * found ;
8787 zend_long loffset = 0 ;
8888 int32_t offset = 0 ;
8989 size_t noffset = 0 ;
9090 zend_long ret_pos ;
9191
92- ZEND_PARSE_PARAMETERS_START (2 , 3 )
92+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
9393 Z_PARAM_STRING (haystack , haystack_len )
9494 Z_PARAM_STRING (needle , needle_len )
9595 Z_PARAM_OPTIONAL
9696 Z_PARAM_LONG (loffset )
97+ Z_PARAM_PATH (locale , locale_len )
9798 ZEND_PARSE_PARAMETERS_END ();
9899
99100 if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -121,7 +122,7 @@ PHP_FUNCTION(grapheme_strpos)
121122 }
122123
123124 /* 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 , /* fIgnoreCase */ 0 , /* last */ 0 , locale );
125126
126127 if ( ret_pos >= 0 ) {
127128 RETURN_LONG (ret_pos );
@@ -134,19 +135,20 @@ PHP_FUNCTION(grapheme_strpos)
134135/* {{{ Find position of first occurrence of a string within another, ignoring case differences */
135136PHP_FUNCTION (grapheme_stripos )
136137{
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 ;
139140 const char * found ;
140141 zend_long loffset = 0 ;
141142 int32_t offset = 0 ;
142143 zend_long ret_pos ;
143144 int is_ascii ;
144145
145- ZEND_PARSE_PARAMETERS_START (2 , 3 )
146+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
146147 Z_PARAM_STRING (haystack , haystack_len )
147148 Z_PARAM_STRING (needle , needle_len )
148149 Z_PARAM_OPTIONAL
149150 Z_PARAM_LONG (loffset )
151+ Z_PARAM_PATH (locale , locale_len )
150152 ZEND_PARSE_PARAMETERS_END ();
151153
152154 if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -185,7 +187,7 @@ PHP_FUNCTION(grapheme_stripos)
185187 }
186188
187189 /* 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 , /* fIgnoreCase */ 1 , /*last */ 0 , locale );
189191
190192 if ( ret_pos >= 0 ) {
191193 RETURN_LONG (ret_pos );
@@ -200,17 +202,19 @@ PHP_FUNCTION(grapheme_stripos)
200202PHP_FUNCTION (grapheme_strrpos )
201203{
202204 char * haystack , * needle ;
203- size_t haystack_len , needle_len ;
205+ char * locale = "" ;
206+ size_t haystack_len , needle_len , locale_len = 0 ;
204207 zend_long loffset = 0 ;
205208 int32_t offset = 0 ;
206209 zend_long ret_pos ;
207210 int is_ascii ;
208211
209- ZEND_PARSE_PARAMETERS_START (2 , 3 )
212+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
210213 Z_PARAM_STRING (haystack , haystack_len )
211214 Z_PARAM_STRING (needle , needle_len )
212215 Z_PARAM_OPTIONAL
213216 Z_PARAM_LONG (loffset )
217+ Z_PARAM_PATH (locale , locale_len )
214218 ZEND_PARSE_PARAMETERS_END ();
215219
216220 if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -242,7 +246,7 @@ PHP_FUNCTION(grapheme_strrpos)
242246 /* else we need to continue via utf16 */
243247 }
244248
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 , /* f_ignore_case */ 0 , /* last */ 1 , locale );
246250
247251 if ( ret_pos >= 0 ) {
248252 RETURN_LONG (ret_pos );
@@ -257,18 +261,19 @@ PHP_FUNCTION(grapheme_strrpos)
257261/* {{{ Find position of last occurrence of a string within another, ignoring case */
258262PHP_FUNCTION (grapheme_strripos )
259263{
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 ;
262266 zend_long loffset = 0 ;
263267 int32_t offset = 0 ;
264268 zend_long ret_pos ;
265269 int is_ascii ;
266270
267- ZEND_PARSE_PARAMETERS_START (2 , 3 )
271+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
268272 Z_PARAM_STRING (haystack , haystack_len )
269273 Z_PARAM_STRING (needle , needle_len )
270274 Z_PARAM_OPTIONAL
271275 Z_PARAM_LONG (loffset )
276+ Z_PARAM_PATH (locale , locale_len )
272277 ZEND_PARSE_PARAMETERS_END ();
273278
274279 if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -309,7 +314,7 @@ PHP_FUNCTION(grapheme_strripos)
309314 /* else we need to continue via utf16 */
310315 }
311316
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 , /* f_ignore_case */ 1 , /*last */ 1 , locale );
313318
314319 if ( ret_pos >= 0 ) {
315320 RETURN_LONG (ret_pos );
@@ -324,10 +329,10 @@ PHP_FUNCTION(grapheme_strripos)
324329/* {{{ Returns part of a string */
325330PHP_FUNCTION (grapheme_substr )
326331{
327- char * str ;
332+ char * str , * locale = "" ;
328333 zend_string * u8_sub_str ;
329334 UChar * ustr ;
330- size_t str_len ;
335+ size_t str_len , locale_len = 0 ;
331336 int32_t ustr_len ;
332337 zend_long lstart = 0 , length = 0 ;
333338 int32_t start = 0 ;
@@ -339,11 +344,12 @@ PHP_FUNCTION(grapheme_substr)
339344 int32_t (* iter_func )(UBreakIterator * );
340345 bool no_length = true;
341346
342- ZEND_PARSE_PARAMETERS_START (2 , 3 )
347+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
343348 Z_PARAM_STRING (str , str_len )
344349 Z_PARAM_LONG (lstart )
345350 Z_PARAM_OPTIONAL
346351 Z_PARAM_LONG_OR_NULL (length , no_length )
352+ Z_PARAM_PATH (locale , locale_len )
347353 ZEND_PARSE_PARAMETERS_END ();
348354
349355 if (lstart < INT32_MIN || lstart > INT32_MAX ) {
@@ -537,17 +543,18 @@ PHP_FUNCTION(grapheme_substr)
537543/* {{{ strstr_common_handler */
538544static void strstr_common_handler (INTERNAL_FUNCTION_PARAMETERS , int f_ignore_case )
539545{
540- char * haystack , * needle ;
546+ char * haystack , * needle , * locale = "" ;
541547 const char * found ;
542- size_t haystack_len , needle_len ;
548+ size_t haystack_len , needle_len , locale_len = 0 ;
543549 int32_t ret_pos , uchar_pos ;
544550 bool part = false;
545551
546- ZEND_PARSE_PARAMETERS_START (2 , 3 )
552+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
547553 Z_PARAM_STRING (haystack , haystack_len )
548554 Z_PARAM_STRING (needle , needle_len )
549555 Z_PARAM_OPTIONAL
550556 Z_PARAM_BOOL (part )
557+ Z_PARAM_PATH (locale , locale_len )
551558 ZEND_PARSE_PARAMETERS_END ();
552559
553560 if ( !f_ignore_case ) {
@@ -574,7 +581,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
574581 }
575582
576583 /* 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 , /* last */ 0 , locale );
578585
579586 if ( ret_pos < 0 ) {
580587 RETURN_FALSE ;
@@ -919,14 +926,17 @@ PHP_FUNCTION(grapheme_levenshtein)
919926 zend_long cost_ins = 1 ;
920927 zend_long cost_rep = 1 ;
921928 zend_long cost_del = 1 ;
929+ char * locale = "" ;
930+ size_t locale_len = 0 ;
922931
923- ZEND_PARSE_PARAMETERS_START (2 , 5 )
932+ ZEND_PARSE_PARAMETERS_START (2 , 6 )
924933 Z_PARAM_STR (string1 )
925934 Z_PARAM_STR (string2 )
926935 Z_PARAM_OPTIONAL
927936 Z_PARAM_LONG (cost_ins )
928937 Z_PARAM_LONG (cost_rep )
929938 Z_PARAM_LONG (cost_del )
939+ Z_PARAM_PATH (locale , locale_len )
930940 ZEND_PARSE_PARAMETERS_END ();
931941
932942 if (cost_ins <= 0 || cost_ins > UINT_MAX / 4 ) {
@@ -1043,7 +1053,7 @@ PHP_FUNCTION(grapheme_levenshtein)
10431053 RETVAL_FALSE ;
10441054 goto out_bi2 ;
10451055 }
1046- UCollator * collator = ucol_open ("" , & ustatus );
1056+ UCollator * collator = ucol_open (locale , & ustatus );
10471057 if (U_FAILURE (ustatus )) {
10481058 intl_error_set_code (NULL , ustatus );
10491059
0 commit comments