Use ZEND_NUM_ARGS() macro instead of custom variable

Also why on earth would someone do this?
This commit is contained in:
George Peter Banyard 2020-04-02 18:43:57 +02:00
parent 4cd3d7b166
commit 577de174de

View file

@ -1533,18 +1533,17 @@ PHP_FUNCTION(mb_ereg_search_regs)
Initialize string and regular expression for search. */ Initialize string and regular expression for search. */
PHP_FUNCTION(mb_ereg_search_init) PHP_FUNCTION(mb_ereg_search_init)
{ {
int argc = ZEND_NUM_ARGS();
zend_string *arg_str; zend_string *arg_str;
char *arg_pattern = NULL, *arg_options = NULL; char *arg_pattern = NULL, *arg_options = NULL;
size_t arg_pattern_len = 0, arg_options_len = 0; size_t arg_pattern_len = 0, arg_options_len = 0;
OnigSyntaxType *syntax = NULL; OnigSyntaxType *syntax = NULL;
OnigOptionType option; OnigOptionType option;
if (zend_parse_parameters(argc, "S|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
RETURN_THROWS(); RETURN_THROWS();
} }
if (argc > 1 && arg_pattern_len == 0) { if (ZEND_NUM_ARGS() > 1 && arg_pattern_len == 0) {
php_error_docref(NULL, E_WARNING, "Empty pattern"); php_error_docref(NULL, E_WARNING, "Empty pattern");
RETURN_FALSE; RETURN_FALSE;
} }
@ -1552,12 +1551,12 @@ PHP_FUNCTION(mb_ereg_search_init)
option = MBREX(regex_default_options); option = MBREX(regex_default_options);
syntax = MBREX(regex_default_syntax); syntax = MBREX(regex_default_syntax);
if (argc == 3) { if (ZEND_NUM_ARGS() == 3) {
option = 0; option = 0;
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL); _php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
} }
if (argc > 1) { if (ZEND_NUM_ARGS() > 1) {
/* create regex pattern buffer */ /* create regex pattern buffer */
if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) { if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) {
RETURN_FALSE; RETURN_FALSE;