]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 20:32:48 +0000 (12:32 -0800)
committerSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 20:56:21 +0000 (12:56 -0800)
ext/standard/assert.c
ext/standard/crc32.c
ext/standard/crypt.c
ext/standard/exec.c
ext/standard/html.c
ext/standard/random.c
ext/standard/soundex.c

index f05ff66f25e39fbb6c3b5274e957bc90313177e3..550a3ec48d3131fb9adc94b38b46b85dd6ad54ef 100644 (file)
@@ -157,9 +157,11 @@ PHP_FUNCTION(assert)
                RETURN_TRUE;
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|z", &assertion, &description) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_ZVAL_DEREF(assertion)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ZVAL_DEREF(description)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (Z_TYPE_P(assertion) == IS_STRING) {
                zval retval;
@@ -290,9 +292,11 @@ PHP_FUNCTION(assert_options)
        int ac = ZEND_NUM_ARGS();
        zend_string *key;
 
-       if (zend_parse_parameters(ac, "l|z", &what, &value) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_LONG(what)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ZVAL_DEREF(value)
+       ZEND_PARSE_PARAMETERS_END();
 
        switch (what) {
        case ASSERT_ACTIVE:
index e6024dcf11cf381532af1e1c9195fcbf04a56819..bef7abab962d243fe27f5016f0c58fca2b6c5471 100644 (file)
@@ -31,9 +31,10 @@ PHP_NAMED_FUNCTION(php_if_crc32)
        uint32_t crcinit = 0;
        register uint32_t crc;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &p, &nr) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(p, nr)
+       ZEND_PARSE_PARAMETERS_END();
+
        crc = crcinit^0xFFFFFFFF;
 
        for (; nr--; ++p) {
index f2f778e764b2f71a0329c0a8630e44327559ab24..a6a290057d0a005ad18471fdc1154457758c3a45 100644 (file)
@@ -245,9 +245,11 @@ PHP_FUNCTION(crypt)
        size_t str_len, salt_in_len = 0;
        zend_string *result;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(str, str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(salt_in, salt_in_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
 
index d541ff6b4c09a1ed0fd6cf9dae599729bb8a7698..9962953e1fc44135e61d968c2fd3ac55557b3c74 100644 (file)
@@ -213,15 +213,15 @@ static void php_exec_ex(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
        zval *ret_code=NULL, *ret_array=NULL;
        int ret;
 
-       if (mode) {
-               if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z/", &cmd, &cmd_len, &ret_code) == FAILURE) {
-                       RETURN_FALSE;
+       ZEND_PARSE_PARAMETERS_START(1, (mode ? 2 : 3))
+               Z_PARAM_STRING(cmd, cmd_len)
+               Z_PARAM_OPTIONAL
+               if (!mode) {
+                       Z_PARAM_ZVAL_DEREF_EX(ret_array, 0, 1)
                }
-       } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z/z/", &cmd, &cmd_len, &ret_array, &ret_code) == FAILURE) {
-                       RETURN_FALSE;
-               }
-       }
+               Z_PARAM_ZVAL_DEREF_EX(ret_code, 0, 1)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        if (!cmd_len) {
                php_error_docref(NULL, E_WARNING, "Cannot execute a blank command");
                RETURN_FALSE;
@@ -477,9 +477,9 @@ PHP_FUNCTION(escapeshellcmd)
        char *command;
        size_t command_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &command, &command_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(command, command_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (command_len) {
                if (command_len != strlen(command)) {
@@ -500,9 +500,9 @@ PHP_FUNCTION(escapeshellarg)
        char *argument;
        size_t argument_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &argument, &argument_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(argument, argument_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (argument) {
                if (argument_len != strlen(argument)) {
@@ -524,9 +524,9 @@ PHP_FUNCTION(shell_exec)
        zend_string *ret;
        php_stream *stream;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &command, &command_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(command, command_len)
+       ZEND_PARSE_PARAMETERS_END();
 
 #ifdef PHP_WIN32
        if ((in=VCWD_POPEN(command, "rt"))==NULL) {
@@ -554,9 +554,9 @@ PHP_FUNCTION(proc_nice)
 {
        zend_long pri;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &pri) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_LONG(pri)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        errno = 0;
        php_ignore_value(nice(pri));
index 473b24ea27b8d5af46bc0b0f01e310c606dfde62..c7d34e78900657cfdc5c78f6bbc43d4fb91afec4 100644 (file)
@@ -1500,9 +1500,11 @@ PHP_FUNCTION(htmlspecialchars_decode)
        zend_long quote_style = ENT_COMPAT;
        zend_string *replaced;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &quote_style) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(str, str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(quote_style)
+       ZEND_PARSE_PARAMETERS_END();
 
        replaced = php_unescape_html_entities((unsigned char*)str, str_len, 0 /*!all*/, (int)quote_style, NULL);
        if (replaced) {
@@ -1622,10 +1624,12 @@ PHP_FUNCTION(get_html_translation_table)
         * getting the translated table from data structures that are optimized for
         * random access, not traversal */
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls",
-                       &all, &flags, &charset_hint, &charset_hint_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 3)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(all)
+               Z_PARAM_LONG(flags)
+               Z_PARAM_STRING(charset_hint, charset_hint_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        charset = determine_charset(charset_hint);
        doctype = flags & ENT_HTML_DOC_TYPE_MASK;
index 1161d76fe2b39ad04fbf694041163b9eeacd39a2..3e3d7ad500c68fb4b84ed552a88c98d09b3a1021 100644 (file)
@@ -191,9 +191,9 @@ PHP_FUNCTION(random_bytes)
        zend_long size;
        zend_string *bytes;
 
-       if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "l", &size) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
+               Z_PARAM_LONG(size)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (size < 1) {
                zend_throw_exception(zend_ce_error, "Length must be greater than 0", 0);
@@ -265,9 +265,10 @@ PHP_FUNCTION(random_int)
        zend_long max;
        zend_long result;
 
-       if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "ll", &min, &max) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 2, 2)
+               Z_PARAM_LONG(min)
+               Z_PARAM_LONG(max)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (min > max) {
                zend_throw_exception(zend_ce_error, "Minimum value must be less than or equal to the maximum value", 0);
index 9512e81475c7fb1015a28b156b8528972068c504..cfad769ff294462a330be4999a6a7e0b0e1862c4 100644 (file)
@@ -60,9 +60,10 @@ PHP_FUNCTION(soundex)
         0,                                                     /* Y */
         '2'};                                          /* Z */
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(str, str_len)
+       ZEND_PARSE_PARAMETERS_END();
+
        if (str_len == 0) {
                RETURN_FALSE;
        }