@@ -55,24 +55,23 @@ void grapheme_register_constants( INIT_FUNC_ARGS )
55
55
PHP_FUNCTION (grapheme_strlen )
56
56
{
57
57
unsigned char * string ;
58
- int string_len ;
58
+ zend_str_size_int string_len ;
59
59
UChar * ustring = NULL ;
60
- int ustring_len = 0 ;
60
+ zend_str_size_int ustring_len = 0 ;
61
61
int ret_len ;
62
62
UErrorCode status ;
63
63
64
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s " , (char * * )& string , & string_len ) == FAILURE ) {
64
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "S " , (char * * )& string , & string_len ) == FAILURE ) {
65
65
66
66
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
67
67
"grapheme_strlen: unable to parse input param" , 0 TSRMLS_CC );
68
68
69
69
RETURN_FALSE ;
70
70
}
71
71
72
- ret_len = grapheme_ascii_check (string , string_len );
73
-
74
- if ( ret_len >= 0 )
75
- RETURN_LONG (ret_len );
72
+ if (grapheme_ascii_check (string , string_len )) {
73
+ RETURN_LONG (string_len );
74
+ }
76
75
77
76
/* convert the string to UTF-16. */
78
77
status = U_ZERO_ERROR ;
@@ -109,13 +108,13 @@ PHP_FUNCTION(grapheme_strlen)
109
108
PHP_FUNCTION (grapheme_strpos )
110
109
{
111
110
unsigned char * haystack , * needle ;
112
- int haystack_len , needle_len ;
111
+ zend_str_size_int haystack_len , needle_len ;
113
112
unsigned char * found ;
114
113
long loffset = 0 ;
115
114
int32_t offset = 0 ;
116
115
int ret_pos ;
117
116
118
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
117
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "SS |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
119
118
120
119
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
121
120
"grapheme_strpos: unable to parse input param" , 0 TSRMLS_CC );
@@ -154,7 +153,7 @@ PHP_FUNCTION(grapheme_strpos)
154
153
}
155
154
156
155
/* if it is there, and if the haystack is ascii, we are all done */
157
- if ( grapheme_ascii_check (haystack , haystack_len ) >= 0 ) {
156
+ if (grapheme_ascii_check (haystack , haystack_len )) {
158
157
159
158
RETURN_LONG (found - haystack );
160
159
}
@@ -176,14 +175,14 @@ PHP_FUNCTION(grapheme_strpos)
176
175
PHP_FUNCTION (grapheme_stripos )
177
176
{
178
177
unsigned char * haystack , * needle , * haystack_dup , * needle_dup ;
179
- int haystack_len , needle_len ;
178
+ zend_str_size_int haystack_len , needle_len ;
180
179
unsigned char * found ;
181
180
long loffset = 0 ;
182
181
int32_t offset = 0 ;
183
182
int ret_pos ;
184
183
int is_ascii ;
185
184
186
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
185
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "SS |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
187
186
188
187
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
189
188
"grapheme_stripos: unable to parse input param" , 0 TSRMLS_CC );
@@ -211,7 +210,7 @@ PHP_FUNCTION(grapheme_stripos)
211
210
}
212
211
213
212
214
- is_ascii = ( grapheme_ascii_check (haystack , haystack_len ) >= 0 );
213
+ is_ascii = grapheme_ascii_check (haystack , haystack_len );
215
214
216
215
if ( is_ascii ) {
217
216
needle_dup = (unsigned char * )estrndup ((char * )needle , needle_len );
@@ -229,7 +228,7 @@ PHP_FUNCTION(grapheme_stripos)
229
228
}
230
229
231
230
/* if needle was ascii too, we are all done, otherwise we need to try using Unicode to see what we get */
232
- if ( grapheme_ascii_check (needle , needle_len ) >= 0 ) {
231
+ if ( grapheme_ascii_check (needle , needle_len ) ) {
233
232
RETURN_FALSE ;
234
233
}
235
234
}
@@ -251,13 +250,13 @@ PHP_FUNCTION(grapheme_stripos)
251
250
PHP_FUNCTION (grapheme_strrpos )
252
251
{
253
252
unsigned char * haystack , * needle ;
254
- int haystack_len , needle_len ;
253
+ zend_str_size_int haystack_len , needle_len ;
255
254
long loffset = 0 ;
256
255
int32_t offset = 0 ;
257
256
int32_t ret_pos ;
258
257
int is_ascii ;
259
258
260
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
259
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "SS |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
261
260
262
261
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
263
262
"grapheme_strrpos: unable to parse input param" , 0 TSRMLS_CC );
@@ -284,7 +283,7 @@ PHP_FUNCTION(grapheme_strrpos)
284
283
RETURN_FALSE ;
285
284
}
286
285
287
- is_ascii = grapheme_ascii_check (haystack , haystack_len ) >= 0 ;
286
+ is_ascii = grapheme_ascii_check (haystack , haystack_len );
288
287
289
288
if ( is_ascii ) {
290
289
@@ -297,7 +296,7 @@ PHP_FUNCTION(grapheme_strrpos)
297
296
298
297
/* if the needle was ascii too, we are done */
299
298
300
- if ( grapheme_ascii_check (needle , needle_len ) >= 0 ) {
299
+ if ( grapheme_ascii_check (needle , needle_len ) ) {
301
300
RETURN_FALSE ;
302
301
}
303
302
@@ -321,13 +320,13 @@ PHP_FUNCTION(grapheme_strrpos)
321
320
PHP_FUNCTION (grapheme_strripos )
322
321
{
323
322
unsigned char * haystack , * needle ;
324
- int haystack_len , needle_len ;
323
+ zend_str_size_int haystack_len , needle_len ;
325
324
long loffset = 0 ;
326
325
int32_t offset = 0 ;
327
326
int32_t ret_pos ;
328
327
int is_ascii ;
329
328
330
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
329
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "SS |l" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & loffset ) == FAILURE ) {
331
330
332
331
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
333
332
"grapheme_strrpos: unable to parse input param" , 0 TSRMLS_CC );
@@ -354,7 +353,7 @@ PHP_FUNCTION(grapheme_strripos)
354
353
RETURN_FALSE ;
355
354
}
356
355
357
- is_ascii = grapheme_ascii_check (haystack , haystack_len ) >= 0 ;
356
+ is_ascii = grapheme_ascii_check (haystack , haystack_len );
358
357
359
358
if ( is_ascii ) {
360
359
unsigned char * needle_dup , * haystack_dup ;
@@ -375,7 +374,7 @@ PHP_FUNCTION(grapheme_strripos)
375
374
376
375
/* if the needle was ascii too, we are done */
377
376
378
- if ( grapheme_ascii_check (needle , needle_len ) >= 0 ) {
377
+ if ( grapheme_ascii_check (needle , needle_len ) ) {
379
378
RETURN_FALSE ;
380
379
}
381
380
@@ -400,7 +399,7 @@ PHP_FUNCTION(grapheme_substr)
400
399
{
401
400
unsigned char * str , * sub_str ;
402
401
UChar * ustr ;
403
- int str_len , sub_str_len , ustr_len ;
402
+ zend_str_size_int str_len , sub_str_len , ustr_len ;
404
403
long lstart = 0 , length = 0 ;
405
404
int32_t start = 0 ;
406
405
int iter_val ;
@@ -410,7 +409,7 @@ PHP_FUNCTION(grapheme_substr)
410
409
int sub_str_start_pos , sub_str_end_pos ;
411
410
int32_t (* iter_func )(UBreakIterator * );
412
411
413
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "sl |l" , (char * * )& str , & str_len , & lstart , & length ) == FAILURE ) {
412
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "Sl |l" , (char * * )& str , & str_len , & lstart , & length ) == FAILURE ) {
414
413
415
414
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
416
415
"grapheme_substr: unable to parse input param" , 0 TSRMLS_CC );
@@ -430,7 +429,7 @@ PHP_FUNCTION(grapheme_substr)
430
429
431
430
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
432
431
433
- if ( grapheme_ascii_check (str , str_len ) >= 0 ) {
432
+ if ( grapheme_ascii_check (str , str_len ) ) {
434
433
grapheme_substr_ascii ((char * )str , str_len , start , length , ZEND_NUM_ARGS (), (char * * ) & sub_str , & sub_str_len );
435
434
436
435
if ( NULL == sub_str ) {
@@ -613,11 +612,11 @@ PHP_FUNCTION(grapheme_substr)
613
612
static void strstr_common_handler (INTERNAL_FUNCTION_PARAMETERS , int f_ignore_case )
614
613
{
615
614
unsigned char * haystack , * needle , * found ;
616
- int haystack_len , needle_len ;
615
+ zend_str_size_int haystack_len , needle_len ;
617
616
int ret_pos , uchar_pos ;
618
617
zend_bool part = 0 ;
619
618
620
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss |b" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & part ) == FAILURE ) {
619
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "SS |b" , (char * * )& haystack , & haystack_len , (char * * )& needle , & needle_len , & part ) == FAILURE ) {
621
620
622
621
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
623
622
"grapheme_strstr: unable to parse input param" , 0 TSRMLS_CC );
@@ -646,7 +645,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
646
645
}
647
646
648
647
/* if it is there, and if the haystack is ascii, we are all done */
649
- if ( grapheme_ascii_check (haystack , haystack_len ) >= 0 ) {
648
+ if ( grapheme_ascii_check (haystack , haystack_len ) ) {
650
649
size_t found_offset = found - haystack ;
651
650
652
651
if (part ) {
@@ -810,7 +809,7 @@ PHP_FUNCTION(grapheme_extract)
810
809
{
811
810
unsigned char * str , * pstr ;
812
811
UChar * ustr ;
813
- int str_len , ustr_len ;
812
+ zend_str_size_int str_len , ustr_len ;
814
813
long size ; /* maximum number of grapheme clusters, bytes, or characters (based on extract_type) to return */
815
814
long lstart = 0 ; /* starting position in str in bytes */
816
815
int32_t start = 0 ;
@@ -821,7 +820,7 @@ PHP_FUNCTION(grapheme_extract)
821
820
int ret_pos ;
822
821
zval * next = NULL ; /* return offset of next part of the string */
823
822
824
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "sl |llz" , (char * * )& str , & str_len , & size , & extract_type , & lstart , & next ) == FAILURE ) {
823
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "Sl |llz" , (char * * )& str , & str_len , & size , & extract_type , & lstart , & next ) == FAILURE ) {
825
824
826
825
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR ,
827
826
"grapheme_extract: unable to parse input param" , 0 TSRMLS_CC );
@@ -890,7 +889,7 @@ PHP_FUNCTION(grapheme_extract)
890
889
(size + 1 because the size-th character might be the beginning of a grapheme cluster)
891
890
*/
892
891
893
- if ( -1 != grapheme_ascii_check (pstr , size + 1 < str_len ? size + 1 : str_len ) ) {
892
+ if ( grapheme_ascii_check (pstr , size + 1 < str_len ? size + 1 : str_len ) ) {
894
893
long nsize = ( size < str_len ? size : str_len );
895
894
if ( NULL != next ) {
896
895
ZVAL_LONG (next , start + nsize );
0 commit comments