@@ -84,6 +84,7 @@ PHP_FUNCTION(grapheme_strpos)
8484 char * haystack , * needle ;
8585 size_t haystack_len , needle_len ;
8686 const char * found ;
87+ char * locale = "" ;
8788 zend_long loffset = 0 ;
8889 int32_t offset = 0 ;
8990 size_t noffset = 0 ;
@@ -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 , 0 /* fIgnoreCase */ , 0 , locale /* last */ );
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_STRING_OR_NULL (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 , 1 /* fIgnoreCase */ , 0 , locale /*last */ );
189191
190192 if ( ret_pos >= 0 ) {
191193 RETURN_LONG (ret_pos );
@@ -200,6 +202,7 @@ PHP_FUNCTION(grapheme_stripos)
200202PHP_FUNCTION (grapheme_strrpos )
201203{
202204 char * haystack , * needle ;
205+ char * locale = "" ;
203206 size_t haystack_len , needle_len ;
204207 zend_long loffset = 0 ;
205208 int32_t offset = 0 ;
@@ -242,7 +245,7 @@ PHP_FUNCTION(grapheme_strrpos)
242245 /* else we need to continue via utf16 */
243246 }
244247
245- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* f_ignore_case */ , 1 /* last */ );
248+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 0 /* f_ignore_case */ , 1 , locale /* last */ );
246249
247250 if ( ret_pos >= 0 ) {
248251 RETURN_LONG (ret_pos );
@@ -257,18 +260,19 @@ PHP_FUNCTION(grapheme_strrpos)
257260/* {{{ Find position of last occurrence of a string within another, ignoring case */
258261PHP_FUNCTION (grapheme_strripos )
259262{
260- char * haystack , * needle ;
261- size_t haystack_len , needle_len ;
263+ char * haystack , * needle , * locale = "" ;
264+ size_t haystack_len , needle_len , locale_len = 0 ;
262265 zend_long loffset = 0 ;
263266 int32_t offset = 0 ;
264267 zend_long ret_pos ;
265268 int is_ascii ;
266269
267- ZEND_PARSE_PARAMETERS_START (2 , 3 )
270+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
268271 Z_PARAM_STRING (haystack , haystack_len )
269272 Z_PARAM_STRING (needle , needle_len )
270273 Z_PARAM_OPTIONAL
271274 Z_PARAM_LONG (loffset )
275+ Z_PARAM_STRING_OR_NULL (locale , locale_len )
272276 ZEND_PARSE_PARAMETERS_END ();
273277
274278 if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -309,7 +313,7 @@ PHP_FUNCTION(grapheme_strripos)
309313 /* else we need to continue via utf16 */
310314 }
311315
312- ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* f_ignore_case */ , 1 /*last */ );
316+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , offset , NULL , 1 /* f_ignore_case */ , 1 , locale /*last */ );
313317
314318 if ( ret_pos >= 0 ) {
315319 RETURN_LONG (ret_pos );
@@ -537,17 +541,18 @@ PHP_FUNCTION(grapheme_substr)
537541/* {{{ strstr_common_handler */
538542static void strstr_common_handler (INTERNAL_FUNCTION_PARAMETERS , int f_ignore_case )
539543{
540- char * haystack , * needle ;
544+ char * haystack , * needle , * locale = "" ;
541545 const char * found ;
542- size_t haystack_len , needle_len ;
546+ size_t haystack_len , needle_len , locale_len = 0 ;
543547 int32_t ret_pos , uchar_pos ;
544548 bool part = false;
545549
546- ZEND_PARSE_PARAMETERS_START (2 , 3 )
550+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
547551 Z_PARAM_STRING (haystack , haystack_len )
548552 Z_PARAM_STRING (needle , needle_len )
549553 Z_PARAM_OPTIONAL
550554 Z_PARAM_BOOL (part )
555+ Z_PARAM_STRING_OR_NULL (locale , locale_len )
551556 ZEND_PARSE_PARAMETERS_END ();
552557
553558 if ( !f_ignore_case ) {
@@ -574,7 +579,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
574579 }
575580
576581 /* 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 */ );
582+ ret_pos = grapheme_strpos_utf16 (haystack , haystack_len , needle , needle_len , 0 , & uchar_pos , f_ignore_case , 0 , locale /*last */ );
578583
579584 if ( ret_pos < 0 ) {
580585 RETURN_FALSE ;
0 commit comments