@@ -334,7 +334,7 @@ static const mbfl_encoding *php_mb_get_encoding(zend_string *encoding_name) {
334
334
335
335
encoding = mbfl_name2encoding (ZSTR_VAL (encoding_name ));
336
336
if (!encoding ) {
337
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , ZSTR_VAL (encoding_name ));
337
+ zend_value_error ( "Unknown encoding \"%s\"" , ZSTR_VAL (encoding_name ));
338
338
return NULL ;
339
339
}
340
340
@@ -1400,8 +1400,9 @@ PHP_FUNCTION(mb_language)
1400
1400
} else {
1401
1401
zend_string * ini_name = zend_string_init ("mbstring.language" , sizeof ("mbstring.language" ) - 1 , 0 );
1402
1402
if (FAILURE == zend_alter_ini_entry (ini_name , name , PHP_INI_USER , PHP_INI_STAGE_RUNTIME )) {
1403
- php_error_docref (NULL , E_WARNING , "Unknown language \"%s\"" , ZSTR_VAL (name ));
1404
- RETVAL_FALSE ;
1403
+ zend_value_error ("Unknown language \"%s\"" , ZSTR_VAL (name ));
1404
+ zend_string_release_ex (ini_name , 0 );
1405
+ return ;
1405
1406
} else {
1406
1407
RETVAL_TRUE ;
1407
1408
}
@@ -1431,8 +1432,8 @@ PHP_FUNCTION(mb_internal_encoding)
1431
1432
} else {
1432
1433
encoding = mbfl_name2encoding (name );
1433
1434
if (!encoding ) {
1434
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , name );
1435
- RETURN_FALSE ;
1435
+ zend_value_error ( "Unknown encoding \"%s\"" , name );
1436
+ return ;
1436
1437
} else {
1437
1438
MBSTRG (current_internal_encoding ) = encoding ;
1438
1439
MBSTRG (internal_encoding_set ) = 1 ;
@@ -1556,8 +1557,8 @@ PHP_FUNCTION(mb_http_output)
1556
1557
} else {
1557
1558
encoding = mbfl_name2encoding (name );
1558
1559
if (!encoding ) {
1559
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , name );
1560
- RETURN_FALSE ;
1560
+ zend_value_error ( "Unknown encoding \"%s\"" , name );
1561
+ return ;
1561
1562
} else {
1562
1563
MBSTRG (http_output_set ) = 1 ;
1563
1564
MBSTRG (current_http_output_encoding ) = encoding ;
@@ -1712,21 +1713,21 @@ PHP_FUNCTION(mb_preferred_mime_name)
1712
1713
1713
1714
if (zend_parse_parameters (ZEND_NUM_ARGS (), "s" , & name , & name_len ) == FAILURE ) {
1714
1715
return ;
1715
- } else {
1716
- no_encoding = mbfl_name2no_encoding (name );
1717
- if (no_encoding == mbfl_no_encoding_invalid ) {
1718
- php_error_docref (NULL , E_WARNING , "Unknown encoding \"%s\"" , name );
1719
- RETVAL_FALSE ;
1720
- } else {
1721
- const char * preferred_name = mbfl_no2preferred_mime_name (no_encoding );
1722
- if (preferred_name == NULL || * preferred_name == '\0' ) {
1723
- php_error_docref (NULL , E_WARNING , "No MIME preferred name corresponding to \"%s\"" , name );
1724
- RETVAL_FALSE ;
1725
- } else {
1726
- RETVAL_STRING ((char * )preferred_name );
1727
- }
1728
- }
1729
1716
}
1717
+
1718
+ no_encoding = mbfl_name2no_encoding (name );
1719
+ if (no_encoding == mbfl_no_encoding_invalid ) {
1720
+ zend_value_error ("Unknown encoding \"%s\"" , name );
1721
+ return ;
1722
+ }
1723
+
1724
+ const char * preferred_name = mbfl_no2preferred_mime_name (no_encoding );
1725
+ if (preferred_name == NULL || * preferred_name == '\0' ) {
1726
+ zend_value_error ("No MIME preferred name corresponding to \"%s\"" , name );
1727
+ return ;
1728
+ }
1729
+
1730
+ RETVAL_STRING ((char * )preferred_name );
1730
1731
}
1731
1732
/* }}} */
1732
1733
@@ -1928,8 +1929,8 @@ PHP_FUNCTION(mb_str_split)
1928
1929
ZEND_PARSE_PARAMETERS_END ();
1929
1930
1930
1931
if (split_length <= 0 ) {
1931
- php_error_docref ( NULL , E_WARNING , "The length of each segment must be greater than zero" );
1932
- RETURN_FALSE ;
1932
+ zend_value_error ( "The length of each segment must be greater than zero" );
1933
+ return ;
1933
1934
}
1934
1935
1935
1936
/* fill mbfl_string structure */
@@ -2105,8 +2106,8 @@ PHP_FUNCTION(mb_strpos)
2105
2106
offset += slen ;
2106
2107
}
2107
2108
if (offset < 0 || offset > slen ) {
2108
- php_error_docref ( NULL , E_WARNING , "Offset not contained in string" );
2109
- RETURN_FALSE ;
2109
+ zend_value_error ( "Offset not contained in string" );
2110
+ return ;
2110
2111
}
2111
2112
}
2112
2113
@@ -2123,17 +2124,17 @@ PHP_FUNCTION(mb_strpos)
2123
2124
case 1 :
2124
2125
break ;
2125
2126
case 2 :
2126
- php_error_docref ( NULL , E_WARNING , "Needle has not positive length" );
2127
- break ;
2127
+ zend_value_error ( "Needle has not positive length" );
2128
+ return ;
2128
2129
case 4 :
2129
- php_error_docref ( NULL , E_WARNING , "Unknown encoding or conversion error" );
2130
- break ;
2130
+ zend_value_error ( "Unknown encoding or conversion error" );
2131
+ return ;
2131
2132
case 8 :
2132
- php_error_docref ( NULL , E_NOTICE , "Argument is empty" );
2133
- break ;
2133
+ zend_value_error ( "Argument is empty" );
2134
+ return ;
2134
2135
default :
2135
- php_error_docref ( NULL , E_WARNING , "Unknown error in mb_strpos" );
2136
- break ;
2136
+ zend_value_error ( "Unknown error in mb_strpos" );
2137
+ return ;
2137
2138
}
2138
2139
RETVAL_FALSE ;
2139
2140
}
@@ -2195,8 +2196,8 @@ PHP_FUNCTION(mb_strrpos)
2195
2196
size_t haystack_char_len = mbfl_strlen (& haystack );
2196
2197
if ((offset > 0 && offset > haystack_char_len ) ||
2197
2198
(offset < 0 && - offset > haystack_char_len )) {
2198
- php_error_docref ( NULL , E_WARNING , "Offset is greater than the length of haystack string" );
2199
- RETURN_FALSE ;
2199
+ zend_value_error ( "Offset is greater than the length of haystack string" );
2200
+ return ;
2200
2201
}
2201
2202
}
2202
2203
@@ -2480,8 +2481,8 @@ PHP_FUNCTION(mb_substr_count)
2480
2481
}
2481
2482
2482
2483
if (needle .len == 0 ) {
2483
- php_error_docref ( NULL , E_WARNING , "Empty substring" );
2484
- RETURN_FALSE ;
2484
+ zend_value_error ( "Empty substring" );
2485
+ return ;
2485
2486
}
2486
2487
2487
2488
n = mbfl_substr_count (& haystack , & needle );
@@ -2678,17 +2679,17 @@ PHP_FUNCTION(mb_strimwidth)
2678
2679
}
2679
2680
2680
2681
if (from < 0 || (size_t )from > str_len ) {
2681
- php_error_docref ( NULL , E_WARNING , "Start position is out of range" );
2682
- RETURN_FALSE ;
2682
+ zend_value_error ( "Start position is out of range" );
2683
+ return ;
2683
2684
}
2684
2685
2685
2686
if (width < 0 ) {
2686
2687
width = swidth + width - from ;
2687
2688
}
2688
2689
2689
2690
if (width < 0 ) {
2690
- php_error_docref ( NULL , E_WARNING , "Width is out of range" );
2691
- RETURN_FALSE ;
2691
+ zend_value_error ( "Width is out of range" );
2692
+ return ;
2692
2693
}
2693
2694
2694
2695
if (trimmarker ) {
@@ -2781,7 +2782,7 @@ MBSTRING_API char *php_mb_convert_encoding(const char *input, size_t length, con
2781
2782
if (_to_encoding && strlen (_to_encoding )) {
2782
2783
to_encoding = mbfl_name2encoding (_to_encoding );
2783
2784
if (!to_encoding ) {
2784
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , _to_encoding );
2785
+ zend_value_error ( "Unknown encoding \"%s\"" , _to_encoding );
2785
2786
return NULL ;
2786
2787
}
2787
2788
} else {
@@ -2874,8 +2875,8 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
2874
2875
if (key ) {
2875
2876
zend_string_release (key );
2876
2877
}
2877
- php_error_docref ( NULL , E_WARNING , "Object is not supported" );
2878
- continue ;
2878
+ zend_value_error ( "Object is not supported" );
2879
+ return NULL ;
2879
2880
}
2880
2881
if (key ) {
2881
2882
zend_hash_add (output , key , & entry_tmp );
@@ -3013,7 +3014,7 @@ PHP_FUNCTION(mb_convert_case)
3013
3014
}
3014
3015
3015
3016
if (case_mode < 0 || case_mode > PHP_UNICODE_CASE_MODE_MAX ) {
3016
- php_error_docref ( NULL , E_WARNING , "Invalid case mode" );
3017
+ zend_value_error ( "Invalid case mode" );
3017
3018
return ;
3018
3019
}
3019
3020
@@ -3141,7 +3142,8 @@ PHP_FUNCTION(mb_detect_encoding)
3141
3142
break ;
3142
3143
}
3143
3144
if (size == 0 ) {
3144
- php_error_docref (NULL , E_WARNING , "Illegal argument" );
3145
+ zend_value_error ("Illegal argument" );
3146
+ return ;
3145
3147
}
3146
3148
}
3147
3149
@@ -3209,8 +3211,8 @@ PHP_FUNCTION(mb_encoding_aliases)
3209
3211
3210
3212
encoding = mbfl_name2encoding (name );
3211
3213
if (!encoding ) {
3212
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , name );
3213
- RETURN_FALSE ;
3214
+ zend_value_error ( "Unknown encoding \"%s\"" , name );
3215
+ return ;
3214
3216
}
3215
3217
3216
3218
array_init (return_value );
@@ -3250,8 +3252,8 @@ PHP_FUNCTION(mb_encode_mimeheader)
3250
3252
if (charset_name != NULL ) {
3251
3253
charset = mbfl_name2encoding (charset_name );
3252
3254
if (!charset ) {
3253
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , charset_name );
3254
- RETURN_FALSE ;
3255
+ zend_value_error ( "Unknown encoding \"%s\"" , charset_name );
3256
+ return ;
3255
3257
}
3256
3258
} else {
3257
3259
const mbfl_language * lang = mbfl_no2language (MBSTRG (language ));
@@ -3520,8 +3522,8 @@ PHP_FUNCTION(mb_convert_variables)
3520
3522
/* new encoding */
3521
3523
to_encoding = mbfl_name2encoding (to_enc );
3522
3524
if (!to_encoding ) {
3523
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , to_enc );
3524
- RETURN_FALSE ;
3525
+ zend_value_error ( "Unknown encoding \"%s\"" , to_enc );
3526
+ return ;
3525
3527
}
3526
3528
3527
3529
/* initialize string */
@@ -3656,8 +3658,8 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type)
3656
3658
if (encoding && encoding_len > 0 ) {
3657
3659
string .encoding = mbfl_name2encoding (encoding );
3658
3660
if (!string .encoding ) {
3659
- php_error_docref ( NULL , E_WARNING , "Unknown encoding \"%s\"" , encoding );
3660
- RETURN_FALSE ;
3661
+ zend_value_error ( "Unknown encoding \"%s\"" , encoding );
3662
+ return ;
3661
3663
}
3662
3664
}
3663
3665
@@ -3965,8 +3967,8 @@ PHP_FUNCTION(mb_send_mail)
3965
3967
str_headers = php_mail_build_headers (headers );
3966
3968
break ;
3967
3969
default :
3968
- php_error_docref ( NULL , E_WARNING , "headers parameter must be string or array" );
3969
- RETURN_FALSE ;
3970
+ zend_type_error ( "headers parameter must be string or array" );
3971
+ return ;
3970
3972
}
3971
3973
}
3972
3974
if (extra_cmd ) {
@@ -4382,7 +4384,7 @@ MBSTRING_API int php_mb_check_encoding(const char *input, size_t length, const c
4382
4384
if (enc != NULL ) {
4383
4385
encoding = mbfl_name2encoding (enc );
4384
4386
if (!encoding || encoding == & mbfl_encoding_pass ) {
4385
- php_error_docref ( NULL , E_WARNING , "Invalid encoding \"%s\"" , enc );
4387
+ zend_value_error ( "Invalid encoding \"%s\"" , enc );
4386
4388
return 0 ;
4387
4389
}
4388
4390
}
@@ -4416,7 +4418,7 @@ MBSTRING_API int php_mb_check_encoding_recursive(HashTable *vars, const zend_str
4416
4418
if (enc != NULL ) {
4417
4419
encoding = mbfl_name2encoding (ZSTR_VAL (enc ));
4418
4420
if (!encoding || encoding == & mbfl_encoding_pass ) {
4419
- php_error_docref ( NULL , E_WARNING , "Invalid encoding \"%s\"" , ZSTR_VAL (enc ));
4421
+ zend_value_error ( "Invalid encoding \"%s\"" , ZSTR_VAL (enc ));
4420
4422
return 0 ;
4421
4423
}
4422
4424
}
@@ -4520,12 +4522,12 @@ static inline zend_long php_mb_ord(const char *str, size_t str_len, zend_string
4520
4522
4521
4523
no_enc = enc -> no_encoding ;
4522
4524
if (php_mb_is_unsupported_no_encoding (no_enc )) {
4523
- php_error_docref ( NULL , E_WARNING , "Unsupported encoding \"%s\"" , ZSTR_VAL (enc_name ));
4525
+ zend_value_error ( "Unsupported encoding \"%s\"" , ZSTR_VAL (enc_name ));
4524
4526
return -1 ;
4525
4527
}
4526
4528
4527
4529
if (str_len == 0 ) {
4528
- php_error_docref ( NULL , E_WARNING , "Empty string" );
4530
+ zend_value_error ( "Empty string" );
4529
4531
return -1 ;
4530
4532
}
4531
4533
@@ -4600,7 +4602,7 @@ static inline zend_string *php_mb_chr(zend_long cp, zend_string *enc_name)
4600
4602
4601
4603
no_enc = enc -> no_encoding ;
4602
4604
if (php_mb_is_unsupported_no_encoding (no_enc )) {
4603
- php_error_docref ( NULL , E_WARNING , "Unsupported encoding \"%s\"" , ZSTR_VAL (enc_name ));
4605
+ zend_value_error ( "Unsupported encoding \"%s\"" , ZSTR_VAL (enc_name ));
4604
4606
return NULL ;
4605
4607
}
4606
4608
@@ -4892,15 +4894,17 @@ MBSTRING_API size_t php_mb_stripos(int mode, const char *old_haystack, size_t ol
4892
4894
if (mode ) {
4893
4895
if ((offset > 0 && (size_t )offset > haystack_char_len ) ||
4894
4896
(offset < 0 && (size_t )(- offset ) > haystack_char_len )) {
4895
- php_error_docref (NULL , E_WARNING , "Offset is greater than the length of haystack string" );
4897
+ zend_value_error ("Offset is greater than the length of haystack string" );
4898
+ n = -1 ;
4896
4899
break ;
4897
4900
}
4898
4901
} else {
4899
4902
if (offset < 0 ) {
4900
4903
offset += (zend_long )haystack_char_len ;
4901
4904
}
4902
4905
if (offset < 0 || (size_t )offset > haystack_char_len ) {
4903
- php_error_docref (NULL , E_WARNING , "Offset not contained in string" );
4906
+ zend_value_error ("Offset not contained in string" );
4907
+ n = -1 ;
4904
4908
break ;
4905
4909
}
4906
4910
}
0 commit comments