@@ -84,6 +84,7 @@ PHP_FUNCTION(grapheme_strpos)
84
84
char * haystack , * needle ;
85
85
size_t haystack_len , needle_len ;
86
86
const char * found ;
87
+ char * locale = "" ;
87
88
zend_long loffset = 0 ;
88
89
int32_t offset = 0 ;
89
90
size_t noffset = 0 ;
@@ -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_OR_NULL (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,6 +202,7 @@ PHP_FUNCTION(grapheme_stripos)
200
202
PHP_FUNCTION (grapheme_strrpos )
201
203
{
202
204
char * haystack , * needle ;
205
+ char * locale = "" ;
203
206
size_t haystack_len , needle_len ;
204
207
zend_long loffset = 0 ;
205
208
int32_t offset = 0 ;
@@ -242,7 +245,7 @@ PHP_FUNCTION(grapheme_strrpos)
242
245
/* else we need to continue via utf16 */
243
246
}
244
247
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 */ );
246
249
247
250
if ( ret_pos >= 0 ) {
248
251
RETURN_LONG (ret_pos );
@@ -257,18 +260,19 @@ PHP_FUNCTION(grapheme_strrpos)
257
260
/* {{{ Find position of last occurrence of a string within another, ignoring case */
258
261
PHP_FUNCTION (grapheme_strripos )
259
262
{
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 ;
262
265
zend_long loffset = 0 ;
263
266
int32_t offset = 0 ;
264
267
zend_long ret_pos ;
265
268
int is_ascii ;
266
269
267
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
270
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
268
271
Z_PARAM_STRING (haystack , haystack_len )
269
272
Z_PARAM_STRING (needle , needle_len )
270
273
Z_PARAM_OPTIONAL
271
274
Z_PARAM_LONG (loffset )
275
+ Z_PARAM_STRING_OR_NULL (locale , locale_len )
272
276
ZEND_PARSE_PARAMETERS_END ();
273
277
274
278
if ( OUTSIDE_STRING (loffset , haystack_len ) ) {
@@ -309,7 +313,7 @@ PHP_FUNCTION(grapheme_strripos)
309
313
/* else we need to continue via utf16 */
310
314
}
311
315
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 */ );
313
317
314
318
if ( ret_pos >= 0 ) {
315
319
RETURN_LONG (ret_pos );
@@ -537,17 +541,18 @@ PHP_FUNCTION(grapheme_substr)
537
541
/* {{{ strstr_common_handler */
538
542
static void strstr_common_handler (INTERNAL_FUNCTION_PARAMETERS , int f_ignore_case )
539
543
{
540
- char * haystack , * needle ;
544
+ char * haystack , * needle , * locale = "" ;
541
545
const char * found ;
542
- size_t haystack_len , needle_len ;
546
+ size_t haystack_len , needle_len , locale_len = 0 ;
543
547
int32_t ret_pos , uchar_pos ;
544
548
bool part = false;
545
549
546
- ZEND_PARSE_PARAMETERS_START (2 , 3 )
550
+ ZEND_PARSE_PARAMETERS_START (2 , 4 )
547
551
Z_PARAM_STRING (haystack , haystack_len )
548
552
Z_PARAM_STRING (needle , needle_len )
549
553
Z_PARAM_OPTIONAL
550
554
Z_PARAM_BOOL (part )
555
+ Z_PARAM_STRING_OR_NULL (locale , locale_len )
551
556
ZEND_PARSE_PARAMETERS_END ();
552
557
553
558
if ( !f_ignore_case ) {
@@ -574,7 +579,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
574
579
}
575
580
576
581
/* 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 */ );
578
583
579
584
if ( ret_pos < 0 ) {
580
585
RETURN_FALSE ;
0 commit comments