]> granicus.if.org Git - php/commitdiff
Use ZEND_NUM_ARGS() macro instead of custom variable
authorGeorge Peter Banyard <girgias@php.net>
Thu, 2 Apr 2020 16:43:57 +0000 (18:43 +0200)
committerGeorge Peter Banyard <girgias@php.net>
Thu, 2 Apr 2020 20:40:00 +0000 (22:40 +0200)
Also why on earth would someone do this?

ext/mbstring/php_mbregex.c

index c4e066fccc31ac0f0c5bdaacf48cbb5d82b3e597..a701021c13ba26a292e56fdc854d886644af7698 100644 (file)
@@ -1533,18 +1533,17 @@ PHP_FUNCTION(mb_ereg_search_regs)
    Initialize string and regular expression for search. */
 PHP_FUNCTION(mb_ereg_search_init)
 {
-       int argc = ZEND_NUM_ARGS();
        zend_string *arg_str;
        char *arg_pattern = NULL, *arg_options = NULL;
        size_t arg_pattern_len = 0, arg_options_len = 0;
        OnigSyntaxType *syntax = NULL;
        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();
        }
 
-       if (argc > 1 && arg_pattern_len == 0) {
+       if (ZEND_NUM_ARGS() > 1 && arg_pattern_len == 0) {
                php_error_docref(NULL, E_WARNING, "Empty pattern");
                RETURN_FALSE;
        }
@@ -1552,12 +1551,12 @@ PHP_FUNCTION(mb_ereg_search_init)
        option = MBREX(regex_default_options);
        syntax = MBREX(regex_default_syntax);
 
-       if (argc == 3) {
+       if (ZEND_NUM_ARGS() == 3) {
                option = 0;
                _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 */
                if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) {
                        RETURN_FALSE;